@instruktlabs/kiln 1.2.2 → 1.2.3

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 (214) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +74 -0
  4. package/README.md +7 -0
  5. package/dist/agent-run.mjs +6392 -1477
  6. package/dist/build.json +23 -23
  7. package/dist/cli.mjs +8453 -3407
  8. package/dist/evaluator-worker.mjs +16608 -12387
  9. package/dist/mcp-engine.mjs +6746 -1725
  10. package/dist/mcp-server.mjs +4 -4
  11. package/dist/viewer/app.js +203 -199
  12. package/dist/viewer/chat.html +209 -205
  13. package/dist/viewer/style.css +10 -0
  14. package/docs/atlas-provenance.md +23 -0
  15. package/docs/community-exporter.md +27 -0
  16. package/docs/export-profiles.md +20 -0
  17. package/docs/material-library.md +9 -5
  18. package/docs/procedural-surfaces-v3.md +276 -0
  19. package/docs/projects-and-live-review.md +1 -1
  20. package/docs/rendering.md +41 -0
  21. package/docs/sdk.md +53 -0
  22. package/docs/tools-operations.md +2 -2
  23. package/docs/tools.md +3 -3
  24. package/lib/asset-materials-node.d.ts +3 -3
  25. package/lib/asset-materials-node.js +29 -33
  26. package/lib/assets-node.d.ts +1 -1
  27. package/lib/assets-node.js +11 -4
  28. package/lib/assets.d.ts +4 -2
  29. package/lib/assets.js +61 -16
  30. package/lib/atlas-provenance.d.ts +86 -0
  31. package/lib/atlas-provenance.js +448 -0
  32. package/lib/character.d.ts +11 -2
  33. package/lib/character.js +90 -2
  34. package/lib/community-exporter.d.ts +3 -2
  35. package/lib/community-exporter.js +139 -3
  36. package/lib/discovery/helper-contracts.js +161 -7
  37. package/lib/discovery/helper-specs.js +49 -4
  38. package/lib/discovery/shapes.js +20 -7
  39. package/lib/engine-identity.d.ts +1 -1
  40. package/lib/engine-identity.js +1 -1
  41. package/lib/evaluator/authoring-diagnostic.d.ts +1 -1
  42. package/lib/evaluator/authoring-diagnostic.js +12 -0
  43. package/lib/evaluator/protocol.d.ts +2 -2
  44. package/lib/evaluator/protocol.js +16 -6
  45. package/lib/evaluator/subprocess.js +2 -2
  46. package/lib/exporter-node.js +9 -1
  47. package/lib/geometry-budget.d.ts +7 -0
  48. package/lib/geometry-budget.js +8 -0
  49. package/lib/gltf-texture-binding.d.ts +6 -0
  50. package/lib/gltf-texture-binding.js +54 -0
  51. package/lib/material-authoring-node.d.ts +6 -0
  52. package/lib/material-authoring-node.js +49 -0
  53. package/lib/material-authoring-schema.d.ts +871 -0
  54. package/lib/material-authoring-schema.js +310 -0
  55. package/lib/material-export.d.ts +5 -0
  56. package/lib/material-export.js +21 -0
  57. package/lib/material-library-node.d.ts +34 -8
  58. package/lib/material-library-node.js +691 -11
  59. package/lib/material-library.d.ts +3704 -4
  60. package/lib/material-library.js +272 -0
  61. package/lib/mcp-core.d.ts +1 -1
  62. package/lib/pinned-material-map.d.ts +33 -0
  63. package/lib/pinned-material-map.js +1 -0
  64. package/lib/portable-material-runtime.d.ts +5 -0
  65. package/lib/portable-material-runtime.js +160 -0
  66. package/lib/portable-sampler-runtime.d.ts +4 -0
  67. package/lib/portable-sampler-runtime.js +26 -0
  68. package/lib/portable-sampler.d.ts +11 -0
  69. package/lib/portable-sampler.js +42 -0
  70. package/lib/primitives.d.ts +15 -3
  71. package/lib/primitives.js +24 -4
  72. package/lib/procedural-material-v2.d.ts +2 -0
  73. package/lib/procedural-material-v2.js +2 -1
  74. package/lib/procedural-material-v3.d.ts +72 -0
  75. package/lib/procedural-material-v3.js +162 -0
  76. package/lib/procedural-texture-v2-compiler.d.ts +31 -0
  77. package/lib/procedural-texture-v2-compiler.js +172 -0
  78. package/lib/procedural-texture-v3-contract.d.ts +125 -0
  79. package/lib/procedural-texture-v3-contract.js +333 -0
  80. package/lib/procedural-texture-v3.d.ts +12 -0
  81. package/lib/procedural-texture-v3.js +165 -0
  82. package/lib/procedural-texture.d.ts +9 -31
  83. package/lib/procedural-texture.js +43 -170
  84. package/lib/project-bundle-node.d.ts +1 -1
  85. package/lib/project-bundle-node.js +70 -13
  86. package/lib/project-bundle.d.ts +91 -3
  87. package/lib/project-bundle.js +48 -7
  88. package/lib/qa/atlas.d.ts +21 -0
  89. package/lib/qa/atlas.js +474 -0
  90. package/lib/qa/index.d.ts +1 -0
  91. package/lib/qa/index.js +1 -0
  92. package/lib/qa/material.js +2 -0
  93. package/lib/qa/skin-integrity.d.ts +18 -0
  94. package/lib/qa/skin-integrity.js +221 -0
  95. package/lib/render-service-host.js +4 -7
  96. package/lib/render.d.ts +3 -3
  97. package/lib/render.js +108 -16
  98. package/lib/skin-binding.d.ts +20 -0
  99. package/lib/skin-binding.js +144 -0
  100. package/lib/texture-atlas-contract.d.ts +97 -0
  101. package/lib/texture-atlas-contract.js +414 -0
  102. package/lib/texture-atlas-pixels.d.ts +73 -0
  103. package/lib/texture-atlas-pixels.js +290 -0
  104. package/lib/texture-atlas.d.ts +10 -0
  105. package/lib/texture-atlas.js +143 -0
  106. package/lib/texture-bake.d.ts +3 -0
  107. package/lib/texture-bake.js +66 -11
  108. package/lib/texture-resolver.d.ts +22 -0
  109. package/lib/texture-resolver.js +24 -0
  110. package/lib/tools/materials.js +8 -7
  111. package/lib/tools/registry.js +5 -16
  112. package/lib/tools/review.js +1 -1
  113. package/lib/uv-data.d.ts +32 -0
  114. package/lib/uv-data.js +172 -0
  115. package/lib/uv-shapes.js +3 -0
  116. package/lib/uv.d.ts +9 -3
  117. package/lib/uv.js +53 -82
  118. package/lib/views/camera.d.ts +3 -3
  119. package/lib/views/camera.js +32 -28
  120. package/lib/views/face-policy.d.ts +9 -0
  121. package/lib/views/face-policy.js +16 -0
  122. package/lib/views/glb.js +218 -24
  123. package/lib/views/pose.d.ts +7 -1
  124. package/lib/views/pose.js +63 -12
  125. package/lib/views/raster.d.ts +6 -2
  126. package/lib/views/raster.js +49 -37
  127. package/lib/views/scene-copy.d.ts +6 -0
  128. package/lib/views/scene-copy.js +73 -0
  129. package/lib/views/scene-raster.js +2 -1
  130. package/lib/views/triangle-coverage.d.ts +8 -0
  131. package/lib/views/triangle-coverage.js +58 -0
  132. package/lib/workspace-node.js +7 -3
  133. package/lib/workspace.d.ts +2 -2
  134. package/package.json +3 -1
  135. package/plugin.json +1 -1
  136. package/plugins/kiln-engine/.claude-plugin/plugin.json +1 -1
  137. package/plugins/kiln-engine/README.md +3 -3
  138. package/plugins/kiln-engine/package-provenance.json +6 -6
  139. package/plugins/kiln-engine/plugin.json +1 -1
  140. package/plugins/kiln-engine/runtime.json +1 -1
  141. package/skills/kiln-author-asset/references/geometry-recipes.md +124 -0
  142. package/skills/kiln-author-asset/references/projects-and-materials.md +32 -2
  143. package/skills/kiln-compose-scene/references/runtime-scenes.md +19 -0
  144. package/skills/kiln-qa-asset/references/integration-checks.md +37 -2
  145. package/src/asset-materials-node.ts +38 -45
  146. package/src/assets-node.ts +22 -5
  147. package/src/assets.ts +61 -20
  148. package/src/atlas-provenance.ts +522 -0
  149. package/src/character.ts +107 -2
  150. package/src/community-exporter.ts +143 -3
  151. package/src/discovery/helper-contracts.ts +188 -7
  152. package/src/discovery/helper-specs.ts +69 -4
  153. package/src/discovery/shapes.ts +25 -9
  154. package/src/engine-identity.ts +1 -1
  155. package/src/evaluator/authoring-diagnostic.ts +19 -1
  156. package/src/evaluator/protocol.ts +19 -9
  157. package/src/evaluator/subprocess.ts +2 -2
  158. package/src/exporter-node.ts +12 -1
  159. package/src/generated/mcp-manifest.json +3 -3
  160. package/src/geometry-budget.ts +8 -0
  161. package/src/gltf-texture-binding.ts +60 -0
  162. package/src/material-authoring-node.ts +68 -0
  163. package/src/material-authoring-schema.ts +343 -0
  164. package/src/material-export.ts +25 -0
  165. package/src/material-library-node.ts +840 -16
  166. package/src/material-library.ts +348 -5
  167. package/src/pinned-material-map.ts +43 -0
  168. package/src/portable-material-runtime.ts +200 -0
  169. package/src/portable-sampler-runtime.ts +40 -0
  170. package/src/portable-sampler.ts +54 -0
  171. package/src/primitives.ts +98 -4
  172. package/src/procedural-material-v2.ts +2 -1
  173. package/src/procedural-material-v3.ts +224 -0
  174. package/src/procedural-texture-v2-compiler.ts +234 -0
  175. package/src/procedural-texture-v3-contract.ts +437 -0
  176. package/src/procedural-texture-v3.ts +220 -0
  177. package/src/procedural-texture.ts +61 -229
  178. package/src/project-bundle-node.ts +106 -14
  179. package/src/project-bundle.ts +61 -18
  180. package/src/project-cli.ts +29 -17
  181. package/src/qa/atlas.ts +597 -0
  182. package/src/qa/index.ts +1 -0
  183. package/src/qa/material.ts +2 -0
  184. package/src/qa/skin-integrity.ts +291 -0
  185. package/src/render-service-host.ts +4 -6
  186. package/src/render.ts +133 -15
  187. package/src/skin-binding.ts +225 -0
  188. package/src/texture-atlas-contract.ts +558 -0
  189. package/src/texture-atlas-pixels.ts +456 -0
  190. package/src/texture-atlas.ts +185 -0
  191. package/src/texture-bake.ts +88 -10
  192. package/src/texture-resolver.ts +55 -0
  193. package/src/tools/materials.ts +15 -11
  194. package/src/tools/registry.ts +5 -15
  195. package/src/tools/review.ts +1 -1
  196. package/src/uv-data.ts +238 -0
  197. package/src/uv-shapes.ts +3 -0
  198. package/src/uv.ts +73 -128
  199. package/src/viewer/app.ts +37 -0
  200. package/src/viewer/live-panel.ts +57 -1
  201. package/src/viewer/material-preview-panel.ts +140 -0
  202. package/src/viewer/material-preview.ts +138 -0
  203. package/src/viewer/materials-panel.ts +34 -5
  204. package/src/viewer/navigation.ts +2 -0
  205. package/src/views/camera.ts +37 -40
  206. package/src/views/face-policy.ts +20 -0
  207. package/src/views/glb.ts +294 -17
  208. package/src/views/pose.ts +71 -13
  209. package/src/views/raster.ts +73 -46
  210. package/src/views/scene-copy.ts +86 -0
  211. package/src/views/scene-raster.ts +2 -1
  212. package/src/views/triangle-coverage.ts +78 -0
  213. package/src/workspace-node.ts +11 -3
  214. package/src/workspace.ts +2 -2
@@ -122,13 +122,13 @@
122
122
  </div>
123
123
  <p id="status" role="status">Loading asset from Kiln…</p>
124
124
  <script type="module">
125
- var dd="186",Zi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},pd=0,dl=1,md=2;var Vs=1,gd=2,ss=3,qi=0,Qt=1,Pn=2,ii=0,$s=1,pl=2,ml=3,gl=4,_d=5;var os=100,xd=101,yd=102,vd=103,bd=104,Sd=200,Md=201,wd=202,Ed=203,Td=204,Ad=205,Rd=206,Cd=207,Pd=208,Id=209,Ld=210,Nd=211,Dd=212,Od=213,Ud=214,Fd=0,zd=1,kd=2,_l=3,Bd=4,Gd=5,Hd=6,Vd=7,$d=0,Wd=1,Zd=2,Hn=0,xl=1,yl=2,vl=3,Ws=4,bl=5,Sl=6,Ml=7;var as=301,vr=302,va=303,ba=304,Zs=306,cs=1000,ls=1001,Sa=1002,Vn=1003,Ma=1004;var br=1005;var $t=1006,us=1007;var ri=1008;var $n=1009,Xd=1010,qd=1011,Xs=1012,wl=1013,ji=1014,Ri=1015,si=1016,El=1017,Tl=1018,hs=1020,jd=35902,Yd=35899,Kd=1021,Jd=1022,oi=1023,Sr=1026,Mr=1027,Qd=1028,Al=1029,wr=1030,Rl=1031;var Cl=1033,wa=33776,Ea=33777,Ta=33778,Aa=33779,Pl=35840,Il=35841,Ll=35842,Nl=35843,Dl=36196,Ol=37492,Ul=37496,Fl=37488,zl=37489,Ra=37490,kl=37491,Bl=37808,Gl=37809,Hl=37810,Vl=37811,$l=37812,Wl=37813,Zl=37814,Xl=37815,ql=37816,jl=37817,Yl=37818,Kl=37819,Jl=37820,Ql=37821,eu=36492,tu=36494,nu=36495,iu=36283,ru=36284,Ca=36285,su=36286;var ou=2300,Pa=2301;var au=0,qs=1,fs=2;var cu=0,ep=1,Er="",Yi="srgb",gn="srgb-linear",lu="linear",dt="srgb";var tp=512,np=513,ip=514,Ia=515,rp=516,sp=517,La=518,op=519;var uu="300 es",hu=2000;function vv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function bv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ns(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ap(){let e=ns("canvas");return e.style.display="block",e}var Pf={},is=null;function Hs(...e){let t="THREE."+e.shift();if(is)is("log",t,...e);else console.log(t,...e)}function cp(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ie(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function xr(...e){let t=e.join(" ");if(t in Pf)return;Pf[t]=!0,Ie(...e)}function lp(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var up={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Wn{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var Kt=["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"],If=1234567,Bs=Math.PI/180,yr=180/Math.PI;function Gn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kt[e&255]+Kt[e>>8&255]+Kt[e>>16&255]+Kt[e>>24&255]+"-"+Kt[t&255]+Kt[t>>8&255]+"-"+Kt[t>>16&15|64]+Kt[t>>24&255]+"-"+Kt[n&63|128]+Kt[n>>8&255]+"-"+Kt[n>>16&255]+Kt[n>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function We(e,t,n){return Math.max(t,Math.min(n,e))}function fu(e,t){return(e%t+t)%t}function Sv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Mv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Gs(e,t,n){return(1-n)*e+n*t}function wv(e,t,n,i){return Gs(e,t,1-Math.exp(-n*i))}function Ev(e,t=1){return t-Math.abs(fu(e,t*2)-t)}function Tv(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Av(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Rv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Cv(e,t){return e+Math.random()*(t-e)}function Pv(e){return e*(0.5-Math.random())}function Iv(e){if(e!==void 0)If=e;let t=If+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Lv(e){return e*Bs}function Nv(e){return e*yr}function Dv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Ov(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Uv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Fv(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Bn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var js={DEG2RAD:Bs,RAD2DEG:yr,generateUUID:Gn,clamp:We,euclideanModulo:fu,mapLinear:Sv,inverseLerp:Mv,lerp:Gs,damp:wv,pingpong:Ev,smoothstep:Tv,smootherstep:Av,randInt:Rv,randFloat:Cv,randFloatSpread:Pv,seededRandom:Iv,degToRad:Lv,radToDeg:Nv,isPowerOfTwo:Dv,ceilPowerOfTwo:Ov,floorPowerOfTwo:Uv,setQuaternionFromProperEuler:Fv,normalize:ot,denormalize:Bn};class Ne{static{Ne.prototype.isVector2=!0}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 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 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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,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 n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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}}class O{static{O.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,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 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 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(Lf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Lf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hc.copy(this).projectOnVector(e),this.sub(Hc)}reflect(e){return this.sub(Hc.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 n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Hc=new O,Lf=new Ht;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],v=i[2],M=i[5],T=i[8];return r[0]=s*g+o*m+a*v,r[3]=s*x+o*E+a*M,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*v,r[4]=c*x+l*E+u*M,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*v,r[5]=f*x+h*E+d*M,r[8]=f*p+h*R+d*T,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],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,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,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return xr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vc.makeScale(e,t)),this}rotate(e){return xr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vc.makeRotation(-e)),this}translate(e,t){return xr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vc.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Vc=new ze,Nf=new ze().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Df=new ze().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function zv(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Ai(r.r),r.g=Ai(r.g),r.b=Ai(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ts(r.r),r.g=ts(r.g),r.b=ts(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=zv();function Ai(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Gr;class du{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(Gr===void 0)Gr=ns("canvas");Gr.width=e.width,Gr.height=e.height;let i=Gr.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Gr}return n.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=ns("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ai(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ai(t[n]/255)*255);else t[n]=Ai(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var kv=0;class Ys{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:kv++}),this.uuid=Gn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push($c(i[s].image));else r.push($c(i[s]))}else r=$c(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function $c(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return du.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ie("Texture: Unable to serialize Texture."),{}}var Bv=0,Wc=new O;class At extends Wn{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=At.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Bv++}),this.uuid=Gn(),this.name="",this.source=new Ys(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Wc).x}get height(){return this.source.getSize(Wc).y}get depth(){return this.source.getSize(Wc).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 n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={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};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=300;At.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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 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 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,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,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);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,v=(p+1)/2,M=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>v)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=M/n,r=T/n;else if(R>v)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=M/i,r=A/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}}class pu extends Wn{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,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},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new At(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].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,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Ys(i)}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"})}}class _n extends pu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Na extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,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()}}class mu extends At{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(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,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,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 Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Hr.setFromMatrixColumn(e,0).length(),r=1/Hr.setFromMatrixColumn(e,1).length(),s=1/Hr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}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(Gv,e,Hv)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),ki.crossVectors(n,pn),ki.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),ki.crossVectors(n,pn)}return ki.normalize(),Zo.crossVectors(pn,ki),i[0]=ki.x,i[4]=Zo.x,i[8]=pn.x,i[1]=ki.y,i[5]=Zo.y,i[9]=pn.y,i[2]=ki.z,i[6]=Zo.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],v=n[15],M=i[0],T=i[4],A=i[8],_=i[12],S=i[1],z=i[5],P=i[9],F=i[13],ee=i[2],I=i[6],H=i[10],q=i[14],C=i[3],X=i[7],k=i[11],Y=i[15];return r[0]=s*M+o*S+a*ee+c*C,r[4]=s*T+o*z+a*I+c*X,r[8]=s*A+o*P+a*H+c*k,r[12]=s*_+o*F+a*q+c*Y,r[1]=l*M+u*S+f*ee+h*C,r[5]=l*T+u*z+f*I+h*X,r[9]=l*A+u*P+f*H+h*k,r[13]=l*_+u*F+f*q+h*Y,r[2]=d*M+g*S+x*ee+p*C,r[6]=d*T+g*z+x*I+p*X,r[10]=d*A+g*P+x*H+p*k,r[14]=d*_+g*F+x*q+p*Y,r[3]=m*M+E*S+R*ee+v*C,r[7]=m*T+E*z+R*I+v*X,r[11]=m*A+E*P+R*H+v*k,r[15]=m*_+E*F+R*q+v*Y,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],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,v=s*h-c*l,M=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*v+p*M)+i*(d*E-g*v+p*T)-r*(d*R-g*M+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}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,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,v=n*a-i*o,M=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,S=l*p-h*d,z=u*x-f*g,P=u*p-h*g,F=f*p-h*x,ee=m*F-E*P+R*z+v*S-M*_+T*A;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/ee;return e[0]=(o*F-a*P+c*z)*I,e[1]=(i*P-n*F-r*z)*I,e[2]=(g*T-x*M+p*v)*I,e[3]=(f*M-u*T-h*v)*I,e[4]=(a*S-s*F-c*_)*I,e[5]=(t*F-i*S+r*_)*I,e[6]=(x*R-d*T-p*E)*I,e[7]=(l*T-f*R+h*E)*I,e[8]=(s*P-o*S+c*A)*I,e[9]=(n*S-t*P-r*A)*I,e[10]=(d*M-g*R+p*m)*I,e[11]=(u*R-l*M-h*m)*I,e[12]=(o*_-s*z-a*A)*I,e[13]=(t*z-n*_+i*A)*I,e[14]=(g*E-d*v-x*m)*I,e[15]=(l*v-u*E+f*m)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:v,y:M,z:T}=n;return i[0]=(1-(g+p))*v,i[1]=(h+R)*v,i[2]=(d-E)*v,i[3]=0,i[4]=(h-R)*M,i[5]=(1-(f+p))*M,i[6]=(x+m)*M,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Hr.set(i[0],i[1],i[2]).length(),o=Hr.set(i[4],i[5],i[6]).length(),a=Hr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Fn.copy(this);let c=1/s,l=1/o,u=1/a;return Fn.elements[0]*=c,Fn.elements[1]*=c,Fn.elements[2]*=c,Fn.elements[4]*=l,Fn.elements[5]*=l,Fn.elements[6]*=l,Fn.elements[8]*=u,Fn.elements[9]*=u,Fn.elements[10]*=u,t.setFromRotationMatrix(Fn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Hr=new O,Fn=new Ge,Gv=new O(0,0,0),Hv=new O(1,1,1),ki=new O,Zo=new O,pn=new O,Of=new Ge,Uf=new Ht;class ni{constructor(e=0,t=0,n=0,i=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(We(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-We(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(We(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-We(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(We(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-We(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Of.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Of,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Uf.setFromEuler(this),this.setFromQuaternion(Uf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}ni.DEFAULT_ORDER="XYZ";class Da{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}}var Vv=0,Ff=new O,Vr=new Ht,bi=new Ge,Xo=new O,Ls=new O,$v=new O,Wv=new Ht,zf=new O(1,0,0),kf=new O(0,1,0),Bf=new O(0,0,1),Gf={type:"added"},Zv={type:"removed"},$r={type:"childadded",child:null},Zc={type:"childremoved",child:null};class ut extends Wn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vv++}),this.uuid=Gn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new O,t=new ni,n=new Ht,i=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ge},normalMatrix:{value:new ze}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Da,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){if(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 Vr.setFromAxisAngle(e,t),this.quaternion.multiply(Vr),this}rotateOnWorldAxis(e,t){return Vr.setFromAxisAngle(e,t),this.quaternion.premultiply(Vr),this}rotateX(e){return this.rotateOnAxis(zf,e)}rotateY(e){return this.rotateOnAxis(kf,e)}rotateZ(e){return this.rotateOnAxis(Bf,e)}translateOnAxis(e,t){return Ff.copy(e).applyQuaternion(this.quaternion),this.position.add(Ff.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(zf,e)}translateY(e){return this.translateOnAxis(kf,e)}translateZ(e){return this.translateOnAxis(Bf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Xo.copy(e);else Xo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)bi.lookAt(Ls,Xo,this.up);else bi.lookAt(Xo,Ls,this.up);if(this.quaternion.setFromRotationMatrix(bi),i)bi.extractRotation(i.matrixWorld),Vr.setFromRotationMatrix(bi),this.quaternion.premultiply(Vr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zv),Zc.child=e,this.dispatchEvent(Zc),Zc.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),bi.multiply(e.parent.matrixWorld);return e.applyMatrix4(bi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.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 n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,$v),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,Wv,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(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{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}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 n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ut.DEFAULT_UP=new O(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ei extends ut{constructor(){super();this.isGroup=!0,this.type="Group"}}var Xv={type:"move"};class Ks{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Xv)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var hp={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},Bi={h:0,s:0,l:0},qo={h:0,s:0,l:0};function Xc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=fu(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Xc(s,r,e+0.3333333333333333),this.g=Xc(s,r,e),this.b=Xc(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ie("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=hp[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ie("Color: Unknown color "+e);return 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=Ai(e.r),this.g=Ai(e.g),this.b=Ai(e.b),this}copyLinearToSRGB(e){return this.r=ts(e.r),this.g=ts(e.g),this.b=ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(Jt.copy(this),e),Math.round(We(Jt.r*255,0,255))*65536+Math.round(We(Jt.g*255,0,255))*256+Math.round(We(Jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(Jt.copy(this),t);let{r:n,g:i,b:r}=Jt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(Jt.copy(this),e);let{r:t,g:n,b:i}=Jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Bi),this.setHSL(Bi.h+e,Bi.s+t,Bi.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Bi),e.getHSL(qo);let n=Gs(Bi.h,qo.h,t),i=Gs(Bi.s,qo.s,t),r=Gs(Bi.l,qo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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}}var Jt=new Oe;Oe.NAMES=hp;class ds extends ut{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(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();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return 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}}var zn=new O,Si=new O,qc=new O,Mi=new O,Wr=new O,Zr=new O,Hf=new O,jc=new O,Yc=new O,Kc=new O,Jc=new at,Qc=new at,el=new at;class Cn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zn.subVectors(e,t),i.cross(zn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){zn.subVectors(i,t),Si.subVectors(n,t),qc.subVectors(e,t);let s=zn.dot(zn),o=zn.dot(Si),a=zn.dot(qc),c=Si.dot(Si),l=Si.dot(qc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Mi)===null)return!1;return Mi.x>=0&&Mi.y>=0&&Mi.x+Mi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Mi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Mi.x),a.addScaledVector(s,Mi.y),a.addScaledVector(o,Mi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Jc.setScalar(0),Qc.setScalar(0),el.setScalar(0),Jc.fromBufferAttribute(e,t),Qc.fromBufferAttribute(e,n),el.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Jc,r.x),s.addScaledVector(Qc,r.y),s.addScaledVector(el,r.z),s}static isFrontFacing(e,t,n,i){return zn.subVectors(n,t),Si.subVectors(e,t),zn.cross(Si).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 zn.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),zn.cross(Si).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Cn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Cn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Cn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Cn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;Wr.subVectors(i,n),Zr.subVectors(r,n),jc.subVectors(e,n);let a=Wr.dot(jc),c=Zr.dot(jc);if(a<=0&&c<=0)return t.copy(n);Yc.subVectors(e,i);let l=Wr.dot(Yc),u=Zr.dot(Yc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Wr,s);Kc.subVectors(e,r);let h=Wr.dot(Kc),d=Zr.dot(Kc);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Zr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return Hf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(Hf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Wr,s).addScaledVector(Zr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new O(1/0,1/0,1/0),t=new O(-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,n=e.length;t<n;t+=3)this.expandByPoint(kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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(0.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 n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,kn);else kn.fromBufferAttribute(r,s);kn.applyMatrix4(e.matrixWorld),this.expandByPoint(kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();jo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();jo.copy(n.boundingBox)}jo.applyMatrix4(e.matrixWorld),this.union(jo)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],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,kn),kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ns),Yo.subVectors(this.max,Ns),Xr.subVectors(e.a,Ns),qr.subVectors(e.b,Ns),jr.subVectors(e.c,Ns),Gi.subVectors(qr,Xr),Hi.subVectors(jr,qr),pr.subVectors(Xr,jr);let t=[0,-Gi.z,Gi.y,0,-Hi.z,Hi.y,0,-pr.z,pr.y,Gi.z,0,-Gi.x,Hi.z,0,-Hi.x,pr.z,0,-pr.x,-Gi.y,Gi.x,0,-Hi.y,Hi.x,0,-pr.y,pr.x,0];if(!tl(t,Xr,qr,jr,Yo))return!1;if(t=[1,0,0,0,1,0,0,0,1],!tl(t,Xr,qr,jr,Yo))return!1;return Ko.crossVectors(Gi,Hi),t=[Ko.x,Ko.y,Ko.z],tl(t,Xr,qr,jr,Yo)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wi),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}}var wi=[new O,new O,new O,new O,new O,new O,new O,new O],kn=new O,jo=new Ft,Xr=new O,qr=new O,jr=new O,Gi=new O,Hi=new O,pr=new O,Ns=new O,Yo=new O,Ko=new O,mr=new O;function tl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){mr.fromArray(e,s);let a=r.x*Math.abs(mr.x)+r.y*Math.abs(mr.y)+r.z*Math.abs(mr.z),c=t.dot(mr),l=n.dot(mr),u=i.dot(mr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Nt=new O,Jo=new Ne,qv=0;class Vt extends Wn{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:qv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Jo.fromBufferAttribute(this,t),Jo.applyMatrix3(e),this.setXY(t,Jo.x,Jo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Bn(t,this.array);return t}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Bn(t,this.array);return t}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Bn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Bn(t,this.array);return t}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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"})}}class Oa extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ua extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class un extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var jv=new Ft,Ds=new O,nl=new O;class xn{constructor(e=new O,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 n=this.center;if(t!==void 0)n.copy(t);else jv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;Ds.subVectors(e,this.center);let t=Ds.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ds,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else nl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(nl)),this.expandByPoint(Ds.copy(e.center).sub(nl));return 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}}var Yv=0,An=new Ge,il=new ut,Yr=new O,mn=new Ft,Os=new Ft,Gt=new O;class en extends Wn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yv++}),this.uuid=Gn(),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){if(Array.isArray(e))this.index=new((vv(e))?Ua:Oa)(e,1);else this.index=e;return 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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return An.makeRotationFromQuaternion(e),this.applyMatrix4(An),this}rotateX(e){return An.makeRotationX(e),this.applyMatrix4(An),this}rotateY(e){return An.makeRotationY(e),this.applyMatrix4(An),this}rotateZ(e){return An.makeRotationZ(e),this.applyMatrix4(An),this}translate(e,t,n){return An.makeTranslation(e,t,n),this.applyMatrix4(An),this}scale(e,t,n){return An.makeScale(e,t,n),this.applyMatrix4(An),this}lookAt(e){return il.lookAt(e),il.updateMatrix(),this.applyMatrix4(il.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yr).negate(),this.translate(Yr.x,Yr.y,Yr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new un(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ft;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(mn.setFromBufferAttribute(r),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,mn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,mn.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(mn.min),this.boundingBox.expandByPoint(mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Os.setFromBufferAttribute(o),this.morphTargetsRelative)Gt.addVectors(mn.min,Os.min),mn.expandByPoint(Gt),Gt.addVectors(mn.max,Os.max),mn.expandByPoint(Gt);else mn.expandByPoint(Os.min),mn.expandByPoint(Os.max)}mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Gt.fromBufferAttribute(o,c),a)Yr.fromBufferAttribute(e,c),Gt.add(Yr);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('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){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new O,a[A]=new O;let c=new O,l=new O,u=new O,f=new Ne,h=new Ne,d=new Ne,g=new O,x=new O;function p(A,_,S){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,S),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,S),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let z=1/(h.x*d.y-d.x*h.y);if(!isFinite(z))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(z),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(z),o[A].add(g),o[_].add(g),o[S].add(g),a[A].add(x),a[_].add(x),a[S].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)p(e.getX(F+0),e.getX(F+1),e.getX(F+2))}let E=new O,R=new O,v=new O,M=new O;function T(A){v.fromBufferAttribute(i,A),M.copy(v);let _=o[A];E.copy(_),E.sub(v.multiplyScalar(v.dot(_))).normalize(),R.crossVectors(M,_);let z=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,z)}for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)T(e.getX(F+0)),T(e.getX(F+1)),T(e.getX(F+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new O,r=new O,s=new O,o=new O,a=new O,c=new O,l=new O,u=new O;if(e)for(let f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Vt(f,l,u)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new en,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.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;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return 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 n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return 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"})}}class Js{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Gn()}onUploadCallback(){}set needsUpdate(e){if(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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var sn=new O;class ps{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyMatrix4(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyNormalMatrix(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.transformDirection(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Bn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Bn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Bn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Bn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Hs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Vt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new ps(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Hs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var rl=new O,Kv=new O,Jv=new ze;class Rn{constructor(e=new O(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=rl.subVectors(n,t).cross(Kv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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,n=!0){let i=e.delta(rl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Jv.getNormalMatrix(e),i=this.coplanarPoint(rl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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}}var Qv=0;class hn extends Wn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qv++}),this.uuid=Gn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Rn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return 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,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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){if(e===!0)this.version++}}var Ei=new O,sl=new O,Qo=new O,ea=new O;class Ki{constructor(e=new O,t=new O(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,Ei)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ei.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Ei.copy(this.origin).addScaledVector(this.direction,t),Ei.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){sl.copy(e).add(t).multiplyScalar(0.5),Qo.copy(t).sub(e).normalize(),ea.copy(this.origin).sub(sl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Qo),o=ea.dot(this.direction),a=-ea.dot(Qo),c=ea.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(sl).addScaledVector(Qo,f);return h}intersectSphere(e,t){if(e.radius<0)return null;Ei.subVectors(e.center,this.origin);let n=Ei.dot(this.direction),i=Ei.dot(Ei)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ei)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),v=Math.abs(c),M=Math.abs(l),T,A,_,S,z,P,F,ee,I,H,q,C;if(R>=v&&R>=M)if(_=a,P=u,I=d,C=p,a>=0)T=c,A=l,S=f,z=h,F=g,ee=x,H=m,q=E;else T=l,A=c,S=h,z=f,F=x,ee=g,H=E,q=m;else if(v>=M)if(_=c,P=f,I=g,C=m,c>=0)T=l,A=a,S=h,z=u,F=x,ee=d,H=E,q=p;else T=a,A=l,S=u,z=h,F=d,ee=x,H=p,q=E;else if(_=l,P=h,I=x,C=E,l>=0)T=a,A=c,S=u,z=f,F=d,ee=g,H=p,q=m;else T=c,A=a,S=f,z=u,F=g,ee=d,H=m,q=p;if(_===0)return null;let X=T/_,k=A/_,Y=1/_,Q=S-X*P,Se=z-k*P,ue=F-X*I,Fe=ee-k*I,Me=H-X*C,Z=q-k*C,re=Me*Fe-Z*ue,se=Q*Z-Se*Me,xe=ue*Se-Fe*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let we=re+se+xe;if(we===0)return null;let Ee=Y*(re*P+se*I+xe*C);if(we>0?Ee<0:Ee>0)return null;return this.at(Ee/we,r)}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)}}class ai extends hn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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 ni,this.combine=0,this.reflectivity=1,this.refractionRatio=0.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}}var Vf=new Ge,gr=new Ki,ta=new xn,$f=new O,na=new O,ia=new O,ra=new O,ol=new O,sa=new O,Wf=new O,oa=new O;class _t extends ut{constructor(e=new en,t=new ai){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){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){sa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(ol.fromBufferAttribute(u,e),s)sa.addScaledVector(ol,l);else sa.addScaledVector(ol.sub(t),l)}t.add(sa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(ta.copy(n.boundingSphere),ta.applyMatrix4(r),gr.copy(e.ray).recast(e.near),ta.containsPoint(gr.origin)===!1){if(gr.intersectSphere(ta,$f)===null)return;if(gr.origin.distanceToSquared($f)>(e.far-e.near)**2)return}if(Vf.copy(r).invert(),gr.copy(e.ray).applyMatrix4(Vf),n.boundingBox!==null){if(gr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,gr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=R,T=R+1,A=R+2;if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function eb(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;oa.copy(a),oa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(oa);if(l<n.near||l>n.far)return null;return{distance:l,point:oa.clone(),object:e}}function aa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,na),e.getVertexPosition(c,ia),e.getVertexPosition(l,ra);let u=eb(e,t,n,i,na,ia,ra,Wf);if(u){let f=new O;if(Cn.getBarycoord(Wf,na,ia,ra,f),r)u.uv=Cn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Cn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Cn.getInterpolatedAttribute(o,a,c,l,f,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new O,materialIndex:0};Cn.getNormal(na,ia,ra,h.normal),u.face=h,u.barycoord=f}return u}var Us=new at,Zf=new at,Xf=new at,tb=new at,qf=new Ge,ca=new O,al=new xn,jf=new Ge,cl=new Ki;class Fa extends _t{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Ft;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingBox.expandByPoint(ca)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingSphere.expandByPoint(ca)}copy(e,t){if(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();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(al.copy(this.boundingSphere),al.applyMatrix4(i),e.ray.intersectsSphere(al)===!1)return;if(jf.copy(i).invert(),cl.copy(e.ray).applyMatrix4(jf),this.boundingBox!==null){if(cl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,cl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(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 at,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Zf.fromBufferAttribute(i.attributes.skinIndex,e),Xf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Us.copy(t),t.set(0,0,0,0);else Us.set(...t,1),t.set(0,0,0);Us.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Xf.getComponent(r);if(s!==0){let o=Zf.getComponent(r);qf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(tb.copy(Us).applyMatrix4(qf),s)}}if(t.isVector4)t.w=Us.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Qs extends ut{constructor(){super();this.isBone=!0,this.type="Bone"}}class eo extends At{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Yf=new Ge,nb=new Ge;class to{constructor(e=[],t=[]){this.uuid=Gn(),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){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:nb;Yf.multiplyMatrices(o,t[r]),Yf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new to(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 n=new eo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ie("Skeleton: No bone found with UUID:",r),s=new Qs;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class Wi extends Vt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}}var Kr=new Ge,Kf=new Ge,la=[],Jf=new Ft,ib=new Ge,Fs=new _t,zs=new xn;class ms extends _t{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Wi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ib)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Ft;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),Jf.copy(e.boundingBox).applyMatrix4(Kr),this.boundingBox.union(Jf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),zs.copy(e.boundingSphere).applyMatrix4(Kr),this.boundingSphere.union(zs)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Fs.geometry=this.geometry,Fs.material=this.material,Fs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(zs.copy(this.boundingSphere),zs.applyMatrix4(n),e.ray.intersectsSphere(zs)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Kr),Kf.multiplyMatrices(n,Kr),Fs.matrixWorld=Kf,Fs.raycast(e,la);for(let s=0,o=la.length;s<o;s++){let a=la[s];a.instanceId=r,a.object=this,t.push(a)}la.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Wi(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new eo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var _r=new xn,rb=new Ne(0.5,0.5),ua=new O;class no{constructor(e=new Rn,t=new Rn,n=new Rn,i=new Rn,r=new Rn,s=new Rn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],v=r[15];if(i[0].setComponents(c-s,h-l,p-d,v-m).normalize(),i[1].setComponents(c+s,h+l,p+d,v+m).normalize(),i[2].setComponents(c+o,h+u,p+g,v+E).normalize(),i[3].setComponents(c-o,h-u,p-g,v-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,v-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,v-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,v+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();_r.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();_r.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_r)}intersectsSprite(e){_r.center.set(0,0,0);let t=rb.distanceTo(e.center);return _r.radius=0.7071067811865476+t,_r.applyMatrix4(e.matrixWorld),this.intersectsSphere(_r)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ua.x=i.normal.x>0?e.max.x:e.min.x,ua.y=i.normal.y>0?e.max.y:e.min.y,ua.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ua)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class io extends hn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var xa=new O,ya=new O,Qf=new Ge,ks=new Ki,ha=new xn,ll=new O,ed=new O;class Ji extends ut{constructor(e=new en,t=new io){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)xa.fromBufferAttribute(t,i-1),ya.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=xa.distanceTo(ya);e.setAttribute("lineDistance",new un(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(ha.copy(n.boundingSphere),ha.applyMatrix4(i),ha.radius+=r,e.ray.intersectsSphere(ha)===!1)return;Qf.copy(i).invert(),ks.copy(e.ray).applyMatrix4(Qf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=fa(this,e,ks,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=fa(this,e,ks,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=fa(this,e,ks,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=fa(this,e,ks,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function fa(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(xa.fromBufferAttribute(a,r),ya.fromBufferAttribute(a,s),n.distanceSqToSegment(xa,ya,ll,ed)>i)return;ll.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ll);if(l<t.near||l>t.far)return;return{distance:l,point:ed.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var td=new O,nd=new O;class za extends Ji{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)td.fromBufferAttribute(t,i),nd.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+td.distanceTo(nd);e.setAttribute("lineDistance",new un(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ka extends Ji{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ro extends hn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var id=new Ge,fl=new Ki,da=new xn,pa=new O;class gs extends ut{constructor(e=new en,t=new ro){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(da.copy(n.boundingSphere),da.applyMatrix4(i),da.radius+=r,e.ray.intersectsSphere(da)===!1)return;id.copy(i).invert(),fl.copy(e.ray).applyMatrix4(id);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);pa.fromBufferAttribute(u,x),rd(pa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)pa.fromBufferAttribute(u,d),rd(pa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function rd(e,t,n,i,r,s,o){let a=fl.distanceSqToPoint(e);if(a<n){let c=new O;fl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class Ba extends At{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Tr extends At{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ys(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class gu extends Tr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Ga extends At{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Qi extends en{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new un(c,3)),this.setAttribute("normal",new un(l,3)),this.setAttribute("uv",new un(u,2));function d(g,x,p,m,E,R,v,M,T,A,_){let S=R/T,z=v/A,P=R/2,F=v/2,ee=M/2,I=T+1,H=A+1,q=0,C=0,X=new O;for(let k=0;k<H;k++){let Y=k*z-F;for(let Q=0;Q<I;Q++){let Se=Q*S-P;X[g]=Se*m,X[x]=Y*E,X[p]=ee,c.push(X.x,X.y,X.z),X[g]=0,X[x]=0,X[p]=M>0?1:-1,l.push(X.x,X.y,X.z),u.push(Q/T),u.push(1-k/A),q+=1}}for(let k=0;k<A;k++)for(let Y=0;Y<T;Y++){let Q=f+Y+I*k,Se=f+Y+I*(k+1),ue=f+(Y+1)+I*(k+1),Fe=f+(Y+1)+I*k;a.push(Q,Se,Fe),a.push(Se,ue,Fe),C+=6}o.addGroup(h,C,_),h+=C,f+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class so extends en{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),v=m+1+c*(p+1),M=m+1+c*p;h.push(E,R,M),h.push(R,v,M)}this.setIndex(h),this.setAttribute("position",new un(d,3)),this.setAttribute("normal",new un(g,3)),this.setAttribute("uv",new un(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new so(e.width,e.height,e.widthSegments,e.heightSegments)}}function Ar(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(sd(r))if(r.isRenderTargetTexture)Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(sd(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Ar(e[n]);for(let r in i)t[r]=i[r]}return t}function sd(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function sb(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function _u(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var fp={clone:Ar,merge:tn},ob=`void main() {
125
+ var ap="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},cp=0,ql=1,lp=2;var po=1,up=2,Ss=3,ur=0,sn=1,kn=2,fi=0,mo=1,Yl=2,Jl=3,Kl=4,hp=5;var Ms=100,dp=101,fp=102,pp=103,mp=104,gp=200,_p=201,xp=202,yp=203,vp=204,bp=205,Sp=206,Mp=207,wp=208,Ep=209,Ap=210,Tp=211,Rp=212,Cp=213,Pp=214,Ip=0,Lp=1,Np=2,Ql=3,Dp=4,Op=5,Up=6,Fp=7,zp=0,kp=1,Bp=2,Kn=0,eu=1,tu=2,nu=3,go=4,iu=5,ru=6,su=7;var ws=301,Or=302,Ya=303,Ja=304,_o=306,Es=1000,As=1001,Ka=1002,Qn=1003,Qa=1004;var Ur=1005;var qt=1006,Ts=1007;var pi=1008;var ei=1009,Vp=1010,Gp=1011,xo=1012,ou=1013,hr=1014,Hi=1015,mi=1016,au=1017,cu=1018,Rs=1020,Hp=35902,$p=35899,Wp=1021,Zp=1022,gi=1023,Fr=1026,zr=1027,Xp=1028,lu=1029,kr=1030,uu=1031;var hu=1033,ec=33776,tc=33777,nc=33778,ic=33779,du=35840,fu=35841,pu=35842,mu=35843,gu=36196,_u=37492,xu=37496,yu=37488,vu=37489,rc=37490,bu=37491,Su=37808,Mu=37809,wu=37810,Eu=37811,Au=37812,Tu=37813,Ru=37814,Cu=37815,Pu=37816,Iu=37817,Lu=37818,Nu=37819,Du=37820,Ou=37821,Uu=36492,Fu=36494,zu=36495,ku=36283,Bu=36284,sc=36285,Vu=36286;var Gu=2300,oc=2301;var Hu=0,yo=1,Cs=2;var $u=0,jp=1,Br="",dr="srgb",wn="srgb-linear",Wu="linear",yt="srgb";var qp=512,Yp=513,Jp=514,ac=515,Kp=516,Qp=517,cc=518,em=519;var Zu="300 es",Xu=2000;function Ab(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Tb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ys(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function tm(){let e=ys("canvas");return e.style.display="block",e}var wf={},vs=null;function fo(...e){let t="THREE."+e.shift();if(vs)vs("log",t,...e);else console.log(t,...e)}function nm(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Le(...e){e=nm(e);let t="THREE."+e.shift();if(vs)vs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ze(...e){e=nm(e);let t="THREE."+e.shift();if(vs)vs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in wf)return;wf[t]=!0,Le(...e)}function im(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var rm={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ti{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var nn=["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"],Ef=1234567,uo=Math.PI/180,Dr=180/Math.PI;function Jn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nn[e&255]+nn[e>>8&255]+nn[e>>16&255]+nn[e>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[n&63|128]+nn[n>>8&255]+"-"+nn[n>>16&255]+nn[n>>24&255]+nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function ju(e,t){return(e%t+t)%t}function Rb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Cb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function ho(e,t,n){return(1-n)*e+n*t}function Pb(e,t,n,i){return ho(e,t,1-Math.exp(-n*i))}function Ib(e,t=1){return t-Math.abs(ju(e,t*2)-t)}function Lb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Nb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Db(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ob(e,t){return e+Math.random()*(t-e)}function Ub(e){return e*(0.5-Math.random())}function Fb(e){if(e!==void 0)Ef=e;let t=Ef+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function zb(e){return e*uo}function kb(e){return e*Dr}function Bb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Vb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Gb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Hb(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*h,c*d,a*l);break;case"YZY":e.set(c*d,a*u,c*h,a*l);break;case"ZXZ":e.set(c*h,c*d,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Yn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function dt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var vo={DEG2RAD:uo,RAD2DEG:Dr,generateUUID:Jn,clamp:qe,euclideanModulo:ju,mapLinear:Rb,inverseLerp:Cb,lerp:ho,damp:Pb,pingpong:Ib,smoothstep:Lb,smootherstep:Nb,randInt:Db,randFloat:Ob,randFloatSpread:Ub,seededRandom:Fb,degToRad:zb,radToDeg:kb,isPowerOfTwo:Bb,ceilPowerOfTwo:Vb,floorPowerOfTwo:Gb,setQuaternionFromProperEuler:Hb,normalize:dt,denormalize:Yn};class De{static{De.prototype.isVector2=!0}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 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 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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,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 n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==h||c!==d||l!==f){let _=a*h+c*d+l*f+u*m;if(_<0)h=-h,d=-d,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+h*o,c=c*p+d*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],h=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*d-c*h,e[t+1]=a*f+l*h+c*u-o*d,e[t+2]=c*f+l*d+o*h-a*u,e[t+3]=l*f-o*u-a*h-c*d,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),h=a(n/2),d=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"YXZ":this._x=h*l*u+c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"ZXY":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u-h*d*f;break;case"ZYX":this._x=h*l*u-c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u+h*d*f;break;case"YZX":this._x=h*l*u+c*d*f,this._y=c*d*u+h*l*f,this._z=c*l*f-h*d*u,this._w=c*l*u-h*d*f;break;case"XZY":this._x=h*l*u-c*d*f,this._y=c*d*u-h*l*f,this._z=c*l*f+h*d*u,this._w=c*l*u+h*d*f;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],h=n+o+u;if(h>0){let d=0.5/Math.sqrt(h+1);this._w=0.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(s-i)*d}else if(n>o&&n>u){let d=2*Math.sqrt(1+n-o-u);this._w=(l-a)/d,this._x=0.25*d,this._y=(i+s)/d,this._z=(r+c)/d}else if(o>u){let d=2*Math.sqrt(1+o-n-u);this._w=(r-c)/d,this._x=(i+s)/d,this._y=0.25*d,this._z=(a+l)/d}else{let d=2*Math.sqrt(1+u-n-o);this._w=(s-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=0.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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}}class U{static{U.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,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 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 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(Af.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Af.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return wl.copy(this).projectOnVector(e),this.sub(wl)}reflect(e){return this.sub(wl.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 n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var wl=new U,Af=new Xt;class Ve{static{Ve.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],h=n[2],d=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=h*m+d*g+f*y,r[5]=h*_+d*S+f*w,r[8]=h*p+d*T+f*A,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],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,h=o*a-l*r,d=c*r-s*a,f=t*u+n*h+i*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=h*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,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,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(El.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(El.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(El.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var El=new Ve,Tf=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Rf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function $b(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Gi(r.r),r.g=Gi(r.g),r.b=Gi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=xs(r.r),r.g=xs(r.g),r.b=xs(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Tf,fromXYZ:Rf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Tf,fromXYZ:Rf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=$b();function Gi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function xs(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var rs;class qu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(rs===void 0)rs=ys("canvas");rs.width=e.width,rs.height=e.height;let i=rs.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=rs}return n.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=ys("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Gi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Gi(t[n]/255)*255);else t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Wb=0;class bo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Wb++}),this.uuid=Jn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Al(i[s].image));else r.push(Al(i[s]))}else r=Al(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Al(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return qu.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Le("Texture: Unable to serialize Texture."),{}}var Zb=0,Tl=new U;class Nt extends ti{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Zb++}),this.uuid=Jn(),this.name="",this.source=new bo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new De(0,0),this.repeat=new De(1,1),this.center=new De(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Tl).x}get height(){return this.source.getSize(Tl).y}get depth(){return this.source.getSize(Tl).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 n=e[t];if(n===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={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};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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 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 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,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,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);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],h=a[1],d=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-h)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+h)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+d+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(d+1)/2,y=(p+1)/2,w=(l+h)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(h-l)*(h-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(h-l)/g,this.w=Math.acos((c+d+p-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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}}class Yu extends ti{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,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},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].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,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new bo(i)}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"})}}class En extends Yu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class lc extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,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()}}class Ju extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class $e{static{$e.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){if(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,n,i,r,s,o,a,c,l,u,h,d,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,h,d,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=h,p[3]=d,p[7]=f,p[11]=m,p[15]=_,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 $e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/ss.setFromMatrixColumn(e,0).length(),r=1/ss.setFromMatrixColumn(e,1).length(),s=1/ss.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=d+f*c,t[5]=h-m*c,t[9]=-o*a,t[2]=m-h*c,t[6]=f+d*c,t[10]=s*a}else if(e.order==="YXZ"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h+m*o,t[4]=f*o-d,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=d*o-f,t[6]=m+h*o,t[10]=s*a}else if(e.order==="ZXY"){let h=a*l,d=a*u,f=c*l,m=c*u;t[0]=h-m*o,t[4]=-s*u,t[8]=f+d*o,t[1]=d+f*o,t[5]=s*l,t[9]=m-h*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let h=s*l,d=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-d,t[8]=h*c+m,t[1]=a*u,t[5]=m*c+h,t[9]=d*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-h*u,t[8]=f*u+d,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=d*u+f,t[10]=h-m*u}else if(e.order==="XZY"){let h=s*a,d=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=h*u+m,t[5]=s*l,t[9]=d*u-f,t[2]=f*u-d,t[6]=o*l,t[10]=m*u+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(Xb,e,jb)}lookAt(e,t,n){let i=this.elements;if(Sn.subVectors(e,t),Sn.lengthSq()===0)Sn.z=1;if(Sn.normalize(),tr.crossVectors(n,Sn),tr.lengthSq()===0){if(Math.abs(n.z)===1)Sn.x+=0.0001;else Sn.z+=0.0001;Sn.normalize(),tr.crossVectors(n,Sn)}return tr.normalize(),Sa.crossVectors(Sn,tr),i[0]=tr.x,i[4]=Sa.x,i[8]=Sn.x,i[1]=tr.y,i[5]=Sa.y,i[9]=Sn.y,i[2]=tr.z,i[6]=Sa.z,i[10]=Sn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+h*K+d*P,r[5]=l*A+u*z+h*I+d*j,r[9]=l*R+u*C+h*G+d*k,r[13]=l*x+u*L+h*X+d*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*q,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],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],h=e[10],d=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*d-c*h,S=o*d-c*u,T=o*h-a*u,y=s*d-c*l,w=s*h-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}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,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-h*f,M=l*p-d*f,z=u*_-h*m,C=u*p-d*m,L=h*p-d*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(h*w-u*A-d*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-h*T+d*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-d*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+h*g)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,h=r*c,d=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(d+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(d-T)*w,i[5]=(1-(h+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(h+m))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=ss.set(i[0],i[1],i[2]).length(),o=ss.set(i[4],i[5],i[6]).length(),a=ss.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Xn.copy(this);let c=1/s,l=1/o,u=1/a;return Xn.elements[0]*=c,Xn.elements[1]*=c,Xn.elements[2]*=c,Xn.elements[4]*=l,Xn.elements[5]*=l,Xn.elements[6]*=l,Xn.elements[8]*=u,Xn.elements[9]*=u,Xn.elements[10]*=u,t.setFromRotationMatrix(Xn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),d=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=u,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var ss=new U,Xn=new $e,Xb=new U(0,0,0),jb=new U(1,1,1),tr=new U,Sa=new U,Sn=new U,Cf=new $e,Pf=new Xt;class di{constructor(e=0,t=0,n=0,i=di.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],h=i[6],d=i[10];switch(t){case"XYZ":if(this._y=Math.asin(qe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,r);else this._x=Math.atan2(h,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-qe(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,d),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(qe(h,-1,1)),Math.abs(h)<0.9999999)this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-qe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(h,d),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(qe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,d);break;case"XZY":if(this._z=Math.asin(-qe(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(h,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,d),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Cf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pf.setFromEuler(this),this.setFromQuaternion(Pf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}di.DEFAULT_ORDER="XYZ";class uc{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}}var qb=0,If=new U,os=new Xt,Ui=new $e,Ma=new U,no=new U,Yb=new U,Jb=new Xt,Lf=new U(1,0,0),Nf=new U(0,1,0),Df=new U(0,0,1),Of={type:"added"},Kb={type:"removed"},as={type:"childadded",child:null},Rl={type:"childremoved",child:null};class gt extends ti{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:qb++}),this.uuid=Jn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new di,n=new Xt,i=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uc,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){if(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 os.setFromAxisAngle(e,t),this.quaternion.multiply(os),this}rotateOnWorldAxis(e,t){return os.setFromAxisAngle(e,t),this.quaternion.premultiply(os),this}rotateX(e){return this.rotateOnAxis(Lf,e)}rotateY(e){return this.rotateOnAxis(Nf,e)}rotateZ(e){return this.rotateOnAxis(Df,e)}translateOnAxis(e,t){return If.copy(e).applyQuaternion(this.quaternion),this.position.add(If.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Lf,e)}translateY(e){return this.translateOnAxis(Nf,e)}translateZ(e){return this.translateOnAxis(Df,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ui.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ma.copy(e);else Ma.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),no.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Ui.lookAt(no,Ma,this.up);else Ui.lookAt(Ma,no,this.up);if(this.quaternion.setFromRotationMatrix(Ui),i)Ui.extractRotation(i.matrixWorld),os.setFromRotationMatrix(Ui),this.quaternion.premultiply(os.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return ze("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Of),as.child=e,this.dispatchEvent(as),as.child=null;else ze("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Kb),Rl.child=e,this.dispatchEvent(Rl),Rl.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Ui.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Ui.multiply(e.parent.matrixWorld);return e.applyMatrix4(Ui),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Of),as.child=e,this.dispatchEvent(as),as.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 n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(no,e,Yb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(no,Jb,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(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{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),h=s(e.skeletons),d=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(h.length>0)n.skeletons=h;if(d.length>0)n.animations=d;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}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 n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ui extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Qb={type:"move"};class So{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ui,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ui,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ui,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=l.position.distanceTo(u.position),d=0.02,f=0.005;if(c.inputState.pinching&&h>d+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&h<=d-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Qb)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ui;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var sm={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},nr={h:0,s:0,l:0},wa={h:0,s:0,l:0};function Cl(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Ue{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=ju(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Cl(s,r,e+0.3333333333333333),this.g=Cl(s,r,e),this.b=Cl(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=sm[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("Color: Unknown color "+e);return 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=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=xs(e.r),this.g=xs(e.g),this.b=xs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(rn.copy(this),e),Math.round(qe(rn.r*255,0,255))*65536+Math.round(qe(rn.g*255,0,255))*256+Math.round(qe(rn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(rn.copy(this),t);let{r:n,g:i,b:r}=rn,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(rn.copy(this),t),e.r=rn.r,e.g=rn.g,e.b=rn.b,e}getStyle(e="srgb"){je.workingToColorSpace(rn.copy(this),e);let{r:t,g:n,b:i}=rn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(wa);let n=ho(nr.h,wa.h,t),i=ho(nr.s,wa.s,t),r=ho(nr.l,wa.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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}}var rn=new Ue;Ue.NAMES=sm;class Ps extends gt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new di,this.environmentIntensity=1,this.environmentRotation=new di,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(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();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return 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}}var jn=new U,Fi=new U,Pl=new U,zi=new U,cs=new U,ls=new U,Uf=new U,Il=new U,Ll=new U,Nl=new U,Dl=new ft,Ol=new ft,Ul=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),jn.subVectors(e,t),i.cross(jn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){jn.subVectors(i,t),Fi.subVectors(n,t),Pl.subVectors(e,t);let s=jn.dot(jn),o=jn.dot(Fi),a=jn.dot(Pl),c=Fi.dot(Fi),l=Fi.dot(Pl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let h=1/u,d=(c*a-o*l)*h,f=(s*l-o*a)*h;return r.set(1-d-f,f,d)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,zi)===null)return!1;return zi.x>=0&&zi.y>=0&&zi.x+zi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,zi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,zi.x),a.addScaledVector(s,zi.y),a.addScaledVector(o,zi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Dl.setScalar(0),Ol.setScalar(0),Ul.setScalar(0),Dl.fromBufferAttribute(e,t),Ol.fromBufferAttribute(e,n),Ul.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Dl,r.x),s.addScaledVector(Ol,r.y),s.addScaledVector(Ul,r.z),s}static isFrontFacing(e,t,n,i){return jn.subVectors(n,t),Fi.subVectors(e,t),jn.cross(Fi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 jn.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),jn.cross(Fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;cs.subVectors(i,n),ls.subVectors(r,n),Il.subVectors(e,n);let a=cs.dot(Il),c=ls.dot(Il);if(a<=0&&c<=0)return t.copy(n);Ll.subVectors(e,i);let l=cs.dot(Ll),u=ls.dot(Ll);if(l>=0&&u<=l)return t.copy(i);let h=a*u-l*c;if(h<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(cs,s);Nl.subVectors(e,r);let d=cs.dot(Nl),f=ls.dot(Nl);if(f>=0&&d<=f)return t.copy(r);let m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(ls,o);let _=l*f-d*u;if(_<=0&&u-l>=0&&d-f>=0)return Uf.subVectors(r,i),o=(u-l)/(u-l+(d-f)),t.copy(i).addScaledVector(Uf,o);let p=1/(_+m+h);return s=m*p,o=h*p,t.copy(n).addScaledVector(cs,s).addScaledVector(ls,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-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,n=e.length;t<n;t+=3)this.expandByPoint(qn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=qn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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(0.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 n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,qn);else qn.fromBufferAttribute(r,s);qn.applyMatrix4(e.matrixWorld),this.expandByPoint(qn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ea.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ea.copy(n.boundingBox)}Ea.applyMatrix4(e.matrixWorld),this.union(Ea)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],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,qn),qn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(io),Aa.subVectors(this.max,io),us.subVectors(e.a,io),hs.subVectors(e.b,io),ds.subVectors(e.c,io),ir.subVectors(hs,us),rr.subVectors(ds,hs),Cr.subVectors(us,ds);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!Fl(t,us,hs,ds,Aa))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Fl(t,us,hs,ds,Aa))return!1;return Ta.crossVectors(ir,rr),t=[Ta.x,Ta.y,Ta.z],Fl(t,us,hs,ds,Aa)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(qn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return ki[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ki[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ki[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ki[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ki[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ki[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ki[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ki[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ki),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}}var ki=[new U,new U,new U,new U,new U,new U,new U,new U],qn=new U,Ea=new Gt,us=new U,hs=new U,ds=new U,ir=new U,rr=new U,Cr=new U,io=new U,Aa=new U,Ta=new U,Pr=new U;function Fl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Pr.fromArray(e,s);let a=r.x*Math.abs(Pr.x)+r.y*Math.abs(Pr.y)+r.z*Math.abs(Pr.z),c=t.dot(Pr),l=n.dot(Pr),u=i.dot(Pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var zt=new U,Ra=new De,eS=0;class jt extends ti{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ra.fromBufferAttribute(this,t),Ra.applyMatrix3(e),this.setXY(t,Ra.x,Ra.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Yn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Yn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Yn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Yn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Yn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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"})}}class hc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class dc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xn extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var tS=new Gt,ro=new U,zl=new U;class An{constructor(e=new U,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 n=this.center;if(t!==void 0)n.copy(t);else tS.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;ro.subVectors(e,this.center);let t=ro.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(ro,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else zl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ro.copy(e.center).add(zl)),this.expandByPoint(ro.copy(e.center).sub(zl));return 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}}var nS=0,Un=new $e,kl=new gt,fs=new U,Mn=new Gt,so=new Gt,Zt=new U;class on extends ti{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nS++}),this.uuid=Jn(),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){if(Array.isArray(e))this.index=new((Ab(e))?dc:hc)(e,1);else this.index=e;return 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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new Ve().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return kl.lookAt(e),kl.updateMatrix(),this.applyMatrix4(kl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fs).negate(),this.translate(fs.x,fs.y,fs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new xn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(Mn.setFromBufferAttribute(r),this.morphTargetsRelative)Zt.addVectors(this.boundingBox.min,Mn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,Mn.max),this.boundingBox.expandByPoint(Zt);else this.boundingBox.expandByPoint(Mn.min),this.boundingBox.expandByPoint(Mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))ze('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new An;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(Mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(so.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(Mn.min,so.min),Mn.expandByPoint(Zt),Zt.addVectors(Mn.max,so.max),Mn.expandByPoint(Zt);else Mn.expandByPoint(so.min),Mn.expandByPoint(so.max)}Mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Zt.fromBufferAttribute(o,c),a)fs.fromBufferAttribute(e,c),Zt.add(fs);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ze('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){ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,h=new De,d=new De,f=new De,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),h.fromBufferAttribute(r,R),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),d.sub(h),f.sub(h);let z=1/(d.x*f.y-f.x*d.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-d.y).multiplyScalar(z),_.copy(u).multiplyScalar(d.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let h=0,d=e.count;h<d;h+=3){let f=e.getX(h+0),m=e.getX(h+1),_=e.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(h+0,l.x,l.y,l.z),n.setXYZ(h+1,l.x,l.y,l.z),n.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,h=new c.constructor(a.length*l),d=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)d=a[m]*o.data.stride+o.offset;else d=a[m]*l;for(let p=0;p<l;p++)h[f++]=c[d++]}return new jt(h,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new on,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=e(h,n);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.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;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];l.push(d.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return 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 n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return 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"})}}class Mo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Jn()}onUploadCallback(){}set needsUpdate(e){if(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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Jn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Jn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var hn=new U;class Is{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Yn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Yn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Yn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Yn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Yn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){fo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new jt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Is(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){fo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Bl=new U,iS=new U,rS=new Ve;class Fn{constructor(e=new U(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Bl.subVectors(n,t).cross(iS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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,n=!0){let i=e.delta(Bl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||rS.getNormalMatrix(e),i=this.coplanarPoint(Bl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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}}var sS=0;class yn extends ti{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:sS++}),this.uuid=Jn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Ue().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Fn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new De().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new De().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return 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,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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){if(e===!0)this.version++}}var Bi=new U,Vl=new U,Ca=new U,Pa=new U;class fr{constructor(e=new U,t=new U(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,Bi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Bi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Bi.copy(this.origin).addScaledVector(this.direction,t),Bi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Vl.copy(e).add(t).multiplyScalar(0.5),Ca.copy(t).sub(e).normalize(),Pa.copy(this.origin).sub(Vl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ca),o=Pa.dot(this.direction),a=-Pa.dot(Ca),c=Pa.lengthSq(),l=Math.abs(1-s*s),u,h,d,f;if(l>0)if(u=s*a-o,h=s*o-a,f=r*l,u>=0)if(h>=-f)if(h<=f){let m=1/l;u*=m,h*=m,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+c}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;else if(h<=-f)u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else if(h<=f)u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+c;else u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+c;else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Vl).addScaledVector(Ca,h);return d}intersectSphere(e,t){if(e.radius<0)return null;Bi.subVectors(e.center,this.origin);let n=Bi.dot(this.direction),i=Bi.dot(Bi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;if(c>=0)n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c;else n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c;if(l>=0)r=(e.min.y-h.y)*l,s=(e.max.y-h.y)*l;else r=(e.max.y-h.y)*l,s=(e.min.y-h.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u;else o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Bi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,h=e.y-s.y,d=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=h,z=d,L=m,K=_,G=g,X=S;else A=l,R=c,M=d,z=h,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=h,I=m,P=g,c>=0)A=l,R=a,M=d,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=d,L=f,K=_,G=p,X=S;else if(x=l,C=d,I=_,P=S,l>=0)A=a,R=c,M=u,z=h,L=f,K=m,G=p,X=g;else A=c,R=a,M=h,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,ee=M-j*C,Se=z-k*C,ue=L-j*I,Be=K-k*I,Me=G-j*P,Z=X-k*P,re=Me*Be-Z*ue,se=ee*Z-Se*Me,xe=ue*Se-Be*ee;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,r)}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)}}class _i extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(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 di,this.combine=0,this.reflectivity=1,this.refractionRatio=0.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}}var Ff=new $e,Ir=new fr,Ia=new An,zf=new U,La=new U,Na=new U,Da=new U,Gl=new U,Oa=new U,kf=new U,Ua=new U;class Mt extends gt{constructor(e=new on,t=new _i){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){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Oa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(Gl.fromBufferAttribute(u,e),s)Oa.addScaledVector(Gl,l);else Oa.addScaledVector(Gl.sub(t),l)}t.add(Oa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ia.copy(n.boundingSphere),Ia.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Ia.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Ia,zf)===null)return;if(Ir.origin.distanceToSquared(zf)>(e.far-e.near)**2)return}if(Ff.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(Ff),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:h,drawRange:d}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),S=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=h.length;f<m;f++){let _=h[f],p=s[_.materialIndex],g=Math.max(_.start,d.start),S=Math.min(a.count,Math.min(_.start+_.count,d.start+d.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=Fa(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=Fa(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function oS(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;Ua.copy(a),Ua.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ua);if(l<n.near||l>n.far)return null;return{distance:l,point:Ua.clone(),object:e}}function Fa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,La),e.getVertexPosition(c,Na),e.getVertexPosition(l,Da);let u=oS(e,t,n,i,La,Na,Da,kf);if(u){let h=new U;if(zn.getBarycoord(kf,La,Na,Da,h),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,h,new De);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,h,new De);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,h,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let d={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(La,Na,Da,d.normal),u.face=d,u.barycoord=h}return u}var oo=new ft,Bf=new ft,Vf=new ft,aS=new ft,Gf=new $e,za=new U,Hl=new An,Hf=new $e,$l=new fr;class fc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingBox.expandByPoint(za)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new An;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,za),this.boundingSphere.expandByPoint(za)}copy(e,t){if(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();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Hl.copy(this.boundingSphere),Hl.applyMatrix4(i),e.ray.intersectsSphere(Hl)===!1)return;if(Hf.copy(i).invert(),$l.copy(e.ray).applyMatrix4(Hf),this.boundingBox!==null){if($l.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,$l)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(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 ft,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Bf.fromBufferAttribute(i.attributes.skinIndex,e),Vf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)oo.copy(t),t.set(0,0,0,0);else oo.set(...t,1),t.set(0,0,0);oo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Vf.getComponent(r);if(s!==0){let o=Bf.getComponent(r);Gf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(aS.copy(oo).applyMatrix4(Gf),s)}}if(t.isVector4)t.w=oo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class wo extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Eo extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,h){super(null,s,o,a,c,l,i,r,u,h);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var $f=new $e,cS=new $e;class Ao{constructor(e=[],t=[]){this.uuid=Jn(),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){Le("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:cS;$f.multiplyMatrices(o,t[r]),$f.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ao(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 n=new Eo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Le("Skeleton: No bone found with UUID:",r),s=new wo;this.bones.push(s),this.boneInverses.push(new $e().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ar extends jt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}}var ps=new $e,Wf=new $e,ka=[],Zf=new Gt,lS=new $e,ao=new Mt,co=new An;class Ls extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,lS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ps),Zf.copy(e.boundingBox).applyMatrix4(ps),this.boundingBox.union(Zf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new An;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ps),co.copy(e.boundingSphere).applyMatrix4(ps),this.boundingSphere.union(co)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(ao.geometry=this.geometry,ao.material=this.material,ao.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(co.copy(this.boundingSphere),co.applyMatrix4(n),e.ray.intersectsSphere(co)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ps),Wf.multiplyMatrices(n,ps),ao.matrixWorld=Wf,ao.raycast(e,ka);for(let s=0,o=ka.length;s<o;s++){let a=ka[s];a.instanceId=r,a.object=this,t.push(a)}ka.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Eo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Lr=new An,uS=new De(0.5,0.5),Ba=new U;class To{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,d-l,p-f,y-g).normalize(),i[1].setComponents(c+s,d+l,p+f,y+g).normalize(),i[2].setComponents(c+o,d+u,p+m,y+S).normalize(),i[3].setComponents(c-o,d-u,p-m,y-S).normalize(),n)i[4].setComponents(a,h,_,T).normalize(),i[5].setComponents(c-a,d-h,p-_,y-T).normalize();else if(i[4].setComponents(c-a,d-h,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,d+h,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,h,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=uS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ba.x=i.normal.x>0?e.max.x:e.min.x,Ba.y=i.normal.y>0?e.max.y:e.min.y,Ba.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ba)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ro extends yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ja=new U,qa=new U,Xf=new $e,lo=new fr,Va=new An,Wl=new U,jf=new U;class pr extends gt{constructor(e=new on,t=new Ro){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)ja.fromBufferAttribute(t,i-1),qa.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ja.distanceTo(qa);e.setAttribute("lineDistance",new xn(n,1))}else Le("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Va.copy(n.boundingSphere),Va.applyMatrix4(i),Va.radius+=r,e.ray.intersectsSphere(Va)===!1)return;Xf.copy(i).invert(),lo.copy(e.ray).applyMatrix4(Xf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=Ga(this,e,lo,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(d),p=Ga(this,e,lo,a,m,_,f-1);if(p)t.push(p)}}else{let d=Math.max(0,s.start),f=Math.min(h.count,s.start+s.count);for(let m=d,_=f-1;m<_;m+=c){let p=Ga(this,e,lo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ga(this,e,lo,a,f-1,d,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ga(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ja.fromBufferAttribute(a,r),qa.fromBufferAttribute(a,s),n.distanceSqToSegment(ja,qa,Wl,jf)>i)return;Wl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Wl);if(l<t.near||l>t.far)return;return{distance:l,point:jf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var qf=new U,Yf=new U;class pc extends pr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)qf.fromBufferAttribute(t,i),Yf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+qf.distanceTo(Yf);e.setAttribute("lineDistance",new xn(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mc extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Co extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var Jf=new $e,jl=new fr,Ha=new An,$a=new U;class Ns extends gt{constructor(e=new on,t=new Co){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ha.copy(n.boundingSphere),Ha.applyMatrix4(i),Ha.radius+=r,e.ray.intersectsSphere(Ha)===!1)return;Jf.copy(i).invert(),jl.copy(e.ray).applyMatrix4(Jf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let h=Math.max(0,s.start),d=Math.min(c.count,s.start+s.count);for(let f=h,m=d;f<m;f++){let _=c.getX(f);$a.fromBufferAttribute(u,_),Kf($a,_,a,i,e,t,this)}}else{let h=Math.max(0,s.start),d=Math.min(u.count,s.start+s.count);for(let f=h,m=d;f<m;f++)$a.fromBufferAttribute(u,f),Kf($a,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Kf(e,t,n,i,r,s,o){let a=jl.distanceSqToPoint(e);if(a<n){let c=new U;jl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class gc extends Nt{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Vr extends Nt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:u};super(h,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new bo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Ku extends Vr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class _c extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends on{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],h=0,d=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new xn(c,3)),this.setAttribute("normal",new xn(l,3)),this.setAttribute("uv",new xn(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let ee=0;ee<I;ee++){let Se=ee*M-C;j[m]=Se*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(ee/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let ee=h+q+I*k,Se=h+q+I*(k+1),ue=h+(q+1)+I*(k+1),Be=h+(q+1)+I*k;a.push(ee,Se,Be),a.push(Se,ue,Be),P+=6}o.addGroup(d,P,x),d+=P,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Po extends on{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,h=t/a,d=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*h-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;d.push(S,T,w),d.push(T,y,w)}this.setIndex(d),this.setAttribute("position",new xn(f,3)),this.setAttribute("normal",new xn(m,3)),this.setAttribute("uv",new xn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Po(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(Qf(r))if(r.isRenderTargetTexture)Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(Qf(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function an(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function Qf(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function hS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Qu(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var om={clone:Gr,merge:an},dS=`void main() {
126
126
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
127
- }`,ab=`void main() {
127
+ }`,fS=`void main() {
128
128
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
129
- }`;class In extends hn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ob,this.fragmentShader=ab,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=Ar(e.uniforms),this.uniformsGroups=sb(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 i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(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 n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new at().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class xu extends In{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ci extends hn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(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 Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(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 ni,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}}class yn extends Ci{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return We(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Ha extends hn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.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}}class yu extends hn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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}}class vu extends hn{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 $i(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function _a(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function cb(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function od(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function lb(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Pi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class bu extends Pi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+m*s[c+v]+E*s[a+v]+R*s[u+v];return r}}class Va extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class Su extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Mu extends Pi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,v=l[R],M=l[R+1],T=hb(n,t,m,v,i);r[d]=dp(T,g,E,M,x)}return r}}function dp(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function ub(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function hb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=dp(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ub(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class vn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=$i(t,this.TimeBufferType),this.values=$i(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:$i(e.times,Array),values:$i(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Array),outTangents:$i(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Va(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new bu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Mu(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="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 Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(_a(this.settings))ad(this.settings.inTangents,e),ad(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(bv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,_a(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function ad(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=2301;class er extends vn{constructor(e,t,n){super(e,t,n)}}er.prototype.ValueTypeName="bool";er.prototype.ValueBufferType=Array;er.prototype.DefaultInterpolation=2300;er.prototype.InterpolantFactoryMethodLinear=void 0;er.prototype.InterpolantFactoryMethodSmooth=void 0;class $a extends vn{constructor(e,t,n,i){super(e,t,n,i)}}$a.prototype.ValueTypeName="color";class tr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}tr.prototype.ValueTypeName="number";class wu extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Ht.slerpFlat(r,0,s,c-o,s,c,a);return r}}class nr extends vn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wu(this.times,this.values,this.getValueSize(),e)}}nr.prototype.ValueTypeName="quaternion";nr.prototype.InterpolantFactoryMethodSmooth=void 0;class ir extends vn{constructor(e,t,n){super(e,t,n)}}ir.prototype.ValueTypeName="string";ir.prototype.ValueBufferType=Array;ir.prototype.DefaultInterpolation=2300;ir.prototype.InterpolantFactoryMethodLinear=void 0;ir.prototype.InterpolantFactoryMethodSmooth=void 0;class Rr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Rr.prototype.ValueTypeName="vector";class rs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Gn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(db(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=cb(a);if(a=od(a,1,l),c=od(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new tr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function fb(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return tr;case"vector":case"vector2":case"vector3":case"vector4":return Rr;case"color":return $a;case"quaternion":return nr;case"bool":case"boolean":return er;case"string":return ir}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function db(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=fb(e.type);if(e.times===void 0){let i=[],r=[];lb(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Float32Array),outTangents:$i(e.settings.outTangents,Float32Array)};return n}var ti={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(cd(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(cd(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function cd(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class oo{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var pp=new oo;class Ii{constructor(e){if(this.manager=e!==void 0?e:pp,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 n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}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}}Ii.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ti={};class mp extends Error{constructor(e,t){super(e);this.response=t}}class ao extends Ii{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ti.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:n,onError:i});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ie("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Ti[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let v=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let M=0,T=l.length;M<T;M++){let A=l[M];if(A.onProgress)A.onProgress(v)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new mp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ti.add(`file:${e}`,c);let l=Ti[e];delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Ti[e];if(l===void 0)throw this.manager.itemError(e),c;delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Jr=new WeakMap;class Eu extends Ii{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Jr.get(s);if(u===void 0)u=[],Jr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=ns("img");function a(){if(l(),t)t(this);let u=Jr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Jr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ti.remove(`image:${e}`);let f=Jr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Jr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ti.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class _s extends Ii{constructor(e){super(e)}load(e,t,n,i){let r=new At,s=new Eu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class xs extends ut{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(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}}class Wa extends xs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(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}}var ul=new Ge,ld=new O,ud=new O;class co{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 Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ld.setFromMatrixPosition(e.matrixWorld),t.position.copy(ld),ud.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ud),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ul.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ul,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ul)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(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}}var ma=new O,ga=new Ht,Qn=new O;class Za extends ut{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,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){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Vi=new O,hd=new Ne,fd=new Ne;class Ut extends Za{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=0.5*this.getFilmHeight()/e;this.fov=yr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Bs*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return yr*2*Math.atan(Math.tan(Bs*0.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,n){Vi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,hd,fd),t.subVectors(fd,hd)}setViewOffset(e,t,n,i,r,s){if(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Bs*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class gp extends co{constructor(){super(new Ut(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=yr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Xa extends xs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new gp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class _p extends co{constructor(){super(new Ut(90,1,0.5,500));this.isPointLightShadow=!0}}class ys extends xs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _p}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Cr extends Za{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,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,n,i,r,s){if(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class xp extends co{constructor(){super(new Cr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class vs extends xs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new xp}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}}class rr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var hl=new WeakMap;class qa extends Ii{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ie("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ie("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(hl.has(s)===!0){if(i)i(hl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ti.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);hl.set(a,c),ti.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Qr=-90,es=1;class Tu extends ut{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ut(Qr,es,e,t);i.layers=this.layers,this.add(i);let r=new Ut(Qr,es,e,t);r.layers=this.layers,this.add(r);let s=new Ut(Qr,es,e,t);s.layers=this.layers,this.add(s);let o=new Ut(Qr,es,e,t);o.layers=this.layers,this.add(o);let a=new Ut(Qr,es,e,t);a.layers=this.layers,this.add(a);let c=new Ut(Qr,es,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.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),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.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),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Au extends Ut{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ru{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Ht.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ht.multiplyQuaternionsFlat(e,s,e,t,e,n),Ht.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Cu="\\[\\]\\.:\\/",pb=new RegExp("["+Cu+"]","g"),Pu="[^"+Cu+"]",mb="[^"+Cu.replace("\\.","")+"]",gb=/((?:WC+[\/:])*)/.source.replace("WC",Pu),_b=/(WCOD+)?/.source.replace("WCOD",mb),xb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pu),yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pu),vb=new RegExp("^"+gb+_b+xb+yb+"$"),bb=["material","materials","bones","map"];class yp{constructor(e,t,n){let i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new et(e,t,n);else return new et.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(pb,"")}static parseTrackName(e){let t=vb.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(bb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=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,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("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){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("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[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=yp;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Iu{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var Sb=new Float32Array(1);class ja extends Wn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Ru(et.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Va(new Float32Array(2),new Float32Array(2),1,Sb),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?rs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Iu(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?rs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class lo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Lu{static{Lu.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Ya extends Wn{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Nu(e,t,n,i){let r=Mb(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Mb(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ie("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Gp(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function wb(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw 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,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Eb=`#ifdef USE_ALPHAHASH
129
+ }`;class Bn extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=dS,this.fragmentShader=fS,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=Gr(e.uniforms),this.uniformsGroups=hS(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 i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(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 n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ue().setHex(i.value);break;case"v2":this.uniforms[n].value=new De().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class eh extends Bn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(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 Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new De(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 di,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}}class Tn extends $i{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new De(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class xc extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new di,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.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}}class th extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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}}class nh extends yn{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 or(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Xa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function pS(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function ep(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function mS(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Wi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class ih extends Wi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-h*_+2*h*m-h*f,g=(1+h)*_+(-1.5-2*h)*m+(-0.5+h)*f+1,S=(-1-d)*_+(1.5+d)*m+0.5*f,T=d*_-d*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class yc extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}}class rh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class sh extends Wi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let h=o*2,d=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=d*h+f*2,g=u[p],S=u[p+1],T=e*h+f*2,y=l[T],w=l[T+1],A=_S(n,t,g,y,i);r[f]=am(A,m,S,w,_)}return r}}function am(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function gS(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function _S(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=am(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=gS(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Rn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=or(t,this.TimeBufferType),this.values=or(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new rh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ih(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new sh(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="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 Error(n);return Le("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Xa(this.settings))tp(this.settings.inTangents,e),tp(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)ze("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ze("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){ze("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ze("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Tb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ze("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,h=u-n,d=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[h+f]||m!==t[d+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,h=s*n;for(let d=0;d!==n;++d)t[h+d]=t[u+d]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Xa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function tp(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Rn.prototype.ValueTypeName="";Rn.prototype.TimeBufferType=Float32Array;Rn.prototype.ValueBufferType=Float32Array;Rn.prototype.DefaultInterpolation=2301;class gr extends Rn{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class vc extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}vc.prototype.ValueTypeName="color";class _r extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class oh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new oh(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends Rn{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class bs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Jn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(yS(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Rn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=pS(a);if(a=ep(a,1,l),c=ep(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];if(!h)i[u]=h=[];h.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function xS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return vc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function yS(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=xS(e.type);if(e.times===void 0){let i=[],r=[];mS(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(Xa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var hi={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(np(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(np(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function np(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Io{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global)d.lastIndex=0;if(d.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var cm=new Io;class Zi{constructor(e){if(this.manager=e!==void 0?e:cm,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 n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}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}}Zi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Vi={};class lm extends Error{constructor(e,t){super(e);this.response=t}}class Lo extends Zi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=hi.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Vi[e]!==void 0){Vi[e].push({onLoad:t,onProgress:n,onError:i});return}Vi[e]=[],Vi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Vi[e],u=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=h?parseInt(h):0,f=d!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:d});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new lm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then((f)=>d.decode(f))}}}).then((c)=>{hi.add(`file:${e}`,c);let l=Vi[e];delete Vi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onLoad)d.onLoad(c)}}).catch((c)=>{let l=Vi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Vi[e];for(let u=0,h=l.length;u<h;u++){let d=l[u];if(d.onError)d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var ms=new WeakMap;class ah extends Zi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=hi.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=ms.get(s);if(u===void 0)u=[],ms.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=ys("img");function a(){if(l(),t)t(this);let u=ms.get(this)||[];for(let h=0;h<u.length;h++){let d=u[h];if(d.onLoad)d.onLoad(this)}ms.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);hi.remove(`image:${e}`);let h=ms.get(this)||[];for(let d=0;d<h.length;d++){let f=h[d];if(f.onError)f.onError(u)}ms.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return hi.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Ds extends Zi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new ah(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Os extends gt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ue(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}}class bc extends Os{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ue(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}}var Zl=new $e,ip=new U,rp=new U;class No{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 De(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new To,this._frameExtents=new De(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ip.setFromMatrixPosition(e.matrixWorld),t.position.copy(ip),rp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rp),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Zl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Zl,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(Zl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(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}}var Wa=new U,Za=new Xt,li=new U;class Sc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=2000,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){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Wa,Za,li),li.x===1&&li.y===1&&li.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,li.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wa,Za,li),li.x===1&&li.y===1&&li.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wa,Za,li.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,sp=new De,op=new De;class Vt extends Sc{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=0.5*this.getFilmHeight()/e;this.fov=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(uo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(uo*0.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,n){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,sp,op),t.subVectors(op,sp)}setViewOffset(e,t,n,i,r,s){if(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(uo*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class um extends No{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Mc extends Os{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new um}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class hm extends No{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Us extends Os{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new hm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class $r extends Sc{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,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,n,i,r,s){if(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class dm extends No{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Fs extends Os{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new dm}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}}class vr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var Xl=new WeakMap;class wc extends Zi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=hi.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Xl.has(s)===!0){if(i)i(Xl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(hi.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Xl.set(a,c),hi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});hi.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var gs=-90,_s=1;class ch extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(gs,_s,e,t);i.layers=this.layers,this.add(i);let r=new Vt(gs,_s,e,t);r.layers=this.layers,this.add(r);let s=new Vt(gs,_s,e,t);s.layers=this.layers,this.add(s);let o=new Vt(gs,_s,e,t);o.layers=this.layers,this.add(o);let a=new Vt(gs,_s,e,t);a.layers=this.layers,this.add(a);let c=new Vt(gs,_s,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.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),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.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),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,h,d),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class lh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class uh{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var hh="\\[\\]\\.:\\/",vS=new RegExp("["+hh+"]","g"),dh="[^"+hh+"]",bS="[^"+hh.replace("\\.","")+"]",SS=/((?:WC+[\/:])*)/.source.replace("WC",dh),MS=/(WCOD+)?/.source.replace("WCOD",bS),wS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dh),ES=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dh),AS=new RegExp("^"+SS+MS+wS+ES+"$"),TS=["material","materials","bones","map"];class fm{constructor(e,t,n){let i=n||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(vS,"")}static parseTrackName(e){let t=AS.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);if(TS.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=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,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("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){ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("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[n]===void 0){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=fm;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class fh{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var RS=new Float32Array(1);class Ec extends ti{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,d);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new uh(ot.create(n,d,m),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,h=(e._localRoot||this._root).uuid;if(delete u[h],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new yc(new Float32Array(2),new Float32Array(2),1,RS),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?bs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new fh(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?bs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class Do{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class ph{static{ph.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Ac extends ti{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function mh(e,t,n,i){let r=CS(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function CS(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Om(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function PS(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,h=l.byteLength,d=e.createBuffer();e.bindBuffer(c,d),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){let{array:u,updateRanges:h}=c;if(e.bindBuffer(l,a),h.length===0)e.bufferSubData(l,0,u);else{h.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<h.length;f++){let m=h[d],_=h[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++d,h[d]=_}h.length=d+1;for(let f=0,m=h.length;f<m;f++){let _=h[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw 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,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var IS=`#ifdef USE_ALPHAHASH
130
130
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
131
- #endif`,Tb=`#ifdef USE_ALPHAHASH
131
+ #endif`,LS=`#ifdef USE_ALPHAHASH
132
132
  const float ALPHA_HASH_SCALE = 0.05;
133
133
  float hash2D( vec2 value ) {
134
134
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -163,20 +163,20 @@
163
163
  : cases.z;
164
164
  return clamp( threshold , 1.0e-6, 1.0 );
165
165
  }
166
- #endif`,Ab=`#ifdef USE_ALPHAMAP
166
+ #endif`,NS=`#ifdef USE_ALPHAMAP
167
167
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
168
- #endif`,Rb=`#ifdef USE_ALPHAMAP
168
+ #endif`,DS=`#ifdef USE_ALPHAMAP
169
169
  uniform sampler2D alphaMap;
170
- #endif`,Cb=`#ifdef USE_ALPHATEST
170
+ #endif`,OS=`#ifdef USE_ALPHATEST
171
171
  #ifdef ALPHA_TO_COVERAGE
172
172
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
173
173
  if ( diffuseColor.a == 0.0 ) discard;
174
174
  #else
175
175
  if ( diffuseColor.a < alphaTest ) discard;
176
176
  #endif
177
- #endif`,Pb=`#ifdef USE_ALPHATEST
177
+ #endif`,US=`#ifdef USE_ALPHATEST
178
178
  uniform float alphaTest;
179
- #endif`,Ib=`#ifdef USE_AOMAP
179
+ #endif`,FS=`#ifdef USE_AOMAP
180
180
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
181
181
  reflectedLight.indirectDiffuse *= ambientOcclusion;
182
182
  #if defined( USE_CLEARCOAT )
@@ -189,10 +189,10 @@
189
189
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
190
190
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
191
191
  #endif
192
- #endif`,Lb=`#ifdef USE_AOMAP
192
+ #endif`,zS=`#ifdef USE_AOMAP
193
193
  uniform sampler2D aoMap;
194
194
  uniform float aoMapIntensity;
195
- #endif`,Nb=`#ifdef USE_BATCHING
195
+ #endif`,kS=`#ifdef USE_BATCHING
196
196
  #if ! defined( GL_ANGLE_multi_draw )
197
197
  #define gl_DrawID _gl_DrawID
198
198
  uniform int _gl_DrawID;
@@ -226,15 +226,15 @@
226
226
  int y = j / size;
227
227
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
228
228
  }
229
- #endif`,Db=`#ifdef USE_BATCHING
229
+ #endif`,BS=`#ifdef USE_BATCHING
230
230
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
231
- #endif`,Ob=`vec3 transformed = vec3( position );
231
+ #endif`,VS=`vec3 transformed = vec3( position );
232
232
  #ifdef USE_ALPHAHASH
233
233
  vPosition = vec3( position );
234
- #endif`,Ub=`vec3 objectNormal = vec3( normal );
234
+ #endif`,GS=`vec3 objectNormal = vec3( normal );
235
235
  #ifdef USE_TANGENT
236
236
  vec3 objectTangent = vec3( tangent.xyz );
237
- #endif`,Fb=`float G_BlinnPhong_Implicit( ) {
237
+ #endif`,HS=`float G_BlinnPhong_Implicit( ) {
238
238
  return 0.25;
239
239
  }
240
240
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
248
248
  float G = G_BlinnPhong_Implicit( );
249
249
  float D = D_BlinnPhong( shininess, dotNH );
250
250
  return F * ( G * D );
251
- } // validated`,zb=`#ifdef USE_IRIDESCENCE
251
+ } // validated`,$S=`#ifdef USE_IRIDESCENCE
252
252
  const mat3 XYZ_TO_REC709 = mat3(
253
253
  3.2404542, -0.9692660, 0.0556434,
254
254
  -1.5371385, 1.8760108, -0.2040259,
@@ -311,7 +311,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
311
311
  }
312
312
  return max( I, vec3( 0.0 ) );
313
313
  }
314
- #endif`,kb=`#ifdef USE_BUMPMAP
314
+ #endif`,WS=`#ifdef USE_BUMPMAP
315
315
  uniform sampler2D bumpMap;
316
316
  uniform float bumpScale;
317
317
  vec2 dHdxy_fwd() {
@@ -332,7 +332,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
332
332
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
333
333
  return normalize( abs( fDet ) * surf_norm - vGrad );
334
334
  }
335
- #endif`,Bb=`#if NUM_CLIPPING_PLANES > 0
335
+ #endif`,ZS=`#if NUM_CLIPPING_PLANES > 0
336
336
  vec4 plane;
337
337
  #ifdef ALPHA_TO_COVERAGE
338
338
  float distanceToPlane, distanceGradient;
@@ -378,20 +378,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
378
378
  if ( clipped ) discard;
379
379
  #endif
380
380
  #endif
381
- #endif`,Gb=`#if NUM_CLIPPING_PLANES > 0
381
+ #endif`,XS=`#if NUM_CLIPPING_PLANES > 0
382
382
  varying vec3 vClipPosition;
383
383
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
384
- #endif`,Hb=`#if NUM_CLIPPING_PLANES > 0
384
+ #endif`,jS=`#if NUM_CLIPPING_PLANES > 0
385
385
  varying vec3 vClipPosition;
386
- #endif`,Vb=`#if NUM_CLIPPING_PLANES > 0
386
+ #endif`,qS=`#if NUM_CLIPPING_PLANES > 0
387
387
  vClipPosition = - mvPosition.xyz;
388
- #endif`,$b=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
388
+ #endif`,YS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
389
389
  diffuseColor *= vColor;
390
- #endif`,Wb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
390
+ #endif`,JS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
391
391
  varying vec4 vColor;
392
- #endif`,Zb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
392
+ #endif`,KS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
393
393
  varying vec4 vColor;
394
- #endif`,Xb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
394
+ #endif`,QS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
395
395
  vColor = vec4( 1.0 );
396
396
  #endif
397
397
  #ifdef USE_COLOR_ALPHA
@@ -404,7 +404,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
404
404
  #endif
405
405
  #ifdef USE_BATCHING_COLOR
406
406
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
407
- #endif`,qb=`#define PI 3.141592653589793
407
+ #endif`,eM=`#define PI 3.141592653589793
408
408
  #define PI2 6.283185307179586
409
409
  #define PI_HALF 1.5707963267948966
410
410
  #define RECIPROCAL_PI 0.3183098861837907
@@ -475,7 +475,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
475
475
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
476
476
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
477
477
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
478
- } // validated`,jb=`#ifdef ENVMAP_TYPE_CUBE_UV
478
+ } // validated`,tM=`#ifdef ENVMAP_TYPE_CUBE_UV
479
479
  #define cubeUV_minMipLevel 4.0
480
480
  #define cubeUV_minTileSize 16.0
481
481
  float getFace( vec3 direction ) {
@@ -568,7 +568,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
568
568
  return vec4( mix( color0, color1, mipF ), 1.0 );
569
569
  }
570
570
  }
571
- #endif`,Yb=`vec3 transformedNormal = objectNormal;
571
+ #endif`,nM=`vec3 transformedNormal = objectNormal;
572
572
  #ifdef USE_TANGENT
573
573
  vec3 transformedTangent = objectTangent;
574
574
  #endif
@@ -594,21 +594,21 @@ transformedNormal = normalMatrix * transformedNormal;
594
594
  #endif
595
595
  #ifdef USE_TANGENT
596
596
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
597
- #endif`,Kb=`#ifdef USE_DISPLACEMENTMAP
597
+ #endif`,iM=`#ifdef USE_DISPLACEMENTMAP
598
598
  uniform sampler2D displacementMap;
599
599
  uniform float displacementScale;
600
600
  uniform float displacementBias;
601
- #endif`,Jb=`#ifdef USE_DISPLACEMENTMAP
601
+ #endif`,rM=`#ifdef USE_DISPLACEMENTMAP
602
602
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
603
- #endif`,Qb=`#ifdef USE_EMISSIVEMAP
603
+ #endif`,sM=`#ifdef USE_EMISSIVEMAP
604
604
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
605
605
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
606
606
  emissiveColor = sRGBTransferEOTF( emissiveColor );
607
607
  #endif
608
608
  totalEmissiveRadiance *= emissiveColor.rgb;
609
- #endif`,eS=`#ifdef USE_EMISSIVEMAP
609
+ #endif`,oM=`#ifdef USE_EMISSIVEMAP
610
610
  uniform sampler2D emissiveMap;
611
- #endif`,tS="gl_FragColor = linearToOutputTexel( gl_FragColor );",nS=`vec4 LinearTransferOETF( in vec4 value ) {
611
+ #endif`,aM="gl_FragColor = linearToOutputTexel( gl_FragColor );",cM=`vec4 LinearTransferOETF( in vec4 value ) {
612
612
  return value;
613
613
  }
614
614
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -616,7 +616,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
616
616
  }
617
617
  vec4 sRGBTransferOETF( in vec4 value ) {
618
618
  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 );
619
- }`,iS=`#ifdef USE_ENVMAP
619
+ }`,lM=`#ifdef USE_ENVMAP
620
620
  #ifdef ENV_WORLDPOS
621
621
  vec3 cameraToFrag;
622
622
  if ( isOrthographic ) {
@@ -643,7 +643,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
643
643
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
644
644
  #endif
645
645
  #endif
646
- #endif`,rS=`#ifdef USE_ENVMAP
646
+ #endif`,uM=`#ifdef USE_ENVMAP
647
647
  uniform float envMapIntensity;
648
648
  uniform mat3 envMapRotation;
649
649
  #ifdef ENVMAP_TYPE_CUBE
@@ -651,7 +651,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
651
651
  #else
652
652
  uniform sampler2D envMap;
653
653
  #endif
654
- #endif`,sS=`#ifdef USE_ENVMAP
654
+ #endif`,hM=`#ifdef USE_ENVMAP
655
655
  uniform float reflectivity;
656
656
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
657
657
  #define ENV_WORLDPOS
@@ -662,7 +662,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
662
662
  #else
663
663
  varying vec3 vReflect;
664
664
  #endif
665
- #endif`,oS=`#ifdef USE_ENVMAP
665
+ #endif`,dM=`#ifdef USE_ENVMAP
666
666
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
667
667
  #define ENV_WORLDPOS
668
668
  #endif
@@ -673,7 +673,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
673
673
  varying vec3 vReflect;
674
674
  uniform float refractionRatio;
675
675
  #endif
676
- #endif`,aS=`#ifdef USE_ENVMAP
676
+ #endif`,fM=`#ifdef USE_ENVMAP
677
677
  #ifdef ENV_WORLDPOS
678
678
  vWorldPosition = worldPosition.xyz;
679
679
  #else
@@ -690,18 +690,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
690
690
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
691
691
  #endif
692
692
  #endif
693
- #endif`,cS=`#ifdef USE_FOG
693
+ #endif`,pM=`#ifdef USE_FOG
694
694
  vFogDepth = - mvPosition.z;
695
- #endif`,lS=`#ifdef USE_FOG
695
+ #endif`,mM=`#ifdef USE_FOG
696
696
  varying float vFogDepth;
697
- #endif`,uS=`#ifdef USE_FOG
697
+ #endif`,gM=`#ifdef USE_FOG
698
698
  #ifdef FOG_EXP2
699
699
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
700
700
  #else
701
701
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
702
702
  #endif
703
703
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
704
- #endif`,hS=`#ifdef USE_FOG
704
+ #endif`,_M=`#ifdef USE_FOG
705
705
  uniform vec3 fogColor;
706
706
  varying float vFogDepth;
707
707
  #ifdef FOG_EXP2
@@ -710,7 +710,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
710
710
  uniform float fogNear;
711
711
  uniform float fogFar;
712
712
  #endif
713
- #endif`,fS=`#ifdef USE_GRADIENTMAP
713
+ #endif`,xM=`#ifdef USE_GRADIENTMAP
714
714
  uniform sampler2D gradientMap;
715
715
  #endif
716
716
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -722,12 +722,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
722
722
  vec2 fw = fwidth( coord ) * 0.5;
723
723
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
724
724
  #endif
725
- }`,dS=`#ifdef USE_LIGHTMAP
725
+ }`,yM=`#ifdef USE_LIGHTMAP
726
726
  uniform sampler2D lightMap;
727
727
  uniform float lightMapIntensity;
728
- #endif`,pS=`LambertMaterial material;
728
+ #endif`,vM=`LambertMaterial material;
729
729
  material.diffuseColor = diffuseColor.rgb;
730
- material.specularStrength = specularStrength;`,mS=`varying vec3 vViewPosition;
730
+ material.specularStrength = specularStrength;`,bM=`varying vec3 vViewPosition;
731
731
  struct LambertMaterial {
732
732
  vec3 diffuseColor;
733
733
  float specularStrength;
@@ -741,7 +741,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
741
741
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
742
742
  }
743
743
  #define RE_Direct RE_Direct_Lambert
744
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gS=`uniform bool receiveShadow;
744
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,SM=`uniform bool receiveShadow;
745
745
  uniform vec3 ambientLightColor;
746
746
  #if defined( USE_LIGHT_PROBES )
747
747
  uniform vec3 lightProbe[ 9 ];
@@ -870,7 +870,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
870
870
  return irradiance;
871
871
  }
872
872
  #endif
873
- #include <lightprobes_pars_fragment>`,_S=`#ifdef USE_ENVMAP
873
+ #include <lightprobes_pars_fragment>`,MM=`#ifdef USE_ENVMAP
874
874
  vec3 getIBLIrradiance( const in vec3 normal ) {
875
875
  #ifdef ENVMAP_TYPE_CUBE_UV
876
876
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -927,8 +927,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
927
927
  }
928
928
  #endif
929
929
  #endif
930
- #endif`,xS=`ToonMaterial material;
931
- material.diffuseColor = diffuseColor.rgb;`,yS=`varying vec3 vViewPosition;
930
+ #endif`,wM=`ToonMaterial material;
931
+ material.diffuseColor = diffuseColor.rgb;`,EM=`varying vec3 vViewPosition;
932
932
  struct ToonMaterial {
933
933
  vec3 diffuseColor;
934
934
  };
@@ -940,11 +940,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
940
940
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
941
941
  }
942
942
  #define RE_Direct RE_Direct_Toon
943
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,vS=`BlinnPhongMaterial material;
943
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,AM=`BlinnPhongMaterial material;
944
944
  material.diffuseColor = diffuseColor.rgb;
945
945
  material.specularColor = specular;
946
946
  material.specularShininess = shininess;
947
- material.specularStrength = specularStrength;`,bS=`varying vec3 vViewPosition;
947
+ material.specularStrength = specularStrength;`,TM=`varying vec3 vViewPosition;
948
948
  struct BlinnPhongMaterial {
949
949
  vec3 diffuseColor;
950
950
  vec3 specularColor;
@@ -961,7 +961,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
961
961
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
962
962
  }
963
963
  #define RE_Direct RE_Direct_BlinnPhong
964
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,SS=`PhysicalMaterial material;
964
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,RM=`PhysicalMaterial material;
965
965
  material.diffuseColor = diffuseColor.rgb;
966
966
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
967
967
  material.metalness = metalnessFactor;
@@ -1054,7 +1054,7 @@ material.roughness = min( material.roughness, 1.0 );
1054
1054
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1055
1055
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1056
1056
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1057
- #endif`,MS=`uniform sampler2D dfgLUT;
1057
+ #endif`,CM=`uniform sampler2D dfgLUT;
1058
1058
  struct PhysicalMaterial {
1059
1059
  vec3 diffuseColor;
1060
1060
  vec3 diffuseContribution;
@@ -1421,7 +1421,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1421
1421
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1422
1422
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1423
1423
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1424
- }`,wS=`
1424
+ }`,PM=`
1425
1425
  vec3 geometryPosition = - vViewPosition;
1426
1426
  vec3 geometryNormal = normal;
1427
1427
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1569,7 +1569,7 @@ IncidentLight directLight;
1569
1569
  #if defined( RE_IndirectSpecular )
1570
1570
  vec3 radiance = vec3( 0.0 );
1571
1571
  vec3 clearcoatRadiance = vec3( 0.0 );
1572
- #endif`,ES=`#if defined( RE_IndirectDiffuse )
1572
+ #endif`,IM=`#if defined( RE_IndirectDiffuse )
1573
1573
  #ifdef USE_LIGHTMAP
1574
1574
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1575
1575
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1599,7 +1599,7 @@ IncidentLight directLight;
1599
1599
  #ifdef USE_CLEARCOAT
1600
1600
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1601
1601
  #endif
1602
- #endif`,TS=`#if defined( RE_IndirectDiffuse )
1602
+ #endif`,LM=`#if defined( RE_IndirectDiffuse )
1603
1603
  #if defined( LAMBERT ) || defined( PHONG )
1604
1604
  irradiance += iblIrradiance;
1605
1605
  #endif
@@ -1607,7 +1607,7 @@ IncidentLight directLight;
1607
1607
  #endif
1608
1608
  #if defined( RE_IndirectSpecular )
1609
1609
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1610
- #endif`,AS=`#ifdef USE_LIGHT_PROBES_GRID
1610
+ #endif`,NM=`#ifdef USE_LIGHT_PROBES_GRID
1611
1611
  uniform highp sampler3D probesSH;
1612
1612
  uniform vec3 probesMin;
1613
1613
  uniform vec3 probesMax;
@@ -1652,27 +1652,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1652
1652
  result += c8 * 0.429043 * ( x * x - y * y );
1653
1653
  return max( result, vec3( 0.0 ) );
1654
1654
  }
1655
- #endif`,RS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1655
+ #endif`,DM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1656
1656
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1657
- #endif`,CS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1657
+ #endif`,OM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1658
1658
  uniform float logDepthBufFC;
1659
1659
  varying float vFragDepth;
1660
1660
  varying float vIsPerspective;
1661
- #endif`,PS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1661
+ #endif`,UM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1662
1662
  varying float vFragDepth;
1663
1663
  varying float vIsPerspective;
1664
- #endif`,IS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1664
+ #endif`,FM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1665
1665
  vFragDepth = 1.0 + gl_Position.w;
1666
1666
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1667
- #endif`,LS=`#ifdef USE_MAP
1667
+ #endif`,zM=`#ifdef USE_MAP
1668
1668
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1669
1669
  #ifdef DECODE_VIDEO_TEXTURE
1670
1670
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1671
1671
  #endif
1672
1672
  diffuseColor *= sampledDiffuseColor;
1673
- #endif`,NS=`#ifdef USE_MAP
1673
+ #endif`,kM=`#ifdef USE_MAP
1674
1674
  uniform sampler2D map;
1675
- #endif`,DS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1675
+ #endif`,BM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1676
1676
  #if defined( USE_POINTS_UV )
1677
1677
  vec2 uv = vUv;
1678
1678
  #else
@@ -1684,7 +1684,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1684
1684
  #endif
1685
1685
  #ifdef USE_ALPHAMAP
1686
1686
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1687
- #endif`,OS=`#if defined( USE_POINTS_UV )
1687
+ #endif`,VM=`#if defined( USE_POINTS_UV )
1688
1688
  varying vec2 vUv;
1689
1689
  #else
1690
1690
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1696,19 +1696,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1696
1696
  #endif
1697
1697
  #ifdef USE_ALPHAMAP
1698
1698
  uniform sampler2D alphaMap;
1699
- #endif`,US=`float metalnessFactor = metalness;
1699
+ #endif`,GM=`float metalnessFactor = metalness;
1700
1700
  #ifdef USE_METALNESSMAP
1701
1701
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1702
1702
  metalnessFactor *= texelMetalness.b;
1703
- #endif`,FS=`#ifdef USE_METALNESSMAP
1703
+ #endif`,HM=`#ifdef USE_METALNESSMAP
1704
1704
  uniform sampler2D metalnessMap;
1705
- #endif`,zS=`#ifdef USE_INSTANCING_MORPH
1705
+ #endif`,$M=`#ifdef USE_INSTANCING_MORPH
1706
1706
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1707
1707
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1708
1708
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1709
1709
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1710
1710
  }
1711
- #endif`,kS=`#if defined( USE_MORPHCOLORS )
1711
+ #endif`,WM=`#if defined( USE_MORPHCOLORS )
1712
1712
  vColor *= morphTargetBaseInfluence;
1713
1713
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1714
1714
  #if defined( USE_COLOR_ALPHA )
@@ -1717,12 +1717,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1717
1717
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1718
1718
  #endif
1719
1719
  }
1720
- #endif`,BS=`#ifdef USE_MORPHNORMALS
1720
+ #endif`,ZM=`#ifdef USE_MORPHNORMALS
1721
1721
  objectNormal *= morphTargetBaseInfluence;
1722
1722
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1723
1723
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1724
1724
  }
1725
- #endif`,GS=`#ifdef USE_MORPHTARGETS
1725
+ #endif`,XM=`#ifdef USE_MORPHTARGETS
1726
1726
  #ifndef USE_INSTANCING_MORPH
1727
1727
  uniform float morphTargetBaseInfluence;
1728
1728
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1736,12 +1736,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1736
1736
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1737
1737
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1738
1738
  }
1739
- #endif`,HS=`#ifdef USE_MORPHTARGETS
1739
+ #endif`,jM=`#ifdef USE_MORPHTARGETS
1740
1740
  transformed *= morphTargetBaseInfluence;
1741
1741
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1742
1742
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1743
1743
  }
1744
- #endif`,VS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1744
+ #endif`,qM=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1745
1745
  #ifdef FLAT_SHADED
1746
1746
  vec3 fdx = dFdx( vViewPosition );
1747
1747
  vec3 fdy = dFdy( vViewPosition );
@@ -1782,7 +1782,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1782
1782
  tbn2[1] *= faceDirection;
1783
1783
  #endif
1784
1784
  #endif
1785
- vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1785
+ vec3 nonPerturbedNormal = normal;`,YM=`#ifdef USE_NORMALMAP_OBJECTSPACE
1786
1786
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1787
1787
  #ifdef FLIP_SIDED
1788
1788
  normal = - normal;
@@ -1800,19 +1800,19 @@ vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1800
1800
  normal = normalize( tbn * mapN );
1801
1801
  #elif defined( USE_BUMPMAP )
1802
1802
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1803
- #endif`,WS=`#ifndef FLAT_SHADED
1803
+ #endif`,JM=`#ifndef FLAT_SHADED
1804
1804
  varying vec3 vNormal;
1805
1805
  #ifdef USE_TANGENT
1806
1806
  varying vec3 vTangent;
1807
1807
  varying vec3 vBitangent;
1808
1808
  #endif
1809
- #endif`,ZS=`#ifndef FLAT_SHADED
1809
+ #endif`,KM=`#ifndef FLAT_SHADED
1810
1810
  varying vec3 vNormal;
1811
1811
  #ifdef USE_TANGENT
1812
1812
  varying vec3 vTangent;
1813
1813
  varying vec3 vBitangent;
1814
1814
  #endif
1815
- #endif`,XS=`#ifndef FLAT_SHADED
1815
+ #endif`,QM=`#ifndef FLAT_SHADED
1816
1816
  vNormal = normalize( transformedNormal );
1817
1817
  #ifdef USE_TANGENT
1818
1818
  vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1821
1821
  vBitangent = - vBitangent;
1822
1822
  #endif
1823
1823
  #endif
1824
- #endif`,qS=`#ifdef USE_NORMALMAP
1824
+ #endif`,ew=`#ifdef USE_NORMALMAP
1825
1825
  uniform sampler2D normalMap;
1826
1826
  uniform vec2 normalScale;
1827
1827
  #endif
@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1843
1843
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1844
1844
  return mat3( T * scale, B * scale, N );
1845
1845
  }
1846
- #endif`,jS=`#ifdef USE_CLEARCOAT
1846
+ #endif`,tw=`#ifdef USE_CLEARCOAT
1847
1847
  vec3 clearcoatNormal = nonPerturbedNormal;
1848
- #endif`,YS=`#ifdef USE_CLEARCOAT_NORMALMAP
1848
+ #endif`,nw=`#ifdef USE_CLEARCOAT_NORMALMAP
1849
1849
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1850
1850
  clearcoatMapN.xy *= clearcoatNormalScale;
1851
1851
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1852
- #endif`,KS=`#ifdef USE_CLEARCOATMAP
1852
+ #endif`,iw=`#ifdef USE_CLEARCOATMAP
1853
1853
  uniform sampler2D clearcoatMap;
1854
1854
  #endif
1855
1855
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1858
1858
  #endif
1859
1859
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1860
1860
  uniform sampler2D clearcoatRoughnessMap;
1861
- #endif`,JS=`#ifdef USE_IRIDESCENCEMAP
1861
+ #endif`,rw=`#ifdef USE_IRIDESCENCEMAP
1862
1862
  uniform sampler2D iridescenceMap;
1863
1863
  #endif
1864
1864
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1865
1865
  uniform sampler2D iridescenceThicknessMap;
1866
- #endif`,QS=`#ifdef OPAQUE
1866
+ #endif`,sw=`#ifdef OPAQUE
1867
1867
  diffuseColor.a = 1.0;
1868
1868
  #endif
1869
1869
  #ifdef USE_TRANSMISSION
1870
1870
  diffuseColor.a *= material.transmissionAlpha;
1871
1871
  #endif
1872
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eM=`vec3 packNormalToRGB( const in vec3 normal ) {
1872
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ow=`vec3 packNormalToRGB( const in vec3 normal ) {
1873
1873
  return normalize( normal ) * 0.5 + 0.5;
1874
1874
  }
1875
1875
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1948,9 +1948,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1948
1948
  #else
1949
1949
  return ( near * far ) / ( ( far - near ) * depth - far );
1950
1950
  #endif
1951
- }`,tM=`#ifdef PREMULTIPLIED_ALPHA
1951
+ }`,aw=`#ifdef PREMULTIPLIED_ALPHA
1952
1952
  gl_FragColor.rgb *= gl_FragColor.a;
1953
- #endif`,nM=`vec4 mvPosition = vec4( transformed, 1.0 );
1953
+ #endif`,cw=`vec4 mvPosition = vec4( transformed, 1.0 );
1954
1954
  #ifdef USE_BATCHING
1955
1955
  mvPosition = batchingMatrix * mvPosition;
1956
1956
  #endif
@@ -1958,22 +1958,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1958
1958
  mvPosition = instanceMatrix * mvPosition;
1959
1959
  #endif
1960
1960
  mvPosition = modelViewMatrix * mvPosition;
1961
- gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
1961
+ gl_Position = projectionMatrix * mvPosition;`,lw=`#ifdef DITHERING
1962
1962
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1963
- #endif`,rM=`#ifdef DITHERING
1963
+ #endif`,uw=`#ifdef DITHERING
1964
1964
  vec3 dithering( vec3 color ) {
1965
1965
  float grid_position = rand( gl_FragCoord.xy );
1966
1966
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1967
1967
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1968
1968
  return color + dither_shift_RGB;
1969
1969
  }
1970
- #endif`,sM=`float roughnessFactor = roughness;
1970
+ #endif`,hw=`float roughnessFactor = roughness;
1971
1971
  #ifdef USE_ROUGHNESSMAP
1972
1972
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1973
1973
  roughnessFactor *= texelRoughness.g;
1974
- #endif`,oM=`#ifdef USE_ROUGHNESSMAP
1974
+ #endif`,dw=`#ifdef USE_ROUGHNESSMAP
1975
1975
  uniform sampler2D roughnessMap;
1976
- #endif`,aM=`#if NUM_SPOT_LIGHT_COORDS > 0
1976
+ #endif`,fw=`#if NUM_SPOT_LIGHT_COORDS > 0
1977
1977
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1978
1978
  #endif
1979
1979
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2224,7 +2224,7 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2224
2224
  }
2225
2225
  #endif
2226
2226
  #endif
2227
- #endif`,cM=`#if NUM_SPOT_LIGHT_COORDS > 0
2227
+ #endif`,pw=`#if NUM_SPOT_LIGHT_COORDS > 0
2228
2228
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2229
2229
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2230
2230
  #endif
@@ -2269,7 +2269,7 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2269
2269
  };
2270
2270
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2271
2271
  #endif
2272
- #endif`,lM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2272
+ #endif`,mw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2273
2273
  #ifdef HAS_NORMAL
2274
2274
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2275
2275
  #else
@@ -2309,7 +2309,7 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2309
2309
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2310
2310
  }
2311
2311
  #pragma unroll_loop_end
2312
- #endif`,uM=`float getShadowMask() {
2312
+ #endif`,gw=`float getShadowMask() {
2313
2313
  float shadow = 1.0;
2314
2314
  #ifdef USE_SHADOWMAP
2315
2315
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2350
2350
  #endif
2351
2351
  #endif
2352
2352
  return shadow;
2353
- }`,hM=`#ifdef USE_SKINNING
2353
+ }`,_w=`#ifdef USE_SKINNING
2354
2354
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2355
2355
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2356
2356
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2357
2357
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2358
- #endif`,fM=`#ifdef USE_SKINNING
2358
+ #endif`,xw=`#ifdef USE_SKINNING
2359
2359
  uniform mat4 bindMatrix;
2360
2360
  uniform mat4 bindMatrixInverse;
2361
2361
  uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2370
2370
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2371
2371
  return mat4( v1, v2, v3, v4 );
2372
2372
  }
2373
- #endif`,dM=`#ifdef USE_SKINNING
2373
+ #endif`,yw=`#ifdef USE_SKINNING
2374
2374
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2375
2375
  vec4 skinned = vec4( 0.0 );
2376
2376
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2378,7 +2378,7 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2378
2378
  skinned += boneMatZ * skinVertex * skinWeight.z;
2379
2379
  skinned += boneMatW * skinVertex * skinWeight.w;
2380
2380
  transformed = ( bindMatrixInverse * skinned ).xyz;
2381
- #endif`,pM=`#ifdef USE_SKINNING
2381
+ #endif`,vw=`#ifdef USE_SKINNING
2382
2382
  mat4 skinMatrix = mat4( 0.0 );
2383
2383
  skinMatrix += skinWeight.x * boneMatX;
2384
2384
  skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
2389
2389
  #ifdef USE_TANGENT
2390
2390
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2391
2391
  #endif
2392
- #endif`,mM=`float specularStrength;
2392
+ #endif`,bw=`float specularStrength;
2393
2393
  #ifdef USE_SPECULARMAP
2394
2394
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2395
2395
  specularStrength = texelSpecular.r;
2396
2396
  #else
2397
2397
  specularStrength = 1.0;
2398
- #endif`,gM=`#ifdef USE_SPECULARMAP
2398
+ #endif`,Sw=`#ifdef USE_SPECULARMAP
2399
2399
  uniform sampler2D specularMap;
2400
- #endif`,_M=`#if defined( TONE_MAPPING )
2400
+ #endif`,Mw=`#if defined( TONE_MAPPING )
2401
2401
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2402
- #endif`,xM=`#ifndef saturate
2402
+ #endif`,ww=`#ifndef saturate
2403
2403
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2404
2404
  #endif
2405
2405
  uniform float toneMappingExposure;
@@ -2496,7 +2496,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2496
2496
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2497
2497
  return mix( color, vec3( newPeak ), g );
2498
2498
  }
2499
- vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISSION
2499
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ew=`#ifdef USE_TRANSMISSION
2500
2500
  material.transmission = transmission;
2501
2501
  material.transmissionAlpha = 1.0;
2502
2502
  material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2517
2517
  material.attenuationColor, material.attenuationDistance );
2518
2518
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2519
2519
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2520
- #endif`,vM=`#ifdef USE_TRANSMISSION
2520
+ #endif`,Aw=`#ifdef USE_TRANSMISSION
2521
2521
  uniform float transmission;
2522
2522
  uniform float thickness;
2523
2523
  uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2643
2643
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2644
2644
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2645
2645
  }
2646
- #endif`,bM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2646
+ #endif`,Tw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2647
2647
  varying vec2 vUv;
2648
2648
  #endif
2649
2649
  #ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2713
2713
  #ifdef USE_THICKNESSMAP
2714
2714
  uniform mat3 thicknessMapTransform;
2715
2715
  varying vec2 vThicknessMapUv;
2716
- #endif`,SM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2716
+ #endif`,Rw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2717
2717
  varying vec2 vUv;
2718
2718
  #endif
2719
2719
  #ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2807
2807
  #ifdef USE_THICKNESSMAP
2808
2808
  uniform mat3 thicknessMapTransform;
2809
2809
  varying vec2 vThicknessMapUv;
2810
- #endif`,MM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2810
+ #endif`,Cw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2811
2811
  vUv = vec3( uv, 1 ).xy;
2812
2812
  #endif
2813
2813
  #ifdef USE_MAP
@@ -2878,7 +2878,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2878
2878
  #endif
2879
2879
  #ifdef USE_THICKNESSMAP
2880
2880
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2881
- #endif`;var wM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2881
+ #endif`;var Pw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2882
2882
  vec4 worldPosition = vec4( transformed, 1.0 );
2883
2883
  #ifdef USE_BATCHING
2884
2884
  worldPosition = batchingMatrix * worldPosition;
@@ -2887,12 +2887,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISS
2887
2887
  worldPosition = instanceMatrix * worldPosition;
2888
2888
  #endif
2889
2889
  worldPosition = modelMatrix * worldPosition;
2890
- #endif`,EM=`varying vec2 vUv;
2890
+ #endif`,Iw=`varying vec2 vUv;
2891
2891
  uniform mat3 uvTransform;
2892
2892
  void main() {
2893
2893
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2894
2894
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2895
- }`,TM=`uniform sampler2D t2D;
2895
+ }`,Lw=`uniform sampler2D t2D;
2896
2896
  uniform float backgroundIntensity;
2897
2897
  varying vec2 vUv;
2898
2898
  void main() {
@@ -2904,14 +2904,14 @@ void main() {
2904
2904
  gl_FragColor = texColor;
2905
2905
  #include <tonemapping_fragment>
2906
2906
  #include <colorspace_fragment>
2907
- }`,AM=`varying vec3 vWorldDirection;
2907
+ }`,Nw=`varying vec3 vWorldDirection;
2908
2908
  #include <common>
2909
2909
  void main() {
2910
2910
  vWorldDirection = transformDirection( position, modelMatrix );
2911
2911
  #include <begin_vertex>
2912
2912
  #include <project_vertex>
2913
2913
  gl_Position.z = gl_Position.w;
2914
- }`,RM=`#ifdef ENVMAP_TYPE_CUBE
2914
+ }`,Dw=`#ifdef ENVMAP_TYPE_CUBE
2915
2915
  uniform samplerCube envMap;
2916
2916
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2917
2917
  uniform sampler2D envMap;
@@ -2933,14 +2933,14 @@ void main() {
2933
2933
  gl_FragColor = texColor;
2934
2934
  #include <tonemapping_fragment>
2935
2935
  #include <colorspace_fragment>
2936
- }`,CM=`varying vec3 vWorldDirection;
2936
+ }`,Ow=`varying vec3 vWorldDirection;
2937
2937
  #include <common>
2938
2938
  void main() {
2939
2939
  vWorldDirection = transformDirection( position, modelMatrix );
2940
2940
  #include <begin_vertex>
2941
2941
  #include <project_vertex>
2942
2942
  gl_Position.z = gl_Position.w;
2943
- }`,PM=`uniform samplerCube tCube;
2943
+ }`,Uw=`uniform samplerCube tCube;
2944
2944
  uniform float tFlip;
2945
2945
  uniform float opacity;
2946
2946
  varying vec3 vWorldDirection;
@@ -2950,7 +2950,7 @@ void main() {
2950
2950
  gl_FragColor.a *= opacity;
2951
2951
  #include <tonemapping_fragment>
2952
2952
  #include <colorspace_fragment>
2953
- }`,IM=`#include <common>
2953
+ }`,Fw=`#include <common>
2954
2954
  #include <batching_pars_vertex>
2955
2955
  #include <uv_pars_vertex>
2956
2956
  #include <displacementmap_pars_vertex>
@@ -2977,7 +2977,7 @@ void main() {
2977
2977
  #include <logdepthbuf_vertex>
2978
2978
  #include <clipping_planes_vertex>
2979
2979
  vHighPrecisionZW = gl_Position.zw;
2980
- }`,LM=`#if DEPTH_PACKING == 3200
2980
+ }`,zw=`#if DEPTH_PACKING == 3200
2981
2981
  uniform float opacity;
2982
2982
  #endif
2983
2983
  #include <common>
@@ -3015,7 +3015,7 @@ void main() {
3015
3015
  #elif DEPTH_PACKING == 3203
3016
3016
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
3017
3017
  #endif
3018
- }`,NM=`#define DISTANCE
3018
+ }`,kw=`#define DISTANCE
3019
3019
  varying vec3 vWorldPosition;
3020
3020
  #include <common>
3021
3021
  #include <batching_pars_vertex>
@@ -3042,7 +3042,7 @@ void main() {
3042
3042
  #include <worldpos_vertex>
3043
3043
  #include <clipping_planes_vertex>
3044
3044
  vWorldPosition = worldPosition.xyz;
3045
- }`,DM=`#define DISTANCE
3045
+ }`,Bw=`#define DISTANCE
3046
3046
  uniform vec3 referencePosition;
3047
3047
  uniform float nearDistance;
3048
3048
  uniform float farDistance;
@@ -3065,13 +3065,13 @@ void main() {
3065
3065
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3066
3066
  dist = saturate( dist );
3067
3067
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3068
- }`,OM=`varying vec3 vWorldDirection;
3068
+ }`,Vw=`varying vec3 vWorldDirection;
3069
3069
  #include <common>
3070
3070
  void main() {
3071
3071
  vWorldDirection = transformDirection( position, modelMatrix );
3072
3072
  #include <begin_vertex>
3073
3073
  #include <project_vertex>
3074
- }`,UM=`uniform sampler2D tEquirect;
3074
+ }`,Gw=`uniform sampler2D tEquirect;
3075
3075
  varying vec3 vWorldDirection;
3076
3076
  #include <common>
3077
3077
  void main() {
@@ -3080,7 +3080,7 @@ void main() {
3080
3080
  gl_FragColor = texture2D( tEquirect, sampleUV );
3081
3081
  #include <tonemapping_fragment>
3082
3082
  #include <colorspace_fragment>
3083
- }`,FM=`uniform float scale;
3083
+ }`,Hw=`uniform float scale;
3084
3084
  attribute float lineDistance;
3085
3085
  varying float vLineDistance;
3086
3086
  #include <common>
@@ -3102,7 +3102,7 @@ void main() {
3102
3102
  #include <logdepthbuf_vertex>
3103
3103
  #include <clipping_planes_vertex>
3104
3104
  #include <fog_vertex>
3105
- }`,zM=`uniform vec3 diffuse;
3105
+ }`,$w=`uniform vec3 diffuse;
3106
3106
  uniform float opacity;
3107
3107
  uniform float dashSize;
3108
3108
  uniform float totalSize;
@@ -3130,7 +3130,7 @@ void main() {
3130
3130
  #include <colorspace_fragment>
3131
3131
  #include <fog_fragment>
3132
3132
  #include <premultiplied_alpha_fragment>
3133
- }`,kM=`#include <common>
3133
+ }`,Ww=`#include <common>
3134
3134
  #include <batching_pars_vertex>
3135
3135
  #include <uv_pars_vertex>
3136
3136
  #include <envmap_pars_vertex>
@@ -3162,7 +3162,7 @@ void main() {
3162
3162
  #include <worldpos_vertex>
3163
3163
  #include <envmap_vertex>
3164
3164
  #include <fog_vertex>
3165
- }`,BM=`uniform vec3 diffuse;
3165
+ }`,Zw=`uniform vec3 diffuse;
3166
3166
  uniform float opacity;
3167
3167
  #ifndef FLAT_SHADED
3168
3168
  varying vec3 vNormal;
@@ -3210,7 +3210,7 @@ void main() {
3210
3210
  #include <fog_fragment>
3211
3211
  #include <premultiplied_alpha_fragment>
3212
3212
  #include <dithering_fragment>
3213
- }`,GM=`#define LAMBERT
3213
+ }`,Xw=`#define LAMBERT
3214
3214
  varying vec3 vViewPosition;
3215
3215
  #include <common>
3216
3216
  #include <batching_pars_vertex>
@@ -3249,7 +3249,7 @@ void main() {
3249
3249
  #include <envmap_vertex>
3250
3250
  #include <shadowmap_vertex>
3251
3251
  #include <fog_vertex>
3252
- }`,HM=`#define LAMBERT
3252
+ }`,jw=`#define LAMBERT
3253
3253
  uniform vec3 diffuse;
3254
3254
  uniform vec3 emissive;
3255
3255
  uniform float opacity;
@@ -3307,7 +3307,7 @@ void main() {
3307
3307
  #include <fog_fragment>
3308
3308
  #include <premultiplied_alpha_fragment>
3309
3309
  #include <dithering_fragment>
3310
- }`,VM=`#define MATCAP
3310
+ }`,qw=`#define MATCAP
3311
3311
  varying vec3 vViewPosition;
3312
3312
  #include <common>
3313
3313
  #include <batching_pars_vertex>
@@ -3341,7 +3341,7 @@ void main() {
3341
3341
  #include <clipping_planes_vertex>
3342
3342
  #include <fog_vertex>
3343
3343
  vViewPosition = - mvPosition.xyz;
3344
- }`,$M=`#define MATCAP
3344
+ }`,Yw=`#define MATCAP
3345
3345
  uniform vec3 diffuse;
3346
3346
  uniform float opacity;
3347
3347
  uniform sampler2D matcap;
@@ -3387,7 +3387,7 @@ void main() {
3387
3387
  #include <fog_fragment>
3388
3388
  #include <premultiplied_alpha_fragment>
3389
3389
  #include <dithering_fragment>
3390
- }`,WM=`#define NORMAL
3390
+ }`,Jw=`#define NORMAL
3391
3391
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3392
3392
  varying vec3 vViewPosition;
3393
3393
  #endif
@@ -3420,7 +3420,7 @@ void main() {
3420
3420
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3421
3421
  vViewPosition = - mvPosition.xyz;
3422
3422
  #endif
3423
- }`,ZM=`#define NORMAL
3423
+ }`,Kw=`#define NORMAL
3424
3424
  uniform float opacity;
3425
3425
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3426
3426
  varying vec3 vViewPosition;
@@ -3441,7 +3441,7 @@ void main() {
3441
3441
  #ifdef OPAQUE
3442
3442
  gl_FragColor.a = 1.0;
3443
3443
  #endif
3444
- }`,XM=`#define PHONG
3444
+ }`,Qw=`#define PHONG
3445
3445
  varying vec3 vViewPosition;
3446
3446
  #include <common>
3447
3447
  #include <batching_pars_vertex>
@@ -3480,7 +3480,7 @@ void main() {
3480
3480
  #include <envmap_vertex>
3481
3481
  #include <shadowmap_vertex>
3482
3482
  #include <fog_vertex>
3483
- }`,qM=`#define PHONG
3483
+ }`,eE=`#define PHONG
3484
3484
  uniform vec3 diffuse;
3485
3485
  uniform vec3 emissive;
3486
3486
  uniform vec3 specular;
@@ -3540,7 +3540,7 @@ void main() {
3540
3540
  #include <fog_fragment>
3541
3541
  #include <premultiplied_alpha_fragment>
3542
3542
  #include <dithering_fragment>
3543
- }`,jM=`#define STANDARD
3543
+ }`,tE=`#define STANDARD
3544
3544
  varying vec3 vViewPosition;
3545
3545
  #ifdef USE_TRANSMISSION
3546
3546
  varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
3583
3583
  #ifdef USE_TRANSMISSION
3584
3584
  vWorldPosition = worldPosition.xyz;
3585
3585
  #endif
3586
- }`,YM=`#define STANDARD
3586
+ }`,nE=`#define STANDARD
3587
3587
  #ifdef PHYSICAL
3588
3588
  #define IOR
3589
3589
  #define USE_SPECULAR
@@ -3711,7 +3711,7 @@ void main() {
3711
3711
  #include <fog_fragment>
3712
3712
  #include <premultiplied_alpha_fragment>
3713
3713
  #include <dithering_fragment>
3714
- }`,KM=`#define TOON
3714
+ }`,iE=`#define TOON
3715
3715
  varying vec3 vViewPosition;
3716
3716
  #include <common>
3717
3717
  #include <batching_pars_vertex>
@@ -3748,7 +3748,7 @@ void main() {
3748
3748
  #include <worldpos_vertex>
3749
3749
  #include <shadowmap_vertex>
3750
3750
  #include <fog_vertex>
3751
- }`,JM=`#define TOON
3751
+ }`,rE=`#define TOON
3752
3752
  uniform vec3 diffuse;
3753
3753
  uniform vec3 emissive;
3754
3754
  uniform float opacity;
@@ -3800,7 +3800,7 @@ void main() {
3800
3800
  #include <fog_fragment>
3801
3801
  #include <premultiplied_alpha_fragment>
3802
3802
  #include <dithering_fragment>
3803
- }`,QM=`uniform float size;
3803
+ }`,sE=`uniform float size;
3804
3804
  uniform float scale;
3805
3805
  #include <common>
3806
3806
  #include <color_pars_vertex>
@@ -3831,7 +3831,7 @@ void main() {
3831
3831
  #include <clipping_planes_vertex>
3832
3832
  #include <worldpos_vertex>
3833
3833
  #include <fog_vertex>
3834
- }`,ew=`uniform vec3 diffuse;
3834
+ }`,oE=`uniform vec3 diffuse;
3835
3835
  uniform float opacity;
3836
3836
  #include <common>
3837
3837
  #include <color_pars_fragment>
@@ -3856,7 +3856,7 @@ void main() {
3856
3856
  #include <colorspace_fragment>
3857
3857
  #include <fog_fragment>
3858
3858
  #include <premultiplied_alpha_fragment>
3859
- }`,tw=`#include <common>
3859
+ }`,aE=`#include <common>
3860
3860
  #include <batching_pars_vertex>
3861
3861
  #include <fog_pars_vertex>
3862
3862
  #include <morphtarget_pars_vertex>
@@ -3879,7 +3879,7 @@ void main() {
3879
3879
  #include <worldpos_vertex>
3880
3880
  #include <shadowmap_vertex>
3881
3881
  #include <fog_vertex>
3882
- }`,nw=`uniform vec3 color;
3882
+ }`,cE=`uniform vec3 color;
3883
3883
  uniform float opacity;
3884
3884
  #include <common>
3885
3885
  #include <fog_pars_fragment>
@@ -3895,7 +3895,7 @@ void main() {
3895
3895
  #include <colorspace_fragment>
3896
3896
  #include <fog_fragment>
3897
3897
  #include <premultiplied_alpha_fragment>
3898
- }`,iw=`uniform float rotation;
3898
+ }`,lE=`uniform float rotation;
3899
3899
  uniform vec2 center;
3900
3900
  #include <common>
3901
3901
  #include <uv_pars_vertex>
@@ -3919,7 +3919,7 @@ void main() {
3919
3919
  #include <logdepthbuf_vertex>
3920
3920
  #include <clipping_planes_vertex>
3921
3921
  #include <fog_vertex>
3922
- }`,rw=`uniform vec3 diffuse;
3922
+ }`,uE=`uniform vec3 diffuse;
3923
3923
  uniform float opacity;
3924
3924
  #include <common>
3925
3925
  #include <uv_pars_fragment>
@@ -3944,7 +3944,7 @@ void main() {
3944
3944
  #include <tonemapping_fragment>
3945
3945
  #include <colorspace_fragment>
3946
3946
  #include <fog_fragment>
3947
- }`,Ve={alphahash_fragment:Eb,alphahash_pars_fragment:Tb,alphamap_fragment:Ab,alphamap_pars_fragment:Rb,alphatest_fragment:Cb,alphatest_pars_fragment:Pb,aomap_fragment:Ib,aomap_pars_fragment:Lb,batching_pars_vertex:Nb,batching_vertex:Db,begin_vertex:Ob,beginnormal_vertex:Ub,bsdfs:Fb,iridescence_fragment:zb,bumpmap_pars_fragment:kb,clipping_planes_fragment:Bb,clipping_planes_pars_fragment:Gb,clipping_planes_pars_vertex:Hb,clipping_planes_vertex:Vb,color_fragment:$b,color_pars_fragment:Wb,color_pars_vertex:Zb,color_vertex:Xb,common:qb,cube_uv_reflection_fragment:jb,defaultnormal_vertex:Yb,displacementmap_pars_vertex:Kb,displacementmap_vertex:Jb,emissivemap_fragment:Qb,emissivemap_pars_fragment:eS,colorspace_fragment:tS,colorspace_pars_fragment:nS,envmap_fragment:iS,envmap_common_pars_fragment:rS,envmap_pars_fragment:sS,envmap_pars_vertex:oS,envmap_physical_pars_fragment:_S,envmap_vertex:aS,fog_vertex:cS,fog_pars_vertex:lS,fog_fragment:uS,fog_pars_fragment:hS,gradientmap_pars_fragment:fS,lightmap_pars_fragment:dS,lights_lambert_fragment:pS,lights_lambert_pars_fragment:mS,lights_pars_begin:gS,lights_toon_fragment:xS,lights_toon_pars_fragment:yS,lights_phong_fragment:vS,lights_phong_pars_fragment:bS,lights_physical_fragment:SS,lights_physical_pars_fragment:MS,lights_fragment_begin:wS,lights_fragment_maps:ES,lights_fragment_end:TS,lightprobes_pars_fragment:AS,logdepthbuf_fragment:RS,logdepthbuf_pars_fragment:CS,logdepthbuf_pars_vertex:PS,logdepthbuf_vertex:IS,map_fragment:LS,map_pars_fragment:NS,map_particle_fragment:DS,map_particle_pars_fragment:OS,metalnessmap_fragment:US,metalnessmap_pars_fragment:FS,morphinstance_vertex:zS,morphcolor_vertex:kS,morphnormal_vertex:BS,morphtarget_pars_vertex:GS,morphtarget_vertex:HS,normal_fragment_begin:VS,normal_fragment_maps:$S,normal_pars_fragment:WS,normal_pars_vertex:ZS,normal_vertex:XS,normalmap_pars_fragment:qS,clearcoat_normal_fragment_begin:jS,clearcoat_normal_fragment_maps:YS,clearcoat_pars_fragment:KS,iridescence_pars_fragment:JS,opaque_fragment:QS,packing:eM,premultiplied_alpha_fragment:tM,project_vertex:nM,dithering_fragment:iM,dithering_pars_fragment:rM,roughnessmap_fragment:sM,roughnessmap_pars_fragment:oM,shadowmap_pars_fragment:aM,shadowmap_pars_vertex:cM,shadowmap_vertex:lM,shadowmask_pars_fragment:uM,skinbase_vertex:hM,skinning_pars_vertex:fM,skinning_vertex:dM,skinnormal_vertex:pM,specularmap_fragment:mM,specularmap_pars_fragment:gM,tonemapping_fragment:_M,tonemapping_pars_fragment:xM,transmission_fragment:yM,transmission_pars_fragment:vM,uv_pars_fragment:bM,uv_pars_vertex:SM,uv_vertex:MM,worldpos_vertex:wM,background_vert:EM,background_frag:TM,backgroundCube_vert:AM,backgroundCube_frag:RM,cube_vert:CM,cube_frag:PM,depth_vert:IM,depth_frag:LM,distance_vert:NM,distance_frag:DM,equirect_vert:OM,equirect_frag:UM,linedashed_vert:FM,linedashed_frag:zM,meshbasic_vert:kM,meshbasic_frag:BM,meshlambert_vert:GM,meshlambert_frag:HM,meshmatcap_vert:VM,meshmatcap_frag:$M,meshnormal_vert:WM,meshnormal_frag:ZM,meshphong_vert:XM,meshphong_frag:qM,meshphysical_vert:jM,meshphysical_frag:YM,meshtoon_vert:KM,meshtoon_frag:JM,points_vert:QM,points_frag:ew,shadow_vert:tw,shadow_frag:nw,sprite_vert:iw,sprite_frag:rw},de={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(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 O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},li={basic:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:tn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:tn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:tn([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:tn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:tn([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:tn([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:tn([de.common,de.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:tn([de.lights,de.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};li.physical={uniforms:tn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Ka={r:0,b:0,g:0},sw=new Ge,Hp=new ze;Hp.set(-1,0,0,0,1,0,0,0,1);function ow(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let v=E.backgroundBlurriness>0;R=t.get(R,v)}return R}function g(E){let R=!1,v=d(E);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),R=!0;let M=e.xr.getEnvironmentBlendMode();if(M==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(M==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let v=d(R);if(v&&(v.isCubeTexture||v.mapping===Zs)){if(l===void 0)l=new _t(new Qi(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:Ar(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(sw.makeRotationFromEuler(R.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Hp);if(l.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,u!==v||f!==v.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new _t(new so(2,2),new In({name:"BackgroundMaterial",uniforms:Ar(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:qi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||f!==v.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Ka,_u(e)),n.buffers.color.setClear(Ka.r,Ka.g,Ka.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function aw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(P,F,ee,I,H){let q=!1,C=f(P,I,ee,F);if(s!==C)s=C,l(s.object);if(q=d(P,I,ee,H),q)g(P,I,ee,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(q||o){if(o=!1,v(P,F,ee,I),H!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(H).buffer)}}function c(){return e.createVertexArray()}function l(P){return e.bindVertexArray(P)}function u(P){return e.deleteVertexArray(P)}function f(P,F,ee,I){let H=I.wireframe===!0,q=i[F.id];if(q===void 0)q={},i[F.id]=q;let C=P.isInstancedMesh===!0?P.id:0,X=q[C];if(X===void 0)X={},q[C]=X;let k=X[ee.id];if(k===void 0)k={},X[ee.id]=k;let Y=k[H];if(Y===void 0)Y=h(c()),k[H]=Y;return Y}function h(P){let F=[],ee=[],I=[];for(let H=0;H<n;H++)F[H]=0,ee[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:ee,attributeDivisors:I,object:P,attributes:{},index:null}}function d(P,F,ee,I){let H=s.attributes,q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=H[k],Se=q[k];if(Se===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Se=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Se=P.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Se)return!0;if(Se&&Q.data!==Se.data)return!0;C++}if(s.attributesNum!==C)return!0;if(s.index!==I)return!0;return!1}function g(P,F,ee,I){let H={},q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=q[k];if(Q===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Q=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Q=P.instanceColor}let Se={};if(Se.attribute=Q,Q&&Q.data)Se.data=Q.data;H[k]=Se,C++}s.attributes=H,s.attributesNum=C,s.index=I}function x(){let P=s.newAttributes;for(let F=0,ee=P.length;F<ee;F++)P[F]=0}function p(P){m(P,0)}function m(P,F){let ee=s.newAttributes,I=s.enabledAttributes,H=s.attributeDivisors;if(ee[P]=1,I[P]===0)e.enableVertexAttribArray(P),I[P]=1;if(H[P]!==F)e.vertexAttribDivisor(P,F),H[P]=F}function E(){let P=s.newAttributes,F=s.enabledAttributes;for(let ee=0,I=F.length;ee<I;ee++)if(F[ee]!==P[ee])e.disableVertexAttribArray(ee),F[ee]=0}function R(P,F,ee,I,H,q,C){if(C===!0)e.vertexAttribIPointer(P,F,ee,H,q);else e.vertexAttribPointer(P,F,ee,I,H,q)}function v(P,F,ee,I){x();let H=I.attributes,q=ee.getAttributes(),C=F.defaultAttributeValues;for(let X in q){let k=q[X];if(k.location>=0){let Y=H[X];if(Y===void 0){if(X==="instanceMatrix"&&P.instanceMatrix)Y=P.instanceMatrix;if(X==="instanceColor"&&P.instanceColor)Y=P.instanceColor}if(Y!==void 0){let Q=Y.normalized,Se=Y.itemSize,ue=t.get(Y);if(ue===void 0)continue;let{buffer:Fe,type:Me,bytesPerElement:Z}=ue,re=Me===e.INT||Me===e.UNSIGNED_INT||Y.gpuType===wl;if(Y.isInterleavedBufferAttribute){let se=Y.data,xe=se.stride,we=Y.offset;if(se.isInstancedInterleavedBuffer){for(let Ee=0;Ee<k.locationSize;Ee++)m(k.location+Ee,se.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ee=0;Ee<k.locationSize;Ee++)p(k.location+Ee);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let Ee=0;Ee<k.locationSize;Ee++)R(k.location+Ee,Se/k.locationSize,Me,Q,xe*Z,(we+Se/k.locationSize*Ee)*Z,re)}else{if(Y.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)m(k.location+se,Y.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=Y.meshPerAttribute*Y.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let se=0;se<k.locationSize;se++)R(k.location+se,Se/k.locationSize,Me,Q,Se*Z,Se/k.locationSize*se*Z,re)}}else if(C!==void 0){let Q=C[X];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}E()}function M(){S();for(let P in i){let F=i[P];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P]}}function T(P){if(i[P.id]===void 0)return;let F=i[P.id];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P.id]}function A(P){for(let F in i){let ee=i[F];for(let I in ee){let H=ee[I];if(H[P.id]===void 0)continue;let q=H[P.id];for(let C in q)u(q[C].object),delete q[C];delete H[P.id]}}}function _(P){for(let F in i){let ee=i[F],I=P.isInstancedMesh===!0?P.id:0,H=ee[I];if(H===void 0)continue;for(let q in H){let C=H[q];for(let X in C)u(C[X].object),delete C[X];delete H[q]}if(delete ee[I],Object.keys(ee).length===0)delete i[F]}}function S(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:S,resetDefaultState:z,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function cw(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function lw(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==oi&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===si&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==$n&&A!==Ri&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ie("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),M=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:v,maxSamples:M,samples:T}}function uw(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Rn,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,v=m.clippingState||null;c.value=v,v=u(g,h,R,d);for(let M=0;M!==R;++M)v[M]=n[M];m.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,v=d;R!==x;++R,v+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var Ss=4,hw=6,fw=20,dw=256,uo=new Cr,vp=new Oe,Du=null,Ou=0,Uu=0,Fu=!1,pw=new O,Pr=new O;class mo{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,n=0.1,i=100,r={}){let{size:s=256,position:o=pw}=r;Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Sp(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(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(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(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(Du,Ou,Uu),this._renderer.xr.enabled=Fu,e.scissorTest=!1,bs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===as||e.mapping===vr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:$t,minFilter:$t,generateMipmaps:!1,type:si,format:oi,colorSpace:gn,depthBuffer:!1},i=bp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=bp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=mw(r)),this._blurMaterial=_w(r,e,t),this._ggxMaterial=gw(r,e,t)}return i}_compileMaterial(e){let t=new _t(new en,e);this._renderer.compile(t,uo)}_sceneToCubeUV(e,t,n,i,r){let a=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(vp),u.toneMapping=Hn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new _t(new Qi,new ai({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(vp),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let v=this._cubeSize;if(bs(i,R*v,E>2?v:0,v,v),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===as||e.mapping===vr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Sp();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;bs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,uo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-Ss?n-d+Ss:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,bs(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,uo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,bs(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,uo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ss?i-this._lodMax+Ss:0),f=4*(this._cubeSize-l);bs(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,uo)}}function mw(e){let t=[],n=[],i=e,r=e-Ss+1+hw;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,v=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(v,d*h*m);for(let M=0;M<h;M++){let T=u[M*2]*2-1,A=u[M*2+1]*2-1;if(m===0)Pr.set(1,A,T);else if(m===1)Pr.set(-T,1,-A);else if(m===2)Pr.set(-T,A,1);else if(m===3)Pr.set(-1,A,-T);else if(m===4)Pr.set(-T,-1,A);else Pr.set(T,A,-1);Pr.toArray(x,(m*h+M)*d)}}let p=new en;if(p.setAttribute("position",new Vt(g,d)),p.setAttribute("outputDirection",new Vt(x,d)),n.push(new _t(p,null)),i>Ss)i--}return{lodMeshes:n,sizeLods:t}}function bp(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=Zs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function gw(e,t,n){return new In({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:dw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
3947
+ }`,Ze={alphahash_fragment:IS,alphahash_pars_fragment:LS,alphamap_fragment:NS,alphamap_pars_fragment:DS,alphatest_fragment:OS,alphatest_pars_fragment:US,aomap_fragment:FS,aomap_pars_fragment:zS,batching_pars_vertex:kS,batching_vertex:BS,begin_vertex:VS,beginnormal_vertex:GS,bsdfs:HS,iridescence_fragment:$S,bumpmap_pars_fragment:WS,clipping_planes_fragment:ZS,clipping_planes_pars_fragment:XS,clipping_planes_pars_vertex:jS,clipping_planes_vertex:qS,color_fragment:YS,color_pars_fragment:JS,color_pars_vertex:KS,color_vertex:QS,common:eM,cube_uv_reflection_fragment:tM,defaultnormal_vertex:nM,displacementmap_pars_vertex:iM,displacementmap_vertex:rM,emissivemap_fragment:sM,emissivemap_pars_fragment:oM,colorspace_fragment:aM,colorspace_pars_fragment:cM,envmap_fragment:lM,envmap_common_pars_fragment:uM,envmap_pars_fragment:hM,envmap_pars_vertex:dM,envmap_physical_pars_fragment:MM,envmap_vertex:fM,fog_vertex:pM,fog_pars_vertex:mM,fog_fragment:gM,fog_pars_fragment:_M,gradientmap_pars_fragment:xM,lightmap_pars_fragment:yM,lights_lambert_fragment:vM,lights_lambert_pars_fragment:bM,lights_pars_begin:SM,lights_toon_fragment:wM,lights_toon_pars_fragment:EM,lights_phong_fragment:AM,lights_phong_pars_fragment:TM,lights_physical_fragment:RM,lights_physical_pars_fragment:CM,lights_fragment_begin:PM,lights_fragment_maps:IM,lights_fragment_end:LM,lightprobes_pars_fragment:NM,logdepthbuf_fragment:DM,logdepthbuf_pars_fragment:OM,logdepthbuf_pars_vertex:UM,logdepthbuf_vertex:FM,map_fragment:zM,map_pars_fragment:kM,map_particle_fragment:BM,map_particle_pars_fragment:VM,metalnessmap_fragment:GM,metalnessmap_pars_fragment:HM,morphinstance_vertex:$M,morphcolor_vertex:WM,morphnormal_vertex:ZM,morphtarget_pars_vertex:XM,morphtarget_vertex:jM,normal_fragment_begin:qM,normal_fragment_maps:YM,normal_pars_fragment:JM,normal_pars_vertex:KM,normal_vertex:QM,normalmap_pars_fragment:ew,clearcoat_normal_fragment_begin:tw,clearcoat_normal_fragment_maps:nw,clearcoat_pars_fragment:iw,iridescence_pars_fragment:rw,opaque_fragment:sw,packing:ow,premultiplied_alpha_fragment:aw,project_vertex:cw,dithering_fragment:lw,dithering_pars_fragment:uw,roughnessmap_fragment:hw,roughnessmap_pars_fragment:dw,shadowmap_pars_fragment:fw,shadowmap_pars_vertex:pw,shadowmap_vertex:mw,shadowmask_pars_fragment:gw,skinbase_vertex:_w,skinning_pars_vertex:xw,skinning_vertex:yw,skinnormal_vertex:vw,specularmap_fragment:bw,specularmap_pars_fragment:Sw,tonemapping_fragment:Mw,tonemapping_pars_fragment:ww,transmission_fragment:Ew,transmission_pars_fragment:Aw,uv_pars_fragment:Tw,uv_pars_vertex:Rw,uv_vertex:Cw,worldpos_vertex:Pw,background_vert:Iw,background_frag:Lw,backgroundCube_vert:Nw,backgroundCube_frag:Dw,cube_vert:Ow,cube_frag:Uw,depth_vert:Fw,depth_frag:zw,distance_vert:kw,distance_frag:Bw,equirect_vert:Vw,equirect_frag:Gw,linedashed_vert:Hw,linedashed_frag:$w,meshbasic_vert:Ww,meshbasic_frag:Zw,meshlambert_vert:Xw,meshlambert_frag:jw,meshmatcap_vert:qw,meshmatcap_frag:Yw,meshnormal_vert:Jw,meshnormal_frag:Kw,meshphong_vert:Qw,meshphong_frag:eE,meshphysical_vert:tE,meshphysical_frag:nE,meshtoon_vert:iE,meshtoon_frag:rE,points_vert:sE,points_frag:oE,shadow_vert:aE,shadow_frag:cE,sprite_vert:lE,sprite_frag:uE},fe={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new De(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ue(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 U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new De(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},yi={basic:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:an([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:an([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:an([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:an([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:an([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:an([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:an([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:an([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:an([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:an([fe.lights,fe.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};yi.physical={uniforms:an([yi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new De(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new De},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new De},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Tc={r:0,b:0,g:0},hE=new $e,Um=new Ve;Um.set(-1,0,0,0,1,0,0,0,1);function dE(e,t,n,i,r,s){let o=new Ue(0),a=r===!0?0:1,c,l,u=null,h=0,d=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===_o)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(yi.backgroundCube.uniforms),vertexShader:yi.backgroundCube.vertexShader,fragmentShader:yi.backgroundCube.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(hE.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Um);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||h!==y.version||d!==e.toneMapping)l.material.needsUpdate=!0,u=y,h=y.version,d=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new Po(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(yi.background.uniforms),vertexShader:yi.background.vertexShader,fragmentShader:yi.background.fragmentShader,side:ur,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||h!==y.version||d!==e.toneMapping)c.material.needsUpdate=!0,u=y,h=y.version,d=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Tc,Qu(e)),n.buffers.color.setClear(Tc.r,Tc.g,Tc.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function fE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=h(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function h(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=d(c()),k[G]=q;return q}function d(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let ee=G[k],Se=X[k];if(Se===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Se=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Se=C.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Se)return!0;if(Se&&ee.data!==Se.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let ee=X[k];if(ee===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)ee=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)ee=C.instanceColor}let Se={};if(Se.attribute=ee,ee&&ee.data)Se.data=ee.data;G[k]=Se,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[j];if(q===void 0){if(j==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(j==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let ee=q.normalized,Se=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:Me,bytesPerElement:Z}=ue,re=Me===e.INT||Me===e.UNSIGNED_INT||q.gpuType===ou;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Se/k.locationSize,Me,ee,xe*Z,(Ee+Se/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Se/k.locationSize,Me,ee,Se*Z,Se/k.locationSize*se*Z,re)}}else if(P!==void 0){let ee=P[j];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(k.location,ee);break;case 3:e.vertexAttrib3fv(k.location,ee);break;case 4:e.vertexAttrib4fv(k.location,ee);break;default:e.vertexAttrib1fv(k.location,ee)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function pE(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let d=0;for(let f=0;f<u;f++)d+=l[f];n.update(d,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function mE(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==gi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===mi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ei&&R!==Hi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let h=n.logarithmicDepthBuffer===!0,d=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&d===!1)Le("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function gE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||i!==0||r;return r=d,i=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){n=u(h,d,0)},this.setState=function(h,d,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=h,g=e.get(h);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,d,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(h,d,f,m){let _=h!==null?h.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=d.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(h[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var ks=4,_E=6,xE=20,yE=256,Oo=new $r,pm=new Ue,gh=null,_h=0,xh=0,yh=!1,vE=new U,Wr=new U;class ko{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,n=0.1,i=100,r={}){let{size:s=256,position:o=vE}=r;gh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),xh=this._renderer.getActiveMipmapLevel(),yh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=_m(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=gm(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(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(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(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(gh,_h,xh),this._renderer.xr.enabled=yh,e.scissorTest=!1,zs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ws||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);gh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),xh=this._renderer.getActiveMipmapLevel(),yh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:mi,format:gi,colorSpace:wn,depthBuffer:!1},i=mm(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=mm(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=bE(r)),this._blurMaterial=ME(r,e,t),this._ggxMaterial=SE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new on,e);this._renderer.compile(t,Oo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:h,toneMapping:d}=u;if(u.getClearColor(pm),u.toneMapping=Kn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new mr,new _i({name:"PMREM.Background",side:sn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(pm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(zs(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=d,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ws||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=_m();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=gm();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;zs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Oo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),h=c*1.25,d=u*h,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-ks?n-f+ks:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=d,a.mipInt.value=f-t,zs(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,Oo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,zs(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,Oo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-ks?i-this._lodMax+ks:0),h=4*(this._cubeSize-l);zs(t,u,h,3*l,2*l),s.setRenderTarget(t),s.render(a,Oo)}}function bE(e){let t=[],n=[],i=e,r=e-ks+1+_E;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,m=new Float32Array(f*d*h),_=new Float32Array(f*d*h);for(let g=0;g<h;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*d*g);for(let w=0;w<d;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*d+w)*f)}}let p=new on;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>ks)i--}return{lodMeshes:n,sizeLods:t}}function mm(e,t,n){let i=new En(e,t,n);return i.texture.mapping=_o,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function SE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:yE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Cc(),fragmentShader:`
3948
3948
 
3949
3949
  precision highp float;
3950
3950
  precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
4048
4048
 
4049
4049
  gl_FragColor = vec4(prefilteredColor, 1.0);
4050
4050
  }
4051
- `,blending:ii,depthTest:!1,depthWrite:!1})}function _w(e,t,n){return new In({name:"SphericalGaussianBlur",defines:{SAMPLES:fw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
4051
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function ME(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:xE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Cc(),fragmentShader:`
4052
4052
 
4053
4053
  precision highp float;
4054
4054
  precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
4108
4108
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
4109
4109
 
4110
4110
  }
4111
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Sp(){return new In({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Qa(),fragmentShader:`
4111
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function gm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cc(),fragmentShader:`
4112
4112
 
4113
4113
  precision mediump float;
4114
4114
  precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
4127
4127
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4128
4128
 
4129
4129
  }
4130
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Mp(){return new In({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Qa(),fragmentShader:`
4130
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function _m(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cc(),fragmentShader:`
4131
4131
 
4132
4132
  precision mediump float;
4133
4133
  precision mediump int;
@@ -4143,7 +4143,7 @@ void main() {
4143
4143
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4144
4144
 
4145
4145
  }
4146
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Qa(){return`
4146
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function Cc(){return`
4147
4147
 
4148
4148
  precision mediump float;
4149
4149
  precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
4158
4158
  gl_Position = vec4( position, 1.0 );
4159
4159
 
4160
4160
  }
4161
- `}class Hu extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Ba(i),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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
4161
+ `}class wh extends En{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new gc(i),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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
4162
4162
 
4163
4163
  varying vec3 vWorldDirection;
4164
4164
 
@@ -4193,7 +4193,7 @@ void main() {
4193
4193
  gl_FragColor = texture2D( tEquirect, sampleUV );
4194
4194
 
4195
4195
  }
4196
- `},i=new Qi(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:Ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;let s=new _t(i,r),o=t.minFilter;if(t.minFilter===ri)t.minFilter=$t;return new Tu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function xw(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===va||d===ba)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Hu(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===va||d===ba,x=d===as||d===vr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===va)h.mapping=as;else if(d===ba)h.mapping=vr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function yw(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)xr("WebGLRenderer: "+i+" extension not supported.");return r}}}function vw(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,v=E.length;R<v;R+=3){let M=E[R+0],T=E[R+1],A=E[R+2];h.push(M,T,T,A,A,M)}}else{let E=g.array;x=g.version;for(let R=0,v=E.length/3-1;R<v;R+=3){let M=R+0,T=R+1,A=R+2;h.push(M,T,T,A,A,M)}}let p=new(g.count>=65535?Ua:Oa)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function bw(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Sw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function Mw(e,t,n){let i=new WeakMap,r=new at;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let S=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",S)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let v=a.attributes.position.count*R,M=1;if(v>t.maxTextureSize)M=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let T=new Float32Array(v*M*4*f),A=new Na(T,v,M,f);A.type=Ri,A.needsUpdate=!0;let _=R*4;for(let z=0;z<f;z++){let P=p[z],F=m[z],ee=E[z],I=v*M*4*z;for(let H=0;H<P.count;H++){let q=H*_;if(d===!0)r.fromBufferAttribute(P,H),T[I+q+0]=r.x,T[I+q+1]=r.y,T[I+q+2]=r.z,T[I+q+3]=0;if(g===!0)r.fromBufferAttribute(F,H),T[I+q+4]=r.x,T[I+q+5]=r.y,T[I+q+6]=r.z,T[I+q+7]=0;if(x===!0)r.fromBufferAttribute(ee,H),T[I+q+8]=r.x,T[I+q+9]=r.y,T[I+q+10]=r.z,T[I+q+11]=ee.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(v,M)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function ww(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var Ew={[xl]:"LINEAR_TONE_MAPPING",[yl]:"REINHARD_TONE_MAPPING",[vl]:"CINEON_TONE_MAPPING",[Ws]:"ACES_FILMIC_TONE_MAPPING",[Sl]:"AGX_TONE_MAPPING",[Ml]:"NEUTRAL_TONE_MAPPING",[bl]:"CUSTOM_TONE_MAPPING"};function Tw(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new en;l.setAttribute("position",new un([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new un([0,2,0,0,2,0],2));let u=new xu({uniforms:{tDiffuse:{value:null}},vertexShader:`
4196
+ `},i=new mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:sn,blending:fi});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===pi)t.minFilter=qt;return new ch(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function wE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(d,f=!1){if(d===null||d===void 0)return null;if(f)return o(d);return s(d)}function s(d){if(d&&d.isTexture){let f=d.mapping;if(f===Ya||f===Ja)if(t.has(d)){let m=t.get(d).texture;return a(m,d.mapping)}else{let m=d.image;if(m&&m.height>0){let _=new wh(m.height);return _.fromEquirectangularTexture(e,d),t.set(d,_),d.addEventListener("dispose",l),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,m=f===Ya||f===Ja,_=f===ws||f===Or;if(m||_){let p=n.get(d),g=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g){if(i===null)i=new ko(e);return p=m?i.fromEquirectangular(d,p):i.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),p.texture}else if(p!==void 0)return p.texture;else{let S=d.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new ko(e);return p=m?i.fromEquirectangular(d):i.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,n.set(d,p),d.addEventListener("dispose",u),p.texture}else return null}}}return d}function a(d,f){if(f===Ya)d.mapping=ws;else if(f===Ja)d.mapping=Or;return d}function c(d){let f=0,m=6;for(let _=0;_<m;_++)if(d[_]!==void 0)f++;return f===m}function l(d){let f=d.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(d){let f=d.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function h(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:h}}function EE(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function AE(e,t,n,i){let r={},s=new WeakMap;function o(h){let d=h.target;if(d.index!==null)t.remove(d.index);for(let m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete r[d.id];let f=s.get(d);if(f)t.remove(f),s.delete(d);if(i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0)delete d._maxInstanceCount;n.memory.geometries--}function a(h,d){if(r[d.id]===!0)return d;return d.addEventListener("dispose",o),r[d.id]=!0,n.memory.geometries++,d}function c(h){let d=h.attributes;for(let f in d)t.update(d[f],e.ARRAY_BUFFER)}function l(h){let d=[],f=h.index,m=h.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];d.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;d.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?dc:hc)(d,1);p.version=_;let g=s.get(h);if(g)t.remove(g);s.set(h,p)}function u(h){let d=s.get(h);if(d){let f=h.index;if(f!==null){if(d.version<f.version)l(h)}}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function TE(e,t,n){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,d){e.drawElements(i,d,s,h*o),n.update(d,i,1)}function l(h,d,f){if(f===0)return;e.drawElementsInstanced(i,d,s,h*o,f),n.update(d,i,f)}function u(h,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,f);let _=0;for(let p=0;p<f;p++)_+=d[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function RE(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:ze("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function CE(e,t,n){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=i.get(a);if(d===void 0||d.count!==h){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(d!==void 0)d.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*h),R=new lc(A,y,w,h);R.type=Hi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<h;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}d={count:h,texture:R,size:new De(y,w)},i.set(a,d),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}return{update:s}}function PE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,h=l.geometry,d=t.get(l,h);if(s.get(d)!==u)t.update(d),s.set(d,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return d}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var IE={[eu]:"LINEAR_TONE_MAPPING",[tu]:"REINHARD_TONE_MAPPING",[nu]:"CINEON_TONE_MAPPING",[go]:"ACES_FILMIC_TONE_MAPPING",[ru]:"AGX_TONE_MAPPING",[su]:"NEUTRAL_TONE_MAPPING",[iu]:"CUSTOM_TONE_MAPPING"};function LE(e,t,n,i,r,s){let o=new En(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new on;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 u=new eh({uniforms:{tDiffuse:{value:null}},vertexShader:`
4197
4197
  precision highp float;
4198
4198
 
4199
4199
  uniform mat4 modelViewMatrix;
@@ -4239,17 +4239,17 @@ void main() {
4239
4239
  #ifdef SRGB_TRANSFER
4240
4240
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4241
4241
  #endif
4242
- }`,depthTest:!1,depthWrite:!1}),f=new _t(l,u),h=new Cr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(v,M){if(o.setSize(v,M),a!==null)a.setSize(v,M);if(c!==null)c.setSize(v,M);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(v,M)}},this.setEffects=function(v){E=v,R=E.length>0&&E[0].isRenderPass===!0;let{width:M,height:T}=o;if(E.length>0&&a===null)a=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1}),c=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(M,T)}},this.begin=function(v,M){if(x)return!1;if(v.toneMapping===Hn&&E.length===0)return!1;if(m=M,M!==null){let{width:T,height:A}=M;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=Hn,!0},this.hasRenderPass=function(){return R},this.end=function(v,M){v.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let S=E[_];if(S.enabled===!1)continue;if(S.render(v,A,T,M),S.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==v.outputColorSpace||g!==v.toneMapping){if(d=v.outputColorSpace,g=v.toneMapping,u.defines={},$e.getTransfer(d)===dt)u.defines.SRGB_TRANSFER="";let _=Ew[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,v.setRenderTarget(m),v.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Vp=new At,Bu=new Tr(1,1),$p=new Na,Wp=new mu,Zp=new Ba,wp=[],Ep=[],Tp=new Float32Array(16),Ap=new Float32Array(9),Rp=new Float32Array(4);function Ms(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=wp[r];if(s===void 0)s=new Float32Array(r),wp[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function ec(e,t){let n=Ep[t];if(n===void 0)n=new Int32Array(t),Ep[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Aw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Rw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2fv(this.addr,t),kt(n,t)}}function Cw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(zt(n,t))return;e.uniform3fv(this.addr,t),kt(n,t)}}function Pw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4fv(this.addr,t),kt(n,t)}}function Iw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Rp.set(i),e.uniformMatrix2fv(this.addr,!1,Rp),kt(n,i)}}function Lw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ap.set(i),e.uniformMatrix3fv(this.addr,!1,Ap),kt(n,i)}}function Nw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Tp.set(i),e.uniformMatrix4fv(this.addr,!1,Tp),kt(n,i)}}function Dw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Ow(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2iv(this.addr,t),kt(n,t)}}function Uw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3iv(this.addr,t),kt(n,t)}}function Fw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4iv(this.addr,t),kt(n,t)}}function zw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function kw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2uiv(this.addr,t),kt(n,t)}}function Bw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3uiv(this.addr,t),kt(n,t)}}function Gw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4uiv(this.addr,t),kt(n,t)}}function Hw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Bu.compareFunction=n.isReversedDepthBuffer()?La:Ia,s=Bu;else s=Vp;n.setTexture2D(t||s,r)}function Vw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||Wp,r)}function $w(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Zp,r)}function Ww(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||$p,r)}function Zw(e){switch(e){case 5126:return Aw;case 35664:return Rw;case 35665:return Cw;case 35666:return Pw;case 35674:return Iw;case 35675:return Lw;case 35676:return Nw;case 5124:case 35670:return Dw;case 35667:case 35671:return Ow;case 35668:case 35672:return Uw;case 35669:case 35673:return Fw;case 5125:return zw;case 36294:return kw;case 36295:return Bw;case 36296:return Gw;case 35678:case 36198:case 36298:case 36306:case 35682:return Hw;case 35679:case 36299:case 36307:return Vw;case 35680:case 36300:case 36308:case 36293:return $w;case 36289:case 36303:case 36311:case 36292:return Ww}}function Xw(e,t){e.uniform1fv(this.addr,t)}function qw(e,t){let n=Ms(t,this.size,2);e.uniform2fv(this.addr,n)}function jw(e,t){let n=Ms(t,this.size,3);e.uniform3fv(this.addr,n)}function Yw(e,t){let n=Ms(t,this.size,4);e.uniform4fv(this.addr,n)}function Kw(e,t){let n=Ms(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Jw(e,t){let n=Ms(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Qw(e,t){let n=Ms(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function eE(e,t){e.uniform1iv(this.addr,t)}function tE(e,t){e.uniform2iv(this.addr,t)}function nE(e,t){e.uniform3iv(this.addr,t)}function iE(e,t){e.uniform4iv(this.addr,t)}function rE(e,t){e.uniform1uiv(this.addr,t)}function sE(e,t){e.uniform2uiv(this.addr,t)}function oE(e,t){e.uniform3uiv(this.addr,t)}function aE(e,t){e.uniform4uiv(this.addr,t)}function cE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Bu;else o=Vp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function lE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Wp,s[o])}function uE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Zp,s[o])}function hE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||$p,s[o])}function fE(e){switch(e){case 5126:return Xw;case 35664:return qw;case 35665:return jw;case 35666:return Yw;case 35674:return Kw;case 35675:return Jw;case 35676:return Qw;case 5124:case 35670:return eE;case 35667:case 35671:return tE;case 35668:case 35672:return nE;case 35669:case 35673:return iE;case 5125:return rE;case 36294:return sE;case 36295:return oE;case 36296:return aE;case 35678:case 36198:case 36298:case 36306:case 35682:return cE;case 35679:case 36299:case 36307:return lE;case 35680:case 36300:case 36308:case 36293:return uE;case 36289:case 36303:case 36311:case 36292:return hE}}class Xp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Zw(t.type)}}class qp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=fE(t.type)}}class jp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var zu=/(\w+)(\])?(\[|\.)?/g;function Cp(e,t){e.seq.push(t),e.map[t.id]=t}function dE(e,t,n){let i=e.name,r=i.length;zu.lastIndex=0;while(!0){let s=zu.exec(i),o=zu.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Cp(n,l===void 0?new Xp(a,e,t):new qp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new jp(a),Cp(n,f);n=f}}}class po{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);dE(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Pp(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var pE=37297,mE=0;function gE(e,t){let n=e.split(`
4242
+ }`,depthTest:!1,depthWrite:!1}),h=new Mt(l,u),d=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new En(w,A,{type:mi,depthBuffer:!1,stencilBuffer:!1}),c=new En(w,A,{type:mi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Kn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Kn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=IE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(h,d),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Fm=new Nt,Sh=new Vr(1,1),zm=new lc,km=new Ju,Bm=new gc,xm=[],ym=[],vm=new Float32Array(16),bm=new Float32Array(9),Sm=new Float32Array(4);function Bs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=xm[r];if(s===void 0)s=new Float32Array(r),xm[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function Ht(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pc(e,t){let n=ym[t];if(n===void 0)n=new Int32Array(t),ym[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function NE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function DE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function OE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function UE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function FE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Sm.set(i),e.uniformMatrix2fv(this.addr,!1,Sm),$t(n,i)}}function zE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;bm.set(i),e.uniformMatrix3fv(this.addr,!1,bm),$t(n,i)}}function kE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;vm.set(i),e.uniformMatrix4fv(this.addr,!1,vm),$t(n,i)}}function BE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function VE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function GE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function HE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function $E(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function WE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function ZE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function XE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function jE(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Sh.compareFunction=n.isReversedDepthBuffer()?cc:ac,s=Sh;else s=Fm;n.setTexture2D(t||s,r)}function qE(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||km,r)}function YE(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Bm,r)}function JE(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||zm,r)}function KE(e){switch(e){case 5126:return NE;case 35664:return DE;case 35665:return OE;case 35666:return UE;case 35674:return FE;case 35675:return zE;case 35676:return kE;case 5124:case 35670:return BE;case 35667:case 35671:return VE;case 35668:case 35672:return GE;case 35669:case 35673:return HE;case 5125:return $E;case 36294:return WE;case 36295:return ZE;case 36296:return XE;case 35678:case 36198:case 36298:case 36306:case 35682:return jE;case 35679:case 36299:case 36307:return qE;case 35680:case 36300:case 36308:case 36293:return YE;case 36289:case 36303:case 36311:case 36292:return JE}}function QE(e,t){e.uniform1fv(this.addr,t)}function eA(e,t){let n=Bs(t,this.size,2);e.uniform2fv(this.addr,n)}function tA(e,t){let n=Bs(t,this.size,3);e.uniform3fv(this.addr,n)}function nA(e,t){let n=Bs(t,this.size,4);e.uniform4fv(this.addr,n)}function iA(e,t){let n=Bs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function rA(e,t){let n=Bs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function sA(e,t){let n=Bs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function oA(e,t){e.uniform1iv(this.addr,t)}function aA(e,t){e.uniform2iv(this.addr,t)}function cA(e,t){e.uniform3iv(this.addr,t)}function lA(e,t){e.uniform4iv(this.addr,t)}function uA(e,t){e.uniform1uiv(this.addr,t)}function hA(e,t){e.uniform2uiv(this.addr,t)}function dA(e,t){e.uniform3uiv(this.addr,t)}function fA(e,t){e.uniform4uiv(this.addr,t)}function pA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Sh;else o=Fm;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function mA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||km,s[o])}function gA(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Bm,s[o])}function _A(e,t,n){let i=this.cache,r=t.length,s=Pc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||zm,s[o])}function xA(e){switch(e){case 5126:return QE;case 35664:return eA;case 35665:return tA;case 35666:return nA;case 35674:return iA;case 35675:return rA;case 35676:return sA;case 5124:case 35670:return oA;case 35667:case 35671:return aA;case 35668:case 35672:return cA;case 35669:case 35673:return lA;case 5125:return uA;case 36294:return hA;case 36295:return dA;case 36296:return fA;case 35678:case 36198:case 36298:case 36306:case 35682:return pA;case 35679:case 36299:case 36307:return mA;case 35680:case 36300:case 36308:case 36293:return gA;case 36289:case 36303:case 36311:case 36292:return _A}}class Vm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=KE(t.type)}}class Gm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xA(t.type)}}class Hm{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var vh=/(\w+)(\])?(\[|\.)?/g;function Mm(e,t){e.seq.push(t),e.map[t.id]=t}function yA(e,t,n){let i=e.name,r=i.length;vh.lastIndex=0;while(!0){let s=vh.exec(i),o=vh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Mm(n,l===void 0?new Vm(a,e,t):new Gm(a,e,t));break}else{let h=n.map[a];if(h===void 0)h=new Hm(a),Mm(n,h);n=h}}}class zo{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);yA(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function wm(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var vA=37297,bA=0;function SA(e,t){let n=e.split(`
4243
4243
  `),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`
4244
- `)}var Ip=new ze;function _E(e){$e._getMatrix(Ip,$e.workingColorSpace,e);let t=`mat3( ${Ip.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case lu:return[t,"LinearTransferOETF"];case dt:return[t,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Lp(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4244
+ `)}var Em=new Ve;function MA(e){je._getMatrix(Em,je.workingColorSpace,e);let t=`mat3( ${Em.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Wu:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Am(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4245
4245
 
4246
4246
  `+s+`
4247
4247
 
4248
- `+gE(e.getShaderSource(t),a)}else return s}function xE(e,t){let n=_E(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4249
- `)}var yE={[xl]:"Linear",[yl]:"Reinhard",[vl]:"Cineon",[Ws]:"ACESFilmic",[Sl]:"AgX",[Ml]:"Neutral",[bl]:"Custom"};function vE(e,t){let n=yE[t];if(n===void 0)return Ie("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ja=new O;function bE(){$e.getLuminanceCoefficients(Ja);let e=Ja.x.toFixed(4),t=Ja.y.toFixed(4),n=Ja.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4250
- `)}function SE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(fo).join(`
4251
- `)}function ME(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4252
- `)}function wE(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function fo(e){return e!==""}function Np(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dp(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var EE=/^[ \t]*#include +<([\w\d./]+)>/gm;function Gu(e){return e.replace(EE,AE)}var TE=new Map;function AE(e,t){let n=Ve[t];if(n===void 0){let i=TE.get(t);if(i!==void 0)n=Ve[i],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Gu(n)}var RE=/#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 Op(e){return e.replace(RE,CE)}function CE(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Up(e){let t=`precision ${e.precision} float;
4248
+ `+SA(e.getShaderSource(t),a)}else return s}function wA(e,t){let n=MA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4249
+ `)}var EA={[eu]:"Linear",[tu]:"Reinhard",[nu]:"Cineon",[go]:"ACESFilmic",[ru]:"AgX",[su]:"Neutral",[iu]:"Custom"};function AA(e,t){let n=EA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Rc=new U;function TA(){je.getLuminanceCoefficients(Rc);let e=Rc.x.toFixed(4),t=Rc.y.toFixed(4),n=Rc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4250
+ `)}function RA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fo).join(`
4251
+ `)}function CA(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4252
+ `)}function PA(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function Fo(e){return e!==""}function Tm(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Rm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var IA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Mh(e){return e.replace(IA,NA)}var LA=new Map;function NA(e,t){let n=Ze[t];if(n===void 0){let i=LA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Mh(n)}var DA=/#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 Cm(e){return e.replace(DA,OA)}function OA(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Pm(e){let t=`precision ${e.precision} float;
4253
4253
  precision ${e.precision} int;
4254
4254
  precision ${e.precision} sampler2D;
4255
4255
  precision ${e.precision} samplerCube;
@@ -4269,30 +4269,30 @@ void main() {
4269
4269
  `;if(e.precision==="highp")t+=`
4270
4270
  #define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
4271
4271
  #define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
4272
- #define LOW_PRECISION`;return t}var PE={[Vs]:"SHADOWMAP_TYPE_PCF",[ss]:"SHADOWMAP_TYPE_VSM"};function IE(e){return PE[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var LE={[as]:"ENVMAP_TYPE_CUBE",[vr]:"ENVMAP_TYPE_CUBE",[Zs]:"ENVMAP_TYPE_CUBE_UV"};function NE(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return LE[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var DE={[vr]:"ENVMAP_MODE_REFRACTION"};function OE(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return DE[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var UE={[$d]:"ENVMAP_BLENDING_MULTIPLY",[Wd]:"ENVMAP_BLENDING_MIX",[Zd]:"ENVMAP_BLENDING_ADD"};function FE(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return UE[e.combine]||"ENVMAP_BLENDING_NONE"}function zE(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function kE(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=IE(n),l=NE(n),u=OE(n),f=FE(n),h=zE(n),d=SE(n),g=ME(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
4273
- `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
4272
+ #define LOW_PRECISION`;return t}var UA={[po]:"SHADOWMAP_TYPE_PCF",[Ss]:"SHADOWMAP_TYPE_VSM"};function FA(e){return UA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var zA={[ws]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[_o]:"ENVMAP_TYPE_CUBE_UV"};function kA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return zA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var BA={[Or]:"ENVMAP_MODE_REFRACTION"};function VA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return BA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var GA={[zp]:"ENVMAP_BLENDING_MULTIPLY",[kp]:"ENVMAP_BLENDING_MIX",[Bp]:"ENVMAP_BLENDING_ADD"};function HA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return GA[e.combine]||"ENVMAP_BLENDING_NONE"}function $A(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function WA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=FA(n),l=kA(n),u=VA(n),h=HA(n),d=$A(n),f=RA(n),m=CA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`
4273
+ `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fo).join(`
4274
4274
  `),p.length>0)p+=`
4275
- `;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
4276
- `),m.length>0)m+=`
4277
- `}else p=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4278
- `].filter(fo).join(`
4279
- `),m=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hn?"#define TONE_MAPPING":"",n.toneMapping!==Hn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Hn?vE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,xE("linearToOutputTexel",n.outputColorSpace),bE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4280
- `].filter(fo).join(`
4281
- `);if(o=Gu(o),o=Np(o,n),o=Dp(o,n),a=Gu(a),a=Np(a,n),a=Dp(a,n),o=Op(o),a=Op(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
4282
- `,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4275
+ `;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fo).join(`
4276
+ `),g.length>0)g+=`
4277
+ `}else p=[Pm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4278
+ `].filter(Fo).join(`
4279
+ `),g=[Pm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Kn?"#define TONE_MAPPING":"",n.toneMapping!==Kn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Kn?AA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,wA("linearToOutputTexel",n.outputColorSpace),TA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4280
+ `].filter(Fo).join(`
4281
+ `);if(o=Mh(o),o=Tm(o,n),o=Rm(o,n),a=Mh(a),a=Tm(a,n),a=Rm(a,n),o=Cm(o),a=Cm(a),n.isRawShaderMaterial!==!0)S=`#version 300 es
4282
+ `,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4283
4283
  `)+`
4284
- `+p,m=["#define varying in",n.glslVersion===uu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===uu?"":"#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(`
4284
+ `+p,g=["#define varying in",n.glslVersion===Zu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Zu?"":"#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(`
4285
4285
  `)+`
4286
- `+m;let R=E+p+o,v=E+m+a,M=Pp(r,r.VERTEX_SHADER,R),T=Pp(r,r.FRAGMENT_SHADER,v);if(r.attachShader(x,M),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(P){if(e.debug.checkShaderErrors){let F=r.getProgramInfoLog(x)||"",ee=r.getShaderInfoLog(M)||"",I=r.getShaderInfoLog(T)||"",H=F.trim(),q=ee.trim(),C=I.trim(),X=!0,k=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(X=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,M,T);else{let Y=Lp(r,M,"vertex"),Q=Lp(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
4286
+ `+g;let T=S+p+o,y=S+g+a,w=wm(r,r.VERTEX_SHADER,T),A=wm(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Am(r,w,"vertex"),ee=Am(r,A,"fragment");ze("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
4287
4287
 
4288
- Material Name: `+P.name+`
4289
- Material Type: `+P.type+`
4288
+ Material Name: `+C.name+`
4289
+ Material Type: `+C.type+`
4290
4290
 
4291
- Program Info Log: `+H+`
4292
- `+Y+`
4293
- `+Q)}else if(H!=="")Ie("WebGLProgram: Program Info Log:",H);else if(q===""||C==="")k=!1;if(k)P.diagnostics={runnable:X,programLog:H,vertexShader:{log:q,prefix:p},fragmentShader:{log:C,prefix:m}}}r.deleteShader(M),r.deleteShader(T),_=new po(r,x),S=wE(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let S;this.getAttributes=function(){if(S===void 0)A(this);return S};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(x,pE);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var BE=0;class Yp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.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,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Kp(e),t.set(e,n);return n}}class Kp{constructor(e){this.id=BE++,this.code=e,this.usedTimes=0}}function GE(e){return e===wr||e===Ra||e===Ca}function HE(e,t,n,i,r,s){let o=new Da,a=new Yp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={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 g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,S,z,P,F,ee){let I=P.fog,H=F.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,C=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,X=t.get(_.envMap||q,C),k=!!X&&X.mapping===Zs?X.image.height:null,Y=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Ie("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let Q=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Se=Q!==void 0?Q.length:0,ue=0;if(H.morphAttributes.position!==void 0)ue=1;if(H.morphAttributes.normal!==void 0)ue=2;if(H.morphAttributes.color!==void 0)ue=3;let Fe,Me,Z,re;if(Y){let mt=li[Y];Fe=mt.vertexShader,Me=mt.fragmentShader}else{Fe=_.vertexShader,Me=_.fragmentShader;let mt=a.getVertexShaderStage(_),it=a.getFragmentShaderStage(_);a.update(_,mt,it),Z=mt.id,re=it.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),we=F.isInstancedMesh===!0,Ee=F.isBatchedMesh===!0,xt=!!_.map,ke=!!_.matcap,Ze=!!X,st=!!_.aoMap,Ye=!!_.lightMap,Zt=!!_.bumpMap&&_.wireframe===!1,yt=!!_.normalMap,cn=!!_.displacementMap,Dt=!!_.emissiveMap,Ot=!!_.metalnessMap,N=!!_.roughnessMap,ln=_.anisotropy>0,nt=_.clearcoat>0,wt=_.dispersion>0,w=_.retroreflectivity>0,y=_.iridescence>0,L=_.sheen>0,V=_.transmission>0,ie=ln&&!!_.anisotropyMap,ae=nt&&!!_.clearcoatMap,he=nt&&!!_.clearcoatNormalMap,j=nt&&!!_.clearcoatRoughnessMap,te=y&&!!_.iridescenceMap,_e=y&&!!_.iridescenceThicknessMap,Pe=L&&!!_.sheenColorMap,fe=L&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Qe=V&&!!_.transmissionMap,U=V&&!!_.thicknessMap,ce=!!_.gradientMap,K=!!_.alphaMap,le=_.alphaTest>0,ye=!!_.alphaHash,ne=!!_.extensions,pe=Hn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:Y,shaderType:_.type,shaderName:_.name,vertexShader:Fe,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Ee,batchingColor:Ee&&F._colorsTexture!==null,instancing:we,instancingColor:we&&F.instanceColor!==null,instancingMorph:we&&F.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:xt,matcap:ke,envMap:Ze,envMapMode:Ze&&X.mapping,envMapCubeUVHeight:k,aoMap:st,lightMap:Ye,bumpMap:Zt,normalMap:yt,displacementMap:cn,emissiveMap:Dt,normalMapObjectSpace:yt&&_.normalMapType===ep,normalMapTangentSpace:yt&&_.normalMapType===cu,packedNormalMap:yt&&_.normalMapType===cu&&GE(_.normalMap.format),metalnessMap:Ot,roughnessMap:N,anisotropy:ln,anisotropyMap:ie,clearcoat:nt,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:j,dispersion:wt,retroreflection:w,iridescence:y,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:L,sheenColorMap:Pe,sheenRoughnessMap:fe,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Qe,thicknessMap:U,gradientMap:ce,opaque:_.transparent===!1&&_.blending===$s&&_.alphaToCoverage===!1,alphaMap:K,alphaTest:le,alphaHash:ye,combine:_.combine,mapUv:xt&&g(_.map.channel),aoMapUv:st&&g(_.aoMap.channel),lightMapUv:Ye&&g(_.lightMap.channel),bumpMapUv:Zt&&g(_.bumpMap.channel),normalMapUv:yt&&g(_.normalMap.channel),displacementMapUv:cn&&g(_.displacementMap.channel),emissiveMapUv:Dt&&g(_.emissiveMap.channel),metalnessMapUv:Ot&&g(_.metalnessMap.channel),roughnessMapUv:N&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:he&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:j&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:fe&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Qe&&g(_.transmissionMap.channel),thicknessMapUv:U&&g(_.thicknessMap.channel),alphaMapUv:K&&g(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(yt||ln),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!H.attributes.uv&&(xt||K),fog:!!I,useFog:_.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&yt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:xe,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ue,numSunLights:S.sun.length,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numSunLightShadows:S.sunShadowMap.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:xt&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===dt,decodeVideoTextureEmissive:Dt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===dt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Pn,flipSided:_.side===Qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||Ee)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let S=[];if(_.shaderID)S.push(_.shaderID);else S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let z in _.defines)S.push(z),S.push(_.defines[z]);if(_.isRawShaderMaterial===!1)m(S,_),E(S,_),S.push(e.outputColorSpace);return S.push(_.customProgramCacheKey),S.join()}function m(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numSunLights),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numSunLightShadows),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function E(_,S){if(o.disableAll(),S.instancing)o.enable(0);if(S.instancingColor)o.enable(1);if(S.instancingMorph)o.enable(2);if(S.matcap)o.enable(3);if(S.envMap)o.enable(4);if(S.normalMapObjectSpace)o.enable(5);if(S.normalMapTangentSpace)o.enable(6);if(S.clearcoat)o.enable(7);if(S.iridescence)o.enable(8);if(S.alphaTest)o.enable(9);if(S.vertexColors)o.enable(10);if(S.vertexAlphas)o.enable(11);if(S.vertexUv1s)o.enable(12);if(S.vertexUv2s)o.enable(13);if(S.vertexUv3s)o.enable(14);if(S.vertexTangents)o.enable(15);if(S.anisotropy)o.enable(16);if(S.alphaHash)o.enable(17);if(S.batching)o.enable(18);if(S.dispersion)o.enable(19);if(S.retroreflection)o.enable(24);if(S.batchingColor)o.enable(20);if(S.gradientMap)o.enable(21);if(S.packedNormalMap)o.enable(22);if(S.vertexNormals)o.enable(23);if(_.push(o.mask),o.disableAll(),S.fog)o.enable(0);if(S.useFog)o.enable(1);if(S.flatShading)o.enable(2);if(S.logarithmicDepthBuffer)o.enable(3);if(S.reversedDepthBuffer)o.enable(4);if(S.skinning)o.enable(5);if(S.morphTargets)o.enable(6);if(S.morphNormals)o.enable(7);if(S.morphColors)o.enable(8);if(S.premultipliedAlpha)o.enable(9);if(S.shadowMapEnabled)o.enable(10);if(S.doubleSided)o.enable(11);if(S.flipSided)o.enable(12);if(S.useDepthPacking)o.enable(13);if(S.dithering)o.enable(14);if(S.transmission)o.enable(15);if(S.sheen)o.enable(16);if(S.opaque)o.enable(17);if(S.pointsUvs)o.enable(18);if(S.decodeVideoTexture)o.enable(19);if(S.decodeVideoTextureEmissive)o.enable(20);if(S.alphaToCoverage)o.enable(21);if(S.numLightProbeGrids>0)o.enable(22);if(S.hasPositionAttribute)o.enable(23);_.push(o.mask)}function R(_){let S=d[_.type],z;if(S){let P=li[S];z=fp.clone(P.uniforms)}else z=_.uniforms;return z}function v(_,S){let z=u.get(S);if(z!==void 0)++z.usedTimes;else z=new kE(e,S,_,r),l.push(z),u.set(S,z);return z}function M(_){if(--_.usedTimes===0){let S=l.indexOf(_);l[S]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:v,releaseProgram:M,releaseShaderCache:T,programs:l,dispose:A}}function VE(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function $E(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Fp(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function zp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||$E);if(i.length>1)i.sort(d||Fp);if(r.length>1)r.sort(d||Fp)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function WE(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new zp,e.set(i,[o]);else if(r>=s.length)o=new zp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function ZE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new Oe};break;case"SpotLight":n={position:new O,direction:new O,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function XE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var qE=0;function jE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function YE(e){let t=new ZE,n=XE(),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 O);let r=new O,s=new Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,v=0,M=0,T=0,A=0,_=0,S=0,z=0;l.sort(jE);for(let F=0,ee=l.length;F<ee;F++){let I=l[F],{color:H,intensity:q,distance:C}=I,X=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===wr)X=I.shadow.map.texture;else X=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=H.r*q,f+=H.g*q,h+=H.b*q;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],q);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[g]=Q,i.sunShadowMap[g]=X;let Se=Y.getViewportCount();for(let ue=0;ue<Se;ue++)i.sunShadowMatrix[x+ue]=Y.getMatrix(ue),i.sunShadowCascade[x+ue]=Y._cascadeData[ue];x+=Se,g++}i.sun[d]=k,d++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=X,i.directionalShadowMatrix[p]=I.shadow.matrix,M++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(H).multiplyScalar(q),k.distance=C,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[E]=k;let Y=I.shadow;if(I.map){if(i.spotLightMap[_]=I.map,_++,Y.updateMatrices(I),I.castShadow)S++}if(i.spotLightMatrix[E]=Y.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.spotShadow[E]=Q,i.spotShadowMap[E]=X,A++}E++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(H).multiplyScalar(q),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[R]=k,R++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,Q.shadowCameraNear=Y.camera.near,Q.shadowCameraFar=Y.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=X,i.pointShadowMatrix[m]=I.shadow.matrix,T++}i.point[m]=k,m++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(q),k.groundColor.copy(I.groundColor).multiplyScalar(q),i.hemi[v]=k,v++}}if(R>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2;else i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=f,i.ambient[2]=h;let P=i.hash;if(P.sunLength!==d||P.directionalLength!==p||P.pointLength!==m||P.spotLength!==E||P.rectAreaLength!==R||P.hemiLength!==v||P.numSunShadows!==g||P.numDirectionalShadows!==M||P.numPointShadows!==T||P.numSpotShadows!==A||P.numSpotMaps!==_||P.numLightProbes!==z)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=v,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.directionalShadowMatrix.length=M,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-S,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=z,P.sunLength=d,P.directionalLength=p,P.pointLength=m,P.spotLength=E,P.rectAreaLength=R,P.hemiLength=v,P.numSunShadows=g,P.numDirectionalShadows=M,P.numPointShadows=T,P.numSpotShadows=A,P.numSpotMaps=_,P.numLightProbes=z,i.version=qE++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let v=l[E];if(v.isSunLight){let M=i.sun[f];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),f++}else if(v.isDirectionalLight){let M=i.directional[h];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),h++}else if(v.isSpotLight){let M=i.spot[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(v.isRectAreaLight){let M=i.rectArea[x];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),s.copy(v.matrixWorld),s.premultiply(m),o.extractRotation(s),M.halfWidth.set(v.width*0.5,0,0),M.halfHeight.set(0,v.height*0.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(v.isPointLight){let M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){let M=i.hemi[p];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function kp(e){let t=new YE(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function KE(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new kp(e),t.set(r,[a]);else if(s>=o.length)a=new kp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var JE=`void main() {
4291
+ Program Info Log: `+G+`
4292
+ `+q+`
4293
+ `+ee)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new zo(r,_),M=PA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,vA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=bA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var ZA=0;class $m{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.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,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Wm(e),t.set(e,n);return n}}class Wm{constructor(e){this.id=ZA++,this.code=e,this.usedTimes=0}}function XA(e){return e===kr||e===rc||e===sc}function jA(e,t,n,i,r,s){let o=new uc,a=new $m,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:h,precision:d}=i,f={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 m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,M,z,C,L,K){let I=C.fog,G=L.geometry,X=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,j=t.get(x.envMap||X,P),k=!!j&&j.mapping===_o?j.image.height:null,q=f[x.type];if(x.precision!==null){if(d=i.getMaxPrecision(x.precision),d!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Se=ee!==void 0?ee.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,Me,Z,re;if(q){let bt=yi[q];Be=bt.vertexShader,Me=bt.fragmentShader}else{Be=x.vertexShader,Me=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,wt=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,nt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,Et=!!x.normalMap,gn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=_n&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,Ne=!!x.specularColorMap,Oe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,Q=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Kn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:Me,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:wt,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:nt,bumpMap:Jt,normalMap:Et,displacementMap:gn,emissiveMap:kt,normalMapObjectSpace:Et&&x.normalMapType===jp,normalMapTangentSpace:Et&&x.normalMapType===$u,packedNormalMap:Et&&x.normalMapType===$u&&XA(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:_n,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:Ne,specularIntensityMap:Oe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===mo&&x.alphaToCoverage===!1,alphaMap:Q,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:wt&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:Et&&m(x.normalMap.channel),displacementMapUv:gn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:Ne&&m(x.specularColorMap.channel),specularIntensityMapUv:Oe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:Q&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(Et||_n),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(wt||Q),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&Et===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:wt&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===sn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=yi[M];z=om.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new WA(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function qA(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function YA(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Im(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Lm(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(d){let f=0;if(d.isInstancedMesh)f+=2;if(d.isSkinnedMesh)f+=1;return f}function a(d,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:d.id,object:d,geometry:f,material:m,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:g},e[t]=S;else S.id=d.id,S.object=d,S.geometry=f,S.material=m,S.materialVariant=o(d),S.groupOrder=_,S.renderOrder=d.renderOrder,S.z=p,S.group=g;return t++,S}function c(d,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(d,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(d,f,m,_,p,g){let S=a(d,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(d,f){if(n.length>1)n.sort(d||YA);if(i.length>1)i.sort(f||Im);if(r.length>1)r.sort(f||Im)}function h(){for(let d=t,f=e.length;d<f;d++){let m=e[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:h,sort:u}}function JA(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Lm,e.set(i,[o]);else if(r>=s.length)o=new Lm,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function KA(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new U,color:new Ue};break;case"SpotLight":n={position:new U,direction:new U,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":n={color:new Ue,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function QA(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var eT=0;function tT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function nT(e){let t=new KA,n=QA(),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 U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,h=0,d=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(tT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,h+=G.g*X,d+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=ee,i.sunShadowMap[m]=j;let Se=q.getViewportCount();for(let ue=0;ue<Se;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Se,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,i.directionalShadow[p]=ee,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,i.spotShadow[S]=ee,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let q=I.shadow,ee=n.get(I);ee.shadowIntensity=q.intensity,ee.shadowBias=q.bias,ee.shadowNormalBias=q.normalBias,ee.shadowRadius=q.radius,ee.shadowMapSize=q.mapSize,ee.shadowCameraNear=q.camera.near,ee.shadowCameraFar=q.camera.far,i.pointShadow[g]=ee,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=eT++}function c(l,u){let h=0,d=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[h];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),h++}else if(y.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Nm(e){let t=new nT(e),n=[],i=[],r=[];function s(d){h.camera=d,n.length=0,i.length=0,r.length=0}function o(d){n.push(d)}function a(d){i.push(d)}function c(d){r.push(d)}function l(){t.setup(n)}function u(d){t.setupView(n,d)}let h={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:h,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function iT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Nm(e),t.set(r,[a]);else if(s>=o.length)a=new Nm(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var rT=`void main() {
4294
4294
  gl_Position = vec4( position, 1.0 );
4295
- }`,QE=`uniform sampler2D shadow_pass;
4295
+ }`,sT=`uniform sampler2D shadow_pass;
4296
4296
  uniform vec2 resolution;
4297
4297
  uniform float radius;
4298
4298
  void main() {
@@ -4317,12 +4317,12 @@ void main() {
4317
4317
  squared_mean = squared_mean / samples;
4318
4318
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4319
4319
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4320
- }`,eT=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],tT=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],Bp=new Ge,ho=new O,ku=new O;function nT(e,t,n){let i=new no,r=new Ne,s=new Ne,o=new at,a=new yu,c=new vu,l={},u=n.maxTextureSize,f={[qi]:Qt,[Qt]:qi,[Pn]:Pn},h=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:JE,fragmentShader:QE}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new _t(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Vs;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===gd)Ie("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Vs;let S=e.getRenderTarget(),z=e.getActiveCubeFace(),P=e.getActiveMipmapLevel(),F=e.state;if(F.setBlending(ii),F.buffers.depth.getReversed()===!0)F.buffers.color.setClear(0,0,0,0);else F.buffers.color.setClear(1,1,1,1);F.buffers.depth.setTest(!0),F.setScissorTest(!1);let ee=m!==this.type;if(ee)A.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((H)=>H.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,H=T.length;I<H;I++){let q=T[I],C=q.shadow;if(C===void 0){Ie("WebGLShadowMap:",q,"has no shadow.");continue}if(C.autoUpdate===!1&&C.needsUpdate===!1)continue;r.copy(C.mapSize);let X=C.getFrameExtents();if(r.multiply(X),s.copy(C.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/X.x),r.x=s.x*X.x,C.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/X.y),r.y=s.y*X.y,C.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(C.camera._reversedDepth=k,C.map===null||ee===!0){if(C.map!==null){if(C.map.depthTexture!==null)C.map.depthTexture.dispose(),C.map.depthTexture=null;C.map.dispose()}if(this.type===ss){if(q.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}C.map=new _n(r.x,r.y,{format:wr,type:si,minFilter:$t,magFilter:$t,generateMipmaps:!1}),C.map.texture.name=q.name+".shadowMap",C.map.depthTexture=new Tr(r.x,r.y,Ri),C.map.depthTexture.name=q.name+".shadowMapDepth",C.map.depthTexture.format=Sr,C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}else{if(q.isPointLight)C.map=new Hu(r.x),C.map.depthTexture=new gu(r.x,ji);else C.map=new _n(r.x,r.y),C.map.depthTexture=new Tr(r.x,r.y,ji);if(C.map.depthTexture.name=q.name+".shadowMap",C.map.depthTexture.format=Sr,this.type===Vs)C.map.depthTexture.compareFunction=k?La:Ia,C.map.depthTexture.minFilter=$t,C.map.depthTexture.magFilter=$t;else C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}C.camera.updateProjectionMatrix()}if(C.map.isWebGLCubeRenderTarget!==!0&&(C.map.width!==r.x||C.map.height!==r.y))C.map.setSize(r.x,r.y);let Y=C.map.isWebGLCubeRenderTarget?6:C.getViewportCount();if(q.isPointLight!==!0)C.updateMatrices(q,_);for(let Q=0;Q<Y;Q++){let Se=C.getCamera(Q);if(q.isPointLight){let{camera:ue,matrix:Fe}=C,Me=q.distance||ue.far;if(Me!==ue.far)ue.far=Me,ue.updateProjectionMatrix();ho.setFromMatrixPosition(q.matrixWorld),ue.position.copy(ho),ku.copy(ue.position),ku.add(eT[Q]),ue.up.copy(tT[Q]),ue.lookAt(ku),ue.updateMatrixWorld(),Fe.makeTranslation(-ho.x,-ho.y,-ho.z),Bp.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),C._frustum.setFromProjectionMatrix(Bp,ue.coordinateSystem,ue.reversedDepth)}if(C.map.isWebGLCubeRenderTarget)e.setRenderTarget(C.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(C.map),e.clear();let ue=C.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),F.viewport(o)}i=C.getFrustum(Q),v(A,_,Se,q,this.type)}if(C.isPointLightShadow!==!0&&this.type===ss)E(C,_);C.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(S,z,P)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:wr,type:si});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,S){let z=null,P=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)z=P;else if(z=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let F=z.uuid,ee=A.uuid,I=l[F];if(I===void 0)I={},l[F]=I;let H=I[ee];if(H===void 0)H=z.clone(),I[ee]=H,A.addEventListener("dispose",M);z=H}if(z.visible=A.visible,z.wireframe=A.wireframe,S===ss)z.side=A.shadowSide!==null?A.shadowSide:A.side;else z.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(z.alphaMap=A.alphaMap,z.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,z.map=A.map,z.clipShadows=A.clipShadows,z.clippingPlanes=A.clippingPlanes,z.clipIntersection=A.clipIntersection,z.displacementMap=A.displacementMap,z.displacementScale=A.displacementScale,z.displacementBias=A.displacementBias,z.wireframeLinewidth=A.wireframeLinewidth,z.linewidth=A.linewidth,_.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let F=e.properties.get(z);F.light=_}return z}function v(T,A,_,S,z){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&z===ss)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let ee=t.update(T),I=T.material;if(Array.isArray(I)){let H=ee.groups;for(let q=0,C=H.length;q<C;q++){let X=H[q],k=I[X.materialIndex];if(k&&k.visible){let Y=R(T,k,S,z);T.onBeforeShadow(e,T,A,_,ee,Y,X),e.renderBufferDirect(_,null,ee,Y,T,X),T.onAfterShadow(e,T,A,_,ee,Y,X)}}}else if(I.visible){let H=R(T,I,S,z);T.onBeforeShadow(e,T,A,_,ee,H,null),e.renderBufferDirect(_,null,ee,H,T,null),T.onAfterShadow(e,T,A,_,ee,H,null)}}}let F=T.children;for(let ee=0,I=F.length;ee<I;ee++)v(F[ee],A,_,S,z)}function M(T){T.target.removeEventListener("dispose",M);for(let _ in l){let S=l[_],z=T.target.uuid;if(z in S)S[z].dispose(),delete S[z]}}}function iT(e,t){function n(){let U=!1,ce=new at,K=null,le=new at(0,0,0,0);return{setMask:function(ye){if(K!==ye&&!U)e.colorMask(ye,ye,ye,ye),K=ye},setLocked:function(ye){U=ye},setClear:function(ye,ne,pe,Be,mt){if(mt===!0)ye*=Be,ne*=Be,pe*=Be;if(ce.set(ye,ne,pe,Be),le.equals(ce)===!1)e.clearColor(ye,ne,pe,Be),le.copy(ce)},reset:function(){U=!1,K=null,le.set(-1,0,0,0)}}}function i(){let U=!1,ce=!1,K=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let Be=ye;ye=null,this.setClear(Be)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(K!==ne&&!U)e.depthMask(ne),K=ne},setFunc:function(ne){if(ce)ne=up[ne];if(le!==ne){switch(ne){case Fd:e.depthFunc(e.NEVER);break;case zd:e.depthFunc(e.ALWAYS);break;case kd:e.depthFunc(e.LESS);break;case _l:e.depthFunc(e.LEQUAL);break;case Bd:e.depthFunc(e.EQUAL);break;case Gd:e.depthFunc(e.GEQUAL);break;case Hd:e.depthFunc(e.GREATER);break;case Vd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){U=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){U=!1,K=null,le=null,ye=null,ce=!1}}}function r(){let U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null;return{setTest:function(it){if(!U)if(it)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(it){if(ce!==it&&!U)e.stencilMask(it),ce=it},setFunc:function(it,Kn,vi){if(K!==it||le!==Kn||ye!==vi)e.stencilFunc(it,Kn,vi),K=it,le=Kn,ye=vi},setOp:function(it,Kn,vi){if(ne!==it||pe!==Kn||Be!==vi)e.stencilOp(it,Kn,vi),ne=it,pe=Kn,Be=vi},setLocked:function(it){U=it},setClear:function(it){if(mt!==it)e.clearStencil(it),mt=it},reset:function(){U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,q=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),C=!1,X=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)X=parseFloat(/^WebGL (\d)/.exec(k)[1]),C=X>=1;else if(k.indexOf("OpenGL ES")!==-1)X=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),C=X>=2;let Y=null,Q={},Se=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Fe=new at().fromArray(Se),Me=new at().fromArray(ue);function Z(U,ce,K,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(U,ne),e.texParameteri(U,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(U,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<K;pe++)if(U===e.TEXTURE_3D||U===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(_l),Zt(!1),yt(dl),se(e.CULL_FACE),st(ii);function se(U){if(u[U]!==!0)e.enable(U),u[U]=!0}function xe(U){if(u[U]!==!1)e.disable(U),u[U]=!1}function we(U,ce){if(h[U]!==ce){if(e.bindFramebuffer(U,ce),h[U]=ce,U===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(U===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ee(U,ce){let K=g,le=!1;if(U){if(K=d.get(ce),K===void 0)K=[],d.set(ce,K);let ye=U.textures;if(K.length!==ye.length||K[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)K[ne]=e.COLOR_ATTACHMENT0+ne;K.length=ye.length,le=!0}}else if(K[0]!==e.BACK)K[0]=e.BACK,le=!0;if(le)e.drawBuffers(K)}function xt(U){if(x!==U)return e.useProgram(U),x=U,!0;return!1}let ke={[os]:e.FUNC_ADD,[xd]:e.FUNC_SUBTRACT,[yd]:e.FUNC_REVERSE_SUBTRACT};ke[vd]=e.MIN,ke[bd]=e.MAX;let Ze={[Sd]:e.ZERO,[Md]:e.ONE,[wd]:e.SRC_COLOR,[Td]:e.SRC_ALPHA,[Ld]:e.SRC_ALPHA_SATURATE,[Pd]:e.DST_COLOR,[Rd]:e.DST_ALPHA,[Ed]:e.ONE_MINUS_SRC_COLOR,[Ad]:e.ONE_MINUS_SRC_ALPHA,[Id]:e.ONE_MINUS_DST_COLOR,[Cd]:e.ONE_MINUS_DST_ALPHA,[Nd]:e.CONSTANT_COLOR,[Dd]:e.ONE_MINUS_CONSTANT_COLOR,[Od]:e.CONSTANT_ALPHA,[Ud]:e.ONE_MINUS_CONSTANT_ALPHA};function st(U,ce,K,le,ye,ne,pe,Be,mt,it){if(U===ii){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(U!==_d){if(U!==m||it!==z){if(E!==os||M!==os)e.blendEquation(e.FUNC_ADD),E=os,M=os;if(it)switch(U){case $s:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFunc(e.ONE,e.ONE);break;case ml:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case gl:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",U);break}else switch(U){case $s:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case ml:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gl:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",U);break}R=null,v=null,T=null,A=null,_.set(0,0,0),S=0,m=U,z=it}return}if(ye=ye||ce,ne=ne||K,pe=pe||le,ce!==E||ye!==M)e.blendEquationSeparate(ke[ce],ke[ye]),E=ce,M=ye;if(K!==R||le!==v||ne!==T||pe!==A)e.blendFuncSeparate(Ze[K],Ze[le],Ze[ne],Ze[pe]),R=K,v=le,T=ne,A=pe;if(Be.equals(_)===!1||mt!==S)e.blendColor(Be.r,Be.g,Be.b,mt),_.copy(Be),S=mt;m=U,z=!1}function Ye(U,ce){U.side===Pn?xe(e.CULL_FACE):se(e.CULL_FACE);let K=U.side===Qt;if(ce)K=!K;Zt(K),U.blending===$s&&U.transparent===!1?st(ii):st(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);let le=U.stencilWrite;if(a.setTest(le),le)a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass);Dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(U){if(P!==U){if(U)e.frontFace(e.CW);else e.frontFace(e.CCW);P=U}}function yt(U){if(U!==pd){if(se(e.CULL_FACE),U!==F)if(U===dl)e.cullFace(e.BACK);else if(U===md)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);F=U}function cn(U){if(U!==ee){if(C)e.lineWidth(U);ee=U}}function Dt(U,ce,K){if(U){if(se(e.POLYGON_OFFSET_FILL),I!==ce||H!==K){if(I=ce,H=K,o.getReversed())ce=-ce;e.polygonOffset(ce,K)}}else xe(e.POLYGON_OFFSET_FILL)}function Ot(U){if(U)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function N(U){if(U===void 0)U=e.TEXTURE0+q-1;if(Y!==U)e.activeTexture(U),Y=U}function ln(U,ce,K){if(K===void 0)if(Y===null)K=e.TEXTURE0+q-1;else K=Y;let le=Q[K];if(le===void 0)le={type:void 0,texture:void 0},Q[K]=le;if(le.type!==U||le.texture!==ce){if(Y!==K)e.activeTexture(K),Y=K;e.bindTexture(U,ce||re[U]),le.type=U,le.texture=ce}}function nt(){let U=Q[Y];if(U!==void 0&&U.type!==void 0)e.bindTexture(U.type,null),U.type=void 0,U.texture=void 0}function wt(){try{e.compressedTexImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function y(){try{e.texSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function L(){try{e.texSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ae(){try{e.texStorage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function he(){try{e.texStorage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function j(){try{e.texImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function te(){try{e.texImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function _e(U){if(f[U]!==void 0)return f[U];else return e.getParameter(U)}function Pe(U,ce){if(f[U]!==ce)e.pixelStorei(U,ce),f[U]=ce}function fe(U){if(Fe.equals(U)===!1)e.scissor(U.x,U.y,U.z,U.w),Fe.copy(U)}function oe(U){if(Me.equals(U)===!1)e.viewport(U.x,U.y,U.z,U.w),Me.copy(U)}function Le(U,ce){let K=l.get(ce);if(K===void 0)K=new WeakMap,l.set(ce,K);let le=K.get(U);if(le===void 0)le=e.getUniformBlockIndex(ce,U.name),K.set(U,le)}function De(U,ce){let le=l.get(ce).get(U);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,U.__bindingPointIndex),c.set(ce,le)}function Qe(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Y=null,Q={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,Fe.set(0,0,e.canvas.width,e.canvas.height),Me.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:we,drawBuffers:Ee,useProgram:xt,setBlending:st,setMaterial:Ye,setFlipSided:Zt,setCullFace:yt,setLineWidth:cn,setPolygonOffset:Dt,setScissorTest:Ot,activeTexture:N,bindTexture:ln,unbindTexture:nt,compressedTexImage2D:wt,compressedTexImage3D:w,texImage2D:j,texImage3D:te,pixelStorei:Pe,getParameter:_e,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:he,texSubImage2D:y,texSubImage3D:L,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:fe,viewport:oe,reset:Qe}}function rT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,y){return g?new OffscreenCanvas(w,y):ns("canvas")}function p(w,y,L){let V=1,ie=wt(w);if(ie.width>L||ie.height>L)V=L/Math.max(ie.width,ie.height);if(V<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 ae=Math.floor(V*ie.width),he=Math.floor(V*ie.height);if(h===void 0)h=x(ae,he);let j=y?x(ae,he):h;return j.width=ae,j.height=he,j.getContext("2d").drawImage(w,0,0,ae,he),Ie("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),j}else{if("data"in w)Ie("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(w,y,L,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let he;if(V){if(he=t.get("EXT_texture_norm16"),!he)Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let j=y;if(y===e.RED){if(L===e.FLOAT)j=e.R32F;if(L===e.HALF_FLOAT)j=e.R16F;if(L===e.UNSIGNED_BYTE)j=e.R8;if(L===e.UNSIGNED_SHORT&&he)j=he.R16_EXT;if(L===e.SHORT&&he)j=he.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.R8UI;if(L===e.UNSIGNED_SHORT)j=e.R16UI;if(L===e.UNSIGNED_INT)j=e.R32UI;if(L===e.BYTE)j=e.R8I;if(L===e.SHORT)j=e.R16I;if(L===e.INT)j=e.R32I}if(y===e.RG){if(L===e.FLOAT)j=e.RG32F;if(L===e.HALF_FLOAT)j=e.RG16F;if(L===e.UNSIGNED_BYTE)j=e.RG8;if(L===e.UNSIGNED_SHORT&&he)j=he.RG16_EXT;if(L===e.SHORT&&he)j=he.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RG8UI;if(L===e.UNSIGNED_SHORT)j=e.RG16UI;if(L===e.UNSIGNED_INT)j=e.RG32UI;if(L===e.BYTE)j=e.RG8I;if(L===e.SHORT)j=e.RG16I;if(L===e.INT)j=e.RG32I}if(y===e.RGB_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGB8UI;if(L===e.UNSIGNED_SHORT)j=e.RGB16UI;if(L===e.UNSIGNED_INT)j=e.RGB32UI;if(L===e.BYTE)j=e.RGB8I;if(L===e.SHORT)j=e.RGB16I;if(L===e.INT)j=e.RGB32I}if(y===e.RGBA_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGBA8UI;if(L===e.UNSIGNED_SHORT)j=e.RGBA16UI;if(L===e.UNSIGNED_INT)j=e.RGBA32UI;if(L===e.BYTE)j=e.RGBA8I;if(L===e.SHORT)j=e.RGBA16I;if(L===e.INT)j=e.RGBA32I}if(y===e.RGB){if(L===e.UNSIGNED_SHORT&&he)j=he.RGB16_EXT;if(L===e.SHORT&&he)j=he.RGB16_SNORM_EXT;if(L===e.UNSIGNED_INT_5_9_9_9_REV)j=e.RGB9_E5;if(L===e.UNSIGNED_INT_10F_11F_11F_REV)j=e.R11F_G11F_B10F}if(y===e.RGBA){let te=ae?lu:$e.getTransfer(ie);if(L===e.FLOAT)j=e.RGBA32F;if(L===e.HALF_FLOAT)j=e.RGBA16F;if(L===e.UNSIGNED_BYTE)j=te===dt?e.SRGB8_ALPHA8:e.RGBA8;if(L===e.UNSIGNED_SHORT&&he)j=he.RGBA16_EXT;if(L===e.SHORT&&he)j=he.RGBA16_SNORM_EXT;if(L===e.UNSIGNED_SHORT_4_4_4_4)j=e.RGBA4;if(L===e.UNSIGNED_SHORT_5_5_5_1)j=e.RGB5_A1}if(j===e.R16F||j===e.R32F||j===e.RG16F||j===e.RG32F||j===e.RGBA16F||j===e.RGBA32F)t.get("EXT_color_buffer_float");return j}function M(w,y){let L;if(w){if(y===null||y===ji||y===hs)L=e.DEPTH24_STENCIL8;else if(y===Ri)L=e.DEPTH32F_STENCIL8;else if(y===Xs)L=e.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===ji||y===hs)L=e.DEPTH_COMPONENT24;else if(y===Ri)L=e.DEPTH_COMPONENT32F;else if(y===Xs)L=e.DEPTH_COMPONENT16;return L}function T(w,y){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Vn&&w.minFilter!==$t)return Math.log2(Math.max(y.width,y.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return y.mipmaps.length;else return 1}function A(w){let y=w.target;if(y.removeEventListener("dispose",A),S(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)f.delete(y)}function _(w){let y=w.target;y.removeEventListener("dispose",_),P(y)}function S(w){let y=i.get(w);if(y.__webglInit===void 0)return;let L=w.source,V=d.get(L);if(V){let ie=V[y.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(w);if(Object.keys(V).length===0)d.delete(L)}i.remove(w)}function z(w){let y=i.get(w);e.deleteTexture(y.__webglTexture);let L=w.source,V=d.get(L);delete V[y.__cacheKey],o.memory.textures--}function P(w){let y=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(y.__webglFramebuffer[V]))for(let ie=0;ie<y.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(y.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(y.__webglFramebuffer[V]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[V])}else{if(Array.isArray(y.__webglFramebuffer))for(let V=0;V<y.__webglFramebuffer.length;V++)e.deleteFramebuffer(y.__webglFramebuffer[V]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let V=0;V<y.__webglColorRenderbuffer.length;V++)if(y.__webglColorRenderbuffer[V])e.deleteRenderbuffer(y.__webglColorRenderbuffer[V])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let L=w.textures;for(let V=0,ie=L.length;V<ie;V++){let ae=i.get(L[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(L[V])}i.remove(w)}let F=0;function ee(){F=0}function I(){return F}function H(w){F=w}function q(){let w=F;if(w>=r.maxTextures)Ie("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return F+=1,w}function C(w){let y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function X(w,y){let L=i.get(w);if(w.isVideoTexture)ln(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&L.__version!==w.version){let V=w.image;if(V===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(L,w,y);return}}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,L.__webglTexture,e.TEXTURE0+y)}function k(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,L.__webglTexture,e.TEXTURE0+y)}function Y(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}n.bindTexture(e.TEXTURE_3D,L.__webglTexture,e.TEXTURE0+y)}function Q(w,y){let L=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&L.__version!==w.version){we(L,w,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,L.__webglTexture,e.TEXTURE0+y)}let Se={[cs]:e.REPEAT,[ls]:e.CLAMP_TO_EDGE,[Sa]:e.MIRRORED_REPEAT},ue={[Vn]:e.NEAREST,[Ma]:e.NEAREST_MIPMAP_NEAREST,[br]:e.NEAREST_MIPMAP_LINEAR,[$t]:e.LINEAR,[us]:e.LINEAR_MIPMAP_NEAREST,[ri]:e.LINEAR_MIPMAP_LINEAR},Fe={[tp]:e.NEVER,[op]:e.ALWAYS,[np]:e.LESS,[Ia]:e.LEQUAL,[ip]:e.EQUAL,[La]:e.GEQUAL,[rp]:e.GREATER,[sp]:e.NOTEQUAL};function Me(w,y){if(y.type===Ri&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===$t||y.magFilter===us||y.magFilter===br||y.magFilter===ri||y.minFilter===$t||y.minFilter===us||y.minFilter===br||y.minFilter===ri))Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Se[y.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Se[y.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Se[y.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ue[y.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ue[y.minFilter]),y.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,Fe[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Vn)return;if(y.minFilter!==br&&y.minFilter!==ri)return;if(y.type===Ri&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let L=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Z(w,y){let L=!1;if(w.__webglInit===void 0)w.__webglInit=!0,y.addEventListener("dispose",A);let V=y.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=C(y);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,L=!0;ie[ae].usedTimes++;let he=ie[w.__cacheKey];if(he!==void 0){if(ie[w.__cacheKey].usedTimes--,he.usedTimes===0)z(y)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return L}function re(w,y,L){return Math.floor(Math.floor(w/L)/y)}function se(w,y,L,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,L,V,y.data);else{ae.sort((Pe,fe)=>Pe.start-fe.start);let he=0;for(let Pe=1;Pe<ae.length;Pe++){let fe=ae[he],oe=ae[Pe],Le=fe.start+fe.count,De=re(oe.start,y.width,4),Qe=re(fe.start,y.width,4);if(oe.start<=Le+1&&De===Qe&&re(oe.start+oe.count-1,y.width,4)===De)fe.count=Math.max(fe.count,oe.start+oe.count-fe.start);else++he,ae[he]=oe}ae.length=he+1;let j=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Pe=0,fe=ae.length;Pe<fe;Pe++){let oe=ae[Pe],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Qe=Le%y.width,U=Math.floor(Le/y.width),ce=De,K=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Qe),n.pixelStorei(e.UNPACK_SKIP_ROWS,U),n.texSubImage2D(e.TEXTURE_2D,0,Qe,U,ce,1,L,V,y.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,j),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(w,y,L){let V=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,y),ae=y.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+L);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+L),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let K=$e.getPrimaries($e.workingColorSpace),le=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),ye=y.colorSpace===Er||K===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let te=p(y.image,!1,r.maxTextureSize);te=nt(y,te);let _e=s.convert(y.format,y.colorSpace),Pe=s.convert(y.type),fe=v(y.internalFormat,_e,Pe,y.normalized,y.colorSpace,y.isVideoTexture);Me(V,y);let oe,Le=y.mipmaps,De=y.isVideoTexture!==!0,Qe=he.__version===void 0||ie===!0,U=ae.dataReady,ce=T(y,te);if(y.isDepthTexture){if(fe=M(y.format===Mr,y.type),Qe)if(De)n.texStorage2D(e.TEXTURE_2D,1,fe,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,null)}else if(y.isDataTexture)if(Le.length>0){if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data);y.generateMipmaps=!1}else if(De){if(Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);if(U)se(y,te,_e,Pe)}else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,te.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(De&&Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,te.depth);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)if(y.layerUpdates.size>0){let ye=Nu(oe.width,oe.height,y.format,y.type);for(let ne of y.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,oe.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,Pe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,_e,Pe,oe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)n.compressedTexSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,oe.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data)}else if(y.isDataArrayTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,te.width,te.height,te.depth);if(U)if(y.layerUpdates.size>0){let K=Nu(te.width,te.height,y.format,y.type);for(let le of y.layerUpdates){let ye=te.data.subarray(le*K/te.data.BYTES_PER_ELEMENT,(le+1)*K/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Pe,ye)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isData3DTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_3D,ce,fe,te.width,te.height,te.depth);if(U)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_3D,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isFramebufferTexture){if(Qe)if(De)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);else{let K=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,fe,K,le,0,_e,Pe,null),K>>=1,le>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let K=e.canvas;if(!K.hasAttribute("layoutsubtree"))K.setAttribute("layoutsubtree","true");if(te.parentNode!==K){K.appendChild(te),f.add(y),K.onpaint=(le)=>{let ye=le.changedElements;for(let ne of f)if(ye.includes(ne.image))ne.needsUpdate=!0},K.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Qe){let K=wt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,_e,Pe,oe)}else n.texImage2D(e.TEXTURE_2D,K,fe,_e,Pe,oe);y.generateMipmaps=!1}else if(De){if(Qe){let K=wt(te);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}if(U)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Pe,te)}else n.texImage2D(e.TEXTURE_2D,0,fe,_e,Pe,te);if(m(y))E(V);if(he.__version=ae.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function we(w,y,L){if(y.image.length!==6)return;let V=Z(w,y),ie=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+L);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+L);let he=$e.getPrimaries($e.workingColorSpace),j=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),te=y.colorSpace===Er||he===j?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=y.isCompressedTexture||y.image[0].isCompressedTexture,Pe=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let ne=0;ne<6;ne++){if(!_e&&!Pe)fe[ne]=p(y.image[ne],!0,r.maxCubemapSize);else fe[ne]=Pe?y.image[ne].image:y.image[ne];fe[ne]=nt(y,fe[ne])}let oe=fe[0],Le=s.convert(y.format,y.colorSpace),De=s.convert(y.type),Qe=v(y.internalFormat,Le,De,y.normalized,y.colorSpace),U=y.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,K=ie.dataReady,le=T(y,oe);Me(e.TEXTURE_CUBE_MAP,y);let ye;if(_e){if(U&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=fe[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(y.format!==oi)if(Le!==null)if(U){if(K)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Be.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Le,De,Be.data)}}}else{if(ye=y.mipmaps,U&&ce){if(ye.length>0)le++;let ne=wt(fe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Pe){if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe[ne].width,fe[ne].height,Le,De,fe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,fe[ne].width,fe[ne].height,0,Le,De,fe[ne].data);for(let pe=0;pe<ye.length;pe++){let mt=ye[pe].image[ne].image;if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,mt.width,mt.height,Le,De,mt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,mt.width,mt.height,0,Le,De,mt.data)}}else{if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,fe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,Le,De,fe[ne]);for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Le,De,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,Le,De,Be.image[ne])}}}if(m(y))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function Ee(w,y,L,V,ie,ae){let he=s.convert(L.format,L.colorSpace),j=s.convert(L.type),te=v(L.internalFormat,he,j,L.normalized,L.colorSpace),_e=i.get(y),Pe=i.get(L);if(Pe.__renderTarget=y,!_e.__hasExternalTextures){let fe=Math.max(1,y.width>>ae),oe=Math.max(1,y.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,fe,oe,y.depth,0,he,j,null);else n.texImage2D(ie,ae,te,fe,oe,0,he,j,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,0,Ot(y));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function xt(w,y,L){if(e.bindRenderbuffer(e.RENDERBUFFER,w),y.depthBuffer){let V=y.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=M(y.stencilBuffer,ie),he=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,w)}else{let V=y.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],he=s.convert(ae.format,ae.colorSpace),j=s.convert(ae.type),te=v(ae.internalFormat,he,j,ae.normalized,ae.colorSpace);if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,te,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ke(w,y,L){let V=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(y.depthTexture);if(ie.__renderTarget=y,!ie.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,y.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y.depthTexture);let _e=s.convert(y.depthTexture.format),Pe=s.convert(y.depthTexture.type),fe;if(y.depthTexture.format===Sr)fe=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Mr)fe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,fe,y.width,y.height,0,_e,Pe,null)}}else X(y.depthTexture,0);let ae=ie.__webglTexture,he=Ot(y),j=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+L:e.TEXTURE_2D,te=y.depthTexture.format===Mr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Sr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else if(y.depthTexture.format===Mr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let y=i.get(w),L=w.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(V){let ie=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),y.__depthDisposeCallback=ie}y.__boundDepthTexture=V}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(L)for(let V=0;V<6;V++)ke(y.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ke(y.__webglFramebuffer[0],w,0);else ke(y.__webglFramebuffer,w,0)}else if(L){y.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[V]),y.__webglDepthbuffer[V]===void 0)y.__webglDepthbuffer[V]=e.createRenderbuffer(),xt(y.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),xt(y.__webglDepthbuffer,w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(w,y,L){let V=i.get(w);if(y!==void 0)Ee(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(L!==void 0)Ze(w)}function Ye(w){let y=w.texture,L=i.get(w),V=i.get(y);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=y.version,o.memory.textures++}if(ae){L.__webglFramebuffer=[];for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer[j]=[];for(let te=0;te<y.mipmaps.length;te++)L.__webglFramebuffer[j][te]=e.createFramebuffer()}else L.__webglFramebuffer[j]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer=[];for(let j=0;j<y.mipmaps.length;j++)L.__webglFramebuffer[j]=e.createFramebuffer()}else L.__webglFramebuffer=e.createFramebuffer();if(he)for(let j=0,te=ie.length;j<te;j++){let _e=i.get(ie[j]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&N(w)===!1){L.__webglMultisampledFramebuffer=e.createFramebuffer(),L.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let j=0;j<ie.length;j++){let te=ie[j];L.__webglColorRenderbuffer[j]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,L.__webglColorRenderbuffer[j]);let _e=s.convert(te.format,te.colorSpace),Pe=s.convert(te.type),fe=v(te.internalFormat,_e,Pe,te.normalized,te.colorSpace,w.isXRRenderTarget===!0),oe=Ot(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,fe,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+j,e.RENDERBUFFER,L.__webglColorRenderbuffer[j])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)L.__webglDepthRenderbuffer=e.createRenderbuffer(),xt(L.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y);for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[j][te],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,te);else Ee(L.__webglFramebuffer[j],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);if(m(y))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let j=0,te=ie.length;j<te;j++){let _e=ie[j],Pe=i.get(_e),fe=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)fe=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(fe,Pe.__webglTexture),Me(fe,_e),Ee(L.__webglFramebuffer,w,_e,e.COLOR_ATTACHMENT0+j,fe,0),m(_e))E(fe)}n.unbindTexture()}else{let j=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)j=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(j,V.__webglTexture),Me(j,y),y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[te],w,y,e.COLOR_ATTACHMENT0,j,te);else Ee(L.__webglFramebuffer,w,y,e.COLOR_ATTACHMENT0,j,0);if(m(y))E(j);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Zt(w){let y=w.textures;for(let L=0,V=y.length;L<V;L++){let ie=y[L];if(m(ie)){let ae=R(w),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),E(ae),n.unbindTexture()}}}let yt=[],cn=[];function Dt(w){if(w.samples>0){if(N(w)===!1){let{textures:y,width:L,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(w),j=y.length>1;if(j)for(let _e=0;_e<y.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=w.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<y.length;_e++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(j){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Pe,0)}if(e.blitFramebuffer(0,0,L,V,0,0,L,V,ie,e.NEAREST),c===!0){if(yt.length=0,cn.length=0,yt.push(e.COLOR_ATTACHMENT0+_e),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)yt.push(ae),cn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,cn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,yt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),j)for(let _e=0;_e<y.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Pe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let y=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function Ot(w){return Math.min(r.maxSamples,w.samples)}function N(w){let y=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ln(w){let y=o.render.frame;if(u.get(w)!==y)u.set(w,y),w.update()}function nt(w,y){let{colorSpace:L,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return y;if(L!==gn&&L!==Er)if($e.getTransfer(L)===dt){if(V!==oi||ie!==$n)Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",L);return y}function wt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=q,this.resetTextureUnits=ee,this.getTextureUnits=I,this.setTextureUnits=H,this.setTexture2D=X,this.setTexture2DArray=k,this.setTexture3D=Y,this.setTextureCube=Q,this.rebindTextures=st,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=Dt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=N,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function sT(e,t){function n(i,r=Er){let s,o=$e.getTransfer(r);if(i===$n)return e.UNSIGNED_BYTE;if(i===El)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Tl)return e.UNSIGNED_SHORT_5_5_5_1;if(i===jd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===Yd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return e.BYTE;if(i===qd)return e.SHORT;if(i===Xs)return e.UNSIGNED_SHORT;if(i===wl)return e.INT;if(i===ji)return e.UNSIGNED_INT;if(i===Ri)return e.FLOAT;if(i===si)return e.HALF_FLOAT;if(i===Kd)return e.ALPHA;if(i===Jd)return e.RGB;if(i===oi)return e.RGBA;if(i===Sr)return e.DEPTH_COMPONENT;if(i===Mr)return e.DEPTH_STENCIL;if(i===Qd)return e.RED;if(i===Al)return e.RED_INTEGER;if(i===wr)return e.RG;if(i===Rl)return e.RG_INTEGER;if(i===Cl)return e.RGBA_INTEGER;if(i===wa||i===Ea||i===Ta||i===Aa)if(o===dt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===wa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===wa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Pl||i===Il||i===Ll||i===Nl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Pl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Il)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ll)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Nl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Dl||i===Ol||i===Ul||i===Fl||i===zl||i===Ra||i===kl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Dl||i===Ol)return o===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ul)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Fl)return s.COMPRESSED_R11_EAC;if(i===zl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ra)return s.COMPRESSED_RG11_EAC;if(i===kl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Bl||i===Gl||i===Hl||i===Vl||i===$l||i===Wl||i===Zl||i===Xl||i===ql||i===jl||i===Yl||i===Kl||i===Jl||i===Ql)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Bl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Hl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Vl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$l)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Zl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Xl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Yl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===eu||i===tu||i===nu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===eu)return o===dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===iu||i===ru||i===Ca||i===su)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===iu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ca)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===su)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===hs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var oT=`
4320
+ }`,oT=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],aT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Dm=new $e,Uo=new U,bh=new U;function cT(e,t,n){let i=new To,r=new De,s=new De,o=new ft,a=new th,c=new nh,l={},u=n.maxTextureSize,h={[ur]:sn,[sn]:ur,[kn]:kn},d=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new De},radius:{value:4}},vertexShader:rT,fragmentShader:sT}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new on;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=po;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===up)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=po;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(fi),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let j=P.getFrameExtents();if(r.multiply(j),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/j.x),r.x=s.x*j.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/j.y),r.y=s.y*j.y,P.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ss){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new En(r.x,r.y,{format:kr,type:mi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Hi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Qn,P.map.depthTexture.magFilter=Qn}else{if(X.isPointLight)P.map=new wh(r.x),P.map.depthTexture=new Ku(r.x,hr);else P.map=new En(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===po)P.map.depthTexture.compareFunction=k?cc:ac,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Qn,P.map.depthTexture.magFilter=Qn}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(X.isPointLight!==!0)P.updateMatrices(X,x);for(let ee=0;ee<q;ee++){let Se=P.getCamera(ee);if(X.isPointLight){let{camera:ue,matrix:Be}=P,Me=X.distance||ue.far;if(Me!==ue.far)ue.far=Me,ue.updateProjectionMatrix();Uo.setFromMatrixPosition(X.matrixWorld),ue.position.copy(Uo),bh.copy(ue.position),bh.add(oT[ee]),ue.up.copy(aT[ee]),ue.lookAt(bh),ue.updateMatrixWorld(),Be.makeTranslation(-Uo.x,-Uo.y,-Uo.z),Dm.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Dm,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(ee);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(ee),y(R,x,Se,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ss)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(d.defines.VSM_SAMPLES!==A.blurSamples)d.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new En(r.x,r.y,{format:kr,type:mi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);d.uniforms.shadow_pass.value=A.map.depthTexture,d.uniforms.resolution.value.set(A.map.width,A.map.height),d.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ss)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:h[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ss)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function lT(e,t){function n(){let F=!1,ce=new ft,Q=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(Q!==ye&&!F)e.colorMask(ye,ye,ye,ye),Q=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,Q=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,Q=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(Q!==ne&&!F)e.depthMask(ne),Q=ne},setFunc:function(ne){if(ce)ne=rm[ne];if(le!==ne){switch(ne){case Ip:e.depthFunc(e.NEVER);break;case Lp:e.depthFunc(e.ALWAYS);break;case Np:e.depthFunc(e.LESS);break;case Ql:e.depthFunc(e.LEQUAL);break;case Dp:e.depthFunc(e.EQUAL);break;case Op:e.depthFunc(e.GEQUAL);break;case Up:e.depthFunc(e.GREATER);break;case Fp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,Q=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,Q=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,ai,Oi){if(Q!==lt||le!==ai||ye!==Oi)e.stencilFunc(lt,ai,Oi),Q=lt,le=ai,ye=Oi},setOp:function(lt,ai,Oi){if(ne!==lt||pe!==ai||He!==Oi)e.stencilOp(lt,ai,Oi),ne=lt,pe=ai,He=Oi},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,Q=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new Ue(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,ee={},Se=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Se),Me=new ft().fromArray(ue);function Z(F,ce,Q,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<Q;pe++)if(F===e.TEXTURE_3D||F===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(Ql),Jt(!1),Et(ql),se(e.CULL_FACE),ht(fi);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(d[F]!==ce){if(e.bindFramebuffer(F,ce),d[F]=ce,F===e.DRAW_FRAMEBUFFER)d[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)d[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let Q=m,le=!1;if(F){if(Q=f.get(ce),Q===void 0)Q=[],f.set(ce,Q);let ye=F.textures;if(Q.length!==ye.length||Q[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)Q[ne]=e.COLOR_ATTACHMENT0+ne;Q.length=ye.length,le=!0}}else if(Q[0]!==e.BACK)Q[0]=e.BACK,le=!0;if(le)e.drawBuffers(Q)}function wt(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[Ms]:e.FUNC_ADD,[dp]:e.FUNC_SUBTRACT,[fp]:e.FUNC_REVERSE_SUBTRACT};Ge[pp]=e.MIN,Ge[mp]=e.MAX;let Ye={[gp]:e.ZERO,[_p]:e.ONE,[xp]:e.SRC_COLOR,[vp]:e.SRC_ALPHA,[Ap]:e.SRC_ALPHA_SATURATE,[wp]:e.DST_COLOR,[Sp]:e.DST_ALPHA,[yp]:e.ONE_MINUS_SRC_COLOR,[bp]:e.ONE_MINUS_SRC_ALPHA,[Ep]:e.ONE_MINUS_DST_COLOR,[Mp]:e.ONE_MINUS_DST_ALPHA,[Tp]:e.CONSTANT_COLOR,[Rp]:e.ONE_MINUS_CONSTANT_COLOR,[Cp]:e.CONSTANT_ALPHA,[Pp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,Q,le,ye,ne,pe,He,bt,lt){if(F===fi){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==hp){if(F!==g||lt!==z){if(S!==Ms||w!==Ms)e.blendEquation(e.FUNC_ADD),S=Ms,w=Ms;if(lt)switch(F){case mo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Yl:e.blendFunc(e.ONE,e.ONE);break;case Jl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Kl:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ze("WebGLState: Invalid blending: ",F);break}else switch(F){case mo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Yl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Jl:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Kl:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||Q,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(Q!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[Q],Ye[le],Ye[ne],Ye[pe]),T=Q,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function nt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let Q=F.side===sn;if(ce)Q=!Q;Jt(Q),F.blending===mo&&F.transparent===!1?ht(fi):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function Et(F){if(F!==cp){if(se(e.CULL_FACE),F!==L)if(F===ql)e.cullFace(e.BACK);else if(F===lp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function gn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,Q){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==Q){if(I=ce,G=Q,o.getReversed())ce=-ce;e.polygonOffset(ce,Q)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function _n(F,ce,Q){if(Q===void 0)if(q===null)Q=e.TEXTURE0+X-1;else Q=q;let le=ee[Q];if(le===void 0)le={type:void 0,texture:void 0},ee[Q]=le;if(le.type!==F||le.texture!==ce){if(q!==Q)e.activeTexture(Q),q=Q;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=ee[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ze("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ze("WebGLState:",F)}}function _e(F){if(h[F]!==void 0)return h[F];else return e.getParameter(F)}function Ie(F,ce){if(h[F]!==ce)e.pixelStorei(F,ce),h[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(Me.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),Me.copy(F)}function Ne(F,ce){let Q=l.get(ce);if(Q===void 0)Q=new WeakMap,l.set(ce,Q);let le=Q.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),Q.set(F,le)}function Oe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},h={},q=null,ee={},d={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new Ue(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.set(0,0,e.canvas.width,e.canvas.height),Me.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:Ee,drawBuffers:Ae,useProgram:wt,setBlending:ht,setMaterial:nt,setFlipSided:Jt,setCullFace:Et,setLineWidth:gn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:_n,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:Ne,uniformBlockBinding:Oe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function uT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new De,u=new WeakMap,h=new Set,d,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):ys("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(d===void 0)d=_(ae,he);let Y=v?_(ae,he):d;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?Wu:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function w(E,v){let N;if(E){if(v===null||v===hr||v===Rs)N=e.DEPTH24_STENCIL8;else if(v===Hi)N=e.DEPTH32F_STENCIL8;else if(v===xo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Rs)N=e.DEPTH_COMPONENT24;else if(v===Hi)N=e.DEPTH_COMPONENT32F;else if(v===xo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Qn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)h.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)_n(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function ee(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Se={[Es]:e.REPEAT,[As]:e.CLAMP_TO_EDGE,[Ka]:e.MIRRORED_REPEAT},ue={[Qn]:e.NEAREST,[Qa]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Ts]:e.LINEAR_MIPMAP_NEAREST,[pi]:e.LINEAR_MIPMAP_LINEAR},Be={[qp]:e.NEVER,[em]:e.ALWAYS,[Yp]:e.LESS,[ac]:e.LEQUAL,[Jp]:e.EQUAL,[cc]:e.GEQUAL,[Kp]:e.GREATER,[Qp]:e.NOTEQUAL};function Me(E,v){if(v.type===Hi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Ts||v.magFilter===Ur||v.magFilter===pi||v.minFilter===qt||v.minFilter===Ts||v.minFilter===Ur||v.minFilter===pi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Se[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Se[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Se[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Qn)return;if(v.minFilter!==Ur&&v.minFilter!==pi)return;if(v.type===Hi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],Ne=de.start+de.count,Oe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=Ne+1&&Oe===st&&re(oe.start+oe.count-1,v.width,4)===Oe)de.count=Math.max(de.count,oe.start+oe.count-de.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],Ne=Math.floor(oe.start/4),Oe=Math.ceil(oe.count/4),st=Ne%v.width,F=Math.floor(Ne/v.width),ce=Oe,Q=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Q=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||Q===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);Me(H,v);let oe,Ne=v.mipmaps,Oe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Oe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(Ne.length>0){if(Oe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Ne[0].width,Ne[0].height);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Oe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Oe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,Ne[0].width,Ne[0].height,te.depth);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],v.format!==gi)if(_e!==null)if(Oe){if(F)if(v.layerUpdates.size>0){let ye=mh(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Q,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Q,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Q,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Q,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Q,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Oe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Ne[0].width,Ne[0].height);for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],v.format!==gi)if(_e!==null)if(Oe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,Q,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Oe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let Q=mh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*Q/te.data.BYTES_PER_ELEMENT,(le+1)*Q/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Oe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Oe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let Q=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,Q,le,0,_e,Ie,null),Q>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Q=e.canvas;if(!Q.hasAttribute("layoutsubtree"))Q.setAttribute("layoutsubtree","true");if(te.parentNode!==Q){Q.appendChild(te),h.add(v),Q.onpaint=(le)=>{let ye=le.changedElements;for(let ne of h)if(ye.includes(ne.image))ne.needsUpdate=!0},Q.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Ne.length>0){if(Oe&&st){let Q=Pt(Ne[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,Q.width,Q.height)}for(let Q=0,le=Ne.length;Q<le;Q++)if(oe=Ne[Q],Oe){if(F)n.texSubImage2D(e.TEXTURE_2D,Q,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,Q,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Oe){if(st){let Q=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,Q.width,Q.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],Ne=s.convert(v.format,v.colorSpace),Oe=s.convert(v.type),st=y(v.internalFormat,Ne,Oe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,Q=ie.dataReady,le=A(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==gi)if(Ne!==null)if(F){if(Q)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,Ne,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,Ne,Oe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,Ne,Oe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,Ne,Oe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,Ne,Oe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,Ne,Oe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,Ne,Oe,bt.data)}}else{if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ne,Oe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,Ne,Oe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(Q)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Ne,Oe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,Ne,Oe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function wt(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),wt(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),wt(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function nt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),wt(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),Me(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),Me(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let Et=[],gn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=E.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(Et.length=0,gn.length=0,Et.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)Et.push(ae),gn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,gn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Et)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function _n(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==wn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==gi||ie!==ei)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ze("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=ee,this.rebindTextures=ht,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function hT(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===ei)return e.UNSIGNED_BYTE;if(i===au)return e.UNSIGNED_SHORT_4_4_4_4;if(i===cu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Hp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===$p)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Vp)return e.BYTE;if(i===Gp)return e.SHORT;if(i===xo)return e.UNSIGNED_SHORT;if(i===ou)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Hi)return e.FLOAT;if(i===mi)return e.HALF_FLOAT;if(i===Wp)return e.ALPHA;if(i===Zp)return e.RGB;if(i===gi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===Xp)return e.RED;if(i===lu)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===uu)return e.RG_INTEGER;if(i===hu)return e.RGBA_INTEGER;if(i===ec||i===tc||i===nc||i===ic)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ec)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ec)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===tc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===nc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===du||i===fu||i===pu||i===mu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===du)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===gu||i===_u||i===xu||i===yu||i===vu||i===rc||i===bu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===gu||i===_u)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===xu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===yu)return s.COMPRESSED_R11_EAC;if(i===vu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===rc)return s.COMPRESSED_RG11_EAC;if(i===bu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Su||i===Mu||i===wu||i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Su)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Mu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===wu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Uu||i===Fu||i===zu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Uu)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Fu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===zu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ku||i===Bu||i===sc||i===Vu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===ku)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Bu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===sc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Vu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Rs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var dT=`
4321
4321
  void main() {
4322
4322
 
4323
4323
  gl_Position = vec4( position, 1.0 );
4324
4324
 
4325
- }`,aT=`
4325
+ }`,fT=`
4326
4326
  uniform sampler2DArray depthColor;
4327
4327
  uniform float depthWidth;
4328
4328
  uniform float depthHeight;
@@ -4341,42 +4341,42 @@ void main() {
4341
4341
 
4342
4342
  }
4343
4343
 
4344
- }`;class Jp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ga(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new In({vertexShader:oT,fragmentShader:aT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _t(new so(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Qp extends Wn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Jp,p={},m=t.getContextAttributes(),E=null,R=null,v=[],M=[],T=new Ne,A=null,_=null,S=new Ut;S.viewport=new at;let z=new Ut;z.viewport=new at;let P=[S,z],F=new Au,ee=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getHandSpace()};function H(Z){let re=M.indexOf(Z.inputSource);if(re===-1)return;let se=v[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function q(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",C);for(let Z=0;Z<v.length;Z++){let re=M[Z];if(re===null)continue;M[Z]=null,v[Z].disconnect(re)}ee=null,I=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",q),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:oi,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,we=null;if(m.depth)we=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Mr:Sr,xe=m.stencil?hs:ji;let Ee={colorFormat:t.RGBA8,depthFormat:we,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(Ee),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:oi,type:$n,depthTexture:new Tr(f.textureWidth,f.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function C(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=M.indexOf(se);if(xe>=0)M[xe]=null,v[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=M.indexOf(se);if(xe===-1){for(let Ee=0;Ee<v.length;Ee++)if(Ee>=M.length){M.push(se),xe=Ee;break}else if(M[Ee]===null){M[Ee]=se,xe=Ee;break}if(xe===-1)break}let we=v[xe];if(we)we.connect(se)}}let X=new O,k=new O;function Y(Z,re,se){X.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=X.distanceTo(k),we=re.projectionMatrix.elements,Ee=se.projectionMatrix.elements,xt=we[14]/(we[10]-1),ke=we[14]/(we[10]+1),Ze=(we[9]+1)/we[5],st=(we[9]-1)/we[5],Ye=(we[8]-1)/we[0],Zt=(Ee[8]+1)/Ee[0],yt=xt*Ye,cn=xt*Zt,Dt=xe/(-Ye+Zt),Ot=Dt*-Ye;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Ot),Z.translateZ(Dt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),we[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let N=xt+Dt,ln=ke+Dt,nt=yt-Ot,wt=cn+(xe-Ot),w=Ze*ke/ln*N,y=st*ke/ln*N;Z.projectionMatrix.makePerspective(nt,wt,w,y,N,ln),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(F.near=z.near=S.near=re,F.far=z.far=S.far=se,ee!==F.near||I!==F.far)i.updateRenderState({depthNear:F.near,depthFar:F.far}),ee=F.near,I=F.far;F.layers.mask=Z.layers.mask|6,S.layers.mask=F.layers.mask&-5,z.layers.mask=F.layers.mask&-3;let xe=Z.parent,we=F.cameras;Q(F,xe);for(let Ee=0;Ee<we.length;Ee++)Q(we[Ee],xe);if(we.length===2)Y(F,S,z);else F.projectionMatrix.copy(S.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Se(Z,F,xe)};function Se(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=yr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return F},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(F)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Fe(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let xe=!1;if(se.length!==F.cameras.length)F.cameras.length=0,xe=!0;for(let ke=0;ke<se.length;ke++){let Ze=se[ke],st=null;if(h!==null)st=h.getViewport(Ze);else{let Zt=u.getViewSubImage(f,Ze);if(st=Zt.viewport,ke===0)e.setRenderTargetTextures(R,Zt.colorTexture,Zt.depthStencilTexture),e.setRenderTarget(R)}let Ye=P[ke];if(Ye===void 0)Ye=new Ut,Ye.layers.enable(ke),Ye.viewport=new at,P[ke]=Ye;if(Ye.matrix.fromArray(Ze.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Ze.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(st.x,st.y,st.width,st.height),ke===0)F.matrix.copy(Ye.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);if(xe===!0)F.cameras.push(Ye)}let we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ke=u.getDepthInformation(se[0]);if(ke&&ke.isValid&&ke.texture)x.init(ke,i.renderState)}if(we&&we.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ke=0;ke<se.length;ke++){let Ze=se[ke].camera;if(Ze){let st=p[Ze];if(!st)st=new Ga,p[Ze]=st;let Ye=u.getCameraImage(Ze);st.sourceTexture=Ye}}}}for(let se=0;se<v.length;se++){let xe=M[se],we=v[se];if(xe!==null&&we!==void 0)we.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new Gp;Me.setAnimationLoop(Fe),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var cT=new Ge,em=new ze;em.set(-1,0,0,0,1,0,0,0,1);function lT(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,_u(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,v){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,v)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Qt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Qt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:v}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(cT.makeRotationFromEuler(v)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(em);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function uT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){let T=M.program;i.uniformBlockBinding(v,T)}function l(v,M){let T=r[v.id];if(T===void 0)p(v),T=u(v),r[v.id]=T,v.addEventListener("dispose",E);let A=M.program;i.updateUBOMapping(v,A);let _=t.render.frame;if(s[v.id]!==_)h(v),s[v.id]=_}function u(v){let M=f();v.__bindingPointIndex=M;let T=e.createBuffer(),{__size:A,usage:_}=v;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,T),T}function f(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=r[v.id],{uniforms:T,__cache:A}=v;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let _=0,S=T.length;_<S;_++){let z=T[_];if(Array.isArray(z))for(let P=0,F=z.length;P<F;P++)d(z[P],_,P,A);else d(z,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(v,M,T,A){if(x(v,M,T,A)===!0){let{__offset:_,value:S}=v;if(Array.isArray(S)){let z=0;for(let P=0;P<S.length;P++){let F=S[P],ee=m(F);if(g(F,v.__data,z),typeof F!=="number"&&typeof F!=="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F))z+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else g(S,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,v.__data)}}function g(v,M,T){if(typeof v==="number"||typeof v==="boolean")M[0]=v;else if(v.isMatrix3)M[0]=v.elements[0],M[1]=v.elements[1],M[2]=v.elements[2],M[3]=0,M[4]=v.elements[3],M[5]=v.elements[4],M[6]=v.elements[5],M[7]=0,M[8]=v.elements[6],M[9]=v.elements[7],M[10]=v.elements[8],M[11]=0;else if(ArrayBuffer.isView(v))M.set(new v.constructor(v.buffer,v.byteOffset,M.length));else v.toArray(M,T)}function x(v,M,T,A){let _=v.value,S=M+"_"+T;if(A[S]===void 0){if(typeof _==="number"||typeof _==="boolean")A[S]=_;else if(ArrayBuffer.isView(_))A[S]=_.slice();else A[S]=_.clone();return!0}else{let z=A[S];if(typeof _==="number"||typeof _==="boolean"){if(z!==_)return A[S]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(z.equals(_)===!1)return z.copy(_),!0}return!1}function p(v){let M=v.uniforms,T=0,A=16;for(let S=0,z=M.length;S<z;S++){let P=Array.isArray(M[S])?M[S]:[M[S]];for(let F=0,ee=P.length;F<ee;F++){let I=P[F],H=Array.isArray(I.value)?I.value:[I.value];for(let q=0,C=H.length;q<C;q++){let X=H[q],k=m(X),Y=T%A,Q=Y%k.boundary,Se=Y+Q;if(T+=Q,Se!==0&&A-Se<k.storage)T+=A-Se;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=T,T+=k.storage}}}let _=T%A;if(_>0)T+=A-_;return v.__size=T,v.__cache={},this}function m(v){let M={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")M.boundary=4,M.storage=4;else if(v.isVector2)M.boundary=8,M.storage=8;else if(v.isVector3||v.isColor)M.boundary=16,M.storage=12;else if(v.isVector4)M.boundary=16,M.storage=16;else if(v.isMatrix3)M.boundary=48,M.storage=48;else if(v.isMatrix4)M.boundary=64,M.storage=64;else if(v.isTexture)Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))M.boundary=16,M.storage=v.byteLength;else Ie("WebGLRenderer: Unsupported uniform value type.",v);return M}function E(v){let M=v.target;M.removeEventListener("dispose",E);let T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete s[M.id]}function R(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var hT=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]),ci=null;function fT(){if(ci===null)ci=new eo(hT,16,16,wr,si),ci.name="DFG_LUT",ci.minFilter=$t,ci.magFilter=$t,ci.wrapS=ls,ci.wrapT=ls,ci.generateMipmaps=!1,ci.needsUpdate=!0;return ci}class Vu{constructor(e={}){let{canvas:t=ap(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=$n}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Cl,Rl,Al]),p=new Set([$n,ji,Xs,hs,El,Tl]),m=new Uint32Array(4),E=new Int32Array(4),R=new O,v=null,M=null,T=[],A=[],_=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=Hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,z=!1,P=null,F=null,ee=null,I=null;this._outputColorSpace=Yi;let H=0,q=0,C=null,X=-1,k=null,Y=new at,Q=new at,Se=null,ue=new Oe(0),Fe=0,{width:Me,height:Z}=t,re=1,se=null,xe=null,we=new at(0,0,Me,Z),Ee=new at(0,0,Me,Z),xt=!1,ke=new no,Ze=!1,st=!1,Ye=new Ge,Zt=new O,yt=new at,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function Ot(){return C===null?re:1}let N=n;function ln(b,D){return t.getContext(b,D)}let nt,wt,w,y,L,V,ie,ae,he,j,te,_e,Pe,fe,oe,Le,De,Qe,U,ce,K,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${dd}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",mt,!1),t.addEventListener("webglcontextcreationerror",it,!1),N===null){if(N=ln("webgl2",b),N===null)if(ln("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Ue("WebGLRenderer: "+b.message),b}function ne(){if(nt=new yw(N),nt.init(),K=new sT(N,nt),wt=new lw(N,nt,e,K),w=new iT(N,nt),wt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);F=N.createFramebuffer(),ee=N.createFramebuffer(),I=N.createFramebuffer(),y=new Sw(N),L=new VE,V=new rT(N,nt,w,L,wt,K,y),ie=new xw(S),ae=new wb(N),le=new aw(N,ae),he=new vw(N,ae,y,le),j=new ww(N,he,ae,le,y),Qe=new Mw(N,wt,V),oe=new uw(L),te=new HE(S,ie,nt,wt,le,oe),_e=new lT(S,L),Pe=new WE,fe=new KE(nt),De=new ow(S,ie,w,j,d,a),Le=new nT(S,j,wt),ye=new uT(N,y,wt,w),U=new cw(N,nt,y),ce=new bw(N,nt,y),y.programs=te.programs,S.capabilities=wt,S.extensions=nt,S.properties=L,S.renderLists=Pe,S.shadowMap=Le,S.state=w,S.info=y}if(g!==$n)_=new Tw(g,t.width,t.height,o,i,r);let pe=new Qp(S,N);this.xr=pe,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let b=nt.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=nt.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(Me,Z,!1)},this.getSize=function(b){return b.set(Me,Z)},this.setSize=function(b,D,W=!0){if(pe.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=b,Z=D,t.width=Math.floor(b*re),t.height=Math.floor(D*re),W===!0)t.style.width=b+"px",t.style.height=D+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,b,D)},this.getDrawingBufferSize=function(b){return b.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(b,D,W){Me=b,Z=D,re=W,t.width=Math.floor(b*W),t.height=Math.floor(D*W),this.setViewport(0,0,b,D)},this.setEffects=function(b){if(g===$n){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let D=0;D<b.length;D++)if(b[D].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(Y)},this.getViewport=function(b){return b.copy(we)},this.setViewport=function(b,D,W,B){if(b.isVector4)we.set(b.x,b.y,b.z,b.w);else we.set(b,D,W,B);w.viewport(Y.copy(we).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ee)},this.setScissor=function(b,D,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,D,W,B);w.scissor(Q.copy(Ee).multiplyScalar(re).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(b){w.setScissorTest(xt=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(b=!0,D=!0,W=!0){let B=0;if(b){let G=!1;if(C!==null){let ge=C.texture.format;G=x.has(ge)}if(G){let ge=C.texture.type,be=p.has(ge),me=De.getClearColor(),Te=De.getClearAlpha(),{r:Re,g:He,b:qe}=me;if(be)m[0]=Re,m[1]=He,m[2]=qe,m[3]=Te,N.clearBufferuiv(N.COLOR,0,m);else E[0]=Re,E[1]=He,E[2]=qe,E[3]=Te,N.clearBufferiv(N.COLOR,0,E)}else B|=N.COLOR_BUFFER_BIT}if(D)B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)N.clear(B)},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(b){b.setRenderer(this),P=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),De.dispose(),Pe.dispose(),fe.dispose(),L.dispose(),ie.dispose(),j.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",bf),pe.removeEventListener("sessionend",Sf),dr.stop()};function Be(b){b.preventDefault(),Hs("WebGLRenderer: Context Lost."),z=!0}function mt(){Hs("WebGLRenderer: Context Restored."),z=!1;let b=y.autoReset,D=Le.enabled,W=Le.autoUpdate,B=Le.needsUpdate,G=Le.type;ne(),y.autoReset=b,Le.enabled=D,Le.autoUpdate=W,Le.needsUpdate=B,Le.type=G}function it(b){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Kn(b){let D=b.target;D.removeEventListener("dispose",Kn),vi(D)}function vi(b){pv(b),L.remove(b)}function pv(b){let D=L.get(b).programs;if(D!==void 0){if(D.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,D,W,B,G,ge){if(D===null)D=cn;let be=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=_v(b,D,W,B,G);w.setMaterial(B,be);let Te=W.index,Re=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Re=2}let He=W.drawRange,qe=W.attributes.position,Ae=He.start*Re,rt=(He.start+He.count)*Re;if(ge!==null)Ae=Math.max(Ae,ge.start*Re),rt=Math.min(rt,(ge.start+ge.count)*Re);if(Te!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,Te.count);else if(qe!==void 0&&qe!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,qe.count);let Lt=rt-Ae;if(Lt<0||Lt===1/0)return;le.setup(G,B,me,W,Te);let vt,ft=U;if(Te!==null)vt=ae.get(Te),ft=ce,ft.setIndex(vt);if(G.isMesh)if(B.wireframe===!0)w.setLineWidth(B.wireframeLinewidth*Ot()),ft.setMode(N.LINES);else ft.setMode(N.TRIANGLES);else if(G.isLine){let Yt=B.linewidth;if(Yt===void 0)Yt=1;if(w.setLineWidth(Yt*Ot()),G.isLineSegments)ft.setMode(N.LINES);else if(G.isLineLoop)ft.setMode(N.LINE_LOOP);else ft.setMode(N.LINE_STRIP)}else if(G.isPoints)ft.setMode(N.POINTS);else if(G.isSprite)ft.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Yt,_multiDrawCounts:ve,_multiDrawCount:rn}=G,Ke=Te?ae.get(Te).bytesPerElement:1,Tn=L.get(B).currentProgram.getUniforms();for(let Jn=0;Jn<rn;Jn++)Tn.setValue(N,"_gl_DrawID",Jn),ft.render(Yt[Jn]/Ke,ve[Jn])}else ft.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)ft.renderInstances(Ae,Lt,G.count);else if(W.isInstancedBufferGeometry){let Yt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,Yt);ft.renderInstances(Ae,Lt,ve)}else ft.render(Ae,Lt)};function vf(b,D,W,B){if(P!==null&&b.isNodeMaterial)P.setObject(B,b);if(Ze===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===Pn&&b.forceSinglePass===!1)b.side=Qt,b.needsUpdate=!0,Wo(b,D,B),b.side=qi,b.needsUpdate=!0,Wo(b,D,B),b.side=Pn;else Wo(b,D,B)}this.compile=function(b,D,W=null){if(W===null)W=b;if(P!==null)P.renderStart(b,D,W);if(M=fe.get(W),M.init(D),A.push(M),W.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}}),b!==W)b.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}});if(M.setupLights(),P!==null)P.updateLights(M.state.lightsArray);if(st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),Ze===!0)oe.setGlobalState(this.clippingPlanes,D);if(P!==null)Le.render(M.state.shadowsArray,W,D);let B=new Set;if(b.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ge=G.material;if(ge)if(Array.isArray(ge))for(let be=0;be<ge.length;be++){let me=ge[be];vf(me,W,D,G),B.add(me)}else vf(ge,W,D,G),B.add(ge)}),M=A.pop(),P!==null)P.renderEnd();return B},this.compileAsync=function(b,D,W=null){let B=this.compile(b,D,W);return new Promise((G)=>{function ge(){if(B.forEach(function(be){let Te=L.get(be).currentProgram;if(Te===void 0||Te.isReady())B.delete(be)}),B.size===0){G(b);return}setTimeout(ge,10)}if(nt.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Bc=null;function mv(b){if(Bc)Bc(b)}function bf(){dr.stop()}function Sf(){dr.start()}let dr=new Gp;if(dr.setAnimationLoop(mv),typeof self<"u")dr.setContext(self);this.setAnimationLoop=function(b){Bc=b,pe.setAnimationLoop(b),b===null?dr.stop():dr.start()},pe.addEventListener("sessionstart",bf),pe.addEventListener("sessionend",Sf),this.render=function(b,D){if(D!==void 0&&D.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(P!==null)P.renderStart(b,D);let W=pe.enabled===!0&&pe.isPresenting===!0,B=_!==null&&(C===null||W)&&_.begin(S,C);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(D);D=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(S,b,D,C);if(M=fe.get(b,A.length),M.init(D),M.state.textureUnits=V.getTextureUnits(),A.push(M),Ye.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),ke.setFromProjectionMatrix(Ye,hu,D.reversedDepth),st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),v=Pe.get(b,T.length),v.init(),T.push(v),pe.enabled===!0&&pe.isPresenting===!0){let be=S.xr.getDepthSensingMesh();if(be!==null)Gc(be,D,-1/0,S.sortObjects)}if(Gc(b,D,0,S.sortObjects),v.finish(),P!==null)P.updateLights(M.state.lightsArray);if(S.sortObjects===!0)v.sort(se,xe);if(Dt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Dt)De.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let G=M.state.shadowsArray;if(Le.render(G,b,D),Ze===!0)oe.endShadows();if((B&&_.hasRenderPass())===!1){let be=v.opaque,me=v.transmissive;if(M.setupLights(),D.isArrayCamera){let Te=D.cameras;if(me.length>0)for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];wf(be,me,b,qe)}if(Dt)De.render(b);for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];Mf(v,b,qe,qe.viewport)}}else{if(me.length>0)wf(be,me,b,D);if(Dt)De.render(b);Mf(v,b,D)}}if(C!==null&&q===0)V.updateMultisampleRenderTarget(C),V.updateRenderTargetMipmap(C);if(B)_.end(S);if(b.isScene===!0)b.onAfterRender(S,b,D);if(le.resetDefaultState(),X=-1,k=null,A.pop(),A.length>0){if(M=A[A.length-1],V.setTextureUnits(M.state.textureUnits),Ze===!0)oe.setGlobalState(S.clippingPlanes,M.state.camera)}else M=null;if(T.pop(),T.length>0)v=T[T.length-1];else v=null;if(P!==null)P.renderEnd()};function Gc(b,D,W,B){if(b.visible===!1)return;if(b.layers.test(D.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(D)}else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight){if(M.pushLight(b),b.castShadow)M.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(ke)){if(B)yt.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ye);let be=j.update(b),me=b.material;if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(ke)){let be=j.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();yt.copy(b.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();yt.copy(be.boundingSphere.center)}yt.applyMatrix4(b.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(me)){let Te=be.groups;for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re],Ae=me[qe.materialIndex];if(Ae&&Ae.visible)v.push(b,be,Ae,W,yt.z,qe,D)}}else if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}}let ge=b.children;for(let be=0,me=ge.length;be<me;be++)Gc(ge[be],D,W,B)}function Mf(b,D,W,B){let{opaque:G,transmissive:ge,transparent:be}=b;if(M.setupLightsView(W),Ze===!0)oe.setGlobalState(S.clippingPlanes,W);if(B)w.viewport(Y.copy(B));if(G.length>0)$o(G,D,W);if(ge.length>0)$o(ge,D,W);if(be.length>0)$o(be,D,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function wf(b,D,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Ae=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new _n(1,1,{generateMipmaps:!0,type:Ae?si:$n,minFilter:ri,samples:Math.max(4,wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let ge=M.state.transmissionRenderTarget[B.id],be=B.viewport||Y;ge.setSize(be.z*S.transmissionResolutionScale,be.w*S.transmissionResolutionScale);let me=S.getRenderTarget(),Te=S.getActiveCubeFace(),Re=S.getActiveMipmapLevel();if(S.setRenderTarget(ge),S.getClearColor(ue),Fe=S.getClearAlpha(),Fe<1)S.setClearColor(16777215,0.5);if(S.clear(),Dt)De.render(W);let He=S.toneMapping;S.toneMapping=Hn;let qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(M.setupLightsView(B),Ze===!0)oe.setGlobalState(S.clippingPlanes,B);if($o(b,W,B),V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let rt=0,Lt=D.length;rt<Lt;rt++){let vt=D[rt],{object:ft,geometry:Yt,material:ve,group:rn}=vt;if(ve.side===Pn&&ft.layers.test(B.layers)){let Ke=ve.side;ve.side=Qt,ve.needsUpdate=!0,Ef(ft,W,B,Yt,ve,rn),ve.side=Ke,ve.needsUpdate=!0,Ae=!0}}if(Ae===!0)V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge)}if(S.setRenderTarget(me,Te,Re),S.setClearColor(ue,Fe),qe!==void 0)B.viewport=qe;S.toneMapping=He}function $o(b,D,W){let B=D.isScene===!0?D.overrideMaterial:null;for(let G=0,ge=b.length;G<ge;G++){let be=b[G],{object:me,geometry:Te,group:Re}=be,He=be.material;if(He.allowOverride===!0&&B!==null)He=B;if(me.layers.test(W.layers))Ef(me,D,W,Te,He,Re)}}function Ef(b,D,W,B,G,ge){if(P!==null&&G.isNodeMaterial)P.setObject(b,G);if(b.onBeforeRender(S,D,W,B,G,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),G.onBeforeRender(S,D,W,B,b,ge),G.transparent===!0&&G.side===Pn&&G.forceSinglePass===!1)G.side=Qt,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=qi,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=Pn;else S.renderBufferDirect(W,D,B,G,b,ge);b.onAfterRender(S,D,W,B,G,ge)}function Wo(b,D,W){if(D.isScene!==!0)D=cn;let B=L.get(b),G=M.state.lights,ge=M.state.shadowsArray,be=G.state.version,me=te.getParameters(b,G.state,ge,D,W,M.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Re=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?D.environment:null,B.fog=D.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,He),B.envMapRotation=B.environment!==null&&b.envMap===null?D.environmentRotation:b.envMapRotation,Re===void 0)b.addEventListener("dispose",Kn),Re=new Map,B.programs=Re;let qe=Re.get(Te);if(qe!==void 0){if(B.currentProgram===qe&&B.lightsStateVersion===be)return Af(b,me),qe}else{if(me.uniforms=te.getUniforms(b),P!==null&&b.isNodeMaterial)P.build(b,W,me);b.onBeforeCompile(me,S),qe=te.acquireProgram(me,Te),Re.set(Te,qe),B.uniforms=me.uniforms}let Ae=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Ae.clippingPlanes=oe.uniform;if(Af(b,me),B.needsLights=yv(b),B.lightsStateVersion=be,B.needsLights)Ae.ambientLightColor.value=G.state.ambient,Ae.lightProbe.value=G.state.probe,Ae.sunLights.value=G.state.sun,Ae.sunLightShadows.value=G.state.sunShadow,Ae.directionalLights.value=G.state.directional,Ae.directionalLightShadows.value=G.state.directionalShadow,Ae.spotLights.value=G.state.spot,Ae.spotLightShadows.value=G.state.spotShadow,Ae.rectAreaLights.value=G.state.rectArea,Ae.ltc_1.value=G.state.rectAreaLTC1,Ae.ltc_2.value=G.state.rectAreaLTC2,Ae.pointLights.value=G.state.point,Ae.pointLightShadows.value=G.state.pointShadow,Ae.hemisphereLights.value=G.state.hemi,Ae.sunShadowMatrix.value=G.state.sunShadowMatrix,Ae.sunShadowCascade.value=G.state.sunShadowCascade,Ae.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ae.spotLightMatrix.value=G.state.spotLightMatrix,Ae.spotLightMap.value=G.state.spotLightMap,Ae.pointShadowMatrix.value=G.state.pointShadowMatrix;return B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=qe,B.uniformsList=null,qe}function Tf(b){if(b.uniformsList===null){let D=b.currentProgram.getUniforms();b.uniformsList=po.seqWithValue(D.seq,b.uniforms)}return b.uniformsList}function Af(b,D){let W=L.get(b);W.outputColorSpace=D.outputColorSpace,W.batching=D.batching,W.batchingColor=D.batchingColor,W.instancing=D.instancing,W.instancingColor=D.instancingColor,W.instancingMorph=D.instancingMorph,W.skinning=D.skinning,W.morphTargets=D.morphTargets,W.morphNormals=D.morphNormals,W.morphColors=D.morphColors,W.morphTargetsCount=D.morphTargetsCount,W.numClippingPlanes=D.numClippingPlanes,W.numIntersection=D.numClipIntersection,W.vertexAlphas=D.vertexAlphas,W.vertexTangents=D.vertexTangents,W.toneMapping=D.toneMapping}function gv(b,D){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;R.setFromMatrixPosition(D.matrixWorld);for(let W=0,B=b.length;W<B;W++){let G=b[W];if(G.texture!==null&&G.boundingBox.containsPoint(R))return G}return null}function _v(b,D,W,B,G){if(D.isScene!==!0)D=cn;V.resetTextureUnits();let ge=D.fog,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?D.environment:null,me=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:$e.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=ie.get(B.envMap||be,Te),He=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,qe=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ae=!!W.morphAttributes.position,rt=!!W.morphAttributes.normal,Lt=!!W.morphAttributes.color,vt=Hn;if(B.toneMapped){if(C===null||C.isXRRenderTarget===!0)vt=S.toneMapping}let ft=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Yt=ft!==void 0?ft.length:0,ve=L.get(B),rn=M.state.lights;if(Ze===!0){if(st===!0||b!==k){let gt=b===k&&B.id===X;oe.setState(B,b,gt)}}let Ke=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==rn.state.version)Ke=!0;else if(ve.outputColorSpace!==me)Ke=!0;else if(G.isBatchedMesh&&ve.batching===!1)Ke=!0;else if(!G.isBatchedMesh&&ve.batching===!0)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!0&&G._colorsTexture===null)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!1&&G._colorsTexture!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancing===!1)Ke=!0;else if(!G.isInstancedMesh&&ve.instancing===!0)Ke=!0;else if(G.isSkinnedMesh&&ve.skinning===!1)Ke=!0;else if(!G.isSkinnedMesh&&ve.skinning===!0)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!0&&G.instanceColor===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!1&&G.instanceColor!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!0&&G.morphTexture===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!1&&G.morphTexture!==null)Ke=!0;else if(ve.envMap!==Re)Ke=!0;else if(B.fog===!0&&ve.fog!==ge)Ke=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))Ke=!0;else if(ve.vertexAlphas!==He)Ke=!0;else if(ve.vertexTangents!==qe)Ke=!0;else if(ve.morphTargets!==Ae)Ke=!0;else if(ve.morphNormals!==rt)Ke=!0;else if(ve.morphColors!==Lt)Ke=!0;else if(ve.toneMapping!==vt)Ke=!0;else if(ve.morphTargetsCount!==Yt)Ke=!0;else if(!!ve.lightProbeGrid!==M.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,ve.__version=B.version;let Tn=ve.currentProgram;if(Ke===!0){if(Tn=Wo(B,D,G),P&&B.isNodeMaterial)P.onUpdateProgram(B,Tn,ve)}let Jn=!1,Ui=!1,kr=!1,lt=Tn.getUniforms(),Ct=ve.uniforms;if(w.useProgram(Tn.program))Jn=!0,Ui=!0,kr=!0;if(B.id!==X)X=B.id,Ui=!0;if(ve.needsLights){let gt=gv(M.state.lightProbeGridArray,G);if(ve.lightProbeGrid!==gt)ve.lightProbeGrid=gt,Ui=!0}if(Jn||k!==b){if(w.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();lt.setValue(N,"projectionMatrix",b.projectionMatrix),lt.setValue(N,"viewMatrix",b.matrixWorldInverse);let zi=lt.map.cameraPosition;if(zi!==void 0)zi.setValue(N,Zt.setFromMatrixPosition(b.matrixWorld));if(wt.logarithmicDepthBuffer)lt.setValue(N,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)lt.setValue(N,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ui=!0,kr=!0}if(ve.needsLights){if(rn.state.sunShadowMap.length>0)lt.setValue(N,"sunShadowMap",rn.state.sunShadowMap,V);if(rn.state.directionalShadowMap.length>0)lt.setValue(N,"directionalShadowMap",rn.state.directionalShadowMap,V);if(rn.state.spotShadowMap.length>0)lt.setValue(N,"spotShadowMap",rn.state.spotShadowMap,V);if(rn.state.pointShadowMap.length>0)lt.setValue(N,"pointShadowMap",rn.state.pointShadowMap,V)}if(G.isSkinnedMesh){lt.setOptional(N,G,"bindMatrix"),lt.setOptional(N,G,"bindMatrixInverse");let gt=G.skeleton;if(gt){if(gt.boneTexture===null)gt.computeBoneTexture();lt.setValue(N,"boneTexture",gt.boneTexture,V)}}if(G.isBatchedMesh){if(lt.setOptional(N,G,"batchingTexture"),lt.setValue(N,"batchingTexture",G._matricesTexture,V),lt.setOptional(N,G,"batchingIdTexture"),lt.setValue(N,"batchingIdTexture",G._indirectTexture,V),lt.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null)lt.setValue(N,"batchingColorTexture",G._colorsTexture,V)}let Fi=W.morphAttributes;if(Fi.position!==void 0||Fi.normal!==void 0||Fi.color!==void 0)Qe.update(G,W,Tn);if(Ui||ve.receiveShadow!==G.receiveShadow)ve.receiveShadow=G.receiveShadow,lt.setValue(N,"receiveShadow",G.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&D.environment!==null)Ct.envMapIntensity.value=D.environmentIntensity;if(Ct.dfgLUT!==void 0)Ct.dfgLUT.value=fT();if(Ui){if(lt.setValue(N,"toneMappingExposure",S.toneMappingExposure),ve.needsLights)xv(Ct,kr);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ct,ge);if(_e.refreshMaterialUniforms(Ct,B,re,Z,M.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let gt=ve.lightProbeGrid;Ct.probesSH.value=gt.texture,Ct.probesMin.value.copy(gt.boundingBox.min),Ct.probesMax.value.copy(gt.boundingBox.max),Ct.probesResolution.value.copy(gt.resolution)}po.upload(N,Tf(ve),Ct,V)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)po.upload(N,Tf(ve),Ct,V),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)lt.setValue(N,"center",G.center);if(lt.setValue(N,"modelViewMatrix",G.modelViewMatrix),lt.setValue(N,"normalMatrix",G.normalMatrix),lt.setValue(N,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){let gt=B.uniformsGroups;for(let zi=0,Br=gt.length;zi<Br;zi++){let Cf=gt[zi];ye.update(Cf,Tn),ye.bind(Cf,Tn)}}return Tn}function xv(b,D){b.ambientLightColor.needsUpdate=D,b.lightProbe.needsUpdate=D,b.sunLights.needsUpdate=D,b.sunLightShadows.needsUpdate=D,b.directionalLights.needsUpdate=D,b.directionalLightShadows.needsUpdate=D,b.pointLights.needsUpdate=D,b.pointLightShadows.needsUpdate=D,b.spotLights.needsUpdate=D,b.spotLightShadows.needsUpdate=D,b.rectAreaLights.needsUpdate=D,b.hemisphereLights.needsUpdate=D}function yv(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(b,D,W){let B=L.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;L.get(b.texture).__webglTexture=D,L.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,D){let W=L.get(b);W.__webglFramebuffer=D,W.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(b,D=0,W=0){C=b,H=D,q=W;let B=null,G=!1,ge=!1;if(b){let me=L.get(b);if(me.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(N.FRAMEBUFFER,me.__webglFramebuffer),Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest,w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),X=-1;return}else if(me.__webglFramebuffer===void 0)V.setupRenderTarget(b);else if(me.__hasExternalTextures)V.rebindTextures(b,L.get(b.texture).__webglTexture,L.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(me.__boundDepthTexture!==He){if(He!==null&&L.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Re=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Re[D]))B=Re[D][W];else B=Re[D];G=!0}else if(b.samples>0&&V.useMultisampledRTT(b)===!1)B=L.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Re))B=Re[W];else B=Re;Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest}else Y.copy(we).multiplyScalar(re).floor(),Q.copy(Ee).multiplyScalar(re).floor(),Se=xt;if(W!==0)B=F;if(w.bindFramebuffer(N.FRAMEBUFFER,B))w.drawBuffers(b,B);if(w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),G){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+D,me.__webglTexture,W)}else if(ge){let me=D;for(let Te=0;Te<b.textures.length;Te++){let Re=L.get(b.textures[Te]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Te,Re.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,me.__webglTexture,W)}X=-1};function Rf(b){let D=L.get(b);if(D.__readFormat!==b.format||D.__readType!==b.type)D.__readFormat=b.format,D.__readType=b.type,D.__formatReadable=wt.textureFormatReadable(b.format),D.__typeReadable=wt.textureTypeReadable(b.type);return D}if(this.readRenderTargetPixels=function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te){w.bindFramebuffer(N.FRAMEBUFFER,Te);try{let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ae.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G))N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),ge)}finally{let Re=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te)if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G)){w.bindFramebuffer(N.FRAMEBUFFER,Te);let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ae.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rt=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.bufferData(N.PIXEL_PACK_BUFFER,ge.byteLength,N.STREAM_READ),N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let Lt=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Lt);let vt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await lp(N,vt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ge),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(rt),N.deleteSync(vt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,D=null,W=0){let B=Math.pow(2,-W),G=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),be=D!==null?D.x:0,me=D!==null?D.y:0;V.setTexture2D(b,0),N.copyTexSubImage2D(N.TEXTURE_2D,W,0,0,be,me,G,ge),w.unbindTexture()},this.copyTextureToTexture=function(b,D,W=null,B=null,G=0,ge=0){let be,me,Te,Re,He,qe,Ae,rt,Lt,vt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)be=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Re=W.min.x,He=W.min.y,qe=W.isBox3?W.min.z:0;else{let Ct=Math.pow(2,-G);if(be=Math.floor(vt.width*Ct),me=Math.floor(vt.height*Ct),b.isDataArrayTexture)Te=vt.depth;else if(b.isData3DTexture)Te=Math.floor(vt.depth*Ct);else Te=1;Re=0,He=0,qe=0}if(B!==null)Ae=B.x,rt=B.y,Lt=B.z;else Ae=0,rt=0,Lt=0;let ft=K.convert(D.format),Yt=K.convert(D.type),ve;if(D.isData3DTexture)V.setTexture3D(D,0),ve=N.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),ve=N.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),ve=N.TEXTURE_2D;w.activeTexture(N.TEXTURE0),w.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,D.flipY),w.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),w.pixelStorei(N.UNPACK_ALIGNMENT,D.unpackAlignment);let rn=w.getParameter(N.UNPACK_ROW_LENGTH),Ke=w.getParameter(N.UNPACK_IMAGE_HEIGHT),Tn=w.getParameter(N.UNPACK_SKIP_PIXELS),Jn=w.getParameter(N.UNPACK_SKIP_ROWS),Ui=w.getParameter(N.UNPACK_SKIP_IMAGES);w.pixelStorei(N.UNPACK_ROW_LENGTH,vt.width),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,vt.height),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Re),w.pixelStorei(N.UNPACK_SKIP_ROWS,He),w.pixelStorei(N.UNPACK_SKIP_IMAGES,qe);let kr=b.isDataArrayTexture||b.isData3DTexture,lt=D.isDataArrayTexture||D.isData3DTexture;if(b.isDepthTexture){let Ct=L.get(b),Fi=L.get(D),gt=L.get(Ct.__renderTarget),zi=L.get(Fi.__renderTarget);w.bindFramebuffer(N.READ_FRAMEBUFFER,gt.__webglFramebuffer),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,zi.__webglFramebuffer);for(let Br=0;Br<Te;Br++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(b).__webglTexture,G,qe+Br),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(D).__webglTexture,ge,Lt+Br);N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.DEPTH_BUFFER_BIT,N.NEAREST)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||b.isRenderTargetTexture||L.has(b)){let Ct=L.get(b),Fi=L.get(D);w.bindFramebuffer(N.READ_FRAMEBUFFER,ee),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,I);for(let gt=0;gt<Te;gt++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ct.__webglTexture,G,qe+gt);else N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ct.__webglTexture,G);if(lt)N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Fi.__webglTexture,ge,Lt+gt);else N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Fi.__webglTexture,ge);if(G!==0)N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.COLOR_BUFFER_BIT,N.NEAREST);else if(lt)N.copyTexSubImage3D(ve,ge,Ae,rt,Lt+gt,Re,He,be,me);else N.copyTexSubImage2D(ve,ge,Ae,rt,Re,He,be,me)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(lt)if(b.isDataTexture||b.isData3DTexture)N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt.data);else if(D.isCompressedArrayTexture)N.compressedTexSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,vt.data);else N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt);else if(b.isDataTexture)N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt.data);else if(b.isCompressedTexture)N.compressedTexSubImage2D(N.TEXTURE_2D,ge,Ae,rt,vt.width,vt.height,ft,vt.data);else N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt);if(w.pixelStorei(N.UNPACK_ROW_LENGTH,rn),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Tn),w.pixelStorei(N.UNPACK_SKIP_ROWS,Jn),w.pixelStorei(N.UNPACK_SKIP_IMAGES,Ui),ge===0&&D.generateMipmaps)N.generateMipmap(ve);w.unbindTexture()},this.initRenderTarget=function(b){if(L.get(b).__webglFramebuffer===void 0)V.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)V.setTextureCube(b,0);else if(b.isData3DTexture)V.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)V.setTexture2DArray(b,0);else V.setTexture2D(b,0);w.unbindTexture()},this.resetState=function(){H=0,q=0,C=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}var nm={type:"change"},Wu={type:"start"},rm={type:"end"},tc=new Ki,im=new Rn,dT=Math.cos(70*js.DEG2RAD),Bt=new O,fn=2*Math.PI,ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$u=0.000001;class Zu extends Ya{constructor(e,t=null){super(e,t);if(this.state=ct.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Zi.ROTATE,MIDDLE:Zi.DOLLY,RIGHT:Zi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new Ht,this._lastTargetPosition=new O,this._quat=new Ht().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lo,this._sphericalDelta=new lo,this._scale=1,this._panOffset=new O,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new O,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mT.bind(this),this._onPointerDown=pT.bind(this),this._onPointerUp=gT.bind(this),this._onContextMenu=MT.bind(this),this._onMouseWheel=yT.bind(this),this._onKeyDown=vT.bind(this),this._onTouchStart=bT.bind(this),this._onTouchMove=ST.bind(this),this._onMouseDown=_T.bind(this),this._onMouseMove=xT.bind(this),this._interceptControlDown=wT.bind(this),this._interceptControlUp=ET.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ct.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(nm),this.update(),this.state=ct.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===ct.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=fn;else if(n>Math.PI)n-=fn;if(i<-Math.PI)i+=fn;else if(i>Math.PI)i-=fn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Bt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new O(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(tc.origin.copy(this.object.position),tc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(tc.direction))<dT)this.object.lookAt(this.target);else im.setFromNormalAndCoplanarPoint(this.object.up,this.target),tc.intersectPlane(im,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>$u||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$u||this._lastTargetPosition.distanceToSquared(this.target)>$u)return this.dispatchEvent(nm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return fn/60*this.autoRotateSpeed*e;else return fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){if(this.screenSpacePanning===!0)Bt.setFromMatrixColumn(t,1);else Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt);Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Bt.copy(i).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function pT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function mT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function gT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(rm),this.state=ct.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function _T(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Zi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ct.DOLLY;break;case Zi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}break;case Zi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function xT(e){switch(this.state){case ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function yT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==ct.NONE)return;e.preventDefault(),this.dispatchEvent(Wu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(rm)}function vT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function bT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ct.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ct.TOUCH_PAN;break;default:this.state=ct.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ct.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ct.TOUCH_DOLLY_ROTATE;break;default:this.state=ct.NONE}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function ST(e){switch(this._trackPointer(e),this.state){case ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ct.NONE}}function MT(e){if(this.enabled===!1)return;e.preventDefault()}function wT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function ET(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Xu extends ds{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Qi;e.deleteAttribute("uv");let t=new Ci({side:Qt}),n=new Ci,i=new ys(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new _t(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ms(e,n,6),o=new ut;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new _t(e,ws(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new _t(e,ws(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new _t(e,ws(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new _t(e,ws(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new _t(e,ws(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new _t(e,ws(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function ws(e){return new Ha({color:0,emissive:16777215,emissiveIntensity:e})}function qu(e,t){if(t===au)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===fs||t===qs){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===fs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function sm(e){let t=new Map,n=new Map,i=e.clone();return om(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function om(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)om(e.children[i],t.children[i],n)}class th extends Ii{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pm(t)}),this.register(function(t){return new mm(t)}),this.register(function(t){return new wm(t)}),this.register(function(t){return new Em(t)}),this.register(function(t){return new Tm(t)}),this.register(function(t){return new _m(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new ym(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new dm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new gm(t)}),this.register(function(t){return new Mm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new hm(t)}),this.register(function(t){return new Ju(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ju(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Am(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=rr.extractUrlBase(e);s=rr.resolveURL(c,this.path)}else s=rr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new ao(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Rm){try{s[Xe.KHR_BINARY_GLTF]=new Cm(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Dm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new fm;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Pm(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new Im;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Lm;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function TT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Pt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class hm{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new vs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ys(l),c.distance=u;break;case"spot":c=new Xa(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ui(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class fm{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return ai}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Yi))}return Promise.all(i)}}class dm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class pm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class gm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class _m{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Yi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class xm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class ym{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class vm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class bm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Yi));return Promise.all(i)}}class Sm{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class wm{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Em{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Tm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Ju{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Am{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Ln.TRIANGLES&&c.mode!==Ln.TRIANGLE_STRIP&&c.mode!==Ln.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new O,p=new Ht,m=new O(1,1,1),E=new ms(d.geometry,d.material,f);for(let v=0;v<f;v++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)m.fromBufferAttribute(a.SCALE,v);E.setMatrixAt(v,g.compose(x,p,m))}let R=null;for(let v in a)if(v==="_COLOR_0"){let M=a[v];E.instanceColor=new Wi(M.array,M.itemSize,M.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(R===null){let T=E.geometry;R=new en,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let M=a[v];R.setAttribute(v,new Wi(M.array,M.itemSize,M.normalized))}ut.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Rm="glTF",go=12,am={JSON:1313821514,BIN:5130562};class Cm{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,go),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Rm)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-go,r=new DataView(e,go),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===am.JSON){let c=new Uint8Array(e,go+s,o);this.content=n.decode(c)}else if(a===am.BIN){let c=go+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Pm{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Qu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Qu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=Es[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Im{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Lm{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class nh extends Pi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let v=s[g+R+o],M=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*v+E*M+x*T+p*A}return r}}var AT=new Ht;class Nm extends nh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return AT.fromArray(r).normalize().toArray(r),r}}var Ln={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Es={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cm={9728:Vn,9729:$t,9984:Ma,9985:us,9986:br,9987:ri},lm={33071:ls,33648:Sa,10497:cs},ju={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},sr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},RT={CUBICSPLINE:void 0,LINEAR:Pa,STEP:ou},Yu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function CT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ci({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qi});return e.DefaultMaterial}function Ir(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ui(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function PT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function IT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function LT(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Ku(n.attributes);else t=e.indices+":"+Ku(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Ku(e.targets[i]);return t}function Ku(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function eh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function NT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var DT=new Ge;class Dm{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new TT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new _s(this.options.manager);else this.textureLoader=new qa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ao(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Ir(r,o,i),ui(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(rr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=ju[i.type],o=Es[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Vt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=ju[i.type],c=Es[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new Js(g,h/l),t.cache.add(m,E);x=new ps(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Vt(g,a,d)}if(i.sparse!==void 0){let p=ju.SCALAR,m=Es[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,v=new m(s[1],E,i.sparse.count*p),M=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Vt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=v.length;T<A;T++){let _=v[T];if(x.setX(_,M[T*a]),a>=2)x.setY(_,M[T*a+1]);if(a>=3)x.setZ(_,M[T*a+2]);if(a>=4)x.setW(_,M[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=cm[f.magFilter]||$t,l.minFilter=cm[f.minFilter]||ri,l.wrapS=lm[f.wrapS]||cs,l.wrapT=lm[f.wrapT]||cs,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Vn&&l.minFilter!==$t,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new At(g);x.needsUpdate=!0,f(x)};t.load(rr.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ui(u,s),u.userData.mimeType=s.mimeType||NT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ro,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new io,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Ci}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Yi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Pn;let l=r.alphaMode||Yu.OPAQUE;if(l===Yu.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Yu.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==ai){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==ai)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Yi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ui(u,r),t.associations.set(u,{materials:e}),r.extensions)Ir(i,u,r);return u})}createUniqueName(e){let t=et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return um(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=LT(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=um(new en,c,t);if(c.mode===Ln.TRIANGLE_STRIP)f=f.then((h)=>qu(h,qs));else if(c.mode===Ln.TRIANGLE_FAN)f=f.then((h)=>qu(h,fs));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?CT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===Ln.TRIANGLES||x.mode===Ln.TRIANGLE_STRIP||x.mode===Ln.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new Fa(g,m):new _t(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===Ln.LINES)p=new za(g,m);else if(x.mode===Ln.LINE_STRIP)p=new Ji(g,m);else if(x.mode===Ln.LINE_LOOP)p=new ka(g,m);else if(x.mode===Ln.POINTS)p=new gs(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)IT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ui(p,r),x.extensions)Ir(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Ir(i,u[0],r);return u[0]}let f=new ei;if(r.extensions)Ir(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ut(js.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return ui(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new to(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let v=f[E],M=h[E],T=d[E],A=g[E],_=x[E];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let S=n._createAnimationTracks(v,M,T,A,_);if(S)for(let z=0;z<S.length;z++)p.push(S[z])}let m=new rs(r,void 0,p);return ui(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,DT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new O().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Qs;else if(c.length>1)l=new ei;else if(c.length===1)l=c[0];else l=new ut;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ui(l,r),r.extensions)Ir(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ei;if(n.name)r.name=i.createUniqueName(n.name);if(ui(r,n),n.extensions)Ir(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(sm(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof hn||f instanceof At)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(sr[r.path]===sr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(sr[r.path]){case sr.weights:l=tr;break;case sr.rotation:l=nr;break;case sr.translation:case sr.scale:l=Rr;break;default:switch(n.itemSize){case 1:l=tr;break;case 2:case 3:default:l=Rr;break}break}let u=i.interpolation!==void 0?RT[i.interpolation]:Pa,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+sr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=eh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof nr?Nm:nh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function OT(e,t,n){let i=t.attributes,r=new Ft;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new O(c[0],c[1],c[2]),new O(l[0],l[1],l[2])),a.normalized){let u=eh(Es[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new O,c=new O;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=eh(Es[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function um(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Qu[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return ui(e,t),OT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?PT(e,t.targets,n):e})}function xo(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function rh(e,t="|"){return e.map((n)=>ah(n)).join(t)}function yo(e,t){if(typeof t==="bigint")return t.toString();return t}class Om{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function vo(e){return new Om(e)}function Um(e){return e===null||e===void 0}function nc(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Fm(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Nn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Li(e){return bo(e._zod.def)??e._zod.def.shape}function zm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Nn(this,t,i),i},enumerable:!0,configurable:!0})}function km(e,t,n){if(t in e)Nn(e,t,n);else e[t]=n}function Lr(e,t,n,i){let r=Li(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)zm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else km(e,s,i?i(o.value,s):o.value)}}function UT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)zm(e,n,()=>t[n]);else km(e,n,i.value)}}function bn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Bm(e){return JSON.stringify(e)}function Gm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var sh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ts(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Hm=vo(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nr(e){if(Ts(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Ts(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function oh(e){if(Nr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vm=new Set(["string","number","symbol"]);function ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function ah(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function $m(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var ic=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ch={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function FT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lr(s,e,rc(e,t)),hi(e,bn(n,{shape:s,checks:[]}))}function rc(e,t){let n=Li(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function zT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(rc(e,t)),o={};return Lr(o,e,Reflect.ownKeys(Li(e)).filter((a)=>!s.has(a))),hi(e,bn(n,{shape:o,checks:[]}))}function kT(e,t){if(!Nr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Li(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function Wm(e,t){let n={};return Lr(n,e,Reflect.ownKeys(Li(e))),UT(n,t),n}function BT(e,t){if(!Nr(t))throw Error("Invalid input to safeExtend: expected a plain object");return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function GT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lr(n,e,Reflect.ownKeys(Li(e))),Lr(n,t,Reflect.ownKeys(Li(t)));let i=bn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return hi(e,i)}function Zm(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(rc(t,n)):void 0,c={};return Lr(c,t,Reflect.ownKeys(Li(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),hi(t,bn(t._zod.def,{shape:c,checks:[]}))}function HT(e,t,n){let i=n?new Set(rc(t,n)):void 0,r={};return Lr(r,t,Reflect.ownKeys(Li(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),hi(t,bn(t._zod.def,{shape:r}))}function fi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function cr(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function _o(e){return typeof e==="string"?e:e?.message}function lh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function di(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(s?.(e))??_o(t?.error?.(e))??_o(n.customError?.(e))??_o(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var VT=/[\uD800-\uDBFF]/;function sc(e){let t=e.length;if(!VT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function oc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function qm(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function jm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else $T(e,n,i.value)}}function Ni(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ac(e,t,n){return Ni(e,t,n,!1)}function Ym(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ni(this,n,i(this))},set(r){Ni(this,n,r)}})}return t}function $T(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ni(this,t,n.bind(this))},set(i){Ni(this,t,i)}})}function WT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var ih,or=!1,ZT={configurable:!0,get(){or=!0;return}};function tt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&ih!==e._zod){ih=void 0;return}ih=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,ZT);let r=or;or=!1;try{let s=n(this);if(or)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return or=or||r,s}catch(s){throw delete this[t],or=or||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function XT(e,t,n,i){let r=WT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var qT="~constantCatch";function Km(e){let t=()=>e;return t[qT]=!0,t}var Jm;var uh={value:void 0,enumerable:!1},Qm="captureStackTrace"in Error?Error:null;function jT(e){let t=Qm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Qm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){uh.value=new s(d);try{Object.defineProperty(h,"_zod",uh)}finally{uh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),jm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?jT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class pi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class So extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Jm=globalThis).__zod_globalConfig??(Jm.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Sn(e){if(e)Object.assign(dn,e);return dn}function YT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yo,2)),e.message}function KT(e){this._zod.message=e}var JT={get:YT,set:KT,enumerable:!0,configurable:!0},fh={value:void 0,enumerable:!1},eg=new WeakSet([Object.prototype,Error.prototype]),tg=(e,t)=>{e.name="$ZodError",fh.value=t,Object.defineProperty(e,"issues",fh),fh.value=void 0,Object.defineProperty(e,"message",JT);let n=Object.getPrototypeOf(e);if(!eg.has(n))eg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},ng=J("$ZodError",tg),jI=J("$ZodError",tg,void 0,{Parent:Error});function QT(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function ig(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)QT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function rg(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function cc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var lc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new pi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var uc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var hc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new pi;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};function sg(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>di(r,n,Sn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var fc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};var eA=Symbol.for("zod.compile.invalid"),tA=Symbol.for("zod.compile.fallback"),dh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==eA)return!0;if(i.definite===!0&&n===void 0)return!1}return nA(e,t,n)};function nA(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[tA]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new pi;return s.issues.length===0}var ph=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},og=(e)=>{let t=lc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,cc(n,o))};return n};var ag=(e)=>{let t=lc(e),n=(i,r,s,o)=>t(i,r,s,cc(n,o));return n};var cg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,cc(n,o))};return n};var lg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>await t(i,r,s,cc(n,o));return n};var ug=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return hc(e)(t,n,r)};var hg=(e)=>(t,n,i)=>hc(e)(t,n,i);var fg=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return fc(e)(t,n,r)};var dg=(e)=>async(t,n,i)=>fc(e)(t,n,i);var pg=/^[cC][0-9a-z]{6,}$/,mg=/^[0-9a-z]+$/,gg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_g=/^[0-9a-vA-V]{20}$/,xg=/^[A-Za-z0-9]{27}$/,yg=/^[a-zA-Z0-9_-]{21}$/;function vg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var bg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Sg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,gh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Mg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iA="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wg(){return new RegExp(iA,"u")}var Eg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ag=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Rg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ig=/^https?$/,Lg=/^\+[1-9]\d{6,14}$/;var Ng="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rA(e){return new RegExp(`^${e}$`)}var Dg=rA(Ng);function mh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Og(e){return new RegExp(`^${mh(e)}$`)}function Ug(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${mh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${mh({precision:e.precision})}`:n;return new RegExp(`^${Ng}T(?:${i})$`)}var Fg=/^[\s\S]{0,}$/;var _h=/^-?\d+$/,Mo=/^-?\d+(?:\.\d+)?$/,zg=/^(?:true|false)$/i;var kg=/^[^A-Z]*$/,Bg=/^[^a-z]*$/;var Xt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var xh=(e)=>{let t=e.value;return!Um(t)&&t.length!==void 0},dc={number:"number",bigint:"bigint",object:"date"},yh=J("$ZodCheckLessThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vh=J("$ZodCheckGreaterThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gg=J("$ZodCheckMultipleOf",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Fm(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Hg=J("$ZodCheckNumberFormat",(e,t)=>{Xt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=ic[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Vg=J("$ZodCheckMaxLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?sc(r):s)<=t.maximum)return;let a=oc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$g=J("$ZodCheckMinLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?sc(r):s)>=t.minimum)return;let a=oc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Wg=J("$ZodCheckLengthEquals",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?sc(r):s;if(o===t.length)return;let a=oc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Eo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Xt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Zg=J("$ZodCheckRegex",(e,t)=>{Eo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xg=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kg),Eo.init(e,t)}),qg=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Bg),Eo.init(e,t)}),jg=J("$ZodCheckIncludes",(e,t)=>{Xt.init(e,t);let n=ar(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Yg=J("$ZodCheckStartsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`^${ar(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Kg=J("$ZodCheckEndsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`.*${ar(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Jg=J("$ZodCheckOverwrite",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class bh{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
4344
+ }`;class Zm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _c(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Bn({vertexShader:dT,fragmentShader:fT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new Po(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xm extends ti{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,h=null,d=null,f=null,m=typeof XRWebGLBinding<"u",_=new Zm,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new De,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new lh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new So,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),d=null,h=null,u=null,i=null,T=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),T=new En(d.framebufferWidth,d.framebufferHeight,{format:gi,type:ei,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Rs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(Ae),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),T=new En(h.textureWidth,h.textureHeight,{format:gi,type:ei,depthTexture:new Vr(h.textureWidth,h.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,wt=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],nt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],Et=wt*nt,gn=wt*Jt,kt=xe/(-nt+Jt),Bt=kt*-nt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=wt+kt,_n=Ge+kt,ct=Et-Bt,Pt=gn+(xe-Bt),E=Ye*Ge/_n*D,v=ht*Ge/_n*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,_n),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function ee(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;ee(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)ee(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Se(Z,L,xe)};function Se(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(h===null&&d===null)return;return a},this.setFoveation=function(Z){if(a=Z,h!==null)h.fixedFoveation=Z;if(d!==null&&d.fixedFoveation!==void 0)d.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(d!==null)e.setRenderTargetFramebuffer(T,d.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(d!==null)ht=d.getViewport(Ye);else{let Jt=u.getViewSubImage(h,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[Ge];if(nt===void 0)nt=new Vt,nt.layers.enable(Ge),nt.viewport=new ft,C[Ge]=nt;if(nt.matrix.fromArray(Ye.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Ye.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(nt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(nt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new _c,p[Ye]=ht;let nt=u.getCameraImage(Ye);ht.sourceTexture=nt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let Me=new Om;Me.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var pT=new $e,jm=new Ve;jm.set(-1,0,0,0,1,0,0,0,1);function mT(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,Qu(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,S,T,y){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),h(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),d(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,S,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===sn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===sn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(pT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(jm);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function h(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function d(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,S){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===sn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function gT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)d(y),s[y.id]=x}function u(y){let w=h();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function h(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,ee=q%k.boundary,Se=q+ee;if(A+=ee,Se!==0&&R-Se<k.storage)A+=R-Se;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var _T=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]),xi=null;function xT(){if(xi===null)xi=new Eo(_T,16,16,kr,mi),xi.name="DFG_LUT",xi.minFilter=qt,xi.magFilter=qt,xi.wrapS=As,xi.wrapT=As,xi.generateMipmaps=!1,xi.needsUpdate=!0;return xi}class Eh{constructor(e={}){let{canvas:t=tm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=ei}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=d,_=new Set([hu,uu,lu]),p=new Set([ei,hr,xo,Rs,au,cu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],R=[],x=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=Kn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,ee=new ft,Se=null,ue=new Ue(0),Be=0,{width:Me,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,Me,Z),Ae=new ft(0,0,Me,Z),wt=!1,Ge=new To,Ye=!1,ht=!1,nt=new $e,Jt=new U,Et=new ft,gn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function _n(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,Ne,Oe,st,F,ce,Q,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${ap}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!1),D===null){if(D=_n("webgl2",b),D===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ze("WebGLRenderer: "+b.message),b}function ne(){if(ct=new EE(D),ct.init(),Q=new hT(D,ct),Pt=new mE(D,ct,e,Q),E=new lT(D,ct),Pt.reversedDepthBuffer&&h)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new RE(D),N=new qA,H=new uT(D,ct,E,N,Pt,Q,v),ie=new wE(M),ae=new PS(D),le=new fE(D,ae),he=new AE(D,ae,v,le),Y=new PE(D,he,ae,le,v),st=new CE(D,Pt,H),oe=new gE(N),te=new jA(M,ie,ct,Pt,le,oe),_e=new mT(M,N),Ie=new JA,de=new iT(ct),Oe=new dE(M,ie,E,Y,f,a),Ne=new cT(M,Y,Pt),ye=new gT(D,v,Pt,E),F=new pE(D,ct,v),ce=new TE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=Ne,M.state=E,M.info=v}if(m!==ei)x=new LE(m,t.width,t.height,o,i,r);let pe=new Xm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(Me,Z,!1)},this.getSize=function(b){return b.set(Me,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){Me=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===ei){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(ee.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return wt},this.setScissorTest=function(b){E.setScissorTest(wt=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,be=p.has(ge),me=Oe.getClearColor(),Te=Oe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(be)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.clear(B)},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(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Oe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",mf),pe.removeEventListener("sessionend",gf),Rr.stop()};function He(b){b.preventDefault(),fo("WebGLRenderer: Context Lost."),z=!0}function bt(){fo("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=Ne.enabled,W=Ne.autoUpdate,B=Ne.needsUpdate,V=Ne.type;ne(),v.autoReset=b,Ne.enabled=O,Ne.autoUpdate=W,Ne.needsUpdate=B,Ne.type=V}function lt(b){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function ai(b){let O=b.target;O.removeEventListener("dispose",ai),Oi(O)}function Oi(b){vb(b),N.remove(b)}function vb(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=gn;let be=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Mb(b,O,W,B,V);E.setMaterial(B,be);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let At,xt=F;if(Te!==null)At=ae.get(Te),xt=ce,xt.setIndex(At);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let tn=B.linewidth;if(tn===void 0)tn=1;if(E.setLineWidth(tn*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:tn,_multiDrawCounts:ve,_multiDrawCount:un}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ci=0;ci<un;ci++)On.setValue(D,"_gl_DrawID",ci),xt.render(tn[ci]/it,ve[ci])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let tn=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,tn);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function pf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=sn,b.needsUpdate=!0,ba(b,O,B),b.side=ur,b.needsUpdate=!0,ba(b,O,B),b.side=kn;else ba(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)Ne.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let be=0;be<ge.length;be++){let me=ge[be];pf(me,W,O,V),B.add(me)}else pf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(be){let Te=N.get(be).currentProgram;if(Te===void 0||Te.isReady())B.delete(be)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Sl=null;function bb(b){if(Sl)Sl(b)}function mf(){Rr.stop()}function gf(){Rr.start()}let Rr=new Om;if(Rr.setAnimationLoop(bb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){Sl=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",mf),pe.addEventListener("sessionend",gf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(nt,Xu,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)Ml(be,O,-1/0,M.sortObjects)}if(Ml(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Oe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(Ne.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let be=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];xf(be,me,b,Ke)}if(kt)Oe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];_f(y,b,Ke,Ke.viewport)}}else{if(me.length>0)xf(be,me,b,O);if(kt)Oe.render(b);_f(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function Ml(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)Et.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let be=Y.update(b),me=b.material;if(me.visible)y.push(b,be,me,W,Et.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let be=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();Et.copy(b.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();Et.copy(be.boundingSphere.center)}Et.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(me)){let Te=be.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,be,Re,W,Et.z,Ke,O)}}else if(me.visible)y.push(b,be,me,W,Et.z,null,O)}}}let ge=b.children;for(let be=0,me=ge.length;be<me;be++)Ml(ge[be],O,W,B)}function _f(b,O,W,B){let{opaque:V,transmissive:ge,transparent:be}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)va(V,O,W);if(ge.length>0)va(ge,O,W);if(be.length>0)va(be,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function xf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new En(1,1,{generateMipmaps:!0,type:Re?mi:ei,minFilter:pi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],be=B.viewport||q;ge.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Oe.render(W);let We=M.toneMapping;M.toneMapping=Kn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(va(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let At=O[ut],{object:xt,geometry:tn,material:ve,group:un}=At;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=sn,ve.needsUpdate=!0,yf(xt,W,B,tn,ve,un),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function va(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let be=b[V],{object:me,geometry:Te,group:Pe}=be,We=be.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))yf(me,O,W,Te,We,Pe)}}function yf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=sn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function ba(b,O,W){if(O.isScene!==!0)O=gn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,be=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",ai),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===be)return bf(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(bf(b,me),B.needsLights=Eb(b),B.lightsStateVersion=be,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function vf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=zo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function bf(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Sb(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Mb(b,O,W,B,V){if(O.isScene!==!0)O=gn;H.resetTextureUnits();let ge=O.fog,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||be,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,At=Kn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)At=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,tn=xt!==void 0?xt.length:0,ve=N.get(B),un=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==un.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==At)it=!0;else if(ve.morphTargetsCount!==tn)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=ba(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ci=!1,Ki=!1,ns=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ci=!0,Ki=!0,ns=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Sb(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ci||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,ns=!0}if(ve.needsLights){if(un.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",un.state.sunShadowMap,H);if(un.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",un.state.directionalShadowMap,H);if(un.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",un.state.spotShadowMap,H);if(un.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",un.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=xT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)wb(Ot,ns);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}zo.upload(D,vf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)zo.upload(D,vf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,is=St.length;er<is;er++){let Mf=St[er];ye.update(Mf,On),ye.bind(Mf,On)}}return On}function wb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Eb(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),ee.copy(b.scissor),Se=b.scissorTest,E.viewport(q),E.scissor(ee),E.setScissorTest(Se),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),ee.copy(b.scissor),Se=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),ee.copy(Ae).multiplyScalar(re).floor(),Se=wt;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(ee),E.setScissorTest(Se),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function Sf(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Sf(Pe);if(Re.__formatReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,Q.convert(We),Q.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Sf(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,Q.convert(We),Q.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let At=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await im(D,At,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(At),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),be=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,be,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let be,me,Te,Pe,We,Ke,Re,ut,Ft,At=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)be=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(be=Math.floor(At.width*Ot),me=Math.floor(At.height*Ot),b.isDataArrayTexture)Te=At.depth;else if(b.isData3DTexture)Te=Math.floor(At.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=Q.convert(O.format),tn=Q.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let un=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ci=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,At.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,At.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let ns=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let is=0;is<Te;is++){if(ns)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+is),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+is);D.blitFramebuffer(Pe,We,be,me,Re,ut,be,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(ns)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,be,me,Re,ut,be,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,be,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,be,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,tn,At.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,At.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,be,me,Te,xt,tn,At);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,be,me,xt,tn,At.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,At.width,At.height,xt,At.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,be,me,xt,tn,At);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,un),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ci),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Xu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var Ym={type:"change"},Th={type:"start"},Km={type:"end"},Ic=new fr,Jm=new Fn,yT=Math.cos(70*vo.DEG2RAD),Wt=new U,vn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ah=0.000001;class Rh extends Ac{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Do,this._sphericalDelta=new Do,this._scale=1,this._panOffset=new U,this._rotateStart=new De,this._rotateEnd=new De,this._rotateDelta=new De,this._panStart=new De,this._panEnd=new De,this._panDelta=new De,this._dollyStart=new De,this._dollyEnd=new De,this._dollyDelta=new De,this._dollyDirection=new U,this._mouse=new De,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=bT.bind(this),this._onPointerDown=vT.bind(this),this._onPointerUp=ST.bind(this),this._onContextMenu=CT.bind(this),this._onMouseWheel=ET.bind(this),this._onKeyDown=AT.bind(this),this._onTouchStart=TT.bind(this),this._onTouchMove=RT.bind(this),this._onMouseDown=MT.bind(this),this._onMouseMove=wT.bind(this),this._interceptControlDown=PT.bind(this),this._interceptControlUp=IT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=pt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ym),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=vn;else if(n>Math.PI)n-=vn;if(i<-Math.PI)i+=vn;else if(i>Math.PI)i-=vn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Wt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Ic.origin.copy(this.object.position),Ic.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ic.direction))<yT)this.object.lookAt(this.target);else Jm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ic.intersectPlane(Jm,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ah||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ah||this._lastTargetPosition.distanceToSquared(this.target)>Ah)return this.dispatchEvent(Ym),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return vn/60*this.autoRotateSpeed*e;else return vn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new De,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function vT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function bT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function ST(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Km),this.state=pt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function MT(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Th)}function wT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function ET(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Th),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Km)}function AT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function TT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Th)}function RT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function CT(e){if(this.enabled===!1)return;e.preventDefault()}function PT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function IT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Ch extends Ps{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new $i({side:sn}),n=new $i,i=new Us(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Ls(e,n,6),o=new gt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,Vs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,Vs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,Vs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,Vs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let h=new Mt(e,Vs(20));h.position.set(3.235,11.486,-12.541),h.scale.set(2.5,2,0.1),this.add(h);let d=new Mt(e,Vs(100));d.position.set(0,20,0),d.scale.set(1,0.1,1),this.add(d)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Vs(e){return new xc({color:0,emissive:16777215,emissiveIntensity:e})}function Ph(e,t){if(t===Hu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Cs||t===yo){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Cs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function Qm(e){let t=new Map,n=new Map,i=e.clone();return eg(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function eg(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)eg(e.children[i],t.children[i],n)}class Fh extends Zi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new cg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new dg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new ag(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new ug(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new sg(t)}),this.register(function(t){return new Dh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Dh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new bg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new Lo(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Sg){try{s[Je.KHR_BINARY_GLTF]=new Mg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Rg(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:s[u]=new og;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new wg(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Eg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Ag;break;default:if(h.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function LT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class sg{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Ue(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],wn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Fs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Us(l),c.distance=u;break;case"spot":c=new Mc(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),vi(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class og{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return _i}extendParams(e,t,n){let i=[];e.color=new Ue(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],wn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class ag{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class cg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new De(r,r)}}return Promise.all(i)}}class lg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class ug{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],wn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(r[0],r[1],r[2],wn),Promise.all(i)}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Ue().setRGB(r[0],r[1],r[2],wn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class xg{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class yg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class vg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Dh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,h=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,h,i.mode,i.filter).then(function(d){return d.buffer});else return s.ready.then(function(){let d=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(d),l,u,h,i.mode,i.filter),d})})}else return null}}class bg{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,d=[];for(let f of u){let m=new $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ls(f.geometry,f.material,h);for(let y=0;y<h;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new on,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),d.push(S)}if(l.isGroup)return l.clear(),l.add(...d),l;return d[0]})}}var Sg="glTF",Bo=12,tg={JSON:1313821514,BIN:5130562};class Mg{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Bo),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Sg)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Bo,r=new DataView(e,Bo),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===tg.JSON){let c=new Uint8Array(e,Bo+s,o);this.content=n.decode(c)}else if(a===tg.BIN){let c=Bo+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class wg{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Oh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Oh[l]||l.toLowerCase();if(s[l]!==void 0){let h=n.accessors[e.attributes[l]],d=Gs[h.componentType];c[u]=d.name,a[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){i.decodeDracoFile(l,function(d){for(let f in d.attributes){let m=d.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(d)},o,c,wn,h)})})}}class Eg{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Ag{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class zh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,h=u*u,d=h*u,f=e*c,m=f-c,_=-2*d+3*h,p=d-h,g=1-_,S=p-h+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var NT=new Xt;class Tg extends zh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return NT.fromArray(r).normalize().toArray(r),r}}var Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Gs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ng={9728:Qn,9729:qt,9984:Qa,9985:Ts,9986:Ur,9987:pi},ig={33071:As,33648:Ka,10497:Es},Ih={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Oh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},DT={CUBICSPLINE:void 0,LINEAR:oc,STEP:Gu},Lh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function OT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function vi(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function UT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0)i=!0;if(h.NORMAL!==void 0)r=!0;if(h.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(i){let d=h.POSITION!==void 0?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=h;if(s)e.morphAttributes.color=d;return e.morphTargetsRelative=!0,e})}function FT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function zT(e){let t,n=e.extensions&&e.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Nh(n.attributes);else t=e.indices+":"+Nh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Nh(e.targets[i]);return t}function Nh(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function Uh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function kT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var BT=new $e;class Rg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new LT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Ds(this.options.manager);else this.textureLoader=new wc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Lo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Zr(r,o,i),vi(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Ih[i.type],o=Gs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Ih[i.type],c=Gs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,h=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(d&&d!==u){let p=Math.floor(h/d),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*d,i.count*d/l),S=new Mo(m,d/l),t.cache.add(g,S);_=new Is(S,a,h%d/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,h,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Ih.SCALAR,g=Gs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let h=(r.samplers||{})[s.sampler]||{};return l.magFilter=ng[h.magFilter]||qt,l.minFilter=ng[h.minFilter]||pi,l.wrapS=ig[h.wrapS]||Es,l.wrapT=ig[h.wrapT]||Es,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Qn&&l.minFilter!==qt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let h=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(h),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(h,d){let f=h;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,h(_)};t.load(vr.resolveURL(u,r.path),f,void 0,d)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return vi(u,s),u.userData.mimeType=s.mimeType||kT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Co,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Ro,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return $i}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ue(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let h=u.baseColorFactor;o.color.setRGB(h[0],h[1],h[2],wn),o.opacity=h[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=kn;let l=r.alphaMode||Lh.OPAQUE;if(l===Lh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Lh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==_i){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new De(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==_i){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==_i){let u=r.emissiveFactor;o.emissive=new Ue().setRGB(u[0],u[1],u[2],wn)}if(r.emissiveTexture!==void 0&&s!==_i)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(vi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return rg(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=zT(c),u=i[l];if(u)s.push(u.promise);else{let h;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])h=r(c);else h=rg(new on,c,t);if(c.mode===Vn.TRIANGLE_STRIP)h=h.then((d)=>Ph(d,yo));else if(c.mode===Vn.TRIANGLE_FAN)h=h.then((d)=>Ph(d,Cs));i[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?OT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let d=0,f=l.length;d<f;d++){let m=l[d],_=s[d],p,g=c[d];if(_.mode===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new fc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new pc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new mc(m,g);else if(_.mode===Vn.POINTS)p=new Ns(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)FT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),vi(p,r),_.extensions)Zr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let d=0,f=u.length;d<f;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1){if(r.extensions)Zr(i,u[0],r);return u[0]}let h=new ui;if(r.extensions)Zr(i,h,r);t.associations.set(h,{meshes:e});for(let d=0,f=u.length;d<f;d++)h.add(u[d]);return h})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Vt(vo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return vi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let h=new $e;if(r!==null)h.fromArray(r.array,c*16);a.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ao(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,h=i.channels.length;u<h;u++){let d=i.channels[u],f=i.samplers[d.sampler],m=d.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let h=u[0],d=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=h.length;S<T;S++){let y=h[S],w=d[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new bs(r,void 0,p);return vi(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],h=c[2];if(h!==null)l.traverse(function(d){if(!d.isSkinnedMesh)return;d.bind(h,BT)});for(let d=0,f=u.length;d<f;d++)l.add(u[d]);if(l.userData.pivot!==void 0&&u.length>0){let d=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(d),l.position.x-=d[0],l.position.y-=d[1],l.position.z-=d[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new wo;else if(c.length>1)l=new ui;else if(c.length===1)l=c[0];else l=new gt;if(l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(vi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ui;if(n.name)r.name=i.createUniqueName(n.name);if(vi(r,n),n.extensions)Zr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let h=a[l];if(h.parent!==null)r.add(Qm(h));else r.add(h)}let c=(l)=>{let u=new Map;for(let[h,d]of i.associations)if(h instanceof yn||h instanceof Nt)u.set(h,d);return l.traverse((h)=>{let d=i.associations.get(h);if(d!=null)u.set(h,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(d){if(d.morphTargetInfluences)a.push(d.name?d.name:d.uuid)}if(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?DT[i.interpolation]:oc,h=this._getArrayFromAccessor(n);for(let d=0,f=a.length;d<f;d++){let m=new l(a[d]+"."+br[r.path],t.array,h,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Uh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof xr?Tg:zh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function VT(e,t,n){let i=t.attributes,r=new Gt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=Uh(Gs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=n.json.accessors[h.POSITION],{min:f,max:m}=d;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){let _=Uh(Gs[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new An;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function rg(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Oh[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(je.workingColorSpace!==wn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return vi(e,t),VT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?UT(e,t.targets,n):e})}function Go(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function Bh(e,t="|"){return e.map((n)=>Hh(n)).join(t)}function Ho(e,t){if(typeof t==="bigint")return t.toString();return t}class Cg{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function $o(e){return new Cg(e)}function Pg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ig(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xi(e){return Wo(e._zod.def)??e._zod.def.shape}function Lg(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Ng(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Xi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Lg(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Ng(e,s,i?i(o.value,s):o.value)}}function GT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Lg(e,n,()=>t[n]);else Ng(e,n,i.value)}}function Cn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Dg(e){return JSON.stringify(e)}function Og(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Vh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Hs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ug=$o(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function jr(e){if(Hs(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Hs(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Gh(e){if(jr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Fg=new Set(["string","number","symbol"]),zg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Hh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function kg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Lc=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),$h={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function HT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Xr(s,e,Nc(e,t)),bi(e,Cn(n,{shape:s,checks:[]}))}function Nc(e,t){let n=Xi(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function $T(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Nc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Xi(e)).filter((a)=>!s.has(a))),bi(e,Cn(n,{shape:o,checks:[]}))}function WT(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Xi(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return bi(e,Cn(e._zod.def,{shape:Bg(e,t)}))}function Bg(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Xi(e))),GT(n,t),n}function ZT(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return bi(e,Cn(e._zod.def,{shape:Bg(e,t)}))}function XT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Xr(n,e,Reflect.ownKeys(Xi(e))),Xr(n,t,Reflect.ownKeys(Xi(t)));let i=Cn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bi(e,i)}function Vg(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Nc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Xi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),bi(t,Cn(t._zod.def,{shape:c,checks:[]}))}function jT(e,t,n){let i=n?new Set(Nc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Xi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),bi(t,Cn(t._zod.def,{shape:r}))}function Hn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Si(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Vo(e){return typeof e==="string"?e:e?.message}function Wh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Mi(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:Vo(e.inst?._zod.def?.error?.(e))??Vo(s?.(e))??Vo(t?.error?.(e))??Vo(n.customError?.(e))??Vo(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var qT=/[\uD800-\uDBFF]/;function Dc(e){let t=e.length;if(!qT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function Oc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Hg(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function $g(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else YT(e,n,i.value)}}function ji(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Uc(e,t,n){return ji(e,t,n,!1)}function Wg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ji(this,n,i(this))},set(r){ji(this,n,r)}})}return t}function YT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ji(this,t,n.bind(this))},set(i){ji(this,t,i)}})}function JT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var kh,Sr=!1,KT={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&kh!==e._zod){kh=void 0;return}kh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,KT);let r=Sr;Sr=!1;try{let s=n(this);if(Sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Sr=Sr||r,s}catch(s){throw delete this[t],Sr=Sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function QT(e,t,n,i){let r=JT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var e1="~constantCatch";function Zg(e){let t=()=>e;return t[e1]=!0,t}var Xg;var Zh={value:void 0,enumerable:!1},jg="captureStackTrace"in Error?Error:null;function t1(e){let t=jg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return jg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(d){this.def=d,this.constr=h,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(d,f){if(!d._zod){Zh.value=new s(f);try{Object.defineProperty(d,"_zod",Zh)}finally{Zh.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let _=Object.getPrototypeOf(d),p=d._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),$g(S,o)}let m=h.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in d))d[_]=m[_].bind(d)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){let f=i?.Parent?t1(u):this;c(f,d);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:(d)=>{if(i?.Parent&&d instanceof i.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class wi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Zo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Xg=globalThis).__zod_globalConfig??(Xg.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Pn(e){if(e)Object.assign(dn,e);return dn}function n1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ho,2)),e.message}function i1(e){this._zod.message=e}var r1={get:n1,set:i1,enumerable:!0,configurable:!0},jh={value:void 0,enumerable:!1},qg=new WeakSet([Object.prototype,Error.prototype]),Yg=(e,t)=>{e.name="$ZodError",jh.value=t,Object.defineProperty(e,"issues",jh),jh.value=void 0,Object.defineProperty(e,"message",r1);let n=Object.getPrototypeOf(e);if(!qg.has(n))qg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},Jg=J("$ZodError",Yg),EN=J("$ZodError",Yg,void 0,{Parent:Error});function s1(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function Kg(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)s1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Qg(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],h=l===a.length-1;if(u==="_errors"){if(h)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(h)d._errors.push(t(o));c=d,l++}}}};return i(e),n}function Fc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var zc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new wi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Mi(l,o,Pn())));throw Vh(c,s?.callee??t),c}return a.value};return t};var kc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Mi(l,o,Pn())));throw Vh(c,s?.callee??t),c}return a.value};return t};var Bc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new wi;return s.issues.length?e_(e,s.issues,r):{success:!0,data:s.value}};function e_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Mi(r,n,Pn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Vc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?e_(e,s.issues,r):{success:!0,data:s.value}};var o1=Symbol.for("zod.compile.invalid"),a1=Symbol.for("zod.compile.fallback"),qh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==o1)return!0;if(i.definite===!0&&n===void 0)return!1}return c1(e,t,n)};function c1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[a1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new wi;return s.issues.length===0}var Yh=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},t_=(e)=>{let t=zc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Fc(n,o))};return n};var n_=(e)=>{let t=zc(e),n=(i,r,s,o)=>t(i,r,s,Fc(n,o));return n};var i_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Fc(n,o))};return n};var r_=(e)=>{let t=kc(e),n=async(i,r,s,o)=>await t(i,r,s,Fc(n,o));return n};var s_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Bc(e)(t,n,r)};var o_=(e)=>(t,n,i)=>Bc(e)(t,n,i);var a_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vc(e)(t,n,r)};var c_=(e)=>async(t,n,i)=>Vc(e)(t,n,i);var l_=/^[cC][0-9a-z]{6,}$/,u_=/^[0-9a-z]+$/,h_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,d_=/^[0-9a-vA-V]{20}$/,f_=/^[A-Za-z0-9]{27}$/,p_=/^[a-zA-Z0-9_-]{21}$/;function m_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var g_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var __=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var x_=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var l1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function y_(){return new RegExp(l1,"u")}var v_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,b_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var S_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,M_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,E_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var A_=/^https?$/,T_=/^\+[1-9]\d{6,14}$/;var R_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function u1(e){return new RegExp(`^${e}$`)}var C_=u1(R_);function Jh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function P_(e){return new RegExp(`^${Jh(e)}$`)}function I_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Jh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Jh({precision:e.precision})}`:n;return new RegExp(`^${R_}T(?:${i})$`)}var L_=/^[\s\S]{0,}$/,N_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Gc=/^-?\d+$/,$s=/^-?\d+(?:\.\d+)?$/,D_=/^(?:true|false)$/i;var O_=/^[^A-Z]*$/,U_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Qh=(e)=>{let t=e.value;return!Pg(t)&&t.length!==void 0},Hc={number:"number",bigint:"bigint",object:"date"},ed=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Hc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),td=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Hc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Hc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),F_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ig(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),z_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Lc[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var k_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Dc(r):s)<=t.maximum)return;let a=Oc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),B_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Dc(r):s)>=t.minimum)return;let a=Oc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),V_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=Qh),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Dc(r):s;if(o===t.length)return;let a=Oc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),jo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),G_=J("$ZodCheckRegex",(e,t)=>{jo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),H_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=O_),jo.init(e,t)}),$_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=U_),jo.init(e,t)}),W_=J("$ZodCheckIncludes",(e,t)=>{Kt.init(e,t);let n=qi(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Z_=J("$ZodCheckStartsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`^${qi(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),X_=J("$ZodCheckEndsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`.*${qi(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var j_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class nd{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
4345
4345
  `).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4346
4346
  ${t.join(`
4347
4347
  `)}
4348
- };`)(...Object.values(this.closed))}}var e_={major:4,minor:6,patch:5};var Mt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=e_;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=fi(a),f;for(let h of c){if(h._zod.def.when){if(Xm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new pi;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(lh(a.issues,d,e),!u)u=fi(a,d)});else{if(a.issues.length===d)continue;if(lh(a.issues,d,e),!u)u=fi(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(fi(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new pi;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new pi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ac(this,"~standard",Mh(this))},set "~standard"(e){Ni(this,"~standard",e)}}),h_=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>di(n,t,Sn()))}:{value:e.value};async function sA(e,t){let n={async:!0};return h_(await e._zod.run({value:t,issues:[]},n),n)}function Mh(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return h_(i,n)}catch(i){}return sA(e,t)},vendor:"zod",version:1}}var _c=J("$ZodString",(e,t)=>{Mt.init(e,t),e._zod.pattern=t.pattern??Fg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),bt=J("$ZodStringFormat",(e,t)=>{Eo.init(e,t),_c.init(e,t)}),f_=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Sg),bt.init(e,t)}),d_=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=gh(i))}else t.pattern??(t.pattern=gh());bt.init(e,t)}),p_=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mg),bt.init(e,t)}),m_=1,mc=2;function g_(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function oA(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return g_(e)||mc;return aA(e,t)}function aA(e,t){if(!t.normalize&&t.protocol?.source===Ig.source&&!/^https?:\/\//i.test(e))return m_;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??mc}return new URL(e)}catch{return mc}}var cA=/[\t\n\r]/g;function t_(e){return e.replace(cA,"")}function lA(e,t){return t.lastIndex=0,t.test(e.hostname)}function uA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var __=J("$ZodURL",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=oA(i,t);if(r===m_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===mc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=t_(i);return}if(t.hostname&&!lA(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!uA(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:t_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),x_=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wg()),bt.init(e,t)}),y_=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?yg:vg(t.length)),bt.init(e,t)}),v_=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pg),bt.init(e,t)}),b_=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mg),bt.init(e,t)}),S_=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gg),bt.init(e,t)}),M_=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_g),bt.init(e,t)}),w_=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xg),bt.init(e,t)}),E_=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ug(t)),bt.init(e,t)}),T_=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dg),bt.init(e,t)}),A_=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Og(t)),bt.init(e,t)}),R_=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=bg),bt.init(e,t)}),C_=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Eg),bt.init(e,t)}),hA=/^[0-9a-fA-F:.]+$/;function P_(e){if(!hA.test(e))return!1;return g_(`http://[${e}]`)}var I_=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Tg),bt.init(e,t),e._zod.check=(n)=>{if(!P_(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var L_=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ag),bt.init(e,t)});function fA(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return P_(n)}var N_=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Rg),bt.init(e,t),e._zod.check=(n)=>{if(!fA(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function D_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var wh=/^[0-9a-zA-Z+/]*={0,2}$/,O_=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=wh),bt.init(e,t),e._zod.check=(n)=>{if(D_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),xc=/^[A-Za-z0-9_-]*$/;function dA(e){if(!xc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return D_(n)}var U_=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xc),bt.init(e,t),e._zod.check=(n)=>{if(dA(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),F_=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Lg),bt.init(e,t)});function pA(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var z_=J("$ZodJWT",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{if(pA(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Eh=J("$ZodNumber",(e,t)=>{Mt.init(e,t),e._zod.pattern=Mo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),k_=J("$ZodNumberFormat",(e,t)=>{Hg.init(e,t),Eh.init(e,t)}),B_=J("$ZodBoolean",(e,t)=>{Mt.init(e,t),e._zod.pattern=zg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var G_=J("$ZodUnknown",(e,t)=>{Mt.init(e,t),e._zod.parse=(n)=>n}),H_=J("$ZodNever",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function n_(e,t,n){if(e.issues.length)t.issues.push(...cr(n,e.issues));t.value[n]=e.value}var V_=J("$ZodArray",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>n_(f,i,c)));else if(n_(u,i,c),a&&u.issues.length!==0&&fi(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function gc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...cr(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var mA=[];function $_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:mA,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=$m(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function W_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(fi(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>gc(p,n,g,t,f,h)));else gc(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var gA=J("$ZodObject",(e,t)=>{Mt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=vo(()=>$_(t));tt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))Nn(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ts,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(fi(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,v=m._zod.run({value:f[p],issues:[]},u);if(v instanceof Promise)h.push(v.then((M)=>gc(M,l,p,f,E,R)));else gc(v,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return W_(h,f,l,u,r.value,e,g===!0)}}),Z_=J("$ZodObjectJIT",(e,t)=>{gA.init(e,t);let n=e._zod.parse,i=vo(()=>$_(t)),r=dn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new bh(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(M)=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,E=(M,T)=>`
4349
- let ${M}_ab = false;
4350
- for (let i = 0; i < ${M}.issues.length; i++) {
4351
- const iss = ${M}.issues[i];
4352
- iss.path = iss.path ? [${T}, ...iss.path] : [${T}];
4348
+ };`)(...Object.values(this.closed))}}var Y_={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Y_;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=Hn(a),h;for(let d of c){if(d._zod.def.when){if(Gg(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new wi;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Wh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(Wh(a.issues,f,e),!u)u=Hn(a,f)}}if(h)return h.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new wi;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>o(h,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new wi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Uc(this,"~standard",sd(this))},set "~standard"(e){ji(this,"~standard",e)}}),u0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Mi(n,t,Pn()))}:{value:e.value};async function h1(e,t){let n={async:!0};return u0(await e._zod.run({value:t,issues:[]},n),n)}function sd(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return u0(i,n)}catch(i){}return h1(e,t)},vendor:"zod",version:1}}var Xc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??L_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=J("$ZodStringFormat",(e,t)=>{jo.init(e,t),Xc.init(e,t)}),h0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=__),Tt.init(e,t)}),d0=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Kh(i))}else t.pattern??(t.pattern=Kh());Tt.init(e,t)}),f0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=x_),Tt.init(e,t)}),p0=1,Wc=2;function m0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function d1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return m0(e)||Wc;return f1(e,t)}function f1(e,t){if(!t.normalize&&t.protocol?.source===A_.source&&!/^https?:\/\//i.test(e))return p0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Wc}return new URL(e)}catch{return Wc}}var p1=/[\t\n\r]/g;function J_(e){return e.replace(p1,"")}function m1(e,t){return t.lastIndex=0,t.test(e.hostname)}function g1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var g0=J("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=d1(i,t);if(r===p0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Wc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=J_(i);return}if(t.hostname&&!m1(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!g1(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:J_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),_0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=y_()),Tt.init(e,t)}),x0=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?p_:m_(t.length)),Tt.init(e,t)}),y0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=l_),Tt.init(e,t)}),v0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=u_),Tt.init(e,t)}),b0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=h_),Tt.init(e,t)}),S0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=d_),Tt.init(e,t)}),M0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=f_),Tt.init(e,t)}),w0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=I_(t)),Tt.init(e,t)}),E0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=C_),Tt.init(e,t)}),A0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=P_(t)),Tt.init(e,t)}),T0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=g_),Tt.init(e,t)}),R0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=v_),Tt.init(e,t)}),_1=/^[0-9a-fA-F:.]+$/;function C0(e){if(!_1.test(e))return!1;return m0(`http://[${e}]`)}var P0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=b_),Tt.init(e,t),e._zod.check=(n)=>{if(!C0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var I0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=S_),Tt.init(e,t)});function x1(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return C0(n)}var L0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=M_),Tt.init(e,t),e._zod.check=(n)=>{if(!x1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function N0(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var od=/^[0-9a-zA-Z+/]*={0,2}$/,D0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=od),Tt.init(e,t),e._zod.check=(n)=>{if(N0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jc=/^[A-Za-z0-9_-]*$/;function y1(e){if(!jc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return N0(n)}var O0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jc),Tt.init(e,t),e._zod.check=(n)=>{if(y1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),U0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=T_),Tt.init(e,t)});function v1(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var F0=J("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=(n)=>{if(v1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ad=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=$s,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),z0=J("$ZodNumberFormat",(e,t)=>{z_.init(e,t),ad.init(e,t)}),k0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=D_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var B0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),V0=J("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function K_(e,t,n){if(e.issues.length)t.issues.push(...Si(n,e.issues));t.value[n]=e.value}var G0=J("$ZodArray",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((h)=>K_(h,i,c)));else if(K_(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function Zc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...Si(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var b1=[];function H0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:b1,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=kg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function $0(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:h,optout:d}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Hn(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>Zc(p,n,m,t,h,d)));else Zc(_,n,m,t,h,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var S1=J("$ZodObject",(e,t)=>{vt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=$o(()=>H0(t));at(e,"propValues",(l)=>{let u=l.def.shape,h={};for(let d in u){let f=u[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(h,d))Gn(h,d,new Set);for(let m of f.values)h[d].add(m);if(f.optin!==void 0)h[d].add(void 0)}}return h});let s=Hs,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let h=l.value;if(!s(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:h[p],issues:[]},u);if(y instanceof Promise)d.push(y.then((w)=>Zc(w,l,p,h,S,T)));else Zc(y,l,p,h,S,T)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return $0(d,h,l,u,r.value,e,m===!0)}}),W0=J("$ZodObjectJIT",(e,t)=>{S1.init(e,t);let n=e._zod.parse,i=$o(()=>H0(t)),r=dn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new nd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`
4349
+ let ${w}_ab = false;
4350
+ for (let i = 0; i < ${w}.issues.length; i++) {
4351
+ const iss = ${w}.issues[i];
4352
+ iss.path = iss.path ? [${A}, ...iss.path] : [${A}];
4353
4353
  payload.issues.push(iss);
4354
- if (iss.continue !== true) ${M}_ab = true;
4354
+ if (iss.continue !== true) ${w}_ab = true;
4355
4355
  }
4356
- if (${M}_ab && ctx && ctx.abortEarly) {
4356
+ if (${w}_ab && ctx && ctx.abortEarly) {
4357
4357
  payload.value = newResult;
4358
4358
  return payload;
4359
- }`;p.write("const input = payload.value;");let R=Object.create(null),v=0;for(let M of g.allKeys)R[M]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=R[M],A=typeof M==="symbol"?`syms[${x.indexOf(M)}]`:Bm(M),_=`${A} in input`,S=d[M],z=S?._zod?.optin,P=z!==void 0,F=S?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),P&&F){let ee=z==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
4360
- const ${T}_present = ${_};
4361
- if (!${T}.issues.length || ${T}_present) {
4362
- if (${T}.issues.length) {${E(T,A)}
4359
+ }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:Dg(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`
4360
+ const ${A}_present = ${x};
4361
+ if (!${A}.issues.length || ${A}_present) {
4362
+ if (${A}.issues.length) {${S(A,R)}
4363
4363
  }
4364
4364
 
4365
- if (${ee}) {
4366
- newResult[${A}] = ${T}.value;
4365
+ if (${K}) {
4366
+ newResult[${R}] = ${A}.value;
4367
4367
  }
4368
4368
  }
4369
4369
 
4370
- `)}else if(!P)p.write(`
4371
- const ${T}_present = ${_};
4372
- if (${T}.issues.length) {${E(T,A)}
4370
+ `)}else if(!C)p.write(`
4371
+ const ${A}_present = ${x};
4372
+ if (${A}.issues.length) {${S(A,R)}
4373
4373
  }
4374
- if (!${T}_present && !${T}.issues.length) {
4374
+ if (!${A}_present && !${A}.issues.length) {
4375
4375
  payload.issues.push({
4376
4376
  code: "invalid_type",
4377
4377
  expected: "nonoptional",
4378
4378
  input: undefined,
4379
- path: [${A}]
4379
+ path: [${R}]
4380
4380
  });
4381
4381
  if (ctx && ctx.abortEarly) {
4382
4382
  payload.value = newResult;
@@ -4384,25 +4384,29 @@ ${t.join(`
4384
4384
  }
4385
4385
  }
4386
4386
 
4387
- if (${T}_present) {
4388
- newResult[${A}] = ${T}.value;
4387
+ if (${A}_present) {
4388
+ newResult[${R}] = ${A}.value;
4389
4389
  }
4390
4390
 
4391
4391
  `);else if(p.write(`
4392
- if (${T}.issues.length) {${E(T,A)}
4392
+ if (${A}.issues.length) {${S(A,R)}
4393
4393
  }
4394
- `),z==="defaulted")p.write(`newResult[${A}] = ${T}.value;`);else p.write(`
4395
- if (${T}.value !== undefined || ${_}) {
4396
- newResult[${A}] = ${T}.value;
4394
+ `),z==="defaulted")p.write(`newResult[${R}] = ${A}.value;`);else p.write(`
4395
+ if (${A}.value !== undefined || ${x}) {
4396
+ newResult[${R}] = ${A}.value;
4397
4397
  }
4398
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ts,c=!dn.jitless,u=c&&Hm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return W_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function i_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!fi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>di(o,i,Sn())))}),t}var Th=J("$ZodUnion",(e,t)=>{Mt.init(e,t),tt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),tt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),tt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),tt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>nc(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return i_(o,i,e,r);return Promise.all(o).then((a)=>i_(a,i,e,r))}});function _A(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var X_=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Th.init(e,t);let n=e._zod.parse;tt(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Nn(s,l,new Set);for(let f of u)s[l].add(f)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=bo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=vo(()=>_A(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Ts(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),q_=J("$ZodIntersection",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>r_(n,c,l));return r_(n,s,o)}});function Sh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nr(e)&&Nr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=Sh(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=Sh(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function r_(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Sh(t.value,n.value);if(!c.valid){if(fi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var j_=J("$ZodRecord",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Nr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>di(g,r,Sn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Mo.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>di(g,r,Sn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Y_=J("$ZodEnum",(e,t)=>{Mt.init(e,t);let n=xo(t.entries),i=new Set(n);e._zod.values=i,tt(e,"pattern",(r)=>{let s=xo(r.def.entries).filter((o)=>Vm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ar(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),K_=J("$ZodLiteral",(e,t)=>{Mt.init(e,t);let n=new Set(t.values);e._zod.values=n,tt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ar(s):s?ar(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var J_=J("$ZodTransform",(e,t)=>{Mt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new pi;return n.value=r,n}});function s_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ah=J("$ZodOptional",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>s_(n,s));return s_(n,r)}return t.innerType._zod.run(n,i)}}),Q_=J("$ZodExactOptional",(e,t)=>{Ah.init(e,t),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),e0=J("$ZodNullable",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)}|null)$`):void 0}),tt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),t0=J("$ZodDefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o_(s,t));return o_(r,t)}});function o_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var n0=J("$ZodPrefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),i0=J("$ZodNonOptional",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>a_(s,e));return a_(r,e)}});function a_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function c_(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>di(r,i,Sn()))},input:e.value}),e}var r0=J("$ZodCatch",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>c_(n,s,t,i));return c_(n,r,t,i)}});var s0=J("$ZodPipe",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>n.def.in._zod.values),tt(e,"optin",(n)=>n.def.in._zod.optin),tt(e,"optout",(n)=>n.def.out._zod.optout),tt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>pc(o,t.in,i));return pc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>pc(s,t.out,i));return pc(r,t.out,i)}});function pc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var o0=J("$ZodReadonly",(e,t)=>{Mt.init(e,t),tt(e,"propValues",(n)=>n.def.innerType._zod.propValues),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"optin",(n)=>n.def.innerType?._zod?.optin),tt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(l_);return l_(r)}});function l_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var a0=J("$ZodCustom",(e,t)=>{Xt.init(e,t),Mt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>u_(s,n,i,e));u_(r,n,i,e);return}});function u_(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Dr(r))}}class l0 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ch="~memo",c0=[];function u0(e){return e!==null&&typeof e==="object"}function Rh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var h0=new WeakMap,To=0,bc=1,Ao=2;function Sc(e,t,n){let i=h0.get(e);if(i!==void 0)return i?Ao:To;if(t.has(e))return Ao;t.add(e);let r=To,s=(u)=>{if(r!==Ao&&u?._zod){let f=Sc(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=To;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?bc:g.value?._zod?Sc(g.value,t,n):To;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=bo(c);a(u?o(u,!0):bc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Sc(u,t,!1):bc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),xA(e,r)}function xA(e,t){if(t!==bc)h0.set(e,t===Ao);return t}function yA(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var yc,vc=[],vA={alloc(e,t,n){let i=yc;if(!i)return n;yc=void 0;let r={value:n,issues:null};return i.set(t.value,r),vc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&bA(s,r.value))throw new l0;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=Sc(e,new Set,!1);if(m===To){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Ao||i)n=!0;else i=!0}let u=c.value;if(!u0(u))return o(c,l);let f=l[Ch];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Ch]=f;let h;if(r===l)h=s;else h=yA(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Rh(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}yc=h;let g=vc.length,x=o(c,l);yc=void 0;let p=vc.length>g?vc.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Rh(m.issues):c0;return m});if(p)p.issues=x.issues.length?Rh(x.issues):c0;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function f0(){return vA}function bA(e,t){let n=e[Ch]?.backEdges;return n!==void 0&&u0(t)&&n.has(t)}var SA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=qm(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${ah(s.values[0])}`;return`Invalid option: expected one of ${rh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${rh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ph(){return{localeError:SA()}}var d0;class p0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function MA(){return new p0}(d0=globalThis).__zod_globalRegistry??(d0.__zod_globalRegistry=MA());var Or=globalThis.__zod_globalRegistry;function m0(e){if(e.checks)e.checks=[...e.checks];return e}function g0(e,t){return new e(m0({type:"string",...Ce(t)}))}function _0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function x0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function y0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function v0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function b0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function S0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function M0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function w0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function E0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function T0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function A0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function R0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function C0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function P0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function I0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function L0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function N0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function D0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function O0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function U0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function F0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function z0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function k0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function B0(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function G0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function H0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function V0(e,t){return new e(m0({type:"number",checks:[],...Ce(t)}))}function $0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function W0(e,t){return new e({type:"boolean",...Ce(t)})}function Z0(e){return new e({type:"unknown"})}function X0(e,t){return new e({type:"never",...Ce(t)})}function Mc(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Ro(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!0})}function wc(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function Co(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function Ec(e,t){return new Gg({check:"multiple_of",...Ce(t),value:e})}function Tc(e,t){return new Vg({check:"max_length",...Ce(t),maximum:e})}function As(e,t){return new $g({check:"min_length",...Ce(t),minimum:e})}function Ac(e,t){return new Wg({check:"length_equals",...Ce(t),length:e})}function Ih(e,t){return new Zg({check:"string_format",format:"regex",...Ce(t),pattern:e})}function Lh(e){return new Xg({check:"string_format",format:"lowercase",...Ce(e)})}function Nh(e){return new qg({check:"string_format",format:"uppercase",...Ce(e)})}function Dh(e,t){return new jg({check:"string_format",format:"includes",...Ce(t),includes:e})}function Oh(e,t){return new Yg({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function Uh(e,t){return new Kg({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function lr(e){return new Jg({check:"overwrite",tx:e})}function Fh(e){return lr((t)=>t.normalize(e))}function zh(){return lr((e)=>e.trim())}function kh(){return lr((e)=>e.toLowerCase())}function Bh(){return lr((e)=>e.toUpperCase())}function Gh(){return lr((e)=>Gm(e))}function q0(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function j0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Y0(e,t){let n=wA((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Dr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Dr(s))}},e(i.value,i)),t);return n}function wA(e,t){let n=new Xt({check:"custom",...Ce(t)});return n._zod.check=e,n}function Po(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Nn(e,i,n[i]);return e}function Vh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Or,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;It(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Po(o.schema,c);if(t.io==="input"&&on(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function K0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $h(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${K0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+K0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
4398
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Hs,c=!dn.jitless,u=c&&Ug.value,h=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!h)return f;return $0([],_,f,m,d,e,m?.abortEarly===!0)}return n(f,m)}});function Q_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!Hn(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Mi(o,i,Pn())))}),t}var cd=J("$ZodUnion",(e,t)=>{vt.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Mr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return Q_(o,i,e,r);return Promise.all(o).then((a)=>Q_(a,i,e,r))}});function M1(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Z0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,cd.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Gn(s,l,new Set);for(let h of u)s[l].add(h)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=Wo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=$o(()=>M1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Hs(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),X0=J("$ZodIntersection",(e,t)=>{vt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>e0(n,c,l));return e0(n,s,o)}});function id(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=id(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=id(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function e0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let h;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);h=[d]}else return!1;for(let d of h){if(!i.has(d))i.set(d,{});i.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=id(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var j0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=dn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=t0(n,"optin"),l=t0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),h=t.rest?s?.abortEarly:void 0,d=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,h&&!d&&m.issues.length)d=Hn(m)}if(t.rest&&!d){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(h&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>n0(S,r,f)));else n0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>i0(u,r,n,o,l));return i0(u,r,n,o,l)}});function t0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function n0(e,t,n){if(e.issues.length)t.issues.push(...Si(n,e.issues));t.value[n]=e.value}function i0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...Si(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var q0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((m)=>Mi(m,r,Pn())),input:u,path:[u],inst:e});continue}let d=h.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Si(u,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Si(u,f.issues));i.value[d]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&$s.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>Mi(m,r,Pn())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Si(l,m.issues));i.value[d]=m.value}));else{if(f.issues.length)i.issues.push(...Si(l,f.issues));i.value[d]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Y0=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=Go(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=Go(r.def.entries).filter((o)=>Fg.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>qi(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),J0=J("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?qi(s):s?qi(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var K0=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new wi;return n.value=r,n}});function r0(e,t){return e.value=t.issues.length?void 0:t.value,e}var ld=J("$ZodOptional",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>r0(n,s));return r0(n,r)}return t.innerType._zod.run(n,i)}}),Q0=J("$ZodExactOptional",(e,t)=>{ld.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),ex=J("$ZodNullable",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),tx=J("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>s0(s,t));return s0(r,t)}});function s0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var nx=J("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),ix=J("$ZodNonOptional",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o0(s,e));return o0(r,e)}});function o0(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function a0(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Mi(r,i,Pn()))},input:e.value}),e}var rx=J("$ZodCatch",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>a0(n,s,t,i));return a0(n,r,t,i)}});var sx=J("$ZodPipe",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>$c(o,t.in,i));return $c(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>$c(s,t.out,i));return $c(r,t.out,i)}});function $c(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var ox=J("$ZodReadonly",(e,t)=>{vt.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(c0);return c0(r)}});function c0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function w1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return N_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===$s?Gc:o)?.source}function rd(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=rd(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(rd);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return w1(e)}var ax=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=rd(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||zg.has(typeof i))n.push(qi(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var cx=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>l0(s,n,i,e));l0(r,n,i,e);return}});function l0(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(qr(r))}}class ux extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var hd="~memo",lx=[];function hx(e){return e!==null&&typeof e==="object"}function ud(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var dx=new WeakMap,qo=0,Jc=1,Yo=2;function Kc(e,t,n){let i=dx.get(e);if(i!==void 0)return i?Yo:qo;if(t.has(e))return Yo;t.add(e);let r=qo,s=(u)=>{if(r!==Yo&&u?._zod){let h=Kc(u,t,n);if(h>r)r=h}},o=(u,h)=>{let d=qo;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(h&&!m.enumerable)continue;let _=m.get?Jc:m.value?._zod?Kc(m.value,t,n):qo;if(_>d)d=_}return d},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Wo(c);a(u?o(u,!0):Jc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Kc(u,t,!1):Jc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;let d=h.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),E1(e,r)}function E1(e,t){if(t!==Jc)dx.set(e,t===Yo);return t}function A1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var qc,Yc=[],T1={alloc(e,t,n){let i=qc;if(!i)return n;qc=void 0;let r={value:n,issues:null};return i.set(t.value,r),Yc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&R1(s,r.value))throw new ux;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=Kc(e,new Set,!1);if(g===qo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Yo||i)n=!0;else i=!0}let u=c.value;if(!hx(u))return o(c,l);let h=l[hd];if(!h)h={buckets:new WeakMap,backEdges:void 0},l[hd]=h;let d;if(r===l)d=s;else d=A1(h,e),r=l,s=d;let f=d.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...ud(f.issues))}else c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(f.value);return c}qc=d;let m=Yc.length,_=o(c,l);qc=void 0;let p=Yc.length>m?Yc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?ud(g.issues):lx;return g});if(p)p.issues=_.issues.length?ud(_.issues):lx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function fx(){return T1}function R1(e,t){let n=e[hd]?.backEdges;return n!==void 0&&hx(t)&&n.has(t)}var C1=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Hg(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Hh(s.values[0])}`;return`Invalid option: expected one of ${Bh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Bh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function dd(){return{localeError:C1()}}var px;class mx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function P1(){return new mx}(px=globalThis).__zod_globalRegistry??(px.__zod_globalRegistry=P1());var Yr=globalThis.__zod_globalRegistry;function gx(e){if(e.checks)e.checks=[...e.checks];return e}function _x(e,t){return new e(gx({type:"string",...Ce(t)}))}function xx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function yx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function vx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function wx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function $x(e,t){return new e(gx({type:"number",checks:[],...Ce(t)}))}function Wx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function Zx(e,t){return new e({type:"boolean",...Ce(t)})}function Xx(e){return new e({type:"unknown"})}function jx(e,t){return new e({type:"never",...Ce(t)})}function Qc(e,t){return new ed({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Jo(e,t){return new ed({check:"less_than",...Ce(t),value:e,inclusive:!0})}function el(e,t){return new td({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function Ko(e,t){return new td({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function tl(e,t){return new F_({check:"multiple_of",...Ce(t),value:e})}function nl(e,t){return new k_({check:"max_length",...Ce(t),maximum:e})}function Ws(e,t){return new B_({check:"min_length",...Ce(t),minimum:e})}function il(e,t){return new V_({check:"length_equals",...Ce(t),length:e})}function fd(e,t){return new G_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function pd(e){return new H_({check:"string_format",format:"lowercase",...Ce(e)})}function md(e){return new $_({check:"string_format",format:"uppercase",...Ce(e)})}function gd(e,t){return new W_({check:"string_format",format:"includes",...Ce(t),includes:e})}function _d(e,t){return new Z_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function xd(e,t){return new X_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new j_({check:"overwrite",tx:e})}function yd(e){return wr((t)=>t.normalize(e))}function vd(){return wr((e)=>e.trim())}function bd(){return wr((e)=>e.toLowerCase())}function Sd(){return wr((e)=>e.toUpperCase())}function Md(){return wr((e)=>Og(e))}function qx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function Yx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Jx(e,t){let n=I1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(qr(s))}},e(i.value,i)),t);return n}function I1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function Qo(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Ed(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Yr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Yi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,d,u)}let h=e._zod.parent;if(h){if(!o.ref)o.ref=h;It(h,t,u),t.seen.get(h).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Qo(o.schema,c);if(t.io==="input"&&fn(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Kx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ad(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(o[0])?.id,d=e.external.uri??((m)=>m);if(h)return{ref:d(h)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Kx(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Kx(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
4399
4399
 
4400
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function ex(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;ex(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var tx=new Set(["type","properties","required","additionalProperties"]),J0=["oneOf","anyOf"];function Q0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Hh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!tx.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??Q0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Hh(a)??{allOf:a};Nn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=Q0(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function EA(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of tx)if(r in e)return;let n=t.filter((r)=>J0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Hh(t);else{let r=n[0],s=J0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Hh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Po(e,i)}function Wh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Po(l,g);if(Po(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())ex(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])EA(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Po(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Nn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Io(t,"input",e.processors),output:Io(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function on(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return on(i.element,n);if(i.type==="set")return on(i.valueType,n);if(i.type==="lazy")return on(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return on(i.innerType,n);if(i.type==="intersection")return on(i.left,n)||on(i.right,n);if(i.type==="record"||i.type==="map")return on(i.keyType,n)||on(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return on(i.in,n)||on(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(on(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(on(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(on(r,n))return!0;if(i.rest&&on(i.rest,n))return!0;return!1}return!1}var nx=(e,t={})=>(n)=>{let i=Vh({...n,processors:t});return It(e,i),$h(i,e),Wh(i,e)},Io=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Vh({...r??{},target:s,io:t,processors:n});return It(e,o),$h(o,e),Wh(o,e)};var Rs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Cs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},ix=(e,t)=>{Rs(e,"minimum",t),Cs(e,"maximum",t)},ax=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},cx=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},lx=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},ux=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},rx=(e,t)=>Rs(e,"minimum",t.minimum),sx=(e,t)=>Cs(e,"maximum",t.maximum),ox=(e)=>(t,n)=>{ux(t,n.format);let[i,r]=e[n.format];Rs(t,"minimum",i),Cs(t,"maximum",r)},TA={greater_than:(e,t)=>Rs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Cs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ax(e,t.value),number_format:ox(ic),bigint_format:ox(ch),min_length:rx,max_length:sx,length_equals:(e,t)=>ix(e,t.length),min_size:rx,max_size:sx,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{if(ux(e,t.format),t.pattern)cx(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>lx(e,t.mime)};function Dn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)TA[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Rs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Rs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Cs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Cs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)ax(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)lx(t,r.mime);for(let s of r.patterns??[])cx(t,s);return t}var AA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},RA=new Map([[wh,Cg],[xc,Pg]]),hx=(e)=>RA.get(e)??e,fx=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Dn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=AA[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(hx);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},dx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Dn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else Di(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},px=(e,t,n,i)=>{n.type="boolean"};var mx=(e,t,n,i)=>{n.not={}};var gx=(e,t,n,i)=>{};var _x=(e,t,n,i)=>{let r=e._zod.def,s=xo(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},xx=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var yx=(e,t,n,i)=>{Di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var vx=(e,t,n,i)=>{Di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var bx=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Dn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function Rc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Rc(t.out);if(t.type==="catch")return Rc(t.innerType);return e._zod.optin}var Sx=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Nn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Rc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Mx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},wx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Zh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=Zh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>Zh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?Mo:_h).source;return d}var Xh=new WeakMap;function CA(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Xh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Zh(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Ex=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Dn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)Nn(r.patternProperties,hx(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Xh.get(t);if(!u)u=[],Xh.set(t,u),t.deferred.push(()=>CA(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Rc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Tx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Ax=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},qh=Symbol();function Rx(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),qh}var Cx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n.default=o},Px=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n._prefault=o},Ix=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Lx=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Nx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var jh=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Dx=new WeakSet([Object.prototype,Error.prototype]);function Cc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var FA=(e,t)=>{ng.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Dx.has(n))return;Dx.add(n),Cc(n,"format",(i)=>(r)=>rg(i,r)),Cc(n,"flatten",(i)=>(r)=>ig(i,r)),Cc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,yo,2)}),Cc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,yo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=J("ZodError",FA,void 0,{Parent:Error});var Ox=lc(Mn),Ux=uc(Mn),Fx=hc(Mn),zx=fc(Mn),kx=og(Mn),Bx=ag(Mn),Gx=cg(Mn),Hx=lg(Mn),Vx=ug(Mn),$x=hg(Mn),Wx=fg(Mn),Zx=dg(Mn);function kA(){if(!dn.localeError)Sn(Ph())}function Ic(){if(!dn.memoizer)Sn({memoizer:f0()})}var Et=J("ZodType",(e,t)=>(kA(),Mt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return hi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(U1(e,t))},superRefine(e,t){return this.check(F1(e,t))},overwrite(e){return this.check(lr(e))},optional(){return jx(this)},exactOptional(){return M1(this)},nullable(){return Yx(this)},nullish(){return jx(Yx(this))},nonoptional(e){return C1(this,e)},array(){return an(this)},or(e){return ty([this,e])},and(e){return y1(this,e)},transform(e){return Kx(this,S1(e))},default(e){return T1(this,e)},prefault(e){return R1(this,e)},catch(e){return I1(this,e)},pipe(e){return Kx(this,e)},readonly(){return D1(this)},describe(e){let t=this.clone();return Or.add(t,{description:e}),t},meta(...e){if(e.length===0)return Or.get(this);let t=this.clone();return Or.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ac(this,"~standard",{...Mh(this),jsonSchema:{input:Io(this,"input"),output:Io(this,"output")}})},set "~standard"(e){Ni(this,"~standard",e)},parse:function e(t,n){return Ox(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ux(this,t,n,{callee:e})},safeParse(e,t){return Fx(this,e,t)},async safeParseAsync(e,t){return zx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ni(this,"spa",e)},validate(e,t){return dh(this,e,t)},validateAsync(e,t){return ph(this,e,t)},encode:function e(t,n){return kx(this,t,n,{callee:e})},decode:function e(t,n){return Bx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Hx(this,t,n,{callee:e})},safeEncode(e,t){return Vx(this,e,t)},safeDecode(e,t){return $x(this,e,t)},async safeEncodeAsync(e,t){return Wx(this,e,t)},async safeDecodeAsync(e,t){return Zx(this,e,t)},toJSONSchema(e){return nx(this,{})(e)},get description(){return Or.get(this)?.description},get _def(){return this._zod.def}}),Jx=J("_ZodString",(e,t)=>{_c.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r)},Ym({format:(e)=>Dn(e).format??null,minLength:(e)=>Dn(e).minimum??null,maxLength:(e)=>Dn(e).maximum??null},{regex(...e){return this.check(Ih(...e))},includes(...e){return this.check(Dh(...e))},startsWith(...e){return this.check(Oh(...e))},endsWith(...e){return this.check(Uh(...e))},min(...e){return this.check(As(...e))},max(...e){return this.check(Tc(...e))},length(...e){return this.check(Ac(...e))},nonempty(...e){return this.check(As(1,...e))},lowercase(e){return this.check(Lh(e))},uppercase(e){return this.check(Nh(e))},trim(){return this.check(zh())},normalize(...e){return this.check(Fh(...e))},toLowerCase(){return this.check(kh())},toUpperCase(){return this.check(Bh())},slugify(){return this.check(Gh())}})),BA=J("ZodString",(e,t)=>{_c.init(e,t),Jx.init(e,t)},{email(e){return this.check(_0(WA,e))},url(e){return this.check(M0(XA,e))},jwt(e){return this.check(z0(c1,e))},emoji(e){return this.check(w0(qA,e))},guid(e){return this.check(x0(ZA,e))},uuid(e){return this.check(y0(Pc,e))},uuidv4(e){return this.check(v0(Pc,e))},uuidv6(e){return this.check(b0(Pc,e))},uuidv7(e){return this.check(S0(Pc,e))},nanoid(e){return this.check(E0(jA,e))},cuid(e){return this.check(T0(YA,e))},cuid2(e){return this.check(A0(KA,e))},ulid(e){return this.check(R0(JA,e))},base64(e){return this.check(O0(s1,e))},base64url(e){return this.check(U0(o1,e))},xid(e){return this.check(C0(QA,e))},ksuid(e){return this.check(P0(e1,e))},ipv4(e){return this.check(I0(t1,e))},ipv6(e){return this.check(L0(n1,e))},cidrv4(e){return this.check(N0(i1,e))},cidrv6(e){return this.check(D0(r1,e))},e164(e){return this.check(F0(a1,e))},datetime(e){return this.check(k0(GA,e))},date(e){return this.check(B0(HA,e))},time(e){return this.check(G0(VA,e))},duration(e){return this.check(H0($A,e))}});function Je(e){return g0(BA,e)}var Tt=J("ZodStringFormat",(e,t)=>{bt.init(e,t),Jx.init(e,t)}),GA=J("ZodISODateTime",(e,t)=>{E_.init(e,t),Tt.init(e,t)}),HA=J("ZodISODate",(e,t)=>{T_.init(e,t),Tt.init(e,t)}),VA=J("ZodISOTime",(e,t)=>{A_.init(e,t),Tt.init(e,t)}),$A=J("ZodISODuration",(e,t)=>{R_.init(e,t),Tt.init(e,t)}),WA=J("ZodEmail",(e,t)=>{p_.init(e,t),Tt.init(e,t)});var ZA=J("ZodGUID",(e,t)=>{f_.init(e,t),Tt.init(e,t)});var Pc=J("ZodUUID",(e,t)=>{d_.init(e,t),Tt.init(e,t)});var XA=J("ZodURL",(e,t)=>{__.init(e,t),Tt.init(e,t)});var qA=J("ZodEmoji",(e,t)=>{x_.init(e,t),Tt.init(e,t)});var jA=J("ZodNanoID",(e,t)=>{y_.init(e,t),Tt.init(e,t)});var YA=J("ZodCUID",(e,t)=>{v_.init(e,t),Tt.init(e,t)});var KA=J("ZodCUID2",(e,t)=>{b_.init(e,t),Tt.init(e,t)});var JA=J("ZodULID",(e,t)=>{S_.init(e,t),Tt.init(e,t)});var QA=J("ZodXID",(e,t)=>{M_.init(e,t),Tt.init(e,t)});var e1=J("ZodKSUID",(e,t)=>{w_.init(e,t),Tt.init(e,t)});var t1=J("ZodIPv4",(e,t)=>{C_.init(e,t),Tt.init(e,t)});var n1=J("ZodIPv6",(e,t)=>{I_.init(e,t),Tt.init(e,t)});var i1=J("ZodCIDRv4",(e,t)=>{L_.init(e,t),Tt.init(e,t)});var r1=J("ZodCIDRv6",(e,t)=>{N_.init(e,t),Tt.init(e,t)});var s1=J("ZodBase64",(e,t)=>{O_.init(e,t),Tt.init(e,t)});var o1=J("ZodBase64URL",(e,t)=>{U_.init(e,t),Tt.init(e,t)});var a1=J("ZodE164",(e,t)=>{F_.init(e,t),Tt.init(e,t)});var c1=J("ZodJWT",(e,t)=>{z_.init(e,t),Tt.init(e,t)});var Qx=J("ZodNumber",(e,t)=>{Eh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r),e.isFinite=!0},Ym({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Dn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Dn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Dn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Dn(e).format??null},{gt(e,t){return this.check(wc(e,t))},gte(e,t){return this.check(Co(e,t))},min(e,t){return this.check(Co(e,t))},lt(e,t){return this.check(Mc(e,t))},lte(e,t){return this.check(Ro(e,t))},max(e,t){return this.check(Ro(e,t))},int(e){return this.check(Xx(e))},safe(e){return this.check(Xx(e))},positive(e){return this.check(wc(0,e))},nonnegative(e){return this.check(Co(0,e))},negative(e){return this.check(Mc(0,e))},nonpositive(e){return this.check(Ro(0,e))},multipleOf(e,t){return this.check(Ec(e,t))},step(e,t){return this.check(Ec(e,t))},finite(){return this}}));function pt(e){return V0(Qx,e)}var l1=J("ZodNumberFormat",(e,t)=>{k_.init(e,t),Qx.init(e,t)});function Xx(e){return $0(l1,e)}var u1=J("ZodBoolean",(e,t)=>{B_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function Lo(e){return W0(u1,e)}var h1=J("ZodUnknown",(e,t)=>{G_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gx(e,n,i,r)});function Ur(){return Z0(h1)}var f1=J("ZodNever",(e,t)=>{H_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function d1(e){return X0(f1,e)}var p1=J("ZodArray",(e,t)=>{Ic(),V_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bx(e,n,i,r),e.element=t.element},{min(e,t){return this.check(As(e,t))},nonempty(e){return this.check(As(1,e))},max(e,t){return this.check(Tc(e,t))},length(e,t){return this.check(Ac(e,t))},unwrap(){return this.element}});function an(e,t){return q0(p1,e,t)}var m1=J("ZodObject",(e,t)=>{Ic(),Z_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),XT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return On(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(bn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},loose(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},strict(){return this.clone(bn(this._zod.def,{catchall:d1()}))},strip(){return this.clone(bn(this._zod.def,{catchall:void 0}))},extend(e){return kT(this,e)},safeExtend(e){return BT(this,e)},merge(e){return GT(this,e)},pick(e){return FT(this,e)},omit(e){return zT(this,e)},partial(...e){return Zm(ny,this,e[0])},exactPartial(...e){return Zm(iy,this,e[0],"exactPartial")},required(...e){return HT(ry,this,e[0])}});function ht(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new m1(n)}var ey=J("ZodUnion",(e,t)=>{Th.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r),e.options=t.options});function ty(e,t){return new ey({type:"union",options:e,...Ce(t)})}var g1=J("ZodDiscriminatedUnion",(e,t)=>{ey.init(e,t),X_.init(e,t)});function _1(e,t,n){return new g1({type:"union",options:t,discriminator:e,...Ce(n)})}var x1=J("ZodIntersection",(e,t)=>{q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r)});function y1(e,t){return new x1({type:"intersection",left:e,right:t})}var qx=J("ZodRecord",(e,t)=>{Ic(),j_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Lc(e,t,n){if(!t||!t._zod)return new qx({type:"record",keyType:Je(),valueType:e,...Ce(t)});return new qx({type:"record",keyType:e,valueType:t,...Ce(n)})}var Kh=J("ZodEnum",(e,t)=>{Y_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(i,r,s)=>_x(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})}});function On(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Kh({type:"enum",entries:n,...Ce(t)})}var v1=J("ZodLiteral",(e,t)=>{K_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qt(e,t){return new v1({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var b1=J("ZodTransform",(e,t)=>{Ic(),J_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function S1(e){return new b1({type:"transform",transform:e})}var ny=J("ZodOptional",(e,t)=>{Ah.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new ny({type:"optional",innerType:e})}var iy=J("ZodExactOptional",(e,t)=>{Q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new iy({type:"optional",innerType:e})}var w1=J("ZodNullable",(e,t)=>{e0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Yx(e){return new w1({type:"nullable",innerType:e})}var E1=J("ZodDefault",(e,t)=>{t0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function T1(e,t){return new E1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var A1=J("ZodPrefault",(e,t)=>{n0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function R1(e,t){return new A1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var ry=J("ZodNonOptional",(e,t)=>{i0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ax(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function C1(e,t){return new ry({type:"nonoptional",innerType:e,...Ce(t)})}var P1=J("ZodCatch",(e,t)=>{r0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function I1(e,t){return new P1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Km(t)})}var L1=J("ZodPipe",(e,t)=>{s0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.in=t.in,e.out=t.out});function Kx(e,t){return new L1({type:"pipe",in:e,out:t})}var N1=J("ZodReadonly",(e,t)=>{o0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Nx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function D1(e){return new N1({type:"readonly",innerType:e})}var O1=J("ZodCustom",(e,t)=>{a0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yx(e,n,i,r)});function U1(e,t={}){return j0(O1,e,t)}function F1(e,t){return Y0(e,t)}var oy=["neutral","dark","light"];var Jh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),ay=Object.freeze({neutral:Jh("neutral",[170,177,188]),dark:Jh("dark",[26,26,26]),light:Jh("light",[223,227,232])});var xD=ay.neutral.rgb,yD=ay.neutral.hex;/*!
4400
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function ty(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;ty(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var ny=new Set(["type","properties","required","additionalProperties"]),Qx=["oneOf","anyOf"];function ey(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function wd(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ny.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??ey(l);if(u===null||u===void 0)continue;if(!a.some((h)=>JSON.stringify(h)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:wd(a)??{allOf:a};Gn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=ey(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function L1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ny)if(r in e)return;let n=t.filter((r)=>Qx.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=wd(t);else{let r=n[0],s=Qx.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>wd([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Qo(e,i)}function Td(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},h=c.ref;if(c.ref=null,h){i(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else Qo(l,m);if(Qo(l,u),a._zod.parent===h)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let d=a._zod.parent;if(d&&d!==h){i(d);let f=e.seen.get(d);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())ty(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let h=a.get(u);if(h)h.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])L1(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Qo(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Gn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ea(t,"input",e.processors),output:ea(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return fn(i.element,n);if(i.type==="set")return fn(i.valueType,n);if(i.type==="lazy")return fn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return fn(i.innerType,n);if(i.type==="intersection")return fn(i.left,n)||fn(i.right,n);if(i.type==="record"||i.type==="map")return fn(i.keyType,n)||fn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fn(i.in,n)||fn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(fn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(fn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(fn(r,n))return!0;if(i.rest&&fn(i.rest,n))return!0;return!1}return!1}var iy=(e,t={})=>(n)=>{let i=Ed({...n,processors:t});return It(e,i),Ad(i,e),Td(i,e)},ea=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Ed({...r??{},target:s,io:t,processors:n});return It(e,o),Ad(o,e),Td(o,e)};var Zs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Xs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},ry=(e,t)=>{Zs(e,"minimum",t),Xs(e,"maximum",t)},cy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ly=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},uy=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},hy=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},sy=(e,t)=>Zs(e,"minimum",t.minimum),oy=(e,t)=>Xs(e,"maximum",t.maximum),ay=(e)=>(t,n)=>{hy(t,n.format);let[i,r]=e[n.format];Zs(t,"minimum",i),Xs(t,"maximum",r)},N1={greater_than:(e,t)=>Zs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Xs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>cy(e,t.value),number_format:ay(Lc),bigint_format:ay($h),min_length:sy,max_length:oy,length_equals:(e,t)=>ry(e,t.length),min_size:sy,max_size:oy,size_equals:(e,t)=>ry(e,t.size),string_format:(e,t)=>{if(hy(e,t.format),t.pattern)ly(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>uy(e,t.mime)};function In(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)N1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Zs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Zs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Xs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Xs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)cy(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)uy(t,r.mime);for(let s of r.patterns??[])ly(t,s);return t}var D1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},O1=new Map([[od,w_],[jc,E_]]),dy=(e)=>O1.get(e)??e,fy=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=In(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=D1[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let h=[...c].map(dy);if(h.length===1)r.pattern=h[0].source;else if(h.length>1)r.allOf=[...h.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},py=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=In(e);r.type=u?"integer":"number";let h=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(d)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Yi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},my=(e,t,n,i)=>{n.type="boolean"};var gy=(e,t,n,i)=>{n.not={}};var _y=(e,t,n,i)=>{};var xy=(e,t,n,i)=>{let r=e._zod.def,s=Go(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},yy=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Yi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Yi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var vy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var by=(e,t,n,i)=>{Yi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Sy=(e,t,n,i)=>{Yi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var My=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=In(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function ta(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ta(t.out);if(t.type==="catch")return ta(t.innerType);return e._zod.optin}var wy=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Yi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?ta(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Ey=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Ay=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Ty=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ta(_)!==void 0:_._zod.optout==="optional"))break;u--}let h=s.items.length,d=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,d)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(d)r.maxItems=h}else{if(r.items=c,d)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(d)r.maxItems=h}let{minimum:f,maximum:m}=In(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Rd(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=Rd(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Rd(e,g,n));if(p.some((g,S)=>g!==_[S]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?$s:Gc).source;return f}var Cd=new WeakMap;function U1(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Cd.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Rd(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Ry=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=In(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let h of a)Gn(r.patternProperties,dy(h).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Cd.get(t);if(!u)u=[],Cd.set(t,u),t.deferred.push(()=>U1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ta(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((h)=>typeof h==="string"||typeof h==="number");if(u.length>0)r.required=u.map(String)}},Cy=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Py=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Pd=Symbol();function Iy(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Yi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Pd}var Ly=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Iy(r.defaultValue,e,t,n,i);if(o!==Pd)n.default=o},Ny=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Iy(r.defaultValue,e,t,n,i);if(o!==Pd)n._prefault=o},Dy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Yi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Oy=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Uy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Id=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Fy=new WeakSet([Object.prototype,Error.prototype]);function rl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var $1=(e,t)=>{Jg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Fy.has(n))return;Fy.add(n),rl(n,"format",(i)=>(r)=>Qg(i,r)),rl(n,"flatten",(i)=>(r)=>Kg(i,r)),rl(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Ho,2)}),rl(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Ho,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Ln=J("ZodError",$1,void 0,{Parent:Error});var zy=zc(Ln),ky=kc(Ln),By=Bc(Ln),Vy=Vc(Ln),Gy=t_(Ln),Hy=n_(Ln),$y=i_(Ln),Wy=r_(Ln),Zy=s_(Ln),Xy=o_(Ln),jy=a_(Ln),qy=c_(Ln);function Z1(){if(!dn.localeError)Pn(dd())}function na(){if(!dn.memoizer)Pn({memoizer:fx()})}var Rt=J("ZodType",(e,t)=>(Z1(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Cn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return bi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(WR(e,t))},superRefine(e,t){return this.check(ZR(e,t))},overwrite(e){return this.check(wr(e))},optional(){return Ky(this)},exactOptional(){return PR(this)},nullable(){return Qy(this)},nullish(){return Ky(Qy(this))},nonoptional(e){return UR(this,e)},array(){return _t(this)},or(e){return ia([this,e])},and(e){return ER(this,e)},transform(e){return ev(this,CR(e))},default(e){return NR(this,e)},prefault(e){return OR(this,e)},catch(e){return zR(this,e)},pipe(e){return ev(this,e)},readonly(){return VR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Uc(this,"~standard",{...sd(this),jsonSchema:{input:ea(this,"input"),output:ea(this,"output")}})},set "~standard"(e){ji(this,"~standard",e)},parse:function e(t,n){return zy(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ky(this,t,n,{callee:e})},safeParse(e,t){return By(this,e,t)},async safeParseAsync(e,t){return Vy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ji(this,"spa",e)},validate(e,t){return qh(this,e,t)},validateAsync(e,t){return Yh(this,e,t)},encode:function e(t,n){return Gy(this,t,n,{callee:e})},decode:function e(t,n){return Hy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await $y(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Wy(this,t,n,{callee:e})},safeEncode(e,t){return Zy(this,e,t)},safeDecode(e,t){return Xy(this,e,t)},async safeEncodeAsync(e,t){return jy(this,e,t)},async safeDecodeAsync(e,t){return qy(this,e,t)},toJSONSchema(e){return iy(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),tv=J("_ZodString",(e,t)=>{Xc.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fy(e,n,i,r)},Wg({format:(e)=>In(e).format??null,minLength:(e)=>In(e).minimum??null,maxLength:(e)=>In(e).maximum??null},{regex(...e){return this.check(fd(...e))},includes(...e){return this.check(gd(...e))},startsWith(...e){return this.check(_d(...e))},endsWith(...e){return this.check(xd(...e))},min(...e){return this.check(Ws(...e))},max(...e){return this.check(nl(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(Ws(1,...e))},lowercase(e){return this.check(pd(e))},uppercase(e){return this.check(md(e))},trim(){return this.check(vd())},normalize(...e){return this.check(yd(...e))},toLowerCase(){return this.check(bd())},toUpperCase(){return this.check(Sd())},slugify(){return this.check(Md())}})),X1=J("ZodString",(e,t)=>{Xc.init(e,t),tv.init(e,t)},{email(e){return this.check(xx(K1,e))},url(e){return this.check(wx(eR,e))},jwt(e){return this.check(kx(mR,e))},emoji(e){return this.check(Ex(tR,e))},guid(e){return this.check(yx(Q1,e))},uuid(e){return this.check(vx(sl,e))},uuidv4(e){return this.check(bx(sl,e))},uuidv6(e){return this.check(Sx(sl,e))},uuidv7(e){return this.check(Mx(sl,e))},nanoid(e){return this.check(Ax(nR,e))},cuid(e){return this.check(Tx(iR,e))},cuid2(e){return this.check(Rx(rR,e))},ulid(e){return this.check(Cx(sR,e))},base64(e){return this.check(Ux(dR,e))},base64url(e){return this.check(Fx(fR,e))},xid(e){return this.check(Px(oR,e))},ksuid(e){return this.check(Ix(aR,e))},ipv4(e){return this.check(Lx(cR,e))},ipv6(e){return this.check(Nx(lR,e))},cidrv4(e){return this.check(Dx(uR,e))},cidrv6(e){return this.check(Ox(hR,e))},e164(e){return this.check(zx(pR,e))},datetime(e){return this.check(Bx(j1,e))},date(e){return this.check(Vx(q1,e))},time(e){return this.check(Gx(Y1,e))},duration(e){return this.check(Hx(J1,e))}});function Xe(e){return _x(X1,e)}var Lt=J("ZodStringFormat",(e,t)=>{Tt.init(e,t),tv.init(e,t)}),j1=J("ZodISODateTime",(e,t)=>{w0.init(e,t),Lt.init(e,t)}),q1=J("ZodISODate",(e,t)=>{E0.init(e,t),Lt.init(e,t)}),Y1=J("ZodISOTime",(e,t)=>{A0.init(e,t),Lt.init(e,t)}),J1=J("ZodISODuration",(e,t)=>{T0.init(e,t),Lt.init(e,t)}),K1=J("ZodEmail",(e,t)=>{f0.init(e,t),Lt.init(e,t)});var Q1=J("ZodGUID",(e,t)=>{h0.init(e,t),Lt.init(e,t)});var sl=J("ZodUUID",(e,t)=>{d0.init(e,t),Lt.init(e,t)});var eR=J("ZodURL",(e,t)=>{g0.init(e,t),Lt.init(e,t)});var tR=J("ZodEmoji",(e,t)=>{_0.init(e,t),Lt.init(e,t)});var nR=J("ZodNanoID",(e,t)=>{x0.init(e,t),Lt.init(e,t)});var iR=J("ZodCUID",(e,t)=>{y0.init(e,t),Lt.init(e,t)});var rR=J("ZodCUID2",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var sR=J("ZodULID",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var oR=J("ZodXID",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var aR=J("ZodKSUID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var cR=J("ZodIPv4",(e,t)=>{R0.init(e,t),Lt.init(e,t)});var lR=J("ZodIPv6",(e,t)=>{P0.init(e,t),Lt.init(e,t)});var uR=J("ZodCIDRv4",(e,t)=>{I0.init(e,t),Lt.init(e,t)});var hR=J("ZodCIDRv6",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var dR=J("ZodBase64",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var fR=J("ZodBase64URL",(e,t)=>{O0.init(e,t),Lt.init(e,t)});var pR=J("ZodE164",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var mR=J("ZodJWT",(e,t)=>{F0.init(e,t),Lt.init(e,t)});var nv=J("ZodNumber",(e,t)=>{ad.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>py(e,n,i,r),e.isFinite=!0},Wg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=In(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=In(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=In(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>In(e).format??null},{gt(e,t){return this.check(el(e,t))},gte(e,t){return this.check(Ko(e,t))},min(e,t){return this.check(Ko(e,t))},lt(e,t){return this.check(Qc(e,t))},lte(e,t){return this.check(Jo(e,t))},max(e,t){return this.check(Jo(e,t))},int(e){return this.check(Yy(e))},safe(e){return this.check(Yy(e))},positive(e){return this.check(el(0,e))},nonnegative(e){return this.check(Ko(0,e))},negative(e){return this.check(Qc(0,e))},nonpositive(e){return this.check(Jo(0,e))},multipleOf(e,t){return this.check(tl(e,t))},step(e,t){return this.check(tl(e,t))},finite(){return this}}));function et(e){return $x(nv,e)}var gR=J("ZodNumberFormat",(e,t)=>{z0.init(e,t),nv.init(e,t)});function Yy(e){return Wx(gR,e)}var _R=J("ZodBoolean",(e,t)=>{k0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>my(e,n,i,r)});function Kr(e){return Zx(_R,e)}var xR=J("ZodUnknown",(e,t)=>{B0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)});function Jr(){return Xx(xR)}var yR=J("ZodNever",(e,t)=>{V0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gy(e,n,i,r)});function vR(e){return jx(yR,e)}var bR=J("ZodArray",(e,t)=>{na(),G0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ws(e,t))},nonempty(e){return this.check(Ws(1,e))},max(e,t){return this.check(nl(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function _t(e,t){return qx(bR,e,t)}var SR=J("ZodObject",(e,t)=>{na(),W0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r),QT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Cn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Cn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Cn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Cn(this._zod.def,{catchall:vR()}))},strip(){return this.clone(Cn(this._zod.def,{catchall:void 0}))},extend(e){return WT(this,e)},safeExtend(e){return ZT(this,e)},merge(e){return XT(this,e)},pick(e){return HT(this,e)},omit(e){return $T(this,e)},partial(...e){return Vg(Dd,this,e[0])},exactPartial(...e){return Vg(sv,this,e[0],"exactPartial")},required(...e){return jT(ov,this,e[0])}});function we(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new SR(n)}var iv=J("ZodUnion",(e,t)=>{cd.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r),e.options=t.options});function ia(e,t){return new iv({type:"union",options:e,...Ce(t)})}var MR=J("ZodDiscriminatedUnion",(e,t)=>{iv.init(e,t),Z0.init(e,t)});function ii(e,t,n){return new MR({type:"union",options:t,discriminator:e,...Ce(n)})}var wR=J("ZodIntersection",(e,t)=>{X0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r)});function ER(e,t){return new wR({type:"intersection",left:e,right:t})}var AR=J("ZodTuple",(e,t)=>{na(),j0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Dd({type:"optional",innerType:t}))})}});function rv(e,t,n){let i=t instanceof vt,r=i?n:t;return new AR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var Jy=J("ZodRecord",(e,t)=>{na(),q0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ol(e,t,n){if(!t||!t._zod)return new Jy({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new Jy({type:"record",keyType:e,valueType:t,...Ce(n)})}var Nd=J("ZodEnum",(e,t)=>{Y0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>xy(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Nd({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Nd({...t,checks:[],...Ce(r),entries:s})}});function Ct(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Nd({type:"enum",entries:n,...Ce(t)})}var TR=J("ZodLiteral",(e,t)=>{J0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Fe(e,t){return new TR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var RR=J("ZodTransform",(e,t)=>{na(),K0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sy(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(qr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function CR(e){return new RR({type:"transform",transform:e})}var Dd=J("ZodOptional",(e,t)=>{ld.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Id(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Ky(e){return new Dd({type:"optional",innerType:e})}var sv=J("ZodExactOptional",(e,t)=>{Q0.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Id(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function PR(e){return new sv({type:"optional",innerType:e})}var IR=J("ZodNullable",(e,t)=>{ex.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Qy(e){return new IR({type:"nullable",innerType:e})}var LR=J("ZodDefault",(e,t)=>{tx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function NR(e,t){return new LR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Gh(t)}})}var DR=J("ZodPrefault",(e,t)=>{nx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ny(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function OR(e,t){return new DR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Gh(t)}})}var ov=J("ZodNonOptional",(e,t)=>{ix.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function UR(e,t){return new ov({type:"nonoptional",innerType:e,...Ce(t)})}var FR=J("ZodCatch",(e,t)=>{rx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zR(e,t){return new FR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Zg(t)})}var kR=J("ZodPipe",(e,t)=>{sx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Oy(e,n,i,r),e.in=t.in,e.out=t.out});function ev(e,t){return new kR({type:"pipe",in:e,out:t})}var BR=J("ZodReadonly",(e,t)=>{ox.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function VR(e){return new BR({type:"readonly",innerType:e})}var GR=J("ZodTemplateLiteral",(e,t)=>{ax.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vy(e,n,i,r)});function HR(e,t){return new GR({type:"template_literal",parts:e,...Ce(t)})}var $R=J("ZodCustom",(e,t)=>{cx.init(e,t),Rt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(e,n,i,r)});function WR(e,t={}){return Yx($R,e,t)}function ZR(e,t){return Jx(e,t)}var av=["neutral","dark","light"];var Ud=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),cv=Object.freeze({neutral:Ud("neutral",[170,177,188]),dark:Ud("dark",[26,26,26]),light:Ud("light",[223,227,232])});var GD=cv.neutral.rgb,HD=cv.neutral.hex;/*!
4401
4401
  fflate - fast JavaScript compression/decompression
4402
4402
  <https://101arrowz.github.io/fflate>
4403
4403
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
4404
4404
  version 0.8.2
4405
- */var Rt=Uint8Array,wn=Uint16Array,cf=Int32Array,Nc=new Rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Dc=new Rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nf=new Rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),py=function(e,t){var n=new wn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new cf(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},my=py(Nc,2),{b:gy,r:rf}=my;gy[28]=258,rf[258]=28;var _y=py(Dc,0),{b:z1,r:cy}=_y,sf=new wn(32768);for(je=0;je<32768;++je)mi=(je&43690)>>1|(je&21845)<<1,mi=(mi&52428)>>2|(mi&13107)<<2,mi=(mi&61680)>>4|(mi&3855)<<4,sf[je]=((mi&65280)>>8|(mi&255)<<8)>>1;var mi,je,gi=function(e,t,n){var i=e.length,r=0,s=new wn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new wn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new wn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[sf[f]>>c]=l}}else{a=new wn(i);for(r=0;r<i;++r)if(e[r])a[r]=sf[o[e[r]-1]++]>>15-e[r]}return a},ur=new Rt(288);for(je=0;je<144;++je)ur[je]=8;var je;for(je=144;je<256;++je)ur[je]=9;var je;for(je=256;je<280;++je)ur[je]=7;var je;for(je=280;je<288;++je)ur[je]=8;var je,Oo=new Rt(32);for(je=0;je<32;++je)Oo[je]=5;var je,k1=gi(ur,9,0),B1=gi(ur,9,1),G1=gi(Oo,5,0),H1=gi(Oo,5,1),Qh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Xn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},ef=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},lf=function(e){return(e+7)/8|0},uf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Rt(e.subarray(t,n))};var V1=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Un=function(e,t,n){var i=Error(t||V1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Un);if(!n)throw i;return i},$1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Rt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Rt(r*3);var l=function(Ee){var xt=n.length;if(Ee>xt){var ke=new Rt(Math.max(xt*2,Ee));ke.set(n),n=ke}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Xn(e,f,1);var E=Xn(e,f+1,3);if(f+=3,!E){var R=lf(f)+4,v=e[R-4]|e[R-3]<<8,M=R+v;if(M>r){if(c)Un(0);break}if(a)l(h+v);n.set(e.subarray(R,M),h),t.b=h+=v,t.p=f=M*8,t.f=u;continue}else if(E==1)d=B1,g=H1,x=9,p=5;else if(E==2){var T=Xn(e,f,31)+257,A=Xn(e,f+10,15)+4,_=T+Xn(e,f+5,31)+1;f+=14;var S=new Rt(_),z=new Rt(19);for(var P=0;P<A;++P)z[nf[P]]=Xn(e,f+P*3,7);f+=A*3;var F=Qh(z),ee=(1<<F)-1,I=gi(z,F,1);for(var P=0;P<_;){var H=I[Xn(e,f,ee)];f+=H&15;var R=H>>4;if(R<16)S[P++]=R;else{var q=0,C=0;if(R==16)C=3+Xn(e,f,3),f+=2,q=S[P-1];else if(R==17)C=3+Xn(e,f,7),f+=3;else if(R==18)C=11+Xn(e,f,127),f+=7;while(C--)S[P++]=q}}var X=S.subarray(0,T),k=S.subarray(T);x=Qh(X),p=Qh(k),d=gi(X,x,1),g=gi(k,p,1)}else Un(1);if(f>m){if(c)Un(0);break}}if(a)l(h+131072);var Y=(1<<x)-1,Q=(1<<p)-1,Se=f;for(;;Se=f){var q=d[ef(e,f)&Y],ue=q>>4;if(f+=q&15,f>m){if(c)Un(0);break}if(!q)Un(2);if(ue<256)n[h++]=ue;else if(ue==256){Se=f,d=null;break}else{var Fe=ue-254;if(ue>264){var P=ue-257,Me=Nc[P];Fe=Xn(e,f,(1<<Me)-1)+gy[P],f+=Me}var Z=g[ef(e,f)&Q],re=Z>>4;if(!Z)Un(3);f+=Z&15;var k=z1[re];if(re>3){var Me=Dc[re];k+=ef(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)Un(0);break}if(a)l(h+131072);var se=h+Fe;if(h<k){var xe=s-k,we=Math.min(k,se);if(xe+h<0)Un(3);for(;h<we;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=d,t.p=Se,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?uf(n,0,h):n.subarray(0,h)},Oi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},No=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},tf=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:yy,l:0};if(r==1){var o=new Rt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(M,T){return M.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new wn(h+1),g=of(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var v=s[i].s;if(d[v]==t)--d[v],++x}g=t}return{t:new Rt(d),l:g}},of=function(e,t,n){return e.s==-1?Math.max(of(e.l,t,n+1),of(e.r,t,n+1)):t[e.s]=n},ly=function(e){var t=e.length;while(t&&!e[--t]);var n=new wn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},Do=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},xy=function(e,t,n){var i=n.length,r=lf(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},uy=function(e,t,n,i,r,s,o,a,c,l,u){Oi(t,u++,n),++r[256];var f=tf(r,15),{t:h,l:d}=f,g=tf(s,15),{t:x,l:p}=g,m=ly(h),{c:E,n:R}=m,v=ly(x),{c:M,n:T}=v,A=new wn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<M.length;++_)++A[M[_]&31];var S=tf(A,7),{t:z,l:P}=S,F=19;for(;F>4&&!z[nf[F-1]];--F);var ee=l+5<<3,I=Do(r,ur)+Do(s,Oo)+o,H=Do(r,h)+Do(s,x)+o+14+3*F+Do(A,z)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&ee<=I&&ee<=H)return xy(t,u,e.subarray(c,c+l));var q,C,X,k;if(Oi(t,u,1+(H<I)),u+=2,H<I){q=gi(h,d,0),C=h,X=gi(x,p,0),k=x;var Y=gi(z,P,0);Oi(t,u,R-257),Oi(t,u+5,T-1),Oi(t,u+10,F-4),u+=14;for(var _=0;_<F;++_)Oi(t,u+3*_,z[nf[_]]);u+=3*F;var Q=[E,M];for(var Se=0;Se<2;++Se){var ue=Q[Se];for(var _=0;_<ue.length;++_){var Fe=ue[_]&31;if(Oi(t,u,Y[Fe]),u+=z[Fe],Fe>15)Oi(t,u,ue[_]>>5&127),u+=ue[_]>>12}}}else q=k1,C=ur,X=G1,k=Oo;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var Fe=Me>>18&31;if(No(t,u,q[Fe+257]),u+=C[Fe+257],Fe>7)Oi(t,u,Me>>23&31),u+=Nc[Fe];var Z=Me&31;if(No(t,u,X[Z]),u+=k[Z],Z>3)No(t,u,Me>>5&8191),u+=Dc[Z]}else No(t,u,q[Me]),u+=C[Me]}return No(t,u,q[256]),u+C[256]},W1=new cf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),yy=new Rt(0),Z1=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Rt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=W1[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new wn(32768),p=s.h||new wn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},v=new cf(25000),M=new wn(288),T=new wn(32),A=0,_=0,S=s.i||0,z=0,P=s.w||0,F=0;for(;S+2<o;++S){var ee=R(S),I=S&32767,H=p[ee];if(x[I]=H,p[ee]=I,P<=S){var q=o-S;if((A>7000||z>24576)&&(q>423||!l)){u=uy(e,c,0,v,M,T,_,z,F,S-F,u),z=A=_=0,F=S;for(var C=0;C<286;++C)M[C]=0;for(var C=0;C<30;++C)T[C]=0}var X=2,k=0,Y=d,Q=I-H&32767;if(q>2&&ee==R(S-Q)){var Se=Math.min(h,q)-1,ue=Math.min(32767,S),Fe=Math.min(258,q);while(Q<=ue&&--Y&&I!=H){if(e[S+X]==e[S+X-Q]){var Me=0;for(;Me<Fe&&e[S+Me]==e[S+Me-Q];++Me);if(Me>X){if(X=Me,k=Q,Me>Se)break;var Z=Math.min(Q,Me-2),re=0;for(var C=0;C<Z;++C){var se=S-Q+C&32767,xe=x[se],we=se-xe&32767;if(we>re)re=we,H=se}}}I=H,H=x[I],Q+=I-H&32767}}if(k){v[z++]=268435456|rf[X]<<18|cy[k];var Ee=rf[X]&31,xt=cy[k]&31;_+=Nc[Ee]+Dc[xt],++M[257+Ee],++T[xt],P=S+X,++A}else v[z++]=e[S],++M[e[S]]}}for(S=Math.max(S,P);S<o;++S)v[z++]=e[S],++M[e[S]];if(u=uy(e,c,l,v,M,T,_,z,F,S-F,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=S,s.w=P}else{for(var S=s.w||0;S<o+l;S+=65535){var ke=S+65535;if(ke>=o)c[u/8|0]=l,ke=o;u=xy(c,u+1,e.subarray(S,ke))}s.i=o}return uf(a,0,i+lf(u)+r)},X1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),q1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=X1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var j1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Rt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return Z1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},vy=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var jt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function by(e,t){return j1(e,t||{},0,0)}function Sy(e,t){return $1(e,{i:2},t&&t.out,t&&t.dictionary)}var My=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=vy(i,s[1]),s=s[0];if(s instanceof Rt)n[o]=[s,a];else n[o+="/"]=[new Rt(0),a],My(s,o,n,i)}},hy=typeof TextEncoder<"u"&&new TextEncoder,Y1=typeof TextDecoder<"u"&&new TextDecoder,K1=0;try{Y1.decode(yy,{stream:!0}),K1=1}catch(e){}function fy(e,t){if(t){var n=new Rt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(hy)return hy.encode(e);var r=e.length,s=new Rt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Rt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return uf(s,0,o)}var af=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Un(9);t+=i+4}return t},dy=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=af(l);if(jt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)Un(10);if(jt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)jt(e,t,n.crc),jt(e,t+4,s<0?-s-2:s),jt(e,t+8,n.size);if(jt(e,t+12,c),jt(e,t+14,f),t+=16,o!=null)jt(e,t,u),jt(e,t+6,n.attrs),jt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;jt(e,t,+g),jt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},J1=function(e,t,n,i,r){jt(e,t,101010256),jt(e,t+8,n),jt(e,t+10,n),jt(e,t+12,i),jt(e,t+16,r)};function wy(e,t){if(!t)t={};var n={},i=[];My(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=fy(o),h=f.length,d=l.comment,g=d&&fy(d),x=g&&g.length,p=af(l.extra);if(h>65535)Un(11);var m=u?by(c,l):c,E=m.length,R=q1();R.p(c),i.push(vy(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var v=new Rt(s+22),M=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];dy(v,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+af(f.extra);v.set(f.c,f.o+_),dy(v,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return J1(v,r,i.length,T,M),v}var hf=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function Q1(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class ff extends Error{diagnostic;constructor(e,t=Q1(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var Ey=1024,Ty=4,Ay=8,eR=6,Ry=80,Uo=256;class St extends ff{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Cy=["solid","checker","stripes","gradient","bricks","noise"],Py=["normal","multiply","screen","overlay"],tR=new Set(["__proto__","prototype","constructor"]);function Oc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new St(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new St(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new St(`${t} must not contain symbol keys.`);if(tR.has(i))throw new St(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new St(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new St(`${t}.${i} must be a plain JSON data field.`)}return e}function nR(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new St(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new St(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new St(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new St(`${t} must be a dense JSON array (missing index ${n}).`);return e}function hr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new St(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function qn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new St(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Fr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new St(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Ly(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new St(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function df(e,t,n){return Ly(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function iR(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Ry||n)throw new St(`${t} must be 1..${Ry} visible characters.`);return e}function rR(e,t,n){if(e===void 0)return n;if(!hf.includes(e))throw new St(`${t} must be one of ${hf.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Iy(e,t){let i=(Ly(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function sR(e,t){let n=e.blend??"normal";if(!Py.includes(n))throw new St(`${t}.blend ${JSON.stringify(n)} is not one of ${Py.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function oR(e,t){let n=`proceduralTexture.layers[${t}]`,i=Oc(e,n),r=i.op;if(!Cy.includes(r))throw new St(`${n}.op ${JSON.stringify(r)} is not one of ${Cy.join(", ")}.`);let s=sR(i,n),o=df(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return hr(i,["op","color","blend","opacity"],n),{op:r,color:qn(i.color,`${n}.color`),...a};case"checker":return hr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),squares:Fr(i.squares,`${n}.squares`,8,1,Uo),...a};case"stripes":return hr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),count:Fr(i.count,`${n}.count`,8,1,Uo),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return hr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:qn(i.from,`${n}.from`),to:qn(i.to,`${n}.to`),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return hr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:qn(i.brick,`${n}.brick`),mortar:qn(i.mortar,`${n}.mortar`),rows:Fr(i.rows,`${n}.rows`,8,1,Uo),cols:Fr(i.cols,`${n}.cols`,4,1,Uo),mortarWidth:df(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:df(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return hr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),scale:Fr(i.scale,`${n}.scale`,8,1,Uo),octaves:Fr(i.octaves,`${n}.octaves`,3,1,eR),seed:Fr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new St(`${n}.op is unsupported.`)}}function aR(e){let t=Oc(e,"proceduralTexture");if(hr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new St(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Ny(e){let t=Oc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Oc(aR(t),"proceduralTexture"):t;if(hr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new St(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Ty||i>Ey||(i&i-1)!==0)throw new St(`proceduralTexture.size must be a power of two between ${Ty} and ${Ey}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new St("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=nR(r,"proceduralTexture.layers");if(s.length>Ay)throw new St(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Ay}.`);let o=iR(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:rR(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(oR)}}var TD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var Yn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Oy=["baseColor","normal","metallicRoughness","emissive","occlusion"],cR={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var zo=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),ko=Je().regex(/^sha256:[a-f0-9]{64}$/),fr=Je().min(1).max(1000),Dy=Je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Uy=ht({id:zo,kind:On(["external","procedural"]),provider:fr,creator:fr,assetId:fr.optional(),assetUrl:Dy.optional(),accessedAt:Je().datetime().optional(),license:ht({spdx:fr,url:Dy,attribution:Je().max(4000)}).strict(),originalFiles:an(ht({name:Je().min(1).max(200),sha256:ko,bytes:pt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Fy=ht({operation:fr,tool:fr,version:fr,parameters:Lc(Je().max(100),ty([Je().max(2000),pt().finite(),Lo()])).optional()}).strict(),jn=pt().int().min(0).max(16777215),Fo=pt().int().min(1).max(256),Ps={blend:On(["normal","multiply","screen","overlay"]).default("normal"),opacity:pt().min(0).max(1).default(1)},zy=ht({schemaVersion:qt(2),size:pt().int().min(4).max(1024).default(256),usage:On(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Je().min(1).max(80).optional(),layers:an(_1("op",[ht({op:qt("solid"),color:jn,...Ps}).strict(),ht({op:qt("checker"),colorA:jn,colorB:jn,squares:Fo.default(8),...Ps}).strict(),ht({op:qt("stripes"),colorA:jn,colorB:jn,count:Fo.default(8),angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("gradient"),from:jn,to:jn,angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("bricks"),brick:jn,mortar:jn,rows:Fo.default(8),cols:Fo.default(4),mortarWidth:pt().min(0).max(1).default(0.06),stagger:pt().min(0).max(1).default(0.5),...Ps}).strict(),ht({op:qt("noise"),colorA:jn,colorB:jn,scale:Fo.default(8),octaves:pt().int().min(1).max(6).default(3),seed:pt().int().min(-2147483648).max(2147483647).default(0),...Ps}).strict()])).min(1).max(8)}).strict(),ky=ht({kind:qt("normal-from-height"),strength:pt().finite().positive().max(64)}).strict(),lR=ht({compiler:qt("kiln.procedural-texture.v2"),spec:zy,derive:ky.optional(),recipeHash:ko,pixelHash:ko,encoder:ht({name:qt("sharp"),version:fr}).strict()}).strict(),By=ht({baseColor:pt().int().min(0).max(16777215).optional(),roughness:pt().min(0).max(1).default(1),metalness:pt().min(0).max(1).default(0),emissive:pt().int().min(0).max(16777215).optional(),emissiveIntensity:pt().min(0).max(64).default(1),alphaMode:On(["opaque","mask","blend"]).default("opaque"),alphaCutoff:pt().min(0).max(1).default(0.5),doubleSided:Lo().default(!1)}).strict(),Gy=ht({schemaVersion:qt(1),materialId:zo,revisionId:ko,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By,sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),file:On(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:ko,bytes:pt().int().positive().max(Yn.maxMapBytes),width:pt().int().positive().max(Yn.maxMapEdge),height:pt().int().positive().max(Yn.maxMapEdge),usage:On(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:On(["srgb","linear"]),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:zo,originalFile:Je().min(1).max(200).optional(),transforms:an(Fy).max(30),procedural:lR.optional()}).strict()).min(1).max(5)}).strict(),PD=ht({materialId:zo,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30).optional(),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By.partial().optional(),sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),sourceId:zo,transforms:an(Fy).max(30),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),procedural:zy,derive:ky.optional()}).strict()).min(1).max(5)}).strict(),Hy=ht({schemaVersion:qt(1),records:an(ht({manifest:Gy,files:Lc(Je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Je().max(Math.ceil(Yn.maxMapBytes/3)*4))}).strict()).max(Yn.maxPayloadRecords)}).strict();function Go(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Go(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Bo(e){Go(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function Vy(e){if(Go(e),new TextEncoder().encode(JSON.stringify(e)).length>Yn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=Gy.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==cR[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Bo(r.procedural.spec)!==Bo(Ny(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>Yn.maxRecordBytes||i>Yn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Uc=67108864,pf=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),uR=Je().regex(/^sha256:[a-f0-9]{64}$/),mf=ht({version:qt("kiln.asset.v1"),assetId:pf,revisionId:pf,parentRevision:pf.optional(),name:Je().min(1).max(200),tags:an(Je().max(80)).max(30),createdAt:Je().datetime(),description:Je().max(4000).optional(),brief:Je().max(8000).optional(),attribution:ht({model:Je().max(200).optional(),harness:Je().max(200).optional(),author:Je().max(200).optional()}).optional(),editable:Lo(),files:Lc(Je(),ht({sha256:uR,bytes:pt().int().nonnegative().max(Uc)})),build:ht({engine:Je(),options:Lc(Je(),Ur()),warnings:an(Je()),integration:Ur().optional(),qa:Ur().optional(),dependencies:an(Ur()).optional(),rebuild:On(["engine-required","external-dependencies-required"])}).optional(),preview:ht({fidelity:Ur().optional(),error:Je().optional(),backdrop:On(oy).optional()}).optional()}),hR="materials.kiln.json",fR=25165824;function $y(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=Vy(c.manifest);return[`${l.materialId}/${l.revisionId}`,Bo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Go(e.materialResources);let r=Hy.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Bo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>Yn.maxPayloadBytes||o>Yn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var dR=new Set(["asset.glb","source.kiln.js","preview.png"]);function pR(e){let t=mf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!dR.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Uc||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");gf(e.files["asset.glb"]),$y(e)}function gf(e){if(e.length<20||e.length>Uc)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Wy(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){pR(i),$y(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>fR)throw Error("Asset material payload exceeds byte limit");t[r+hR]=s}}for(let i of Object.values(t))n+=i.length;if(n>Uc)throw Error("Bundle exceeds 64 MiB");return wy(t,{level:0})}function _i(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof At)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Zy(e){gf(e);let t=new oo,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new _s(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new th(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)_i(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Xy(e,t,n=40,i=[e]){let r=e.getCenter(new O),s=Math.max(e.getSize(new O).length()/2,0.01),o=new O(1,0.65,1.25).normalize(),a=new O().crossVectors(new O(0,1,0),o).normalize(),c=new O().crossVectors(o,a),l=[];for(let E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let v of[E.min.y,E.max.y])for(let M of[E.min.z,E.max.z])l.push(new O(R,v,M));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),v=R.dot(a),M=R.dot(c);u=Math.min(u,v),f=Math.max(f,v),h=Math.min(h,M),d=Math.max(d,M)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),v=R.dot(o);p=Math.max(p,v+Math.abs(R.dot(a))*1.12/x,v+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function _f(e,t){return{position:e.position.clone(),target:t.clone()}}function xf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new O).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new O))+r*20,10),e.updateProjectionMatrix()}function qy(e,t,n){let i=e.getWorldDirection(new O);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new O(0,1,0)),s=new O;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function jy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function Yy(e,t,n){if(t())return e;n(e);return}function Fc(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function zc(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Ft().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Ft,i=new Ft,r=new O;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Ft().setFromObject(e,!0):n}function Ho(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Ky(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((g)=>!Number.isInteger(g)||!t[g]||n.has(g)))continue;let f=l.parent;while(f&&!i.has(f))f=f.parent;if(f)continue;let h=[l];for(let g of u)h.push(await e.parser.getDependency("node",g));Fc(e,h.slice(1)),i.add(l);let d=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:d,levels:h})}if(r.length===0)return;let s=Ho(e.scene)-r.reduce((c,l)=>c+yf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,f)=>u+yf(f,l),0));return{chains:r,triangles:a}}var Jy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function yf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Ho(Jy(e,t))}function Qy(e,t){let n=Jy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function ev(e,t){for(let n of e.chains)Qy(n,t)}function tv(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Qy(i,n),!0}function nv(e,t){if(!e)return;return{triangles:Ho(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>yf(n,r))}))}}function Is(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function iv(e){let t=new Vu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Ws,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new ds,i=new Ut(40,1,0.01,1000),r=new Zu(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(C)=>{if(!o||!c.has(C.code))return;C.preventDefault(),s.add(C.code)},u=(C)=>s.delete(C.code),f=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",f);let h=new mo(t),d=new Xu,g=h.fromScene(d,0.04);n.environment=g.texture,d.dispose(),h.dispose();let x=new vs(16773591,2.4);x.position.set(4,8,5),n.add(x),n.add(new Wa(14806490,5065021,1.7));let p,m,E,R=[],v=!0,M=performance.now(),T=0,A=0,_=!1,S,z,P,F=(C)=>{if(!P)return;clearTimeout(P.timeout),P.reject(Error(C)),P=void 0},ee=(C)=>{let X=t.getContext(),k=X.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:C-P.started,frameMs:jy(P.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(X.getParameter(X.VERSION)),vendor:String(X.getParameter(X.VENDOR)),renderer:String(X.getParameter(X.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(X.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(X.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let C=zc(p),X=[];p.traverseVisible((ue)=>{if(ue instanceof _t||ue instanceof Ji||ue instanceof gs){let Fe=new Ft().setFromObject(ue,!0);if(!Fe.isEmpty())X.push(Fe)}});let{center:k,radius:Y,distance:Q,position:Se}=Xy(C,i.aspect,i.fov,X);if(r.target.copy(k),i.position.copy(Se),i.near=Math.max(Y/1000,0.0001),i.far=Q+Y*100,r.minDistance=Y*0.1,r.maxDistance=Y*80,a=Math.max(Y*0.35,0.01),o)r.minDistance=Y*0.00001;i.updateProjectionMatrix(),r.update()},H=new ResizeObserver(()=>{let{clientWidth:C,clientHeight:X}=e;if(!C||!X)return;t.setSize(C,X),i.aspect=C/X,i.updateProjectionMatrix()});H.observe(e);let q=(C)=>{if(_)return;let X=Math.min((C-M)/1000,0.1);if(M=C,e.clientWidth&&e.clientHeight){if(v)E?.update(X);if(o&&s.size){let k=qy(i,s,X*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),S!==void 0)z=performance.now()-S,S=void 0;if(P){if(P.previous>0&&P.samples.length<1800)P.samples.push(C-P.previous);if(P.previous=C,C-P.started>=P.duration&&P.samples.length){let k=ee(C);clearTimeout(P.timeout),P.resolve(k),P=void 0}}}else s.clear(),F("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(q)};return T=requestAnimationFrame(q),{async load(C,X={}){let k=performance.now(),Y=++A;F("The artifact changed during measurement. Measure the new revision again.");let Q=await Zy(C);Fc(Q,[Q.scene]);let Se=await Ky(Q);try{Q.assertTexturesLoaded()}catch(xe){_i(Q.scene);for(let we of Is(Se))_i(we);throw xe}let ue=Yy(Q,()=>!_&&Y===A&&X.isCurrent?.()!==!1,(xe)=>{_i(xe.scene);for(let we of Is(Se))_i(we)});if(!ue)return;let Fe=p&&X.preserveView?_f(i,r.target):void 0;if(p){E?.stopAllAction(),E?.uncacheRoot(p),n.remove(p),_i(p);for(let xe of Is(m))_i(xe)}p=ue.scene,m=Se,S=k,z=void 0,n.add(p),R=ue.animations,E=new ja(p),v=!0;let{clientWidth:Me,clientHeight:Z}=e;if(t.setSize(Me,Z),i.aspect=Me&&Z?Me/Z:i.aspect,I(),Fe)xf(i,r.target,Fe,zc(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let we=xe;if(!we.isMesh)return;re++;for(let Ee of Array.isArray(we.material)?we.material:[we.material])se.add(Ee)}),X.onCommit?.(),{triangles:Ho(p),meshes:re,materials:se.size,clips:R.map((xe)=>xe.name),...m?{levels:m.triangles}:{}}},level(C){if(F("The level of detail changed. Measure the displayed combination again."),m)ev(m,C)},partLevel(C,X){if(F("The level of detail changed. Measure the displayed combination again."),m)tv(m,C,X)},lod(){return p?nv(m,p):void 0},reset:I,cancelMeasurement:F,measure(C=3000){if(_||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(C)||C<1000||C>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(P)return Promise.reject(Error("A measurement is already running."));return new Promise((X,k)=>{P={started:performance.now(),previous:0,duration:C,samples:[],resolve:X,reject:k,timeout:setTimeout(()=>F("Measurement was interrupted or the browser stopped delivering frames."),C+2000)}})},view(){return _f(i,r.target)},setView(C){if(!p)return;xf(i,r.target,C,zc(p)),r.update()},navigation(C){if(o=C==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(C){for(let X of p?[p,...Is(m)]:[])X.traverse((k)=>{let Y=k;if(Y.isMesh){for(let Q of Array.isArray(Y.material)?Y.material:[Y.material])if("wireframe"in Q)Q.wireframe=C}})},lighting(C){t.toneMappingExposure=C==="bright"?1.65:C==="soft"?0.85:1.15,x.intensity=C==="soft"?0.8:2.4},clip(C){if(E?.stopAllAction(),R[C])E?.clipAction(R[C]).play()},pause(C){v=!C},dispose(){if(F("The viewport closed before measurement finished."),_=!0,A++,cancelAnimationFrame(T),H.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",f),p)_i(p);for(let C of Is(m))_i(C);g.dispose(),t.dispose(),e.replaceChildren()}}}var rv=["127.0.0.1","localhost","[::1]"];async function sv(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&rv.includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var av=16777216,cv=Math.ceil(av/3)*4,Wt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function mR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function ov(e){if(typeof e!=="string"||e.length>cv)return Wt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Wt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Wt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(mR(n)!==e)Wt("contains noncanonical base64 data");return n}function Vo(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function lv(e){if(!Vo(e))return Wt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=mf.safeParse(e.manifest);if(!t.success||!Vo(e.files))return Wt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Wt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Wt("file metadata is missing");if(r+=n.files[c].bytes,r>av)return Wt("exceeds the decoded size limit");let u=typeof l==="string"?l:Vo(l)?l.data:void 0;if(typeof u!=="string")return Wt("file encoding is malformed");if(s+=u.length,s>cv)return Wt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=ov(l);else{if(!Vo(l)||l.encoding!=="kiln.deflate-base64.v1")return Wt("encoding is unsupported");let g=ov(l.data);try{f=Sy(g,{out:new Uint8Array(u.bytes+1)})}catch{return Wt("compressed data is damaged")}}if(f.length!==u.bytes)return Wt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Wt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Wt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Vo(e.downloadUrls))return Wt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Wt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function uv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var En=(e)=>document.getElementById(e),xi=En("status"),nn,fv={},zr,gR=0,yi=0,kc=new Map;function dv(e,t){let n=++gR;return new Promise((i,r)=>{let s=setTimeout(()=>{kc.delete(n),r(Error("Chat host did not respond."))},20000);kc.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function hv(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function _R(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function xR(e){let t=++yi;nn=void 0,En("stats").textContent="",En("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await yR(e,t)}catch(n){if(t!==yi)return;xi.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function yR(e,t){if(e.isError){xi.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await lv(e._meta?.kilnAsset)}catch(i){if(t!==yi)return;xi.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==yi)return;nn=n.record,En("name").textContent=nn.manifest.name,fv=n.downloadUrls,En("revision").textContent=`${nn.manifest.editable?"Editable source included":"GLB asset"} · ${nn.manifest.revisionId.slice(0,10)}`,En("attribution").textContent=uv(nn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{zr??=iv(En("stage"));let i=await zr.load(nn.files["asset.glb"]);if(t!==yi)return;if(i){En("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(nn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=En("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}xi.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==yi)return;zr?.dispose(),zr=void 0;let r=nn.files["preview.png"];if(r){let s=new Image;s.alt=`${nn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${_R(r)}`,En("stage").replaceChildren(s)}xi.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;En("source").hidden=!nn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=kc.get(t.id);if(kc.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")xR(t.params);if(t.method==="ui/resource-teardown")zr?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});En("reset").onclick=()=>zr?.reset();En("clips").onchange=(e)=>zr?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!nn)return;let t=yi,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Wy([nn]):nn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=nn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,xi.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await sv(r,`${o}-${i}`,s,dv,a,fv[i]);if(t!==yi)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},xi.replaceChildren("Download ready. ",l)}else xi.textContent="Download requested."}catch(a){if(t===yi)xi.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!nn||t!==yi}};dv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{hv("ui/notifications/initialized"),hv("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{xi.textContent=e.message});
4405
+ */var Dt=Uint8Array,Nn=Uint16Array,Wd=Int32Array,al=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cl=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Bd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mv=function(e,t){var n=new Nn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Wd(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},gv=mv(al,2),{b:_v,r:Vd}=gv;_v[28]=258,Vd[258]=28;var xv=mv(cl,0),{b:XR,r:lv}=xv,Gd=new Nn(32768);for(Qe=0;Qe<32768;++Qe)Ei=(Qe&43690)>>1|(Qe&21845)<<1,Ei=(Ei&52428)>>2|(Ei&13107)<<2,Ei=(Ei&61680)>>4|(Ei&3855)<<4,Gd[Qe]=((Ei&65280)>>8|(Ei&255)<<8)>>1;var Ei,Qe,Ai=function(e,t,n){var i=e.length,r=0,s=new Nn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Nn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Nn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],h=o[e[r]-1]++<<u;for(var d=h|(1<<u)-1;h<=d;++h)a[Gd[h]>>c]=l}}else{a=new Nn(i);for(r=0;r<i;++r)if(e[r])a[r]=Gd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,oa=new Dt(32);for(Qe=0;Qe<32;++Qe)oa[Qe]=5;var Qe,jR=Ai(Er,9,0),qR=Ai(Er,9,1),YR=Ai(oa,5,0),JR=Ai(oa,5,1),Fd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ri=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},zd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Zd=function(e){return(e+7)/8|0},Xd=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var KR=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(e,t,n){var i=Error(t||KR[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},QR=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(Ae){var wt=n.length;if(Ae>wt){var Ge=new Dt(Math.max(wt*2,Ae));Ge.set(n),n=Ge}},u=t.f||0,h=t.p||0,d=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ri(e,h,1);var S=ri(e,h+1,3);if(h+=3,!S){var T=Zd(h)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(d+y);n.set(e.subarray(T,w),d),t.b=d+=y,t.p=h=w*8,t.f=u;continue}else if(S==1)f=qR,m=JR,_=9,p=5;else if(S==2){var A=ri(e,h,31)+257,R=ri(e,h+10,15)+4,x=A+ri(e,h+5,31)+1;h+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Bd[C]]=ri(e,h+C*3,7);h+=R*3;var L=Fd(z),K=(1<<L)-1,I=Ai(z,L,1);for(var C=0;C<x;){var G=I[ri(e,h,K)];h+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ri(e,h,3),h+=2,X=M[C-1];else if(T==17)P=3+ri(e,h,7),h+=3;else if(T==18)P=11+ri(e,h,127),h+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=Fd(j),p=Fd(k),f=Ai(j,_,1),m=Ai(k,p,1)}else $n(1);if(h>g){if(c)$n(0);break}}if(a)l(d+131072);var q=(1<<_)-1,ee=(1<<p)-1,Se=h;for(;;Se=h){var X=f[zd(e,h)&q],ue=X>>4;if(h+=X&15,h>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[d++]=ue;else if(ue==256){Se=h,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,Me=al[C];Be=ri(e,h,(1<<Me)-1)+_v[C],h+=Me}var Z=m[zd(e,h)&ee],re=Z>>4;if(!Z)$n(3);h+=Z&15;var k=XR[re];if(re>3){var Me=cl[re];k+=zd(e,h)&(1<<Me)-1,h+=Me}if(h>g){if(c)$n(0);break}if(a)l(d+131072);var se=d+Be;if(d<k){var xe=s-k,Ee=Math.min(k,se);if(xe+d<0)$n(3);for(;d<Ee;++d)n[d]=i[xe+d]}for(;d<se;++d)n[d]=n[d-k]}}if(t.l=f,t.p=Se,t.b=d,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return d!=n.length&&o?Xd(n,0,d):n.subarray(0,d)},Ji=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},ra=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},kd=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:vv,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,h=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var d=s[0].s;for(var i=1;i<r;++i)if(s[i].s>d)d=s[i].s;var f=new Nn(d+1),m=Hd(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},Hd=function(e,t,n){return e.s==-1?Math.max(Hd(e.l,t,n+1),Hd(e.r,t,n+1)):t[e.s]=n},uv=function(e){var t=e.length;while(t&&!e[--t]);var n=new Nn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},sa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},yv=function(e,t,n){var i=n.length,r=Zd(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},hv=function(e,t,n,i,r,s,o,a,c,l,u){Ji(t,u++,n),++r[256];var h=kd(r,15),{t:d,l:f}=h,m=kd(s,15),{t:_,l:p}=m,g=uv(d),{c:S,n:T}=g,y=uv(_),{c:w,n:A}=y,R=new Nn(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=kd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Bd[L-1]];--L);var K=l+5<<3,I=sa(r,Er)+sa(s,oa)+o,G=sa(r,d)+sa(s,_)+o+14+3*L+sa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return yv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Ji(t,u,1+(G<I)),u+=2,G<I){X=Ai(d,f,0),P=d,j=Ai(_,p,0),k=_;var q=Ai(z,C,0);Ji(t,u,T-257),Ji(t,u+5,A-1),Ji(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Ji(t,u+3*x,z[Bd[x]]);u+=3*L;var ee=[S,w];for(var Se=0;Se<2;++Se){var ue=ee[Se];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Ji(t,u,q[Be]),u+=z[Be],Be>15)Ji(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=jR,P=Er,j=YR,k=oa;for(var x=0;x<a;++x){var Me=i[x];if(Me>255){var Be=Me>>18&31;if(ra(t,u,X[Be+257]),u+=P[Be+257],Be>7)Ji(t,u,Me>>23&31),u+=al[Be];var Z=Me&31;if(ra(t,u,j[Z]),u+=k[Z],Z>3)ra(t,u,Me>>5&8191),u+=cl[Z]}else ra(t,u,X[Me]),u+=P[Me]}return ra(t,u,X[256]),u+P[256]},eC=new Wd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vv=new Dt(0),tC=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var h=eC[t-1],d=h>>13,f=h&8191,m=(1<<n)-1,_=s.p||new Nn(32768),p=s.h||new Nn(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new Wd(25000),w=new Nn(288),A=new Nn(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=hv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,ee=I-G&32767;if(X>2&&K==T(M-ee)){var Se=Math.min(d,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(ee<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-ee]){var Me=0;for(;Me<Be&&e[M+Me]==e[M+Me-ee];++Me);if(Me>j){if(j=Me,k=ee,Me>Se)break;var Z=Math.min(ee,Me-2),re=0;for(var P=0;P<Z;++P){var se=M-ee+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],ee+=I-G&32767}}if(k){y[z++]=268435456|Vd[j]<<18|lv[k];var Ae=Vd[j]&31,wt=lv[k]&31;x+=al[Ae]+cl[wt],++w[257+Ae],++A[wt],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=hv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=yv(c,u+1,e.subarray(M,Ge))}s.i=o}return Xd(a,0,i+Zd(u)+r)},nC=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),iC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=nC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var rC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return tC(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},bv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Sv(e,t){return rC(e,t||{},0,0)}function Mv(e,t){return QR(e,{i:2},t&&t.out,t&&t.dictionary)}var wv=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=bv(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],wv(s,o,n,i)}},dv=typeof TextEncoder<"u"&&new TextEncoder,sC=typeof TextDecoder<"u"&&new TextDecoder,oC=0;try{sC.decode(vv,{stream:!0}),oC=1}catch(e){}function fv(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(dv)return dv.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return Xd(s,0,o)}var $d=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},pv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,h=$d(l);if(Qt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var d=new Date(n.mtime==null?Date.now():n.mtime),f=d.getFullYear()-1980;if(f<0||f>119)$n(10);if(Qt(e,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,h),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,h)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},aC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Ev(e,t){if(!t)t={};var n={},i=[];wv(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,h=fv(o),d=h.length,f=l.comment,m=f&&fv(f),_=m&&m.length,p=$d(l.extra);if(d>65535)$n(11);var g=u?Sv(c,l):c,S=g.length,T=iC();T.p(c),i.push(bv(l,{size:c.length,crc:T.d(),c:g,f:h,m,u:d!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+d+p+S,s+=76+2*(d+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var h=i[R];pv(y,h.o,h,h.f,h.u,h.c.length);var x=30+h.f.length+$d(h.extra);y.set(h.c,h.o+x),pv(y,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+x+(h.m?h.m.length:0)}return aC(y,r,i.length,A,w),y}var Ti=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function cC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither and seeded stamps support only albedo/emissive. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class aa extends Error{diagnostic;constructor(e,t=cC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var ll=1024,ul=4,hl=8,qd=6,Av=80,es=256;class rt extends aa{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Tv=["solid","checker","stripes","gradient","bricks","noise"],Rv=["normal","multiply","screen","overlay"],lC=new Set(["__proto__","prototype","constructor"]);function dl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(lC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function uC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function si(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Pv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function jd(e,t,n){return Pv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function hC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Av||n)throw new rt(`${t} must be 1..${Av} visible characters.`);return e}function dC(e,t,n){if(e===void 0)return n;if(!Ti.includes(e))throw new rt(`${t} must be one of ${Ti.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Cv(e,t){let i=(Pv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function fC(e,t){let n=e.blend??"normal";if(!Rv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Rv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function pC(e,t){let n=`proceduralTexture.layers[${t}]`,i=dl(e,n),r=i.op;if(!Tv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Tv.join(", ")}.`);let s=fC(i,n),o=jd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:si(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Cv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:si(i.from,`${n}.from`),to:si(i.to,`${n}.to`),angleDeg:Cv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:si(i.brick,`${n}.brick`),mortar:si(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:jd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:jd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:si(i.colorA,`${n}.colorA`),colorB:si(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,qd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function mC(e){let t=dl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function ca(e){let t=dl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?dl(mC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<ul||i>ll||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${ul} and ${ll}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=uC(r,"proceduralTexture.layers");if(s.length>hl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${hl}.`);let o=hC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:dC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(pC)}}var gC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ri=(e,t)=>e>>>t|e<<32-t;function js(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ri(T,7)^Ri(T,18)^T>>>3,A=Ri(y,17)^Ri(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,h,d,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ri(f,6)^Ri(f,11)^Ri(f,25),y=f&m^~f&_,w=p+T+y+gC[S]+a[S]>>>0,A=Ri(l,2)^Ri(l,13)^Ri(l,22),R=l&u^l&h^u&h,x=A+R>>>0;p=_,_=m,m=f,f=d+w>>>0,d=h,h=u,u=l,l=w+x>>>0}let g=[l,u,h,d,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var qs="kiln.procedural-rgba.v3.1";var ua=1024,_C=1048576,ha=64,pl=64,la=256,ml=32,Iv=64000000,xC=67108864;function tt(e){throw new rt(`proceduralTexture V3: ${e}`,"PROCEDURAL_TEXTURE_V3_CONTRACT")}var yC=new Set(["__proto__","prototype","constructor"]);function vC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)tt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)tt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))tt(`${r} must be finite.`);return}if(typeof i!=="object")tt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)tt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))tt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)tt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let h of l){if(typeof h!=="string"||yC.has(h))tt(`${r} has a forbidden key.`);if(o&&h==="length")continue;let d=u[h];if(!d.enumerable||!("value"in d))tt(`${r}.${h} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=c))tt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)tt(`${r} must be a dense JSON array.`);for(let h of l)if(h!=="length"||!o)n(u[h].value,`${r}.${String(h)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))tt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))tt(`${n} has unknown field ${r}.`);return i}function pn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)tt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Lv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")tt(`${t} must be boolean.`);return e}function fl(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)tt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>pn(s,i,r,`${n}[${o}]`))}function Nv(e,t){let n=fl(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function Dv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:pn(i.x,-4096,4096,`${t}.x`),y:pn(i.y,-4096,4096,`${t}.y`),width:pn(i.width,1,2048,`${t}.width`),height:pn(i.height,1,2048,`${t}.height`)}}function bC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...Dv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>pl)tt(`${t}.points requires 3..${pl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>fl(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:fl(n.from,2,`${t}.from`,-4096,4096),to:fl(n.to,2,`${t}.to`,-4096,4096),width:pn(n.width,1,2048,`${t}.width`)};return tt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Ov(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function SC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function MC(e,t,n,i=0,r=0){let[s,o,a,c]=Ov(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function gl(e){vC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)tt("schemaVersion must be 3.");let n=pn(t.width,4,ua,"width"),i=pn(t.height,4,ua,"height"),r=n*i;if(r>_C)tt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ti.includes(s))tt("usage must be a known texture usage.");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))tt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>ha)tt(`operations must be an array with at most ${ha} entries.`);let l=r,u=0,h=0,d=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)tt(`${S}.spec requires explicit schemaVersion 2.`);let k=ca(j);if(k.size!==n||k.size!==i||k.usage!==s)tt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,ee)=>q+(ee.op==="noise"?ee.octaves*16:4),0)),h+=r*4,{op:"legacy-v2",spec:k,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)}}let y=bC(T.shape,`${S}.shape`),w=SC(y),[A,R,x,M]=MC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:pn(T.alpha,0,255,`${S}.alpha`,255),invert:Lv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return tt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Nv(T.rgba,`${S}.rgba`),opacity:pn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};if(Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S),!o)tt("stamps are supported only for color usages albedo and emissive.");let L=pn(T.count,1,la,`${S}.count`),K=Lv(T.periodic,`${S}.periodic`),[I,G,X,P]=Ov(y);if(K&&(X-I>n||P-G>i))tt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>la)tt(`expanded stamps budget exceeds ${la}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:pn(T.seed,0,4294967295,`${S}.seed`),area:Dv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)tt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>ml)tt(`palette.colors requires 1..${ml} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")tt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>pn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Iv)tt(`estimated work budget ${l} exceeds ${Iv}.`);if(r*4+h>xC)tt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Nv(t.background,"background"),operations:d,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)tt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+h}}function Yd(e){return gl(e).spec}function wC(e){return gl(e).canonicalJson}function Jd(e){return`sha256:${js(`${qs}
4406
+ ${wC(e)}`)}`}var Kd=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],Qd=["nearest","linear"],da=["repeat","clamp-to-edge","mirrored-repeat"];function _l(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Kd,magFilter:Qd,wrapS:da,wrapT:da};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Ys="kiln.texture-atlas.v1.1",mn=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728});class Fv extends aa{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function ke(e){throw new Fv(e)}function tf(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>mn.jsonBytes)ke("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)ke("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))ke("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)ke("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")ke("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)ke("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))ke("JSON array budget exceeded.");let h=Reflect.ownKeys(o);if(h.length>1024||c&&h.length!==u+1)ke("dense bounded JSON fields are required.");r(2+Math.max(0,h.length-(c?1:0)-1));for(let d of h){if(c&&d==="length")continue;if(typeof d!=="string"||["__proto__","prototype","constructor"].includes(d))ke("forbidden JSON field.");if(d.length>4096)ke("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(d)).length+1);let f=Object.getOwnPropertyDescriptor(o,d);if(!f.enumerable||!("value"in f))ke("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=u))ke("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function bn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))ke(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))ke(`${n} has an unknown field.`);return i}function Zn(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)ke(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))ke(`${t} must be an exact SHA-256 hash.`);return e}function Uv(e,t){let n=bn(e,["x","y","width","height"],t);return{x:Zn(n.x,0,4096,`${t}.x`),y:Zn(n.y,0,4096,`${t}.y`),width:Zn(n.width,1,4096,`${t}.width`),height:Zn(n.height,1,4096,`${t}.height`)}}function fa(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function zv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)ke("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)ke("source crop/content dimensions must match; resampling is unsupported.")}function ef(e){return e.kind==="procedural"?`procedural:${Jd(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function pa(e){tf(e);let t=bn(e,["schemaVersion","width","height","usage","sampler","regions"],"atlas");if(t.schemaVersion!==1)ke("schemaVersion must be 1.");let n=Zn(t.width,4,mn.edge,"width"),i=Zn(t.height,4,mn.edge,"height");if(!Ti.includes(t.usage))ke("usage must be a texture usage.");let r=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>mn.regions)ke("regions must contain 1..64 entries.");let s=t.regions.map((c,l)=>{let u=bn(c,["name","content","gutter","edgeMode","source","crop"],`regions[${l}]`);if(typeof u.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(u.name))ke("region name must be a stable lowercase identifier.");let h=Uv(u.content,"content"),d=u.gutter===void 0?2:Zn(u.gutter,0,32,"gutter"),f=u.edgeMode===void 0?"copy-edge":u.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(f))ke("unsupported edgeMode.");if(f==="mask-rgb-dilate"&&r!=="albedo"&&r!=="emissive")ke("mask RGB dilation requires color usage.");let m=bn(u.source,["kind","spec","resourceId","pin","expected"],"source"),_,p=u.crop===void 0?void 0:Uv(u.crop,"crop");if(m.kind==="procedural"){bn(m,["kind","spec"],"procedural source");let T=gl(m.spec);if(T.spec.usage!==r)ke("source usage does not match atlas usage.");_={kind:"procedural",spec:T.spec},p??={x:0,y:0,width:T.spec.width,height:T.spec.height},zv(p,h,T.spec.width,T.spec.height)}else if(m.kind==="resource"){if(bn(m,["kind","resourceId","pin","expected"],"resource source"),typeof m.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(m.resourceId))ke("source resourceId must be an exact returned map ID.");let T=bn(m.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof T.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(T.resourceId))ke("pin resourceId must be a material ID.");let y=Tr(T.revisionId,"pin revisionId"),w=Tr(T.sha256,"pin sha256");if(y!==w)ke("source pin revision/hash mismatch.");let A;if(m.expected!==void 0){let R=bn(m.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");A={...R.width===void 0?{}:{width:Zn(R.width,1,4096,"expected.width")},...R.height===void 0?{}:{height:Zn(R.height,1,4096,"expected.height")},...R.imageSha256===void 0?{}:{imageSha256:Tr(R.imageSha256,"expected.imageSha256")},...R.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(R.decodedPixelHash,"expected.decodedPixelHash")}}}if(_={kind:"resource",resourceId:m.resourceId,pin:{resourceId:T.resourceId,revisionId:y,sha256:w},...A?{expected:A}:{}},p&&(p.width!==h.width||p.height!==h.height))ke("source crop/content dimensions must match; resampling is unsupported.")}else ke("source kind must be procedural or pinned resource.");let g={name:u.name,content:h,gutter:d,edgeMode:f,source:_,...p?{crop:p}:{}},S=fa(g);if(S.x<0||S.y<0||S.x+S.width>n||S.y+S.height>i)ke("padded allocation is out of bounds.");return g}).sort((c,l)=>c.name<l.name?-1:c.name>l.name?1:0);if(new Set(s.map((c)=>c.name)).size!==s.length)ke("duplicate region name.");for(let c=0;c<s.length;c++)for(let l=c+1;l<s.length;l++){let u=fa(s[c]),h=fa(s[l]);if(u.x<h.x+h.width&&h.x<u.x+u.width&&u.y<h.y+h.height&&h.y<u.y+u.height)ke(`padded allocations overlap: ${s[c].name}, ${s[l].name}.`)}if(new Set(s.map((c)=>ef(c.source))).size>mn.sources)ke("distinct source budget exceeds 16.");let o;try{o=_l(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(c){ke(`sampler: ${c.message}`)}let a={schemaVersion:1,width:n,height:i,usage:r,sampler:o,regions:s};if(new TextEncoder().encode(JSON.stringify(a)).length>mn.jsonBytes)ke("canonical JSON byte budget exceeded.");return a}function EC(e){return JSON.stringify(pa(e))}function AC(e){return`sha256:${js(`${Ys}
4407
+ ${EC(e)}`)}`}function Ci(e){tf(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function TC(e){return`sha256:${js(`kiln.atlas-layout.v1
4408
+ ${Ci({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:fa(t)}))})}`)}`}function nf(e,t){tf(e);let n=pa(t),i=bn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Ys||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")ke("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ci(i.sampler)!==Ci(n.sampler)||i.specHash!==AC(n)||i.layoutHash!==TC(n))ke("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[ef(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)ke("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=bn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))ke("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)ke("manifest source identity mismatch.");let h=Zn(l.width,1,4096,"manifest source width"),d=Zn(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(bn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),h!==u.spec.width||d!==u.spec.height||l.recipeHash!==Jd(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")ke("manifest procedural source identity mismatch.")}else{bn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=bn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==h||f.height!==d||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))ke("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Zn(f.encodedByteLength,1,mn.encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)ke("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))ke("manifest source expectation mismatch.")}}s.set(l.id,{width:h,height:d})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=bn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),h=ef(l.source),d=s.get(h),f=l.crop??{x:0,y:0,width:d.width,height:d.height};if(zv(f,l.content,d.width,d.height),u.name!==l.name||u.sourceId!==h||Ci(u.content)!==Ci(l.content)||Ci(u.allocation)!==Ci(fa(l))||Ci(u.crop)!==Ci(f))ke("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${js(`kiln.atlas-manifest.v1
4409
+ ${Ci(a)}`)}`)ke("manifest hash mismatch.");return structuredClone(e)}var RC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:Ct(["normal","multiply","screen","overlay"]),opacity:i};return we({schemaVersion:Fe(2),size:et().int().min(ul).max(ll),usage:Ct(Ti),name:Xe().min(1).max(80).optional(),layers:_t(ii("op",[we({op:Fe("solid"),color:e,...r}).strict(),we({op:Fe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),we({op:Fe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),we({op:Fe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),we({op:Fe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),we({op:Fe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(qd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(hl)}).strict()})();function kv(e,t=RC){let n=(k,q)=>et().int().min(k).max(q),i=n(0,255),r=n(-4096,4096),s=rv([r,r]),o=rv([i,i,i,i]),a=Ct(Ti),c=HR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),h=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),d={width:n(1,4096),height:n(1,4096)},f=we({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=we({x:n(0,4096),y:n(0,4096),...d}).strict(),_=ii("kind",[f.extend({kind:Fe("rectangle")}).strict(),f.extend({kind:Fe("ellipse")}).strict(),we({kind:Fe("polygon"),points:_t(s).min(3).max(pl)}).strict(),we({kind:Fe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=we({op:Fe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=we({op:Fe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=we({op:Fe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,la),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=we({op:Fe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=we({colors:_t(n(0,16777215)).min(1).max(ml),dither:Ct(["none","bayer4"])}).strict(),w={schemaVersion:Fe(3),width:n(4,ua),height:n(4,ua),usage:a,name:l.optional(),background:o},A=we({...w,operations:_t(ii("op",[p,g,S,T.extend({spec:t})])).max(ha),palette:y.optional()}).strict(),R=we({...w,usage:a.optional(),background:o.optional(),operations:_t(ii("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(ha),palette:y.partial({dither:!0}).optional()}).strict(),x=we({minFilter:Ct(Kd),magFilter:Ct(Qd),wrapS:Ct(da),wrapT:Ct(da)}).strict(),M=we({resourceId:u,revisionId:c,sha256:c}).strict(),z=we({kind:Fe("resource"),resourceId:h,pin:M,expected:we({...d,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=we({name:u,content:m,gutter:n(0,32),edgeMode:Ct(["copy-edge","mask-rgb-dilate"]),source:ii("kind",[we({kind:Fe("procedural"),spec:A}).strict(),z]),crop:m.optional()}).strict(),L={schemaVersion:Fe(1),width:n(4,mn.edge),height:n(4,mn.edge),usage:a,sampler:x},K=we({...L,regions:_t(C).min(1).max(mn.regions)}).strict(),I=we({...L,sampler:x.optional(),regions:_t(C.extend({source:ii("kind",[we({kind:Fe("procedural"),spec:R}).strict(),z])}).partial({gutter:!0,edgeMode:!0})).min(1).max(mn.regions)}).strict(),G=we({materialId:u,revisionId:c,resourceId:h,slot:Ct(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:Ct(["srgb","linear"]),...d,encodedByteLength:n(1,mn.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),X={id:Xe().min(1).max(1024),...d,decodedPixelHash:c},P=ii("kind",[we({...X,kind:Fe("procedural"),recipeHash:c,compilerId:Fe(qs)}).strict(),we({...X,kind:Fe("resource"),descriptor:G}).strict()]),j=we({version:Fe("kiln.atlas-manifest.v1"),compilerId:Fe(Ys),width:L.width,height:L.height,usage:a,origin:Fe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(P).min(1).max(mn.sources),regions:_t(we({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(mn.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:I,canonicalTextureAtlasSpecV1Schema:K,textureAtlasManifestV1Schema:j,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:G}}var cn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Vv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Gv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Ks=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Ii=Xe().regex(/^sha256:[a-f0-9]{64}$/),Pi=Xe().min(1).max(1000),Bv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Hv=we({id:Ks,kind:Ct(["external","procedural"]),provider:Pi,creator:Pi,assetId:Pi.optional(),assetUrl:Bv.optional(),accessedAt:Xe().datetime().optional(),license:we({spdx:Pi,url:Bv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(we({name:Xe().min(1).max(200),sha256:Ii,bytes:et().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),$v=we({operation:Pi,tool:Pi,version:Pi,parameters:ol(Xe().max(100),ia([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),oi=et().int().min(0).max(16777215),ma=et().int().min(1).max(256),Js={blend:Ct(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},_a=we({schemaVersion:Fe(2),size:et().int().min(4).max(1024).default(256),usage:Ct(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ii("op",[we({op:Fe("solid"),color:oi,...Js}).strict(),we({op:Fe("checker"),colorA:oi,colorB:oi,squares:ma.default(8),...Js}).strict(),we({op:Fe("stripes"),colorA:oi,colorB:oi,count:ma.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Js}).strict(),we({op:Fe("gradient"),from:oi,to:oi,angleDeg:et().min(-36000).max(36000).default(0),...Js}).strict(),we({op:Fe("bricks"),brick:oi,mortar:oi,rows:ma.default(8),cols:ma.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Js}).strict(),we({op:Fe("noise"),colorA:oi,colorB:oi,scale:ma.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Js}).strict()])).min(1).max(8)}).strict(),of=we({kind:Fe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),CC=we({compiler:Fe("kiln.procedural-texture.v2"),spec:_a,derive:of.optional(),recipeHash:Ii,pixelHash:Ii,encoder:we({name:Fe("sharp"),version:Pi}).strict()}).strict(),Wv=we({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:Ct(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),ga=we({schemaVersion:Fe(1),materialId:Ks,revisionId:Ii,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:we({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Wv,sources:_t(Hv).min(1).max(20),maps:_t(we({slot:Ct(Vv),file:Ct(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Ii,bytes:et().int().positive().max(cn.maxMapBytes),width:et().int().positive().max(cn.maxMapEdge),height:et().int().positive().max(cn.maxMapEdge),usage:Ct(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Ct(["srgb","linear"]),normalConvention:Fe("opengl").optional(),channelPacking:Fe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Ks,originalFile:Xe().min(1).max(200).optional(),transforms:_t($v).max(30),procedural:CC.optional()}).strict()).min(1).max(5)}).strict(),rf=we({materialId:Ks,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:we({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Wv.partial().optional(),sources:_t(Hv).min(1).max(20),maps:_t(we({slot:Ct(Vv),sourceId:Ks,transforms:_t($v).max(30),normalConvention:Fe("opengl").optional(),channelPacking:Fe("r-occlusion-g-roughness-b-metallic").optional(),procedural:_a,derive:of.optional()}).strict()).min(1).max(5)}).strict(),sf=we({schemaVersion:Fe(1),records:_t(we({manifest:ga,files:ol(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(cn.maxMapBytes/3)*4))}).strict()).max(cn.maxPayloadRecords)}).strict();function eo(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");eo(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function en(e){eo(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function PC(e){if(eo(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=ga.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==Gv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(en(r.procedural.spec)!==en(ca(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Qs=kv(_a),Zv=Qs.portableSamplerSchema.refine((e)=>{try{return en(e)===en(_l(e))}catch{return!1}}),IC=Qs.canonicalProceduralTextureSpecV3Schema.refine((e)=>{try{return en(e)===en(Yd(e))}catch{return!1}}),LC=Qs.canonicalTextureAtlasSpecV1Schema.refine((e)=>{try{return en(e)===en(pa(e))}catch{return!1}}),NC=Qs.textureAtlasManifestV1Schema,DC=we({resourceId:Ks,revisionId:Ii,sha256:Ii}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),OC=ii("kind",[we({kind:Fe("procedural"),compilerId:Ct(["kiln.procedural-texture.v2",qs]),spec:ia([_a,IC]),recipeHash:Ii,pixelHash:Ii,encoder:we({name:Fe("sharp"),version:Pi}).strict(),derive:of.optional()}).strict(),we({kind:Fe("atlas"),compilerId:Fe(Ys),spec:LC,manifest:NC,encoder:we({name:Fe("sharp"),version:Pi}).strict()}).strict().superRefine((e,t)=>{try{nf(e.manifest,e.spec)}catch{t.addIssue({code:"custom",message:"Invalid stored atlas manifest"})}})]),Xv=ga.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Fe(2),dependencies:_t(DC).max(16),maps:_t(ga.shape.maps.element.omit({procedural:!0}).extend({sampler:Zv,pixelHash:Ii,recipe:OC.optional()}).strict()).min(1).max(5)}).strict(),UC=ii("schemaVersion",[ga,Xv]),FC=sf.extend({schemaVersion:Fe(2),records:_t(sf.shape.records.element.extend({manifest:UC}).strict()).max(cn.maxPayloadRecords)}).strict(),jv=ii("schemaVersion",[sf,FC]);function qv(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var zC=rf.extend({schemaVersion:Fe(2),maps:_t(rf.shape.maps.element.omit({procedural:!0}).extend({sampler:Zv,procedural:ia([_a,Qs.proceduralTextureSpecV3Schema.refine((e)=>{try{return Yd(e),!0}catch{return!1}})]).optional(),atlas:Qs.textureAtlasSpecV1Schema.refine((e)=>{try{return pa(e),!0}catch{return!1}}).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),bO=ia([rf,zC]);function af(e){if(eo(e),new TextEncoder().encode(JSON.stringify(e)).length>cn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return PC(e);let t=Xv.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==Gv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==qs||c.derive||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions/derivation mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||en(l)!==en(ca(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(nf(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||en(c.spec.sampler)!==en(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>cn.maxRecordBytes||i>cn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var xl=67108864,cf=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),kC=Xe().regex(/^sha256:[a-f0-9]{64}$/),lf=we({version:Fe("kiln.asset.v1"),assetId:cf,revisionId:cf,parentRevision:cf.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:we({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:ol(Xe(),we({sha256:kC,bytes:et().int().nonnegative().max(xl)})),build:we({engine:Xe(),options:ol(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:Ct(["engine-required","external-dependencies-required"])}).optional(),preview:we({fidelity:Jr().optional(),error:Xe().optional(),backdrop:Ct(av).optional()}).optional()}),BC="materials.kiln.json",VC=25165824;function GC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=af(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&en(o)!==en(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>cn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function Yv(e,t=!1){let n=GC(e),i=new Map(n.map((h)=>[`${h.materialId}/${h.revisionId}`,en(h)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}eo(e.materialResources);let r=jv.parse(e.materialResources),s=0,o=0,a=new Map;for(let h of r.records){let d=af(h.manifest),f=`${h.manifest.materialId}/${h.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==en(d))throw Error("Asset material closure mismatch");if(a.set(f,d),Object.keys(h.files).length!==h.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of h.manifest.maps){if(h.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>cn.maxPayloadBytes||o>cn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(h)=>{if(l.has(h))throw Error("Asset material closure contains a cycle");if(c.has(h))return;let d=a.get(h);if(!d)throw Error("Asset material closure incomplete");l.add(h);for(let f of qv(d))u(`${f.resourceId}/${f.revisionId}`);l.delete(h),c.add(h)};for(let h of i.keys())u(h);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var HC=new Set(["asset.glb","source.kiln.js","preview.png"]);function $C(e){let t=lf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!HC.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>xl||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");uf(e.files["asset.glb"]),Yv(e)}function uf(e){if(e.length<20||e.length>xl)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Jv(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){$C(i),Yv(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>VC)throw Error("Asset material payload exceeds byte limit");t[r+BC]=s}}for(let i of Object.values(t))n+=i.length;if(n>xl)throw Error("Bundle exceeds 64 MiB");return Ev(t,{level:0})}function Li(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Kv(e){uf(e);let t=new Io,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Ds(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new Fh(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Li(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Qv(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),h=Math.max(h,y),d=Math.min(d,w),f=Math.max(f,w)}r.addScaledVector(a,(u+h)/2),r.addScaledVector(c,(d+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function hf(e,t){return{position:e.position.clone(),target:t.clone()}}function df(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new U))+r*20,10),e.updateProjectionMatrix()}function eb(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function tb(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function nb(e,t,n){if(t())return e;n(e);return}function yl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function vl(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Gt().setFromObject(e,!0):n}function xa(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function ib(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let h=l.parent;while(h&&!i.has(h))h=h.parent;if(h)continue;let d=[l];for(let m of u)d.push(await e.parser.getDependency("node",m));yl(e,d.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:d})}if(r.length===0)return;let s=xa(e.scene)-r.reduce((c,l)=>c+ff(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,h)=>u+ff(h,l),0));return{chains:r,triangles:a}}var rb=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function ff(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return xa(rb(e,t))}function sb(e,t){let n=rb(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function ob(e,t){for(let n of e.chains)sb(n,t)}function ab(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return sb(i,n),!0}function cb(e,t){if(!e)return;return{triangles:xa(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>ff(n,r))}))}}function to(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function lb(e){let t=new Eh({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=go,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Ps,i=new Vt(40,1,0.01,1000),r=new Rh(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),h=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",h);let d=new ko(t),f=new Ch,m=d.fromScene(f,0.04);n.environment=m.texture,f.dispose(),d.dispose();let _=new Fs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new bc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:tb(C.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let P=vl(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ns){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:ee,position:Se}=Qv(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Se),i.near=Math.max(q/1000,0.0001),i.far=ee+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=eb(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let ee=await Kv(P);yl(ee,[ee.scene]);let Se=await ib(ee);try{ee.assertTexturesLoaded()}catch(xe){Li(ee.scene);for(let Ee of to(Se))Li(Ee);throw xe}let ue=nb(ee,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Li(xe.scene);for(let Ee of to(Se))Li(Ee)});if(!ue)return;let Be=p&&j.preserveView?hf(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Li(p);for(let xe of to(g))Li(xe)}p=ue.scene,g=Se,M=k,z=void 0,n.add(p),T=ue.animations,S=new Ec(p),y=!0;let{clientWidth:Me,clientHeight:Z}=e;if(t.setSize(Me,Z),i.aspect=Me&&Z?Me/Z:i.aspect,I(),Be)df(i,r.target,Be,vl(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:xa(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)ob(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)ab(g,P,j)},lod(){return p?cb(g,p):void 0},reset:I,cancelMeasurement:L,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((j,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return hf(i,r.target)},setView(P){if(!p)return;df(i,r.target,P,vl(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let j of p?[p,...to(g)]:[])j.traverse((k)=>{let q=k;if(q.isMesh){for(let ee of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in ee)ee.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",h),p)Li(p);for(let P of to(g))Li(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var ub=["127.0.0.1","localhost","[::1]"];async function hb(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let h=new URL(s);if(h.protocol!=="https:"&&!(h.protocol==="http:"&&ub.includes(h.hostname)))throw Error("Invalid host download URL");return{downloadUrl:h.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var fb=16777216,pb=Math.ceil(fb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function WC(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function db(e){if(typeof e!=="string"||e.length>pb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(WC(n)!==e)Yt("contains noncanonical base64 data");return n}function ya(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function mb(e){if(!ya(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=lf.safeParse(e.manifest);if(!t.success||!ya(e.files))return Yt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Yt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Yt("file metadata is missing");if(r+=n.files[c].bytes,r>fb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ya(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>pb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],h;if(typeof l==="string")h=db(l);else{if(!ya(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=db(l.data);try{h=Mv(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(h.length!==u.bytes)return Yt("byte count does not match the saved file");let d=await crypto.subtle.digest("SHA-256",Uint8Array.from(h));if(`sha256:${Array.from(new Uint8Array(d),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=h}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ya(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function gb(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Dn=(e)=>document.getElementById(e),Ni=Dn("status"),ln,xb={},ts,ZC=0,Di=0,bl=new Map;function yb(e,t){let n=++ZC;return new Promise((i,r)=>{let s=setTimeout(()=>{bl.delete(n),r(Error("Chat host did not respond."))},20000);bl.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function _b(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function XC(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function jC(e){let t=++Di;ln=void 0,Dn("stats").textContent="",Dn("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await qC(e,t)}catch(n){if(t!==Di)return;Ni.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function qC(e,t){if(e.isError){Ni.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await mb(e._meta?.kilnAsset)}catch(i){if(t!==Di)return;Ni.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Di)return;ln=n.record,Dn("name").textContent=ln.manifest.name,xb=n.downloadUrls,Dn("revision").textContent=`${ln.manifest.editable?"Editable source included":"GLB asset"} · ${ln.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=gb(ln.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ts??=lb(Dn("stage"));let i=await ts.load(ln.files["asset.glb"]);if(t!==Di)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(ln.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Ni.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Di)return;ts?.dispose(),ts=void 0;let r=ln.files["preview.png"];if(r){let s=new Image;s.alt=`${ln.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${XC(r)}`,Dn("stage").replaceChildren(s)}Ni.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!ln.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=bl.get(t.id);if(bl.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")jC(t.params);if(t.method==="ui/resource-teardown")ts?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ts?.reset();Dn("clips").onchange=(e)=>ts?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!ln)return;let t=Di,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Jv([ln]):ln.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=ln.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Ni.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await hb(r,`${o}-${i}`,s,yb,a,xb[i]);if(t!==Di)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},Ni.replaceChildren("Download ready. ",l)}else Ni.textContent="Download requested."}catch(a){if(t===Di)Ni.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!ln||t!==Di}};yb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{_b("ui/notifications/initialized"),_b("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Ni.textContent=e.message});
4406
4410
 
4407
4411
  </script>
4408
4412
  </body>