@needle-tools/engine 3.41.2-beta → 3.41.2-beta.2

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.
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+e.toString())}const i=To()||K_()&&rt();if((
4344
4344
  #__vconsole .vc-mask {
4345
4345
  overflow: hidden;
4346
4346
  }
4347
- `,la?.prepend(n),i===!0&&mT()<=0&&nQ(),console.log("\u{1F335} Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function $ie(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(t){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let r=globalThis["needle:codegen_files"][0];const s=r.indexOf("?");s>-1&&(r=r.substring(0,s));const o=location.protocol+"//"+location.host+location.pathname+"/"+r,a=encodeURIComponent(o);i.fullUrl="https://viewer.needle.tools?inspect&file="+a;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),i.on("show",function(){const t=e();t&&t.src!==i.fullUrl&&(t.src=i.fullUrl)}),i.on("hide",function(){const t=e();t&&(t.src="")}),i.on("addTopBar",function(t){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(r){window.open(i.fullUrl,"_blank"),aa?.hide()}}),n.push({name:"Reload",onClick:function(r){const s=e();s&&(s.src=i.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(r){const s=e();s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen instanceof Function&&s.webkitRequestFullscreen()}}),t(n)}),i}function ene(){return document.querySelector("#__vconsole .vc-switch")||null}function tne(){return document.querySelector("#__vconsole")||null}const aQ=ee("debugdefines");Pm('if(!globalThis[""3.41.2-beta""]) globalThis[""3.41.2-beta""] = "0.0.0";'),Pm('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Pm('if(!globalThis[""Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)""]) globalThis[""Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)""] = "unknown";'),Pm('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.41.2-beta";'),Pm('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Pm('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)";');const Za="3.41.2-beta",Aw="undefined",pB="Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)";aQ&&console.log(`Engine version: ${Za} (generator: ${Aw})
4347
+ `,la?.prepend(n),i===!0&&mT()<=0&&nQ(),console.log("\u{1F335} Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function $ie(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(t){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let r=globalThis["needle:codegen_files"][0];const s=r.indexOf("?");s>-1&&(r=r.substring(0,s));const o=location.protocol+"//"+location.host+location.pathname+"/"+r,a=encodeURIComponent(o);i.fullUrl="https://viewer.needle.tools?inspect&file="+a;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),i.on("show",function(){const t=e();t&&t.src!==i.fullUrl&&(t.src=i.fullUrl)}),i.on("hide",function(){const t=e();t&&(t.src="")}),i.on("addTopBar",function(t){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(r){window.open(i.fullUrl,"_blank"),aa?.hide()}}),n.push({name:"Reload",onClick:function(r){const s=e();s&&(s.src=i.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(r){const s=e();s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen instanceof Function&&s.webkitRequestFullscreen()}}),t(n)}),i}function ene(){return document.querySelector("#__vconsole .vc-switch")||null}function tne(){return document.querySelector("#__vconsole")||null}const aQ=ee("debugdefines");Pm('if(!globalThis[""3.41.2-beta.2""]) globalThis[""3.41.2-beta.2""] = "0.0.0";'),Pm('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Pm('if(!globalThis[""Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)""]) globalThis[""Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)""] = "unknown";'),Pm('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.41.2-beta.2";'),Pm('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Pm('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)";');const Za="3.41.2-beta.2",Aw="undefined",pB="Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)";aQ&&console.log(`Engine version: ${Za} (generator: ${Aw})
4348
4348
  Project built at ${pB}`);const Yc="needle_isActiveInHierarchy",mp="builtin_components",H0="needle_editor_guid";function Pm(i){try{(0,eval)(i)}catch(e){aQ&&console.error(e)}}const ine='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',nne=btoa(ine),rne="data:image/svg+xml;base64,"+nne,sne=rne,one=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(one);const ane='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',lne=btoa(ane),cne="data:image/svg+xml;charset=utf-8;base64,"+lne,hne=cne,ca=ee("debuglicense");let gp="basic";ca&&console.log("License Type: "+gp);function cu(){switch(gp){case"pro":case"enterprise":return!0}return!1}function fB(){switch(gp){case"indie":return!0}return!1}function Jc(){return cu()||fB()}const lQ=[];function une(i){if(cu()||fB())return i(!0);lQ.push(i)}function dne(i){for(const e of lQ)try{e(i)}catch{}}hi.registerCallback(Ei.ContextRegistered,i=>{mne(i.context),Ane(),fne(i.context)});let Ap,mB=!1,vw="";async function pne(){if(Ap)return Ap;if(gp==="basic")try{const i="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Za+"&generator="+encodeURIComponent(Aw),e=await fetch(i,{method:"GET"}).catch(t=>{ca&&console.error("License check failed",t)});e?.status===200?(mB=!1,ca&&console.log("License check succeeded"),gp="pro",dne(!0)):e?.status===403?(mB=!0,vw=await e.text()):ca&&console.log("License check failed with status "+e?.status)}catch(i){ca&&console.error("License check failed",i)}else ca&&console.log('Runtime license check is skipped because license is already applied as "'+gp+'"')}Ap=pne();async function fne(i){function e(){const r=document.createElement("div");r.className="needle-forbidden",r.style.cssText=`
4349
4349
  position: fixed;
4350
4350
  top: 0;
@@ -4415,7 +4415,7 @@ CLICK HERE TO GET A LICENSE`,t.style.cursor="pointer",t.style.userSelect="none",
4415
4415
  * SPDX-License-Identifier: MIT
4416
4416
  */const bB="162",yw=0,xne=1,_ne=2,fQ=1,mQ=100,gQ=204,AQ=205,vQ=3,wne=0,yQ="attached",Cne="detached",bQ=300,Ene=301,X0=1e3,yp=1001,xB=1002,bp=1003,Sne=1004,Ine=1005,Y0=1006,Mne=1007,bw=1008,ha=1009,Tne=1014,xp=1015,xw=1016,Bne=1020,hu=1023,_B=1026,xQ=1027,km=1028,J0=1030,Rne=33776,Dne=33779,Pne=35840,kne=35842,One=36196,Lne=37492,Fne=37496,Une=37808,_Q=37812,Nne=36492,K0=2300,Om=2301,wB=2302,wQ=2400,CQ=2401,EQ=2402,Qne=2500,zne=0,SQ=1,CB=2,jne=0,EB="",fs="srgb",po="srgb-linear",IQ="display-p3",SB="display-p3-linear",IB="linear",MQ="srgb",TQ="rec709",BQ="p3",Lm=7680,RQ=519,Gne=515,MB=35044,_p=2e3,TB=2001;class _w{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const n=this._listeners[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const n=t.slice(0);for(let r=0,s=n.length;r<s;r++)n[r].call(this,e);e.target=null}}}const ms=["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"];let DQ=1234567;const Z0=Math.PI/180,$0=180/Math.PI;function $a(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ms[i&255]+ms[i>>8&255]+ms[i>>16&255]+ms[i>>24&255]+"-"+ms[e&255]+ms[e>>8&255]+"-"+ms[e>>16&15|64]+ms[e>>24&255]+"-"+ms[t&63|128]+ms[t>>8&255]+"-"+ms[t>>16&255]+ms[t>>24&255]+ms[n&255]+ms[n>>8&255]+ms[n>>16&255]+ms[n>>24&255]).toLowerCase()}function gs(i,e,t){return Math.max(e,Math.min(t,i))}function BB(i,e){return(i%e+e)%e}function Hne(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Vne(i,e,t){return i!==e?(t-i)/(e-i):0}function ev(i,e,t){return(1-t)*i+t*e}function Wne(i,e,t,n){return ev(i,e,1-Math.exp(-t*n))}function qne(i,e=1){return e-Math.abs(BB(i,e*2)-e)}function Xne(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Yne(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Jne(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Kne(i,e){return i+Math.random()*(e-i)}function Zne(i){return i*(.5-Math.random())}function $ne(i){i!==void 0&&(DQ=i);let e=DQ+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ere(i){return i*Z0}function tre(i){return i*$0}function ire(i){return(i&i-1)===0&&i!==0}function nre(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function rre(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function sre(i,e,t,n,r){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),h=o((e+n)/2),d=s((e-n)/2),p=o((e-n)/2),f=s((n-e)/2),m=o((n-e)/2);switch(r){case"XYX":i.set(a*h,l*d,l*p,a*c);break;case"YZY":i.set(l*p,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*p,a*h,a*c);break;case"XZX":i.set(a*h,l*m,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*m,a*c);break;case"ZYZ":i.set(l*m,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function el(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Bi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const ore={DEG2RAD:Z0,RAD2DEG:$0,generateUUID:$a,clamp:gs,euclideanModulo:BB,mapLinear:Hne,inverseLerp:Vne,lerp:ev,damp:Wne,pingpong:qne,smoothstep:Xne,smootherstep:Yne,randInt:Jne,randFloat:Kne,randFloatSpread:Zne,seededRandom:$ne,degToRad:ere,radToDeg:tre,isPowerOfTwo:ire,ceilPowerOfTwo:nre,floorPowerOfTwo:rre,setQuaternionFromProperEuler:sre,normalize:Bi,denormalize:el};class bn{constructor(e=0,t=0){bn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("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){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(gs(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Fh{constructor(e,t,n,r,s,o,a,l,c){Fh.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,l,c)}set(e,t,n,r,s,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],p=n[2],f=n[5],m=n[8],A=r[0],v=r[3],g=r[6],y=r[1],b=r[4],x=r[7],w=r[2],I=r[5],M=r[8];return s[0]=o*A+a*y+l*w,s[3]=o*v+a*b+l*I,s[6]=o*g+a*x+l*M,s[1]=c*A+h*y+d*w,s[4]=c*v+h*b+d*I,s[7]=c*g+h*x+d*M,s[2]=p*A+f*y+m*w,s[5]=p*v+f*b+m*I,s[8]=p*g+f*x+m*M,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*s*h+n*a*l+r*s*c-r*o*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,p=a*l-h*s,f=c*s-o*l,m=t*d+n*p+r*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/m;return e[0]=d*A,e[1]=(r*c-h*n)*A,e[2]=(a*n-r*o)*A,e[3]=p*A,e[4]=(h*t-r*l)*A,e[5]=(r*s-a*t)*A,e[6]=f*A,e[7]=(n*l-c*t)*A,e[8]=(o*t-n*s)*A,this}transpose(){let e;const 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){const 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,r,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(RB.makeScale(e,t)),this}rotate(e){return this.premultiply(RB.makeRotation(-e)),this}translate(e,t){return this.premultiply(RB.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const 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){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])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){const 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)}}const RB=new Fh;function are(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function DB(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}const PQ={};function kQ(i){i in PQ||(PQ[i]=!0,console.warn(i))}const OQ=new Fh().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),LQ=new Fh().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ww={[po]:{transfer:IB,primaries:TQ,toReference:i=>i,fromReference:i=>i},[fs]:{transfer:MQ,primaries:TQ,toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[SB]:{transfer:IB,primaries:BQ,toReference:i=>i.applyMatrix3(LQ),fromReference:i=>i.applyMatrix3(OQ)},[IQ]:{transfer:MQ,primaries:BQ,toReference:i=>i.convertSRGBToLinear().applyMatrix3(LQ),fromReference:i=>i.applyMatrix3(OQ).convertLinearToSRGB()}},lre=new Set([po,SB]),Ro={enabled:!0,_workingColorSpace:po,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!lre.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;const n=ww[e].toReference,r=ww[t].fromReference;return r(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return ww[i].primaries},getTransfer:function(i){return i===EB?IB:ww[i].transfer}};function Fm(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function PB(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Um;class cre{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Um===void 0&&(Um=DB("canvas")),Um.width=e.width,Um.height=e.height;const n=Um.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Um}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=DB("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Fm(s[o]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Fm(t[n]/255)*255):t[n]=Fm(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hre=0;class ure{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hre++}),this.uuid=$a(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(kB(r[o].image)):s.push(kB(r[o]))}else s=kB(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function kB(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?cre.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let dre=0;class ur extends _w{constructor(e=ur.DEFAULT_IMAGE,t=ur.DEFAULT_MAPPING,n=yp,r=yp,s=Y0,o=bw,a=hu,l=ha,c=ur.DEFAULT_ANISOTROPY,h=EB){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dre++}),this.uuid=$a(),this.name="",this.source=new ure(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fh,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){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)}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.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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==bQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case X0:e.x=e.x-Math.floor(e.x);break;case yp:e.x=e.x<0?0:1;break;case xB:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case X0:e.y=e.y-Math.floor(e.y);break;case yp:e.y=e.y<0?0:1;break;case xB:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}ur.DEFAULT_IMAGE=null,ur.DEFAULT_MAPPING=bQ,ur.DEFAULT_ANISOTROPY=1;class Ua{constructor(e=0,t=0,n=0,r=1){Ua.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("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){const t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const o=e.elements,a=o[0],l=o[4],c=o[8],h=o[1],d=o[5],p=o[9],f=o[2],m=o[6],A=o[10];if(Math.abs(l-h)<.01&&Math.abs(c-f)<.01&&Math.abs(p-m)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+f)<.1&&Math.abs(p+m)<.1&&Math.abs(a+d+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const g=(a+1)/2,y=(d+1)/2,b=(A+1)/2,x=(l+h)/4,w=(c+f)/4,I=(p+m)/4;return g>y&&g>b?g<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(g),r=x/n,s=w/n):y>b?y<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(y),n=x/r,s=I/r):b<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(b),n=w/s,r=I/s),this.set(n,r,s,t),this}let v=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(h-l)*(h-l));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(c-f)/v,this.z=(h-l)/v,this.w=Math.acos((a+d+A-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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 pre extends ur{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=bp,this.minFilter=bp,this.wrapR=yp,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class uu{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3];const p=s[o+0],f=s[o+1],m=s[o+2],A=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d;return}if(a===1){e[t+0]=p,e[t+1]=f,e[t+2]=m,e[t+3]=A;return}if(d!==A||l!==p||c!==f||h!==m){let v=1-a;const g=l*p+c*f+h*m+d*A,y=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){const w=Math.sqrt(b),I=Math.atan2(w,g*y);v=Math.sin(v*I)/w,a=Math.sin(a*I)/w}const x=a*y;if(l=l*v+p*x,c=c*v+f*x,h=h*v+m*x,d=d*v+A*x,v===1-a){const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,r,s,o){const a=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[o],p=s[o+1],f=s[o+2],m=s[o+3];return e[t]=a*m+h*d+l*f-c*p,e[t+1]=l*m+h*p+c*d-a*f,e[t+2]=c*m+h*f+a*p-l*d,e[t+3]=h*m-a*d-l*p-c*f,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(r/2),d=a(s/2),p=l(n/2),f=l(r/2),m=l(s/2);switch(o){case"XYZ":this._x=p*h*d+c*f*m,this._y=c*f*d-p*h*m,this._z=c*h*m+p*f*d,this._w=c*h*d-p*f*m;break;case"YXZ":this._x=p*h*d+c*f*m,this._y=c*f*d-p*h*m,this._z=c*h*m-p*f*d,this._w=c*h*d+p*f*m;break;case"ZXY":this._x=p*h*d-c*f*m,this._y=c*f*d+p*h*m,this._z=c*h*m+p*f*d,this._w=c*h*d-p*f*m;break;case"ZYX":this._x=p*h*d-c*f*m,this._y=c*f*d+p*h*m,this._z=c*h*m-p*f*d,this._w=c*h*d+p*f*m;break;case"YZX":this._x=p*h*d+c*f*m,this._y=c*f*d+p*h*m,this._z=c*h*m-p*f*d,this._w=c*h*d-p*f*m;break;case"XZY":this._x=p*h*d-c*f*m,this._y=c*f*d-p*h*m,this._z=c*h*m+p*f*d,this._w=c*h*d+p*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=n+a+d;if(p>0){const f=.5/Math.sqrt(p+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-r)*f}else if(n>a&&n>d){const f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+c)/f}else if(a>d){const f=2*Math.sqrt(1+a-n-d);this._w=(s-c)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-n-a);this._w=(o-r)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gs(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+r*c-s*l,this._y=r*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-r*a,this._w=o*h-n*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+n*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),d=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=o*d+this._w*p,this._x=n*d+this._x*p,this._y=r*d+this._y*p,this._z=s*d+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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 ue{constructor(e=0,t=0,n=0){ue.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("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(FQ.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(FQ.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*n),h=2*(a*t-s*r),d=2*(s*n-o*t);return this.x=t+l*c+o*d-a*h,this.y=n+l*h+a*c-s*d,this.z=r+l*d+s*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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){const n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-n*l,this.z=n*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return OB.copy(this).projectOnVector(e),this.sub(OB)}reflect(e){return this.sub(OB.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(gs(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const 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}}const OB=new ue,FQ=new uu;class tl{constructor(e=new ue(1/0,1/0,1/0),t=new ue(-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(il.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(il.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){const n=il.copy(t).multiplyScalar(.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(.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);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,il):il.fromBufferAttribute(s,o),il.applyMatrix4(e.matrixWorld),this.expandByPoint(il);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Cw.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Cw.copy(n.boundingBox)),Cw.applyMatrix4(e.matrixWorld),this.union(Cw)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,il),il.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(tv),Ew.subVectors(this.max,tv),Nm.subVectors(e.a,tv),Qm.subVectors(e.b,tv),zm.subVectors(e.c,tv),du.subVectors(Qm,Nm),pu.subVectors(zm,Qm),wp.subVectors(Nm,zm);let t=[0,-du.z,du.y,0,-pu.z,pu.y,0,-wp.z,wp.y,du.z,0,-du.x,pu.z,0,-pu.x,wp.z,0,-wp.x,-du.y,du.x,0,-pu.y,pu.x,0,-wp.y,wp.x,0];return!LB(t,Nm,Qm,zm,Ew)||(t=[1,0,0,0,1,0,0,0,1],!LB(t,Nm,Qm,zm,Ew))?!1:(Sw.crossVectors(du,pu),t=[Sw.x,Sw.y,Sw.z],LB(t,Nm,Qm,zm,Ew))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,il).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(il).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Kc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Kc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Kc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Kc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Kc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Kc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Kc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Kc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Kc),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)}}const Kc=[new ue,new ue,new ue,new ue,new ue,new ue,new ue,new ue],il=new ue,Cw=new tl,Nm=new ue,Qm=new ue,zm=new ue,du=new ue,pu=new ue,wp=new ue,tv=new ue,Ew=new ue,Sw=new ue,Cp=new ue;function LB(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Cp.fromArray(i,s);const a=r.x*Math.abs(Cp.x)+r.y*Math.abs(Cp.y)+r.z*Math.abs(Cp.z),l=e.dot(Cp),c=t.dot(Cp),h=n.dot(Cp);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const fre=new tl,iv=new ue,FB=new ue;class nl{constructor(e=new ue,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){const n=this.center;t!==void 0?n.copy(t):fre.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const 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){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;iv.subVectors(e,this.center);const t=iv.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(iv,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(FB.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(iv.copy(e.center).add(FB)),this.expandByPoint(iv.copy(e.center).sub(FB))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Zc=new ue,UB=new ue,Iw=new ue,fu=new ue,NB=new ue,Mw=new ue,QB=new ue;class Tw{constructor(e=new ue,t=new ue(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,Zc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Zc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zc.copy(this.origin).addScaledVector(this.direction,t),Zc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){UB.copy(e).add(t).multiplyScalar(.5),Iw.copy(t).sub(e).normalize(),fu.copy(this.origin).sub(UB);const s=e.distanceTo(t)*.5,o=-this.direction.dot(Iw),a=fu.dot(this.direction),l=-fu.dot(Iw),c=fu.lengthSq(),h=Math.abs(1-o*o);let d,p,f,m;if(h>0)if(d=o*l-a,p=o*a-l,m=s*h,d>=0)if(p>=-m)if(p<=m){const A=1/h;d*=A,p*=A,f=d*(d+o*p+2*a)+p*(o*d+p+2*l)+c}else p=s,d=Math.max(0,-(o*p+a)),f=-d*d+p*(p+2*l)+c;else p=-s,d=Math.max(0,-(o*p+a)),f=-d*d+p*(p+2*l)+c;else p<=-m?(d=Math.max(0,-(-o*s+a)),p=d>0?-s:Math.min(Math.max(-s,-l),s),f=-d*d+p*(p+2*l)+c):p<=m?(d=0,p=Math.min(Math.max(-s,-l),s),f=p*(p+2*l)+c):(d=Math.max(0,-(o*s+a)),p=d>0?s:Math.min(Math.max(-s,-l),s),f=-d*d+p*(p+2*l)+c);else p=o>0?-s:s,d=Math.max(0,-(o*p+a)),f=-d*d+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(UB).addScaledVector(Iw,p),f}intersectSphere(e,t){Zc.subVectors(e.center,this.origin);const n=Zc.dot(this.direction),r=Zc.dot(Zc)-n*n,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,r=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,r=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,o=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,o=(e.min.y-p.y)*h),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(a=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),n>l||a>r)||((a>n||n!==n)&&(n=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Zc)!==null}intersectTriangle(e,t,n,r,s){NB.subVectors(t,e),Mw.subVectors(n,e),QB.crossVectors(NB,Mw);let o=this.direction.dot(QB),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;fu.subVectors(this.origin,e);const l=a*this.direction.dot(Mw.crossVectors(fu,Mw));if(l<0)return null;const c=a*this.direction.dot(NB.cross(fu));if(c<0||l+c>o)return null;const h=-a*fu.dot(QB);return h<0?null:this.at(h/o,s)}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 ni{constructor(e,t,n,r,s,o,a,l,c,h,d,p,f,m,A,v){ni.prototype.isMatrix4=!0,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,r,s,o,a,l,c,h,d,p,f,m,A,v)}set(e,t,n,r,s,o,a,l,c,h,d,p,f,m,A,v){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=p,g[3]=f,g[7]=m,g[11]=A,g[15]=v,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 ni().fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){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){const t=this.elements,n=e.elements,r=1/jm.setFromMatrixColumn(e,0).length(),s=1/jm.setFromMatrixColumn(e,1).length(),o=1/jm.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=o*h,f=o*d,m=a*h,A=a*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+m*c,t[5]=p-A*c,t[9]=-a*l,t[2]=A-p*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*h,f=l*d,m=c*h,A=c*d;t[0]=p+A*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=f*a-m,t[6]=A+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*h,f=l*d,m=c*h,A=c*d;t[0]=p-A*a,t[4]=-o*d,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*h,t[9]=A-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*h,f=o*d,m=a*h,A=a*d;t[0]=l*h,t[4]=m*c-f,t[8]=p*c+A,t[1]=l*d,t[5]=A*c+p,t[9]=f*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,f=o*c,m=a*l,A=a*c;t[0]=l*h,t[4]=A-p*d,t[8]=m*d+f,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*d+m,t[10]=p-A*d}else if(e.order==="XZY"){const p=o*l,f=o*c,m=a*l,A=a*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+A,t[5]=o*h,t[9]=f*d-m,t[2]=m*d-f,t[6]=a*h,t[10]=A*d+p}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(mre,e,gre)}lookAt(e,t,n){const r=this.elements;return Do.subVectors(e,t),Do.lengthSq()===0&&(Do.z=1),Do.normalize(),mu.crossVectors(n,Do),mu.lengthSq()===0&&(Math.abs(n.z)===1?Do.x+=1e-4:Do.z+=1e-4,Do.normalize(),mu.crossVectors(n,Do)),mu.normalize(),Bw.crossVectors(Do,mu),r[0]=mu.x,r[4]=Bw.x,r[8]=Do.x,r[1]=mu.y,r[5]=Bw.y,r[9]=Do.y,r[2]=mu.z,r[6]=Bw.z,r[10]=Do.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],d=n[5],p=n[9],f=n[13],m=n[2],A=n[6],v=n[10],g=n[14],y=n[3],b=n[7],x=n[11],w=n[15],I=r[0],M=r[4],T=r[8],D=r[12],S=r[1],B=r[5],U=r[9],j=r[13],L=r[2],H=r[6],P=r[10],O=r[14],Q=r[3],X=r[7],Y=r[11],ne=r[15];return s[0]=o*I+a*S+l*L+c*Q,s[4]=o*M+a*B+l*H+c*X,s[8]=o*T+a*U+l*P+c*Y,s[12]=o*D+a*j+l*O+c*ne,s[1]=h*I+d*S+p*L+f*Q,s[5]=h*M+d*B+p*H+f*X,s[9]=h*T+d*U+p*P+f*Y,s[13]=h*D+d*j+p*O+f*ne,s[2]=m*I+A*S+v*L+g*Q,s[6]=m*M+A*B+v*H+g*X,s[10]=m*T+A*U+v*P+g*Y,s[14]=m*D+A*j+v*O+g*ne,s[3]=y*I+b*S+x*L+w*Q,s[7]=y*M+b*B+x*H+w*X,s[11]=y*T+b*U+x*P+w*Y,s[15]=y*D+b*j+x*O+w*ne,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],f=e[14],m=e[3],A=e[7],v=e[11],g=e[15];return m*(+s*l*d-r*c*d-s*a*p+n*c*p+r*a*f-n*l*f)+A*(+t*l*f-t*c*p+s*o*p-r*o*f+r*c*h-s*l*h)+v*(+t*c*d-t*a*f-s*o*d+n*o*f+s*a*h-n*c*h)+g*(-r*a*h-t*l*d+t*a*p+r*o*d-n*o*p+n*l*h)}transpose(){const e=this.elements;let 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){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],f=e[11],m=e[12],A=e[13],v=e[14],g=e[15],y=d*v*c-A*p*c+A*l*f-a*v*f-d*l*g+a*p*g,b=m*p*c-h*v*c-m*l*f+o*v*f+h*l*g-o*p*g,x=h*A*c-m*d*c+m*a*f-o*A*f-h*a*g+o*d*g,w=m*d*l-h*A*l-m*a*p+o*A*p+h*a*v-o*d*v,I=t*y+n*b+r*x+s*w;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/I;return e[0]=y*M,e[1]=(A*p*s-d*v*s-A*r*f+n*v*f+d*r*g-n*p*g)*M,e[2]=(a*v*s-A*l*s+A*r*c-n*v*c-a*r*g+n*l*g)*M,e[3]=(d*l*s-a*p*s-d*r*c+n*p*c+a*r*f-n*l*f)*M,e[4]=b*M,e[5]=(h*v*s-m*p*s+m*r*f-t*v*f-h*r*g+t*p*g)*M,e[6]=(m*l*s-o*v*s-m*r*c+t*v*c+o*r*g-t*l*g)*M,e[7]=(o*p*s-h*l*s+h*r*c-t*p*c-o*r*f+t*l*f)*M,e[8]=x*M,e[9]=(m*d*s-h*A*s-m*n*f+t*A*f+h*n*g-t*d*g)*M,e[10]=(o*A*s-m*a*s+m*n*c-t*A*c-o*n*g+t*a*g)*M,e[11]=(h*a*s-o*d*s-h*n*c+t*d*c+o*n*f-t*a*f)*M,e[12]=w*M,e[13]=(h*A*r-m*d*r+m*n*p-t*A*p-h*n*v+t*d*v)*M,e[14]=(m*a*r-o*A*r-m*n*l+t*A*l+o*n*v-t*a*v)*M,e[15]=(o*d*r-h*a*r+h*n*l-t*d*l-o*n*p+t*a*p)*M,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const 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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),r=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-r*l,c*l+r*a,0,c*a+r*l,h*a+n,h*l-r*o,0,c*l-r*a,h*l+r*o,s*l*l+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,r,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,d=a+a,p=s*c,f=s*h,m=s*d,A=o*h,v=o*d,g=a*d,y=l*c,b=l*h,x=l*d,w=n.x,I=n.y,M=n.z;return r[0]=(1-(A+g))*w,r[1]=(f+x)*w,r[2]=(m-b)*w,r[3]=0,r[4]=(f-x)*I,r[5]=(1-(p+g))*I,r[6]=(v+y)*I,r[7]=0,r[8]=(m+b)*M,r[9]=(v-y)*M,r[10]=(1-(p+A))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=jm.set(r[0],r[1],r[2]).length();const o=jm.set(r[4],r[5],r[6]).length(),a=jm.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],rl.copy(this);const l=1/s,c=1/o,h=1/a;return rl.elements[0]*=l,rl.elements[1]*=l,rl.elements[2]*=l,rl.elements[4]*=c,rl.elements[5]*=c,rl.elements[6]*=c,rl.elements[8]*=h,rl.elements[9]*=h,rl.elements[10]*=h,t.setFromRotationMatrix(rl),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=_p){const l=this.elements,c=2*s/(t-e),h=2*s/(n-r),d=(t+e)/(t-e),p=(n+r)/(n-r);let f,m;if(a===_p)f=-(o+s)/(o-s),m=-2*o*s/(o-s);else if(a===TB)f=-o/(o-s),m=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,o,a=_p){const l=this.elements,c=1/(t-e),h=1/(n-r),d=1/(o-s),p=(t+e)*c,f=(n+r)*h;let m,A;if(a===_p)m=(o+s)*d,A=-2*d;else if(a===TB)m=s*d,A=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=A,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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){const 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}}const jm=new ue,rl=new ni,mre=new ue(0,0,0),gre=new ue(1,1,1),mu=new ue,Bw=new ue,Do=new ue,UQ=new ni,NQ=new uu;class FA{constructor(e=0,t=0,n=0,r=FA.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],h=r[9],d=r[2],p=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(gs(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-gs(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(gs(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-gs(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(gs(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-gs(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return UQ.makeRotationFromQuaternion(e),this.setFromRotationMatrix(UQ,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return NQ.setFromEuler(this),this.setFromQuaternion(NQ,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}FA.DEFAULT_ORDER="XYZ";class Are{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}}let vre=0;const QQ=new ue,Gm=new uu,$c=new ni,Rw=new ue,nv=new ue,yre=new ue,bre=new uu,zQ=new ue(1,0,0),jQ=new ue(0,1,0),GQ=new ue(0,0,1),xre={type:"added"},_re={type:"removed"},zB={type:"childadded",child:null},jB={type:"childremoved",child:null};class Gn extends _w{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vre++}),this.uuid=$a(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Gn.DEFAULT_UP.clone();const e=new ue,t=new FA,n=new uu,r=new ue(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),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:r},modelViewMatrix:{value:new ni},normalMatrix:{value:new Fh}}),this.matrix=new ni,this.matrixWorld=new ni,this.matrixAutoUpdate=Gn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Gn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Are,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Gm.setFromAxisAngle(e,t),this.quaternion.multiply(Gm),this}rotateOnWorldAxis(e,t){return Gm.setFromAxisAngle(e,t),this.quaternion.premultiply(Gm),this}rotateX(e){return this.rotateOnAxis(zQ,e)}rotateY(e){return this.rotateOnAxis(jQ,e)}rotateZ(e){return this.rotateOnAxis(GQ,e)}translateOnAxis(e,t){return QQ.copy(e).applyQuaternion(this.quaternion),this.position.add(QQ.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(zQ,e)}translateY(e){return this.translateOnAxis(jQ,e)}translateZ(e){return this.translateOnAxis(GQ,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4($c.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Rw.copy(e):Rw.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),nv.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$c.lookAt(nv,Rw,this.up):$c.lookAt(Rw,nv,this.up),this.quaternion.setFromRotationMatrix($c),r&&($c.extractRotation(r.matrixWorld),Gm.setFromRotationMatrix($c),this.quaternion.premultiply(Gm.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(xre),zB.child=e,this.dispatchEvent(zB),zB.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(_re),jB.child=e,this.dispatchEvent(jB),jB.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),$c.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),$c.multiply(e.parent.matrixWorld)),e.applyMatrix4($c),this.add(e),e.updateWorldMatrix(!1,!0),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,r=this.children.length;n<r;n++){const s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].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(nv,e,yre),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nv,bre,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++){const a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];r.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),d=o(e.shapes),p=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),p.length>0&&(n.skeletons=p),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=r,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Gn.DEFAULT_UP=new ue(0,1,0),Gn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Gn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const sl=new ue,eh=new ue,GB=new ue,th=new ue,Hm=new ue,Vm=new ue,HQ=new ue,HB=new ue,VB=new ue,WB=new ue;class Mc{constructor(e=new ue,t=new ue,n=new ue){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),sl.subVectors(e,t),r.cross(sl);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){sl.subVectors(r,t),eh.subVectors(n,t),GB.subVectors(e,t);const o=sl.dot(sl),a=sl.dot(eh),l=sl.dot(GB),c=eh.dot(eh),h=eh.dot(GB),d=o*c-a*a;if(d===0)return s.set(0,0,0),null;const p=1/d,f=(c*l-a*h)*p,m=(o*h-a*l)*p;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,th)===null?!1:th.x>=0&&th.y>=0&&th.x+th.y<=1}static getInterpolation(e,t,n,r,s,o,a,l){return this.getBarycoord(e,t,n,r,th)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,th.x),l.addScaledVector(o,th.y),l.addScaledVector(a,th.z),l)}static isFrontFacing(e,t,n,r){return sl.subVectors(n,t),eh.subVectors(e,t),sl.cross(eh).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return sl.subVectors(this.c,this.b),eh.subVectors(this.a,this.b),sl.cross(eh).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Mc.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Mc.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Mc.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Mc.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mc.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let o,a;Hm.subVectors(r,n),Vm.subVectors(s,n),HB.subVectors(e,n);const l=Hm.dot(HB),c=Vm.dot(HB);if(l<=0&&c<=0)return t.copy(n);VB.subVectors(e,r);const h=Hm.dot(VB),d=Vm.dot(VB);if(h>=0&&d<=h)return t.copy(r);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(Hm,o);WB.subVectors(e,s);const f=Hm.dot(WB),m=Vm.dot(WB);if(m>=0&&f<=m)return t.copy(s);const A=f*c-l*m;if(A<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(n).addScaledVector(Vm,a);const v=h*m-f*d;if(v<=0&&d-h>=0&&f-m>=0)return HQ.subVectors(s,r),a=(d-h)/(d-h+(f-m)),t.copy(r).addScaledVector(HQ,a);const g=1/(v+A+p);return o=A*g,a=p*g,t.copy(n).addScaledVector(Hm,o).addScaledVector(Vm,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const VQ={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},gu={h:0,s:0,l:0},Dw={h:0,s:0,l:0};function qB(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Xn{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){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=fs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ro.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Ro.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ro.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Ro.workingColorSpace){if(e=BB(e,1),t=gs(t,0,1),n=gs(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=qB(o,s,e+1/3),this.g=qB(o,s,e),this.b=qB(o,s,e-1/3)}return Ro.toWorkingColorSpace(this,r),this}setStyle(e,t=fs){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=fs){const n=VQ[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fm(e.r),this.g=Fm(e.g),this.b=Fm(e.b),this}copyLinearToSRGB(e){return this.r=PB(e.r),this.g=PB(e.g),this.b=PB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=fs){return Ro.fromWorkingColorSpace(As.copy(this),e),Math.round(gs(As.r*255,0,255))*65536+Math.round(gs(As.g*255,0,255))*256+Math.round(gs(As.b*255,0,255))}getHexString(e=fs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ro.workingColorSpace){Ro.fromWorkingColorSpace(As.copy(this),t);const n=As.r,r=As.g,s=As.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ro.workingColorSpace){return Ro.fromWorkingColorSpace(As.copy(this),t),e.r=As.r,e.g=As.g,e.b=As.b,e}getStyle(e=fs){Ro.fromWorkingColorSpace(As.copy(this),e);const t=As.r,n=As.g,r=As.b;return e!==fs?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(gu),this.setHSL(gu.h+e,gu.s+t,gu.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(gu),e.getHSL(Dw);const n=ev(gu.h,Dw.h,t),r=ev(gu.s,Dw.s,t),s=ev(gu.l,Dw.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const As=new Xn;Xn.NAMES=VQ;let wre=0;class Au extends _w{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wre++}),this.uuid=$a(),this.name="",this.type="Material",this.blending=fQ,this.side=yw,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=gQ,this.blendDst=AQ,this.blendEquation=mQ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Xn(0,0,0),this.blendAlpha=0,this.depthFunc=vQ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=RQ,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lm,this.stencilZFail=Lm,this.stencilZPass=Lm,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==fQ&&(n.blending=this.blending),this.side!==yw&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==gQ&&(n.blendSrc=this.blendSrc),this.blendDst!==AQ&&(n.blendDst=this.blendDst),this.blendEquation!==mQ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==vQ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==RQ&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lm&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Lm&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Lm&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].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.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Wm extends Au{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Xn(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 FA,this.combine=wne,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Yn=new ue,Pw=new bn;class Po{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=MB,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xp,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return kQ("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}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 r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];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++)Pw.fromBufferAttribute(this,t),Pw.applyMatrix3(e),this.setXY(t,Pw.x,Pw.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Yn.fromBufferAttribute(this,t),Yn.applyMatrix3(e),this.setXYZ(t,Yn.x,Yn.y,Yn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Yn.fromBufferAttribute(this,t),Yn.applyMatrix4(e),this.setXYZ(t,Yn.x,Yn.y,Yn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Yn.fromBufferAttribute(this,t),Yn.applyNormalMatrix(e),this.setXYZ(t,Yn.x,Yn.y,Yn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Yn.fromBufferAttribute(this,t),Yn.transformDirection(e),this.setXYZ(t,Yn.x,Yn.y,Yn.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];return this.normalized&&(n=el(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=el(t,this.array)),t}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=el(t,this.array)),t}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=el(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=el(t,this.array)),t}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),s=Bi(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==MB&&(e.usage=this.usage),e}}class Cre extends Po{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ere extends Po{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class XB extends Po{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Sre=0;const ua=new ni,YB=new Gn,qm=new ue,ko=new tl,rv=new tl,gr=new ue;class wl extends _w{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sre++}),this.uuid=$a(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(are(e)?Ere:Cre)(e,1):this.index=e,this}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){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Fh().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ua.makeRotationFromQuaternion(e),this.applyMatrix4(ua),this}rotateX(e){return ua.makeRotationX(e),this.applyMatrix4(ua),this}rotateY(e){return ua.makeRotationY(e),this.applyMatrix4(ua),this}rotateZ(e){return ua.makeRotationZ(e),this.applyMatrix4(ua),this}translate(e,t,n){return ua.makeTranslation(e,t,n),this.applyMatrix4(ua),this}scale(e,t,n){return ua.makeScale(e,t,n),this.applyMatrix4(ua),this}lookAt(e){return YB.lookAt(e),YB.updateMatrix(),this.applyMatrix4(YB.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qm).negate(),this.translate(qm.x,qm.y,qm.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new XB(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tl);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ue(-1/0,-1/0,-1/0),new ue(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];ko.setFromBufferAttribute(s),this.morphTargetsRelative?(gr.addVectors(this.boundingBox.min,ko.min),this.boundingBox.expandByPoint(gr),gr.addVectors(this.boundingBox.max,ko.max),this.boundingBox.expandByPoint(gr)):(this.boundingBox.expandByPoint(ko.min),this.boundingBox.expandByPoint(ko.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nl);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ue,1/0);return}if(e){const n=this.boundingSphere.center;if(ko.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];rv.setFromBufferAttribute(a),this.morphTargetsRelative?(gr.addVectors(ko.min,rv.min),ko.expandByPoint(gr),gr.addVectors(ko.max,rv.max),ko.expandByPoint(gr)):(ko.expandByPoint(rv.min),ko.expandByPoint(rv.max))}ko.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)gr.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(gr));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)gr.fromBufferAttribute(a,c),l&&(qm.fromBufferAttribute(e,c),gr.add(qm)),r=Math.max(r,n.distanceToSquared(gr))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Po(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let T=0;T<n.count;T++)a[T]=new ue,l[T]=new ue;const c=new ue,h=new ue,d=new ue,p=new bn,f=new bn,m=new bn,A=new ue,v=new ue;function g(T,D,S){c.fromBufferAttribute(n,T),h.fromBufferAttribute(n,D),d.fromBufferAttribute(n,S),p.fromBufferAttribute(s,T),f.fromBufferAttribute(s,D),m.fromBufferAttribute(s,S),h.sub(c),d.sub(c),f.sub(p),m.sub(p);const B=1/(f.x*m.y-m.x*f.y);isFinite(B)&&(A.copy(h).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(B),v.copy(d).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(B),a[T].add(A),a[D].add(A),a[S].add(A),l[T].add(v),l[D].add(v),l[S].add(v))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let T=0,D=y.length;T<D;++T){const S=y[T],B=S.start,U=S.count;for(let j=B,L=B+U;j<L;j+=3)g(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const b=new ue,x=new ue,w=new ue,I=new ue;function M(T){w.fromBufferAttribute(r,T),I.copy(w);const D=a[T];b.copy(D),b.sub(w.multiplyScalar(w.dot(D))).normalize(),x.crossVectors(I,D);const S=x.dot(l[T])<0?-1:1;o.setXYZW(T,b.x,b.y,b.z,S)}for(let T=0,D=y.length;T<D;++T){const S=y[T],B=S.start,U=S.count;for(let j=B,L=B+U;j<L;j+=3)M(e.getX(j+0)),M(e.getX(j+1)),M(e.getX(j+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Po(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let p=0,f=n.count;p<f;p++)n.setXYZ(p,0,0,0);const r=new ue,s=new ue,o=new ue,a=new ue,l=new ue,c=new ue,h=new ue,d=new ue;if(e)for(let p=0,f=e.count;p<f;p+=3){const m=e.getX(p+0),A=e.getX(p+1),v=e.getX(p+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,A),o.fromBufferAttribute(t,v),h.subVectors(o,s),d.subVectors(r,s),h.cross(d),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,A),c.fromBufferAttribute(n,v),a.add(h),l.add(h),c.add(h),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(A,l.x,l.y,l.z),n.setXYZ(v,c.x,c.y,c.z)}else for(let p=0,f=t.count;p<f;p+=3)r.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),h.subVectors(o,s),d.subVectors(r,s),h.cross(d),n.setXYZ(p+0,h.x,h.y,h.z),n.setXYZ(p+1,h.x,h.y,h.z),n.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)gr.fromBufferAttribute(e,t),gr.normalize(),e.setXYZ(t,gr.x,gr.y,gr.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,d=a.normalized,p=new c.constructor(l.length*h);let f=0,m=0;for(let A=0,v=l.length;A<v;A++){a.isInterleavedBufferAttribute?f=l[A]*a.data.stride+a.offset:f=l[A]*h;for(let g=0;g<h;g++)p[m++]=c[f++]}return new Po(p,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wl,n=this.index.array,r=this.attributes;for(const a in r){const l=r[a],c=e(l,n);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,d=c.length;h<d;h++){const p=c[h],f=e(p,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let p=0,f=d.length;p<f;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const WQ=new ni,Ep=new Tw,kw=new nl,qQ=new ue,Xm=new ue,Ym=new ue,Jm=new ue,JB=new ue,Ow=new ue,Lw=new bn,Fw=new bn,Uw=new bn,XQ=new ue,YQ=new ue,JQ=new ue,Nw=new ue,Qw=new ue;class Sp extends Gn{constructor(e=new wl,t=new Wm){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=n.length;r<s;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(s&&a){Ow.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],d=s[l];h!==0&&(JB.fromBufferAttribute(d,e),o?Ow.addScaledVector(JB,h):Ow.addScaledVector(JB.sub(t),h))}t.add(Ow)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),kw.copy(n.boundingSphere),kw.applyMatrix4(s),Ep.copy(e.ray).recast(e.near),!(kw.containsPoint(Ep.origin)===!1&&(Ep.intersectSphere(kw,qQ)===null||Ep.origin.distanceToSquared(qQ)>(e.far-e.near)**2))&&(WQ.copy(s).invert(),Ep.copy(e.ray).applyMatrix4(WQ),!(n.boundingBox!==null&&Ep.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ep)))}_computeIntersections(e,t,n){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,p=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,A=p.length;m<A;m++){const v=p[m],g=o[v.materialIndex],y=Math.max(v.start,f.start),b=Math.min(a.count,Math.min(v.start+v.count,f.start+f.count));for(let x=y,w=b;x<w;x+=3){const I=a.getX(x),M=a.getX(x+1),T=a.getX(x+2);r=zw(this,g,e,n,c,h,d,I,M,T),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=v.materialIndex,t.push(r))}}else{const m=Math.max(0,f.start),A=Math.min(a.count,f.start+f.count);for(let v=m,g=A;v<g;v+=3){const y=a.getX(v),b=a.getX(v+1),x=a.getX(v+2);r=zw(this,o,e,n,c,h,d,y,b,x),r&&(r.faceIndex=Math.floor(v/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,A=p.length;m<A;m++){const v=p[m],g=o[v.materialIndex],y=Math.max(v.start,f.start),b=Math.min(l.count,Math.min(v.start+v.count,f.start+f.count));for(let x=y,w=b;x<w;x+=3){const I=x,M=x+1,T=x+2;r=zw(this,g,e,n,c,h,d,I,M,T),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=v.materialIndex,t.push(r))}}else{const m=Math.max(0,f.start),A=Math.min(l.count,f.start+f.count);for(let v=m,g=A;v<g;v+=3){const y=v,b=v+1,x=v+2;r=zw(this,o,e,n,c,h,d,y,b,x),r&&(r.faceIndex=Math.floor(v/3),t.push(r))}}}}function Ire(i,e,t,n,r,s,o,a){let l;if(e.side===xne?l=n.intersectTriangle(o,s,r,!0,a):l=n.intersectTriangle(r,s,o,e.side===yw,a),l===null)return null;Qw.copy(a),Qw.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(Qw);return c<t.near||c>t.far?null:{distance:c,point:Qw.clone(),object:i}}function zw(i,e,t,n,r,s,o,a,l,c){i.getVertexPosition(a,Xm),i.getVertexPosition(l,Ym),i.getVertexPosition(c,Jm);const h=Ire(i,e,t,n,Xm,Ym,Jm,Nw);if(h){r&&(Lw.fromBufferAttribute(r,a),Fw.fromBufferAttribute(r,l),Uw.fromBufferAttribute(r,c),h.uv=Mc.getInterpolation(Nw,Xm,Ym,Jm,Lw,Fw,Uw,new bn)),s&&(Lw.fromBufferAttribute(s,a),Fw.fromBufferAttribute(s,l),Uw.fromBufferAttribute(s,c),h.uv1=Mc.getInterpolation(Nw,Xm,Ym,Jm,Lw,Fw,Uw,new bn)),o&&(XQ.fromBufferAttribute(o,a),YQ.fromBufferAttribute(o,l),JQ.fromBufferAttribute(o,c),h.normal=Mc.getInterpolation(Nw,Xm,Ym,Jm,XQ,YQ,JQ,new ue),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new ue,materialIndex:0};Mc.getNormal(Xm,Ym,Jm,d.normal),h.face=d}return h}let KQ=class extends Gn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ni,this.projectionMatrix=new ni,this.projectionMatrixInverse=new ni,this.coordinateSystem=_p}copy(i,e){return super.copy(i,e),this.matrixWorldInverse.copy(i.matrixWorldInverse),this.projectionMatrix.copy(i.projectionMatrix),this.projectionMatrixInverse.copy(i.projectionMatrixInverse),this.coordinateSystem=i.coordinateSystem,this}getWorldDirection(i){return super.getWorldDirection(i).negate()}updateMatrixWorld(i){super.updateMatrixWorld(i),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(i,e){super.updateWorldMatrix(i,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const vu=new ue,ZQ=new bn,$Q=new bn;class KB extends KQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Z0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $0*2*Math.atan(Math.tan(Z0*.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){vu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(vu.x,vu.y).multiplyScalar(-e/vu.z),vu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vu.x,vu.y).multiplyScalar(-e/vu.z)}getViewSize(e,t){return this.getViewBounds(e,ZQ,$Q),t.subVectors($Q,ZQ)}setViewOffset(e,t,n,r,s,o){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=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Z0*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*n/c,r*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ZB=new ue,Mre=new ue,Tre=new Fh;class Km{constructor(e=new ue(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=ZB.subVectors(n,t).cross(Mre.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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){const n=e.delta(ZB),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const 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){const n=t||Tre.getNormalMatrix(e),r=this.coplanarPoint(ZB).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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)}}const Ip=new nl,jw=new ue;class ez{constructor(e=new Km,t=new Km,n=new Km,r=new Km,s=new Km,o=new Km){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=_p){const n=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],h=r[5],d=r[6],p=r[7],f=r[8],m=r[9],A=r[10],v=r[11],g=r[12],y=r[13],b=r[14],x=r[15];if(n[0].setComponents(l-s,p-c,v-f,x-g).normalize(),n[1].setComponents(l+s,p+c,v+f,x+g).normalize(),n[2].setComponents(l+o,p+h,v+m,x+y).normalize(),n[3].setComponents(l-o,p-h,v-m,x-y).normalize(),n[4].setComponents(l-a,p-d,v-A,x-b).normalize(),t===_p)n[5].setComponents(l+a,p+d,v+A,x+b).normalize();else if(t===TB)n[5].setComponents(a,d,A,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ip.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ip.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ip)}intersectsSprite(e){return Ip.center.set(0,0,0),Ip.radius=.7071067811865476,Ip.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ip)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(jw.x=r.normal.x>0?e.max.x:e.min.x,jw.y=r.normal.y>0?e.max.y:e.min.y,jw.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(jw)<0)return!1}return!0}containsPoint(e){const 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 tz extends KQ{constructor(e=-1,t=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=o,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,r,s,o){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=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Bre extends ur{constructor(e,t,n,r,s,o,a,l,c,h){if(h=h!==void 0?h:_B,h!==_B&&h!==xQ)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===_B&&(n=Tne),n===void 0&&h===xQ&&(n=Bne),super(null,r,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:bp,this.minFilter=l!==void 0?l:bp,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Rre=new Bre(1,1);Rre.compareFunction=Gne;class $B extends Gn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Dre{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=MB,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=$a()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return kQ("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}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 r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$a()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const 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){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$a()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const js=new ue;class zO{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)js.fromBufferAttribute(this,t),js.applyMatrix4(e),this.setXYZ(t,js.x,js.y,js.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)js.fromBufferAttribute(this,t),js.applyNormalMatrix(e),this.setXYZ(t,js.x,js.y,js.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)js.fromBufferAttribute(this,t),js.transformDirection(e),this.setXYZ(t,js.x,js.y,js.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=el(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Bi(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),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];return this.normalized&&(t=el(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=el(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=el(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=el(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),n=Bi(n,this.array),r=Bi(r,this.array),s=Bi(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Po(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zO(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const iz=new ue,nz=new Ua,rz=new Ua,Pre=new ue,sz=new ni,Gw=new ue,eR=new nl,oz=new ni,tR=new Tw;class kre extends Sp{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=yQ,this.bindMatrix=new ni,this.bindMatrixInverse=new ni,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new tl),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Gw),this.boundingBox.expandByPoint(Gw)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new nl),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Gw),this.boundingSphere.expandByPoint(Gw)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),eR.copy(this.boundingSphere),eR.applyMatrix4(r),e.ray.intersectsSphere(eR)!==!1&&(oz.copy(r).invert(),tR.copy(e.ray).applyMatrix4(oz),!(this.boundingBox!==null&&tR.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,tR)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ua,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===yQ?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Cne?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;nz.fromBufferAttribute(r.attributes.skinIndex,e),rz.fromBufferAttribute(r.attributes.skinWeight,e),iz.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=rz.getComponent(s);if(o!==0){const a=nz.getComponent(s);sz.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(Pre.copy(iz).applyMatrix4(sz),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class az extends Gn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class iR extends ur{constructor(e=null,t=1,n=1,r,s,o,a,l,c=bp,h=bp,d,p){super(null,o,a,l,c,h,r,s,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const lz=new ni,Ore=new ni;class jO{constructor(e=[],t=[]){this.uuid=$a(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const 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){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new ni)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new ni;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++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:Ore;lz.multiplyMatrices(a,t[s]),lz.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new jO(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new iR(t,e,e,hu,xp);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new az),this.bones.push(o),this.boneInverses.push(new ni().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const o=t[r];e.bones.push(o.uuid);const a=n[r];e.boneInverses.push(a.toArray())}return e}}class nR extends Po{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Zm=new ni,cz=new ni,Hw=[],hz=new tl,Lre=new ni,sv=new Sp,ov=new nl;class Fre extends Sp{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new nR(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Lre)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new tl),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zm),hz.copy(e.boundingBox).applyMatrix4(Zm),this.boundingBox.union(hz)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new nl),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zm),ov.copy(e.boundingSphere).applyMatrix4(Zm),this.boundingSphere.union(ov)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,o=e*s+1;for(let a=0;a<n.length;a++)n[a]=r[o+a]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(sv.geometry=this.geometry,sv.material=this.material,sv.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ov.copy(this.boundingSphere),ov.applyMatrix4(n),e.ray.intersectsSphere(ov)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Zm),cz.multiplyMatrices(n,Zm),sv.matrixWorld=cz,sv.raycast(e,Hw);for(let o=0,a=Hw.length;o<a;o++){const l=Hw[o];l.instanceId=s,l.object=this,t.push(l)}Hw.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new nR(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new iR(new Float32Array(r*this.count),r,this.count,km,xp));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<n.length;c++)o+=n[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=r*e;s[l]=a,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class uz extends Au{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Xn(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}}const dz=new ue,pz=new ue,fz=new ni,rR=new Tw,Vw=new nl;class sR extends Gn{constructor(e=new wl,t=new uz){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,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(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)dz.fromBufferAttribute(t,r-1),pz.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=dz.distanceTo(pz);e.setAttribute("lineDistance",new XB(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Vw.copy(n.boundingSphere),Vw.applyMatrix4(r),Vw.radius+=s,e.ray.intersectsSphere(Vw)===!1)return;fz.copy(r).invert(),rR.copy(e.ray).applyMatrix4(fz);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new ue,h=new ue,d=new ue,p=new ue,f=this.isLineSegments?2:1,m=n.index,A=n.attributes.position;if(m!==null){const v=Math.max(0,o.start),g=Math.min(m.count,o.start+o.count);for(let y=v,b=g-1;y<b;y+=f){const x=m.getX(y),w=m.getX(y+1);if(c.fromBufferAttribute(A,x),h.fromBufferAttribute(A,w),rR.distanceSqToSegment(c,h,p,d)>l)continue;p.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(p);I<e.near||I>e.far||t.push({distance:I,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),g=Math.min(A.count,o.start+o.count);for(let y=v,b=g-1;y<b;y+=f){if(c.fromBufferAttribute(A,y),h.fromBufferAttribute(A,y+1),rR.distanceSqToSegment(c,h,p,d)>l)continue;p.applyMatrix4(this.matrixWorld);const x=e.ray.origin.distanceTo(p);x<e.near||x>e.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=n.length;r<s;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}const mz=new ue,gz=new ue;class Ure extends sR{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)mz.fromBufferAttribute(t,r),gz.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+mz.distanceTo(gz);e.setAttribute("lineDistance",new XB(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Nre extends sR{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Az extends Au{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Xn(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}}const vz=new ni,oR=new Tw,Ww=new nl,qw=new ue;class Qre extends Gn{constructor(e=new wl,t=new Az){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,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}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ww.copy(n.boundingSphere),Ww.applyMatrix4(r),Ww.radius+=s,e.ray.intersectsSphere(Ww)===!1)return;vz.copy(r).invert(),oR.copy(e.ray).applyMatrix4(vz);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let f=d,m=p;f<m;f++){const A=c.getX(f);qw.fromBufferAttribute(h,A),yz(qw,A,l,r,e,t,this)}}else{const d=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let f=d,m=p;f<m;f++)qw.fromBufferAttribute(h,f),yz(qw,f,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=n.length;r<s;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function yz(i,e,t,n,r,s,o){const a=oR.distanceSqToPoint(i);if(a<t){const l=new ue;oR.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class Xw extends ur{constructor(e,t,n,r,s,o,a,l,c,h,d,p){super(null,o,a,l,c,h,r,s,d,p),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zre extends Xw{constructor(e,t,n,r,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=yp}}class jre extends Xw{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ene),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Yw extends Au{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Xn(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 Xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jne,this.normalScale=new bn(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 FA,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 ih extends Yw{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 bn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return gs(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Xn(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 Xn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Xn(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){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.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,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}}function Jw(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Gre(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Hre(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function bz(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=i[a+l]}return r}function xz(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=i[r++];while(s!==void 0)}class av{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let o;i:{n:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<s)break n;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=t[++n],e<r)break t}o=t.length;break i}if(!(e>=s)){const a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break t}o=n,n=0;break i}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Vre extends av{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:wQ,endingEnd:wQ}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,o=e+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case CQ:s=e,a=2*t-n;break;case EQ:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case CQ:o=e,l=2*n-t;break;case EQ:o=1,l=n+r[1]-r[0];break;default:o=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,n,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,f=this._weightNext,m=(n-t)/(r-t),A=m*m,v=A*m,g=-p*v+2*p*A-p*m,y=(1+p)*v+(-1.5-2*p)*A+(-.5+p)*m+1,b=(-1-f)*v+(1.5+f)*A+.5*m,x=f*v-f*A;for(let w=0;w!==a;++w)s[w]=g*o[h+w]+y*o[c+w]+b*o[l+w]+x*o[d+w];return s}}class Wre extends av{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(r-t),d=1-h;for(let p=0;p!==a;++p)s[p]=o[c+p]*d+o[l+p]*h;return s}}class qre extends av{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Fl{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Jw(t,this.TimeBufferType),this.values=Jw(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Jw(e.times,Array),values:Jw(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new qre(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Wre(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Vre(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case K0:t=this.InterpolantFactoryMethodDiscrete;break;case Om:t=this.InterpolantFactoryMethodLinear;break;case wB:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const 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 new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return K0;case this.InterpolantFactoryMethodLinear:return Om;case this.InterpolantFactoryMethodSmooth:return wB}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,o=r-1;for(;s!==r&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Gre(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===wB,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(r)l=!0;else{const d=a*n,p=d-n,f=d+n;for(let m=0;m!==n;++m){const A=t[d+m];if(A!==t[p+m]||A!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const d=a*n,p=o*n;for(let f=0;f!==n;++f)t[p+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Fl.prototype.TimeBufferType=Float32Array,Fl.prototype.ValueBufferType=Float32Array,Fl.prototype.DefaultInterpolation=Om;class $m extends Fl{}$m.prototype.ValueTypeName="bool",$m.prototype.ValueBufferType=Array,$m.prototype.DefaultInterpolation=K0,$m.prototype.InterpolantFactoryMethodLinear=void 0,$m.prototype.InterpolantFactoryMethodSmooth=void 0;class _z extends Fl{}_z.prototype.ValueTypeName="color";class eg extends Fl{}eg.prototype.ValueTypeName="number";class Xre extends av{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(r-t);let c=e*a;for(let h=c+a;c!==h;c+=4)uu.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Mp extends Fl{InterpolantFactoryMethodLinear(e){return new Xre(this.times,this.values,this.getValueSize(),e)}}Mp.prototype.ValueTypeName="quaternion",Mp.prototype.DefaultInterpolation=Om,Mp.prototype.InterpolantFactoryMethodSmooth=void 0;class tg extends Fl{}tg.prototype.ValueTypeName="string",tg.prototype.ValueBufferType=Array,tg.prototype.DefaultInterpolation=K0,tg.prototype.InterpolantFactoryMethodLinear=void 0,tg.prototype.InterpolantFactoryMethodSmooth=void 0;class ig extends Fl{}ig.prototype.ValueTypeName="vector";class Yre{constructor(e,t=-1,n,r=Qne){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=$a(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(Kre(n[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Fl.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const h=Hre(l);l=bz(l,1,h),c=bz(c,1,h),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new eg(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],h=c.name.match(s);if(h&&h.length>1){const d=h[1];let p=r[d];p||(r[d]=p=[]),p.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,p,f,m){if(p.length!==0){const A=[],v=[];xz(p,A,v,f),A.length!==0&&m.push(new h(d,A,v))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let f;for(f=0;f<d.length;f++)if(d[f].morphTargets)for(let m=0;m<d[f].morphTargets.length;m++)p[d[f].morphTargets[m]]=-1;for(const m in p){const A=[],v=[];for(let g=0;g!==d[f].morphTargets.length;++g){const y=d[f];A.push(y.time),v.push(y.morphTarget===m?1:0)}r.push(new eg(".morphTargetInfluence["+m+"]",A,v))}l=p.length*o}else{const p=".bones["+t[h].name+"]";n(ig,p+".position",d,"pos",r),n(Mp,p+".quaternion",d,"rot",r),n(ig,p+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.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(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Jre(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eg;case"vector":case"vector2":case"vector3":case"vector4":return ig;case"color":return _z;case"quaternion":return Mp;case"bool":case"boolean":return $m;case"string":return tg}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Kre(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Jre(i.type);if(i.times===void 0){const t=[],n=[];xz(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const yu={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Zre{constructor(e,t,n){const r=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,r.onProgress!==void 0&&r.onProgress(h,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,p=c.length;d<p;d+=2){const f=c[d],m=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}}const $re=new Zre;class bu{constructor(e){this.manager=e!==void 0?e:$re,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}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}}bu.DEFAULT_MATERIAL_NAME="__DEFAULT";const nh={};class ese extends Error{constructor(e,t){super(e),this.response=t}}class Tp extends bu{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=yu.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(nh[e]!==void 0){nh[e].push({onLoad:t,onProgress:n,onError:r});return}nh[e]=[],nh[e].push({onLoad:t,onProgress:n,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=nh[e],d=c.body.getReader(),p=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=p?parseInt(p):0,m=f!==0;let A=0;const v=new ReadableStream({start(g){y();function y(){d.read().then(({done:b,value:x})=>{if(b)g.close();else{A+=x.byteLength;const w=new ProgressEvent("progress",{lengthComputable:m,loaded:A,total:f});for(let I=0,M=h.length;I<M;I++){const T=h[I];T.onProgress&&T.onProgress(w)}g.enqueue(x),y()}})}}});return new Response(v)}else throw new ese(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(f=>p.decode(f))}}}).then(c=>{yu.add(e,c);const h=nh[e];delete nh[e];for(let d=0,p=h.length;d<p;d++){const f=h[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=nh[e];if(h===void 0)throw this.manager.itemError(e),c;delete nh[e];for(let d=0,p=h.length;d<p;d++){const f=h[d];f.onError&&f.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}}class tse extends bu{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=yu.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=DB("img");function l(){h(),yu.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(d){h(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class wz extends bu{constructor(e){super(e)}load(e,t,n,r){const s=new ur,o=new tse(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}let aR=class extends Gn{constructor(i,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Xn(i),this.intensity=e}dispose(){}copy(i,e){return super.copy(i,e),this.color.copy(i.color),this.intensity=i.intensity,this}toJSON(i){const e=super.toJSON(i);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}};const lR=new ni,Cz=new ue,Ez=new ue;class cR{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new bn(512,512),this.map=null,this.mapPass=null,this.matrix=new ni,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ez,this._frameExtents=new bn(1,1),this._viewportCount=1,this._viewports=[new Ua(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Cz.setFromMatrixPosition(e.matrixWorld),t.position.copy(Cz),Ez.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ez),t.updateMatrixWorld(),lR.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lR),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(lR)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class ise extends cR{constructor(){super(new KB(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=$0*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nse extends aR{constructor(e,t,n=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Gn.DEFAULT_UP),this.updateMatrix(),this.target=new Gn,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new ise}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}}const Sz=new ni,lv=new ue,hR=new ue;class rse extends cR{constructor(){super(new KB(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new bn(4,2),this._viewportCount=6,this._viewports=[new Ua(2,1,1,1),new Ua(0,1,1,1),new Ua(3,1,1,1),new Ua(1,1,1,1),new Ua(3,0,1,1),new Ua(1,0,1,1)],this._cubeDirections=[new ue(1,0,0),new ue(-1,0,0),new ue(0,0,1),new ue(0,0,-1),new ue(0,1,0),new ue(0,-1,0)],this._cubeUps=[new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,0,1),new ue(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),lv.setFromMatrixPosition(e.matrixWorld),n.position.copy(lv),hR.copy(n.position),hR.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(hR),n.updateMatrixWorld(),r.makeTranslation(-lv.x,-lv.y,-lv.z),Sz.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sz)}}class sse extends aR{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new rse}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class ose extends cR{constructor(){super(new tz(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ase extends aR{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Gn.DEFAULT_UP),this.updateMatrix(),this.target=new Gn,this.shadow=new ose}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class cv{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class lse extends bu{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=yu.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return yu.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),yu.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});yu.add(e,l),s.manager.itemStart(e)}}class cse{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Iz(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Iz();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Iz(){return(typeof performance>"u"?Date:performance).now()}const uR="\\[\\]\\.:\\/",hse=new RegExp("["+uR+"]","g"),dR="[^"+uR+"]",use="[^"+uR.replace("\\.","")+"]",dse=/((?:WC+[\/:])*)/.source.replace("WC",dR),pse=/(WCOD+)?/.source.replace("WCOD",use),fse=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dR),mse=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dR),gse=new RegExp("^"+dse+pse+fse+mse+"$"),Ase=["material","materials","bones","map"];class vse{constructor(e,t,n){const r=n||Ri.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Ri{constructor(e,t,n){this.path=t,this.parsedPath=n||Ri.parseTrackName(t),this.node=Ri.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ri.Composite(e,t,n):new Ri(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hse,"")}static parseTrackName(e){const t=gse.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);Ase.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("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){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const l=n(a.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Ri.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[r];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ri.Composite=vse,Ri.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ri.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ri.prototype.GetterByBindingType=[Ri.prototype._getValue_direct,Ri.prototype._getValue_array,Ri.prototype._getValue_arrayElement,Ri.prototype._getValue_toArray],Ri.prototype.SetterByBindingTypeAndVersioning=[[Ri.prototype._setValue_direct,Ri.prototype._setValue_direct_setNeedsUpdate,Ri.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_array,Ri.prototype._setValue_array_setNeedsUpdate,Ri.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_arrayElement,Ri.prototype._setValue_arrayElement_setNeedsUpdate,Ri.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_fromArray,Ri.prototype._setValue_fromArray_setNeedsUpdate,Ri.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]],typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:bB}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+bB):window.__THREE__=bB);function Mz(i,e){if(e===zne)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===CB||e===SQ){let t=i.getIndex();if(t===null){const o=[],a=i.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,r=[];if(e===CB)for(let o=1;o<=n;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=i.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}let yse=class extends bu{constructor(i){super(i),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Cse(e)}),this.register(function(e){return new Pse(e)}),this.register(function(e){return new kse(e)}),this.register(function(e){return new Ose(e)}),this.register(function(e){return new Sse(e)}),this.register(function(e){return new Ise(e)}),this.register(function(e){return new Mse(e)}),this.register(function(e){return new Tse(e)}),this.register(function(e){return new wse(e)}),this.register(function(e){return new Bse(e)}),this.register(function(e){return new Ese(e)}),this.register(function(e){return new Dse(e)}),this.register(function(e){return new Rse(e)}),this.register(function(e){return new xse(e)}),this.register(function(e){return new Lse(e)}),this.register(function(e){return new Fse(e)})}load(i,e,t,n){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const l=cv.extractUrlBase(i);s=cv.resolveURL(l,this.path)}else s=cv.extractUrlBase(i);this.manager.itemStart(i);const o=function(l){n?n(l):console.error(l),r.manager.itemError(i),r.manager.itemEnd(i)},a=new Tp(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(i,function(l){try{r.parse(l,s,function(c){e(c),r.manager.itemEnd(i)},o)}catch(c){o(c)}},t,o)}setDRACOLoader(i){return this.dracoLoader=i,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(i){return this.ktx2Loader=i,this}setMeshoptDecoder(i){return this.meshoptDecoder=i,this}register(i){return this.pluginCallbacks.indexOf(i)===-1&&this.pluginCallbacks.push(i),this}unregister(i){return this.pluginCallbacks.indexOf(i)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(i),1),this}parse(i,e,t,n){let r;const s={},o={},a=new TextDecoder;if(typeof i=="string")r=JSON.parse(i);else if(i instanceof ArrayBuffer)if(a.decode(new Uint8Array(i,0,4))===Tz){try{s[oi.KHR_BINARY_GLTF]=new Use(i)}catch(c){n&&n(c);return}r=JSON.parse(s[oi.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(i));else r=i;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Kse(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const h=this.pluginCallbacks[c](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,s[h.name]=!0}if(r.extensionsUsed)for(let c=0;c<r.extensionsUsed.length;++c){const h=r.extensionsUsed[c],d=r.extensionsRequired||[];switch(h){case oi.KHR_MATERIALS_UNLIT:s[h]=new _se;break;case oi.KHR_DRACO_MESH_COMPRESSION:s[h]=new Nse(r,this.dracoLoader);break;case oi.KHR_TEXTURE_TRANSFORM:s[h]=new Qse;break;case oi.KHR_MESH_QUANTIZATION:s[h]=new zse;break;default:d.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(t,n)}parseAsync(i,e){const t=this;return new Promise(function(n,r){t.parse(i,e,n,r)})}};function bse(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const oi={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_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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};let xse=class{constructor(i){this.parser=i,this.name=oi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const i=this.parser,e=this.parser.json.nodes||[];for(let t=0,n=e.length;t<n;t++){const r=e[t];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&i._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(i){const e=this.parser,t="light:"+i;let n=e.cache.get(t);if(n)return n;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[i];let o;const a=new Xn(16777215);s.color!==void 0&&a.setRGB(s.color[0],s.color[1],s.color[2],po);const l=s.range!==void 0?s.range:0;switch(s.type){case"directional":o=new ase(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new sse(a),o.distance=l;break;case"spot":o=new nse(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=s.spot.innerConeAngle!==void 0?s.spot.innerConeAngle:0,s.spot.outerConeAngle=s.spot.outerConeAngle!==void 0?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,_u(o,s),s.intensity!==void 0&&(o.intensity=s.intensity),o.name=e.createUniqueName(s.name||"light_"+i),n=Promise.resolve(o),e.cache.add(t,n),n}getDependency(i,e){if(i==="light")return this._loadLight(e)}createNodeAttachment(i){const e=this,t=this.parser,n=t.json.nodes[i],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(s){return t._getNodeRef(e.cache,r,s)})}},_se=class{constructor(){this.name=oi.KHR_MATERIALS_UNLIT}getMaterialType(){return Wm}extendParams(i,e,t){const n=[];i.color=new Xn(1,1,1),i.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;i.color.setRGB(s[0],s[1],s[2],po),i.opacity=s[3]}r.baseColorTexture!==void 0&&n.push(t.assignTexture(i,"map",r.baseColorTexture,fs))}return Promise.all(n)}},wse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name].emissiveStrength;return n!==void 0&&(e.emissiveIntensity=n),Promise.resolve()}},Cse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_CLEARCOAT}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(t.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new bn(o,o)}return Promise.all(r)}},Ese=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_IRIDESCENCE}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}},Sse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_SHEEN}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Xn(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;e.sheenColor.setRGB(o[0],o[1],o[2],po)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(t.assignTexture(e,"sheenColorMap",s.sheenColorTexture,fs)),s.sheenRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}},Ise=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_TRANSMISSION}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(t.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}},Mse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_VOLUME}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(t.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return e.attenuationColor=new Xn().setRGB(o[0],o[1],o[2],po),Promise.all(r)}},Tse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_IOR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name];return e.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}},Bse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_SPECULAR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(t.assignTexture(e,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return e.specularColor=new Xn().setRGB(o[0],o[1],o[2],po),s.specularColorTexture!==void 0&&r.push(t.assignTexture(e,"specularColorMap",s.specularColorTexture,fs)),Promise.all(r)}},Rse=class{constructor(i){this.parser=i,this.name=oi.EXT_MATERIALS_BUMP}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(t.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}},Dse=class{constructor(i){this.parser=i,this.name=oi.KHR_MATERIALS_ANISOTROPY}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:ih}extendMaterialParams(i,e){const t=this.parser,n=t.json.materials[i];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(t.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}},Pse=class{constructor(i){this.parser=i,this.name=oi.KHR_TEXTURE_BASISU}loadTexture(i){const e=this.parser,t=e.json,n=t.textures[i];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(i,r.source,s)}},kse=class{constructor(i){this.parser=i,this.name=oi.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(i){const e=this.name,t=this.parser,n=t.json,r=n.textures[i];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=n.images[s.source];let a=t.textureLoader;if(o.uri){const l=t.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return t.loadTextureImage(i,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(i)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(i){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){i(e.height===1)}})),this.isSupported}},Ose=class{constructor(i){this.parser=i,this.name=oi.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(i){const e=this.name,t=this.parser,n=t.json,r=n.textures[i];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],o=n.images[s.source];let a=t.textureLoader;if(o.uri){const l=t.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return t.loadTextureImage(i,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(i)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(i){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){i(e.height===1)}})),this.isSupported}},Lse=class{constructor(i){this.name=oi.EXT_MESHOPT_COMPRESSION,this.parser=i}loadBufferView(i){const e=this.parser.json,t=e.bufferViews[i];if(t.extensions&&t.extensions[this.name]){const n=t.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const a=n.byteOffset||0,l=n.byteLength||0,c=n.count,h=n.byteStride,d=new Uint8Array(o,a,l);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(c,h,d,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(c*h);return s.decodeGltfBuffer(new Uint8Array(p),c,h,d,n.mode,n.filter),p})})}else return null}},Fse=class{constructor(i){this.name=oi.EXT_MESH_GPU_INSTANCING,this.parser=i}createNodeMesh(i){const e=this.parser.json,t=e.nodes[i];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const n=e.meshes[t.mesh];for(const a of n.primitives)if(a.mode!==da.TRIANGLES&&a.mode!==da.TRIANGLE_STRIP&&a.mode!==da.TRIANGLE_FAN&&a.mode!==void 0)return null;const r=t.extensions[this.name].attributes,s=[],o={};for(const a in r)s.push(this.parser.getDependency("accessor",r[a]).then(l=>(o[a]=l,o[a])));return s.length<1?null:(s.push(this.parser.createNodeMesh(i)),Promise.all(s).then(a=>{const l=a.pop(),c=l.isGroup?l.children:[l],h=a[0].count,d=[];for(const p of c){const f=new ni,m=new ue,A=new uu,v=new ue(1,1,1),g=new Fre(p.geometry,p.material,h);for(let y=0;y<h;y++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,y),o.ROTATION&&A.fromBufferAttribute(o.ROTATION,y),o.SCALE&&v.fromBufferAttribute(o.SCALE,y),g.setMatrixAt(y,f.compose(m,A,v));for(const y in o)if(y==="_COLOR_0"){const b=o[y];g.instanceColor=new nR(b.array,b.itemSize,b.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&p.geometry.setAttribute(y,o[y]);Gn.prototype.copy.call(g,p),this.parser.assignFinalMaterial(g),d.push(g)}return l.isGroup?(l.clear(),l.add(...d),l):d[0]}))}};const Tz="glTF",hv=12,Bz={JSON:1313821514,BIN:5130562};let Use=class{constructor(i){this.name=oi.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(i,0,hv),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(i.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Tz)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-hv,r=new DataView(i,hv);let s=0;for(;s<n;){const o=r.getUint32(s,!0);s+=4;const a=r.getUint32(s,!0);if(s+=4,a===Bz.JSON){const l=new Uint8Array(i,hv+s,o);this.content=t.decode(l)}else if(a===Bz.BIN){const l=hv+s;this.body=i.slice(l,l+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Nse=class{constructor(i,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=oi.KHR_DRACO_MESH_COMPRESSION,this.json=i,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(i,e){const t=this.json,n=this.dracoLoader,r=i.extensions[this.name].bufferView,s=i.extensions[this.name].attributes,o={},a={},l={};for(const c in s){const h=fR[c]||c.toLowerCase();o[h]=s[c]}for(const c in i.attributes){const h=fR[c]||c.toLowerCase();if(s[c]!==void 0){const d=t.accessors[i.attributes[c]],p=ng[d.componentType];l[h]=p.name,a[h]=d.normalized===!0}}return e.getDependency("bufferView",r).then(function(c){return new Promise(function(h,d){n.decodeDracoFile(c,function(p){for(const f in p.attributes){const m=p.attributes[f],A=a[f];A!==void 0&&(m.normalized=A)}h(p)},o,l,po,d)})})}},Qse=class{constructor(){this.name=oi.KHR_TEXTURE_TRANSFORM}extendTexture(i,e){return(e.texCoord===void 0||e.texCoord===i.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(i=i.clone(),e.texCoord!==void 0&&(i.channel=e.texCoord),e.offset!==void 0&&i.offset.fromArray(e.offset),e.rotation!==void 0&&(i.rotation=e.rotation),e.scale!==void 0&&i.repeat.fromArray(e.scale),i.needsUpdate=!0),i}},zse=class{constructor(){this.name=oi.KHR_MESH_QUANTIZATION}},Rz=class extends av{constructor(i,e,t,n){super(i,e,t,n)}copySampleValue_(i){const e=this.resultBuffer,t=this.sampleValues,n=this.valueSize,r=i*n*3+n;for(let s=0;s!==n;s++)e[s]=t[r+s];return e}interpolate_(i,e,t,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,l=o*3,c=n-e,h=(t-e)/c,d=h*h,p=d*h,f=i*l,m=f-l,A=-2*p+3*d,v=p-d,g=1-A,y=v-d+h;for(let b=0;b!==o;b++){const x=s[m+b+o],w=s[m+b+a]*c,I=s[f+b+o],M=s[f+b]*c;r[b]=g*x+y*w+A*I+v*M}return r}};const jse=new uu;let Gse=class extends Rz{interpolate_(i,e,t,n){const r=super.interpolate_(i,e,t,n);return jse.fromArray(r).normalize().toArray(r),r}};const da={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},ng={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Dz={9728:bp,9729:Y0,9984:Sne,9985:Mne,9986:Ine,9987:bw},Pz={33071:yp,33648:xB,10497:X0},pR={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fR={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"},xu={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Hse={CUBICSPLINE:void 0,LINEAR:Om,STEP:K0},mR={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Vse(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new Yw({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:yw})),i.DefaultMaterial}function Bp(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function _u(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Wse(i,e,t){let n=!1,r=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(i);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):i.attributes.position;o.push(p)}if(r){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):i.attributes.normal;a.push(p)}if(s){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):i.attributes.color;l.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],p=c[2];return n&&(i.morphAttributes.position=h),r&&(i.morphAttributes.normal=d),s&&(i.morphAttributes.color=p),i.morphTargetsRelative=!0,i})}function qse(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xse(i){let e;const t=i.extensions&&i.extensions[oi.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+gR(t.attributes):e=i.indices+":"+gR(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+gR(i.targets[n]);return e}function gR(i){let e="";const t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function AR(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Yse(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Jse=new ni;let Kse=class{constructor(i={},e={}){this.json=i,this.extensions={},this.plugins={},this.options=e,this.cache=new bse,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 t=!1,n=!1,r=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||n&&r<98?this.textureLoader=new wz(this.options.manager):this.textureLoader=new lse(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Tp(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(i){this.extensions=i}setPlugins(i){this.plugins=i}parse(i,e){const t=this,n=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([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(s){const o={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:t,userData:{}};return Bp(r,o,n),_u(o,n),Promise.all(t._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){i(o)})}).catch(e)}_markDefs(){const i=this.json.nodes||[],e=this.json.skins||[],t=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const s=e[n].joints;for(let o=0,a=s.length;o<a;o++)i[s[o]].isBone=!0}for(let n=0,r=i.length;n<r;n++){const s=i[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(t[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(i,e){e!==void 0&&(i.refs[e]===void 0&&(i.refs[e]=i.uses[e]=0),i.refs[e]++)}_getNodeRef(i,e,t){if(i.refs[e]<=1)return t;const n=t.clone(),r=(s,o)=>{const a=this.associations.get(s);a!=null&&this.associations.set(o,a);for(const[l,c]of s.children.entries())r(c,o.children[l])};return r(t,n),n.name+="_instance_"+i.uses[e]++,n}_invokeOne(i){const e=Object.values(this.plugins);e.push(this);for(let t=0;t<e.length;t++){const n=i(e[t]);if(n)return n}return null}_invokeAll(i){const e=Object.values(this.plugins);e.unshift(this);const t=[];for(let n=0;n<e.length;n++){const r=i(e[n]);r&&t.push(r)}return t}getDependency(i,e){const t=i+":"+e;let n=this.cache.get(t);if(!n){switch(i){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(i,e)}),!n)throw new Error("Unknown type: "+i);break}this.cache.add(t,n)}return n}getDependencies(i){let e=this.cache.get(i);if(!e){const t=this,n=this.json[i+(i==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(r,s){return t.getDependency(i,s)})),this.cache.add(i,e)}return e}loadBuffer(i){const e=this.json.buffers[i],t=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&i===0)return Promise.resolve(this.extensions[oi.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,s){t.load(cv.resolveURL(e.uri,n.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(i){const e=this.json.bufferViews[i];return this.getDependency("buffer",e.buffer).then(function(t){const n=e.byteLength||0,r=e.byteOffset||0;return t.slice(r,r+n)})}loadAccessor(i){const e=this,t=this.json,n=this.json.accessors[i];if(n.bufferView===void 0&&n.sparse===void 0){const s=pR[n.type],o=ng[n.componentType],a=n.normalized===!0,l=new o(n.count*s);return Promise.resolve(new Po(l,s,a))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(s){const o=s[0],a=pR[n.type],l=ng[n.componentType],c=l.BYTES_PER_ELEMENT,h=c*a,d=n.byteOffset||0,p=n.bufferView!==void 0?t.bufferViews[n.bufferView].byteStride:void 0,f=n.normalized===!0;let m,A;if(p&&p!==h){const v=Math.floor(d/p),g="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+v+":"+n.count;let y=e.cache.get(g);y||(m=new l(o,v*p,n.count*p/c),y=new Dre(m,p/c),e.cache.add(g,y)),A=new zO(y,a,d%p/c,f)}else o===null?m=new l(n.count*a):m=new l(o,d,n.count*a),A=new Po(m,a,f);if(n.sparse!==void 0){const v=pR.SCALAR,g=ng[n.sparse.indices.componentType],y=n.sparse.indices.byteOffset||0,b=n.sparse.values.byteOffset||0,x=new g(s[1],y,n.sparse.count*v),w=new l(s[2],b,n.sparse.count*a);o!==null&&(A=new Po(A.array.slice(),A.itemSize,A.normalized));for(let I=0,M=x.length;I<M;I++){const T=x[I];if(A.setX(T,w[I*a]),a>=2&&A.setY(T,w[I*a+1]),a>=3&&A.setZ(T,w[I*a+2]),a>=4&&A.setW(T,w[I*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return A})}loadTexture(i){const e=this.json,t=this.options,n=e.textures[i].source,r=e.images[n];let s=this.textureLoader;if(r.uri){const o=t.manager.getHandler(r.uri);o!==null&&(s=o)}return this.loadTextureImage(i,n,s)}loadTextureImage(i,e,t){const n=this,r=this.json,s=r.textures[i],o=r.images[e],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(e,t).then(function(c){c.flipY=!1,c.name=s.name||o.name||"",c.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(c.name=o.uri);const h=(r.samplers||{})[s.sampler]||{};return c.magFilter=Dz[h.magFilter]||Y0,c.minFilter=Dz[h.minFilter]||bw,c.wrapS=Pz[h.wrapS]||X0,c.wrapT=Pz[h.wrapT]||X0,c.anisotropy=4,n.associations.set(c,{textures:i}),c}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(i,e){const t=this,n=this.json,r=this.options;if(this.sourceCache[i]!==void 0)return this.sourceCache[i].then(h=>h.clone());const s=n.images[i],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(s.bufferView!==void 0)a=t.getDependency("bufferView",s.bufferView).then(function(h){l=!0;const d=new Blob([h],{type:s.mimeType});return a=o.createObjectURL(d),a});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+i+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(h){return new Promise(function(d,p){let f=d;e.isImageBitmapLoader===!0&&(f=function(m){const A=new ur(m);A.needsUpdate=!0,d(A)}),e.load(cv.resolveURL(h,r.path),f,void 0,p)})}).then(function(h){return l===!0&&o.revokeObjectURL(a),h.userData.mimeType=s.mimeType||Yse(s.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),h});return this.sourceCache[i]=c,c}assignTexture(i,e,t,n){const r=this;return this.getDependency("texture",t.index).then(function(s){if(!s)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(s=s.clone(),s.channel=t.texCoord),r.extensions[oi.KHR_TEXTURE_TRANSFORM]){const o=t.extensions!==void 0?t.extensions[oi.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=r.associations.get(s);s=r.extensions[oi.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}return n!==void 0&&(s.colorSpace=n),i[e]=s,s})}assignFinalMaterial(i){const e=i.geometry;let t=i.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(i.isPoints){const o="PointsMaterial:"+t.uuid;let a=this.cache.get(o);a||(a=new Az,Au.prototype.copy.call(a,t),a.color.copy(t.color),a.map=t.map,a.sizeAttenuation=!1,this.cache.add(o,a)),t=a}else if(i.isLine){const o="LineBasicMaterial:"+t.uuid;let a=this.cache.get(o);a||(a=new uz,Au.prototype.copy.call(a,t),a.color.copy(t.color),a.map=t.map,this.cache.add(o,a)),t=a}if(n||r||s){let o="ClonedMaterial:"+t.uuid+":";n&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let a=this.cache.get(o);a||(a=t.clone(),r&&(a.vertexColors=!0),s&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(o,a),this.associations.set(a,this.associations.get(t))),t=a}i.material=t}getMaterialType(){return Yw}loadMaterial(i){const e=this,t=this.json,n=this.extensions,r=t.materials[i];let s;const o={},a=r.extensions||{},l=[];if(a[oi.KHR_MATERIALS_UNLIT]){const h=n[oi.KHR_MATERIALS_UNLIT];s=h.getMaterialType(),l.push(h.extendParams(o,r,e))}else{const h=r.pbrMetallicRoughness||{};if(o.color=new Xn(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],po),o.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(e.assignTexture(o,"map",h.baseColorTexture,fs)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(i)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(i,o)})))}r.doubleSided===!0&&(o.side=_ne);const c=r.alphaMode||mR.OPAQUE;if(c===mR.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===mR.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==Wm&&(l.push(e.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new bn(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;o.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&s!==Wm&&(l.push(e.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==Wm){const h=r.emissiveFactor;o.emissive=new Xn().setRGB(h[0],h[1],h[2],po)}return r.emissiveTexture!==void 0&&s!==Wm&&l.push(e.assignTexture(o,"emissiveMap",r.emissiveTexture,fs)),Promise.all(l).then(function(){const h=new s(o);return r.name&&(h.name=r.name),_u(h,r),e.associations.set(h,{materials:i}),r.extensions&&Bp(n,h,r),h})}createUniqueName(i){const e=Ri.sanitizeNodeName(i||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(i){const e=this,t=this.extensions,n=this.primitiveCache;function r(o){return t[oi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,e).then(function(a){return kz(a,o,e)})}const s=[];for(let o=0,a=i.length;o<a;o++){const l=i[o],c=Xse(l),h=n[c];if(h)s.push(h.promise);else{let d;l.extensions&&l.extensions[oi.KHR_DRACO_MESH_COMPRESSION]?d=r(l):d=kz(new wl,l,e),n[c]={primitive:l,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(i){const e=this,t=this.json,n=this.extensions,r=t.meshes[i],s=r.primitives,o=[];for(let a=0,l=s.length;a<l;a++){const c=s[a].material===void 0?Vse(this.cache):this.getDependency("material",s[a].material);o.push(c)}return o.push(e.loadGeometries(s)),Promise.all(o).then(function(a){const l=a.slice(0,a.length-1),c=a[a.length-1],h=[];for(let p=0,f=c.length;p<f;p++){const m=c[p],A=s[p];let v;const g=l[p];if(A.mode===da.TRIANGLES||A.mode===da.TRIANGLE_STRIP||A.mode===da.TRIANGLE_FAN||A.mode===void 0)v=r.isSkinnedMesh===!0?new kre(m,g):new Sp(m,g),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),A.mode===da.TRIANGLE_STRIP?v.geometry=Mz(v.geometry,SQ):A.mode===da.TRIANGLE_FAN&&(v.geometry=Mz(v.geometry,CB));else if(A.mode===da.LINES)v=new Ure(m,g);else if(A.mode===da.LINE_STRIP)v=new sR(m,g);else if(A.mode===da.LINE_LOOP)v=new Nre(m,g);else if(A.mode===da.POINTS)v=new Qre(m,g);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(v.geometry.morphAttributes).length>0&&qse(v,r),v.name=e.createUniqueName(r.name||"mesh_"+i),_u(v,r),A.extensions&&Bp(n,v,A),e.assignFinalMaterial(v),h.push(v)}for(let p=0,f=h.length;p<f;p++)e.associations.set(h[p],{meshes:i,primitives:p});if(h.length===1)return r.extensions&&Bp(n,h[0],r),h[0];const d=new $B;r.extensions&&Bp(n,d,r),e.associations.set(d,{meshes:i});for(let p=0,f=h.length;p<f;p++)d.add(h[p]);return d})}loadCamera(i){let e;const t=this.json.cameras[i],n=t[t.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?e=new KB(ore.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):t.type==="orthographic"&&(e=new tz(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),t.name&&(e.name=this.createUniqueName(t.name)),_u(e,t),Promise.resolve(e)}loadSkin(i){const e=this.json.skins[i],t=[];for(let n=0,r=e.joints.length;n<r;n++)t.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",e.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(n){const r=n.pop(),s=n,o=[],a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l];if(h){o.push(h);const d=new ni;r!==null&&d.fromArray(r.array,l*16),a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new jO(o,a)})}loadAnimation(i){const e=this.json,t=this,n=e.animations[i],r=n.name?n.name:"animation_"+i,s=[],o=[],a=[],l=[],c=[];let h=0,d=n.channels.length;for(h=0,d=n.channels.length;h<d;h++){const p=n.channels[h],f=n.samplers[p.sampler],m=p.target,A=m.node,v=n.parameters!==void 0?n.parameters[f.input]:f.input,g=n.parameters!==void 0?n.parameters[f.output]:f.output;m.node!==void 0&&(s.push(this.getDependency("node",A)),o.push(this.getDependency("accessor",v)),a.push(this.getDependency("accessor",g)),l.push(f),c.push(m))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],y=[];for(h=0,d=f.length;h<d;h++){const b=f[h],x=m[h],w=A[h],I=v[h],M=g[h];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const T=t._createAnimationTracks(b,x,w,I,M);if(T)for(let D=0;D<T.length;D++)y.push(T[D])}return new Yre(r,void 0,y)})}createNodeMesh(i){const e=this.json,t=this,n=e.nodes[i];return n.mesh===void 0?null:t.getDependency("mesh",n.mesh).then(function(r){const s=t._getNodeRef(t.meshCache,n.mesh,r);return n.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let a=0,l=n.weights.length;a<l;a++)o.morphTargetInfluences[a]=n.weights[a]}),s})}loadNode(i){const e=this.json,t=this,n=e.nodes[i],r=t._loadNodeShallow(i),s=[],o=n.children||[];for(let l=0,c=o.length;l<c;l++)s.push(t.getDependency("node",o[l]));const a=n.skin===void 0?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(s),a]).then(function(l){const c=l[0],h=l[1],d=l[2];d!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(d,Jse)});for(let p=0,f=h.length;p<f;p++)c.add(h[p]);return c})}_loadNodeShallow(i){const e=this.json,t=this.extensions,n=this;if(this.nodeCache[i]!==void 0)return this.nodeCache[i];const r=e.nodes[i],s=r.name?n.createUniqueName(r.name):"",o=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(i)});return a&&o.push(a),r.camera!==void 0&&o.push(n.getDependency("camera",r.camera).then(function(l){return n._getNodeRef(n.cameraCache,r.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(i)}).forEach(function(l){o.push(l)}),this.nodeCache[i]=Promise.all(o).then(function(l){let c;if(r.isBone===!0?c=new az:l.length>1?c=new $B:l.length===1?c=l[0]:c=new Gn,c!==l[0])for(let h=0,d=l.length;h<d;h++)c.add(l[h]);if(r.name&&(c.userData.name=r.name,c.name=s),_u(c,r),r.extensions&&Bp(t,c,r),r.matrix!==void 0){const h=new ni;h.fromArray(r.matrix),c.applyMatrix4(h)}else r.translation!==void 0&&c.position.fromArray(r.translation),r.rotation!==void 0&&c.quaternion.fromArray(r.rotation),r.scale!==void 0&&c.scale.fromArray(r.scale);return n.associations.has(c)||n.associations.set(c,{}),n.associations.get(c).nodes=i,c}),this.nodeCache[i]}loadScene(i){const e=this.extensions,t=this.json.scenes[i],n=this,r=new $B;t.name&&(r.name=n.createUniqueName(t.name)),_u(r,t),t.extensions&&Bp(e,r,t);const s=t.nodes||[],o=[];for(let a=0,l=s.length;a<l;a++)o.push(n.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let c=0,h=a.length;c<h;c++)r.add(a[c]);const l=c=>{const h=new Map;for(const[d,p]of n.associations)(d instanceof Au||d instanceof ur)&&h.set(d,p);return c.traverse(d=>{const p=n.associations.get(d);p!=null&&h.set(d,p)}),h};return n.associations=l(r),r})}_createAnimationTracks(i,e,t,n,r){const s=[],o=i.name?i.name:i.uuid,a=[];xu[r.path]===xu.weights?i.traverse(function(d){d.morphTargetInfluences&&a.push(d.name?d.name:d.uuid)}):a.push(o);let l;switch(xu[r.path]){case xu.weights:l=eg;break;case xu.rotation:l=Mp;break;case xu.position:case xu.scale:l=ig;break;default:switch(t.itemSize){case 1:l=eg;break;case 2:case 3:default:l=ig;break}break}const c=n.interpolation!==void 0?Hse[n.interpolation]:Om,h=this._getArrayFromAccessor(t);for(let d=0,p=a.length;d<p;d++){const f=new l(a[d]+"."+xu[r.path],e.array,h,c);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),s.push(f)}return s}_getArrayFromAccessor(i){let e=i.array;if(i.normalized){const t=AR(e.constructor),n=new Float32Array(e.length);for(let r=0,s=e.length;r<s;r++)n[r]=e[r]*t;e=n}return e}_createCubicSplineTrackInterpolant(i){i.createInterpolant=function(e){const t=this instanceof Mp?Gse:Rz;return new t(this.times,this.values,this.getValueSize()/3,e)},i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Zse(i,e,t){const n=e.attributes,r=new tl;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(r.set(new ue(l[0],l[1],l[2]),new ue(c[0],c[1],c[2])),a.normalized){const h=AR(ng[a.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new ue,l=new ue;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const A=AR(ng[p.componentType]);l.multiplyScalar(A)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}i.boundingBox=r;const o=new nl;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=o}function kz(i,e,t){const n=e.attributes,r=[];function s(o,a){return t.getDependency("accessor",o).then(function(l){i.setAttribute(a,l)})}for(const o in n){const a=fR[o]||o.toLowerCase();a in i.attributes||r.push(s(n[o],a))}if(e.indices!==void 0&&!i.index){const o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});r.push(o)}return Ro.workingColorSpace!==po&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ro.workingColorSpace}" not supported.`),_u(i,e),Zse(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Wse(i,e.targets,t):i})}var $se=function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var r=WebAssembly.validate(t)?e:i,s,o=WebAssembly.instantiate(a(r),{}).then(function(g){s=g.instance,s.exports.__wasm_call_ctors()});function a(g){for(var y=new Uint8Array(g.length),b=0;b<g.length;++b){var x=g.charCodeAt(b);y[b]=x>96?x-97:x>64?x-39:x+4}for(var w=0,b=0;b<g.length;++b)y[w++]=y[b]<60?n[y[b]]:(y[b]-60)*64+y[++b];return y.buffer.slice(0,w)}function l(g,y,b,x,w,I){var M=s.exports.sbrk,T=b+3&-4,D=M(T*x),S=M(w.length),B=new Uint8Array(s.exports.memory.buffer);B.set(w,S);var U=g(D,b,x,S,w.length);if(U==0&&I&&I(D,T,x),y.set(B.subarray(D,D+b*x)),M(D-M(0)),U!=0)throw new Error("Malformed buffer data: "+U)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],p=0;function f(g){var y={object:new Worker(g),pending:0,requests:{}};return y.object.onmessage=function(b){var x=b.data;y.pending-=x.count,y.requests[x.id][x.action](x.value),delete y.requests[x.id]},y}function m(g){for(var y="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(r))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+l.toString()+v.toString(),b=new Blob([y],{type:"text/javascript"}),x=URL.createObjectURL(b),w=0;w<g;++w)d[w]=f(x);URL.revokeObjectURL(x)}function A(g,y,b,x,w){for(var I=d[0],M=1;M<d.length;++M)d[M].pending<I.pending&&(I=d[M]);return new Promise(function(T,D){var S=new Uint8Array(b),B=p++;I.pending+=g,I.requests[B]={resolve:T,reject:D},I.object.postMessage({id:B,count:g,size:y,source:S,mode:x,filter:w},[S.buffer])})}function v(g){o.then(function(){var y=g.data;try{var b=new Uint8Array(y.count*y.size);l(s.exports[y.mode],b,y.count,y.size,y.source,s.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:b},[b.buffer])}catch(x){self.postMessage({id:y.id,count:y.count,action:"reject",value:x})}})}return{ready:o,supported:!0,useWorkers:function(g){m(g)},decodeVertexBuffer:function(g,y,b,x,w){l(s.exports.meshopt_decodeVertexBuffer,g,y,b,x,s.exports[c[w]])},decodeIndexBuffer:function(g,y,b,x){l(s.exports.meshopt_decodeIndexBuffer,g,y,b,x)},decodeIndexSequence:function(g,y,b,x){l(s.exports.meshopt_decodeIndexSequence,g,y,b,x)},decodeGltfBuffer:function(g,y,b,x,w,I){l(s.exports[h[w]],g,y,b,x,s.exports[c[I]])},decodeGltfBufferAsync:function(g,y,b,x,w){return d.length>0?A(g,y,b,h[x],c[w]):o.then(function(){var I=new Uint8Array(g*y);return l(s.exports[h[x]],I,g,y,b,s.exports[c[w]]),I})}}}();const vR=new WeakMap;let eoe=class extends bu{constructor(i){super(i),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(i){return this.decoderPath=i,this}setDecoderConfig(i){return this.decoderConfig=i,this}setWorkerLimit(i){return this.workerLimit=i,this}load(i,e,t,n){const r=new Tp(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(i,s=>{this.parse(s,e,n)},t,n)}parse(i,e,t=()=>{}){this.decodeDracoFile(i,e,null,null,fs).catch(t)}decodeDracoFile(i,e,t,n,r=po,s=()=>{}){const o={attributeIDs:t||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!t,vertexColorSpace:r};return this.decodeGeometry(i,o).then(e).catch(s)}decodeGeometry(i,e){const t=JSON.stringify(e);if(vR.has(i)){const a=vR.get(i);if(a.key===t)return a.promise;if(i.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,s=i.byteLength,o=this._getWorker(r,s).then(a=>(n=a,new Promise((l,c)=>{n._callbacks[r]={resolve:l,reject:c},n.postMessage({type:"decode",id:r,taskConfig:e,buffer:i},[i])}))).then(a=>this._createGeometry(a.geometry));return o.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),vR.set(i,{key:t,promise:o}),o}_createGeometry(i){const e=new wl;i.index&&e.setIndex(new Po(i.index.array,1));for(let t=0;t<i.attributes.length;t++){const n=i.attributes[t],r=n.name,s=n.array,o=n.itemSize,a=new Po(s,o);r==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(s instanceof Float32Array)),e.setAttribute(r,a)}return e}_assignVertexColorSpace(i,e){if(e!==fs)return;const t=new Xn;for(let n=0,r=i.count;n<r;n++)t.fromBufferAttribute(i,n).convertSRGBToLinear(),i.setXYZ(n,t.r,t.g,t.b)}_loadLibrary(i,e){const t=new Tp(this.manager);return t.setPath(this.decoderPath),t.setResponseType(e),t.setWithCredentials(this.withCredentials),new Promise((n,r)=>{t.load(i,n,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const i=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return i?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(t=>{const n=t[0];i||(this.decoderConfig.wasmBinary=t[1]);const r=toe.toString(),s=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
4417
4417
  `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(i,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(r){const s=r.data;switch(s.type){case"decode":n._callbacks[s.id].resolve(s);break;case"error":n._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,r){return n._taskLoad>r._taskLoad?-1:1});const t=this.workerPool[this.workerPool.length-1];return t._taskCosts[i]=e,t._taskLoad+=e,t})}_releaseTask(i,e){i._taskLoad-=i._taskCosts[e],delete i._callbacks[e],delete i._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(i=>i._taskLoad))}dispose(){for(let i=0;i<this.workerPool.length;++i)this.workerPool[i].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function toe(){let i,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":i=a.decoderConfig,e=new Promise(function(h){i.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(i)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,p=new d.Decoder;try{const f=t(d,p,new Int8Array(l),c),m=f.attributes.map(A=>A.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{d.destroy(p)}});break}};function t(o,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let p,f;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)p=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,p);else if(m===o.POINT_CLOUD)p=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const A={index:null,attributes:[]};for(const v in h){const g=self[d[v]];let y,b;if(c.useUniqueIDs)b=h[v],y=a.GetAttributeByUniqueId(p,b);else{if(b=a.GetAttributeId(p,o[h[v]]),b===-1)continue;y=a.GetAttribute(p,b)}const x=r(o,a,p,v,g,y);v==="color"&&(x.vertexColorSpace=c.vertexColorSpace),A.attributes.push(x)}return m===o.TRIANGULAR_MESH&&(A.index=n(o,a,p)),o.destroy(p),A}function n(o,a,l){const c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);const p=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:p,itemSize:1}}function r(o,a,l,c,h,d){const p=d.num_components(),f=l.num_points()*p,m=f*h.BYTES_PER_ELEMENT,A=s(o,h),v=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,d,A,m,v);const g=new h(o.HEAPF32.buffer,v,f).slice();return o._free(v),{name:c,array:g,itemSize:p}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}let ioe=class{constructor(i=4){this.pool=i,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(i){if(!this.workers[i]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,i)),this.workers[i]=e}}_getIdleWorker(){for(let i=0;i<this.pool;i++)if(!(this.workerStatus&1<<i))return i;return-1}_onMessage(i,e){const t=this.workersResolve[i];if(t&&t(e),this.queue.length){const{resolve:n,msg:r,transfer:s}=this.queue.shift();this.workersResolve[i]=n,this.workers[i].postMessage(r,s)}else this.workerStatus^=1<<i}setWorkerCreator(i){this.workerCreator=i}setWorkerLimit(i){this.pool=i}postMessage(i,e){return new Promise(t=>{const n=this._getIdleWorker();n!==-1?(this._initWorker(n),this.workerStatus|=1<<n,this.workersResolve[n]=t,this.workers[n].postMessage(i,e)):this.queue.push({resolve:t,msg:i,transfer:e})})}dispose(){this.workers.forEach(i=>i.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}};const noe=0,Oz=2,roe=1,Lz=2,soe=0,ooe=1,aoe=10,loe=0,Fz=9,Uz=15,Nz=16,Qz=22,zz=37,jz=43,Gz=76,Hz=83,Vz=97,Wz=100,qz=103,Xz=109,Yz=165,Jz=166;let coe=class{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}},uv=class{constructor(i,e,t,n){this._dataView=new DataView(i.buffer,i.byteOffset+e,t),this._littleEndian=n,this._offset=0}_nextUint8(){const i=this._dataView.getUint8(this._offset);return this._offset+=1,i}_nextUint16(){const i=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,i}_nextUint32(){const i=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,i}_nextUint64(){const i=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,i}_nextInt32(){const i=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,i}_skip(i){return this._offset+=i,this}_scan(i,e=0){const t=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==e&&n<i;)n++,this._offset++;return n<i&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+t,n)}};const Gs=[171,75,84,88,32,50,48,187,13,10,26,10];function Kz(i){return typeof TextDecoder<"u"?new TextDecoder().decode(i):Buffer.from(i).toString("utf8")}function hoe(i){const e=new Uint8Array(i.buffer,i.byteOffset,Gs.length);if(e[0]!==Gs[0]||e[1]!==Gs[1]||e[2]!==Gs[2]||e[3]!==Gs[3]||e[4]!==Gs[4]||e[5]!==Gs[5]||e[6]!==Gs[6]||e[7]!==Gs[7]||e[8]!==Gs[8]||e[9]!==Gs[9]||e[10]!==Gs[10]||e[11]!==Gs[11])throw new Error("Missing KTX 2.0 identifier.");const t=new coe,n=17*Uint32Array.BYTES_PER_ELEMENT,r=new uv(i,Gs.length,n,!0);t.vkFormat=r._nextUint32(),t.typeSize=r._nextUint32(),t.pixelWidth=r._nextUint32(),t.pixelHeight=r._nextUint32(),t.pixelDepth=r._nextUint32(),t.layerCount=r._nextUint32(),t.faceCount=r._nextUint32();const s=r._nextUint32();t.supercompressionScheme=r._nextUint32();const o=r._nextUint32(),a=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),d=r._nextUint64(),p=new uv(i,Gs.length+n,3*s*8,!0);for(let O=0;O<s;O++)t.levels.push({levelData:new Uint8Array(i.buffer,i.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const f=new uv(i,o,a,!0),m={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},A=(m.descriptorBlockSize/4-6)/4;for(let O=0;O<A;O++){const Q={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelType:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&Q.channelType?(Q.sampleLower=f._nextInt32(),Q.sampleUpper=f._nextInt32()):(Q.sampleLower=f._nextUint32(),Q.sampleUpper=f._nextUint32()),m.samples[O]=Q}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(m);const v=new uv(i,l,c,!0);for(;v._offset<c;){const O=v._nextUint32(),Q=v._scan(O),X=Kz(Q),Y=v._scan(O-Q.byteLength);t.keyValue[X]=X.match(/^ktx/i)?Kz(Y):Y,v._offset%4&&v._skip(4-v._offset%4)}if(d<=0)return t;const g=new uv(i,h,d,!0),y=g._nextUint16(),b=g._nextUint16(),x=g._nextUint32(),w=g._nextUint32(),I=g._nextUint32(),M=g._nextUint32(),T=[];for(let O=0;O<s;O++)T.push({imageFlags:g._nextUint32(),rgbSliceByteOffset:g._nextUint32(),rgbSliceByteLength:g._nextUint32(),alphaSliceByteOffset:g._nextUint32(),alphaSliceByteLength:g._nextUint32()});const D=h+g._offset,S=D+x,B=S+w,U=B+I,j=new Uint8Array(i.buffer,i.byteOffset+D,x),L=new Uint8Array(i.buffer,i.byteOffset+S,w),H=new Uint8Array(i.buffer,i.byteOffset+B,I),P=new Uint8Array(i.buffer,i.byteOffset+U,M);return t.globalData={endpointCount:y,selectorCount:b,imageDescs:T,endpointsData:j,selectorsData:L,tablesData:H,extendedData:P},t}let yR,rh,bR;const xR={env:{emscripten_notify_memory_growth:function(i){bR=new Uint8Array(rh.exports.memory.buffer)}}};let uoe=class{init(){return yR||(yR=typeof fetch<"u"?fetch("data:application/wasm;base64,"+Zz).then(i=>i.arrayBuffer()).then(i=>WebAssembly.instantiate(i,xR)).then(this._init):WebAssembly.instantiate(Buffer.from(Zz,"base64"),xR).then(this._init),yR)}_init(i){rh=i.instance,xR.env.emscripten_notify_memory_growth(0)}decode(i,e=0){if(!rh)throw new Error("ZSTDDecoder: Await .init() before decoding.");const t=i.byteLength,n=rh.exports.malloc(t);bR.set(i,n),e=e||Number(rh.exports.ZSTD_findDecompressedSize(n,t));const r=rh.exports.malloc(e),s=rh.exports.ZSTD_decompress(r,e,n,t),o=bR.slice(r,r+s);return rh.exports.free(n),rh.exports.free(r),o}};const Zz="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",_R=new WeakMap;let wR=0,CR,dv=class Yb extends bu{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new ioe,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync("texture-compression-astc"),etc1Supported:await e.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await e.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await e.hasFeatureAsync("texture-compression-bc"),bptcSupported:await e.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await e.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:e.hasFeature("texture-compression-bptc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new Tp(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new Tp(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const r=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,r]).then(([s,o])=>{const a=Yb.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(Yb.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Yb.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Yb.BasisFormat),"/* basis_transcoder.js */",s,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
4418
- `);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),wR>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),wR++}return this.transcoderPending}load(e,t,n,r){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const s=new Tp(this.manager);s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials),s.load(e,o=>{if(_R.has(o))return _R.get(o).promise.then(t).catch(r);this._createTexture(o).then(a=>t?t(a):null).catch(r)},n,r)}_createTextureFrom(e,t){const{faces:n,width:r,height:s,format:o,type:a,error:l,dfdFlags:c}=e;if(a==="error")return Promise.reject(l);let h;if(t.faceCount===6)h=new jre(n,o,ha);else{const d=n[0].mipmaps;h=t.layerCount>1?new zre(d,r,s,t.layerCount,o,ha):new Xw(d,r,s,o,ha)}return h.minFilter=n[0].mipmaps.length===1?Y0:bw,h.magFilter=Y0,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=$z(t),h.premultiplyAlpha=!!(c&roe),h}async _createTexture(e,t={}){const n=hoe(new Uint8Array(e));if(n.vkFormat!==loe)return poe(n);const r=t,s=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e])).then(o=>this._createTextureFrom(o.data,n));return _R.set(e,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),wR--,this}};dv.BasisFormat={ETC1S:0,UASTC_4x4:1},dv.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},dv.EngineFormat={RGBAFormat:hu,RGBA_ASTC_4x4_Format:Une,RGBA_BPTC_Format:Nne,RGBA_ETC2_EAC_Format:Fne,RGBA_PVRTC_4BPPV1_Format:kne,RGBA_S3TC_DXT5_Format:Dne,RGB_ETC1_Format:One,RGB_ETC2_Format:Lne,RGB_PVRTC_4BPPV1_Format:Pne,RGB_S3TC_DXT1_Format:Rne},dv.BasisWorker=function(){let i,e,t;const n=_EngineFormat,r=_TranscoderFormat,s=_BasisFormat;self.addEventListener("message",function(m){const A=m.data;switch(A.type){case"init":i=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:g,width:y,height:b,hasAlpha:x,format:w,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:y,height:b,hasAlpha:x,format:w,dfdFlags:I},g)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(m){e=new Promise(A=>{t={wasmBinary:m,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(m){const A=new t.KTX2File(new Uint8Array(m));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const g=A.isUASTC()?s.UASTC_4x4:s.ETC1S,y=A.getWidth(),b=A.getHeight(),x=A.getLayers()||1,w=A.getLevels(),I=A.getFaces(),M=A.getHasAlpha(),T=A.getDFDFlags(),{transcoderFormat:D,engineFormat:S}=d(g,y,b,M);if(!y||!b||!w)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const B=[],U=[];for(let j=0;j<I;j++){const L=[];for(let H=0;H<w;H++){const P=[];let O,Q;for(let Y=0;Y<x;Y++){const ne=A.getImageLevelInfo(H,Y,j);j===0&&H===0&&Y===0&&(ne.origWidth%4!==0||ne.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),w>1?(O=ne.origWidth,Q=ne.origHeight):(O=ne.width,Q=ne.height);const ye=new Uint8Array(A.getImageTranscodedSizeInBytes(H,Y,0,D));if(!A.transcodeImage(ye,H,Y,j,D,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");P.push(ye)}const X=f(P);L.push({data:X,width:O,height:Q}),U.push(X.buffer)}B.push({mipmaps:L,width:y,height:b,format:S})}return v(),{faces:B,buffers:U,width:y,height:b,hasAlpha:M,format:S,dfdFlags:T}}const l=[{if:"astcSupported",basisFormat:[s.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGB_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],c=l.sort(function(m,A){return m.priorityETC1S-A.priorityETC1S}),h=l.sort(function(m,A){return m.priorityUASTC-A.priorityUASTC});function d(m,A,v,g){let y,b;const x=m===s.ETC1S?c:h;for(let w=0;w<x.length;w++){const I=x[w];if(i[I.if]&&I.basisFormat.includes(m)&&!(g&&I.transcoderFormat.length<2)&&!(I.needsPowerOfTwo&&!(p(A)&&p(v))))return y=I.transcoderFormat[g?1:0],b=I.engineFormat[g?1:0],{transcoderFormat:y,engineFormat:b}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),y=r.RGBA32,b=n.RGBAFormat,{transcoderFormat:y,engineFormat:b}}function p(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let A=0;for(let y=0;y<m.length;y++){const b=m[y];A+=b.byteLength}const v=new Uint8Array(A);let g=0;for(let y=0;y<m.length;y++){const b=m[y];v.set(b,g),g+=b.byteLength}return v}};const doe=new Set([hu,J0,km]),ER={[Xz]:hu,[Vz]:hu,[zz]:hu,[jz]:hu,[qz]:J0,[Hz]:J0,[Nz]:J0,[Qz]:J0,[Wz]:km,[Gz]:km,[Uz]:km,[Fz]:km,[Jz]:_Q,[Yz]:_Q},SR={[Xz]:xp,[Vz]:xw,[zz]:ha,[jz]:ha,[qz]:xp,[Hz]:xw,[Nz]:ha,[Qz]:ha,[Wz]:xp,[Gz]:xw,[Uz]:ha,[Fz]:ha,[Jz]:ha,[Yz]:ha};async function poe(i){const{vkFormat:e}=i;if(ER[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;i.supercompressionScheme===Oz&&(CR||(CR=new Promise(async s=>{const o=new uoe;await o.init(),s(o)})),t=await CR);const n=[];for(let s=0;s<i.levels.length;s++){const o=Math.max(1,i.pixelWidth>>s),a=Math.max(1,i.pixelHeight>>s),l=i.pixelDepth?Math.max(1,i.pixelDepth>>s):0,c=i.levels[s];let h;if(i.supercompressionScheme===noe)h=c.levelData;else if(i.supercompressionScheme===Oz)h=t.decode(c.levelData,c.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let d;SR[e]===xp?d=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):SR[e]===xw?d=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):d=h,n.push({data:d,width:o,height:a,depth:l})}let r;if(doe.has(ER[e]))r=i.pixelDepth===0?new iR(n[0].data,i.pixelWidth,i.pixelHeight):new pre(n[0].data,i.pixelWidth,i.pixelHeight,i.pixelDepth);else{if(i.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new Xw(n,i.pixelWidth,i.pixelHeight)}return r.mipmaps=n,r.type=SR[e],r.format=ER[e],r.colorSpace=$z(i),r.needsUpdate=!0,Promise.resolve(r)}function $z(i){const e=i.dataFormatDescriptor[0];return e.colorPrimaries===ooe?e.transferFunction===Lz?fs:po:e.colorPrimaries===aoe?e.transferFunction===Lz?IQ:SB:(e.colorPrimaries===soe||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),EB)}let Kw="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",IR="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";fetch(Kw+"draco_decoder.js",{method:"head"}).catch(i=>{Kw="./include/draco/",IR="./include/ktx2/"});function foe(i){Kw=i}function moe(i){IR=i}let pv,MR,fv;function goe(i){pv||(pv=new eoe,pv.setDecoderPath(Kw),pv.setDecoderConfig({type:"js"})),fv||(fv=new dv,fv.setTranscoderPath(IR)),MR||(MR=$se),i?fv.detectSupport(i):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail")}function Aoe(i){i.dracoLoader||i.setDRACOLoader(pv),i.ktx2Loader||i.setKTX2Loader(fv),i.meshoptDecoder||i.setMeshoptDecoder(MR)}mv("debugprogressive");function mv(i){const e=new URL(window.location.href).searchParams.get(i);return e==null||e==="0"||e==="false"?!1:e===""?!0:e}function voe(i,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||i===void 0)return e;const t=i.lastIndexOf("/");if(t>=0){const n=i.substring(0,t+1);for(;n.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return n+e}return e}let Zw;function yoe(){return Zw!==void 0||(Zw=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),mv("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",Zw)),Zw}const TR=Symbol("needle:raycast-mesh");function $w(i){return i?.[TR]instanceof wl?i[TR]:null}function boe(i,e){if((i.type==="Mesh"||i.type==="SkinnedMesh")&&!$w(i)){const t=xoe(e);t.userData={isRaycastMesh:!0},i[TR]=t}}function xoe(i){const e=new wl;for(const t in i.attributes)e.setAttribute(t,i.getAttribute(t));return e.setIndex(i.getIndex()),e}const wu=new Array,sh="NEEDLE_progressive",Yi=mv("debugprogressive"),BR=Symbol("needle-progressive-texture"),gv=new Map,RR=new Set;if(Yi){let i=function(){e+=1,console.log("Toggle LOD level",e,gv),gv.forEach((r,s)=>{for(const o of r.keys){const a=s[o];if(a!=null){if(a.isBufferGeometry===!0){const l=pi.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=e,pi.assignMeshLOD(s,c),l&&(t=Math.max(t,l.lods.length-1))}else if(s.isMaterial===!0){s["DEBUG:LOD"]=e,pi.assignTextureLOD(s,e);break}}}}),e>=t&&(e=-1)},e=-1,t=2,n=!1;window.addEventListener("keyup",r=>{r.key==="p"&&i(),r.key==="w"&&(n=!n,RR&&RR.forEach(s=>{s.name!="BackgroundCubeMaterial"&&s.glyphMap==null&&"wireframe"in s&&(s.wireframe=n)}))})}function e4(i,e,t){var n;if(!Yi)return;gv.has(i)||gv.set(i,{keys:[],sourceId:t});const r=gv.get(i);((n=r?.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const Ar=class{constructor(i,e){this.loadMesh=t=>{var n,r;if(this._isLoadingMesh)return null;const s=(r=(n=this.parser.json.meshes[t])==null?void 0:n.extensions)==null?void 0:r[sh];return s?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",t).then(o=>{var a;return this._isLoadingMesh=!1,o&&Ar.registerMesh(this.url,s.guid,o,(a=s.lods)==null?void 0:a.length,void 0,s),o})):null},Yi&&console.log("Progressive extension registered for",e),this.parser=i,this.url=e}get name(){return sh}static getMeshLODInformation(i){const e=this.getAssignedLODInformation(i);return e!=null&&e.key?this.lodInfos.get(e.key):null}static getMaterialMinMaxLODsCount(i,e){const t=this,n="LODS:minmax",r=i[n];if(r!=null)return r;if(e||(e={min_count:1/0,max_count:0,lods:[]}),Array.isArray(i)){for(const o of i)this.getMaterialMinMaxLODsCount(o,e);return i[n]=e,e}if(Yi==="verbose"&&console.log("getMaterialMinMaxLODsCount",i),i.type==="ShaderMaterial"||i.type==="RawShaderMaterial"){const o=i;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;l?.isTexture===!0&&s(l,e)}}else if(i.isMaterial)for(const o of Object.keys(i)){const a=i[o];a?.isTexture===!0&&s(a,e)}return i[n]=e,e;function s(o,a){const l=t.getAssignedLODInformation(o);if(l){const c=t.lodInfos.get(l.key);if(c&&c.lods){a.min_count=Math.min(a.min_count,c.lods.length),a.max_count=Math.max(a.max_count,c.lods.length);for(let h=0;h<c.lods.length;h++){const d=c.lods[h];d.width&&(a.lods[h]=a.lods[h]||{min_height:1/0,max_height:0},a.lods[h].min_height=Math.min(a.lods[h].min_height,d.height),a.lods[h].max_height=Math.max(a.lods[h].max_height,d.height))}}}}}static hasLODLevelAvailable(i,e){var t;if(Array.isArray(i)){for(const s of i)if(this.hasLODLevelAvailable(s,e))return!0;return!1}if(i.isMaterial===!0){for(const s of Object.keys(i)){const o=i[s];if(o&&o.isTexture&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(i.isGroup===!0){for(const s of i.children)if(s.isMesh===!0&&this.hasLODLevelAvailable(s,e))return!0}let n,r;if(i.isMesh?n=i.geometry:(i.isBufferGeometry||i.isTexture)&&(n=i),n&&(t=n?.userData)!=null&&t.LODS){const s=n.userData.LODS;if(r=this.lodInfos.get(s.key),e===void 0)return r!=null;if(r)return Array.isArray(r.lods)?e<r.lods.length:e===0}return!1}static assignMeshLOD(i,e){var t;if(!i)return Promise.resolve(null);if(i instanceof Sp||i.isMesh===!0){const n=i.geometry,r=this.getAssignedLODInformation(n);if(!r)return Promise.resolve(null);for(const s of wu)(t=s.onBeforeGetLODMesh)==null||t.call(s,i,e);return i["LOD:requested level"]=e,Ar.getOrLoadLOD(n,e).then(s=>{if(i["LOD:requested level"]===e){if(delete i["LOD:requested level"],Array.isArray(s)){const o=r.index||0;s=s[o]}s&&n!=s&&(s?.isBufferGeometry?(i.geometry=s,Yi&&e4(i,"geometry",r.url)):Yi&&console.error("Invalid LOD geometry",s))}return s}).catch(s=>(console.error("Error loading mesh LOD",i,s),null))}else Yi&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",i);return Promise.resolve(null)}static assignTextureLOD(i,e=0){if(!i)return Promise.resolve(null);if(i instanceof Au||i.isMaterial===!0){const t=i,n=[],r=new Array;if(Yi&&RR.add(t),t.uniforms&&t.isRawShaderMaterial||t.isShaderMaterial===!0){const s=t;for(const o of Object.keys(s.uniforms)){const a=s.uniforms[o].value;if(a?.isTexture===!0){const l=this.assignTextureLODForSlot(a,e,t,o);n.push(l),r.push(o)}}}else for(const s of Object.keys(t)){const o=t[s];if(o?.isTexture===!0){const a=this.assignTextureLODForSlot(o,e,t,s);n.push(a),r.push(s)}}return Promise.all(n).then(s=>{const o=new Array;for(let a=0;a<s.length;a++){const l=s[a],c=r[a];l&&l.isTexture===!0?o.push({material:t,slot:c,texture:l,level:e}):o.push({material:t,slot:c,texture:null,level:e})}return o})}if(i instanceof ur||i.isTexture===!0){const t=i;return this.assignTextureLODForSlot(t,e,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(i,e,t,n){return i?.isTexture!==!0?Promise.resolve(null):n==="glyphMap"?Promise.resolve(i):Ar.getOrLoadLOD(i,e).then(r=>{if(Array.isArray(r))return null;if(r?.isTexture===!0){if(r!=i){if(t&&n){const s=t[n];if(s){const o=this.getAssignedLODInformation(s);if(o&&o?.level<e)return Yi==="verbose"&&console.warn("Assigned texture level is already higher: ",o.level,e,t,s,r),null}t[n]=r}if(Yi&&n&&t){const s=this.getAssignedLODInformation(i);s&&e4(t,n,s.url)}}return r}else Yi=="verbose"&&console.warn("No LOD found for",i,e);return null}).catch(r=>(console.error("Error loading LOD",i,r),null))}afterRoot(i){var e,t;return Yi&&console.log("AFTER",this.url,i),(e=this.parser.json.textures)==null||e.forEach((n,r)=>{var s;if(n!=null&&n.extensions){const o=n?.extensions[sh];if(o){if(!o.lods){Yi&&console.warn("Texture has no LODs",o);return}let a=!1;for(const l of this.parser.associations.keys())l.isTexture===!0&&this.parser.associations.get(l).textures===r&&(a=!0,Ar.registerTexture(this.url,l,(s=o.lods)==null?void 0:s.length,r,o));a||this.parser.getDependency("texture",r).then(l=>{var c;l&&Ar.registerTexture(this.url,l,(c=o.lods)==null?void 0:c.length,r,o)})}}}),(t=this.parser.json.meshes)==null||t.forEach((n,r)=>{if(n!=null&&n.extensions){const s=n?.extensions[sh];if(s&&s.lods){for(const o of this.parser.associations.keys())if(o.isMesh){const a=this.parser.associations.get(o);a.meshes===r&&Ar.registerMesh(this.url,s.guid,o,s.lods.length,a.primitives,s)}}}}),null}static async getOrLoadLOD(i,e){var t,n,r,s;const o=Yi=="verbose",a=i.userData.LODS;if(!a)return null;const l=a?.key;let c;if(i.isTexture===!0){const h=i;h.source&&h.source[BR]&&(c=h.source[BR])}if(c||(c=Ar.lodInfos.get(l)),c){if(e>0){let p=!1;const f=Array.isArray(c.lods);if(f&&e>=c.lods.length?p=!0:f||(p=!0),p)return this.lowresCache.get(l)}const h=Array.isArray(c.lods)?(t=c.lods[e])==null?void 0:t.path:c.lods;if(!h)return Yi&&!c["missing:uri"]&&(c["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+e,c)),null;const d=voe(a.url,h);if(d.endsWith(".glb")||d.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const p=d+"_"+c.guid,f=this.previouslyLoaded.get(p);if(f!==void 0){o&&console.log(`LOD ${e} was already loading/loaded: ${p}`);let v=await f.catch(y=>(console.error(`Error loading LOD ${e} from ${d}
4418
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),wR>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),wR++}return this.transcoderPending}load(e,t,n,r){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const s=new Tp(this.manager);s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials),s.load(e,o=>{if(_R.has(o))return _R.get(o).promise.then(t).catch(r);this._createTexture(o).then(a=>t?t(a):null).catch(r)},n,r)}_createTextureFrom(e,t){const{faces:n,width:r,height:s,format:o,type:a,error:l,dfdFlags:c}=e;if(a==="error")return Promise.reject(l);let h;if(t.faceCount===6)h=new jre(n,o,ha);else{const d=n[0].mipmaps;h=t.layerCount>1?new zre(d,r,s,t.layerCount,o,ha):new Xw(d,r,s,o,ha)}return h.minFilter=n[0].mipmaps.length===1?Y0:bw,h.magFilter=Y0,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=$z(t),h.premultiplyAlpha=!!(c&roe),h}async _createTexture(e,t={}){const n=hoe(new Uint8Array(e));if(n.vkFormat!==loe)return poe(n);const r=t,s=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e])).then(o=>this._createTextureFrom(o.data,n));return _R.set(e,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),wR--,this}};dv.BasisFormat={ETC1S:0,UASTC_4x4:1},dv.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},dv.EngineFormat={RGBAFormat:hu,RGBA_ASTC_4x4_Format:Une,RGBA_BPTC_Format:Nne,RGBA_ETC2_EAC_Format:Fne,RGBA_PVRTC_4BPPV1_Format:kne,RGBA_S3TC_DXT5_Format:Dne,RGB_ETC1_Format:One,RGB_ETC2_Format:Lne,RGB_PVRTC_4BPPV1_Format:Pne,RGB_S3TC_DXT1_Format:Rne},dv.BasisWorker=function(){let i,e,t;const n=_EngineFormat,r=_TranscoderFormat,s=_BasisFormat;self.addEventListener("message",function(m){const A=m.data;switch(A.type){case"init":i=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:g,width:y,height:b,hasAlpha:x,format:w,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:y,height:b,hasAlpha:x,format:w,dfdFlags:I},g)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(m){e=new Promise(A=>{t={wasmBinary:m,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(m){const A=new t.KTX2File(new Uint8Array(m));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const g=A.isUASTC()?s.UASTC_4x4:s.ETC1S,y=A.getWidth(),b=A.getHeight(),x=A.getLayers()||1,w=A.getLevels(),I=A.getFaces(),M=A.getHasAlpha(),T=A.getDFDFlags(),{transcoderFormat:D,engineFormat:S}=d(g,y,b,M);if(!y||!b||!w)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const B=[],U=[];for(let j=0;j<I;j++){const L=[];for(let H=0;H<w;H++){const P=[];let O,Q;for(let Y=0;Y<x;Y++){const ne=A.getImageLevelInfo(H,Y,j);j===0&&H===0&&Y===0&&(ne.origWidth%4!==0||ne.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),w>1?(O=ne.origWidth,Q=ne.origHeight):(O=ne.width,Q=ne.height);const ye=new Uint8Array(A.getImageTranscodedSizeInBytes(H,Y,0,D));if(!A.transcodeImage(ye,H,Y,j,D,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");P.push(ye)}const X=f(P);L.push({data:X,width:O,height:Q}),U.push(X.buffer)}B.push({mipmaps:L,width:y,height:b,format:S})}return v(),{faces:B,buffers:U,width:y,height:b,hasAlpha:M,format:S,dfdFlags:T}}const l=[{if:"astcSupported",basisFormat:[s.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGB_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],c=l.sort(function(m,A){return m.priorityETC1S-A.priorityETC1S}),h=l.sort(function(m,A){return m.priorityUASTC-A.priorityUASTC});function d(m,A,v,g){let y,b;const x=m===s.ETC1S?c:h;for(let w=0;w<x.length;w++){const I=x[w];if(i[I.if]&&I.basisFormat.includes(m)&&!(g&&I.transcoderFormat.length<2)&&!(I.needsPowerOfTwo&&!(p(A)&&p(v))))return y=I.transcoderFormat[g?1:0],b=I.engineFormat[g?1:0],{transcoderFormat:y,engineFormat:b}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),y=r.RGBA32,b=n.RGBAFormat,{transcoderFormat:y,engineFormat:b}}function p(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let A=0;for(let y=0;y<m.length;y++){const b=m[y];A+=b.byteLength}const v=new Uint8Array(A);let g=0;for(let y=0;y<m.length;y++){const b=m[y];v.set(b,g),g+=b.byteLength}return v}};const doe=new Set([hu,J0,km]),ER={[Xz]:hu,[Vz]:hu,[zz]:hu,[jz]:hu,[qz]:J0,[Hz]:J0,[Nz]:J0,[Qz]:J0,[Wz]:km,[Gz]:km,[Uz]:km,[Fz]:km,[Jz]:_Q,[Yz]:_Q},SR={[Xz]:xp,[Vz]:xw,[zz]:ha,[jz]:ha,[qz]:xp,[Hz]:xw,[Nz]:ha,[Qz]:ha,[Wz]:xp,[Gz]:xw,[Uz]:ha,[Fz]:ha,[Jz]:ha,[Yz]:ha};async function poe(i){const{vkFormat:e}=i;if(ER[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;i.supercompressionScheme===Oz&&(CR||(CR=new Promise(async s=>{const o=new uoe;await o.init(),s(o)})),t=await CR);const n=[];for(let s=0;s<i.levels.length;s++){const o=Math.max(1,i.pixelWidth>>s),a=Math.max(1,i.pixelHeight>>s),l=i.pixelDepth?Math.max(1,i.pixelDepth>>s):0,c=i.levels[s];let h;if(i.supercompressionScheme===noe)h=c.levelData;else if(i.supercompressionScheme===Oz)h=t.decode(c.levelData,c.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let d;SR[e]===xp?d=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):SR[e]===xw?d=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):d=h,n.push({data:d,width:o,height:a,depth:l})}let r;if(doe.has(ER[e]))r=i.pixelDepth===0?new iR(n[0].data,i.pixelWidth,i.pixelHeight):new pre(n[0].data,i.pixelWidth,i.pixelHeight,i.pixelDepth);else{if(i.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new Xw(n,i.pixelWidth,i.pixelHeight)}return r.mipmaps=n,r.type=SR[e],r.format=ER[e],r.colorSpace=$z(i),r.needsUpdate=!0,Promise.resolve(r)}function $z(i){const e=i.dataFormatDescriptor[0];return e.colorPrimaries===ooe?e.transferFunction===Lz?fs:po:e.colorPrimaries===aoe?e.transferFunction===Lz?IQ:SB:(e.colorPrimaries===soe||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),EB)}let Kw="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",IR="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";fetch(Kw+"draco_decoder.js",{method:"head"}).catch(i=>{Kw="./include/draco/",IR="./include/ktx2/"});function foe(i){Kw=i}function moe(i){IR=i}let pv,MR,fv;function goe(i){pv||(pv=new eoe,pv.setDecoderPath(Kw),pv.setDecoderConfig({type:"js"})),fv||(fv=new dv,fv.setTranscoderPath(IR)),MR||(MR=$se),i?fv.detectSupport(i):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail")}function Aoe(i){i.dracoLoader||i.setDRACOLoader(pv),i.ktx2Loader||i.setKTX2Loader(fv),i.meshoptDecoder||i.setMeshoptDecoder(MR)}mv("debugprogressive");function mv(i){const e=new URL(window.location.href).searchParams.get(i);return e==null||e==="0"||e==="false"?!1:e===""?!0:e}function voe(i,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||i===void 0)return e;const t=i.lastIndexOf("/");if(t>=0){const n=i.substring(0,t+1);for(;n.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return n+e}return e}let Zw;function yoe(){return Zw!==void 0||(Zw=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),mv("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",Zw)),Zw}const TR=Symbol("needle:raycast-mesh");function $w(i){return i?.[TR]instanceof wl?i[TR]:null}function boe(i,e){if((i.type==="Mesh"||i.type==="SkinnedMesh")&&!$w(i)){const t=xoe(e);t.userData={isRaycastMesh:!0},i[TR]=t}}function xoe(i){const e=new wl;for(const t in i.attributes)e.setAttribute(t,i.getAttribute(t));return e.setIndex(i.getIndex()),e}const wu=new Array,sh="NEEDLE_progressive",Yi=mv("debugprogressive"),BR=Symbol("needle-progressive-texture"),gv=new Map,RR=new Set;if(Yi){let i=function(){e+=1,console.log("Toggle LOD level",e,gv),gv.forEach((r,s)=>{for(const o of r.keys){const a=s[o];if(a!=null){if(a.isBufferGeometry===!0){const l=pi.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=e,pi.assignMeshLOD(s,c),l&&(t=Math.max(t,l.lods.length-1))}else if(s.isMaterial===!0){s["DEBUG:LOD"]=e,pi.assignTextureLOD(s,e);break}}}}),e>=t&&(e=-1)},e=-1,t=2,n=!1;window.addEventListener("keyup",r=>{r.key==="p"&&i(),r.key==="w"&&(n=!n,RR&&RR.forEach(s=>{s.name!="BackgroundCubeMaterial"&&s.glyphMap==null&&"wireframe"in s&&(s.wireframe=n)}))})}function e4(i,e,t){var n;if(!Yi)return;gv.has(i)||gv.set(i,{keys:[],sourceId:t});const r=gv.get(i);((n=r?.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const Ar=class{constructor(i,e){this.loadMesh=t=>{var n,r;if(this._isLoadingMesh)return null;const s=(r=(n=this.parser.json.meshes[t])==null?void 0:n.extensions)==null?void 0:r[sh];return s?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",t).then(o=>{var a;return this._isLoadingMesh=!1,o&&Ar.registerMesh(this.url,s.guid,o,(a=s.lods)==null?void 0:a.length,void 0,s),o})):null},Yi&&console.log("Progressive extension registered for",e),this.parser=i,this.url=e}get name(){return sh}static getMeshLODInformation(i){const e=this.getAssignedLODInformation(i);return e!=null&&e.key?this.lodInfos.get(e.key):null}static getMaterialMinMaxLODsCount(i,e){const t=this,n="LODS:minmax",r=i[n];if(r!=null)return r;if(e||(e={min_count:1/0,max_count:0,lods:[]}),Array.isArray(i)){for(const o of i)this.getMaterialMinMaxLODsCount(o,e);return i[n]=e,e}if(Yi==="verbose"&&console.log("getMaterialMinMaxLODsCount",i),i.type==="ShaderMaterial"||i.type==="RawShaderMaterial"){const o=i;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;l?.isTexture===!0&&s(l,e)}}else if(i.isMaterial)for(const o of Object.keys(i)){const a=i[o];a?.isTexture===!0&&s(a,e)}return i[n]=e,e;function s(o,a){const l=t.getAssignedLODInformation(o);if(l){const c=t.lodInfos.get(l.key);if(c&&c.lods){a.min_count=Math.min(a.min_count,c.lods.length),a.max_count=Math.max(a.max_count,c.lods.length);for(let h=0;h<c.lods.length;h++){const d=c.lods[h];d.width&&(a.lods[h]=a.lods[h]||{min_height:1/0,max_height:0},a.lods[h].min_height=Math.min(a.lods[h].min_height,d.height),a.lods[h].max_height=Math.max(a.lods[h].max_height,d.height))}}}}}static hasLODLevelAvailable(i,e){var t;if(Array.isArray(i)){for(const s of i)if(this.hasLODLevelAvailable(s,e))return!0;return!1}if(i.isMaterial===!0){for(const s of Object.keys(i)){const o=i[s];if(o&&o.isTexture&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(i.isGroup===!0){for(const s of i.children)if(s.isMesh===!0&&this.hasLODLevelAvailable(s,e))return!0}let n,r;if(i.isMesh?n=i.geometry:(i.isBufferGeometry||i.isTexture)&&(n=i),n&&(t=n?.userData)!=null&&t.LODS){const s=n.userData.LODS;if(r=this.lodInfos.get(s.key),e===void 0)return r!=null;if(r)return Array.isArray(r.lods)?e<r.lods.length:e===0}return!1}static assignMeshLOD(i,e){var t;if(!i)return Promise.resolve(null);if(i instanceof Sp||i.isMesh===!0){const n=i.geometry,r=this.getAssignedLODInformation(n);if(!r)return Promise.resolve(null);for(const s of wu)(t=s.onBeforeGetLODMesh)==null||t.call(s,i,e);return i["LOD:requested level"]=e,Ar.getOrLoadLOD(n,e).then(s=>{if(i["LOD:requested level"]===e){if(delete i["LOD:requested level"],Array.isArray(s)){const o=r.index||0;s=s[o]}s&&n!=s&&(s?.isBufferGeometry?(i.geometry=s,Yi&&e4(i,"geometry",r.url)):Yi&&console.error("Invalid LOD geometry",s))}return s}).catch(s=>(console.error("Error loading mesh LOD",i,s),null))}else Yi&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",i);return Promise.resolve(null)}static assignTextureLOD(i,e=0){if(!i)return Promise.resolve(null);if(i instanceof Au||i.isMaterial===!0){const t=i,n=[],r=new Array;if(Yi&&RR.add(t),t.uniforms&&t.isRawShaderMaterial||t.isShaderMaterial===!0){const s=t;for(const o of Object.keys(s.uniforms)){const a=s.uniforms[o].value;if(a?.isTexture===!0){const l=this.assignTextureLODForSlot(a,e,t,o);n.push(l),r.push(o)}}}else for(const s of Object.keys(t)){const o=t[s];if(o?.isTexture===!0){const a=this.assignTextureLODForSlot(o,e,t,s);n.push(a),r.push(s)}}return Promise.all(n).then(s=>{const o=new Array;for(let a=0;a<s.length;a++){const l=s[a],c=r[a];l&&l.isTexture===!0?o.push({material:t,slot:c,texture:l,level:e}):o.push({material:t,slot:c,texture:null,level:e})}return o})}if(i instanceof ur||i.isTexture===!0){const t=i;return this.assignTextureLODForSlot(t,e,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(i,e,t,n){return i?.isTexture!==!0?Promise.resolve(null):n==="glyphMap"?Promise.resolve(i):Ar.getOrLoadLOD(i,e).then(r=>{if(Array.isArray(r))return null;if(r?.isTexture===!0){if(r!=i){if(t&&n){const s=t[n];if(s){const o=this.getAssignedLODInformation(s);if(o&&o?.level<e)return Yi==="verbose"&&console.warn("Assigned texture level is already higher: ",o.level,e,t,s,r),null}t[n]=r}if(Yi&&n&&t){const s=this.getAssignedLODInformation(i);s&&e4(t,n,s.url)}}return r}else Yi=="verbose"&&console.warn("No LOD found for",i,e);return null}).catch(r=>(console.error("Error loading LOD",i,r),null))}afterRoot(i){var e,t;return Yi&&console.log("AFTER",this.url,i),(e=this.parser.json.textures)==null||e.forEach((n,r)=>{var s;if(n!=null&&n.extensions){const o=n?.extensions[sh];if(o){if(!o.lods){Yi&&console.warn("Texture has no LODs",o);return}let a=!1;for(const l of this.parser.associations.keys())if(l.isTexture===!0){const c=this.parser.associations.get(l);c?.textures===r&&(a=!0,Ar.registerTexture(this.url,l,(s=o.lods)==null?void 0:s.length,r,o))}a||this.parser.getDependency("texture",r).then(l=>{var c;l&&Ar.registerTexture(this.url,l,(c=o.lods)==null?void 0:c.length,r,o)})}}}),(t=this.parser.json.meshes)==null||t.forEach((n,r)=>{if(n!=null&&n.extensions){const s=n?.extensions[sh];if(s&&s.lods){for(const o of this.parser.associations.keys())if(o.isMesh){const a=this.parser.associations.get(o);a?.meshes===r&&Ar.registerMesh(this.url,s.guid,o,s.lods.length,a.primitives,s)}}}}),null}static async getOrLoadLOD(i,e){var t,n,r,s;const o=Yi=="verbose",a=i.userData.LODS;if(!a)return null;const l=a?.key;let c;if(i.isTexture===!0){const h=i;h.source&&h.source[BR]&&(c=h.source[BR])}if(c||(c=Ar.lodInfos.get(l)),c){if(e>0){let p=!1;const f=Array.isArray(c.lods);if(f&&e>=c.lods.length?p=!0:f||(p=!0),p)return this.lowresCache.get(l)}const h=Array.isArray(c.lods)?(t=c.lods[e])==null?void 0:t.path:c.lods;if(!h)return Yi&&!c["missing:uri"]&&(c["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+e,c)),null;const d=voe(a.url,h);if(d.endsWith(".glb")||d.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const p=d+"_"+c.guid,f=this.previouslyLoaded.get(p);if(f!==void 0){o&&console.log(`LOD ${e} was already loading/loaded: ${p}`);let v=await f.catch(y=>(console.error(`Error loading LOD ${e} from ${d}
4419
4419
  `,y),null)),g=!1;if(v==null||(v instanceof ur&&i instanceof ur?(n=v.image)!=null&&n.data||(r=v.source)!=null&&r.data?v=this.copySettings(i,v):(g=!0,this.previouslyLoaded.delete(p)):v instanceof wl&&i instanceof wl&&((s=v.attributes.position)!=null&&s.array||(g=!0,this.previouslyLoaded.delete(p)))),!g)return v}const m=c,A=new Promise(async(v,g)=>{const y=new yse;Aoe(y),Yi&&(await new Promise(M=>setTimeout(M,1e3)),o&&console.warn("Start loading (delayed) "+d,m.guid));let b=d;if(m&&Array.isArray(m.lods)){const M=m.lods[e];M.hash&&(b+="?v="+M.hash)}const x=await y.loadAsync(b).catch(M=>(console.error(`Error loading LOD ${e} from ${d}
4420
4420
  `,M),null));if(!x)return null;const w=x.parser;o&&console.log("Loading finished "+d,m.guid);let I=0;if(x.parser.json.textures){let M=!1;for(const T of x.parser.json.textures){if(T!=null&&T.extensions){const D=T?.extensions[sh];if(D!=null&&D.guid&&D.guid===m.guid){M=!0;break}}I++}if(M){let T=await w.getDependency("texture",I);return T&&Ar.assignLODInformation(a.url,T,l,e,void 0,void 0),o&&console.log('change "'+i.name+'" \u2192 "'+T.name+'"',d,I,T,p),i instanceof ur&&(T=this.copySettings(i,T)),T&&(T.guid=m.guid),v(T)}else Yi&&console.warn("Could not find texture with guid",m.guid,x.parser.json)}if(I=0,x.parser.json.meshes){let M=!1;for(const T of x.parser.json.meshes){if(T!=null&&T.extensions){const D=T?.extensions[sh];if(D!=null&&D.guid&&D.guid===m.guid){M=!0;break}}I++}if(M){const T=await w.getDependency("mesh",I),D=m;if(o&&console.log(`Loaded Mesh "${T.name}"`,d,I,T,p),T.isMesh===!0){const S=T.geometry;return Ar.assignLODInformation(a.url,S,l,e,void 0,D.density),v(S)}else{const S=new Array;for(let B=0;B<T.children.length;B++){const U=T.children[B];if(U.isMesh===!0){const j=U.geometry;Ar.assignLODInformation(a.url,j,l,e,B,D.density),S.push(j)}}return v(S)}}else Yi&&console.warn("Could not find mesh with guid",m.guid,x.parser.json)}return v(null)});return this.previouslyLoaded.set(p,A),await A}else if(i instanceof ur){o&&console.log("Load texture from uri: "+d);const p=await new wz().loadAsync(d);return p?(p.guid=c.guid,p.flipY=!1,p.needsUpdate=!0,p.colorSpace=i.colorSpace,o&&console.log(c,p)):Yi&&console.warn("failed loading",d),p}}else Yi&&console.warn(`Can not load LOD ${e}: no LOD info found for "${l}" ${i.name}`,i.type);return null}static assignLODInformation(i,e,t,n,r,s){if(!e)return;e.userData||(e.userData={});const o=new _oe(i,t,n,r,s);e.userData.LODS=o}static getAssignedLODInformation(i){var e;return((e=i?.userData)==null?void 0:e.LODS)||null}static copySettings(i,e){return e=e.clone(),Yi&&console.warn(`Copying texture settings
4421
4421
  `,i.uuid,`
@@ -5232,7 +5232,7 @@ a=extmap-allow-mixed`)!==-1){const r=n.sdp.split(`
5232
5232
  isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
5233
5233
  isBrowserSupported:`).concat(this.isBrowserSupported(),`
5234
5234
  isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},i}()),G5={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},rde=function(){function i(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=G5,this.browser=qv.getBrowser(),this.browserVersion=qv.getVersion(),this.supports=function(){var e={browser:qv.isBrowserSupported(),webRTC:qv.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(G5),e.audioVideo=!0;var n=void 0;try{n=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!n.ordered;try{n.binaryType="blob",e.binaryBlob=!qv.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e}(),this.pack=JG.pack,this.unpack=JG.unpack,this._dataCount=1}return i.prototype.noop=function(){},i.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},i.prototype.chunk=function(e){for(var t=[],n=e.size,r=Math.ceil(n/_i.chunkedMTU),s=0,o=0;o<n;){var a=Math.min(n,o+_i.chunkedMTU),l=e.slice(o,a),c={__peerData:this._dataCount,n:s,data:l,total:r};t.push(c),o=a,s++}return this._dataCount++,t},i.prototype.blobToArrayBuffer=function(e,t){var n=new FileReader;return n.onload=function(r){r.target&&t(r.target.result)},n.readAsArrayBuffer(e),n},i.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer},i.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},i.prototype.isSecure=function(){return location.protocol==="https:"},i}(),_i=new rde,H5={};ql(H5,"Peer",()=>BD,i=>BD=i);var Xv={},sde=Object.prototype.hasOwnProperty,Ks="~";function Yv(){}Object.create&&(Yv.prototype=Object.create(null),new Yv().__proto__||(Ks=!1));function ode(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function V5(i,e,t,n,r){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new ode(t,n||i,r),o=Ks?Ks+e:e;return i._events[o]?i._events[o].fn?i._events[o]=[i._events[o],s]:i._events[o].push(s):(i._events[o]=s,i._eventsCount++),i}function J1(i,e){--i._eventsCount===0?i._events=new Yv:delete i._events[e]}function bs(){this._events=new Yv,this._eventsCount=0}bs.prototype.eventNames=function(){var i=[],e,t;if(this._eventsCount===0)return i;for(t in e=this._events)sde.call(e,t)&&i.push(Ks?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},bs.prototype.listeners=function(i){var e=Ks?Ks+i:i,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,r=t.length,s=new Array(r);n<r;n++)s[n]=t[n].fn;return s},bs.prototype.listenerCount=function(i){var e=Ks?Ks+i:i,t=this._events[e];return t?t.fn?1:t.length:0},bs.prototype.emit=function(i,e,t,n,r,s){var o=Ks?Ks+i:i;if(!this._events[o])return!1;var a=this._events[o],l=arguments.length,c,h;if(a.fn){switch(a.once&&this.removeListener(i,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,e),!0;case 3:return a.fn.call(a.context,e,t),!0;case 4:return a.fn.call(a.context,e,t,n),!0;case 5:return a.fn.call(a.context,e,t,n,r),!0;case 6:return a.fn.call(a.context,e,t,n,r,s),!0}for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];a.fn.apply(a.context,c)}else{var d=a.length,p;for(h=0;h<d;h++)switch(a[h].once&&this.removeListener(i,a[h].fn,void 0,!0),l){case 1:a[h].fn.call(a[h].context);break;case 2:a[h].fn.call(a[h].context,e);break;case 3:a[h].fn.call(a[h].context,e,t);break;case 4:a[h].fn.call(a[h].context,e,t,n);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];a[h].fn.apply(a[h].context,c)}}return!0},bs.prototype.on=function(i,e,t){return V5(this,i,e,t,!1)},bs.prototype.once=function(i,e,t){return V5(this,i,e,t,!0)},bs.prototype.removeListener=function(i,e,t,n){var r=Ks?Ks+i:i;if(!this._events[r])return this;if(!e)return J1(this,r),this;var s=this._events[r];if(s.fn)s.fn===e&&(!n||s.once)&&(!t||s.context===t)&&J1(this,r);else{for(var o=0,a=[],l=s.length;o<l;o++)(s[o].fn!==e||n&&!s[o].once||t&&s[o].context!==t)&&a.push(s[o]);a.length?this._events[r]=a.length===1?a[0]:a:J1(this,r)}return this},bs.prototype.removeAllListeners=function(i){var e;return i?(e=Ks?Ks+i:i,this._events[e]&&J1(this,e)):(this._events=new Yv,this._eventsCount=0),this},bs.prototype.off=bs.prototype.removeListener,bs.prototype.addListener=bs.prototype.on,bs.prefixed=Ks,bs.EventEmitter=bs,Xv=bs;var ut={};ql(ut,"LogLevel",()=>go,i=>go=i),ql(ut,"default",()=>W5,i=>W5=i);var zp=function(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},jp=function(i,e,t){if(t||arguments.length===2)for(var n=0,r=e.length,s;n<r;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return i.concat(s||Array.prototype.slice.call(e))},ade="PeerJS: ",go;(function(i){i[i.Disabled=0]="Disabled",i[i.Errors=1]="Errors",i[i.Warnings=2]="Warnings",i[i.All=3]="All"})(go||(go={}));var lde=function(){function i(){this._logLevel=go.Disabled}return Object.defineProperty(i.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),i.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=go.All&&this._print.apply(this,jp([go.All],zp(e),!1))},i.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=go.Warnings&&this._print.apply(this,jp([go.Warnings],zp(e),!1))},i.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=go.Errors&&this._print.apply(this,jp([go.Errors],zp(e),!1))},i.prototype.setLogFunction=function(e){this._print=e},i.prototype._print=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=jp([ade],zp(t),!1);for(var s in r)r[s]instanceof Error&&(r[s]="("+r[s].name+") "+r[s].message);e>=go.All?console.log.apply(console,jp([],zp(r),!1)):e>=go.Warnings?console.warn.apply(console,jp(["WARNING"],zp(r),!1)):e>=go.Errors&&console.error.apply(console,jp(["ERROR"],zp(r),!1))},i}(),W5=new lde,q5={};ql(q5,"Socket",()=>X5,i=>X5=i);var ul;(function(i){i.Data="data",i.Media="media"})(ul||(ul={}));var Fn;(function(i){i.BrowserIncompatible="browser-incompatible",i.Disconnected="disconnected",i.InvalidID="invalid-id",i.InvalidKey="invalid-key",i.Network="network",i.PeerUnavailable="peer-unavailable",i.SslUnavailable="ssl-unavailable",i.ServerError="server-error",i.SocketError="socket-error",i.SocketClosed="socket-closed",i.UnavailableID="unavailable-id",i.WebRTC="webrtc"})(Fn||(Fn={}));var fh;(function(i){i.Binary="binary",i.BinaryUTF8="binary-utf8",i.JSON="json"})(fh||(fh={}));var mh;(function(i){i.Message="message",i.Disconnected="disconnected",i.Error="error",i.Close="close"})(mh||(mh={}));var Gr;(function(i){i.Heartbeat="HEARTBEAT",i.Candidate="CANDIDATE",i.Offer="OFFER",i.Answer="ANSWER",i.Open="OPEN",i.Error="ERROR",i.IdTaken="ID-TAKEN",i.InvalidKey="INVALID-KEY",i.Leave="LEAVE",i.Expire="EXPIRE"})(Gr||(Gr={}));var ED={};ED=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz St\xFCckler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","So\u0308ren Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var cde=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),hde=function(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},ude=function(i,e,t){if(t||arguments.length===2)for(var n=0,r=e.length,s;n<r;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return i.concat(s||Array.prototype.slice.call(e))},dde=function(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X5=function(i){cde(e,i);function e(t,n,r,s,o,a){a===void 0&&(a=5e3);var l=i.call(this)||this;l.pingInterval=a,l._disconnected=!0,l._messagesQueue=[];var c=t?"wss://":"ws://";return l._baseUrl=c+n+":"+r+s+"peerjs?key="+o,l}return e.prototype.start=function(t,n){var r=this;this._id=t;var s="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(n);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+ED.version),this._disconnected=!1,this._socket.onmessage=function(o){var a;try{a=JSON.parse(o.data),ut.default.log("Server message received:",a)}catch{ut.default.log("Invalid server message",o.data);return}r.emit(mh.Message,a)},this._socket.onclose=function(o){r._disconnected||(ut.default.log("Socket closed.",o),r._cleanup(),r._disconnected=!0,r.emit(mh.Disconnected))},this._socket.onopen=function(){r._disconnected||(r._sendQueuedMessages(),ut.default.log("Socket open"),r._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){ut.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Gr.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,n,r=ude([],hde(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=dde(r),o=s.next();!o.done;o=s.next()){var a=o.value;this.send(a)}}catch(l){t={error:l}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit(mh.Error,"Invalid message");return}if(this._wsOpen()){var n=JSON.stringify(t);this._socket.send(n)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e}(Xv.EventEmitter),SD={};ql(SD,"MediaConnection",()=>K5,i=>K5=i);var ID={};ql(ID,"Negotiator",()=>Y5,i=>Y5=i);var K1=function(){return K1=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},K1.apply(this,arguments)},Z1=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(d){o(d)}}function l(h){try{c(n.throw(h))}catch(d){o(d)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})},$1=function(i,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(i,t)}catch(h){c=[6,h],r=0}finally{n=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Y5=function(){function i(e){this.connection=e}return i.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===ul.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===ul.Data){var n=this.connection,r={ordered:!!e.reliable},s=t.createDataChannel(n.label,r);n.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},i.prototype._startPeerConnection=function(){ut.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},i.prototype._setupListeners=function(e){var t=this,n=this.connection.peer,r=this.connection.connectionId,s=this.connection.type,o=this.connection.provider;ut.default.log("Listening for ICE candidates."),e.onicecandidate=function(a){!a.candidate||!a.candidate.candidate||(ut.default.log("Received ICE candidates for ".concat(n,":"),a.candidate),o.socket.send({type:Gr.Candidate,payload:{candidate:a.candidate,type:s,connectionId:r},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":ut.default.log("iceConnectionState is failed, closing connections to "+n),t.connection.emit("error",new Error("Negotiation of connection to "+n+" failed.")),t.connection.close();break;case"closed":ut.default.log("iceConnectionState is closed, closing connections to "+n),t.connection.emit("error",new Error("Connection to "+n+" closed.")),t.connection.close();break;case"disconnected":ut.default.log("iceConnectionState changed to disconnected on the connection with "+n);break;case"completed":e.onicecandidate=_i.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},ut.default.log("Listening for data channel"),e.ondatachannel=function(a){ut.default.log("Received data channel");var l=a.channel,c=o.getConnection(n,r);c.initialize(l)},ut.default.log("Listening for remote stream"),e.ontrack=function(a){ut.default.log("Received remote stream");var l=a.streams[0],c=o.getConnection(n,r);if(c.type===ul.Media){var h=c;t._addStreamToMediaConnection(l,h)}}},i.prototype.cleanup=function(){ut.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",n=!1;if(this.connection.type===ul.Data){var r=this.connection,s=r.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},i.prototype._makeOffer=function(){return Z1(this,void 0,Promise,function(){var e,t,n,r,s,o,a;return $1(this,function(l){switch(l.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,l.label=1;case 1:return l.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:n=l.sent(),ut.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),l.label=3;case 3:return l.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return l.sent(),ut.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),r={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:_i.browser},this.connection.type===ul.Data&&(s=this.connection,r=K1(K1({},r),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Gr.Offer,payload:r,dst:this.connection.peer}),[3,6];case 5:return o=l.sent(),o!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(Fn.WebRTC,o),ut.default.log("Failed to setLocalDescription, ",o)),[3,6];case 6:return[3,8];case 7:return a=l.sent(),t.emitError(Fn.WebRTC,a),ut.default.log("Failed to createOffer, ",a),[3,8];case 8:return[2]}})})},i.prototype._makeAnswer=function(){return Z1(this,void 0,Promise,function(){var e,t,n,r,s;return $1(this,function(o){switch(o.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,o.label=1;case 1:return o.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:n=o.sent(),ut.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return o.sent(),ut.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Gr.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,browser:_i.browser},dst:this.connection.peer}),[3,6];case 5:return r=o.sent(),t.emitError(Fn.WebRTC,r),ut.default.log("Failed to setLocalDescription, ",r),[3,6];case 6:return[3,8];case 7:return s=o.sent(),t.emitError(Fn.WebRTC,s),ut.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},i.prototype.handleSDP=function(e,t){return Z1(this,void 0,Promise,function(){var n,r,s,o;return $1(this,function(a){switch(a.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,r=this.connection.provider,ut.default.log("Setting remote description",t),s=this,a.label=1;case 1:return a.trys.push([1,5,,6]),[4,n.setRemoteDescription(t)];case 2:return a.sent(),ut.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:a.sent(),a.label=4;case 4:return[3,6];case 5:return o=a.sent(),r.emitError(Fn.WebRTC,o),ut.default.log("Failed to setRemoteDescription, ",o),[3,6];case 6:return[2]}})})},i.prototype.handleCandidate=function(e){return Z1(this,void 0,Promise,function(){var t,n,r,s,o,a;return $1(this,function(l){switch(l.label){case 0:ut.default.log("handleCandidate:",e),t=e.candidate,n=e.sdpMLineIndex,r=e.sdpMid,s=this.connection.peerConnection,o=this.connection.provider,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:r,sdpMLineIndex:n,candidate:t}))];case 2:return l.sent(),ut.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return a=l.sent(),o.emitError(Fn.WebRTC,a),ut.default.log("Failed to handleCandidate, ",a),[3,4];case 4:return[2]}})})},i.prototype._addTracksToConnection=function(e,t){if(ut.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return ut.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(n){t.addTrack(n,e)})},i.prototype._addStreamToMediaConnection=function(e,t){ut.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},i}(),MD={};ql(MD,"BaseConnection",()=>J5,i=>J5=i);var pde=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),J5=function(i){pde(e,i);function e(t,n,r){var s=i.call(this)||this;return s.peer=t,s.provider=n,s.options=r,s._open=!1,s.metadata=r.metadata,s}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e}(Xv.EventEmitter),fde=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),eC=function(){return eC=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},eC.apply(this,arguments)},mde=function(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K5=function(i){fde(e,i);function e(t,n,r){var s=i.call(this,t,n,r)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||e.ID_PREFIX+_i.randomToken(),s._negotiator=new ID.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return ul.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){ut.default.log("Receiving stream",t),this._remoteStream=t,i.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var n=t.type,r=t.payload;switch(t.type){case Gr.Answer:this._negotiator.handleSDP(n,r.sdp),this._open=!0;break;case Gr.Candidate:this._negotiator.handleCandidate(r.candidate);break;default:ut.default.warn("Unrecognized message type:".concat(n," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,n){var r,s;if(n===void 0&&(n={}),this._localStream){ut.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,n&&n.sdpTransform&&(this.options.sdpTransform=n.sdpTransform),this._negotiator.startConnection(eC(eC({},this.options._payload),{_stream:t}));var o=this.provider._getMessages(this.connectionId);try{for(var a=mde(o),l=a.next();!l.done;l=a.next()){var c=l.value;this.handleMessage(c)}}catch(h){r={error:h}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,i.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e}(MD.BaseConnection),TD={};ql(TD,"DataConnection",()=>eH,i=>eH=i);var Z5={};ql(Z5,"EncodingQueue",()=>$5,i=>$5=i);var gde=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),$5=function(i){gde(e,i);function e(){var t=i.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(n){t._processing=!1,n.target&&t.emit("done",n.target.result),t.doNextTask()},t.fileReader.onerror=function(n){ut.default.error("EncodingQueue error:",n),t._processing=!1,t.destroy(),t.emit("error",n)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e}(Xv.EventEmitter),Ade=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),vde=function(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},eH=function(i){Ade(e,i);function e(t,n,r){var s=i.call(this,t,n,r)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new Z5.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+_i.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||fh.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(o){s._bufferedSend(o)}),s._encodingQueue.on("error",function(){ut.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new ID.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return ul.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!_i.supports.binaryBlob||_i.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){ut.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){ut.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){ut.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var n=this,r=t.data,s=r.constructor,o=this.serialization===fh.Binary||this.serialization===fh.BinaryUTF8,a=r;if(o){if(s===Blob){_i.blobToArrayBuffer(r,function(c){var h=_i.unpack(c);n.emit("data",h)});return}else if(s===ArrayBuffer)a=_i.unpack(r);else if(s===String){var l=_i.binaryStringToArrayBuffer(r);a=_i.unpack(l)}}else this.serialization===fh.JSON&&(a=this.parse(r));if(a.__peerData){this._handleChunk(a);return}i.prototype.emit.call(this,"data",a)},e.prototype._handleChunk=function(t){var n=t.__peerData,r=this._chunkedData[n]||{data:[],count:0,total:t.total};if(r.data[t.n]=t.data,r.count++,this._chunkedData[n]=r,r.total===r.count){delete this._chunkedData[n];var s=new Blob(r.data);this._handleDataMessage({data:s})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,i.prototype.emit.call(this,"close"))},e.prototype.send=function(t,n){if(!this.open){i.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===fh.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===fh.Binary||this.serialization===fh.BinaryUTF8){var r=_i.pack(t);if(!n&&r.size>_i.chunkedMTU){this._sendChunks(r);return}_i.supports.binaryBlob?this._bufferedSend(r):this._encodingQueue.enque(r)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var n=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){n._buffering=!1,n._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(r){return ut.default.error("DC#:".concat(this.connectionId," Error when sending:"),r),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var n,r,s=_i.chunk(t);ut.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var o=vde(s),a=o.next();!a.done;a=o.next()){var l=a.value;this.send(l,!0)}}catch(c){n={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},e.prototype.handleMessage=function(t){var n=t.payload;switch(t.type){case Gr.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Gr.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:ut.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e}(MD.BaseConnection),tH={};ql(tH,"API",()=>rH,i=>rH=i);var iH=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(d){o(d)}}function l(h){try{c(n.throw(h))}catch(d){o(d)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})},nH=function(i,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(i,t)}catch(h){c=[6,h],r=0}finally{n=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},rH=function(){function i(e){this._options=e}return i.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",n=this._options,r=n.host,s=n.port,o=n.path,a=n.key,l=new URL("".concat(t,"://").concat(r,":").concat(s).concat(o).concat(a,"/").concat(e));return l.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),l.searchParams.set("version",ED.version),fetch(l.href,{referrerPolicy:this._options.referrerPolicy})},i.prototype.retrieveId=function(){return iH(this,void 0,Promise,function(){var e,t,n;return nH(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=r.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=r.sent(),ut.default.error("Error retrieving ID",t),n="",this._options.path==="/"&&this._options.host!==_i.CLOUD_HOST&&(n=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+n);case 3:return[2]}})})},i.prototype.listAllPeers=function(){return iH(this,void 0,Promise,function(){var e,t,n;return nH(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=r.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===_i.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw n=r.sent(),ut.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},i}(),yde=function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Jv=function(){return Jv=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Jv.apply(this,arguments)},Kv=function(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},bde=function(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},BD=function(i){yde(e,i);function e(t,n){var r=i.call(this)||this;r._id=null,r._lastServerId=null,r._destroyed=!1,r._disconnected=!1,r._open=!1,r._connections=new Map,r._lostMessages=new Map;var s;return t&&t.constructor==Object?n=t:t&&(s=t.toString()),n=Jv({debug:0,host:_i.CLOUD_HOST,port:_i.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:_i.randomToken(),config:_i.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},n),r._options=n,r._options.host==="/"&&(r._options.host=window.location.hostname),r._options.path&&(r._options.path[0]!=="/"&&(r._options.path="/"+r._options.path),r._options.path[r._options.path.length-1]!=="/"&&(r._options.path+="/")),r._options.secure===void 0&&r._options.host!==_i.CLOUD_HOST?r._options.secure=_i.isSecure():r._options.host==_i.CLOUD_HOST&&(r._options.secure=!0),r._options.logFunction&&ut.default.setLogFunction(r._options.logFunction),ut.default.logLevel=r._options.debug||0,r._api=new tH.API(n),r._socket=r._createServerConnection(),!_i.supports.audioVideo&&!_i.supports.data?(r._delayedAbort(Fn.BrowserIncompatible,"The current browser does not support WebRTC"),r):s&&!_i.validateId(s)?(r._delayedAbort(Fn.InvalidID,'ID "'.concat(s,'" is invalid')),r):(s?r._initialize(s):r._api.retrieveId().then(function(o){return r._initialize(o)}).catch(function(o){return r._abort(Fn.ServerError,o)}),r)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,n,r=Object.create(null);try{for(var s=Kv(this._connections),o=s.next();!o.done;o=s.next()){var a=bde(o.value,2),l=a[0],c=a[1];r[l]=c}}catch(h){t={error:h}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,n=new q5.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(mh.Message,function(r){t._handleMessage(r)}),n.on(mh.Error,function(r){t._abort(Fn.SocketError,r)}),n.on(mh.Disconnected,function(){t.disconnected||(t.emitError(Fn.Network,"Lost connection to server."),t.disconnect())}),n.on(mh.Close,function(){t.disconnected||t._abort(Fn.SocketClosed,"Underlying socket is already closed.")}),n},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var n,r,s=t.type,o=t.payload,a=t.src;switch(s){case Gr.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Gr.Error:this._abort(Fn.ServerError,o.msg);break;case Gr.IdTaken:this._abort(Fn.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Gr.InvalidKey:this._abort(Fn.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Gr.Leave:ut.default.log("Received leave message from ".concat(a)),this._cleanupPeer(a),this._connections.delete(a);break;case Gr.Expire:this.emitError(Fn.PeerUnavailable,"Could not connect to peer ".concat(a));break;case Gr.Offer:var m=o.connectionId,A=this.getConnection(a,m);if(A&&(A.close(),ut.default.warn("Offer received for existing Connection ID:".concat(m))),o.type===ul.Media){var l=new SD.MediaConnection(a,this,{connectionId:m,_payload:o,metadata:o.metadata});A=l,this._addConnection(a,A),this.emit("call",l)}else if(o.type===ul.Data){var c=new TD.DataConnection(a,this,{connectionId:m,_payload:o,metadata:o.metadata,label:o.label,serialization:o.serialization,reliable:o.reliable});A=c,this._addConnection(a,A),this.emit("connection",c)}else{ut.default.warn("Received malformed connection type:".concat(o.type));return}var h=this._getMessages(m);try{for(var d=Kv(h),p=d.next();!p.done;p=d.next()){var f=p.value;A.handleMessage(f)}}catch(v){n={error:v}}finally{try{p&&!p.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}break;default:if(!o){ut.default.warn("You received a malformed message from ".concat(a," of type ").concat(s));return}var m=o.connectionId,A=this.getConnection(a,m);A&&A.peerConnection?A.handleMessage(t):m?this._storeMessage(m,t):ut.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,n){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(n)},e.prototype._getMessages=function(t){var n=this._lostMessages.get(t);return n?(this._lostMessages.delete(t),n):[]},e.prototype.connect=function(t,n){if(n===void 0&&(n={}),this.disconnected){ut.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(Fn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var r=new TD.DataConnection(t,this,n);return this._addConnection(t,r),r},e.prototype.call=function(t,n,r){if(r===void 0&&(r={}),this.disconnected){ut.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(Fn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){ut.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new SD.MediaConnection(t,this,Jv(Jv({},r),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){ut.default.log("add connection ".concat(n.type,":").concat(n.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(n)},e.prototype._removeConnection=function(t){var n=this._connections.get(t.peer);if(n){var r=n.indexOf(t);r!==-1&&n.splice(r,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,n){var r,s,o=this._connections.get(t);if(!o)return null;try{for(var a=Kv(o),l=a.next();!l.done;l=a.next()){var c=l.value;if(c.connectionId===n)return c}}catch(h){r={error:h}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}return null},e.prototype._delayedAbort=function(t,n){var r=this;setTimeout(function(){r._abort(t,n)},0)},e.prototype._abort=function(t,n){ut.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){ut.default.error("Error:",n);var r;typeof n=="string"?r=new Error(n):r=n,r.type=t,this.emit("error",r)},e.prototype.destroy=function(){this.destroyed||(ut.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,n;try{for(var r=Kv(this._connections.keys()),s=r.next();!s.done;s=r.next()){var o=s.value;this._cleanupPeer(o),this._connections.delete(o)}}catch(a){t={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var n,r,s=this._connections.get(t);if(s)try{for(var o=Kv(s),a=o.next();!a.done;a=o.next()){var l=a.value;l.close()}}catch(c){n={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;ut.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)ut.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)ut.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var n=this;t===void 0&&(t=function(r){}),this._api.listAllPeers().then(function(r){return t(r)}).catch(function(r){return n._abort(Fn.ServerError,r)})},e.DEFAULT_KEY="peerjs",e}(Xv.EventEmitter),RD=H5.Peer;const xde=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return BD},default:RD,util:_i},Symbol.toStringTag,{value:"Module"}));let DD;function _de(){return DD}function wde(i){DD=i}function sH(i,e){return e||(e={}),e={...DD,...e},i?new RD(i,e):new RD(e)}async function oH(){const i=await Promise.resolve().then(()=>xde);return console.log(i),i.default===void 0?i:i.default}class aH{constructor(){u(this,"_host"),u(this,"_client"),u(this,"_clientData"),this.onEnable()}get isHost(){return this._host!==void 0}onEnable(){const e="HOST-5980e65c-8438-453e-8b35-f13c736dcd81";this.trySetupHost(e)}async trySetupHost(e){const t=await oH(),n=new t(e);n.on("error",r=>{console.error(r),this._host=void 0,this.trySetupClient(e)}),n.on("open",r=>{this._host=new Ede(n)})}async trySetupClient(e){const t=await oH();this._client=new t,this._client.on("error",n=>{console.error("Client error",n)}),this._client.on("open",n=>{console.log("client connected",n),this._clientData=this._client.connect(e,{metadata:{id:n}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",r=>{console.log("<<",r)})})}}class Cde{constructor(e){u(this,"_peer"),this._peer=e}}class Ede extends Cde{constructor(e){var t;super(e),u(this,"_connections",[]),console.log("I AM THE HOST"),(t=this._peer)==null||t.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}get isHost(){return!0}onConnection(e){console.log("host connection",e),e.on("open",()=>{this._connections.push(e),this.broadcastConnection(e)})}broadcastConnection(e){const t=this._connections.map(n=>{var r;return(r=n.metadata)==null?void 0:r.id}).filter(n=>n!==void 0);this.broadcast({type:"connection-list",connections:t})}broadcast(e){if(e!=null){console.log(">>",e);for(const t in this._peer.connections){const n=this._peer.connections[t];if(n)if(Array.isArray(n))for(const r of n)r&&r.send(e);else console.warn(n)}}}}const lH="https://urls.needle.tools/default-networking-backend/index";let zu="wss://needle-tiny-starter.glitch.me/socket";const Zs=!!ee("debugnet"),Zv=!!(Zs||ee("debugowner")),cH=ee("debugnetbin");var hH=(i=>(i.ConnectionInfo="connection-start-info",i))(hH||{}),Wt=(i=>(i.Join="join-room",i.Leave="leave-room",i.JoinedRoom="joined-room",i.LeftRoom="left-room",i.UserJoinedRoom="user-joined-room",i.UserLeftRoom="user-left-room",i.RoomStateSent="room-state-sent",i))(Wt||{});class Sde{constructor(){u(this,"room"),u(this,"viewId"),u(this,"allowEditing"),u(this,"inRoom")}}class Ide{constructor(){u(this,"room")}}class Mde{constructor(){u(this,"userId")}}var uH=(i=>(i.RequestHasOwner="request-has-owner",i.ResponseHasOwner="response-has-owner",i.RequestIsOwner="request-is-owner",i.ResponseIsOwner="response-is-owner",i.RequestOwnership="request-ownership",i.GainedOwnership="gained-ownership",i.RemoveOwnership="remove-ownership",i.LostOwnership="lost-ownership",i.GainedOwnershipBroadcast="gained-ownership-broadcast",i.LostOwnershipBroadcast="lost-ownership-broadcast",i))(uH||{});class PD{constructor(e,t){u(this,"guid"),u(this,"connection"),u(this,"_hasOwnership",!1),u(this,"_isOwned"),u(this,"_gainSubscription"),u(this,"_lostSubscription"),u(this,"_hasOwnerResponse"),u(this,"_isWaitingForOwnershipResponseCallback",null),this.connection=e,this.guid=t,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),e.beginListen("lost-ownership",this._lostSubscription),e.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),e.beginListen("response-has-owner",this._hasOwnerResponse)}get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(e){e.guid===this.guid&&(this._isOwned=e.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(e){e.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=e.value,e.value||(Zv&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((e,t)=>{this.requestOwnership();let n=0;const r=()=>{if(n++>10)return t("Timeout");setTimeout(()=>{this.hasOwnership?e(this):r()},100)};r()})}requestOwnership(){return Zv&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(e){e.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===e.owner?(Zv&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(e){e===this.guid&&(Zv&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class dH{constructor(e){u(this,"context"),u(this,"_peer",null),u(this,"_usersInRoomCopy",[]),u(this,"_defaultMessagesBuffer",[]),u(this,"_defaultMessagesBufferArray",[]),u(this,"netWebSocketUrlProvider"),u(this,"_listeners",{}),u(this,"_listenersBinary",{}),u(this,"connected",!1),u(this,"channelId"),u(this,"_connectionId",null),u(this,"_ws"),u(this,"_waitingForSocket",{}),u(this,"_isInRoom",!1),u(this,"_currentRoomName",null),u(this,"_currentRoomViewId",null),u(this,"_currentRoomAllowEditing",!0),u(this,"_currentInRoom",[]),u(this,"_state",{}),u(this,"_currentDelay",-1),u(this,"_connectingToWebsocketPromise",null),this.context=e}get peer(){return this._peer||(this._peer=new aH),this._peer}tryGetState(e){return e==="invalid"?null:this._state[e]}get connectionId(){return this._connectionId}get isDebugEnabled(){return Zs}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const e=new URL(window.location.href);return e.searchParams.set("view",this.currentRoomViewId),e.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){var e;return((e=this._ws)==null?void 0:e.url)??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(e){return this._currentInRoom.indexOf(e)!==-1}usersInRoom(e=null){e||(e=this._usersInRoomCopy),e.length=0;for(const t of this._currentInRoom)e.push(t);return e}joinRoom(e,t=!1){return e?e.length>1024?(console.error('Room name too long, can not join: "'+e+'". Max length is 1024 characters.'),!1):(this.connect(),Zs&&console.log("join: "+e),this.send("join-room",{room:e,viewOnly:t},ya.OnConnection),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}leaveRoom(e=null){return e||(e=this.currentRoomName),e?(this.send("leave-room",{room:e}),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}send(e,t=null,n=ya.Queued){if(t===null&&(t={}),n===ya.Queued){this._defaultMessagesBuffer.push({key:e,value:t});return}return this.sendWithWebsocket(e,t,n)}sendDeleteRemoteState(e){this.send("delete-state",{guid:e,dontSave:!0}),delete this._state[e]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(e){var t;cH&&console.log("<< send binary",this.context.time.frame,e.length/1024+" KB"),(t=this._ws)==null||t.send(e)}sendBufferedMessagesNow(){var e;if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const t=Object.keys(this._defaultMessagesBuffer).length;for(const r in this._defaultMessagesBuffer){const s=this._defaultMessagesBuffer[r];if(t<=1){this.sendWithWebsocket(s.key,s.value,ya.Immediate);break}const o=this.toMessage(s.key,s.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&Zs&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const n=JSON.stringify(this._defaultMessagesBufferArray);(e=this._ws)==null||e.send(n)}beginListen(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),t}stopListening(e,t){return this.stopListen(e,t)}stopListen(e,t){if(!t||!this._listeners[e])return;const n=this._listeners[e].indexOf(t);n>=0&&this._listeners[e].splice(n,1)}beginListenBinary(e,t){return this._listenersBinary[e]||(this._listenersBinary[e]=[]),this._listenersBinary[e].push(t),t}stopListenBinary(e,t){if(!this._listenersBinary[e])return;const n=this._listenersBinary[e].indexOf(t);n>=0&&this._listenersBinary[e].splice(n,1)}registerProvider(e){this.netWebSocketUrlProvider=e}async connect(){var e;if(this.connected)return Promise.resolve(!0);Zs&&console.log("connecting");const t=(e=this.netWebSocketUrlProvider)==null?void 0:e.getWebsocketUrl();return t?zu=t:_N()&&(zu="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){var e;(e=this._ws)==null||e.close(),this._ws=void 0}connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(e,t)=>{var n;let r=!1;const s=c=>{r||(r=!0,e(c))};if(zu===void 0&&(console.log("Fetch default backend url: "+lH),zu=await(await fetch(lH)).text()),zu===void 0){s(!1);return}console.log(`\u22A1 Connecting to networking backend on
5235
- `+zu);const o=await Promise.resolve().then(()=>Yxe),a=((n=o.default)==null?void 0:n.WebsocketBuilder)??o.WebsocketBuilder,l=new a(zu).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=l,this.connected=!0,console.log(`\u229E Connected to networking backend
5235
+ `+zu);const o=await Promise.resolve().then(()=>Xxe),a=((n=o.default)==null?void 0:n.WebsocketBuilder)??o.WebsocketBuilder,l=new a(zu).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=l,this.connected=!0,console.log(`\u229E Connected to networking backend
5236
5236
  `+zu),s(!0),this.onSendQueued(ya.OnConnection)}).onClose(c=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,s(!1)}).onError((c,h)=>{console.error("\u22A0 Websocket error",c,h),s(!1)}).onRetry(()=>{console.log("Retry connecting to networking websocket")}).build();l.addEventListener(o.WebsocketEvent.message,(c,h)=>{this.onMessage(c,h)})})}onMessage(e,t){const n=t.data;try{if(typeof n!="string"){n.size&&this.handleIncomingBinaryMessage(n);return}const r=JSON.parse(n);if(Array.isArray(r))for(const s of r)this.handleIncomingStringMessage(s);else this.handleIncomingStringMessage(r);return}catch(r){Zs&&n==="pong"?console.log("<<",n):rt()&&console.error("Failed to parse message",r)}}async handleIncomingBinaryMessage(e){cH&&console.log("<< bin",this.context.time.frame);const t=await e.arrayBuffer();var n=new Uint8Array(t);const r=new Kb(n),s=r.getBufferIdentifier(),o=this._listenersBinary[s],a=VG(r),l=WG(a);if(l&&typeof l=="string"&&(this._state[l]=a),!o)return;const c=a??r;for(const h of o)h(c)}handleIncomingStringMessage(e){var t,n;if(Zs&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const a=e.data;a&&(console.assert(a.id!==void 0&&a.id!==null&&a.id.length>0,"server did not send connection id",a.id),console.log("Your id is: "+a.id,this.context.alias??""),this._connectionId=a.id)}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(Zs&&console.log(e),e){this._isInRoom=!0;const a=e;this._currentRoomName=a.room,this._currentRoomViewId=a.viewId,this._currentRoomAllowEditing=a.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...a.inRoom),Zs&&console.log("joined room with",this._currentInRoom,this.context.alias??"");const l=new URL(window.location.href);l.searchParams.has("room")&&l.searchParams.delete("room"),l.searchParams.set("view",this._currentRoomViewId),console.log("Room view id: "+this._currentRoomViewId+`
5237
5237
  `+l.href)}this.onSendQueued(ya.OnRoomJoin);break;case"left-room":e.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(e.data){const a=e.data;this._currentInRoom.push(a.userId),Zs&&console.log(a.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const a=e.data,l=this._currentInRoom.indexOf(a.userId);l>=0&&(Zs&&console.log(a.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(l,1)),a.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Zs&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const o=(t=e.data)==null?void 0:t.time;o&&(this._currentDelay=this.context.time.time-o),Zs&&console.log("Current latency: "+this._currentDelay.toFixed(1)+" sec","Clients in room: "+((n=this._currentInRoom)==null?void 0:n.length));break}let r=this._listeners[e.key];if(r){r=[...r];for(const o of r)try{o(e.data)}catch(a){console.error('Error invoking callback for "'+e.key+'"',a)}}const s=e.data;s&&(this._state[s.guid]=s)}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,n=ya.OnRoomJoin){if(!this._ws){const s=this._waitingForSocket[n]||[];s.push(()=>this.sendWithWebsocket(e,t,n)),this._waitingForSocket[n]=s;return}const r=JSON.stringify(this.toMessage(e,t));Zs&&console.log(">>",e),this._ws.send(r)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const n of t)n();t.length=0}}}const $v=ee("debugwebxr");class kD{constructor(e,t){u(this,"controllerStates",[]),u(this,"userId"),u(this,"context"),u(this,"userStateEvtName"),u(this,"onReceivedControllerState",n=>{$v&&console.log(`XRSync: Received change for ${this.userId}: ${n.type} ${n.handedness}; tracked=${n.isTracking}`);let r=!1;for(let s=0;s<this.controllerStates.length;s++)if(this.controllerStates[s].index===n.index){this.controllerStates[s]=n,r=!0;break}r||this.controllerStates.push(n)}),this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const n=this.controllerStates[t];let r=!1;for(let s=0;s<e.controllers.length;s++)e.controllers[s].index===n.index&&(r=!0);r||($v&&console.log(`XRSync: ${n.type} ${n.handedness} removed`,n.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(n))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(n=>n.index===e.index);if(t){let n=!1;n||(n=t.isTracking!=e.isTracking),n&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const n={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(n),this.context.connection.send(this.userStateEvtName,n),$v&&console.log(`XRSync: ${n.type} ${n.handedness} added`,n.index)}}}class pH{constructor(e){u(this,"context"),u(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||($v&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new kD(this.context.connection.connectionId,this.context)));for(const t of this.context.connection.usersInRoom())this._states.has(t)||this._states.set(t,new kD(t,this.context))}}),u(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const t=this._states.get(this.context.connection.connectionId);t?.dispose(),this._states.delete(this.context.connection.connectionId)}}),u(this,"onOtherUserJoinedRoom",t=>{const n=t.userId;this._states.has(n)||($v&&console.log("XRSync: Remote user joined room",n),this._states.set(n,new kD(n,this.context)))}),u(this,"onOtherUserLeftRoom",t=>{const n=t.userId;if(!this._states.has(n)){const r=this._states.get(n);r?.dispose(),this._states.delete(n)}}),u(this,"_states",new Map),this.context=e,this.context.connection.beginListen(Wt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Wt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Wt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Wt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const n=this._states.get(e);if(!n)return;const r=n.controllerStates.find(s=>s.handedness===t);return r?.isTracking||!1}getDeviceType(e,t){if(!e)return;const n=this._states.get(e);if(!n)return;const r=n.controllerStates.find(s=>s.handedness===t);return r?.type||"unknown"}destroy(){this.context.connection.stopListen(Wt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Wt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Wt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Wt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t?.update(e)}}onExitXR(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t?.onExitXR(e)}}}class fH{constructor(){u(this,"_fadeToColorQuad"),u(this,"_fadeToColorMaterial"),u(this,"_requestedFadeValue",0),u(this,"_transitionPromise",null),u(this,"_transitionResolve",null),this._fadeToColorMaterial=new Zt({color:0,transparent:!0,depthTest:!1,fog:!1,side:mi}),this._fadeToColorQuad=new pe(new ir(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const n=this._fadeToColorQuad,r=this._fadeToColorMaterial;n.parent!==e&&r.opacity>0?e.add(n):r.opacity===0&&n.removeFromParent(),n.layers.set(2),n.material=this._fadeToColorMaterial,n.position.z=-1,n.renderOrder=1/0;const s=this._requestedFadeValue;r.opacity=$e.lerp(r.opacity,s,t/.03),Math.abs(r.opacity-s)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}}var Gp=(i=>(i[i.Quad=0]="Quad",i[i.Cube=1]="Cube",i[i.Sphere=2]="Sphere",i))(Gp||{});class ey{static createPrimitive(e,t){let n;switch(e){case"Quad":case 0:{const r=new ir(1,1,1,1),s=t?.material??new ps({color:16777215});t!=null&&t.texture&&"map"in s&&(s.map=t.texture),n=new pe(r,s)}break;case"Cube":case 1:{const r=new Wi(1,1,1),s=t?.material??new ps({color:16777215});t!=null&&t.texture&&"map"in s&&(s.map=t.texture),n=new pe(r,s)}break;case"Sphere":case 2:{const r=new _l(.5,16,16),s=t?.material??new ps({color:16777215});t!=null&&t.texture&&"map"in s&&(s.map=t.texture),n=new pe(r,s)}break}return this.applyDefaultObjectOptions(n,t),n}static createSprite(e){const t=new o_({color:16777215});e!=null&&e.texture&&"map"in t&&(t.map=e.texture);const n=new fM(t);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){t!=null&&t.name&&(e.name=t.name),t!=null&&t.position&&e.position.set(t.position.x,t.position.y,t.position.z),t!=null&&t.rotation&&e.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),t!=null&&t.scale&&e.scale.set(t.scale.x,t.scale.y,t.scale.z)}}const mH=class{constructor(i,e,t){u(this,"_session"),u(this,"_mode"),u(this,"_init"),u(this,"_renderer"),u(this,"_camera"),u(this,"_scene"),u(this,"onEnd",()=>{var n;(n=this._session)==null||n.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),u(this,"_lastTime",0),u(this,"onFrame",(n,r)=>{const s=n-this._lastTime;this.update(n,s),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),u(this,"_objects",[]),this._mode=i,this._init=e,this._session=t,this._session.addEventListener("end",this.onEnd),this._renderer=new jc({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(t),this._renderer.xr.enabled=!0,this._camera=new Dt,this._scene=new Fr,this._scene.fog=new s_(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(i,e){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!e)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const t=await navigator.xr.requestSession(i,e);return t.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new mH(i,e,t),this._active):(t.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await kl(100)),this._active=null}get isAR(){return this._mode==="immersive-ar"}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const i={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,i}async onBeforeHandoff(){await kl(1e3),this._scene.clear()}setupScene(){this._scene.background=new _e(0),this._scene.add(new j_(5,10,1118481,1118481));const i=new ep(16777215,1);i.position.set(0,20,0),i.castShadow=!1,this._scene.add(i);const e=new ep(16777215,1);e.position.set(0,-1,0),e.castShadow=!1,this._scene.add(e);const t=new $d(16777215,1,100,1);t.position.set(0,2,0),t.castShadow=!1,t.distance=200,this._scene.add(t);const n=50;for(let r=0;r<100;r++){const s=new ps({color:2236962,metalness:1,roughness:.8});this.isAR&&(s.emissive=new _e(Math.random(),Math.random(),Math.random()),s.emissiveIntensity=Math.random());const o=$e.random(0,1)>.5?Gp.Sphere:Gp.Cube,a=ey.createPrimitive(o,{material:s});a.position.x=$e.random(-n,n),a.position.y=$e.random(-2,n),a.position.z=$e.random(-n,n),a.rotation.x=$e.random(0,Math.PI*2),a.rotation.y=$e.random(0,Math.PI*2),a.rotation.z=$e.random(0,Math.PI*2),a.scale.multiplyScalar(.5+Math.random()*10);const l=a.position.distanceTo(this._camera.position)-a.scale.x;l<1&&a.position.multiplyScalar(1+1/l),this._objects.push(a),this._scene.add(a)}}update(i,e){const t=i*4e-4;for(let n=0;n<this._objects.length;n++){const r=this._objects[n];r.position.y+=Math.sin(t+n*.5)*.005,r.rotateY(.002)}}};let Ig=mH;u(Ig,"_active",null),u(Ig,"_requestInFlight",!1);const Cr=ee("debugwebxr"),Tde=ee("stats");function Bde(i){let e=null;const t=i;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=i,e}Rde();async function Rde(){var i;if(ee("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],hi.addContextCreatedCallback(async t=>{if(!e)return;Dm(!0);const n=await e;if(n){const r=_t.getDefaultSessionInit("immersive-vr");_t.setSession("immersive-vr",n,r,t.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(i=navigator.xr)==null||i.addEventListener("sessiongranted",async()=>{Dm(!0),console.log("Received Session Granted..."),await kl(100);const e=sessionStorage.getItem("needle_xr_session_mode"),t=sessionStorage.getItem("needle_xr_session_init")??null,n=t?JSON.parse(t):null;let r=null;if(gH()&&(await Ig.start(e||"immersive-vr",n||_t.getDefaultSessionInit("immersive-vr")),await kde(),r=await Ig.handoff()),r)_t.setSession(r.mode,r.session,r.init,kt.Current);else if(e&&t){console.log("Session Granted: Restore last session");const s=JSON.parse(t);_t.start(e,s).catch(o=>console.warn(o))}else _t.start("immersive-vr").catch(s=>console.warn("Session Granted failed:",s))},{once:!0})}}function Dde(i,e){sessionStorage.setItem("needle_xr_session_mode",i),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function Pde(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const OD=new Set;hi.registerCallback(Ei.ContextCreationStart,async i=>{OD.add(i.context)}),hi.registerCallback(Ei.ContextCreated,async i=>{OD.delete(i.context)});function gH(){return OD.size>0}function kde(){return new Promise(i=>{const e=Date.now(),t=setInterval(()=>{(!gH()||Date.now()-e>6e4)&&(clearInterval(t),i())},100)})}ap()&&rt()&&window.addEventListener("keydown",i=>{(i.key==="x"||i.key==="Escape")&&_t.active&&_t.stop()});const ju=class{constructor(i,e,t,n){u(this,"context"),u(this,"session"),u(this,"mode"),u(this,"controllers",[]),u(this,"_rigScale",1),u(this,"_lastRigScaleUpdate",-1),u(this,"_rigs",[]),u(this,"_viewerHitTestSource",null),u(this,"_defaultRig"),u(this,"_xr_scripts"),u(this,"_xr_update_scripts",[]),u(this,"_inactive_scripts",[]),u(this,"_controllerAdded"),u(this,"_controllerRemoved"),u(this,"_originalCameraWorldPosition"),u(this,"_originalCameraWorldRotation"),u(this,"_originalCameraWorldScale"),u(this,"_originalCameraParent"),u(this,"_mainCamera",null),u(this,"onRendererSessionSet",()=>{var o;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(o=this.context.mainCameraComponent)==null||o.applyClearFlags())}),u(this,"onInputSourceAdded",o=>{if(o.targetRayMode==="screen")return;let a=0;for(let c=0;c<this.session.inputSources.length;c++)if(this.session.inputSources[c]===o){a=c;break}if(this.controllers.find(c=>c.inputSource===o)){console.warn("Controller already exists for input source",a);return}Cr&&console.log("Adding controller",a);const l=new cD(this,o,a);this._newControllers.push(l)}),u(this,"_ended",!1),u(this,"_newControllers",[]),u(this,"onEnd",o=>{var a,l,c;if(this._ended)return;this._ended=!0,Cr&&console.log("XR Session ended"),Pde(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,Nu(this.onBefore,Gi.LateUpdate);const h=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);h>=0&&this.context.pre_render_callbacks.splice(h,1);const d=this.context.post_render_callbacks.indexOf(this.onAfterRender);d>=0&&this.context.post_render_callbacks.splice(d,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var p;(p=this.context.mainCameraComponent)==null||p.applyClearFlags()}),LG({session:this});for(const p of ju._xrEndListeners)p({xr:this});for(let p=0;p<this.controllers.length;p++)this.disconnectInputSource(this.controllers[p].inputSource);for(const p of this._xr_scripts)(a=p?.onLeaveXR)==null||a.call(p,{xr:this});(l=this.sync)==null||l.onExitXR(this),this.context.mainCamera&&((c=this._originalCameraParent)==null||c.add(this.context.mainCamera),this._originalCameraWorldPosition&&mr(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&oa(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&Rm(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),Dm(!1)}),u(this,"_didStart",!1),u(this,"onBefore",o=>{var a,l,c,h,d,p,f,m;const A=o.xrFrame;if(!A)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((a=this.rig)==null?void 0:a.isActive)==!1&&(Cr&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(l=this._mainCamera)!=null&&l.gameObject&&((h=(c=this._mainCamera)==null?void 0:c.gameObject)==null?void 0:h.parent)!==this.rig.gameObject&&this.rig.gameObject.add((d=this._mainCamera)==null?void 0:d.gameObject),this.internalUpdateState(),this.applyCustomForward();const v={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const g=[...this.context.new_scripts_xr];for(let y=0;y<g.length;y++){const b=this.context.new_scripts_xr[y];if(!b||b.destroyed||((p=b.supportsXR)==null?void 0:p.call(b,this.mode))==!1){this.context.new_scripts_xr.splice(y,1);continue}if(!b.activeAndEnabled){this.context.new_scripts_xr.splice(y,1),this.markInactive(b);continue}if(this.addScript(b)){this.invokeCallback_EnterXR(b);for(const x of this.controllers)this.invokeCallback_ControllerAdded(b,x)}}}}else{this._didStart=!0,OG({session:this});for(const y of ju._xrStartListeners)y(v);const g=[...this._xr_scripts];Cr&&console.log("NeedleXRSession start, handle scripts:",g);for(const y of g){if(y.destroyed){this._script_to_remove.push(y);continue}if(!y.activeAndEnabled){this.markInactive(y);continue}this.invokeCallback_EnterXR(y);for(const b of this.controllers)this.invokeCallback_ControllerAdded(y,b)}}this.syncCameraCullingMask();for(const g of this.controllers)g.onUpdate(A);if(this._newControllers.length>0){const g=[...this._newControllers];this._newControllers.length=0;for(const y of g)if(y.connected){this.controllers.push(y);for(const b of this._xr_scripts){if(b.destroyed){this._script_to_remove.push(b);continue}b.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(b,y)}}this.controllers.sort((y,b)=>y.index-b.index)}for(const g of this._xr_update_scripts){if(g.destroyed===!0){this._script_to_remove.push(g);continue}if(g.activeAndEnabled===!1){this.markInactive(g);continue}g.onUpdateXR&&g.onUpdateXR(v)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const g=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const y of g)!y.destroyed&&this.running&&((f=y.onLeaveXR)==null||f.call(y,v)),this.removeScript(y)}(m=this.sync)==null||m.onUpdate(this),this.onRenderDebug()}),u(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),u(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),ap()){const o=this.context.renderer;if(o.xr.isPresenting&&this.context.mainCamera){const a=o.xr.enabled,l=o.getRenderTarget();o.xr.enabled=!1,o.setRenderTarget(null),o.render(this.context.scene,this.context.mainCamera),o.xr.enabled=a,o.setRenderTarget(l)}}}),u(this,"_script_to_remove",[]),u(this,"_camera"),u(this,"_cameraRenderParent",new ve().rotateY(Math.PI)),u(this,"_previousCameraParent"),u(this,"_customforward",!0),u(this,"originalCameraNearPlane"),u(this,"_viewerPose"),u(this,"_transformOrientation",new Ce),u(this,"_transformPosition",new E),u(this,"_transition");var r,s;Dde(i,n.init),this.session=e,this.mode=i,this.context=t,(Cr||ee("console"))&&Dm(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(o=>typeof o.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,Uu(this.onBefore,Gi.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=n.init.optionalFeatures)!=null&&r.includes("hit-test")||(s=n.init.requiredFeatures)!=null&&s.includes("hit-test"))&&e.requestReferenceSpace("viewer").then(o=>{var a,l;return(l=(a=e.requestHitTestSource)==null?void 0:a.call(e,{space:o}))==null?void 0:l.then(c=>this._viewerHitTestSource=c)}).catch(o=>console.warn(o)),this.context.mainCamera&&(this._originalCameraWorldPosition=Tt(this.context.mainCamera,new E),this._originalCameraWorldRotation=Ti(this.context.mainCamera,new Ce),this._originalCameraWorldScale=zi(this.context.mainCamera,new E),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new Fue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let o=0;o<e.inputSources.length;o++){const a=e.inputSources[o];if(!a.handedness){console.warn("Input source in xr session has no handedness - ignoring",o);continue}this.onInputSourceAdded(a)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",o=>{for(const a of o.removed)this.disconnectInputSource(a);for(const a of o.added)this.onInputSourceAdded(a)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(i){return this._sync||(this._sync=new pH(i)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var i;return((i=this._activeSession)==null?void 0:i.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(i=>i.some(e=>e)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(i){var e;return((e=this.xrSystem)==null?void 0:e.isSessionSupported(i).catch(t=>(Cr&&console.error(t),!1)))??Promise.resolve(!1)}static onSessionRequestStart(i){this._sessionRequestStartListeners.push(i)}static offSessionRequestStart(i){const e=this._sessionRequestStartListeners.indexOf(i);e>=0&&this._sessionRequestStartListeners.splice(e,1)}static onSessionRequestEnd(i){this._sessionRequestEndListeners.push(i)}static offSessionRequestEnd(i){const e=this._sessionRequestEndListeners.indexOf(i);e>=0&&this._sessionRequestEndListeners.splice(e,1)}static onXRSessionStart(i){this._xrStartListeners.push(i)}static offXRSessionStart(i){const e=this._xrStartListeners.indexOf(i);e>=0&&this._xrStartListeners.splice(e,1)}static onXRSessionEnd(i){this._xrEndListeners.push(i)}static offXRSessionEnd(i){const e=this._xrEndListeners.indexOf(i);e>=0&&this._xrEndListeners.splice(e,1)}static onControllerAdded(i){this._controllerAddedListeners.push(i)}static offControllerAdded(i){const e=this._controllerAddedListeners.indexOf(i);e>=0&&this._controllerAddedListeners.splice(e,1)}static onControllerRemoved(i){this._controllerRemovedListeners.push(i)}static offControllerRemoved(i){const e=this._controllerRemovedListeners.indexOf(i);e>=0&&this._controllerRemovedListeners.splice(e,1)}static offerSession(i,e,t){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+i),e=="default"&&(e=this.getDefaultSessionInit(i)),navigator.xr.offerSession(i,{...e}).then(n=>ju.setSession(i,n,e,t)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(i){switch(i){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",i),{}}}static async start(i,e,t){var n,r,s,o;if(rt()&&ee("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await Ig.start(i,e||ju.getDefaultSessionInit(i)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Cr||rt())&&Pi("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(t||(t=kt.Current),t||(t=hi.All[0]),!t)throw new Error("No Needle Engine Context found");switch(e||(e={}),i){case"immersive-ar":{if(await((n=this.xrSystem)==null?void 0:n.isSessionSupported("immersive-ar"))!==!0)return console.error(i+" is not supported by this browser."),null;const c=this.getDefaultSessionInit(i),h=Bde(t.domElement);h&&!K_()&&(c.domOverlay={root:h},c.optionalFeatures.push("dom-overlay")),e={...c,...e}}break;case"immersive-vr":{if(await((r=this.xrSystem)==null?void 0:r.isSessionSupported("immersive-vr"))!==!0)return console.error(i+" is not supported by this browser."),null;e={...this.getDefaultSessionInit(i),...e}}break;default:console.warn("No default session init for mode",i);break}e.optionalFeatures??(e.optionalFeatures=[]),e.requiredFeatures??(e.requiredFeatures=[]),await Ig.stop();const a=i=="immersive-ar"?t.scripts_immersive_ar:t.scripts_immersive_vr;Cr?console.log(`%cRequesting ${i} session`,"font-weight:bold;",e,a):console.log(`%cRequesting ${i} session`,"font-weight:bold;");for(const c of a)c.onBeforeXR&&c.onBeforeXR(i,e);for(const c of this._sessionRequestStartListeners)c({mode:i,init:e});Cr&&nn("Requesting "+i+" session ("+Date.now()+")"),this._currentSessionRequest=(s=navigator.xr)==null?void 0:s.requestSession(i,e),this._currentSessionRequestMode=i;const l=await((o=this._currentSessionRequest)==null?void 0:o.catch(c=>{console.error(c,"Code: "+c.code),c.code===9&&Pi("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&Pi("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const c of this._sessionRequestEndListeners)c({mode:i,init:e,newSession:l||null});return l?this.setSession(i,l,e,t):(console.warn("XR Session request was rejected"),null)}static setSession(i,e,t,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=i=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new ju(i,e,n,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:t}),e.addEventListener("end",this.onEnd),Cr?console.log(`%cStarted ${i} session`,"font-weight:bold;",r):console.log(`%cStarted ${i} session`,"font-weight:bold;"),this._activeSession}static stop(){var i;(i=this._activeSession)==null||i.end()}get sync(){return ju._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(i=>i.isLeft)}get rightController(){return this.controllers.find(i=>i.isRight)}getController(i){return typeof i=="number"?this.controllers[i]||null:this.controllers.find(e=>e.side===i)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(i=>i.inputSource.targetRayMode==="tracked-pointer")||rt()&&ap()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const i=this.frame.getImageTrackingResults();for(const e of i)if(e.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const i=this._rigs[0]??null;return i!=null&&i.gameObject&&Hp(i.gameObject)||i?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):i}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(i){this._rigs.indexOf(i)>=0||(i.priority===void 0&&(i.priority=0),this._rigs.push(i),this.updateActiveXRRig())}removeRig(i){const e=this._rigs.indexOf(i);e!==-1&&(this._rigs.splice(e,1),this.updateActiveXRRig())}setRigActive(i){const e=this._rigs.indexOf(i);this._rigs.splice(e,1),this._rigs.unshift(i),this.updateActiveXRRig()}updateActiveXRRig(){const i=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let e=this._rigs[0];e&&e.priority===void 0&&(e.priority=0);for(let t=1;t<this._rigs.length;t++){const n=this._rigs[t];if(n.isActive){if(Hp(n.gameObject)){this._rigs.splice(t,1),t--;continue}(!e||e.isActive===!1||n.priority!==void 0&&n.priority>e.priority)&&(e=n)}}if(i!==e){const t=this._rigs.indexOf(e);t>=0&&this._rigs.splice(t,1),this._rigs.unshift(e)}Cr&&(i===e?console.log("Updated Active XR Rig:",e,"prev:",i):console.log("Updated Active XRRig:",e," (the same as before)"))}getHitTest(i){if(i)return this.getControllerHitTest(i);if(!this._viewerHitTestSource)return null;const e=this._viewerHitTestSource,t=this.frame.getHitTestResults(e);if(t.length>0){const n=t[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(i){const e=i.hitTestSource;if(!e)return null;const t=this.frame.getHitTestResultsForTransientInput(e);for(const n of t)if(n.inputSource===i.inputSource)for(const r of n.results)return this.convertHitTestResult(r);return null}convertHitTestResult(i){const e=this.context.renderer.xr.getReferenceSpace(),t=e&&i.getPose(e);if(t){const n=En(t.transform.position),r=dp(t.transform.orientation),s=this.context.mainCamera;if(s?.parent!==this._cameraRenderParent&&n.applyMatrix4(z1),s!=null&&s.parent){n.applyMatrix4(s.parent.matrixWorld),r.multiply(xa);const o=Ti(s.parent);o.premultiply(xa),r.premultiply(o)}return{hit:i,position:n,quaternion:r}}return null}convertSpace(i){const e=En(i.position);e.applyMatrix4(z1);const t=dp(i.orientation);return t.premultiply(xa),{position:e,quaternion:t}}disconnectInputSource(i){const e=(t,n,r)=>{if(t.inputSource===i){Cr&&console.log("Disconnecting controller",t.index),this.controllers.splice(r,1),this.invokeControllerEvent(t,this._controllerRemoved,"removed");const s={xr:this,controller:t,change:"removed"};for(const o of this._xr_scripts)o.onXRControllerRemoved&&o.onXRControllerRemoved(s);t.onDisconnected()}};for(let t=this.controllers.length-1;t>=0;t--){const n=this.controllers[t];e(n,this.controllers,t)}for(let t=this._newControllers.length-1;t>=0;t--){const n=this._newControllers[t];e(n,this._newControllers,t)}}end(){this._ended||this.session.end().catch(i=>console.warn(i))}onRenderDebug(){if(Cr)for(const i of this.controllers)i.onRenderDebug();if((Cr||Tde)&&this.rig){const i=this.rig.gameObject.worldPosition,e=this.rig.gameObject.worldForward;i.add(e.multiplyScalar(1.5));const t=this.rig.gameObject.worldUp;i.add(t.multiplyScalar(2.5));let n="";if(n+=this.context.time.smoothedFps.toFixed(1),Cr)for(const r of this.controllers)n+=`
5238
5238
  ${r.hand?"hand":"ctrl"} ${r.inputSource.handedness}[${r.index}] con:${r.connected} tr:${r.isTracking}`;At.DrawLabel(i,n)}}addScript(i){return this._xr_scripts.includes(i)?!1:(Cr&&console.log("Register new XRScript",i),this._xr_scripts.push(i),typeof i.onUpdateXR=="function"&&this._xr_update_scripts.push(i),!0)}markInactive(i){if(!(this._inactive_scripts.indexOf(i)>=0)){this.removeScript(i,!1),this._inactive_scripts.push(i);for(const e of this.controllers)this.invokeCallback_ControllerRemoved(i,e);this.invokeCallback_LeaveXR(i)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let i=this._inactive_scripts.length-1;i>=0;i--){const e=this._inactive_scripts[i];if(e.activeAndEnabled){this._inactive_scripts.splice(i,1),this.addScript(e),this.invokeCallback_EnterXR(e);for(const t of this.controllers)this.invokeCallback_ControllerAdded(e,t)}}}removeScript(i,e=!0){Cr&&console.log("Remove XRScript",i);const t=this._xr_scripts.indexOf(i);t>=0&&this._xr_scripts.splice(t,1);const n=this._xr_update_scripts.indexOf(i);if(n>=0&&this._xr_update_scripts.splice(n,1),e){const r=this._inactive_scripts.indexOf(i);r>=0&&this._inactive_scripts.splice(r,1)}}invokeCallback_EnterXR(i){i.onEnterXR&&i.onEnterXR({xr:this})}invokeCallback_ControllerAdded(i,e){i.onXRControllerAdded&&i.onXRControllerAdded({xr:this,controller:e,change:"added"})}invokeCallback_ControllerRemoved(i,e){i.onXRControllerRemoved&&i.onXRControllerRemoved({xr:this,controller:e,change:"removed"})}invokeCallback_LeaveXR(i){i.onLeaveXR&&!i.destroyed&&i.onLeaveXR({xr:this})}syncCameraCullingMask(){var i;const e=this.context.xrCamera,t=(i=this.context.mainCameraComponent)==null?void 0:i.cullingMask;if(e&&t!==void 0){for(const n of e.cameras)n.layers.mask=t;e.layers.mask=t}else if(e){for(const n of e.cameras)n.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(i,e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r)try{r({xr:this,controller:i,change:t})}catch(s){console.error(s)}}}applyCustomForward(){var i;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(i=this._previousCameraParent)==null||i.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let e=.02;if(this.rig){const t=zi(this.rig.gameObject);e*=t.x}this._camera instanceof Dt&&this._camera.near>e&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=e)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Dt&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const i=this.context.renderer.xr.getReferenceSpace();if(!i){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(i),this._viewerPose){const e=this._viewerPose.transform;this._transformPosition.set(e.position.x,e.position.y,e.position.z),this._transformOrientation.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w)}}get transition(){return this._transition||(this._transition=new fH),this._transition}fadeTransition(){return this._transition||(this._transition=new fH),this._transition.fadeTransition()}updateFade(i){this._transition&&i instanceof Dt&&this._transition.update(i,this.context.time.deltaTime)}onUpdateFade_PostRender(){var i;(i=this._transition)==null||i.remove()}};let _t=ju;u(_t,"_sync",null),u(_t,"_currentSessionRequestMode",null),u(_t,"_currentSessionRequest"),u(_t,"_activeSession"),u(_t,"_sessionRequestStartListeners",[]),u(_t,"_sessionRequestEndListeners",[]),u(_t,"_xrStartListeners",[]),u(_t,"_xrEndListeners",[]),u(_t,"_controllerAddedListeners",[]),u(_t,"_controllerRemovedListeners",[]),u(_t,"onEnd",()=>{Cr&&console.log("XR Session ended"),ju._activeSession=null});const LD=ee("debugwebxr");class AH{static tryFindAvatarObjects(e,t,n){if(n.head&&n.leftHand&&n.rightHand)return;const r=e.name.toLocaleLowerCase();!n.head&&r.includes("head")&&(LD&&console.log("FOUND AVATAR HEAD",e.name),n.head=new ti("",t,e)),r.includes("hand")&&(!n.leftHand&&r.includes("left")&&(LD&&console.log("FOUND AVATAR LEFT HAND",e.name),n.leftHand=new ti("",t,e)),!n.rightHand&&r.includes("right")&&(LD&&console.log("FOUND AVATAR RIGHT HAND",e.name),n.rightHand=new ti("",t,e)));for(let s=0;s<e.children.length;s++){if(n.head&&n.leftHand&&n.rightHand)return;const o=e.children[s];this.tryFindAvatarObjects(o,t,n)}}}var tC=(i=>(i.Visible="application-visible",i.Hidden="application-hidden",i.MuteChanged="application-mutechanged",i))(tC||{});let iC=!1;const Mg=[];function Tg(){if(iC)return;rt()&&console.debug("User interaction registered: audio can now be played"),iC=!0;const i=[...Mg];Mg.length=0,i.forEach(e=>e())}document.addEventListener("pointerdown",Tg),document.addEventListener("click",Tg),document.addEventListener("dragstart",Tg),document.addEventListener("touchstart",Tg),document.addEventListener("keydown",Tg),_t.onXRSessionStart(()=>{Tg()});const vH=class extends EventTarget{constructor(i){super(),u(this,"_mute",!1),u(this,"context"),u(this,"_isVisible",!0),this.context=i,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return iC}static registerWaitForInteraction(i){if(i!==null){if(iC){i();return}Mg.indexOf(i)===-1&&Mg.push(i)}}static unregisterWaitForInteraction(i){const e=Mg.indexOf(i);e!==-1&&Mg.splice(e,1)}get muted(){return this._mute}set muted(i){i!==this._mute&&(this._mute=i,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(i){switch(i.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}};let Gu=vH;u(Gu,"registerWaitForAllowAudio",vH.registerWaitForInteraction);function*yH(i,e=null){const t=e?e.time:kt.Current.time,n=t.time;for(;t.time-n<i;)yield}function*Ode(i){for(let e=0;e<i;e++)yield}function*bH(i){let e=!0;for(i.then(()=>e=!1),i.catch(()=>e=!1);e;)yield}class ty extends GM{constructor(e){super(e),this.type=dn}parse(e){const t=Math.pow(2.7182818,2.2);function n(C,R){let z=0;for(let N=0;N<65536;++N)(N==0||C[N>>3]&1<<(N&7))&&(R[z++]=N);const $=z-1;for(;z<65536;)R[z++]=0;return $}function r(C){for(let R=0;R<16384;R++)C[R]={},C[R].len=0,C[R].lit=0,C[R].p=null}const s={l:0,c:0,lc:0};function o(C,R,z,$,N){for(;z<C;)R=R<<8|W($,N),z+=8;z-=C,s.l=R>>z&(1<<C)-1,s.c=R,s.lc=z}const a=new Array(59);function l(C){for(let z=0;z<=58;++z)a[z]=0;for(let z=0;z<65537;++z)a[C[z]]+=1;let R=0;for(let z=58;z>0;--z){const $=R+a[z]>>1;a[z]=R,R=$}for(let z=0;z<65537;++z){const $=C[z];$>0&&(C[z]=$|a[$]++<<6)}}function c(C,R,z,$,N,J){const V=R;let oe=0,le=0;for(;$<=N;$++){if(V.value-R.value>z)return!1;o(6,oe,le,C,V);const xe=s.l;if(oe=s.c,le=s.lc,J[$]=xe,xe==63){if(V.value-R.value>z)throw new Error("Something wrong with hufUnpackEncTable");o(8,oe,le,C,V);let Te=s.l+6;if(oe=s.c,le=s.lc,$+Te>N+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Te--;)J[$++]=0;$--}else if(xe>=59){let Te=xe-59+2;if($+Te>N+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Te--;)J[$++]=0;$--}}l(J)}function h(C){return C&63}function d(C){return C>>6}function p(C,R,z,$){for(;R<=z;R++){const N=d(C[R]),J=h(C[R]);if(N>>J)throw new Error("Invalid table entry");if(J>14){const V=$[N>>J-14];if(V.len)throw new Error("Invalid table entry");if(V.lit++,V.p){const oe=V.p;V.p=new Array(V.lit);for(let le=0;le<V.lit-1;++le)V.p[le]=oe[le]}else V.p=new Array(1);V.p[V.lit-1]=R}else if(J){let V=0;for(let oe=1<<14-J;oe>0;oe--){const le=$[(N<<14-J)+V];if(le.len||le.p)throw new Error("Invalid table entry");le.len=J,le.lit=R,V++}}}return!0}const f={c:0,lc:0};function m(C,R,z,$){C=C<<8|W(z,$),R+=8,f.c=C,f.lc=R}const A={c:0,lc:0};function v(C,R,z,$,N,J,V,oe,le){if(C==R){$<8&&(m(z,$,N,J),z=f.c,$=f.lc),$-=8;let xe=z>>$;if(xe=new Uint8Array([xe])[0],oe.value+xe>le)return!1;const Te=V[oe.value-1];for(;xe-- >0;)V[oe.value++]=Te}else if(oe.value<le)V[oe.value++]=C;else return!1;A.c=z,A.lc=$}function g(C){return C&65535}function y(C){const R=g(C);return R>32767?R-65536:R}const b={a:0,b:0};function x(C,R){const z=y(C),$=y(R),N=z+($&1)+($>>1),J=N,V=N-$;b.a=J,b.b=V}function w(C,R){const z=g(C),$=g(R),N=z-($>>1)&65535,J=$+N-32768&65535;b.a=J,b.b=N}function I(C,R,z,$,N,J,V){const oe=V<16384,le=z>N?N:z;let xe=1,Te,We;for(;xe<=le;)xe<<=1;for(xe>>=1,Te=xe,xe>>=1;xe>=1;){We=0;const Ve=We+J*(N-Te),Ye=J*xe,ft=J*Te,it=$*xe,bt=$*Te;let Yt,Li,$i,dr;for(;We<=Ve;We+=ft){let Di=We;const ri=We+$*(z-Te);for(;Di<=ri;Di+=bt){const Bn=Di+it,no=Di+Ye,Hn=no+it;oe?(x(C[Di+R],C[no+R]),Yt=b.a,$i=b.b,x(C[Bn+R],C[Hn+R]),Li=b.a,dr=b.b,x(Yt,Li),C[Di+R]=b.a,C[Bn+R]=b.b,x($i,dr),C[no+R]=b.a,C[Hn+R]=b.b):(w(C[Di+R],C[no+R]),Yt=b.a,$i=b.b,w(C[Bn+R],C[Hn+R]),Li=b.a,dr=b.b,w(Yt,Li),C[Di+R]=b.a,C[Bn+R]=b.b,w($i,dr),C[no+R]=b.a,C[Hn+R]=b.b)}if(z&xe){const Bn=Di+Ye;oe?x(C[Di+R],C[Bn+R]):w(C[Di+R],C[Bn+R]),Yt=b.a,C[Bn+R]=b.b,C[Di+R]=Yt}}if(N&xe){let Di=We;const ri=We+$*(z-Te);for(;Di<=ri;Di+=bt){const Bn=Di+it;oe?x(C[Di+R],C[Bn+R]):w(C[Di+R],C[Bn+R]),Yt=b.a,C[Bn+R]=b.b,C[Di+R]=Yt}}Te=xe,xe>>=1}return We}function M(C,R,z,$,N,J,V,oe,le){let xe=0,Te=0;const We=V,Ve=Math.trunc($.value+(N+7)/8);for(;$.value<Ve;)for(m(xe,Te,z,$),xe=f.c,Te=f.lc;Te>=14;){const ft=xe>>Te-14&16383,it=R[ft];if(it.len)Te-=it.len,v(it.lit,J,xe,Te,z,$,oe,le,We),xe=A.c,Te=A.lc;else{if(!it.p)throw new Error("hufDecode issues");let bt;for(bt=0;bt<it.lit;bt++){const Yt=h(C[it.p[bt]]);for(;Te<Yt&&$.value<Ve;)m(xe,Te,z,$),xe=f.c,Te=f.lc;if(Te>=Yt&&d(C[it.p[bt]])==(xe>>Te-Yt&(1<<Yt)-1)){Te-=Yt,v(it.p[bt],J,xe,Te,z,$,oe,le,We),xe=A.c,Te=A.lc;break}}if(bt==it.lit)throw new Error("hufDecode issues")}}const Ye=8-N&7;for(xe>>=Ye,Te-=Ye;Te>0;){const ft=R[xe<<14-Te&16383];if(ft.len)Te-=ft.len,v(ft.lit,J,xe,Te,z,$,oe,le,We),xe=A.c,Te=A.lc;else throw new Error("hufDecode issues")}return!0}function T(C,R,z,$,N,J){const V={value:0},oe=z.value,le=fe(R,z),xe=fe(R,z);z.value+=4;const Te=fe(R,z);if(z.value+=4,le<0||le>=65537||xe<0||xe>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const We=new Array(65537),Ve=new Array(16384);r(Ve);const Ye=$-(z.value-oe);if(c(C,z,Ye,le,xe,We),Te>8*($-(z.value-oe)))throw new Error("Something wrong with hufUncompress");p(We,le,xe,Ve),M(We,Ve,C,z,Te,xe,J,N,V)}function D(C,R,z){for(let $=0;$<z;++$)R[$]=C[R[$]]}function S(C){for(let R=1;R<C.length;R++){const z=C[R-1]+C[R]-128;C[R]=z}}function B(C,R){let z=0,$=Math.floor((C.length+1)/2),N=0;const J=C.length-1;for(;!(N>J||(R[N++]=C[z++],N>J));)R[N++]=C[$++]}function U(C){let R=C.byteLength;const z=new Array;let $=0;const N=new DataView(C);for(;R>0;){const J=N.getInt8($++);if(J<0){const V=-J;R-=V+1;for(let oe=0;oe<V;oe++)z.push(N.getUint8($++))}else{const V=J;R-=2;const oe=N.getUint8($++);for(let le=0;le<V+1;le++)z.push(oe)}}return z}function j(C,R,z,$,N,J){let V=new DataView(J.buffer);const oe=z[C.idx[0]].width,le=z[C.idx[0]].height,xe=3,Te=Math.floor(oe/8),We=Math.ceil(oe/8),Ve=Math.ceil(le/8),Ye=oe-(We-1)*8,ft=le-(Ve-1)*8,it={value:0},bt=new Array(xe),Yt=new Array(xe),Li=new Array(xe),$i=new Array(xe),dr=new Array(xe);for(let ri=0;ri<xe;++ri)dr[ri]=R[C.idx[ri]],bt[ri]=ri<1?0:bt[ri-1]+We*Ve,Yt[ri]=new Float32Array(64),Li[ri]=new Uint16Array(64),$i[ri]=new Uint16Array(We*64);for(let ri=0;ri<Ve;++ri){let Bn=8;ri==Ve-1&&(Bn=ft);let no=8;for(let F=0;F<We;++F){F==We-1&&(no=Ye);for(let ie=0;ie<xe;++ie)Li[ie].fill(0),Li[ie][0]=N[bt[ie]++],L(it,$,Li[ie]),H(Li[ie],Yt[ie]),P(Yt[ie]);O(Yt);for(let ie=0;ie<xe;++ie)Q(Yt[ie],$i[ie],F*64)}let Hn=0;for(let F=0;F<xe;++F){const ie=z[C.idx[F]].type;for(let de=8*ri;de<8*ri+Bn;++de){Hn=dr[F][de];for(let me=0;me<Te;++me){const ae=me*64+(de&7)*8;V.setUint16(Hn+0*2*ie,$i[F][ae+0],!0),V.setUint16(Hn+1*2*ie,$i[F][ae+1],!0),V.setUint16(Hn+2*2*ie,$i[F][ae+2],!0),V.setUint16(Hn+3*2*ie,$i[F][ae+3],!0),V.setUint16(Hn+4*2*ie,$i[F][ae+4],!0),V.setUint16(Hn+5*2*ie,$i[F][ae+5],!0),V.setUint16(Hn+6*2*ie,$i[F][ae+6],!0),V.setUint16(Hn+7*2*ie,$i[F][ae+7],!0),Hn+=8*2*ie}}if(Te!=We)for(let de=8*ri;de<8*ri+Bn;++de){const me=dr[F][de]+8*Te*2*ie,ae=Te*64+(de&7)*8;for(let Je=0;Je<no;++Je)V.setUint16(me+Je*2*ie,$i[F][ae+Je],!0)}}}const Di=new Uint16Array(oe);V=new DataView(J.buffer);for(let ri=0;ri<xe;++ri){z[C.idx[ri]].decoded=!0;const Bn=z[C.idx[ri]].type;if(z[ri].type==2)for(let no=0;no<le;++no){const Hn=dr[ri][no];for(let F=0;F<oe;++F)Di[F]=V.getUint16(Hn+F*2*Bn,!0);for(let F=0;F<oe;++F)V.setFloat32(Hn+F*2*Bn,Ae(Di[F]),!0)}}}function L(C,R,z){let $,N=1;for(;N<64;)$=R[C.value],$==65280?N=64:$>>8==255?N+=$&255:(z[N]=$,N++),C.value++}function H(C,R){R[0]=Ae(C[0]),R[1]=Ae(C[1]),R[2]=Ae(C[5]),R[3]=Ae(C[6]),R[4]=Ae(C[14]),R[5]=Ae(C[15]),R[6]=Ae(C[27]),R[7]=Ae(C[28]),R[8]=Ae(C[2]),R[9]=Ae(C[4]),R[10]=Ae(C[7]),R[11]=Ae(C[13]),R[12]=Ae(C[16]),R[13]=Ae(C[26]),R[14]=Ae(C[29]),R[15]=Ae(C[42]),R[16]=Ae(C[3]),R[17]=Ae(C[8]),R[18]=Ae(C[12]),R[19]=Ae(C[17]),R[20]=Ae(C[25]),R[21]=Ae(C[30]),R[22]=Ae(C[41]),R[23]=Ae(C[43]),R[24]=Ae(C[9]),R[25]=Ae(C[11]),R[26]=Ae(C[18]),R[27]=Ae(C[24]),R[28]=Ae(C[31]),R[29]=Ae(C[40]),R[30]=Ae(C[44]),R[31]=Ae(C[53]),R[32]=Ae(C[10]),R[33]=Ae(C[19]),R[34]=Ae(C[23]),R[35]=Ae(C[32]),R[36]=Ae(C[39]),R[37]=Ae(C[45]),R[38]=Ae(C[52]),R[39]=Ae(C[54]),R[40]=Ae(C[20]),R[41]=Ae(C[22]),R[42]=Ae(C[33]),R[43]=Ae(C[38]),R[44]=Ae(C[46]),R[45]=Ae(C[51]),R[46]=Ae(C[55]),R[47]=Ae(C[60]),R[48]=Ae(C[21]),R[49]=Ae(C[34]),R[50]=Ae(C[37]),R[51]=Ae(C[47]),R[52]=Ae(C[50]),R[53]=Ae(C[56]),R[54]=Ae(C[59]),R[55]=Ae(C[61]),R[56]=Ae(C[35]),R[57]=Ae(C[36]),R[58]=Ae(C[48]),R[59]=Ae(C[49]),R[60]=Ae(C[57]),R[61]=Ae(C[58]),R[62]=Ae(C[62]),R[63]=Ae(C[63])}function P(C){const R=.5*Math.cos(.7853975),z=.5*Math.cos(3.14159/16),$=.5*Math.cos(3.14159/8),N=.5*Math.cos(3*3.14159/16),J=.5*Math.cos(5*3.14159/16),V=.5*Math.cos(3*3.14159/8),oe=.5*Math.cos(7*3.14159/16),le=new Array(4),xe=new Array(4),Te=new Array(4),We=new Array(4);for(let Ve=0;Ve<8;++Ve){const Ye=Ve*8;le[0]=$*C[Ye+2],le[1]=V*C[Ye+2],le[2]=$*C[Ye+6],le[3]=V*C[Ye+6],xe[0]=z*C[Ye+1]+N*C[Ye+3]+J*C[Ye+5]+oe*C[Ye+7],xe[1]=N*C[Ye+1]-oe*C[Ye+3]-z*C[Ye+5]-J*C[Ye+7],xe[2]=J*C[Ye+1]-z*C[Ye+3]+oe*C[Ye+5]+N*C[Ye+7],xe[3]=oe*C[Ye+1]-J*C[Ye+3]+N*C[Ye+5]-z*C[Ye+7],Te[0]=R*(C[Ye+0]+C[Ye+4]),Te[3]=R*(C[Ye+0]-C[Ye+4]),Te[1]=le[0]+le[3],Te[2]=le[1]-le[2],We[0]=Te[0]+Te[1],We[1]=Te[3]+Te[2],We[2]=Te[3]-Te[2],We[3]=Te[0]-Te[1],C[Ye+0]=We[0]+xe[0],C[Ye+1]=We[1]+xe[1],C[Ye+2]=We[2]+xe[2],C[Ye+3]=We[3]+xe[3],C[Ye+4]=We[3]-xe[3],C[Ye+5]=We[2]-xe[2],C[Ye+6]=We[1]-xe[1],C[Ye+7]=We[0]-xe[0]}for(let Ve=0;Ve<8;++Ve)le[0]=$*C[16+Ve],le[1]=V*C[16+Ve],le[2]=$*C[48+Ve],le[3]=V*C[48+Ve],xe[0]=z*C[8+Ve]+N*C[24+Ve]+J*C[40+Ve]+oe*C[56+Ve],xe[1]=N*C[8+Ve]-oe*C[24+Ve]-z*C[40+Ve]-J*C[56+Ve],xe[2]=J*C[8+Ve]-z*C[24+Ve]+oe*C[40+Ve]+N*C[56+Ve],xe[3]=oe*C[8+Ve]-J*C[24+Ve]+N*C[40+Ve]-z*C[56+Ve],Te[0]=R*(C[Ve]+C[32+Ve]),Te[3]=R*(C[Ve]-C[32+Ve]),Te[1]=le[0]+le[3],Te[2]=le[1]-le[2],We[0]=Te[0]+Te[1],We[1]=Te[3]+Te[2],We[2]=Te[3]-Te[2],We[3]=Te[0]-Te[1],C[0+Ve]=We[0]+xe[0],C[8+Ve]=We[1]+xe[1],C[16+Ve]=We[2]+xe[2],C[24+Ve]=We[3]+xe[3],C[32+Ve]=We[3]-xe[3],C[40+Ve]=We[2]-xe[2],C[48+Ve]=We[1]-xe[1],C[56+Ve]=We[0]-xe[0]}function O(C){for(let R=0;R<64;++R){const z=C[0][R],$=C[1][R],N=C[2][R];C[0][R]=z+1.5747*N,C[1][R]=z-.1873*$-.4682*N,C[2][R]=z+1.8556*$}}function Q(C,R,z){for(let $=0;$<64;++$)R[z+$]=Ud.toHalfFloat(X(C[$]))}function X(C){return C<=1?Math.sign(C)*Math.pow(Math.abs(C),2.2):Math.sign(C)*Math.pow(t,Math.abs(C)-1)}function Y(C){return new DataView(C.array.buffer,C.offset.value,C.size)}function ne(C){const R=C.viewer.buffer.slice(C.offset.value,C.offset.value+C.size),z=new Uint8Array(U(R)),$=new Uint8Array(z.length);return S(z),B(z,$),new DataView($.buffer)}function ye(C){const R=C.array.slice(C.offset.value,C.offset.value+C.size),z=wv(R),$=new Uint8Array(z.length);return S(z),B(z,$),new DataView($.buffer)}function Pe(C){const R=C.viewer,z={value:C.offset.value},$=new Uint16Array(C.width*C.scanlineBlockSize*(C.channels*C.type)),N=new Uint8Array(8192);let J=0;const V=new Array(C.channels);for(let ft=0;ft<C.channels;ft++)V[ft]={},V[ft].start=J,V[ft].end=V[ft].start,V[ft].nx=C.width,V[ft].ny=C.lines,V[ft].size=C.type,J+=V[ft].nx*V[ft].ny*V[ft].size;const oe=Ze(R,z),le=Ze(R,z);if(le>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(oe<=le)for(let ft=0;ft<le-oe+1;ft++)N[ft+oe]=Ne(R,z);const xe=new Uint16Array(65536),Te=n(N,xe),We=fe(R,z);T(C.array,R,z,We,$,J);for(let ft=0;ft<C.channels;++ft){const it=V[ft];for(let bt=0;bt<V[ft].size;++bt)I($,it.start+bt,it.nx,it.size,it.ny,it.nx*it.size,Te)}D(xe,$,J);let Ve=0;const Ye=new Uint8Array($.buffer.byteLength);for(let ft=0;ft<C.lines;ft++)for(let it=0;it<C.channels;it++){const bt=V[it],Yt=bt.nx*bt.size,Li=new Uint8Array($.buffer,bt.end*2,Yt*2);Ye.set(Li,Ve),Ve+=Yt*2,bt.end+=Yt}return new DataView(Ye.buffer)}function se(C){const R=C.array.slice(C.offset.value,C.offset.value+C.size),z=wv(R),$=C.lines*C.channels*C.width,N=C.type==1?new Uint16Array($):new Uint32Array($);let J=0,V=0;const oe=new Array(4);for(let le=0;le<C.lines;le++)for(let xe=0;xe<C.channels;xe++){let Te=0;switch(C.type){case 1:oe[0]=J,oe[1]=oe[0]+C.width,J=oe[1]+C.width;for(let We=0;We<C.width;++We){const Ve=z[oe[0]++]<<8|z[oe[1]++];Te+=Ve,N[V]=Te,V++}break;case 2:oe[0]=J,oe[1]=oe[0]+C.width,oe[2]=oe[1]+C.width,J=oe[2]+C.width;for(let We=0;We<C.width;++We){const Ve=z[oe[0]++]<<24|z[oe[1]++]<<16|z[oe[2]++]<<8;Te+=Ve,N[V]=Te,V++}break}}return new DataView(N.buffer)}function be(C){const R=C.viewer,z={value:C.offset.value},$=new Uint8Array(C.width*C.lines*(C.channels*C.type*2)),N={version:Ie(R,z),unknownUncompressedSize:Ie(R,z),unknownCompressedSize:Ie(R,z),acCompressedSize:Ie(R,z),dcCompressedSize:Ie(R,z),rleCompressedSize:Ie(R,z),rleUncompressedSize:Ie(R,z),rleRawSize:Ie(R,z),totalAcUncompressedCount:Ie(R,z),totalDcUncompressedCount:Ie(R,z),acCompression:Ie(R,z)};if(N.version<2)throw new Error("EXRLoader.parse: "+qt.compression+" version "+N.version+" is unsupported");const J=new Array;let V=Ze(R,z)-2;for(;V>0;){const it=Me(R.buffer,z),bt=Ne(R,z),Yt=bt>>2&3,Li=(bt>>4)-1,$i=new Int8Array([Li])[0],dr=Ne(R,z);J.push({name:it,index:$i,type:dr,compression:Yt}),V-=it.length+3}const oe=qt.channels,le=new Array(C.channels);for(let it=0;it<C.channels;++it){const bt=le[it]={},Yt=oe[it];bt.name=Yt.name,bt.compression=0,bt.decoded=!1,bt.type=Yt.pixelType,bt.pLinear=Yt.pLinear,bt.width=C.width,bt.height=C.lines}const xe={idx:new Array(3)};for(let it=0;it<C.channels;++it){const bt=le[it];for(let Yt=0;Yt<J.length;++Yt){const Li=J[Yt];bt.name==Li.name&&(bt.compression=Li.compression,Li.index>=0&&(xe.idx[Li.index]=it),bt.offset=it)}}let Te,We,Ve;if(N.acCompressedSize>0)switch(N.acCompression){case 0:Te=new Uint16Array(N.totalAcUncompressedCount),T(C.array,R,z,N.acCompressedSize,Te,N.totalAcUncompressedCount);break;case 1:const it=C.array.slice(z.value,z.value+N.totalAcUncompressedCount),bt=wv(it);Te=new Uint16Array(bt.buffer),z.value+=N.totalAcUncompressedCount;break}if(N.dcCompressedSize>0){const it={array:C.array,offset:z,size:N.dcCompressedSize};We=new Uint16Array(ye(it).buffer),z.value+=N.dcCompressedSize}if(N.rleRawSize>0){const it=C.array.slice(z.value,z.value+N.rleCompressedSize),bt=wv(it);Ve=U(bt.buffer),z.value+=N.rleCompressedSize}let Ye=0;const ft=new Array(le.length);for(let it=0;it<ft.length;++it)ft[it]=new Array;for(let it=0;it<C.lines;++it)for(let bt=0;bt<le.length;++bt)ft[bt].push(Ye),Ye+=le[bt].width*C.type*2;j(xe,ft,le,Te,We,$);for(let it=0;it<le.length;++it){const bt=le[it];if(!bt.decoded)switch(bt.compression){case 2:let Yt=0,Li=0;for(let $i=0;$i<C.lines;++$i){let dr=ft[it][Yt];for(let Di=0;Di<bt.width;++Di){for(let ri=0;ri<2*bt.type;++ri)$[dr++]=Ve[Li+ri*bt.width*bt.height];Li++}Yt++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView($.buffer)}function Me(C,R){const z=new Uint8Array(C);let $=0;for(;z[R.value+$]!=0;)$+=1;const N=new TextDecoder().decode(z.slice(R.value,R.value+$));return R.value=R.value+$+1,N}function Xe(C,R,z){const $=new TextDecoder().decode(new Uint8Array(C).slice(R.value,R.value+z));return R.value=R.value+z,$}function Ke(C,R){const z=ot(C,R),$=fe(C,R);return[z,$]}function ke(C,R){const z=fe(C,R),$=fe(C,R);return[z,$]}function ot(C,R){const z=C.getInt32(R.value,!0);return R.value=R.value+4,z}function fe(C,R){const z=C.getUint32(R.value,!0);return R.value=R.value+4,z}function W(C,R){const z=C[R.value];return R.value=R.value+1,z}function Ne(C,R){const z=C.getUint8(R.value);return R.value=R.value+1,z}const Ie=function(C,R){let z;return"getBigInt64"in DataView.prototype?z=Number(C.getBigInt64(R.value,!0)):z=C.getUint32(R.value+4,!0)+Number(C.getUint32(R.value,!0)<<32),R.value+=8,z};function Se(C,R){const z=C.getFloat32(R.value,!0);return R.value+=4,z}function Ge(C,R){return Ud.toHalfFloat(Se(C,R))}function Ae(C){const R=(C&31744)>>10,z=C&1023;return(C>>15?-1:1)*(R?R===31?z?NaN:1/0:Math.pow(2,R-15)*(1+z/1024):6103515625e-14*(z/1024))}function Ze(C,R){const z=C.getUint16(R.value,!0);return R.value+=2,z}function at(C,R){return Ae(Ze(C,R))}function Et(C,R,z,$){const N=z.value,J=[];for(;z.value<N+$-1;){const V=Me(R,z),oe=ot(C,z),le=Ne(C,z);z.value+=3;const xe=ot(C,z),Te=ot(C,z);J.push({name:V,pixelType:oe,pLinear:le,xSampling:xe,ySampling:Te})}return z.value+=1,J}function G(C,R){const z=Se(C,R),$=Se(C,R),N=Se(C,R),J=Se(C,R),V=Se(C,R),oe=Se(C,R),le=Se(C,R),xe=Se(C,R);return{redX:z,redY:$,greenX:N,greenY:J,blueX:V,blueY:oe,whiteX:le,whiteY:xe}}function k(C,R){const z=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],$=Ne(C,R);return z[$]}function ce(C,R){const z=fe(C,R),$=fe(C,R),N=fe(C,R),J=fe(C,R);return{xMin:z,yMin:$,xMax:N,yMax:J}}function Ee(C,R){const z=["INCREASING_Y"],$=Ne(C,R);return z[$]}function Oe(C,R){const z=Se(C,R),$=Se(C,R);return[z,$]}function Be(C,R){const z=Se(C,R),$=Se(C,R),N=Se(C,R);return[z,$,N]}function mt(C,R,z,$,N){if($==="string"||$==="stringvector"||$==="iccProfile")return Xe(R,z,N);if($==="chlist")return Et(C,R,z,N);if($==="chromaticities")return G(C,z);if($==="compression")return k(C,z);if($==="box2i")return ce(C,z);if($==="lineOrder")return Ee(C,z);if($==="float")return Se(C,z);if($==="v2f")return Oe(C,z);if($==="v3f")return Be(C,z);if($==="int")return ot(C,z);if($==="rational")return Ke(C,z);if($==="timecode")return ke(C,z);if($==="preview")return z.value+=N,"skipped";z.value+=N}function lt(C,R,z){const $={};if(C.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");$.version=C.getUint8(4);const N=C.getUint8(5);$.spec={singleTile:!!(N&2),longName:!!(N&4),deepFormat:!!(N&8),multiPart:!!(N&16)},z.value=8;let J=!0;for(;J;){const V=Me(R,z);if(V==0)J=!1;else{const oe=Me(R,z),le=fe(C,z),xe=mt(C,R,z,oe,le);xe===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${oe}'.`):$[V]=xe}}if(N&-5)throw console.error("THREE.EXRHeader:",$),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return $}function Qe(C,R,z,$,N){const J={size:0,viewer:R,array:z,offset:$,width:C.dataWindow.xMax-C.dataWindow.xMin+1,height:C.dataWindow.yMax-C.dataWindow.yMin+1,channels:C.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:C.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:bi};switch(C.compression){case"NO_COMPRESSION":J.lines=1,J.uncompress=Y;break;case"RLE_COMPRESSION":J.lines=1,J.uncompress=ne;break;case"ZIPS_COMPRESSION":J.lines=1,J.uncompress=ye;break;case"ZIP_COMPRESSION":J.lines=16,J.uncompress=ye;break;case"PIZ_COMPRESSION":J.lines=32,J.uncompress=Pe;break;case"PXR24_COMPRESSION":J.lines=16,J.uncompress=se;break;case"DWAA_COMPRESSION":J.lines=32,J.uncompress=be;break;case"DWAB_COMPRESSION":J.lines=256,J.uncompress=be;break;default:throw new Error("EXRLoader.parse: "+C.compression+" is unsupported")}if(J.scanlineBlockSize=J.lines,J.type==1)switch(N){case qi:J.getter=at,J.inputSize=2;break;case dn:J.getter=Ze,J.inputSize=2;break}else if(J.type==2)switch(N){case qi:J.getter=Se,J.inputSize=4;break;case dn:J.getter=Ge,J.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+J.type+" for "+C.compression+".");J.blockCount=(C.dataWindow.yMax+1)/J.scanlineBlockSize;for(let oe=0;oe<J.blockCount;oe++)Ie(R,$);J.outputChannels=J.channels==3?4:J.channels;const V=J.width*J.height*J.outputChannels;switch(N){case qi:J.byteArray=new Float32Array(V),J.channels<J.outputChannels&&J.byteArray.fill(1,0,V);break;case dn:J.byteArray=new Uint16Array(V),J.channels<J.outputChannels&&J.byteArray.fill(15360,0,V);break;default:console.error("THREE.EXRLoader: unsupported type: ",N);break}return J.bytesPerLine=J.width*J.inputSize*J.channels,J.outputChannels==4?(J.format=yi,J.colorSpace=bi):(J.format=Ga,J.colorSpace=ks),J}const je=new DataView(e),xt=new Uint8Array(e),Fe={value:0},qt=lt(je,e,Fe),Le=Qe(qt,je,xt,Fe,this.type),yt={value:0},ct={R:0,G:1,B:2,A:3,Y:0};for(let C=0;C<Le.height/Le.scanlineBlockSize;C++){const R=fe(je,Fe);Le.size=fe(je,Fe),Le.lines=R+Le.scanlineBlockSize>Le.height?Le.height-R:Le.scanlineBlockSize;const z=Le.size<Le.lines*Le.bytesPerLine?Le.uncompress(Le):Y(Le);Fe.value+=Le.size;for(let $=0;$<Le.scanlineBlockSize;$++){const N=$+C*Le.scanlineBlockSize;if(N>=Le.height)break;for(let J=0;J<Le.channels;J++){const V=ct[qt.channels[J].name];for(let oe=0;oe<Le.width;oe++){yt.value=($*(Le.channels*Le.width)+J*Le.width+oe)*Le.inputSize;const le=(Le.height-1-N)*(Le.width*Le.outputChannels)+oe*Le.outputChannels+V;Le.byteArray[le]=Le.getter(z,yt)}}}}return{header:qt,width:Le.width,height:Le.height,data:Le.byteArray,format:Le.format,colorSpace:Le.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(o,a){o.colorSpace=a.colorSpace,o.minFilter=St,o.magFilter=St,o.generateMipmaps=!1,o.flipY=!1,t&&t(o,a)}return super.load(e,s,n,r)}}const Lde=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:ty},Symbol.toStringTag,{value:"Module"}));class nC extends GM{constructor(e){super(e),this.type=dn}parse(e){const t=function(g,y){switch(g){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(y||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(y||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(y||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(y||""))}},n=`
@@ -6233,7 +6233,7 @@ void main() {
6233
6233
  `,r.uuid,`
6234
6234
  `,s?.copy.uuid,`
6235
6235
  `,i.name)}const c=r.clone();c.version=r.version,s?(s.copy=c,s.material=r):(s={material:r,copy:c},t.push(s)),c[dge]=this,c[pge]=r,Yy&&console.log("Set reflection",i.name,i.guid)}s&&s.copy&&(s.copy.onBeforeCompile=r.onBeforeCompile);const l=s?.copy;l.envMap=this.texture,i.sharedMaterials[n]=l}}onUnset(i){const e=Ih._rendererMaterialsCache.get(i);if(e)for(let t=0;t<e.length;t++){const n=e[t];i.sharedMaterials[t]=n.material}}},u(iE,"_probes",new Map),u(iE,"_rendererMaterialsCache",new Map),iE);let rA=Ih;n6([_(E)],rA.prototype,"center",2),n6([_(E)],rA.prototype,"size",2);const YP=ee("debugexr");class fge{constructor(e){u(this,"parser"),this.parser=e,YP&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const t=this.name,n=this.parser,r=n.json.textures[e];if(YP&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=new ty(n.options.manager);return YP&&console.log("EXT_texture_exr.loadTexture",s),n.loadTextureImage(e,s.source,o)}}typeof window<"u"&&window.addEventListener("unhandledrejection",i=>{});const Mh=_r,nE="$___Export_Components",mge="NEEDLE_components";var s6;class gge{constructor(){u(this,s6)}}s6=mp;class Age{constructor(e,t,n){u(this,"node"),u(this,"nodeIndex"),u(this,"nodeDef"),this.node=e,this.nodeIndex=t,this.nodeDef=n}}class vge{constructor(){u(this,"parser"),u(this,"nodeToObjectMap",{}),u(this,"exportContext"),u(this,"objectToNodeMap",{}),u(this,"context"),u(this,"writer")}get name(){return mge}registerExport(e){e.register(t=>{if("serializeUserData"in t){const n=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(r,s)=>{try{this.serializeUserData(r,s),n(r,s)}finally{this.afterSerializeUserData(r,s)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var n;const r=(n=e.userData)==null?void 0:n.components;!r||r.length<=0||(delete e.userData.components,e[nE]=r)}afterSerializeUserData(e,t){if(e.type==="Scene"&&Mh&&console.log("DONE",JSON.stringify(t)),e[nE]===void 0)return;const n=e[nE];delete e[nE],n!==null&&(e.userData.components=n)}writeNode(e,t){const n=this.writer.json.nodes.length;Mh&&console.log(e.name,n,e.uuid);const r=new Age(e,n,t);this.exportContext[n]=r,this.objectToNodeMap[e.uuid]=n}afterParse(e){var t;Mh&&console.log("AFTER",e);for(const n in this.exportContext){const r=this.exportContext[n],s=r.node,o=r.nodeDef,a=r.nodeIndex,l=(t=s.userData)==null?void 0:t.components;if(!l||l.length<=0)continue;const c=new gge;o.extensions=o.extensions||{},o.extensions[this.name]=c,this.context.object=s,this.context.nodeId=a,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const d of l){this.context.target=d;const p=Xa().writeBuiltinComponentData(d,this.context);p!==null&&h.push(p)}h.length>0&&(c[mp]=h,Mh&&console.log("DID WRITE",s,"nodeIndex",a,h))}}beforeRoot(){return Mh&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){const t=e.parser,n=t?.extensions;if(!n)return;const r=n[this.name];Mh&&console.log("After root",e,this.parser,n);const s=[];if(r===!0){const o=t.json.nodes;if(o){for(let a=0;a<o.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<o.length;a++){const l=o[a],c=a,h=l.extensions;if(!h)continue;const d=h[this.name];if(!d)continue;Mh&&console.log("NODE",l);const p=this.nodeToObjectMap[c];if(!p){console.error("Could not find object for node index: "+c,l,t);continue}bC(p),s.push(this.createComponents(p,d))}}}await Promise.all(s)}async createComponents(e,t){if(!t)return;const n=t[mp];if(n){const r=new Array;Mh&&console.log(e.name,n);for(const s in n){const o=n[s];Mh&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&r.push(X2(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
6236
- `,a,e,o))),e.userData=e.userData||{},e.userData[mp]=e.userData[mp]||[],e.userData[mp].push(o)}await Promise.all(r).catch(s=>{console.error("Error while loading components",s)})}}}const o6="NEEDLE_gameobject_data";class yge{constructor(e){u(this,"parser"),this.parser=e}get name(){return o6}afterRoot(e){var t;const n=[];for(let r=0;r<((t=this.parser.json.nodes)==null?void 0:t.length);r++){const s=this.parser.json.nodes[r];if(s&&s.extensions){const o=s.extensions[o6];if(o){const a=this.findAndApplyExtensionData(r,o);n.push(a)}}}return Promise.all(n).then(()=>null)}async findAndApplyExtensionData(e,t){const n=await this.parser.getDependency("node",e);n&&this.applyExtensionData(n,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.userData.hideFlags=t.hideFlags??0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const a6="NEEDLE_lighting_settings",sA=ee("debugenvlight");class bge{constructor(e,t,n){u(this,"parser"),u(this,"sourceId"),u(this,"context"),this.parser=e,this.sourceId=t,this.context=n}get name(){return a6}afterRoot(e){const t=this.parser.json.extensions;if(t){const n=t[a6];if(n){sA&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',n);let r;if(e.scene.children.length===1){const s=e.scene.children[0];r=te.addNewComponent(s,rE,{},!1)}else{const s=new ve;s.name="LightSettings "+this.sourceId,e.scene.add(s),r=te.addNewComponent(s,rE,{},!1)}r.sourceId=this.sourceId,r.ambientIntensity=n.ambientIntensity,r.ambientLight=new _e().fromArray(n.ambientLight),Array.isArray(n.ambientTrilight)&&(r.ambientTrilight=n.ambientTrilight.map(s=>new _e().fromArray(s))),r.ambientMode=n.ambientMode,r.environmentReflectionSource=n.environmentReflectionSource}}return null}}hi.registerCallback(Ei.ContextCreated,i=>{const e=i.context,t=te.findObjectOfType(rE,e);t!=null&&t.sourceId&&(t.enabled=!0)});class rE extends Re{constructor(){super(...arguments),u(this,"ambientMode",Bg.Skybox),u(this,"ambientLight"),u(this,"ambientTrilight"),u(this,"ambientIntensity",1),u(this,"environmentReflectionSource",lC.Skybox),u(this,"_hasReflection",!1),u(this,"_ambientLightObj"),u(this,"_hemisphereLightObj")}awake(){var e;if(this.sourceId){const n=this.environmentReflectionSource===lC.Skybox?Hu.Skybox:Hu.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,n,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),sA&&window.addEventListener("keydown",n=>{if(!this.destroyed)switch(n.key){case"l":this.enabled=!this.enabled;break}});const t=(e=this.gameObject.userData)==null?void 0:e.components;if(t){const n=t.indexOf(this);t.splice(n,1),t.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*$e.lerp(0,1.33,t)}onEnable(){if(sA&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==Bg.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new P_(this.ambientLight,this.ambientIntensity*e),sA&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===Bg.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],n=this.calculateIntensityFactor(t);this._hemisphereLightObj=new HM(t,e,this.ambientIntensity*n),this.gameObject.add(this._hemisphereLightObj),sA&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,n)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){sA&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var l6=(i=>(i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_3D=35680]="SAMPLER_3D",i[i.SAMPLER_CUBE=35681]="SAMPLER_CUBE",i[i.UNKNOWN=0]="UNKNOWN",i))(l6||{});const ad=ee("debugcustomshader"),oA="NEEDLE_techniques_webgl";class xge{constructor(){u(this,"objectToWorldMatrix",new ge),u(this,"worldToObjectMatrix",new ge),u(this,"objectToWorld",new Array),u(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),aC(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),aC(this.worldToObjectMatrix,this.worldToObject)}}const gn=class extends T_{constructor(i,...e){super(...e),u(this,"identifier"),u(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),u(this,"_sphericalHarmonicsName","unity_SpecCube0"),u(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),u(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),u(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),u(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),u(this,"_rendererData",new xge),this.identifier=i,ad&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&kt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const i=super.clone();return c6(i),i}dispose(){super.dispose();const i=kt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);i>=0&&kt.Current.pre_render_callbacks.splice(i,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&kt.Current.setRequireColor(!0),this.depthTextureUniform&&kt.Current.setRequireDepth(!0)}onBeforeRender(i,e,t,n,r,s){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(t,r)}onUpdateUniforms(i,e){const t=kt.Current;if(i&&(gn.viewProjection&&this.uniforms[this._viewProjectionName]&&(gn.viewProjection.copy(i.projectionMatrix).multiply(i.matrixWorldInverse),aC(gn.viewProjection,gn._viewProjectionValues)),gn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(gn.viewMatrix.copy(i.matrixWorldInverse),aC(gn.viewMatrix,gn._viewMatrixValues)),this.uniforms[gn._worldSpaceCameraPosName]&&gn._worldSpaceCameraPos.setFromMatrixPosition(i.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=t.sceneLighting.timeVec4),this.uniforms._Time){const o=this.uniforms._Time.value;o.x=t.sceneLighting.timeVec4.x/20,o.y=t.sceneLighting.timeVec4.x,o.z=t.sceneLighting.timeVec4.x*2,o.w=t.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const o=this.uniforms._SinTime.value;o.x=Math.sin(t.sceneLighting.timeVec4.x/8),o.y=Math.sin(t.sceneLighting.timeVec4.x/4),o.z=Math.sin(t.sceneLighting.timeVec4.x/2),o.w=Math.sin(t.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const o=this.uniforms._CosTime.value;o.x=Math.cos(t.sceneLighting.timeVec4.x/8),o.y=Math.cos(t.sceneLighting.timeVec4.x/4),o.z=Math.cos(t.sceneLighting.timeVec4.x/2),o.w=Math.cos(t.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const o=this.uniforms.unity_DeltaTime.value;o.x=t.time.deltaTime,o.y=1/t.time.deltaTime,o.z=t.time.smoothedDeltaTime,o.w=1/t.time.smoothedDeltaTime}const n=t.mainLight;if(n){const o=Tt(n.gameObject,gn._mainLightPosition);this.uniforms._MainLightPosition={value:o.normalize()},gn._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:gn._mainLightColor};const a=n.intensity;gn._lightData.z=a,this.uniforms.unity_LightData={value:gn._lightData}}if(i&&(gn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=gn._viewProjectionValues),gn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=gn._viewMatrixValues),this.uniforms[gn._worldSpaceCameraPosName]&&(this.uniforms[gn._worldSpaceCameraPosName]={value:gn._worldSpaceCameraPos}),t.mainCameraComponent)){if(this.uniforms._ProjectionParams){const o=this.uniforms._ProjectionParams.value;o.x=1,o.y=t.mainCameraComponent.nearClipPlane,o.z=t.mainCameraComponent.farClipPlane,o.w=1/o.z,this.uniforms._ProjectionParams.value=o}if(this.uniforms._ZBufferParams){const o=this.uniforms._ZBufferParams.value,a=t.mainCameraComponent;o.x=1-a.farClipPlane/a.nearClipPlane,o.y=a.farClipPlane/a.nearClipPlane,o.z=o.x/a.farClipPlane,o.w=o.y/a.farClipPlane,this.uniforms._ZBufferParams.value=o}if(this.uniforms._ScreenParams){const o=this.uniforms._ScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScreenParams.value=o}if(this.uniforms._ScaledScreenParams){const o=this.uniforms._ScaledScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScaledScreenParams.value=o}}const r=this.depthTextureUniform;r&&(r.value=t.depthTexture);const s=this.opaqueTextureUniform;if(s&&(s.value=t.opaqueColorTexture),e){const o=this._rendererData;o.updateFrom(e),this.uniforms[this._worldToObjectName].value=o.worldToObject,this.uniforms[this._objToWorldName].value=o.objectToWorld}this.uniformsNeedUpdate=!0}};let gl=gn;u(gl,"viewProjection",new ge),u(gl,"_viewProjectionValues",[]),u(gl,"viewMatrix",new ge),u(gl,"_viewMatrixValues",[]),u(gl,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),u(gl,"_worldSpaceCameraPos",new E),u(gl,"_mainLightColor",new qe),u(gl,"_mainLightPosition",new E),u(gl,"_lightData",new qe);class _ge{constructor(e,t){u(this,"parser"),u(this,"identifier"),this.parser=e,this.identifier=t}get name(){return oA}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return ad&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[oA])return ad&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const n=t.extensions[oA].technique;if(n<0)return null;const r=this.parser.json.extensions[oA];if(!r)return null;ad&&console.log(r);const s=r.techniques[n];return s?new Promise(async(o,a)=>{var l,c,h;const d=await Wde(r,s.program),p=d?.fragmentShader,f=d?.vertexShader;if(!p||!f)return a();ad&&console.log("loadMaterial",t,d);const m={},A=s.uniforms;(f.includes("_Time")||p.includes("_Time"))&&(m._Time={value:new qe(0,0,0,0)}),(f.includes("_SinTime")||p.includes("_SinTime"))&&(m._SinTime={value:new qe(0,0,0,0)}),(f.includes("_CosTime")||p.includes("_CosTime"))&&(m._CosTime={value:new qe(0,0,0,0)}),(f.includes("unity_DeltaTime")||p.includes("unity_DeltaTime"))&&(m.unity_DeltaTime={value:new qe(0,0,0,0)});for(const y in A){const b=y;switch(b){case"_TimeParameters":const x=new qe;m[b]={value:x};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":m[b]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":m[b]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":m[b]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":m[b]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":m[b]={value:null};break}}let v=!1;if(t.extensions&&t.extensions[oA]){const y=t.extensions[oA];if(y.technique===n){ad&&console.log(t.name,"Material Properties",y);for(const b in y.values){const x=y.values[b];if(typeof x=="string"){if(x.startsWith("/textures/")){const w=x.substring(10),I=Number.parseInt(w);if(I>=0){const M=await this.parser.getDependency("texture",I);M instanceof Ut&&(M.colorSpace=bi,M.needsUpdate=!0),m[b]={value:M};continue}}switch(b){case"alphaMode":x==="BLEND"&&(v=!0);continue}}if(Array.isArray(x)&&x.length===4){m[b]={value:new qe(x[0],x[1],x[2],x[3])};continue}m[b]={value:x}}}}const g=new gl(this.identifier,{name:t.name??"",uniforms:m,vertexShader:f,fragmentShader:p,lights:!1});switch(g.glslVersion=Bx,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(l=m._Cull)==null?void 0:l.value){case 0:g.side=mi;break;case 1:g.side=un;break;case 2:g.side=rr;break;default:g.side=rr;break}switch((c=m._ZTest)==null?void 0:c.value){case 3:g.depthTest=!0,g.depthFunc=Qf;break;case 6:g.depthTest=!0,g.depthFunc=GA;break;case 2:g.depthTest=!0,g.depthFunc=jA;break;case 4:g.depthTest=!0,g.depthFunc=Bd;break;case 5:g.depthTest=!0,g.depthFunc=ux;break;case 7:g.depthTest=!0,g.depthFunc=hx;break;case 8:g.depthTest=!1,g.depthFunc=cx;break}g.transparent=v,v&&(g.depthWrite=!1),Hde(m),g.onUpdateUniforms();for(const y in A){const b=y,x=A[y].type;if(((h=m[b])==null?void 0:h.value)===void 0)switch(x){case l6.SAMPLER_2D:m[b]={value:jde},console.warn("Missing/unassigned texture, fallback to white: "+b);break;default:b==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+b,A[y]);break}}ad&&console.log(g.uuid,m),c6(g),o(g)}):null}}function c6(i){if(i.uniforms){ad&&console.log("Uniforms:",i.uniforms);for(const t in i.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,n){Object.getOwnPropertyDescriptor(i,t)||Object.defineProperty(i,t,{get:()=>i.uniforms[n].value,set:r=>{i.uniforms[n].value=r,i.needsUpdate=!0}})}}const wge=ee("debugextensions");let sE;const Cge=Promise.resolve().then(()=>Zxe).then(async i=>(sE=i.GLTFAnimationPointerExtension,sE)).catch(i=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",i)}),mf=new Array;function Ege(i){mf.includes(i)||mf.push(i)}function Sge(i){const e=mf.indexOf(i);e>=0&&mf.splice(e,1)}function JP(i){const e=new vge;return i.register(t=>(e.parser=t,e)),e}class Ige{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function KP(i,e,t){const n=t.indexOf("?");n>=0&&(t=t.substring(0,n)),i.register(r=>new yge(r)),i.register(r=>new aue(r)),i.register(r=>new Ude(r,e.lightmaps,t)),i.register(r=>new bge(r,t,e)),i.register(r=>new _ge(r,t)),i.register(r=>new qP(r,t)),i.register(r=>new pi(r,t)),i.register(r=>new fge(r)),zj()&&i.register(r=>new T2(r)),await Cge.catch(r=>{}),i.register(r=>{if(sE){const s=new sE(r);return s.setAnimationPointerResolver.bind(s)(new Ige),s}else return(wge||rt())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const r of mf)r.onImport&&r.onImport(i,t,e)}function ZP(i,e){for(const t of mf)t.onExport&&t.onExport(i,e)}function $P(i,e,t){for(const n of mf)n.onLoaded&&n.onLoaded(i,e,t)}const Al=ee("debuginstancing"),h6=class{constructor(){u(this,"objs",[])}setup(i,e,t,n,r,s=0){i.applySettings(e);const o=this.tryCreateOrAddInstance(e,t,r);if(o)pi.assignTextureLOD(o.renderer.material,0),n===null&&(n=[]),n.push(o);else if(s<=0&&e.type!=="Mesh"){const a=s+1;for(const l of e.children)n=this.setup(i,l,t,n,r,a)}return s===0&&r.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(e),n}tryCreateOrAddInstance(i,e,t){if(i.type==="Mesh"){const n=t.foundMeshes;if(t.foundMeshes+=1,!t.rend.enableInstancing)return null;if(t.rend.enableInstancing!==!0){if(n>=t.rend.enableInstancing.length)return Al&&console.error("Something is wrong with instance setup",i,t.rend.enableInstancing,n),null;if(!t.rend.enableInstancing[n])return null}const r=i,s=r.material;for(const c of this.objs)if(!!c.canAdd(r.geometry,s))return c.addInstance(r);const o=16;let a=i.name;a!=null&&a.length||(a=hT());const l=new u6(a,r.geometry,s,o,e);return this.objs.push(l),l.addInstance(r)}return null}autoUpdateInstanceMatrix(i){const e=i.matrixWorld.multiplyMatrices.bind(i.matrixWorld),t=i.matrixWorld.clone(),n=(r,s)=>{const o=e(r,s);return(i[kv]||t.equals(o)===!1)&&(t.copy(o),i[kv]=!0),o};i.matrixWorld.multiplyMatrices=n}};let Jy=h6;u(Jy,"instance",new h6);const oE=class{constructor(i,e){u(this,"object"),u(this,"renderer"),u(this,"__instanceIndex",-1),u(this,"__reservedVertexRange",0),u(this,"__reservedIndexRange",0),u(this,"meshInformation"),this.__instanceIndex=-1,this.object=i,this.renderer=e,i[qj]=e,this.meshInformation=aA(i.geometry),oE.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(i=!1,e=!0){this.__instanceIndex<0||(e&&this.object.updateWorldMatrix(!0,i),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(i){this.__instanceIndex<0||this.renderer.updateInstance(i,this.__instanceIndex)}setGeometry(i){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(i,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),te.markAsInstancedRendered(this.object,!0))}remove(i){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,i),te.markAsInstancedRendered(this.object,!1),i)){const e=oE.all.indexOf(this);e>=0&&oE.all.splice(e,1)}}};let Ky=oE;u(Ky,"all",[]);class u6{constructor(e,t,n,r,s){u(this,"allowResize",!0),u(this,"name",""),u(this,"geometry"),u(this,"material"),u(this,"context"),u(this,"inst"),u(this,"handles",[]),u(this,"maxInstanceCount"),u(this,"_currentInstanceCount",0),u(this,"_currentVertexCount",0),u(this,"_currentIndexCount",0),u(this,"_maxVertexCount"),u(this,"_maxIndexCount"),u(this,"_needUpdateBounds",!1),u(this,"_debugMaterial",null),u(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[Ov]===!0&&(Al&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())}),u(this,"onAfterRender",()=>{this.inst.layers.disableAll()}),u(this,"_availableBuckets",new Array),u(this,"_usedBuckets",new Array),this.name=e,this.geometry=t,this.material=n,this.context=s,this.maxInstanceCount=Math.max(2,r),Al&&(this._debugMaterial=d6());const o=this.tryEstimateVertexCountSize(this.maxInstanceCount,[t],r);this._maxVertexCount=o.vertexCount,this._maxIndexCount=o.indexCount,this.inst=new m_(this.maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this.inst[Ov]=!0,this.inst.visible=!0,this.context.scene.add(this.inst),n instanceof T_&&(n.defines.USE_INSTANCING=!0,n.needsUpdate=!0),s.pre_render_callbacks.push(this.onBeforeRender),s.post_render_callbacks.push(this.onAfterRender),Al&&console.log(`Instanced renderer created with ${this.maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get count(){return this._currentInstanceCount}canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){Al&&console.warn("Dispose instanced renderer",this.name),this.context.scene.remove(this.inst),this.inst.dispose(),this.inst=null,this.handles=[]}addInstance(e){const t=new Ky(e,this);e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0);try{this.add(t)}catch(n){return console.error(`Failed adding mesh to instancing
6236
+ `,a,e,o))),e.userData=e.userData||{},e.userData[mp]=e.userData[mp]||[],e.userData[mp].push(o)}await Promise.all(r).catch(s=>{console.error("Error while loading components",s)})}}}const o6="NEEDLE_gameobject_data";class yge{constructor(e){u(this,"parser"),this.parser=e}get name(){return o6}afterRoot(e){var t;const n=[];for(let r=0;r<((t=this.parser.json.nodes)==null?void 0:t.length);r++){const s=this.parser.json.nodes[r];if(s&&s.extensions){const o=s.extensions[o6];if(o){const a=this.findAndApplyExtensionData(r,o);n.push(a)}}}return Promise.all(n).then(()=>null)}async findAndApplyExtensionData(e,t){const n=await this.parser.getDependency("node",e);n&&this.applyExtensionData(n,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.userData.hideFlags=t.hideFlags??0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const a6="NEEDLE_lighting_settings",sA=ee("debugenvlight");class bge{constructor(e,t,n){u(this,"parser"),u(this,"sourceId"),u(this,"context"),this.parser=e,this.sourceId=t,this.context=n}get name(){return a6}afterRoot(e){const t=this.parser.json.extensions;if(t){const n=t[a6];if(n){sA&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',n);let r;if(e.scene.children.length===1){const s=e.scene.children[0];r=te.addNewComponent(s,rE,{},!1)}else{const s=new ve;s.name="LightSettings "+this.sourceId,e.scene.add(s),r=te.addNewComponent(s,rE,{},!1)}r.sourceId=this.sourceId,r.ambientIntensity=n.ambientIntensity,r.ambientLight=new _e().fromArray(n.ambientLight),Array.isArray(n.ambientTrilight)&&(r.ambientTrilight=n.ambientTrilight.map(s=>new _e().fromArray(s))),r.ambientMode=n.ambientMode,r.environmentReflectionSource=n.environmentReflectionSource}}return null}}hi.registerCallback(Ei.ContextCreated,i=>{const e=i.context,t=te.findObjectOfType(rE,e);t!=null&&t.sourceId&&(t.enabled=!0)});class rE extends Re{constructor(){super(...arguments),u(this,"ambientMode",Bg.Skybox),u(this,"ambientLight"),u(this,"ambientTrilight"),u(this,"ambientIntensity",1),u(this,"environmentReflectionSource",lC.Skybox),u(this,"_hasReflection",!1),u(this,"_ambientLightObj"),u(this,"_hemisphereLightObj")}awake(){var e;if(this.sourceId){const n=this.environmentReflectionSource===lC.Skybox?Hu.Skybox:Hu.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,n,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),sA&&window.addEventListener("keydown",n=>{if(!this.destroyed)switch(n.key){case"l":this.enabled=!this.enabled;break}});const t=(e=this.gameObject.userData)==null?void 0:e.components;if(t){const n=t.indexOf(this);t.splice(n,1),t.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*$e.lerp(0,1.33,t)}onEnable(){if(sA&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==Bg.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new P_(this.ambientLight,this.ambientIntensity*e),sA&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===Bg.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],n=this.calculateIntensityFactor(t);this._hemisphereLightObj=new HM(t,e,this.ambientIntensity*n),this.gameObject.add(this._hemisphereLightObj),sA&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,n)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){sA&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var l6=(i=>(i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_3D=35680]="SAMPLER_3D",i[i.SAMPLER_CUBE=35681]="SAMPLER_CUBE",i[i.UNKNOWN=0]="UNKNOWN",i))(l6||{});const ad=ee("debugcustomshader"),oA="NEEDLE_techniques_webgl";class xge{constructor(){u(this,"objectToWorldMatrix",new ge),u(this,"worldToObjectMatrix",new ge),u(this,"objectToWorld",new Array),u(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),aC(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),aC(this.worldToObjectMatrix,this.worldToObject)}}const gn=class extends T_{constructor(i,...e){super(...e),u(this,"identifier"),u(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),u(this,"_sphericalHarmonicsName","unity_SpecCube0"),u(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),u(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),u(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),u(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),u(this,"_rendererData",new xge),this.identifier=i,ad&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&kt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const i=super.clone();return c6(i),i}dispose(){super.dispose();const i=kt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);i>=0&&kt.Current.pre_render_callbacks.splice(i,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&kt.Current.setRequireColor(!0),this.depthTextureUniform&&kt.Current.setRequireDepth(!0)}onBeforeRender(i,e,t,n,r,s){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(t,r)}onUpdateUniforms(i,e){const t=kt.Current;if(i&&(gn.viewProjection&&this.uniforms[this._viewProjectionName]&&(gn.viewProjection.copy(i.projectionMatrix).multiply(i.matrixWorldInverse),aC(gn.viewProjection,gn._viewProjectionValues)),gn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(gn.viewMatrix.copy(i.matrixWorldInverse),aC(gn.viewMatrix,gn._viewMatrixValues)),this.uniforms[gn._worldSpaceCameraPosName]&&gn._worldSpaceCameraPos.setFromMatrixPosition(i.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=t.sceneLighting.timeVec4),this.uniforms._Time){const o=this.uniforms._Time.value;o.x=t.sceneLighting.timeVec4.x/20,o.y=t.sceneLighting.timeVec4.x,o.z=t.sceneLighting.timeVec4.x*2,o.w=t.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const o=this.uniforms._SinTime.value;o.x=Math.sin(t.sceneLighting.timeVec4.x/8),o.y=Math.sin(t.sceneLighting.timeVec4.x/4),o.z=Math.sin(t.sceneLighting.timeVec4.x/2),o.w=Math.sin(t.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const o=this.uniforms._CosTime.value;o.x=Math.cos(t.sceneLighting.timeVec4.x/8),o.y=Math.cos(t.sceneLighting.timeVec4.x/4),o.z=Math.cos(t.sceneLighting.timeVec4.x/2),o.w=Math.cos(t.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const o=this.uniforms.unity_DeltaTime.value;o.x=t.time.deltaTime,o.y=1/t.time.deltaTime,o.z=t.time.smoothedDeltaTime,o.w=1/t.time.smoothedDeltaTime}const n=t.mainLight;if(n){const o=Tt(n.gameObject,gn._mainLightPosition);this.uniforms._MainLightPosition={value:o.normalize()},gn._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:gn._mainLightColor};const a=n.intensity;gn._lightData.z=a,this.uniforms.unity_LightData={value:gn._lightData}}if(i&&(gn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=gn._viewProjectionValues),gn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=gn._viewMatrixValues),this.uniforms[gn._worldSpaceCameraPosName]&&(this.uniforms[gn._worldSpaceCameraPosName]={value:gn._worldSpaceCameraPos}),t.mainCameraComponent)){if(this.uniforms._ProjectionParams){const o=this.uniforms._ProjectionParams.value;o.x=1,o.y=t.mainCameraComponent.nearClipPlane,o.z=t.mainCameraComponent.farClipPlane,o.w=1/o.z,this.uniforms._ProjectionParams.value=o}if(this.uniforms._ZBufferParams){const o=this.uniforms._ZBufferParams.value,a=t.mainCameraComponent;o.x=1-a.farClipPlane/a.nearClipPlane,o.y=a.farClipPlane/a.nearClipPlane,o.z=o.x/a.farClipPlane,o.w=o.y/a.farClipPlane,this.uniforms._ZBufferParams.value=o}if(this.uniforms._ScreenParams){const o=this.uniforms._ScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScreenParams.value=o}if(this.uniforms._ScaledScreenParams){const o=this.uniforms._ScaledScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScaledScreenParams.value=o}}const r=this.depthTextureUniform;r&&(r.value=t.depthTexture);const s=this.opaqueTextureUniform;if(s&&(s.value=t.opaqueColorTexture),e){const o=this._rendererData;o.updateFrom(e),this.uniforms[this._worldToObjectName].value=o.worldToObject,this.uniforms[this._objToWorldName].value=o.objectToWorld}this.uniformsNeedUpdate=!0}};let gl=gn;u(gl,"viewProjection",new ge),u(gl,"_viewProjectionValues",[]),u(gl,"viewMatrix",new ge),u(gl,"_viewMatrixValues",[]),u(gl,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),u(gl,"_worldSpaceCameraPos",new E),u(gl,"_mainLightColor",new qe),u(gl,"_mainLightPosition",new E),u(gl,"_lightData",new qe);class _ge{constructor(e,t){u(this,"parser"),u(this,"identifier"),this.parser=e,this.identifier=t}get name(){return oA}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return ad&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[oA])return ad&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const n=t.extensions[oA].technique;if(n<0)return null;const r=this.parser.json.extensions[oA];if(!r)return null;ad&&console.log(r);const s=r.techniques[n];return s?new Promise(async(o,a)=>{var l,c,h;const d=await Wde(r,s.program),p=d?.fragmentShader,f=d?.vertexShader;if(!p||!f)return a();ad&&console.log("loadMaterial",t,d);const m={},A=s.uniforms;(f.includes("_Time")||p.includes("_Time"))&&(m._Time={value:new qe(0,0,0,0)}),(f.includes("_SinTime")||p.includes("_SinTime"))&&(m._SinTime={value:new qe(0,0,0,0)}),(f.includes("_CosTime")||p.includes("_CosTime"))&&(m._CosTime={value:new qe(0,0,0,0)}),(f.includes("unity_DeltaTime")||p.includes("unity_DeltaTime"))&&(m.unity_DeltaTime={value:new qe(0,0,0,0)});for(const y in A){const b=y;switch(b){case"_TimeParameters":const x=new qe;m[b]={value:x};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":m[b]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":m[b]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":m[b]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":m[b]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":m[b]={value:null};break}}let v=!1;if(t.extensions&&t.extensions[oA]){const y=t.extensions[oA];if(y.technique===n){ad&&console.log(t.name,"Material Properties",y);for(const b in y.values){const x=y.values[b];if(typeof x=="string"){if(x.startsWith("/textures/")){const w=x.substring(10),I=Number.parseInt(w);if(I>=0){const M=await this.parser.getDependency("texture",I);M instanceof Ut&&(M.colorSpace=bi,M.needsUpdate=!0),m[b]={value:M};continue}}switch(b){case"alphaMode":x==="BLEND"&&(v=!0);continue}}if(Array.isArray(x)&&x.length===4){m[b]={value:new qe(x[0],x[1],x[2],x[3])};continue}m[b]={value:x}}}}const g=new gl(this.identifier,{name:t.name??"",uniforms:m,vertexShader:f,fragmentShader:p,lights:!1});switch(g.glslVersion=Bx,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(l=m._Cull)==null?void 0:l.value){case 0:g.side=mi;break;case 1:g.side=un;break;case 2:g.side=rr;break;default:g.side=rr;break}switch((c=m._ZTest)==null?void 0:c.value){case 3:g.depthTest=!0,g.depthFunc=Qf;break;case 6:g.depthTest=!0,g.depthFunc=GA;break;case 2:g.depthTest=!0,g.depthFunc=jA;break;case 4:g.depthTest=!0,g.depthFunc=Bd;break;case 5:g.depthTest=!0,g.depthFunc=ux;break;case 7:g.depthTest=!0,g.depthFunc=hx;break;case 8:g.depthTest=!1,g.depthFunc=cx;break}g.transparent=v,v&&(g.depthWrite=!1),Hde(m),g.onUpdateUniforms();for(const y in A){const b=y,x=A[y].type;if(((h=m[b])==null?void 0:h.value)===void 0)switch(x){case l6.SAMPLER_2D:m[b]={value:jde},console.warn("Missing/unassigned texture, fallback to white: "+b);break;default:b==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+b,A[y]);break}}ad&&console.log(g.uuid,m),c6(g),o(g)}):null}}function c6(i){if(i.uniforms){ad&&console.log("Uniforms:",i.uniforms);for(const t in i.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,n){Object.getOwnPropertyDescriptor(i,t)||Object.defineProperty(i,t,{get:()=>i.uniforms[n].value,set:r=>{i.uniforms[n].value=r,i.needsUpdate=!0}})}}const wge=ee("debugextensions");let sE;const Cge=Promise.resolve().then(()=>Kxe).then(async i=>(sE=i.GLTFAnimationPointerExtension,sE)).catch(i=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",i)}),mf=new Array;function Ege(i){mf.includes(i)||mf.push(i)}function Sge(i){const e=mf.indexOf(i);e>=0&&mf.splice(e,1)}function JP(i){const e=new vge;return i.register(t=>(e.parser=t,e)),e}class Ige{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function KP(i,e,t){const n=t.indexOf("?");n>=0&&(t=t.substring(0,n)),i.register(r=>new yge(r)),i.register(r=>new aue(r)),i.register(r=>new Ude(r,e.lightmaps,t)),i.register(r=>new bge(r,t,e)),i.register(r=>new _ge(r,t)),i.register(r=>new qP(r,t)),i.register(r=>new pi(r,t)),i.register(r=>new fge(r)),zj()&&i.register(r=>new T2(r)),await Cge.catch(r=>{}),i.register(r=>{if(sE){const s=new sE(r);return s.setAnimationPointerResolver.bind(s)(new Ige),s}else return(wge||rt())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const r of mf)r.onImport&&r.onImport(i,t,e)}function ZP(i,e){for(const t of mf)t.onExport&&t.onExport(i,e)}function $P(i,e,t){for(const n of mf)n.onLoaded&&n.onLoaded(i,e,t)}const Al=ee("debuginstancing"),h6=class{constructor(){u(this,"objs",[])}setup(i,e,t,n,r,s=0){i.applySettings(e);const o=this.tryCreateOrAddInstance(e,t,r);if(o)pi.assignTextureLOD(o.renderer.material,0),n===null&&(n=[]),n.push(o);else if(s<=0&&e.type!=="Mesh"){const a=s+1;for(const l of e.children)n=this.setup(i,l,t,n,r,a)}return s===0&&r.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(e),n}tryCreateOrAddInstance(i,e,t){if(i.type==="Mesh"){const n=t.foundMeshes;if(t.foundMeshes+=1,!t.rend.enableInstancing)return null;if(t.rend.enableInstancing!==!0){if(n>=t.rend.enableInstancing.length)return Al&&console.error("Something is wrong with instance setup",i,t.rend.enableInstancing,n),null;if(!t.rend.enableInstancing[n])return null}const r=i,s=r.material;for(const c of this.objs)if(!!c.canAdd(r.geometry,s))return c.addInstance(r);const o=16;let a=i.name;a!=null&&a.length||(a=hT());const l=new u6(a,r.geometry,s,o,e);return this.objs.push(l),l.addInstance(r)}return null}autoUpdateInstanceMatrix(i){const e=i.matrixWorld.multiplyMatrices.bind(i.matrixWorld),t=i.matrixWorld.clone(),n=(r,s)=>{const o=e(r,s);return(i[kv]||t.equals(o)===!1)&&(t.copy(o),i[kv]=!0),o};i.matrixWorld.multiplyMatrices=n}};let Jy=h6;u(Jy,"instance",new h6);const oE=class{constructor(i,e){u(this,"object"),u(this,"renderer"),u(this,"__instanceIndex",-1),u(this,"__reservedVertexRange",0),u(this,"__reservedIndexRange",0),u(this,"meshInformation"),this.__instanceIndex=-1,this.object=i,this.renderer=e,i[qj]=e,this.meshInformation=aA(i.geometry),oE.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(i=!1,e=!0){this.__instanceIndex<0||(e&&this.object.updateWorldMatrix(!0,i),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(i){this.__instanceIndex<0||this.renderer.updateInstance(i,this.__instanceIndex)}setGeometry(i){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(i,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),te.markAsInstancedRendered(this.object,!0))}remove(i){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,i),te.markAsInstancedRendered(this.object,!1),i)){const e=oE.all.indexOf(this);e>=0&&oE.all.splice(e,1)}}};let Ky=oE;u(Ky,"all",[]);class u6{constructor(e,t,n,r,s){u(this,"allowResize",!0),u(this,"name",""),u(this,"geometry"),u(this,"material"),u(this,"context"),u(this,"inst"),u(this,"handles",[]),u(this,"maxInstanceCount"),u(this,"_currentInstanceCount",0),u(this,"_currentVertexCount",0),u(this,"_currentIndexCount",0),u(this,"_maxVertexCount"),u(this,"_maxIndexCount"),u(this,"_needUpdateBounds",!1),u(this,"_debugMaterial",null),u(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[Ov]===!0&&(Al&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())}),u(this,"onAfterRender",()=>{this.inst.layers.disableAll()}),u(this,"_availableBuckets",new Array),u(this,"_usedBuckets",new Array),this.name=e,this.geometry=t,this.material=n,this.context=s,this.maxInstanceCount=Math.max(2,r),Al&&(this._debugMaterial=d6());const o=this.tryEstimateVertexCountSize(this.maxInstanceCount,[t],r);this._maxVertexCount=o.vertexCount,this._maxIndexCount=o.indexCount,this.inst=new m_(this.maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this.inst[Ov]=!0,this.inst.visible=!0,this.context.scene.add(this.inst),n instanceof T_&&(n.defines.USE_INSTANCING=!0,n.needsUpdate=!0),s.pre_render_callbacks.push(this.onBeforeRender),s.post_render_callbacks.push(this.onAfterRender),Al&&console.log(`Instanced renderer created with ${this.maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get count(){return this._currentInstanceCount}canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){Al&&console.warn("Dispose instanced renderer",this.name),this.context.scene.remove(this.inst),this.inst.dispose(),this.inst=null,this.handles=[]}addInstance(e){const t=new Ky(e,this);e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0);try{this.add(t)}catch(n){return console.error(`Failed adding mesh to instancing
6237
6237
  `,n),rt()&&lB("Failed instancing mesh. See the browser console for details."),null}return t}add(e){const t=e.object.geometry;if(!this.validateGeometry(t)){Al&&console.error("Cannot add instance, invalid geometry",this.name,t);return}if(this.mustGrow(t))if(this.allowResize)this.grow(t);else{console.error("Cannot add instance, max count reached",this.name,this.count,this.maxInstanceCount);return}e.object.updateWorldMatrix(!0,!0),this.addGeometry(e),this.handles[e.__instanceIndex]=e,this._currentInstanceCount+=1,this.markNeedsUpdate(),this._currentInstanceCount>0&&(this.inst.visible=!0)}remove(e,t){e&&(e.__instanceIndex<0||this.handles[e.__instanceIndex]!=e||this._currentInstanceCount<=0||(this.removeGeometry(e,t),this.handles[e.__instanceIndex]=null,e.__instanceIndex=-1,this._currentInstanceCount>0&&(this._currentInstanceCount-=1),this._currentInstanceCount<=0&&(this.inst.visible=!1),this.markNeedsUpdate()))}updateInstance(e,t){this.inst.setMatrixAt(t,e),this.markNeedsUpdate()}updateGeometry(e,t){return this.validateGeometry(e)?(this.mustGrow()&&this.grow(e),Al&&console.debug("UPDATE MESH",t,e.name,aA(e),e.attributes.position.count,e.index?e.index.count:0),this.inst.setGeometryAt(t,e),this.markNeedsUpdate(),!0):!1}validateGeometry(e){return this.geometry,!0}markNeedsUpdate(){this._needUpdateBounds=!0}mustGrow(e){if(this.count>=this.maxInstanceCount)return!0;if(!e)return!1;const t=aA(e),n=t.vertexCount,r=t.indexCount;return this._currentVertexCount+n>this._maxVertexCount||this._currentIndexCount+r>this._maxIndexCount}grow(e){const t=this.maxInstanceCount*2,n=this.tryEstimateVertexCountSize(t,[e]),r=Math.max(this._maxVertexCount,n.vertexCount),s=Math.max(this._maxIndexCount,n.indexCount,this._maxVertexCount*2);if(Al){const a=aA(e);console.warn(`Growing batched mesh for "${this.name}/${e.name}" ${a.vertexCount} vertices, ${a.indexCount} indices
6238
6238
  Max count ${this.maxInstanceCount} \u2192 ${t}
6239
6239
  Max vertex count ${this._maxVertexCount} -> ${r}
@@ -7343,7 +7343,7 @@ void main() {
7343
7343
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
7344
7344
 
7345
7345
  #include <fog_vertex>
7346
- }`);new E(0,0,1);var Fve=function(i){_A(t,i);var e=wA(t);function t(n){var r;return wt(this,t),r=e.call(this,n),Z(ii(r),"positionBuffer",void 0),Z(ii(r),"previousBuffer",void 0),Z(ii(r),"nextBuffer",void 0),Z(ii(r),"uvBuffer",void 0),Z(ii(r),"sideBuffer",void 0),Z(ii(r),"widthBuffer",void 0),Z(ii(r),"colorBuffer",void 0),Z(ii(r),"indexBuffer",void 0),Z(ii(r),"vector_",new E),Z(ii(r),"vector2_",new E),Z(ii(r),"vector3_",new E),Z(ii(r),"quaternion_",new Ce),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return Ct(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new gt,this.indexBuffer=new et(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(ls),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new et(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(ls),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new et(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(ls),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new et(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(ls),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new et(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(ls),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new et(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(ls),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new et(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(ls),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new et(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(ls),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new K(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new K(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=qk(this.settings.material.map.channel),n.map=new we(this.settings.material.map),n.mapTransform=new we(new Lt().copy(this.settings.material.map.matrix))),this.settings.renderMode===nt.Trail)this.material=new Mt({uniforms:n,defines:r,vertexShader:Lve,fragmentShader:Ove,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Td});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,s=0,o=0;this.systems.forEach(function(a){for(var l=0;l<a.particleNum;l++)o+=a.particles[l].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(a){var l=n.quaternion_,c=n.vector2_,h=n.vector3_;a.emitter.matrixWorld.decompose(c,l,h);for(var d=a.particles,p=a.particleNum,f=n.settings.uTileCount,m=n.settings.vTileCount,A=1/f,v=1/m,g=0;g<p;g++){var y=d[g],b=y.uvTile%m,x=Math.floor(y.uvTile/m),w=y.previous.values(),I=w.next(),M=I.value,T=M;I.done||(I=w.next());var D=void 0;I.value!==void 0?D=I.value:D=T;for(var S=0;S<y.previous.length;S++,r+=2){if(n.positionBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.positionBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z),a.worldSpace?(n.positionBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.positionBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z)):(y.parentMatrix?n.vector_.copy(T.position).applyMatrix4(y.parentMatrix):n.vector_.copy(T.position).applyMatrix4(a.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.previousBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.previousBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(y.parentMatrix?n.vector_.copy(M.position).applyMatrix4(y.parentMatrix):n.vector_.copy(M.position).applyMatrix4(a.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.nextBuffer.setXYZ(r,D.position.x,D.position.y,D.position.z),n.nextBuffer.setXYZ(r+1,D.position.x,D.position.y,D.position.z)):(y.parentMatrix?n.vector_.copy(D.position).applyMatrix4(y.parentMatrix):n.vector_.copy(D.position).applyMatrix4(a.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),a.worldSpace)n.widthBuffer.setX(r,T.size),n.widthBuffer.setX(r+1,T.size);else if(y.parentMatrix)n.widthBuffer.setX(r,T.size),n.widthBuffer.setX(r+1,T.size);else{var B=(Math.abs(h.x)+Math.abs(h.y)+Math.abs(h.z))/3;n.widthBuffer.setX(r,T.size*B),n.widthBuffer.setX(r+1,T.size*B)}n.uvBuffer.setXY(r,(S/y.previous.length+b)*A,(m-x-1)*v),n.uvBuffer.setXY(r+1,(S/y.previous.length+b)*A,(m-x)*v),n.colorBuffer.setXYZW(r,T.color.x,T.color.y,T.color.z,T.color.w),n.colorBuffer.setXYZW(r+1,T.color.x,T.color.y,T.color.z,T.color.w),S+1<y.previous.length&&(n.indexBuffer.setX(s*3,r),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+2),s++,n.indexBuffer.setX(s*3,r+2),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+3),s++),M=T,T=D,I.done||(I=w.next(),I.value!==void 0&&(D=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=s*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,s*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(D9),Uve=function(i){_A(t,i);var e=wA(t);function t(){var n;return wt(this,t),n=e.call(this),Z(ii(n),"batches",[]),Z(ii(n),"systemToBatchIndex",new Map),Z(ii(n),"type","BatchedRenderer"),n}return Ct(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),s=0;s<this.batches.length;s++)if(t.equals(this.batches[s].settings,r)){this.batches[s].addSystem(n),this.systemToBatchIndex.set(n,s);return}var o;switch(r.renderMode){case nt.Trail:o=new Fve(r);break;case nt.Mesh:case nt.BillBoard:case nt.VerticalBillBoard:case nt.HorizontalBillBoard:case nt.StretchedBillBoard:o=new kve(r);break}o.addSystem(n),this.batches.push(o),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(s,o){o.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ve),Nve=Uve,k9=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new E;wt(this,i),Z(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=n}return Ct(i,[{key:"transform",value:function(e,t){e.x=this.locations[t%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[t%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new i(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(t){return t.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,t){var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");if(r){r.drawImage(e,0,0);var s=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var o=0;o<s.height;o++)for(var a=0;a<s.width;a++)s.data[(o*s.width+a)*4+3]>t&&this.locations.push(new K(a,s.height-o))}}}],[{key:"fromJSON",value:function(e){var t=new i(e.scaleX,e.scaleY,new E(e.position[0],e.position[1],e.position[2]));return t.locations=e.locations.map(function(n){return new K(n.x,n.y)}),t}}]),i}();function Qve(i){switch(i.type){case"TextureSequencer":return k9.fromJSON(i);default:return new k9}}var zve=function(){function i(e){wt(this,i),Z(this,"type","ApplySequences"),Z(this,"sequencers",[]),Z(this,"time",0),Z(this,"index",0),Z(this,"pCount",0),Z(this,"delay",void 0),Z(this,"tempV",new E),this.delay=e}return Ct(i,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new E,e.begin=new E,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,t){var n=this.sequencers[this.index],r=e.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),n[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,i.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,t){this.sequencers.push([e,t])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var t=CA(e,2),n=t[0],r=t[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new i(this.delay);return e.sequencers=this.sequencers.map(function(t){return[t[0].clone(),t[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var t=new i(e.delay);return e.sequencers.forEach(function(n){t.sequencers.push([Hi(n.range),Qve(n.sequencer)])}),t}}]),i}();Z(zve,"BEZIER",new Nk(0,0,1,1));var he=function(i){return i[i.Number=0]="Number",i[i.Vec2=1]="Vec2",i[i.Vec3=2]="Vec3",i[i.Vec4=3]="Vec4",i[i.Boolean=4]="Boolean",i[i.AnyType=5]="AnyType",i}({}),O9=Ct(function i(e,t,n,r){wt(this,i),Z(this,"input",void 0),Z(this,"inputIndex",void 0),Z(this,"output",void 0),Z(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=n,this.outputIndex=r,this.output.inputs[r]=this}),jve=function(){function i(){wt(this,i),Z(this,"visited",new Set),Z(this,"graph_",void 0),Z(this,"context_",void 0),i.Instance=this}return Ct(i,[{key:"traverse",value:function(e){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(e.id);for(var t=[],n=0;n<e.inputs.length;n++)if(e.inputs[n]instanceof O9){var r=e.inputs[n].input;this.visited.has(r.id)||this.traverse(r),t.push(r.outputValues[e.inputs[n].inputIndex])}else t.push(e.inputs[n].getValue(this.context_));e.func(this.context_,t,e.outputValues),this.graph_.nodesInOrder.push(e)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var e=this.graph_.nodesInOrder,t=0;t<e.length;t++){for(var n=[],r=e[t],s=0;s<r.inputs.length;s++)if(r.inputs[s]instanceof O9)n.push(r.inputs[s].input.outputValues[r.inputs[s].inputIndex]);else if(r.inputs[s]!==void 0)n.push(r.inputs[s].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(e,t){if(this.graph_=e,this.context_=t,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<e.outputNodes.length;n++){var r=e.outputNodes[n];this.traverse(r)}e.compiled=!0}}}]),i}();Z(jve,"Instance",void 0);var ui=function(){function i(e){wt(this,i),Z(this,"name",void 0),Z(this,"nodeTypeSignatures",[]),this.name=e}return Ct(i,[{key:"addSignature",value:function(e,t,n){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:t,func:n})}}]),i}(),HE=new ui("add");HE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]+t[1]}),HE.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),HE.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),HE.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].addVectors(t[0],t[1])});var VE=new ui("sub");VE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]-t[1]}),VE.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),VE.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),VE.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].subVectors(t[0],t[1])});var WE=new ui("mul");WE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]*t[1]}),WE.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),WE.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),WE.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])});var qE=new ui("div");qE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]/t[1]}),qE.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),qE.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),qE.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])});var Gve=new ui("sin");Gve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.sin(t[0])});var Hve=new ui("cos");Hve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.cos(t[0])});var Vve=new ui("tan");Vve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.tan(t[0])});var Wve=new ui("abs");Wve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.abs(t[0])});var qve=new ui("min");qve.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.min(t[0],t[1])});var Xve=new ui("max");Xve.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.max(t[0],t[1])});var Xk=new ui("dot");Xk.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),Xk.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),Xk.addSignature([he.Vec4,he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])});var Yve=new ui("cross");Yve.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].crossVectors(t[0],t[1])});var Yk=new ui("length");Yk.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),Yk.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),Yk.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].length()});var Jk=new ui("lengthSq");Jk.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),Jk.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),Jk.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()});var Kk=new ui("normalize");Kk.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).normalize()}),Kk.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).normalize()}),Kk.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).normalize()});var L9=new ui("distance");L9.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])}),L9.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])});var Jve=new ui("and");Jve.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]&&t[1]});var Kve=new ui("or");Kve.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]||t[1]});var Zve=new ui("not");Zve.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=!t[0]});var XE=new ui("equal");XE.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]===t[1]}),XE.addSignature([he.Vec2,he.Vec2],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),XE.addSignature([he.Vec3,he.Vec3],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),XE.addSignature([he.Vec4,he.Vec4],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])});var $ve=new ui("lessThan");$ve.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<t[1]});var eye=new ui("greaterThan");eye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>t[1]});var tye=new ui("lessThanOrEqual");tye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<=t[1]});var iye=new ui("greaterThanOrEqual");iye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>=t[1]});var nye=new ui("if");nye.addSignature([he.Boolean,he.AnyType,he.AnyType],[he.AnyType],function(i,e,t,n){n[0]=t[0]?t[1]:t[2]});var rye=new ui("number");rye.addSignature([],[he.Number],function(i,e,t,n){n[0]=e.value});var sye=new ui("vec2");sye.addSignature([],[he.Vec2],function(i,e,t,n){n[0]=e.value});var oye=new ui("vec3");oye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=e.value});var aye=new ui("vec4");aye.addSignature([],[he.Vec4],function(i,e,t,n){n[0]=e.value});var lye=new ui("bool");lye.addSignature([],[he.Boolean],function(i,e,t,n){n[0]=e.value});var cye=new ui("particlePosition");cye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var hye=new ui("particleVelocity");hye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var uye=new ui("particleRotation");uye.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var dye=new ui("particleAge");dye.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var wb=new ui("output");wb.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var pye=Object.defineProperty,fye=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?fye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&pye(e,t,r),r};const Cb=ee("debugparticles"),mye=ee("noprogressive"),gye=ee("debugprogressive");var Zk=(i=>(i[i.Birth=0]="Birth",i[i.Collision=1]="Collision",i[i.Death=2]="Death",i[i.Trigger=3]="Trigger",i[i.Manual=4]="Manual",i))(Zk||{});class ka extends Re{constructor(){super(...arguments),u(this,"renderMode"),u(this,"particleMaterial"),u(this,"trailMaterial"),u(this,"particleMesh"),u(this,"maxParticleSize"),u(this,"minParticleSize"),u(this,"velocityScale"),u(this,"cameraVelocityScale"),u(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&rt()){const e=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let t=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return t&&e&&t.side===rr&&(t=t.clone(),t.side=un,e?this.trailMaterial=t:this.particleMaterial=t),t&&!mye&&t._didRequestTextureLOD===void 0&&(t._didRequestTextureLOD=0,gye&&console.log("Load material LOD",t.name),pi.assignTextureLOD(t,0)),t}getMesh(e){let t=null;if(!t&&(this.particleMesh instanceof pe&&(t=this.particleMesh.geometry),t===null)){t=new ir(1,1);const n=t.attributes.uv;for(let r=0;r<n.count;r++)n.setX(r,1-n.getX(r))}return new pe(t,this.getMaterial())}}yn([_()],ka.prototype,"renderMode",2),yn([_(Rt)],ka.prototype,"particleMaterial",2),yn([_(Rt)],ka.prototype,"trailMaterial",2),yn([_()],ka.prototype,"maxParticleSize",2),yn([_()],ka.prototype,"minParticleSize",2),yn([_()],ka.prototype,"velocityScale",2),yn([_()],ka.prototype,"cameraVelocityScale",2),yn([_()],ka.prototype,"lengthScale",2);class YE{constructor(e,t=1){u(this,"_curve"),u(this,"_factor"),u(this,"type","function"),this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class $k{constructor(e){u(this,"type","value"),u(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Aye extends $k{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class vye extends $k{constructor(){super(...arguments),u(this,"_lastPosition",new E),u(this,"_lastDistance",0)}update(){const e=Tt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let s=this._lastDistance/this.system.deltaTime*r;Number.isFinite(s)||(s=0),e+=s}const t=this.system.emission.getBurst();t>0&&(e+=t/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return $e.clamp(e,0,n/this.system.deltaTime)}}class yye extends $k{genValue(){return this.system.isPlaying,0}}class Ad{constructor(e){u(this,"system"),u(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class bye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleTextureSheet")}update(e,t){const n=this.system.textureSheetAnimation;if(n.enabled){const r=e.age/e.life,s=n.evaluate(r);s!==void 0&&(e.uvTile=s)}}}const F9=Symbol("particleRotation");class xye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleRotation")}initialize(e){e[F9]=Math.random()}update(e,t){if(e.rotation===void 0)return;const n=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(n,e[F9])*t:this.system.renderer.renderMode===Bh.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(n,r)*t}}}const U9=Symbol("sizeLerpFactor"),_ye=new E;class wye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleSize"),u(this,"_minSize",0),u(this,"_maxSize",1)}initialize(e){e[U9]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,t){const n=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,e[U9]).x);let s=1;if(this.system.renderer.renderMode!==Bh.Mesh&&(s=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*s,this.system.localspace){const o=G9(this.system,_ye);e.size*=o.x}}}const EA=Symbol("particleLife"),eO=Symbol("trailLifetime"),N9=Symbol("trailStartLength"),tO=Symbol("trailWidthRandom");class Cye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleTrail")}initialize(e){e instanceof vb&&(e[EA]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[eO]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[eO]),e[N9]=e.length,e[tO]=Math.random())}update(e){var t;if((t=this.system.trails)!=null&&t.enabled&&e instanceof vb){const n=e,r=e.age/e[EA],s=e.previous.values(),o=e.previous.length;for(let a=0;a<o;a++){const l=s.next().value,c=1-a/(o-1);let h=e.size;h<=0&&!this.system.trails.sizeAffectsWidth&&(h=20*this.system.trails.widthOverTrail.evaluate(.5,n[tO])),l.size=this.system.trails.getWidth(h,r,c,n[tO]),l.color.copy(e.color),this.system.trails.getColor(l.color,r,c)}if(e.age>e[EA]){e.velocity.set(0,0,0);const a=(e.age-e[EA])/e[eO];n.length=$e.lerp(e[N9],0,a)}}}}const JE=Symbol("startVelocity"),Q9=Symbol("gravityModifier"),iO=Symbol("gravitySpeed"),KE=Symbol("velocity lerp factor"),nO=new E;class Eye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleVelocity"),u(this,"_gravityDirection",new E)}initialize(e){var t,n;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(t=this.system.inheritVelocity)!=null&&t.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[JE]?e[JE].copy(e.velocity):e[JE]=e.velocity.clone();const s=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[Q9]=s*r,e[iO]=s*r*.5,e[KE]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===tb.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,t){var n;const r=e[JE],s=e[Q9];if(s!==0){const p=s*e[iO];nO.copy(this._gravityDirection).multiplyScalar(p),e[iO]+=t*.05,r.add(nO)}e.velocity.copy(r);const o=e.age/e.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,o,e[KE]);const a=this.system.noise;a.enabled&&a.apply(0,e.position,e.velocity,t,e.age,e.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(e.size=l.evaluate(e.velocity,o,e[KE],e.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(e.velocity,e[KE],e.color);const h=this.system.velocityOverLifetime;h.enabled&&h.apply(e,0,e.position,e.velocity,t,e.age,e.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(e.position,r,e.velocity,e.size,o,t,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const z9=Symbol("colorLerpFactor"),j9=new wi(1,1,1,1),Tf=new wi(1,1,1,1);class Sye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleColor")}initialize(e){}_init(e){const t=this.system.renderer.particleMaterial;Tf.copy(this.system.main.startColor.evaluate(Math.random())),t!=null&&t.color&&(j9.copy(t.color),Tf.multiply(j9)),Tf.convertLinearToSRGB(),e.startColor.set(Tf.r,Tf.g,Tf.b,Tf.alpha),e.color.copy(e.startColor),e[z9]=Math.random()}update(e,t){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const n=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(n,e[z9]);e.color.set(r.r,r.g,r.b,r.alpha).multiply(e.startColor)}else e.color.copy(e.startColor)}}class Iye{constructor(e){u(this,"system"),u(this,"emission"),u(this,"autoDestroy"),u(this,"startLength"),u(this,"emissionBursts"),u(this,"onlyUsedByOther"),u(this,"behaviors",[]),u(this,"rendererEmitterSettings",{startLength:new Ms(220),followLocalOrigin:!1}),u(this,"flatWhiteTexture"),u(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new vye(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new YE(this.system.main.startLifetime)}get startSpeed(){return new YE(this.system.main.startSpeed)}get startRotation(){return new YE(this.system.main.startRotation)}get startSize(){return new YE(this.system.main.startSize)}get startColor(){return new GE(new qe(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new yye(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return nt.Trail;switch(this.system.renderer.renderMode){case Bh.Billboard:return nt.BillBoard;case Bh.Stretch:return nt.StretchedBillBoard;case Bh.HorizontalBillboard:return nt.HorizontalBillBoard;case Bh.VerticalBillboard:return nt.VerticalBillBoard;case Bh.Mesh:return nt.Mesh}return nt.BillBoard}get speedFactor(){var e;let t=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===Bh.Stretch&&(t*=this.system.renderer.velocityScale??1),t}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const n=t.clone();n.premultiplyAlpha=!1,n.colorSpace=bi,this.clonedTexture.original=t,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=UD(new wi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Aye(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??zh}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===tb.World}}class Mye{constructor(){u(this,"burstIndex",0),u(this,"burstWaveIndex",0),u(this,"time",0),u(this,"waitEmiting",0)}}const ZE=class extends Re{constructor(){super(...arguments),u(this,"_state"),u(this,"colorOverLifetime"),u(this,"main"),u(this,"emission"),u(this,"sizeOverLifetime"),u(this,"shape"),u(this,"noise"),u(this,"trails"),u(this,"velocityOverLifetime"),u(this,"limitVelocityOverLifetime"),u(this,"inheritVelocity"),u(this,"colorBySpeed"),u(this,"textureSheetAnimation"),u(this,"rotationOverLifetime"),u(this,"rotationBySpeed"),u(this,"sizeBySpeed"),u(this,"_cameraScale",1),u(this,"__worldQuaternion",new Ce),u(this,"_worldQuaternionInverted",new Ce),u(this,"_worldScale",new E),u(this,"_worldPositionFrame",-1),u(this,"_worldPos",new E),u(this,"_renderer"),u(this,"_batchSystem"),u(this,"_particleSystem"),u(this,"_interface"),u(this,"_container"),u(this,"_time",0),u(this,"_isPlaying",!0),u(this,"_isUsedAsSubsystem",!1),u(this,"_didPreWarm",!1),u(this,"_bursts"),u(this,"_subEmitterSystems"),u(this,"_lastBatchesCount",-1),u(this,"lastMaterialVersion",-1)}play(i=!1){var e;i&&te.foreachComponent(this.gameObject,t=>{t instanceof ZE&&t!==this&&t.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(i=!0){i&&te.foreachComponent(this.gameObject,e=>{e instanceof ZE&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(i=!0,e=!1){i&&te.foreachComponent(this.gameObject,t=>{t instanceof ZE&&t!==this&&t.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var i;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(i=this.emission)==null||i.reset())}emit(i){if(this._particleSystem){this.onUpdate(),i=Math.min(i,this.maxParticles-this.currentParticles),this._state||(this._state=new Mye),this._state.waitEmiting=i,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(i){this.main.playOnAwake=i}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var i;return((i=this._particleSystem)==null?void 0:i.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===tb.World}get localspace(){return this.main.simulationSpace===tb.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Tt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(i){return this._particleSystem?(i instanceof Ad&&(i.system=this),rt()&&console.log("add behaviour",i),this._particleSystem.addBehavior(i),!0):!1}removeBehaviour(i){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,t=e.indexOf(i);return t!==-1&&e.splice(t,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof ib)){const n=new ib;_g(n,t),i[e]=n}}this._bursts=i}set subEmitterSystems(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof Eb)){const n=new Eb;_g(n,t),i[e]=n}}Cb&&i.length>0&&console.log("SubEmitters: ",i,this),this._subEmitterSystems=i}onAfterDeserialize(i){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(ka),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ve,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Nve,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Iye(this),this._particleSystem=new Mve(this._interface),this._particleSystem.addBehavior(new wye(this)),this._particleSystem.addBehavior(new Sye(this)),this._particleSystem.addBehavior(new bye(this)),this._particleSystem.addBehavior(new xye(this)),this._particleSystem.addBehavior(new Eye(this)),this._particleSystem.addBehavior(new Cye(this)),this._batchSystem.addSystem(this._particleSystem);const i=this._particleSystem.emitter;this.context.scene.add(i),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Cb&&(console.log(this),this.gameObject.add(new Mo(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof pe&&this._interface.renderMode==nt.Mesh&&pi.assignMeshLOD(this.renderer.particleMesh,0).then(i=>{i&&this.particleSystem&&this._interface.renderMode==nt.Mesh&&(this.particleSystem.instancingGeometry=i)})}onDestroy(){var i,e,t,n;(i=this._container)==null||i.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(t=this._particleSystem)==null||t.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var i;this.main&&(this._didPreWarm===!1&&((i=this.main)==null?void 0:i.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var i;if(!((i=this.emission)!=null&&i.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,t=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,s=Math.min(Math.max(t,n)/Math.max(.01,this.main.simulationSpeed),r),o=Math.ceil(s/e),a=Date.now();Cb&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${s} sec). Duration: ${t}, Lifetime: ${n}`);for(let l=0;l<o&&!(this.currentParticles>=this.maxParticles);l++){const c=Date.now()-a;if(c>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${c}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(i){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(i)}this._time+=i,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let i=0;i<this._batchSystem.batches.length;i++){const e=this._batchSystem.batches[i];e.layers.disableAll();const t=this.layer;e.layers.mask=1<<t}}onUpdate(){var i,e;const t=this.renderer.getMaterial(this.trails.enabled);if(t&&t.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=t.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const n=this.context.mainCamera;if(n){const o=zi(n);this._cameraScale=o.x}const r=!this.worldspace,s=this.gameObject;if(Ti(s,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),zi(this.gameObject,this._worldScale),r&&this._container&&(i=this.gameObject)!=null&&i.parent){const o=G9(this,nO);this._container.matrix.makeScale(o.x,o.y,o.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var i;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():rt()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const t=(i=e.particleSystem)==null?void 0:i._particleSystem;if(t){e.particleSystem._isUsedAsSubsystem=!0;const n=new $E(this,this._particleSystem,e.particleSystem,t);n.emitterType=e.type,n.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(n)}else Cb&&console.warn("Could not add SubParticleSystem",e,this)}}};let er=ZE;yn([_(nb)],er.prototype,"colorOverLifetime",2),yn([_(Jr)],er.prototype,"main",2),yn([_(cc)],er.prototype,"emission",2),yn([_(cd)],er.prototype,"sizeOverLifetime",2),yn([_(An)],er.prototype,"shape",2),yn([_(Mi)],er.prototype,"noise",2),yn([_(ln)],er.prototype,"trails",2),yn([_(vn)],er.prototype,"velocityOverLifetime",2),yn([_(Zn)],er.prototype,"limitVelocityOverLifetime",2),yn([_(hd)],er.prototype,"inheritVelocity",2),yn([_(gf)],er.prototype,"colorBySpeed",2),yn([_(Kr)],er.prototype,"textureSheetAnimation",2),yn([_(Ta)],er.prototype,"rotationOverLifetime",2),yn([_(Ho)],er.prototype,"rotationBySpeed",2),yn([_(eo)],er.prototype,"sizeBySpeed",2);class Eb{constructor(){u(this,"particleSystem"),u(this,"emitProbability",1),u(this,"properties"),u(this,"type")}_deserialize(e,t){const n=this.particleSystem;if(n instanceof er)return;let r="";n&&typeof n.guid=="string"&&(r=n.guid,this.particleSystem=te.findByGuid(r,t)),Cb&&!(this.particleSystem instanceof er)&&console.warn("Could not find particle system for sub emitter",r,t,this)}}function G9(i,e){if(e.set(1,1,1),i.gameObject.parent&&i.localspace)switch(i.main.scalingMode){case ik.Local:e=zi(i.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!i.unsupported_scaling_mode){i.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+ik[i.main.scalingMode]+" is not supported";rt()&&Pi(t),console.warn(t,i.name,i)}e=zi(i.gameObject,e);break}return e}new E(1,1,1),new E(0,0,1);class $E{constructor(e,t,n,r){u(this,"type","NeedleParticleSubEmitter"),u(this,"emitterType"),u(this,"emitterProbability"),u(this,"q_",new Ce),u(this,"v_",new E),u(this,"v2_",new E),u(this,"_emitterMatrix",new ge),u(this,"_circularBuffer"),this.system=e,this.particleSystem=t,this.subSystem=n,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const s=1e3;this._circularBuffer=new ra(()=>new ge,s)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===Zk.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===Zk.Death){let r=e.life;if(e[EA]!==void 0&&(r=e[EA]),!(e.age+t*1.2>=r))return;const s=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=s}const n=new ge;n.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(t,e.emissionState,n)}}var Tye=Object.defineProperty,Bye=Object.getOwnPropertyDescriptor,Rye=(i,e,t,n)=>{for(var r=n>1?void 0:n?Bye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Tye(e,t,r),r};class Sb extends ws{constructor(){super(...arguments),u(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new hG;return this.granularity.onValueChanged=t=>{e.granularity=t},e}}Rye([_(Bt)],Sb.prototype,"granularity",2),Ia("PixelationEffect",Sb);class QA extends Re{constructor(){super(...arguments),u(this,"_didAssignPlayerColor",!1),u(this,"tryAssignColor",()=>{const e=te.getComponentInParent(this.gameObject,Ma);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const t=te.getComponentInParent(this.gameObject,qr);return t!=null&&t.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(t.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Wt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Wt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield yH(.2),!this.tryAssignColor()););}assignUserColor(e){const t=QA.hashCode(e),n=QA.colorFromHashCode(t);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const s=r;s.material&&s.material.color&&this.assignColor(n,e,s)}}assignColor(e,t,n){let r=n.material;r&&(r._playerMaterial!==t&&(r=r.clone(),r._playerMaterial=t,n.material=r),r.color=e)}static hashCode(e){var t=0,n,r;if(e.length===0)return t;for(n=0;n<e.length;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t|=0;return t}static colorFromHashCode(e){const t=(e&16711680)>>16,n=(e&65280)>>8,r=e&255;return new _e(t/255,n/255,r/255)}}async function rO(i){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>uxe);e.observedAttributes.includes(i)||e.observedAttributes.push(i)}var Dye=Object.defineProperty,Pye=Object.getOwnPropertyDescriptor,Ib=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Dye(e,t,r),r};const Oa=ee("debugskybox");rO("skybox-image"),rO("environment-image");function H9(i,e,t,n,r){const s=new xc;s.allowDrop=!1,s.allowNetworking=!1,s.background=t,s.environment=n,te.addComponent(i.scene,s);const o=a=>{typeof a=="string"&&(Oa&&console.log(r,"CHANGED TO",a),s.setSkybox(a))};return RN(i.domElement,r,o),s.addEventListener("destroy",()=>{Oa&&console.log("Destroyed attribute remote skybox",r),DN(i.domElement,r,o)}),s.setSkybox(e)}hi.addContextCreatedCallback(i=>{var e;const t=i.context,n=t.domElement.getAttribute("skybox-image"),r=t.domElement.getAttribute("environment-image"),s=new Array;if(n){Oa&&console.log("Creating remote skybox to load "+n),((e=t.mainCameraComponent)==null?void 0:e.clearFlags)!==Zp.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=H9(t,n,!0,!1,"skybox-image");s.push(o)}if(r){Oa&&console.log("Creating remote environment to load "+r);const o=H9(t,r,!1,!0,"environment-image");s.push(o)}return s.length>0?Z_(s):Promise.resolve()});function V9(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function W9(i){const e=V9().find(t=>t.src===i);return e?(Oa&&console.log("Skybox: Found previously loaded texture for "+i),e.texture):null}async function kye(i){const e=await i;B2(e,!0),ji(e)}function Oye(i,e){const t=V9();for(;t.length>5;){const n=t.shift();n&&kye(n.texture)}e.then(n=>B2(n,!1)),t.push({src:i,texture:e})}class xc extends Re{constructor(){super(...arguments),u(this,"url"),u(this,"allowDrop",!0),u(this,"background",!0),u(this,"environment",!0),u(this,"allowNetworking",!0),u(this,"_loader"),u(this,"_prevUrl"),u(this,"_prevLoadedEnvironment"),u(this,"_prevEnvironment",null),u(this,"_prevBackground",null),u(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),u(this,"onDragOverEvent",e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)(t==="text/uri-list"||t==="Files")&&e.preventDefault()}),u(this,"onDrop",e=>{var t,n,r,s;if(this.allowDrop&&e.dataTransfer){for(const o of e.dataTransfer.types)if(Oa&&console.log(o),o==="text/uri-list"){const a=e.dataTransfer.getData(o);Oa&&console.log(o,a);let l=(n=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:n.name;if(l||(l=(s=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:s.name),Oa&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${c}`),e.preventDefault(),this.setSkybox(c);break}else if(this.isValidTextureType(a)){console.log("[Remote Skybox] Setting skybox from url: "+a),e.preventDefault(),this.setSkybox(a);break}else{console.warn(`[RemoteSkybox] Unknown url ${a}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const c=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:e,url:a,apply:h=>{e.preventDefault(),this.setSkybox(h)}}});this.dispatchEvent(c)}}else if(o=="Files"){const a=e.dataTransfer.files.item(0);if(Oa&&console.log(o,a),!a)continue;if(!this.isValidTextureType(a.name)){console.warn(`[RemoteSkybox]: File "${a.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(W9(a.name)===null){const l=new Blob([a]),c=URL.createObjectURL(l);e.preventDefault(),this.setSkybox(c,a.name)}else e.preventDefault(),this.setSkybox(a.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Ni.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(e,t){var n;if(!this.activeAndEnabled||(e=Lye(e),!e))return!1;if(t??(t=e),this.isValidTextureType(t)||console.warn("Potentially invalid skybox url",t,"on",this.name),Oa&&console.log("Set remote skybox url: "+e),this._prevUrl===e&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(n=this._prevLoadedEnvironment)==null||n.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=e;const r=await this.loadTexture(e,t);if(!r||!this.enabled)return!1;this.url=e;const s=e.lastIndexOf("/");return r.name=e.substring(s>=0?s+1:0),this._loader instanceof Dl&&(r.colorSpace=ht),this._prevLoadedEnvironment=r,this.applySkybox(),!0}async loadTexture(e,t){var n,r,s,o,a;if(!e)return Promise.resolve(null);t??(t=e);const l=W9(t);if(l){const p=await l;if(((r=(n=p.source)==null?void 0:n.data)==null?void 0:r.length)>0||(a=(o=(s=p.source)==null?void 0:s.data)==null?void 0:o.data)!=null&&a.length)return p}const c=t.endsWith(".exr"),h=t.endsWith(".hdr");c?this._loader instanceof ty||(this._loader=new ty):h?this._loader instanceof nC||(this._loader=new nC):this._loader instanceof Dl||(this._loader=new Dl),Oa&&console.log("Loading skybox: "+e);const d=this._loader.loadAsync(e);return Oye(t,d),await d}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Gf,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Oa&&console.log("Set remote skybox",this.url,!Ni.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Ni.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(e){return e.startsWith("http://")||e.startsWith("https://")}isValidTextureType(e){for(const t of this.validTextureTypes)if(e.endsWith(t))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Ib([vP(xc.prototype.urlChangedSyncField),_(URL)],xc.prototype,"url",2),Ib([_()],xc.prototype,"allowDrop",2),Ib([_()],xc.prototype,"background",2),Ib([_()],xc.prototype,"environment",2),Ib([_()],xc.prototype,"allowNetworking",2);function Lye(i){switch(i?.toLowerCase()){case"studio":i="https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";break;case"blurred-skybox":i="https://cdn.needle.tools/static/skybox/blurred-skybox.exr";break;case"quicklook-ar":i="https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";break;case"quicklook":i="https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr";break}return i===void 0?null:i}var Fye=Object.defineProperty,Uye=Object.getOwnPropertyDescriptor,Wo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Uye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Fye(e,t,r),r};const qo=ee("debugsceneswitcher"),eS="scene";rO(eS);const vd=Promise.resolve(!1);class Ts extends Re{constructor(){super(...arguments),u(this,"autoLoadFirstScene",!0),u(this,"scenes",[]),u(this,"loadingScene"),u(this,"queryParameterName","scene"),u(this,"useSceneName",!0),u(this,"clamp",!0),u(this,"useHistory",!0),u(this,"useKeyboard",!0),u(this,"useSwipe",!0),u(this,"useSceneLighting",!0),u(this,"preloadNext",1),u(this,"preloadPrevious",1),u(this,"preloadConcurrent",2),u(this,"_currentIndex",-1),u(this,"_currentScene"),u(this,"_engineElementOverserver"),u(this,"_preloadScheduler"),u(this,"onPopState",async e=>{if(!this.useHistory)return;const t=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=e?.state;if(r&&r.startsWith(this.guid)){const s=r.substr(this.guid.length+2);qo&&console.log("PopState",s),await this.trySelectSceneFromValue(s)}}}finally{this.useHistory=t}}),u(this,"normalizedSwipeThresholdX",.1),u(this,"_didSwipe",!1),u(this,"onInputPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const n=t.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),u(this,"onInputPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),u(this,"onInputKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const n=parseInt(t)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),u(this,"__lastSwitchScene"),u(this,"__lastSwitchScenePromise"),u(this,"_currentlyLoadingScene"),u(this,"_lastLoadingScene"),u(this,"_loadingScenePromise"),u(this,"_isCurrentlyLoading",!1),u(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),qo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(on.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(on.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(on.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===eS){const n=this.context.domElement.getAttribute(eS);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Nye(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(eS);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(on.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(on.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(on.PointerUp,this.onInputPointerUp),(e=this._preloadScheduler)==null||e.stop()}addScene(e){if(typeof e=="string"){let t=this.context.addressables.findAssetReference(e);return t||(t=new ti(e),this.context.addressables.registerAssetReference(t)),this.scenes.push(t),t}return this.scenes.push(e),e}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,n,r;if(qo&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(t=this.scenes)==null?void 0:t.find(a=>a.uri===e);if(!o){const a=ti.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(a)}if(o)e=(n=this.scenes)==null?void 0:n.indexOf(o);else return vd}if(!((r=this.scenes)!=null&&r.length))return vd;if(e<0){if(this.clamp)return vd;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return vd;e=0}const s=this.scenes[e];return this.switchScene(s)}async switchScene(e){if(!(e instanceof ti)){const t=typeof e;return t==="string"?this.select(e):t==="number"?this.select(e):(console.warn("SceneSwitcher: Can't switch to scene",e,"of type",t),!1)}return e.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===e&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=e,this.__lastSwitchScenePromise=this.__internalSwitchScene(e),await this.__lastSwitchScenePromise)}async __internalSwitchScene(e){var t,n;if(this._currentScene){qo&&console.log("UNLOAD",e.uri);const s=this.tryGetSceneEventListener(this._currentScene.asset);if(s!=null&&s.sceneClosing){const o=s.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;try{this._currentlyLoadingScene=e,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const s=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(s),await this.onStartLoading(),await e.loadAssetAsync((a,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return qo&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return qo&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if(qo&&console.log("ADD",e.uri),this._currentScene=e,te.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0){let c=r.toString();if(this.useSceneName&&(c=q9(e.uri)),(n=this.queryParameterName)!=null&&n.length)q_(this.queryParameterName,c,this.useHistory);else{const h=history.state,d=this.guid+"::"+r;h!==d&&history.pushState(d,"unused",location.href)}}const a=this.tryGetSceneEventListener(e.asset);if(a!=null&&a.sceneOpened){const c=a.sceneOpened(this);c instanceof Promise&&await c}const l=new CustomEvent("scene-opened",{detail:{scene:e,switcher:this,index:r}});return this.dispatchEvent(l),!0}}catch(s){console.error(s)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof ti)return t.preload()}return vd}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return vd;const t=ee(this.queryParameterName);return typeof t=="boolean"?vd:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);{const n=e.toLowerCase();for(let r=0;r<this.scenes.length;r++){const s=this.scenes[r];if(s&&q9(s.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return zs()&&console.warn('Can not find scene: "'+e+'"',this),vd}async onStartLoading(){var e,t;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(e=this.loadingScene)==null?void 0:e.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(t=this.loadingScene)!=null&&t.asset)){qo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;te.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const s=r.sceneOpened(this);s instanceof Promise&&await s}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var e;if(this._isCurrentlyLoading=!1,(e=this.loadingScene)!=null&&e.asset){qo&&console.log("Remove loading scene",this.loadingScene.uri);const t=this.loadingScene.asset,n=this.tryGetSceneEventListener(t);if(typeof n?.sceneClosing=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}te.remove(t)}if(!this._isCurrentlyLoading){const t=this.tryGetSceneEventListener(this.gameObject);if(t&&t.sceneClosing){const n=t.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(e,t=0){const n=te.foreachComponent(e,r=>r.sceneClosing?r:void 0);if(t===0&&!n&&e.children.length)for(const r of e.children){const s=this.tryGetSceneEventListener(r,t+1);if(s)return s}return n||null}}Wo([_()],Ts.prototype,"autoLoadFirstScene",2),Wo([_(ti)],Ts.prototype,"scenes",2),Wo([_(ti)],Ts.prototype,"loadingScene",2),Wo([_()],Ts.prototype,"queryParameterName",2),Wo([_()],Ts.prototype,"useSceneName",2),Wo([_()],Ts.prototype,"clamp",2),Wo([_()],Ts.prototype,"useHistory",2),Wo([_()],Ts.prototype,"useKeyboard",2),Wo([_()],Ts.prototype,"useSwipe",2),Wo([_()],Ts.prototype,"useSceneLighting",2),Wo([_()],Ts.prototype,"preloadNext",2),Wo([_()],Ts.prototype,"preloadPrevious",2),Wo([_()],Ts.prototype,"preloadConcurrent",2);function q9(i){const e=i.split("/").pop(),t=e?.split(".").shift();return t!=null&&t.length?t:i}class Nye{constructor(e,t=1,n=1,r=2){u(this,"maxLoadAhead"),u(this,"maxLoadBehind"),u(this,"maxConcurrent"),u(this,"_isRunning",!1),u(this,"_switcher"),u(this,"_loadTasks",[]),u(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=n,this.maxConcurrent=r}begin(){if(this._isRunning)return;qo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,n;const r=this._switcher.scenes,s=setInterval(()=>{if(this.allLoaded()&&(qo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(s);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,n=0,t=0);const o=n%2===0;o&&(t+=1),n+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new Qye(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1}return!0}}class Qye{constructor(e,t,n){u(this,"index"),u(this,"asset"),u(this,"tasks"),this.index=e,this.asset=t,this.tasks=n,n.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(qo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),qo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function zye(){return new Promise((i,e)=>{const t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function jye(i){await zye(),i()}var Gye=Object.defineProperty,Hye=Object.getOwnPropertyDescriptor,Xo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Gye(e,t,r),r};const Rr=ee("debugvideo");var X9=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(X9||{}),Y9=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(Y9||{}),J9=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(J9||{});class hr extends Re{constructor(){super(),u(this,"playOnAwake",!0),u(this,"aspectMode",0),u(this,"clip",null),u(this,"source",1),u(this,"_url",null),u(this,"renderMode"),u(this,"targetMaterialProperty"),u(this,"targetMaterialRenderer"),u(this,"targetTexture"),u(this,"time",0),u(this,"_playbackSpeed",1),u(this,"_isLooping",!1),u(this,"_muted",!1),u(this,"_audioOutputMode",2),u(this,"playInBackground",!0),u(this,"_crossOrigin","anonymous"),u(this,"_videoElement",null),u(this,"_videoTexture",null),u(this,"_videoMaterial",null),u(this,"_isPlaying",!1),u(this,"wasPlaying",!1),u(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),u(this,"_receivedInput",!1),u(this,"_overlay",null),u(this,"_targetObjects"),u(this,"_updateAspectRoutineId",-1),u(this,"_hls"),u(this,"onHlsAvailable",()=>{var e;Rr&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(e=this._videoElement)==null||e.play(),Rr&&console.log("HLS: loaded",this.clip))}),jye(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ee("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(e){const t=this._url!==e;this.__didAwake?t&&this.setClipURL(e??""):this._url=e}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}get currentVideo(){return this.clip}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&rt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Rr&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(e){this._url!==e&&(this._url=e,this.source=1,Rr&&console.log("set url",e),this._videoElement?e.endsWith(".m3u8")||e.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var e,t;Rr&&console.log("VideoPlayer.onEnable",Y9[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){var e;window.removeEventListener("visibilitychange",this.visibilityChanged),(e=this._overlay)==null||e.stop(),this.pause()}onDestroy(){var e;this._videoElement&&((e=this.videoElement)==null||e.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;if(this._videoElement||this.create(!1),!this._videoElement){Rr&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Rr&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),Rr&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Rr&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Rr&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),Rr&&console.log("PAUSE",this,this.currentTime)}create(e){let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url,!(t!=null&&t.length)&&typeof this.clip=="string"&&(t=this.clip);break}return t?(this._videoElement||(Rr&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(Rr&&console.log("Set Video src",t),this._videoElement.src=t):(Rr&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new mU(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=ht,e&&this.handleBeginPlaying(e),Rr&&console.log("Video: handle playing done...",t,e),!0):(Rr&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new Vye(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),Rr&&console.log("created video element",e),e}handleBeginPlaying(e){var t,n;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(n=te.getComponent(this.gameObject,Mn))==null?void 0:n.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,J9[this.renderMode],this);return}const s=r.material;if(s){this._targetObjects.push(r),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),r.material=this._videoMaterial);const o="map",a=this._videoMaterial;if(!this.targetMaterialProperty)a[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:a[o]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,n=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const s of n.getVideoTracks()){const o=s.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let s=0;s<10;s++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const s of this._targetObjects){let o=1;if(s.parent){const a=zi(s.parent);o=a.x/a.y}switch(this.aspectMode){case 1:s.scale.y=1/r*s.scale.x*o;break;case 2:s.scale.x=r*s.scale.y*o;break}}for(let s=0;s<3;s++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let e=document.head.querySelector("script[data-hls_library]");e?globalThis.Hls?this.onHlsAvailable():e.addEventListener("load",this.onHlsAvailable):(Rr&&console.log("HLS: load script"),e=document.createElement("script"),e.dataset.hls_library="hls.js",e.src="https://cdn.jsdelivr.net/npm/hls.js@1",e.addEventListener("load",this.onHlsAvailable),document.head.append(e))}}Xo([_()],hr.prototype,"playOnAwake",2),Xo([_()],hr.prototype,"aspectMode",2),Xo([_(URL)],hr.prototype,"clip",2),Xo([_()],hr.prototype,"source",2),Xo([_(URL)],hr.prototype,"url",1),Xo([_()],hr.prototype,"renderMode",2),Xo([_()],hr.prototype,"targetMaterialProperty",2),Xo([_(Mn)],hr.prototype,"targetMaterialRenderer",2),Xo([_(Ut)],hr.prototype,"targetTexture",2),Xo([_()],hr.prototype,"time",2),Xo([_()],hr.prototype,"playbackSpeed",1),Xo([_()],hr.prototype,"isLooping",1),Xo([_()],hr.prototype,"audioOutputMode",1);class Vye{constructor(e){u(this,"context"),u(this,"_videos",[]),u(this,"_screenspaceModeQuad"),u(this,"_isInScreenspaceMode",!1),u(this,"_input"),this.context=e,this._input=new Wye(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=ey.createPrimitive(Gp.Quad,{material:new qye(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const n=this._screenspaceModeQuad;this.context.scene.add(n),this.updateScreenspaceMaterialUniforms();const r=n.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Wye{constructor(e){u(this,"_onResizeScreenFn"),u(this,"_onKeyUpFn"),u(this,"_onMouseWheelFn"),u(this,"context"),u(this,"overlay"),u(this,"_material"),u(this,"_isPinching",!1),u(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new K;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const s=new K(r.movementX,r.movementY);s.x/=this.context.domElement.clientWidth,s.y/=this.context.domElement.clientHeight,t.set(s.x,s.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let n=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-n<.3&&this.overlay.stop(),n=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const s=r.touches[0],o=r.touches[1],a=s.clientX-o.clientX,l=s.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const h=c-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class qye extends Mt{constructor(e){super(),u(this,"_offset",new K),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new qe(0,0,1,1)}},this.vertexShader=`
7346
+ }`);new E(0,0,1);var Fve=function(i){_A(t,i);var e=wA(t);function t(n){var r;return wt(this,t),r=e.call(this,n),Z(ii(r),"positionBuffer",void 0),Z(ii(r),"previousBuffer",void 0),Z(ii(r),"nextBuffer",void 0),Z(ii(r),"uvBuffer",void 0),Z(ii(r),"sideBuffer",void 0),Z(ii(r),"widthBuffer",void 0),Z(ii(r),"colorBuffer",void 0),Z(ii(r),"indexBuffer",void 0),Z(ii(r),"vector_",new E),Z(ii(r),"vector2_",new E),Z(ii(r),"vector3_",new E),Z(ii(r),"quaternion_",new Ce),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return Ct(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new gt,this.indexBuffer=new et(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(ls),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new et(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(ls),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new et(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(ls),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new et(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(ls),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new et(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(ls),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new et(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(ls),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new et(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(ls),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new et(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(ls),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new K(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new K(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=qk(this.settings.material.map.channel),n.map=new we(this.settings.material.map),n.mapTransform=new we(new Lt().copy(this.settings.material.map.matrix))),this.settings.renderMode===nt.Trail)this.material=new Mt({uniforms:n,defines:r,vertexShader:Lve,fragmentShader:Ove,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Td});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,s=0,o=0;this.systems.forEach(function(a){for(var l=0;l<a.particleNum;l++)o+=a.particles[l].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(a){var l=n.quaternion_,c=n.vector2_,h=n.vector3_;a.emitter.matrixWorld.decompose(c,l,h);for(var d=a.particles,p=a.particleNum,f=n.settings.uTileCount,m=n.settings.vTileCount,A=1/f,v=1/m,g=0;g<p;g++){var y=d[g],b=y.uvTile%m,x=Math.floor(y.uvTile/m),w=y.previous.values(),I=w.next(),M=I.value,T=M;I.done||(I=w.next());var D=void 0;I.value!==void 0?D=I.value:D=T;for(var S=0;S<y.previous.length;S++,r+=2){if(n.positionBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.positionBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z),a.worldSpace?(n.positionBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.positionBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z)):(y.parentMatrix?n.vector_.copy(T.position).applyMatrix4(y.parentMatrix):n.vector_.copy(T.position).applyMatrix4(a.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.previousBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.previousBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(y.parentMatrix?n.vector_.copy(M.position).applyMatrix4(y.parentMatrix):n.vector_.copy(M.position).applyMatrix4(a.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.nextBuffer.setXYZ(r,D.position.x,D.position.y,D.position.z),n.nextBuffer.setXYZ(r+1,D.position.x,D.position.y,D.position.z)):(y.parentMatrix?n.vector_.copy(D.position).applyMatrix4(y.parentMatrix):n.vector_.copy(D.position).applyMatrix4(a.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),a.worldSpace)n.widthBuffer.setX(r,T.size),n.widthBuffer.setX(r+1,T.size);else if(y.parentMatrix)n.widthBuffer.setX(r,T.size),n.widthBuffer.setX(r+1,T.size);else{var B=(Math.abs(h.x)+Math.abs(h.y)+Math.abs(h.z))/3;n.widthBuffer.setX(r,T.size*B),n.widthBuffer.setX(r+1,T.size*B)}n.uvBuffer.setXY(r,(S/y.previous.length+b)*A,(m-x-1)*v),n.uvBuffer.setXY(r+1,(S/y.previous.length+b)*A,(m-x)*v),n.colorBuffer.setXYZW(r,T.color.x,T.color.y,T.color.z,T.color.w),n.colorBuffer.setXYZW(r+1,T.color.x,T.color.y,T.color.z,T.color.w),S+1<y.previous.length&&(n.indexBuffer.setX(s*3,r),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+2),s++,n.indexBuffer.setX(s*3,r+2),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+3),s++),M=T,T=D,I.done||(I=w.next(),I.value!==void 0&&(D=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=s*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,s*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(D9),Uve=function(i){_A(t,i);var e=wA(t);function t(){var n;return wt(this,t),n=e.call(this),Z(ii(n),"batches",[]),Z(ii(n),"systemToBatchIndex",new Map),Z(ii(n),"type","BatchedRenderer"),n}return Ct(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),s=0;s<this.batches.length;s++)if(t.equals(this.batches[s].settings,r)){this.batches[s].addSystem(n),this.systemToBatchIndex.set(n,s);return}var o;switch(r.renderMode){case nt.Trail:o=new Fve(r);break;case nt.Mesh:case nt.BillBoard:case nt.VerticalBillBoard:case nt.HorizontalBillBoard:case nt.StretchedBillBoard:o=new kve(r);break}o.addSystem(n),this.batches.push(o),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(s,o){o.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ve),Nve=Uve,k9=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new E;wt(this,i),Z(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=n}return Ct(i,[{key:"transform",value:function(e,t){e.x=this.locations[t%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[t%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new i(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(t){return t.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,t){var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");if(r){r.drawImage(e,0,0);var s=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var o=0;o<s.height;o++)for(var a=0;a<s.width;a++)s.data[(o*s.width+a)*4+3]>t&&this.locations.push(new K(a,s.height-o))}}}],[{key:"fromJSON",value:function(e){var t=new i(e.scaleX,e.scaleY,new E(e.position[0],e.position[1],e.position[2]));return t.locations=e.locations.map(function(n){return new K(n.x,n.y)}),t}}]),i}();function Qve(i){switch(i.type){case"TextureSequencer":return k9.fromJSON(i);default:return new k9}}var zve=function(){function i(e){wt(this,i),Z(this,"type","ApplySequences"),Z(this,"sequencers",[]),Z(this,"time",0),Z(this,"index",0),Z(this,"pCount",0),Z(this,"delay",void 0),Z(this,"tempV",new E),this.delay=e}return Ct(i,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new E,e.begin=new E,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,t){var n=this.sequencers[this.index],r=e.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),n[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,i.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,t){this.sequencers.push([e,t])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var t=CA(e,2),n=t[0],r=t[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new i(this.delay);return e.sequencers=this.sequencers.map(function(t){return[t[0].clone(),t[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var t=new i(e.delay);return e.sequencers.forEach(function(n){t.sequencers.push([Hi(n.range),Qve(n.sequencer)])}),t}}]),i}();Z(zve,"BEZIER",new Nk(0,0,1,1));var he=function(i){return i[i.Number=0]="Number",i[i.Vec2=1]="Vec2",i[i.Vec3=2]="Vec3",i[i.Vec4=3]="Vec4",i[i.Boolean=4]="Boolean",i[i.AnyType=5]="AnyType",i}({}),O9=Ct(function i(e,t,n,r){wt(this,i),Z(this,"input",void 0),Z(this,"inputIndex",void 0),Z(this,"output",void 0),Z(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=n,this.outputIndex=r,this.output.inputs[r]=this}),jve=function(){function i(){wt(this,i),Z(this,"visited",new Set),Z(this,"graph_",void 0),Z(this,"context_",void 0),i.Instance=this}return Ct(i,[{key:"traverse",value:function(e){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(e.id);for(var t=[],n=0;n<e.inputs.length;n++)if(e.inputs[n]instanceof O9){var r=e.inputs[n].input;this.visited.has(r.id)||this.traverse(r),t.push(r.outputValues[e.inputs[n].inputIndex])}else t.push(e.inputs[n].getValue(this.context_));e.func(this.context_,t,e.outputValues),this.graph_.nodesInOrder.push(e)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var e=this.graph_.nodesInOrder,t=0;t<e.length;t++){for(var n=[],r=e[t],s=0;s<r.inputs.length;s++)if(r.inputs[s]instanceof O9)n.push(r.inputs[s].input.outputValues[r.inputs[s].inputIndex]);else if(r.inputs[s]!==void 0)n.push(r.inputs[s].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(e,t){if(this.graph_=e,this.context_=t,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<e.outputNodes.length;n++){var r=e.outputNodes[n];this.traverse(r)}e.compiled=!0}}}]),i}();Z(jve,"Instance",void 0);var ui=function(){function i(e){wt(this,i),Z(this,"name",void 0),Z(this,"nodeTypeSignatures",[]),this.name=e}return Ct(i,[{key:"addSignature",value:function(e,t,n){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:t,func:n})}}]),i}(),HE=new ui("add");HE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]+t[1]}),HE.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),HE.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),HE.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].addVectors(t[0],t[1])});var VE=new ui("sub");VE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]-t[1]}),VE.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),VE.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),VE.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].subVectors(t[0],t[1])});var WE=new ui("mul");WE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]*t[1]}),WE.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),WE.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),WE.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])});var qE=new ui("div");qE.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]/t[1]}),qE.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),qE.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),qE.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])});var Gve=new ui("sin");Gve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.sin(t[0])});var Hve=new ui("cos");Hve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.cos(t[0])});var Vve=new ui("tan");Vve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.tan(t[0])});var Wve=new ui("abs");Wve.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.abs(t[0])});var qve=new ui("min");qve.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.min(t[0],t[1])});var Xve=new ui("max");Xve.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.max(t[0],t[1])});var Xk=new ui("dot");Xk.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),Xk.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),Xk.addSignature([he.Vec4,he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])});var Yve=new ui("cross");Yve.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].crossVectors(t[0],t[1])});var Yk=new ui("length");Yk.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),Yk.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),Yk.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].length()});var Jk=new ui("lengthSq");Jk.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),Jk.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),Jk.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()});var Kk=new ui("normalize");Kk.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).normalize()}),Kk.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).normalize()}),Kk.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).normalize()});var L9=new ui("distance");L9.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])}),L9.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])});var Jve=new ui("and");Jve.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]&&t[1]});var Kve=new ui("or");Kve.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]||t[1]});var Zve=new ui("not");Zve.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=!t[0]});var XE=new ui("equal");XE.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]===t[1]}),XE.addSignature([he.Vec2,he.Vec2],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),XE.addSignature([he.Vec3,he.Vec3],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),XE.addSignature([he.Vec4,he.Vec4],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])});var $ve=new ui("lessThan");$ve.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<t[1]});var eye=new ui("greaterThan");eye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>t[1]});var tye=new ui("lessThanOrEqual");tye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<=t[1]});var iye=new ui("greaterThanOrEqual");iye.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>=t[1]});var nye=new ui("if");nye.addSignature([he.Boolean,he.AnyType,he.AnyType],[he.AnyType],function(i,e,t,n){n[0]=t[0]?t[1]:t[2]});var rye=new ui("number");rye.addSignature([],[he.Number],function(i,e,t,n){n[0]=e.value});var sye=new ui("vec2");sye.addSignature([],[he.Vec2],function(i,e,t,n){n[0]=e.value});var oye=new ui("vec3");oye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=e.value});var aye=new ui("vec4");aye.addSignature([],[he.Vec4],function(i,e,t,n){n[0]=e.value});var lye=new ui("bool");lye.addSignature([],[he.Boolean],function(i,e,t,n){n[0]=e.value});var cye=new ui("particlePosition");cye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var hye=new ui("particleVelocity");hye.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var uye=new ui("particleRotation");uye.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var dye=new ui("particleAge");dye.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var wb=new ui("output");wb.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0]=t[0]}),wb.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var pye=Object.defineProperty,fye=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?fye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&pye(e,t,r),r};const Cb=ee("debugparticles"),mye=ee("noprogressive"),gye=ee("debugprogressive");var Zk=(i=>(i[i.Birth=0]="Birth",i[i.Collision=1]="Collision",i[i.Death=2]="Death",i[i.Trigger=3]="Trigger",i[i.Manual=4]="Manual",i))(Zk||{});class ka extends Re{constructor(){super(...arguments),u(this,"renderMode"),u(this,"particleMaterial"),u(this,"trailMaterial"),u(this,"particleMesh"),u(this,"maxParticleSize"),u(this,"minParticleSize"),u(this,"velocityScale"),u(this,"cameraVelocityScale"),u(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&rt()){const e=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let t=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return t&&e&&t.side===rr&&(t=t.clone(),t.side=un,e?this.trailMaterial=t:this.particleMaterial=t),t&&!mye&&t._didRequestTextureLOD===void 0&&(t._didRequestTextureLOD=0,gye&&console.log("Load material LOD",t.name),pi.assignTextureLOD(t,0)),t}getMesh(e){let t=null;if(!t&&(this.particleMesh instanceof pe&&(t=this.particleMesh.geometry),t===null)){t=new ir(1,1);const n=t.attributes.uv;for(let r=0;r<n.count;r++)n.setX(r,1-n.getX(r))}return new pe(t,this.getMaterial())}}yn([_()],ka.prototype,"renderMode",2),yn([_(Rt)],ka.prototype,"particleMaterial",2),yn([_(Rt)],ka.prototype,"trailMaterial",2),yn([_()],ka.prototype,"maxParticleSize",2),yn([_()],ka.prototype,"minParticleSize",2),yn([_()],ka.prototype,"velocityScale",2),yn([_()],ka.prototype,"cameraVelocityScale",2),yn([_()],ka.prototype,"lengthScale",2);class YE{constructor(e,t=1){u(this,"_curve"),u(this,"_factor"),u(this,"type","function"),this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class $k{constructor(e){u(this,"type","value"),u(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Aye extends $k{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class vye extends $k{constructor(){super(...arguments),u(this,"_lastPosition",new E),u(this,"_lastDistance",0)}update(){const e=Tt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let s=this._lastDistance/this.system.deltaTime*r;Number.isFinite(s)||(s=0),e+=s}const t=this.system.emission.getBurst();t>0&&(e+=t/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return $e.clamp(e,0,n/this.system.deltaTime)}}class yye extends $k{genValue(){return this.system.isPlaying,0}}class Ad{constructor(e){u(this,"system"),u(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class bye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleTextureSheet")}update(e,t){const n=this.system.textureSheetAnimation;if(n.enabled){const r=e.age/e.life,s=n.evaluate(r);s!==void 0&&(e.uvTile=s)}}}const F9=Symbol("particleRotation");class xye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleRotation")}initialize(e){e[F9]=Math.random()}update(e,t){if(e.rotation===void 0)return;const n=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(n,e[F9])*t:this.system.renderer.renderMode===Bh.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(n,r)*t}}}const U9=Symbol("sizeLerpFactor"),_ye=new E;class wye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleSize"),u(this,"_minSize",0),u(this,"_maxSize",1)}initialize(e){e[U9]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,t){const n=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,e[U9]).x);let s=1;if(this.system.renderer.renderMode!==Bh.Mesh&&(s=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*s,this.system.localspace){const o=G9(this.system,_ye);e.size*=o.x}}}const EA=Symbol("particleLife"),eO=Symbol("trailLifetime"),N9=Symbol("trailStartLength"),tO=Symbol("trailWidthRandom");class Cye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleTrail")}initialize(e){e instanceof vb&&(e[EA]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[eO]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[eO]),e[N9]=e.length,e[tO]=Math.random())}update(e){var t;if((t=this.system.trails)!=null&&t.enabled&&e instanceof vb){const n=e,r=e.age/e[EA],s=e.previous.values(),o=e.previous.length;for(let a=0;a<o;a++){const l=s.next().value,c=1-a/(o-1);let h=e.size;h<=0&&!this.system.trails.sizeAffectsWidth&&(h=20*this.system.trails.widthOverTrail.evaluate(.5,n[tO])),l.size=this.system.trails.getWidth(h,r,c,n[tO]),l.color.copy(e.color),this.system.trails.getColor(l.color,r,c)}if(e.age>e[EA]){e.velocity.set(0,0,0);const a=(e.age-e[EA])/e[eO];n.length=$e.lerp(e[N9],0,a)}}}}const JE=Symbol("startVelocity"),Q9=Symbol("gravityModifier"),iO=Symbol("gravitySpeed"),KE=Symbol("velocity lerp factor"),nO=new E;class Eye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleVelocity"),u(this,"_gravityDirection",new E)}initialize(e){var t,n;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(t=this.system.inheritVelocity)!=null&&t.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[JE]?e[JE].copy(e.velocity):e[JE]=e.velocity.clone();const s=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[Q9]=s*r,e[iO]=s*r*.5,e[KE]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===tb.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,t){var n;const r=e[JE],s=e[Q9];if(s!==0){const p=s*e[iO];nO.copy(this._gravityDirection).multiplyScalar(p),e[iO]+=t*.05,r.add(nO)}e.velocity.copy(r);const o=e.age/e.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,o,e[KE]);const a=this.system.noise;a.enabled&&a.apply(0,e.position,e.velocity,t,e.age,e.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(e.size=l.evaluate(e.velocity,o,e[KE],e.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(e.velocity,e[KE],e.color);const h=this.system.velocityOverLifetime;h.enabled&&h.apply(e,0,e.position,e.velocity,t,e.age,e.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(e.position,r,e.velocity,e.size,o,t,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const z9=Symbol("colorLerpFactor"),j9=new wi(1,1,1,1),Tf=new wi(1,1,1,1);class Sye extends Ad{constructor(){super(...arguments),u(this,"type","NeedleColor")}initialize(e){}_init(e){const t=this.system.renderer.particleMaterial;Tf.copy(this.system.main.startColor.evaluate(Math.random())),t!=null&&t.color&&(j9.copy(t.color),Tf.multiply(j9)),Tf.convertLinearToSRGB(),e.startColor.set(Tf.r,Tf.g,Tf.b,Tf.alpha),e.color.copy(e.startColor),e[z9]=Math.random()}update(e,t){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const n=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(n,e[z9]);e.color.set(r.r,r.g,r.b,r.alpha).multiply(e.startColor)}else e.color.copy(e.startColor)}}class Iye{constructor(e){u(this,"system"),u(this,"emission"),u(this,"autoDestroy"),u(this,"startLength"),u(this,"emissionBursts"),u(this,"onlyUsedByOther"),u(this,"behaviors",[]),u(this,"rendererEmitterSettings",{startLength:new Ms(220),followLocalOrigin:!1}),u(this,"flatWhiteTexture"),u(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new vye(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new YE(this.system.main.startLifetime)}get startSpeed(){return new YE(this.system.main.startSpeed)}get startRotation(){return new YE(this.system.main.startRotation)}get startSize(){return new YE(this.system.main.startSize)}get startColor(){return new GE(new qe(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new yye(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return nt.Trail;switch(this.system.renderer.renderMode){case Bh.Billboard:return nt.BillBoard;case Bh.Stretch:return nt.StretchedBillBoard;case Bh.HorizontalBillboard:return nt.HorizontalBillBoard;case Bh.VerticalBillboard:return nt.VerticalBillBoard;case Bh.Mesh:return nt.Mesh}return nt.BillBoard}get speedFactor(){var e;let t=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===Bh.Stretch&&(t*=this.system.renderer.velocityScale??1),t}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const n=t.clone();n.premultiplyAlpha=!1,n.colorSpace=bi,this.clonedTexture.original=t,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=UD(new wi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Aye(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??zh}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===tb.World}}class Mye{constructor(){u(this,"burstIndex",0),u(this,"burstWaveIndex",0),u(this,"time",0),u(this,"waitEmiting",0)}}const ZE=class extends Re{constructor(){super(...arguments),u(this,"_state"),u(this,"colorOverLifetime"),u(this,"main"),u(this,"emission"),u(this,"sizeOverLifetime"),u(this,"shape"),u(this,"noise"),u(this,"trails"),u(this,"velocityOverLifetime"),u(this,"limitVelocityOverLifetime"),u(this,"inheritVelocity"),u(this,"colorBySpeed"),u(this,"textureSheetAnimation"),u(this,"rotationOverLifetime"),u(this,"rotationBySpeed"),u(this,"sizeBySpeed"),u(this,"_cameraScale",1),u(this,"__worldQuaternion",new Ce),u(this,"_worldQuaternionInverted",new Ce),u(this,"_worldScale",new E),u(this,"_worldPositionFrame",-1),u(this,"_worldPos",new E),u(this,"_renderer"),u(this,"_batchSystem"),u(this,"_particleSystem"),u(this,"_interface"),u(this,"_container"),u(this,"_time",0),u(this,"_isPlaying",!0),u(this,"_isUsedAsSubsystem",!1),u(this,"_didPreWarm",!1),u(this,"_bursts"),u(this,"_subEmitterSystems"),u(this,"_lastBatchesCount",-1),u(this,"lastMaterialVersion",-1)}play(i=!1){var e;i&&te.foreachComponent(this.gameObject,t=>{t instanceof ZE&&t!==this&&t.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(i=!0){i&&te.foreachComponent(this.gameObject,e=>{e instanceof ZE&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(i=!0,e=!1){i&&te.foreachComponent(this.gameObject,t=>{t instanceof ZE&&t!==this&&t.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var i;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(i=this.emission)==null||i.reset())}emit(i){if(this._particleSystem){this.onUpdate(),i=Math.min(i,this.maxParticles-this.currentParticles),this._state||(this._state=new Mye),this._state.waitEmiting=i,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(i){this.main.playOnAwake=i}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var i;return((i=this._particleSystem)==null?void 0:i.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===tb.World}get localspace(){return this.main.simulationSpace===tb.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Tt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(i){return this._particleSystem?(i instanceof Ad&&(i.system=this),rt()&&console.log("add behaviour",i),this._particleSystem.addBehavior(i),!0):!1}removeBehaviour(i){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,t=e.indexOf(i);return t!==-1&&e.splice(t,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof ib)){const n=new ib;_g(n,t),i[e]=n}}this._bursts=i}set subEmitterSystems(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof Eb)){const n=new Eb;_g(n,t),i[e]=n}}Cb&&i.length>0&&console.log("SubEmitters: ",i,this),this._subEmitterSystems=i}onAfterDeserialize(i){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(ka),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ve,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Nve,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Iye(this),this._particleSystem=new Mve(this._interface),this._particleSystem.addBehavior(new wye(this)),this._particleSystem.addBehavior(new Sye(this)),this._particleSystem.addBehavior(new bye(this)),this._particleSystem.addBehavior(new xye(this)),this._particleSystem.addBehavior(new Eye(this)),this._particleSystem.addBehavior(new Cye(this)),this._batchSystem.addSystem(this._particleSystem);const i=this._particleSystem.emitter;this.context.scene.add(i),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),Cb&&(console.log(this),this.gameObject.add(new Mo(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof pe&&this._interface.renderMode==nt.Mesh&&pi.assignMeshLOD(this.renderer.particleMesh,0).then(i=>{i&&this.particleSystem&&this._interface.renderMode==nt.Mesh&&(this.particleSystem.instancingGeometry=i)})}onDestroy(){var i,e,t,n;(i=this._container)==null||i.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(t=this._particleSystem)==null||t.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var i;this.main&&(this._didPreWarm===!1&&((i=this.main)==null?void 0:i.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var i;if(!((i=this.emission)!=null&&i.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,t=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,s=Math.min(Math.max(t,n)/Math.max(.01,this.main.simulationSpeed),r),o=Math.ceil(s/e),a=Date.now();Cb&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${s} sec). Duration: ${t}, Lifetime: ${n}`);for(let l=0;l<o&&!(this.currentParticles>=this.maxParticles);l++){const c=Date.now()-a;if(c>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${c}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(i){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(i)}this._time+=i,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let i=0;i<this._batchSystem.batches.length;i++){const e=this._batchSystem.batches[i];e.layers.disableAll();const t=this.layer;e.layers.mask=1<<t}}onUpdate(){var i,e;const t=this.renderer.getMaterial(this.trails.enabled);if(t&&t.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=t.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const n=this.context.mainCamera;if(n){const o=zi(n);this._cameraScale=o.x}const r=!this.worldspace,s=this.gameObject;if(Ti(s,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),zi(this.gameObject,this._worldScale),r&&this._container&&(i=this.gameObject)!=null&&i.parent){const o=G9(this,nO);this._container.matrix.makeScale(o.x,o.y,o.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var i;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():rt()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const t=(i=e.particleSystem)==null?void 0:i._particleSystem;if(t){e.particleSystem._isUsedAsSubsystem=!0;const n=new $E(this,this._particleSystem,e.particleSystem,t);n.emitterType=e.type,n.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(n)}else Cb&&console.warn("Could not add SubParticleSystem",e,this)}}};let er=ZE;yn([_(nb)],er.prototype,"colorOverLifetime",2),yn([_(Jr)],er.prototype,"main",2),yn([_(cc)],er.prototype,"emission",2),yn([_(cd)],er.prototype,"sizeOverLifetime",2),yn([_(An)],er.prototype,"shape",2),yn([_(Mi)],er.prototype,"noise",2),yn([_(ln)],er.prototype,"trails",2),yn([_(vn)],er.prototype,"velocityOverLifetime",2),yn([_(Zn)],er.prototype,"limitVelocityOverLifetime",2),yn([_(hd)],er.prototype,"inheritVelocity",2),yn([_(gf)],er.prototype,"colorBySpeed",2),yn([_(Kr)],er.prototype,"textureSheetAnimation",2),yn([_(Ta)],er.prototype,"rotationOverLifetime",2),yn([_(Ho)],er.prototype,"rotationBySpeed",2),yn([_(eo)],er.prototype,"sizeBySpeed",2);class Eb{constructor(){u(this,"particleSystem"),u(this,"emitProbability",1),u(this,"properties"),u(this,"type")}_deserialize(e,t){const n=this.particleSystem;if(n instanceof er)return;let r="";n&&typeof n.guid=="string"&&(r=n.guid,this.particleSystem=te.findByGuid(r,t)),Cb&&!(this.particleSystem instanceof er)&&console.warn("Could not find particle system for sub emitter",r,t,this)}}function G9(i,e){if(e.set(1,1,1),i.gameObject.parent&&i.localspace)switch(i.main.scalingMode){case ik.Local:e=zi(i.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!i.unsupported_scaling_mode){i.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+ik[i.main.scalingMode]+" is not supported";rt()&&Pi(t),console.warn(t,i.name,i)}e=zi(i.gameObject,e);break}return e}new E(1,1,1),new E(0,0,1);class $E{constructor(e,t,n,r){u(this,"type","NeedleParticleSubEmitter"),u(this,"emitterType"),u(this,"emitterProbability"),u(this,"q_",new Ce),u(this,"v_",new E),u(this,"v2_",new E),u(this,"_emitterMatrix",new ge),u(this,"_circularBuffer"),this.system=e,this.particleSystem=t,this.subSystem=n,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const s=1e3;this._circularBuffer=new ra(()=>new ge,s)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===Zk.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===Zk.Death){let r=e.life;if(e[EA]!==void 0&&(r=e[EA]),!(e.age+t*1.2>=r))return;const s=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=s}const n=new ge;n.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(t,e.emissionState,n)}}var Tye=Object.defineProperty,Bye=Object.getOwnPropertyDescriptor,Rye=(i,e,t,n)=>{for(var r=n>1?void 0:n?Bye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Tye(e,t,r),r};class Sb extends ws{constructor(){super(...arguments),u(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new hG;return this.granularity.onValueChanged=t=>{e.granularity=t},e}}Rye([_(Bt)],Sb.prototype,"granularity",2),Ia("PixelationEffect",Sb);class QA extends Re{constructor(){super(...arguments),u(this,"_didAssignPlayerColor",!1),u(this,"tryAssignColor",()=>{const e=te.getComponentInParent(this.gameObject,Ma);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const t=te.getComponentInParent(this.gameObject,qr);return t!=null&&t.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(t.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Wt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Wt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield yH(.2),!this.tryAssignColor()););}assignUserColor(e){const t=QA.hashCode(e),n=QA.colorFromHashCode(t);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const s=r;s.material&&s.material.color&&this.assignColor(n,e,s)}}assignColor(e,t,n){let r=n.material;r&&(r._playerMaterial!==t&&(r=r.clone(),r._playerMaterial=t,n.material=r),r.color=e)}static hashCode(e){var t=0,n,r;if(e.length===0)return t;for(n=0;n<e.length;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t|=0;return t}static colorFromHashCode(e){const t=(e&16711680)>>16,n=(e&65280)>>8,r=e&255;return new _e(t/255,n/255,r/255)}}async function rO(i){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>hxe);e.observedAttributes.includes(i)||e.observedAttributes.push(i)}var Dye=Object.defineProperty,Pye=Object.getOwnPropertyDescriptor,Ib=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Dye(e,t,r),r};const Oa=ee("debugskybox");rO("skybox-image"),rO("environment-image");function H9(i,e,t,n,r){const s=new xc;s.allowDrop=!1,s.allowNetworking=!1,s.background=t,s.environment=n,te.addComponent(i.scene,s);const o=a=>{typeof a=="string"&&(Oa&&console.log(r,"CHANGED TO",a),s.setSkybox(a))};return RN(i.domElement,r,o),s.addEventListener("destroy",()=>{Oa&&console.log("Destroyed attribute remote skybox",r),DN(i.domElement,r,o)}),s.setSkybox(e)}hi.addContextCreatedCallback(i=>{var e;const t=i.context,n=t.domElement.getAttribute("skybox-image"),r=t.domElement.getAttribute("environment-image"),s=new Array;if(n){Oa&&console.log("Creating remote skybox to load "+n),((e=t.mainCameraComponent)==null?void 0:e.clearFlags)!==Zp.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=H9(t,n,!0,!1,"skybox-image");s.push(o)}if(r){Oa&&console.log("Creating remote environment to load "+r);const o=H9(t,r,!1,!0,"environment-image");s.push(o)}return s.length>0?Z_(s):Promise.resolve()});function V9(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function W9(i){const e=V9().find(t=>t.src===i);return e?(Oa&&console.log("Skybox: Found previously loaded texture for "+i),e.texture):null}async function kye(i){const e=await i;B2(e,!0),ji(e)}function Oye(i,e){const t=V9();for(;t.length>5;){const n=t.shift();n&&kye(n.texture)}e.then(n=>B2(n,!1)),t.push({src:i,texture:e})}class xc extends Re{constructor(){super(...arguments),u(this,"url"),u(this,"allowDrop",!0),u(this,"background",!0),u(this,"environment",!0),u(this,"allowNetworking",!0),u(this,"_loader"),u(this,"_prevUrl"),u(this,"_prevLoadedEnvironment"),u(this,"_prevEnvironment",null),u(this,"_prevBackground",null),u(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),u(this,"onDragOverEvent",e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)(t==="text/uri-list"||t==="Files")&&e.preventDefault()}),u(this,"onDrop",e=>{var t,n,r,s;if(this.allowDrop&&e.dataTransfer){for(const o of e.dataTransfer.types)if(Oa&&console.log(o),o==="text/uri-list"){const a=e.dataTransfer.getData(o);Oa&&console.log(o,a);let l=(n=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:n.name;if(l||(l=(s=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:s.name),Oa&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${c}`),e.preventDefault(),this.setSkybox(c);break}else if(this.isValidTextureType(a)){console.log("[Remote Skybox] Setting skybox from url: "+a),e.preventDefault(),this.setSkybox(a);break}else{console.warn(`[RemoteSkybox] Unknown url ${a}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const c=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:e,url:a,apply:h=>{e.preventDefault(),this.setSkybox(h)}}});this.dispatchEvent(c)}}else if(o=="Files"){const a=e.dataTransfer.files.item(0);if(Oa&&console.log(o,a),!a)continue;if(!this.isValidTextureType(a.name)){console.warn(`[RemoteSkybox]: File "${a.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(W9(a.name)===null){const l=new Blob([a]),c=URL.createObjectURL(l);e.preventDefault(),this.setSkybox(c,a.name)}else e.preventDefault(),this.setSkybox(a.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Ni.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(e,t){var n;if(!this.activeAndEnabled||(e=Lye(e),!e))return!1;if(t??(t=e),this.isValidTextureType(t)||console.warn("Potentially invalid skybox url",t,"on",this.name),Oa&&console.log("Set remote skybox url: "+e),this._prevUrl===e&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(n=this._prevLoadedEnvironment)==null||n.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=e;const r=await this.loadTexture(e,t);if(!r||!this.enabled)return!1;this.url=e;const s=e.lastIndexOf("/");return r.name=e.substring(s>=0?s+1:0),this._loader instanceof Dl&&(r.colorSpace=ht),this._prevLoadedEnvironment=r,this.applySkybox(),!0}async loadTexture(e,t){var n,r,s,o,a;if(!e)return Promise.resolve(null);t??(t=e);const l=W9(t);if(l){const p=await l;if(((r=(n=p.source)==null?void 0:n.data)==null?void 0:r.length)>0||(a=(o=(s=p.source)==null?void 0:s.data)==null?void 0:o.data)!=null&&a.length)return p}const c=t.endsWith(".exr"),h=t.endsWith(".hdr");c?this._loader instanceof ty||(this._loader=new ty):h?this._loader instanceof nC||(this._loader=new nC):this._loader instanceof Dl||(this._loader=new Dl),Oa&&console.log("Loading skybox: "+e);const d=this._loader.loadAsync(e);return Oye(t,d),await d}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Gf,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Oa&&console.log("Set remote skybox",this.url,!Ni.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Ni.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(e){return e.startsWith("http://")||e.startsWith("https://")}isValidTextureType(e){for(const t of this.validTextureTypes)if(e.endsWith(t))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Ib([vP(xc.prototype.urlChangedSyncField),_(URL)],xc.prototype,"url",2),Ib([_()],xc.prototype,"allowDrop",2),Ib([_()],xc.prototype,"background",2),Ib([_()],xc.prototype,"environment",2),Ib([_()],xc.prototype,"allowNetworking",2);function Lye(i){switch(i?.toLowerCase()){case"studio":i="https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";break;case"blurred-skybox":i="https://cdn.needle.tools/static/skybox/blurred-skybox.exr";break;case"quicklook-ar":i="https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";break;case"quicklook":i="https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr";break}return i===void 0?null:i}var Fye=Object.defineProperty,Uye=Object.getOwnPropertyDescriptor,Wo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Uye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Fye(e,t,r),r};const qo=ee("debugsceneswitcher"),eS="scene";rO(eS);const vd=Promise.resolve(!1);class Ts extends Re{constructor(){super(...arguments),u(this,"autoLoadFirstScene",!0),u(this,"scenes",[]),u(this,"loadingScene"),u(this,"queryParameterName","scene"),u(this,"useSceneName",!0),u(this,"clamp",!0),u(this,"useHistory",!0),u(this,"useKeyboard",!0),u(this,"useSwipe",!0),u(this,"useSceneLighting",!0),u(this,"preloadNext",1),u(this,"preloadPrevious",1),u(this,"preloadConcurrent",2),u(this,"_currentIndex",-1),u(this,"_currentScene"),u(this,"_engineElementOverserver"),u(this,"_preloadScheduler"),u(this,"onPopState",async e=>{if(!this.useHistory)return;const t=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=e?.state;if(r&&r.startsWith(this.guid)){const s=r.substr(this.guid.length+2);qo&&console.log("PopState",s),await this.trySelectSceneFromValue(s)}}}finally{this.useHistory=t}}),u(this,"normalizedSwipeThresholdX",.1),u(this,"_didSwipe",!1),u(this,"onInputPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const n=t.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),u(this,"onInputPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),u(this,"onInputKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const n=parseInt(t)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),u(this,"__lastSwitchScene"),u(this,"__lastSwitchScenePromise"),u(this,"_currentlyLoadingScene"),u(this,"_lastLoadingScene"),u(this,"_loadingScenePromise"),u(this,"_isCurrentlyLoading",!1),u(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),qo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(on.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(on.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(on.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===eS){const n=this.context.domElement.getAttribute(eS);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Nye(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(eS);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(on.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(on.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(on.PointerUp,this.onInputPointerUp),(e=this._preloadScheduler)==null||e.stop()}addScene(e){if(typeof e=="string"){let t=this.context.addressables.findAssetReference(e);return t||(t=new ti(e),this.context.addressables.registerAssetReference(t)),this.scenes.push(t),t}return this.scenes.push(e),e}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,n,r;if(qo&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(t=this.scenes)==null?void 0:t.find(a=>a.uri===e);if(!o){const a=ti.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(a)}if(o)e=(n=this.scenes)==null?void 0:n.indexOf(o);else return vd}if(!((r=this.scenes)!=null&&r.length))return vd;if(e<0){if(this.clamp)return vd;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return vd;e=0}const s=this.scenes[e];return this.switchScene(s)}async switchScene(e){if(!(e instanceof ti)){const t=typeof e;return t==="string"?this.select(e):t==="number"?this.select(e):(console.warn("SceneSwitcher: Can't switch to scene",e,"of type",t),!1)}return e.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===e&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=e,this.__lastSwitchScenePromise=this.__internalSwitchScene(e),await this.__lastSwitchScenePromise)}async __internalSwitchScene(e){var t,n;if(this._currentScene){qo&&console.log("UNLOAD",e.uri);const s=this.tryGetSceneEventListener(this._currentScene.asset);if(s!=null&&s.sceneClosing){const o=s.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;try{this._currentlyLoadingScene=e,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const s=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(s),await this.onStartLoading(),await e.loadAssetAsync((a,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return qo&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return qo&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if(qo&&console.log("ADD",e.uri),this._currentScene=e,te.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0){let c=r.toString();if(this.useSceneName&&(c=q9(e.uri)),(n=this.queryParameterName)!=null&&n.length)q_(this.queryParameterName,c,this.useHistory);else{const h=history.state,d=this.guid+"::"+r;h!==d&&history.pushState(d,"unused",location.href)}}const a=this.tryGetSceneEventListener(e.asset);if(a!=null&&a.sceneOpened){const c=a.sceneOpened(this);c instanceof Promise&&await c}const l=new CustomEvent("scene-opened",{detail:{scene:e,switcher:this,index:r}});return this.dispatchEvent(l),!0}}catch(s){console.error(s)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof ti)return t.preload()}return vd}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return vd;const t=ee(this.queryParameterName);return typeof t=="boolean"?vd:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);{const n=e.toLowerCase();for(let r=0;r<this.scenes.length;r++){const s=this.scenes[r];if(s&&q9(s.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return zs()&&console.warn('Can not find scene: "'+e+'"',this),vd}async onStartLoading(){var e,t;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(e=this.loadingScene)==null?void 0:e.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(t=this.loadingScene)!=null&&t.asset)){qo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;te.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const s=r.sceneOpened(this);s instanceof Promise&&await s}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var e;if(this._isCurrentlyLoading=!1,(e=this.loadingScene)!=null&&e.asset){qo&&console.log("Remove loading scene",this.loadingScene.uri);const t=this.loadingScene.asset,n=this.tryGetSceneEventListener(t);if(typeof n?.sceneClosing=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}te.remove(t)}if(!this._isCurrentlyLoading){const t=this.tryGetSceneEventListener(this.gameObject);if(t&&t.sceneClosing){const n=t.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(e,t=0){const n=te.foreachComponent(e,r=>r.sceneClosing?r:void 0);if(t===0&&!n&&e.children.length)for(const r of e.children){const s=this.tryGetSceneEventListener(r,t+1);if(s)return s}return n||null}}Wo([_()],Ts.prototype,"autoLoadFirstScene",2),Wo([_(ti)],Ts.prototype,"scenes",2),Wo([_(ti)],Ts.prototype,"loadingScene",2),Wo([_()],Ts.prototype,"queryParameterName",2),Wo([_()],Ts.prototype,"useSceneName",2),Wo([_()],Ts.prototype,"clamp",2),Wo([_()],Ts.prototype,"useHistory",2),Wo([_()],Ts.prototype,"useKeyboard",2),Wo([_()],Ts.prototype,"useSwipe",2),Wo([_()],Ts.prototype,"useSceneLighting",2),Wo([_()],Ts.prototype,"preloadNext",2),Wo([_()],Ts.prototype,"preloadPrevious",2),Wo([_()],Ts.prototype,"preloadConcurrent",2);function q9(i){const e=i.split("/").pop(),t=e?.split(".").shift();return t!=null&&t.length?t:i}class Nye{constructor(e,t=1,n=1,r=2){u(this,"maxLoadAhead"),u(this,"maxLoadBehind"),u(this,"maxConcurrent"),u(this,"_isRunning",!1),u(this,"_switcher"),u(this,"_loadTasks",[]),u(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=n,this.maxConcurrent=r}begin(){if(this._isRunning)return;qo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,n;const r=this._switcher.scenes,s=setInterval(()=>{if(this.allLoaded()&&(qo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(s);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,n=0,t=0);const o=n%2===0;o&&(t+=1),n+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new Qye(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1}return!0}}class Qye{constructor(e,t,n){u(this,"index"),u(this,"asset"),u(this,"tasks"),this.index=e,this.asset=t,this.tasks=n,n.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(qo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),qo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function zye(){return new Promise((i,e)=>{const t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function jye(i){await zye(),i()}var Gye=Object.defineProperty,Hye=Object.getOwnPropertyDescriptor,Xo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hye(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Gye(e,t,r),r};const Rr=ee("debugvideo");var X9=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(X9||{}),Y9=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(Y9||{}),J9=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(J9||{});class hr extends Re{constructor(){super(),u(this,"playOnAwake",!0),u(this,"aspectMode",0),u(this,"clip",null),u(this,"source",1),u(this,"_url",null),u(this,"renderMode"),u(this,"targetMaterialProperty"),u(this,"targetMaterialRenderer"),u(this,"targetTexture"),u(this,"time",0),u(this,"_playbackSpeed",1),u(this,"_isLooping",!1),u(this,"_muted",!1),u(this,"_audioOutputMode",2),u(this,"playInBackground",!0),u(this,"_crossOrigin","anonymous"),u(this,"_videoElement",null),u(this,"_videoTexture",null),u(this,"_videoMaterial",null),u(this,"_isPlaying",!1),u(this,"wasPlaying",!1),u(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),u(this,"_receivedInput",!1),u(this,"_overlay",null),u(this,"_targetObjects"),u(this,"_updateAspectRoutineId",-1),u(this,"_hls"),u(this,"onHlsAvailable",()=>{var e;Rr&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(e=this._videoElement)==null||e.play(),Rr&&console.log("HLS: loaded",this.clip))}),jye(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ee("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(e){const t=this._url!==e;this.__didAwake?t&&this.setClipURL(e??""):this._url=e}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}get currentVideo(){return this.clip}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&rt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Rr&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(e){this._url!==e&&(this._url=e,this.source=1,Rr&&console.log("set url",e),this._videoElement?e.endsWith(".m3u8")||e.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var e,t;Rr&&console.log("VideoPlayer.onEnable",Y9[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){var e;window.removeEventListener("visibilitychange",this.visibilityChanged),(e=this._overlay)==null||e.stop(),this.pause()}onDestroy(){var e;this._videoElement&&((e=this.videoElement)==null||e.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;if(this._videoElement||this.create(!1),!this._videoElement){Rr&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Rr&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),Rr&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Rr&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Rr&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),Rr&&console.log("PAUSE",this,this.currentTime)}create(e){let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url,!(t!=null&&t.length)&&typeof this.clip=="string"&&(t=this.clip);break}return t?(this._videoElement||(Rr&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(Rr&&console.log("Set Video src",t),this._videoElement.src=t):(Rr&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new mU(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=ht,e&&this.handleBeginPlaying(e),Rr&&console.log("Video: handle playing done...",t,e),!0):(Rr&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new Vye(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),Rr&&console.log("created video element",e),e}handleBeginPlaying(e){var t,n;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(n=te.getComponent(this.gameObject,Mn))==null?void 0:n.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,J9[this.renderMode],this);return}const s=r.material;if(s){this._targetObjects.push(r),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),r.material=this._videoMaterial);const o="map",a=this._videoMaterial;if(!this.targetMaterialProperty)a[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:a[o]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,n=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const s of n.getVideoTracks()){const o=s.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let s=0;s<10;s++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const s of this._targetObjects){let o=1;if(s.parent){const a=zi(s.parent);o=a.x/a.y}switch(this.aspectMode){case 1:s.scale.y=1/r*s.scale.x*o;break;case 2:s.scale.x=r*s.scale.y*o;break}}for(let s=0;s<3;s++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let e=document.head.querySelector("script[data-hls_library]");e?globalThis.Hls?this.onHlsAvailable():e.addEventListener("load",this.onHlsAvailable):(Rr&&console.log("HLS: load script"),e=document.createElement("script"),e.dataset.hls_library="hls.js",e.src="https://cdn.jsdelivr.net/npm/hls.js@1",e.addEventListener("load",this.onHlsAvailable),document.head.append(e))}}Xo([_()],hr.prototype,"playOnAwake",2),Xo([_()],hr.prototype,"aspectMode",2),Xo([_(URL)],hr.prototype,"clip",2),Xo([_()],hr.prototype,"source",2),Xo([_(URL)],hr.prototype,"url",1),Xo([_()],hr.prototype,"renderMode",2),Xo([_()],hr.prototype,"targetMaterialProperty",2),Xo([_(Mn)],hr.prototype,"targetMaterialRenderer",2),Xo([_(Ut)],hr.prototype,"targetTexture",2),Xo([_()],hr.prototype,"time",2),Xo([_()],hr.prototype,"playbackSpeed",1),Xo([_()],hr.prototype,"isLooping",1),Xo([_()],hr.prototype,"audioOutputMode",1);class Vye{constructor(e){u(this,"context"),u(this,"_videos",[]),u(this,"_screenspaceModeQuad"),u(this,"_isInScreenspaceMode",!1),u(this,"_input"),this.context=e,this._input=new Wye(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=ey.createPrimitive(Gp.Quad,{material:new qye(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const n=this._screenspaceModeQuad;this.context.scene.add(n),this.updateScreenspaceMaterialUniforms();const r=n.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Wye{constructor(e){u(this,"_onResizeScreenFn"),u(this,"_onKeyUpFn"),u(this,"_onMouseWheelFn"),u(this,"context"),u(this,"overlay"),u(this,"_material"),u(this,"_isPinching",!1),u(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new K;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const s=new K(r.movementX,r.movementY);s.x/=this.context.domElement.clientWidth,s.y/=this.context.domElement.clientHeight,t.set(s.x,s.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let n=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-n<.3&&this.overlay.stop(),n=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const s=r.touches[0],o=r.touches[1],a=s.clientX-o.clientX,l=s.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const h=c-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class qye extends Mt{constructor(e){super(),u(this,"_offset",new K),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new qe(0,0,1,1)}},this.vertexShader=`
7347
7347
  uniform sampler2D map;
7348
7348
  uniform float screenAspect;
7349
7349
  uniform vec4 offsetScale;
@@ -7431,10 +7431,10 @@ void main() {
7431
7431
  ${o}
7432
7432
 
7433
7433
  This could mean you forgot to add a npmdef to your ExportInfo
7434
- <a href="https://engine.needle.tools/docs/project_structure.html#creating-and-installing-a-npmdef" target="_blank">documentation</a>`,Bo.Warn)}}if(e.children)for(const s of e.children)await _O(i,s,t)}function nxe(i,e){const{instance:t,compData:n,obj:r}=i;e.object=r,e.target=t,P1(t,n,e),Ub&&console.debug("add "+n.name,n,t)}const cV=ee("debugfileformat");async function hV(i){const e=await fetch(i,{method:"GET",headers:{range:"bytes=0-32"}}).catch(t=>null);if(e!=null&&e.ok){const t=await e.arrayBuffer(),n=uV(t);return cV&&console.log("Determined file type from header: "+n),n}return"unknown"}function uV(i){if(i.byteLength<4)return"unknown";const e=new Uint8Array(i);return cV&&console.warn(`Trying to determine file type from binary data
7434
+ <a href="https://engine.needle.tools/docs/project_structure.html#creating-and-installing-a-npmdef" target="_blank">documentation</a>`,Bo.Warn)}}if(e.children)for(const s of e.children)await _O(i,s,t)}function nxe(i,e){const{instance:t,compData:n,obj:r}=i;e.object=r,e.target=t,P1(t,n,e),Ub&&console.debug("add "+n.name,n,t)}const cV=ee("debugfileformat");async function hV(i,e=!0){var t;if(e){let r=i;const s=new URL(r,globalThis.location.origin);let o=null;const a=s.searchParams.get("filetype");switch(a&&(o=a.toUpperCase()),o!=null&&o.length||(o=(t=s.pathname.split(".").pop())==null?void 0:t.toUpperCase()),o){case"GLTF":return"gltf";case"VRM":return"vrm";case"GLB":return"glb";case"FBX":return"fbx";case"USD":return"usd";case"USDA":return"usda";case"USDZ":return"usdz"}}const n=await fetch(i,{method:"GET",headers:{range:"bytes=0-32"}}).catch(r=>null);if(n!=null&&n.ok){const r=await n.arrayBuffer(),s=uV(r);return cV&&console.log("Determined file type from header: "+s),s}return"unknown"}function uV(i){if(i.byteLength<4)return"unknown";const e=new Uint8Array(i);return cV&&console.warn(`Trying to determine file type from binary data
7435
7435
  `,'"'+new TextDecoder().decode(i)+`"
7436
- `,e),e[0]==103&&e[1]==108&&e[2]==84&&e[3]==70?"glb":e[0]==80&&e[1]==75&&e[2]==3&&e[3]==4?"usdz":e[0]==80&&e[1]==88&&e[2]==82&&e[3]==45&&e[4]==85&&e[5]==83&&e[6]==68&&e[7]==67?"usd":e[0]==35&&e[1]==117&&e[2]==115&&e[3]==100&&e[4]==97?"usda":e[0]==75&&e[1]==97&&e[2]==121&&e[3]==100&&e[4]==97&&e[5]==114&&e[6]==97&&e[7]==32?"fbx":e[0]==35&&e[1]==32&&e[2]==66&&e[3]==108&&e[4]==101&&e[5]==110&&e[6]==100&&e[7]==101&&e[8]==114&&e[9]==32?"obj":"unknown"}class wO{createBuiltinComponents(e,t,n,r,s){return ixe(e,t,n,r,s)}writeBuiltinComponentData(e,t){return exe(e,t)}parseSync(e,t,n,r){return gV(e,t,n,r)}loadSync(e,t,n,r,s){return EO(e,t,n,r,s)}}sT(wO);const dV=ee("printGltf")||ee("printgltf"),pV=ee("downloadgltf");var fV=(i=>(i[i.BeforeLoad=0]="BeforeLoad",i[i.AfterLoaded=1]="AfterLoaded",i[i.FinishedSetup=10]="FinishedSetup",i))(fV||{});class Of{constructor(e,t,n,r){u(this,"context"),u(this,"loader"),u(this,"path"),u(this,"gltf"),this.context=e,this.path=t,this.loader=n,this.gltf=r}}const _d={};function rxe(i,e){_d[i]=_d[i]||[],_d[i].push(e)}function sxe(i,e){if(_d[i]){const t=_d[i].indexOf(e);t>=0&&_d[i].splice(t,1)}}function RA(i,e){if(_d[i])for(const t of _d[i])t(e)}async function mV(i,e,t,n,r){dV&&console.warn("glTF",e,t),e.includes("?")&&(e=e.split("?")[0]),await Xa().createBuiltinComponents(i,e,t,n,r)}async function oxe(i){var e;switch(((e=i.split("?")[0].split(".").pop())==null?void 0:e.toUpperCase())||""){case"GLTF":return"gltf";case"GLB":return"glb";case"FBX":return"fbx"}return await hV(i)||"unknown"}async function CO(i,e){const t=await oxe(i);switch(t){case"unknown":return console.warn("Unknown file type:",i),new Tu;case"fbx":return new j4;case"obj":return new d2;case"usd":case"usda":case"usdz":return console.warn("USD files are not supported."),null;default:console.warn("Unknown file type:",t);case"gltf":case"glb":const n=new Tu;return await KP(n,e,i),n}}async function gV(i,e,t,n){typeof t!="string"&&(console.warn("Parse gltf binary without path, this might lead to errors in resolving extensions. Please provide the source path of the gltf/glb file",t,typeof t),t=""),dV&&console.log("Parse glTF",t);const r=await CO(t,i);if(!r)return;if(r instanceof d2){typeof e!="string"&&(e=new TextDecoder().decode(e));const o=r.parse(e);return{animations:o.animations,scene:o,scenes:[o]}}if(!(r instanceof Tu)){const o=r.parse(e,t);return yV(r,o),{animations:o.animations,scene:o,scenes:[o]}}const s=JP(r);return new Promise((o,a)=>{try{let l=t.split("?")[0].trimEnd();if(l.endsWith(".glb")||l.endsWith(".gltf")){const h=l.split("/");h.pop(),l=h.join("/"),l.endsWith("/")||(l+="/")}r.resourcePath=l,n1(r,i),RA(0,new Of(i,t,r));const c=i.mainCamera;r.parse(e,"",async h=>{$P(t,h,i),RA(1,new Of(i,t,r,h)),await mV(i,t,h,n,s),await AV(h.scene,i,c),RA(10,new Of(i,t,r,h)),o(h),pV&&vV(e)},h=>{console.error("failed loading "+t,h),o(void 0)})}catch(l){console.error(l),a(l)}})}async function EO(i,e,t,n,r){axe(e);const s=await CO(e,i);if(!s)return;if(!(s instanceof Tu)){const a=await s.loadAsync(e,r);return yV(s,a),{animations:a.animations,scene:a,scenes:[a]}}const o=JP(s);return new Promise((a,l)=>{try{n1(s,i),RA(0,new Of(i,e,s));const c=i.mainCamera;s.load(e,async h=>{$P(e,h,i),RA(1,new Of(i,e,s,h)),await mV(i,t,h,n,o),await AV(h.scene,i,c),RA(10,new Of(i,e,s,h)),a(h),pV&&vV(e)},h=>{r?.call(s,h)},h=>{console.error("failed loading "+e,h),a(void 0)})}catch(c){console.error(c),l(c)}})}async function AV(i,e,t){t||(t=e.mainCamera),t?await e.renderer.compileAsync(i,t,e.scene):Wle(i,e)}function axe(i){if(new URL(i,window.location.href).href.startsWith("file://")){const e=`Hi - it looks like you are trying to load a local file which will not work. You need to use a webserver to serve your files.
7437
- Please refer to the documentation on <a href="https://fwd.needle.tools/needle-engine/docs/local-server">https://docs.needle.tools</a> or ask for help in our <a href="https://discord.needle.tools">discord community</a>`;nn(e),console.warn(e)}}function vV(i){if(typeof i=="string"){const e=document.createElement("a");e.href=i,e.download=i.split("/").pop(),e.click()}else{const e=new Blob([i],{type:"application/octet-stream"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="download.glb",n.click()}}function yV(i,e){if(e!=null&&e.isObject3D){const t=e;i instanceof j4?t.traverse(n=>{const r=n;r!=null&&r.isMesh&&$3(r,r.material)}):i instanceof d2&&t.traverse(n=>{})}}sT(wO);const cn=ee("debugwebcomponent"),bV="needle-engine",xV="vr",_V="desktop",lxe=[dQ,xV,_V],Qb="ar-session-active",zb="desktop-session-active",cxe=["hash","src","camera-controls","loadstart","progress","loadfinished","dracoDecoderPath","dracoDecoderType","ktx2DecoderPath","tone-mapping"];class SO extends HTMLElement{constructor(){super(),u(this,"_context"),u(this,"_overlay_ar"),u(this,"_loadingProgress01",0),u(this,"_loadingView"),u(this,"_previousSrc",null),u(this,"_didFullyLoad",!1),u(this,"_loadId",0),u(this,"_abortController",null),u(this,"_lastSourceFiles",null),u(this,"_createContextPromise",null),u(this,"onXRSessionStarted",()=>{var t;const n=this.context.xrSessionMode;n==="immersive-ar"?this.onEnterAR(this.context.xrSession):n==="immersive-vr"&&this.onEnterVR(this.context.xrSession),(t=this.context.xrSession)==null||t.addEventListener("end",()=>{this.dispatchEvent(new CustomEvent("xr-session-ended",{detail:{session:this.context.xrSession,context:this._context,sessionMode:n}})),n==="immersive-ar"?this.onExitAR(this.context.xrSession):n==="immersive-vr"&&this.onExitVR(this.context.xrSession)})}),u(this,"onReady",()=>{var t;return(t=this._loadingView)==null?void 0:t.onLoadingFinished()}),u(this,"onError",()=>{var t;return(t=this._loadingView)==null?void 0:t.setMessage("Loading failed!")}),u(this,"_previouslyRegisteredMap",new Map),this._overlay_ar=new bne,this.addEventListener("ready",this.onReady),OH(),this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>
7436
+ `,e),e[0]==103&&e[1]==108&&e[2]==84&&e[3]==70?"glb":e[0]==80&&e[1]==75&&e[2]==3&&e[3]==4?"usdz":e[0]==80&&e[1]==88&&e[2]==82&&e[3]==45&&e[4]==85&&e[5]==83&&e[6]==68&&e[7]==67?"usd":e[0]==35&&e[1]==117&&e[2]==115&&e[3]==100&&e[4]==97?"usda":e[0]==75&&e[1]==97&&e[2]==121&&e[3]==100&&e[4]==97&&e[5]==114&&e[6]==97&&e[7]==32?"fbx":e[0]==35&&e[1]==32&&e[2]==66&&e[3]==108&&e[4]==101&&e[5]==110&&e[6]==100&&e[7]==101&&e[8]==114&&e[9]==32?"obj":"unknown"}class wO{createBuiltinComponents(e,t,n,r,s){return ixe(e,t,n,r,s)}writeBuiltinComponentData(e,t){return exe(e,t)}parseSync(e,t,n,r){return gV(e,t,n,r)}loadSync(e,t,n,r,s){return EO(e,t,n,r,s)}}sT(wO);const dV=ee("printGltf")||ee("printgltf"),pV=ee("downloadgltf");var fV=(i=>(i[i.BeforeLoad=0]="BeforeLoad",i[i.AfterLoaded=1]="AfterLoaded",i[i.FinishedSetup=10]="FinishedSetup",i))(fV||{});class Of{constructor(e,t,n,r){u(this,"context"),u(this,"loader"),u(this,"path"),u(this,"gltf"),this.context=e,this.path=t,this.loader=n,this.gltf=r}}const _d={};function rxe(i,e){_d[i]=_d[i]||[],_d[i].push(e)}function sxe(i,e){if(_d[i]){const t=_d[i].indexOf(e);t>=0&&_d[i].splice(t,1)}}function RA(i,e){if(_d[i])for(const t of _d[i])t(e)}async function mV(i,e,t,n,r){dV&&console.warn("glTF",e,t),e.includes("?")&&(e=e.split("?")[0]),await Xa().createBuiltinComponents(i,e,t,n,r)}async function CO(i,e){const t=await hV(i)||"unknown";switch(t){case"unknown":return console.warn("Unknown file type:",i),new Tu;case"fbx":return new j4;case"obj":return new d2;case"usd":case"usda":case"usdz":return console.warn("USD files are not supported."),null;default:console.warn("Unknown file type:",t);case"gltf":case"glb":case"vrm":const n=new Tu;return await KP(n,e,i),n}}async function gV(i,e,t,n){typeof t!="string"&&(console.warn("Parse gltf binary without path, this might lead to errors in resolving extensions. Please provide the source path of the gltf/glb file",t,typeof t),t=""),dV&&console.log("Parse glTF",t);const r=await CO(t,i);if(!r)return;if(r instanceof d2){typeof e!="string"&&(e=new TextDecoder().decode(e));const o=r.parse(e);return{animations:o.animations,scene:o,scenes:[o]}}if(!(r instanceof Tu)){const o=r.parse(e,t);return yV(r,o),{animations:o.animations,scene:o,scenes:[o]}}const s=JP(r);return new Promise((o,a)=>{try{let l=t.split("?")[0].trimEnd();if(l.endsWith(".glb")||l.endsWith(".gltf")){const h=l.split("/");h.pop(),l=h.join("/"),l.endsWith("/")||(l+="/")}r.resourcePath=l,n1(r,i),RA(0,new Of(i,t,r));const c=i.mainCamera;r.parse(e,"",async h=>{$P(t,h,i),RA(1,new Of(i,t,r,h)),await mV(i,t,h,n,s),await AV(h.scene,i,c),RA(10,new Of(i,t,r,h)),o(h),pV&&vV(e)},h=>{console.error("failed loading "+t,h),o(void 0)})}catch(l){console.error(l),a(l)}})}async function EO(i,e,t,n,r){oxe(e);const s=await CO(e,i);if(!s)return;if(!(s instanceof Tu)){const a=await s.loadAsync(e,r);return yV(s,a),{animations:a.animations,scene:a,scenes:[a]}}const o=JP(s);return new Promise((a,l)=>{try{n1(s,i),RA(0,new Of(i,e,s));const c=i.mainCamera;s.load(e,async h=>{$P(e,h,i),RA(1,new Of(i,e,s,h)),await mV(i,t,h,n,o),await AV(h.scene,i,c),RA(10,new Of(i,e,s,h)),a(h),pV&&vV(e)},h=>{r?.call(s,h)},h=>{console.error("failed loading "+e,h),a(void 0)})}catch(c){console.error(c),l(c)}})}async function AV(i,e,t){t||(t=e.mainCamera),t?await e.renderer.compileAsync(i,t,e.scene):Wle(i,e)}function oxe(i){if(new URL(i,window.location.href).href.startsWith("file://")){const e=`Hi - it looks like you are trying to load a local file which will not work. You need to use a webserver to serve your files.
7437
+ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-engine/docs/local-server">https://docs.needle.tools</a> or ask for help in our <a href="https://discord.needle.tools">discord community</a>`;nn(e),console.warn(e)}}function vV(i){if(typeof i=="string"){const e=document.createElement("a");e.href=i,e.download=i.split("/").pop(),e.click()}else{const e=new Blob([i],{type:"application/octet-stream"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="download.glb",n.click()}}function yV(i,e){if(e!=null&&e.isObject3D){const t=e;i instanceof j4?t.traverse(n=>{const r=n;r!=null&&r.isMesh&&$3(r,r.material)}):i instanceof d2&&t.traverse(n=>{})}}sT(wO);const cn=ee("debugwebcomponent"),bV="needle-engine",xV="vr",_V="desktop",axe=[dQ,xV,_V],Qb="ar-session-active",zb="desktop-session-active",lxe=["hash","src","camera-controls","loadstart","progress","loadfinished","dracoDecoderPath","dracoDecoderType","ktx2DecoderPath","tone-mapping"];class SO extends HTMLElement{constructor(){super(),u(this,"_context"),u(this,"_overlay_ar"),u(this,"_loadingProgress01",0),u(this,"_loadingView"),u(this,"_previousSrc",null),u(this,"_didFullyLoad",!1),u(this,"_loadId",0),u(this,"_abortController",null),u(this,"_lastSourceFiles",null),u(this,"_createContextPromise",null),u(this,"onXRSessionStarted",()=>{var t;const n=this.context.xrSessionMode;n==="immersive-ar"?this.onEnterAR(this.context.xrSession):n==="immersive-vr"&&this.onEnterVR(this.context.xrSession),(t=this.context.xrSession)==null||t.addEventListener("end",()=>{this.dispatchEvent(new CustomEvent("xr-session-ended",{detail:{session:this.context.xrSession,context:this._context,sessionMode:n}})),n==="immersive-ar"?this.onExitAR(this.context.xrSession):n==="immersive-vr"&&this.onExitVR(this.context.xrSession)})}),u(this,"onReady",()=>{var t;return(t=this._loadingView)==null?void 0:t.onLoadingFinished()}),u(this,"onError",()=>{var t;return(t=this._loadingView)==null?void 0:t.setMessage("Loading failed!")}),u(this,"_previouslyRegisteredMap",new Map),this._overlay_ar=new bne,this.addEventListener("ready",this.onReady),OH(),this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>
7438
7438
  @import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
7439
7439
 
7440
7440
  :host {
@@ -7492,11 +7492,11 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
7492
7492
  <div class="content">
7493
7493
  <slot class="overlay-content"></slot>
7494
7494
  </div>
7495
- `,this.shadowRoot&&this.shadowRoot.appendChild(e.content.cloneNode(!0)),this._context=new kt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return cxe}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const e=this.getAttribute("camera-controls");return e==null?null:!(e===null||e==="False"||e==="false"||e==="0")}getContext(){return new Promise((e,t)=>{if(this._context&&this.loadingFinished)e(this._context);else{const n=()=>{this.removeEventListener("loadfinished",n),this._context&&this.loadingFinished&&e(this._context)};this.addEventListener("loadfinished",n)}})}get context(){return this._context}async connectedCallback(){if(cn&&console.log("<needle-engine> connected"),this.addEventListener("xr-session-started",this.onXRSessionStarted),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];cn&&console.log('src is null, trying to load from globalThis["needle:codegen_files"]',t),t&&(cn&&console.log('globalThis["needle:codegen_files"]',t),this.setAttribute("src",t))}cn&&console.log("src",this.getAttribute("src"));const e=this._loadId;setTimeout(()=>{this.isConnected!==!1&&e===this._loadId&&this.onLoad()},1),Za!=null&&Za.length&&this.setAttribute("version",Za)}disconnectedCallback(){var e;this.removeEventListener("xr-session-started",this.onXRSessionStarted),this._didFullyLoad=!1;const t=this.getAttribute("keep-alive"),n=t==null||t?.length>0&&t!=="true"&&t!=="1";cn&&console.warn('<needle-engine> disconnected, keep-alive: "'+t+'"',typeof t,"Dispose=",n),n?(cn&&console.warn("<needle-engine> dispose"),(e=this._context)==null||e.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1):cn&&console.warn("<needle-engine> is not disposed because keep-alive is set")}attributeChangedCallback(e,t,n){switch(cn&&console.log("attributeChangedCallback",e,t,n),e){case"src":cn&&console.warn(`<needle-engine src>
7495
+ `,this.shadowRoot&&this.shadowRoot.appendChild(e.content.cloneNode(!0)),this._context=new kt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return lxe}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const e=this.getAttribute("camera-controls");return e==null?null:!(e===null||e==="False"||e==="false"||e==="0")}getContext(){return new Promise((e,t)=>{if(this._context&&this.loadingFinished)e(this._context);else{const n=()=>{this.removeEventListener("loadfinished",n),this._context&&this.loadingFinished&&e(this._context)};this.addEventListener("loadfinished",n)}})}get context(){return this._context}async connectedCallback(){if(cn&&console.log("<needle-engine> connected"),this.addEventListener("xr-session-started",this.onXRSessionStarted),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];cn&&console.log('src is null, trying to load from globalThis["needle:codegen_files"]',t),t&&(cn&&console.log('globalThis["needle:codegen_files"]',t),this.setAttribute("src",t))}cn&&console.log("src",this.getAttribute("src"));const e=this._loadId;setTimeout(()=>{this.isConnected!==!1&&e===this._loadId&&this.onLoad()},1),Za!=null&&Za.length&&this.setAttribute("version",Za)}disconnectedCallback(){var e;this.removeEventListener("xr-session-started",this.onXRSessionStarted),this._didFullyLoad=!1;const t=this.getAttribute("keep-alive"),n=t==null||t?.length>0&&t!=="true"&&t!=="1";cn&&console.warn('<needle-engine> disconnected, keep-alive: "'+t+'"',typeof t,"Dispose=",n),n?(cn&&console.warn("<needle-engine> dispose"),(e=this._context)==null||e.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1):cn&&console.warn("<needle-engine> is not disposed because keep-alive is set")}attributeChangedCallback(e,t,n){switch(cn&&console.log("attributeChangedCallback",e,t,n),e){case"src":cn&&console.warn(`<needle-engine src>
7496
7496
  changed from "`,t,'" to "',n,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=n);break;case"loadstart":case"progress":case"loadfinished":typeof n=="string"&&n.length>0&&(cn&&console.log(e+" attribute changed",n),this.registerEventFromAttribute(e,n));break;case"dracoDecoderPath":cn&&console.log("dracoDecoderPath",n),S4(n);break;case"dracoDecoderType":n==="wasm"||n==="js"?(cn&&console.log("dracoDecoderType",n),I4(n)):console.error("Invalid dracoDecoderType",n,"expected js or wasm");break;case"ktx2DecoderPath":cn&&console.log("ktx2DecoderPath",n),M4(n);break;case"tone-mapping":{this.applyTonemapping();break}}}async onLoad(){var e,t;if(!this.isConnected)return;if(this._context||(cn&&console.warn("Create new context"),this._context=new kt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const n=this.getSourceFiles();if(!this.checkIfSourceHasChanged(n,this._lastSourceFiles))return;this._abortController&&(cn&&console.warn("Abort previous loading process"),this._abortController.abort(),this._abortController=null),this._lastSourceFiles=n;const r=++this._loadId;if((n==null||n.length<=0)&&(cn&&console.warn("Clear scene",n),this._context.clear(),r!==this._loadId))return;const s=this.getAttribute("alias");this.classList.add("loading");const o=Jc();this.ensureLoadStartIsRegistered();let a=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:s},cancelable:!0}));if(o){const A=this.getAttribute("hide-loading-overlay");A!=null&&A!=="0"&&(a=!1)}a===!1&&!o&&(rt()||(a=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),rt()&&Pi('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&a&&(this._loadingView=new yB(this)),a&&(this._didFullyLoad!==!0?(e=this._loadingView)==null||e.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===r&&this._loadingView.onLoadingBegin("begin load")},300)),cn&&console.warn(`--------------
7497
7497
  Needle Engine: Begin loading `+r+`
7498
- `,n),this.onBeforeBeginLoading();const l=[],c={context:this._context,name:"",progress:{},index:0,count:n.length,totalProgress01:this._loadingProgress01},h=new CustomEvent("progress",{detail:c}),d=new Array,p=new AbortController;this._abortController=p;const f={files:n,abortSignal:p.signal,onLoadingProgress:A=>{var v;if(p.signal.aborted)return;const g=A.index;!d[g]&&A.name&&(d[g]=hxe(A.name)),A.name=d[g],a&&((v=this._loadingView)==null||v.onLoadingUpdate(A)),c.name=A.name,c.progress=A.progress,this._loadingProgress01=AB(A),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(h)},onLoadingFinished:(A,v,g)=>{p.signal.aborted||g&&l.push({src:v,file:g})}},m=this.getAttribute("hash");if(m!=null&&(this._context.hash=m),this._context.alias=s,this._createContextPromise=this._context.create(f),await this._createContextPromise,this.applyTonemapping(),cn&&console.warn(`--------------
7498
+ `,n),this.onBeforeBeginLoading();const l=[],c={context:this._context,name:"",progress:{},index:0,count:n.length,totalProgress01:this._loadingProgress01},h=new CustomEvent("progress",{detail:c}),d=new Array,p=new AbortController;this._abortController=p;const f={files:n,abortSignal:p.signal,onLoadingProgress:A=>{var v;if(p.signal.aborted)return;const g=A.index;!d[g]&&A.name&&(d[g]=cxe(A.name)),A.name=d[g],a&&((v=this._loadingView)==null||v.onLoadingUpdate(A)),c.name=A.name,c.progress=A.progress,this._loadingProgress01=AB(A),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(h)},onLoadingFinished:(A,v,g)=>{p.signal.aborted||g&&l.push({src:v,file:g})}},m=this.getAttribute("hash");if(m!=null&&(this._context.hash=m),this._context.alias=s,this._createContextPromise=this._context.create(f),await this._createContextPromise,this.applyTonemapping(),cn&&console.warn(`--------------
7499
7499
  Needle Engine: finished loading `+r+`
7500
7500
  `,n,`Aborted? ${p.signal.aborted}`),this._loadId!==r||p.signal.aborted){console.log("Loading finished but aborted...");return}this._loadingProgress01=1,a&&((t=this._loadingView)==null||t.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:s,loadedFiles:l}}))}applyTonemapping(){var e;if(!((e=this._context)!=null&&e.renderer))return;const t=this.getAttribute("tone-mapping");switch(t?.toLowerCase()){case"none":this._context.renderer.toneMapping=Ds;break;case"linear":this._context.renderer.toneMapping=zf;break;case"neutral":this._context.renderer.toneMapping=jf;break;case"agx":this._context.renderer.toneMapping=VA;break;default:t!=null&&console.warn("Invalid tone-mapping attribute: "+t)}}internalSetLoadingMessage(e){var t;(t=this._loadingView)==null||t.setMessage(e)}getSourceFiles(){const e=this.getAttribute("src");if(!e)return[];let t;Array.isArray(e)?t=e:e.startsWith("[")&&e.endsWith("]")?t=JSON.parse(e):e.includes(",")?t=e.split(","):t=[e];for(let n=t.length-1;n>=0;n--){const r=t[n];(r==="null"||r==="undefined"||r?.length<=0)&&t.splice(n,1)}return t}checkIfSourceHasChanged(e,t){if(e?.length!==t?.length||e==null&&t!==null||e!==null&&t==null)return!0;if(e!==null&&t!==null){for(let n=0;n<e?.length;n++)if(e[n]!==t[n])return!0}return!1}ensureLoadStartIsRegistered(){const e=this.getAttribute("loadstart");e&&this.registerEventFromAttribute("loadstart",e)}registerEventFromAttribute(e,t){const n=this._previouslyRegisteredMap.get(e);if(n&&(this._previouslyRegisteredMap.delete(e),this.removeEventListener(e,n)),typeof t=="string"&&t.length>0)try{const r=(0,eval)(t);typeof r=="function"&&(this._previouslyRegisteredMap.set(e,r),this.addEventListener(e,s=>r?.call(globalThis,this._context,s)))}catch(r){console.error("Error registering event "+e+'="'+t+`" failed with the following error:
7501
- `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e){var t;this.onSetupAR();const n=this.getAROverlayContainer();this._overlay_ar.onBegin(this._context,n,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Qb),this.classList.remove(zb);const e=this.getAROverlayContainer();cn&&console.warn("onSetupAR:",e),e&&(e.classList.add(Qb),e.classList.remove(zb)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,dQ))}onSetupVR(){this.classList.remove(Qb),this.classList.remove(zb),this.foreachHtmlElement(e=>this.setupElementsForMode(e,xV))}onSetupDesktop(){this.classList.remove(Qb),this.classList.add(zb);const e=this.getAROverlayContainer();e&&(e.classList.remove(Qb),e.classList.add(zb)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,_V))}setupElementsForMode(e,t,n=null){var r,s;if(!(e===((s=(r=this._context)==null?void 0:r.renderer)==null?void 0:s.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const o of lxe)e.classList.contains(o)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const n=this.children[t];n.style&&e(n)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(cn&&console.log("using custom draco decoder path",e),S4(e));const t=this.getAttribute("dracoDecoderType");t&&(cn&&console.log("using custom draco decoder type",t),I4(t));const n=this.getAttribute("ktx2DecoderPath");n&&(cn&&console.log("using custom ktx2 decoder path",n),M4(n))}}typeof window<"u"&&!window.customElements.get(bV)&&window.customElements.define(bV,SO);function hxe(i){if(i.startsWith("blob:"))return"blob";const e=i.split("/");let t=e[e.length-1];const n=t.indexOf("?");n>0&&(t=t.substring(0,n));const r=t.indexOf("=");r>0&&(t=t.substring(r));const s=t.split(".").pop();if((s==="glb"||s==="gltf")&&(t=t.substring(0,t.length-4)),t=decodeURIComponent(t),t.length>3){let o="";for(let a=0;a<t.length;a++){let l=t[a];if(l===" "&&o.length<=0)continue;const c=o.length===0,h=l>="0"&&l<="9";c==!1&&l===l.toUpperCase()&&!h?o+=" "+l:(c&&(l=l.toUpperCase()),o+=l)}return cn&&console.log("displayName",t,o),o}return cn&&console.log("displayName",t),t}const uxe=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:SO},Symbol.toStringTag,{value:"Module"}));function dxe(){Gu.registerWaitForAllowAudio(()=>{const i=L_.getContext();i.addEventListener("statechange",()=>{setTimeout(()=>{const e=i.state;(e==="suspended"||e==="interrupted")&&i.resume().then(()=>{console.log("AudioContext resumed successfully")}).catch(t=>{console.log("Failed to resume AudioContext: "+t)})},500)})})}setTimeout(dxe,1e3);const dS=ee("debughotreload");let jb=!1;const Gb=new Map;function pxe(){return jb}function fxe(i){var e;if(jb)return;const t=i.constructor.name;Gb.has(t)?(e=Gb.get(t))==null||e.push(i):Gb.set(t,[i])}function mxe(i){if(jb)return;const e=i.constructor.name,t=Gb.get(e);if(!t)return;const n=t.indexOf(i);n!==-1&&t.splice(n,1)}let wV=!1;function gxe(){if(dS||wV)return;wV=!0;const i=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}i.apply(console,e)}}function Axe(i){dS&&console.log("[HMR] Apply changes",i,Object.keys(i)),gxe();for(const e of Object.keys(i))try{jb=!0;const t=q.get(e);if(!t){dS&&console.log("[HMR] Type not found: "+e);continue}const n=i[e],r=Gb.get(n.name);let s="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?s+=" x"+o:s+=" - no instances",console.log(s);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(n.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new n,h=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&A&&ch(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in h)if(h[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],y=g.name,b="bound ";if(y===b)continue;const x=g.name.substring(b.length),w=n.prototype[x];w&&(d[v]=w.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&A&&k2(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(dS)console.error(t);else return!1}finally{jb=!1,Ol(Bo.Log,"Script changes applied (HMR)")}return!0}let Ue;const Hb=new Array(128).fill(void 0);Hb.push(void 0,null,!0,!1),Hb.length;let pS=null;function CV(){return pS!==null&&pS.byteLength!==0||(pS=new Int32Array(Ue.memory.buffer)),pS}const vxe=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&vxe.decode();function pt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}let fS=null;function yxe(){return fS!==null&&fS.byteLength!==0||(fS=new Float32Array(Ue.memory.buffer)),fS}let Vb=128;function EV(i){if(Vb==1)throw new Error("out of js stack");return Hb[--Vb]=i,Vb}let mS=null;function bxe(){return mS!==null&&mS.byteLength!==0||(mS=new Uint32Array(Ue.memory.buffer)),mS}let Ko=0;function Lf(i,e){const t=e(4*i.length,4)>>>0;return yxe().set(i,t/4),Ko=i.length,t}function gS(i,e){const t=e(4*i.length,4)>>>0;return bxe().set(i,t/4),Ko=i.length,t}const ns=Object.freeze({Ball:0,0:"Ball",Cuboid:1,1:"Cuboid",Capsule:2,2:"Capsule",Segment:3,3:"Segment",Polyline:4,4:"Polyline",Triangle:5,5:"Triangle",TriMesh:6,6:"TriMesh",HeightField:7,7:"HeightField",Compound:8,8:"Compound",ConvexPolyhedron:9,9:"ConvexPolyhedron",Cylinder:10,10:"Cylinder",Cone:11,11:"Cone",RoundCuboid:12,12:"RoundCuboid",RoundTriangle:13,13:"RoundTriangle",RoundCylinder:14,14:"RoundCylinder",RoundCone:15,15:"RoundCone",RoundConvexPolyhedron:16,16:"RoundConvexPolyhedron",HalfSpace:17,17:"HalfSpace"});class xxe{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_raweventqueue_free(e)}constructor(e){const t=Ue.raweventqueue_new(e);return this.__wbg_ptr=t>>>0,this}drainCollisionEvents(e){try{Ue.raweventqueue_drainCollisionEvents(this.__wbg_ptr,EV(e))}finally{Hb[Vb++]=void 0}}drainContactForceEvents(e){try{Ue.raweventqueue_drainContactForceEvents(this.__wbg_ptr,EV(e))}finally{Hb[Vb++]=void 0}}clear(){Ue.raweventqueue_clear(this.__wbg_ptr)}}class Rs{static __wrap(e){e>>>=0;const t=Object.create(Rs.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawgenericjoint_free(e)}static generic(e,t,n,r){pt(e,st),pt(t,st),pt(n,st);const s=Ue.rawgenericjoint_generic(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return s===0?void 0:Rs.__wrap(s)}static spring(e,t,n,r,s){pt(r,st),pt(s,st);const o=Ue.rawgenericjoint_spring(e,t,n,r.__wbg_ptr,s.__wbg_ptr);return Rs.__wrap(o)}static rope(e,t,n){pt(t,st),pt(n,st);const r=Ue.rawgenericjoint_rope(e,t.__wbg_ptr,n.__wbg_ptr);return Rs.__wrap(r)}static spherical(e,t){pt(e,st),pt(t,st);const n=Ue.rawgenericjoint_spherical(e.__wbg_ptr,t.__wbg_ptr);return Rs.__wrap(n)}static prismatic(e,t,n,r,s,o){pt(e,st),pt(t,st),pt(n,st);const a=Ue.rawgenericjoint_prismatic(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r,s,o);return a===0?void 0:Rs.__wrap(a)}static fixed(e,t,n,r){pt(e,st),pt(t,ss),pt(n,st),pt(r,ss);const s=Ue.rawgenericjoint_fixed(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr);return Rs.__wrap(s)}static revolute(e,t,n){pt(e,st),pt(t,st),pt(n,st);const r=Ue.rawgenericjoint_revolute(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr);return r===0?void 0:Rs.__wrap(r)}}class GO{static __wrap(e){e>>>=0;const t=Object.create(GO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawpointprojection_free(e)}point(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return st.__wrap(e)}isInside(){return Ue.rawpointprojection_isInside(this.__wbg_ptr)!==0}}class HO{static __wrap(e){e>>>=0;const t=Object.create(HO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrayintersection_free(e)}normal(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return st.__wrap(e)}toi(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}featureType(){return Ue.rawpointcolliderprojection_featureType(this.__wbg_ptr)}featureId(){try{const n=Ue.__wbindgen_add_to_stack_pointer(-16);Ue.rawpointcolliderprojection_featureId(n,this.__wbg_ptr);var e=CV()[n/4+0],t=CV()[n/4+1];return e===0?void 0:t>>>0}finally{Ue.__wbindgen_add_to_stack_pointer(16)}}}class ss{static __wrap(e){e>>>=0;const t=Object.create(ss.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrotation_free(e)}constructor(e,t,n,r){const s=Ue.rawrotation_new(e,t,n,r);return this.__wbg_ptr=s>>>0,this}static identity(){const e=Ue.rawrotation_identity();return ss.__wrap(e)}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}get w(){return Ue.rawintegrationparameters_erp(this.__wbg_ptr)}}class jt{static __wrap(e){e>>>=0;const t=Object.create(jt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshape_free(e)}static cuboid(e,t,n){const r=Ue.rawshape_cuboid(e,t,n);return jt.__wrap(r)}static roundCuboid(e,t,n,r){const s=Ue.rawshape_roundCuboid(e,t,n,r);return jt.__wrap(s)}static ball(e){const t=Ue.rawshape_ball(e);return jt.__wrap(t)}static halfspace(e){pt(e,st);const t=Ue.rawshape_halfspace(e.__wbg_ptr);return jt.__wrap(t)}static capsule(e,t){const n=Ue.rawshape_capsule(e,t);return jt.__wrap(n)}static cylinder(e,t){const n=Ue.rawshape_cylinder(e,t);return jt.__wrap(n)}static roundCylinder(e,t,n){const r=Ue.rawshape_roundCylinder(e,t,n);return jt.__wrap(r)}static cone(e,t){const n=Ue.rawshape_cone(e,t);return jt.__wrap(n)}static roundCone(e,t,n){const r=Ue.rawshape_roundCone(e,t,n);return jt.__wrap(r)}static polyline(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_polyline(n,r,s,o);return jt.__wrap(a)}static trimesh(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_trimesh(n,r,s,o);return jt.__wrap(a)}static heightfield(e,t,n,r){const s=Lf(n,Ue.__wbindgen_malloc),o=Ko;pt(r,st);const a=Ue.rawshape_heightfield(e,t,s,o,r.__wbg_ptr);return jt.__wrap(a)}static segment(e,t){pt(e,st),pt(t,st);const n=Ue.rawshape_segment(e.__wbg_ptr,t.__wbg_ptr);return jt.__wrap(n)}static triangle(e,t,n){pt(e,st),pt(t,st),pt(n,st);const r=Ue.rawshape_triangle(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr);return jt.__wrap(r)}static roundTriangle(e,t,n,r){pt(e,st),pt(t,st),pt(n,st);const s=Ue.rawshape_roundTriangle(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return jt.__wrap(s)}static convexHull(e){const t=Lf(e,Ue.__wbindgen_malloc),n=Ko,r=Ue.rawshape_convexHull(t,n);return r===0?void 0:jt.__wrap(r)}static roundConvexHull(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=Ue.rawshape_roundConvexHull(n,r,t);return s===0?void 0:jt.__wrap(s)}static convexMesh(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_convexMesh(n,r,s,o);return a===0?void 0:jt.__wrap(a)}static roundConvexMesh(e,t,n){const r=Lf(e,Ue.__wbindgen_malloc),s=Ko,o=gS(t,Ue.__wbindgen_malloc),a=Ko,l=Ue.rawshape_roundConvexMesh(r,s,o,a,n);return l===0?void 0:jt.__wrap(l)}castShape(e,t,n,r,s,o,a,l,c){pt(e,st),pt(t,ss),pt(n,st),pt(r,jt),pt(s,st),pt(o,ss),pt(a,st);const h=Ue.rawshape_castShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr,o.__wbg_ptr,a.__wbg_ptr,l,c);return h===0?void 0:WO.__wrap(h)}intersectsShape(e,t,n,r,s){return pt(e,st),pt(t,ss),pt(n,jt),pt(r,st),pt(s,ss),Ue.rawshape_intersectsShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr)!==0}contactShape(e,t,n,r,s,o){pt(e,st),pt(t,ss),pt(n,jt),pt(r,st),pt(s,ss);const a=Ue.rawshape_contactShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr,o);return a===0?void 0:VO.__wrap(a)}containsPoint(e,t,n){return pt(e,st),pt(t,ss),pt(n,st),Ue.rawshape_containsPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr)!==0}projectPoint(e,t,n,r){pt(e,st),pt(t,ss),pt(n,st);const s=Ue.rawshape_projectPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return GO.__wrap(s)}intersectsRay(e,t,n,r,s){return pt(e,st),pt(t,ss),pt(n,st),pt(r,st),Ue.rawshape_intersectsRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s)!==0}castRay(e,t,n,r,s,o){return pt(e,st),pt(t,ss),pt(n,st),pt(r,st),Ue.rawshape_castRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s,o)}castRayAndGetNormal(e,t,n,r,s,o){pt(e,st),pt(t,ss),pt(n,st),pt(r,st);const a=Ue.rawshape_castRayAndGetNormal(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s,o);return a===0?void 0:HO.__wrap(a)}}class VO{static __wrap(e){e>>>=0;const t=Object.create(VO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapecontact_free(e)}distance(){return Ue.rawkinematiccharactercontroller_maxSlopeClimbAngle(this.__wbg_ptr)}point1(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return st.__wrap(e)}point2(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return st.__wrap(e)}normal1(){const e=Ue.rawshapecollidertoi_witness2(this.__wbg_ptr);return st.__wrap(e)}normal2(){const e=Ue.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr);return st.__wrap(e)}}class WO{static __wrap(e){e>>>=0;const t=Object.create(WO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapetoi_free(e)}toi(){return Ue.rawrotation_x(this.__wbg_ptr)}witness1(){const e=Ue.rawshapetoi_witness1(this.__wbg_ptr);return st.__wrap(e)}witness2(){const e=Ue.rawcontactforceevent_total_force(this.__wbg_ptr);return st.__wrap(e)}normal1(){const e=Ue.rawshapetoi_normal1(this.__wbg_ptr);return st.__wrap(e)}normal2(){const e=Ue.rawshapetoi_normal2(this.__wbg_ptr);return st.__wrap(e)}}class st{static __wrap(e){e>>>=0;const t=Object.create(st.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawvector_free(e)}static zero(){const e=Ue.rawvector_zero();return st.__wrap(e)}constructor(e,t,n){const r=Ue.rawvector_new(e,t,n);return this.__wbg_ptr=r>>>0,this}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}set x(e){Ue.rawvector_set_x(this.__wbg_ptr,e)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}set y(e){Ue.rawintegrationparameters_set_dt(this.__wbg_ptr,e)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}set z(e){Ue.rawvector_set_z(this.__wbg_ptr,e)}xyz(){const e=Ue.rawvector_xyz(this.__wbg_ptr);return st.__wrap(e)}yxz(){const e=Ue.rawvector_yxz(this.__wbg_ptr);return st.__wrap(e)}zxy(){const e=Ue.rawvector_zxy(this.__wbg_ptr);return st.__wrap(e)}xzy(){const e=Ue.rawvector_xzy(this.__wbg_ptr);return st.__wrap(e)}yzx(){const e=Ue.rawvector_yzx(this.__wbg_ptr);return st.__wrap(e)}zyx(){const e=Ue.rawvector_zyx(this.__wbg_ptr);return st.__wrap(e)}}class _xe{constructor(e,t,n){this.x=e,this.y=t,this.z=n}}class De{static new(e,t,n){return new _xe(e,t,n)}static intoRaw(e){return new st(e.x,e.y,e.z)}static zeros(){return De.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=De.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class SV{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.w=r}}class Vi{static identity(){return new SV(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new SV(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new ss(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}class wxe{constructor(e){this.elements=e}get m11(){return this.elements[0]}get m12(){return this.elements[1]}get m21(){return this.m12}get m13(){return this.elements[2]}get m31(){return this.m13}get m22(){return this.elements[3]}get m23(){return this.elements[4]}get m32(){return this.m23}get m33(){return this.elements[5]}}class IV{static fromRaw(e){const t=new wxe(e.elements());return e.free(),t}}var Wb,Bs,MV,TV,tr,IO,zn,BV,AS,MO,RV,vS,DA;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Wb||(Wb={}));class DV{constructor(e,t,n){this.rawSet=e,this.colliderSet=t,this.handle=n}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,n,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,n,r)}restrictTranslations(e,t,n,r){this.setEnabledTranslations(e,t,n,r)}setEnabledRotations(e,t,n,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,n,r)}restrictRotations(e,t,n,r){this.setEnabledRotations(e,t,n,r)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}additionalSolverIterations(){return this.rawSet.rbAdditionalSolverIterations(this.handle)}setAdditionalSolverIterations(e){this.rawSet.rbSetAdditionalSolverIterations(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return De.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Vi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return De.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Vi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let n=De.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,n,t),n.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let n=De.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,n,t),n.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return De.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return De.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}effectiveInvMass(){return De.fromRaw(this.rawSet.rbEffectiveInvMass(this.handle))}invMass(){return this.rawSet.rbInvMass(this.handle)}localCom(){return De.fromRaw(this.rawSet.rbLocalCom(this.handle))}worldCom(){return De.fromRaw(this.rawSet.rbWorldCom(this.handle))}invPrincipalInertiaSqrt(){return De.fromRaw(this.rawSet.rbInvPrincipalInertiaSqrt(this.handle))}principalInertia(){return De.fromRaw(this.rawSet.rbPrincipalInertia(this.handle))}principalInertiaLocalFrame(){return Vi.fromRaw(this.rawSet.rbPrincipalInertiaLocalFrame(this.handle))}effectiveWorldInvInertiaSqrt(){return IV.fromRaw(this.rawSet.rbEffectiveWorldInvInertiaSqrt(this.handle))}effectiveAngularInertia(){return IV.fromRaw(this.rawSet.rbEffectiveAngularInertia(this.handle))}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){return this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}setEnabled(e){this.rawSet.rbSetEnabled(this.handle,e)}isEnabled(){return this.rawSet.rbIsEnabled(this.handle)}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e,t){return this.rawSet.rbSetBodyType(this.handle,e,t)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,n,r,s){let o=De.intoRaw(t),a=De.intoRaw(n),l=Vi.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,s),o.free(),a.free(),l.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const n=De.intoRaw(e);this.rawSet.rbAddForce(this.handle,n,t),n.free()}applyImpulse(e,t){const n=De.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,n,t),n.free()}addTorque(e,t){const n=De.intoRaw(e);this.rawSet.rbAddTorque(this.handle,n,t),n.free()}applyTorqueImpulse(e,t){const n=De.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,n,t),n.free()}addForceAtPoint(e,t,n){const r=De.intoRaw(e),s=De.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,s,n),r.free(),s.free()}applyImpulseAtPoint(e,t,n){const r=De.intoRaw(e),s=De.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,s,n),r.free(),s.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Rope=3]="Rope",i[i.Spring=4]="Spring",i[i.Spherical=5]="Spherical",i[i.Generic=6]="Generic"})(Bs||(Bs={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(MV||(MV={})),function(i){i[i.X=1]="X",i[i.Y=2]="Y",i[i.Z=4]="Z",i[i.AngX=8]="AngX",i[i.AngY=16]="AngY",i[i.AngZ=32]="AngZ"}(TV||(TV={}));class Uh{constructor(){}static fixed(e,t,n,r){let s=new Uh;return s.anchor1=e,s.anchor2=n,s.frame1=t,s.frame2=r,s.jointType=Bs.Fixed,s}static spring(e,t,n,r,s){let o=new Uh;return o.anchor1=r,o.anchor2=s,o.length=e,o.stiffness=t,o.damping=n,o.jointType=Bs.Spring,o}static rope(e,t,n){let r=new Uh;return r.anchor1=t,r.anchor2=n,r.length=e,r.jointType=Bs.Rope,r}static generic(e,t,n,r){let s=new Uh;return s.anchor1=e,s.anchor2=t,s.axis=n,s.axesMask=r,s.jointType=Bs.Generic,s}static spherical(e,t){let n=new Uh;return n.anchor1=e,n.anchor2=t,n.jointType=Bs.Spherical,n}static prismatic(e,t,n){let r=new Uh;return r.anchor1=e,r.anchor2=t,r.axis=n,r.jointType=Bs.Prismatic,r}static revolute(e,t,n){let r=new Uh;return r.anchor1=e,r.anchor2=t,r.axis=n,r.jointType=Bs.Revolute,r}intoRaw(){let e,t,n=De.intoRaw(this.anchor1),r=De.intoRaw(this.anchor2),s=!1,o=0,a=0;switch(this.jointType){case Bs.Fixed:let l=Vi.intoRaw(this.frame1),c=Vi.intoRaw(this.frame2);t=Rs.fixed(n,l,r,c),l.free(),c.free();break;case Bs.Spring:t=Rs.spring(this.length,this.stiffness,this.damping,n,r);break;case Bs.Rope:t=Rs.rope(this.length,n,r);break;case Bs.Prismatic:e=De.intoRaw(this.axis),this.limitsEnabled&&(s=!0,o=this.limits[0],a=this.limits[1]),t=Rs.prismatic(n,r,e,s,o,a),e.free();break;case Bs.Generic:e=De.intoRaw(this.axis);let h=this.axesMask;t=Rs.generic(n,r,e,h);break;case Bs.Spherical:t=Rs.spherical(n,r);break;case Bs.Revolute:e=De.intoRaw(this.axis),t=Rs.revolute(n,r,e),e.free()}return n.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(tr||(tr={}));class ex{constructor(e,t,n,r,s){this.distance=e,this.point1=t,this.point2=n,this.normal1=r,this.normal2=s}static fromRaw(e){if(!e)return null;const t=new ex(e.distance(),De.fromRaw(e.point1()),De.fromRaw(e.point2()),De.fromRaw(e.normal1()),De.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(IO||(IO={}));class US{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new US(De.fromRaw(e.point()),e.isInside());return e.free(),t}}class Cxe{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class NS{constructor(e,t,n,r){this.featureType=IO.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),n!==void 0&&(this.featureType=n)}static fromRaw(e){if(!e)return null;const t=new NS(e.toi(),De.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class tx{constructor(e,t,n,r,s){this.toi=e,this.witness1=t,this.witness2=n,this.normal1=r,this.normal2=s}static fromRaw(e,t){if(!t)return null;const n=new tx(t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),n}}class qO extends tx{constructor(e,t,n,r,s,o){super(t,n,r,s,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const n=new qO(e.get(t.colliderHandle()),t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),n}}class Dr{static fromRaw(e,t){const n=e.coShapeType(t);let r,s,o,a,l,c,h;switch(n){case ns.Ball:return new TO(e.coRadius(t));case ns.Cuboid:return r=e.coHalfExtents(t),new PV(r.x,r.y,r.z);case ns.RoundCuboid:return r=e.coHalfExtents(t),s=e.coRoundRadius(t),new kV(r.x,r.y,r.z,s);case ns.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new OV(l,c);case ns.Segment:return o=e.coVertices(t),new LV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]));case ns.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new NV(o,a);case ns.Triangle:return o=e.coVertices(t),new FV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]));case ns.RoundTriangle:return o=e.coVertices(t),s=e.coRoundRadius(t),new UV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]),s);case ns.HalfSpace:return h=De.fromRaw(e.coHalfspaceNormal(t)),new Exe(h);case ns.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new QV(o,a);case ns.HeightField:const d=e.coHeightfieldScale(t),p=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),m=e.coHeightfieldNCols(t);return new zV(f,m,p,d);case ns.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new BO(o,a);case ns.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),s=e.coRoundRadius(t),new RO(o,a,s);case ns.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new jV(l,c);case ns.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),s=e.coRoundRadius(t),new GV(l,c,s);case ns.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new HV(l,c);case ns.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),s=e.coRoundRadius(t),new VV(l,c,s);default:throw new Error("unknown shape type: "+n)}}castShape(e,t,n,r,s,o,a,l,c){let h=De.intoRaw(e),d=Vi.intoRaw(t),p=De.intoRaw(n),f=De.intoRaw(s),m=Vi.intoRaw(o),A=De.intoRaw(a),v=this.intoRaw(),g=r.intoRaw(),y=tx.fromRaw(null,v.castShape(h,d,p,g,f,m,A,l,c));return h.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g.free(),y}intersectsShape(e,t,n,r,s){let o=De.intoRaw(e),a=Vi.intoRaw(t),l=De.intoRaw(r),c=Vi.intoRaw(s),h=this.intoRaw(),d=n.intoRaw(),p=h.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),h.free(),d.free(),p}contactShape(e,t,n,r,s,o){let a=De.intoRaw(e),l=Vi.intoRaw(t),c=De.intoRaw(r),h=Vi.intoRaw(s),d=this.intoRaw(),p=n.intoRaw(),f=ex.fromRaw(d.contactShape(a,l,p,c,h,o));return a.free(),l.free(),c.free(),h.free(),d.free(),p.free(),f}containsPoint(e,t,n){let r=De.intoRaw(e),s=Vi.intoRaw(t),o=De.intoRaw(n),a=this.intoRaw(),l=a.containsPoint(r,s,o);return r.free(),s.free(),o.free(),a.free(),l}projectPoint(e,t,n,r){let s=De.intoRaw(e),o=Vi.intoRaw(t),a=De.intoRaw(n),l=this.intoRaw(),c=US.fromRaw(l.projectPoint(s,o,a,r));return s.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,n,r){let s=De.intoRaw(t),o=Vi.intoRaw(n),a=De.intoRaw(e.origin),l=De.intoRaw(e.dir),c=this.intoRaw(),h=c.intersectsRay(s,o,a,l,r);return s.free(),o.free(),a.free(),l.free(),c.free(),h}castRay(e,t,n,r,s){let o=De.intoRaw(t),a=Vi.intoRaw(n),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),h=this.intoRaw(),d=h.castRay(o,a,l,c,r,s);return o.free(),a.free(),l.free(),c.free(),h.free(),d}castRayAndGetNormal(e,t,n,r,s){let o=De.intoRaw(t),a=Vi.intoRaw(n),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),h=this.intoRaw(),d=NS.fromRaw(h.castRayAndGetNormal(o,a,l,c,r,s));return o.free(),a.free(),l.free(),c.free(),h.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron",i[i.HalfSpace=17]="HalfSpace"})(zn||(zn={}));class TO extends Dr{constructor(e){super(),this.type=zn.Ball,this.radius=e}intoRaw(){return jt.ball(this.radius)}}class Exe extends Dr{constructor(e){super(),this.type=zn.HalfSpace,this.normal=e}intoRaw(){let e=De.intoRaw(this.normal),t=jt.halfspace(e);return e.free(),t}}class PV extends Dr{constructor(e,t,n){super(),this.type=zn.Cuboid,this.halfExtents=De.new(e,t,n)}intoRaw(){return jt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class kV extends Dr{constructor(e,t,n,r){super(),this.type=zn.RoundCuboid,this.halfExtents=De.new(e,t,n),this.borderRadius=r}intoRaw(){return jt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class OV extends Dr{constructor(e,t){super(),this.type=zn.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return jt.capsule(this.halfHeight,this.radius)}}class LV extends Dr{constructor(e,t){super(),this.type=zn.Segment,this.a=e,this.b=t}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=jt.segment(e,t);return e.free(),t.free(),n}}class FV extends Dr{constructor(e,t,n){super(),this.type=zn.Triangle,this.a=e,this.b=t,this.c=n}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=De.intoRaw(this.c),r=jt.triangle(e,t,n);return e.free(),t.free(),n.free(),r}}class UV extends Dr{constructor(e,t,n,r){super(),this.type=zn.RoundTriangle,this.a=e,this.b=t,this.c=n,this.borderRadius=r}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=De.intoRaw(this.c),r=jt.roundTriangle(e,t,n,this.borderRadius);return e.free(),t.free(),n.free(),r}}class NV extends Dr{constructor(e,t){super(),this.type=zn.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return jt.polyline(this.vertices,this.indices)}}class QV extends Dr{constructor(e,t){super(),this.type=zn.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return jt.trimesh(this.vertices,this.indices)}}class BO extends Dr{constructor(e,t){super(),this.type=zn.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?jt.convexMesh(this.vertices,this.indices):jt.convexHull(this.vertices)}}class RO extends Dr{constructor(e,t,n){super(),this.type=zn.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=n}intoRaw(){return this.indices?jt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):jt.roundConvexHull(this.vertices,this.borderRadius)}}class zV extends Dr{constructor(e,t,n,r){super(),this.type=zn.HeightField,this.nrows=e,this.ncols=t,this.heights=n,this.scale=r}intoRaw(){let e=De.intoRaw(this.scale),t=jt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class jV extends Dr{constructor(e,t){super(),this.type=zn.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return jt.cylinder(this.halfHeight,this.radius)}}class GV extends Dr{constructor(e,t,n){super(),this.type=zn.RoundCylinder,this.borderRadius=n,this.halfHeight=e,this.radius=t}intoRaw(){return jt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class HV extends Dr{constructor(e,t){super(),this.type=zn.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return jt.cone(this.halfHeight,this.radius)}}class VV extends Dr{constructor(e,t,n){super(),this.type=zn.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=n}intoRaw(){return jt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(BV||(BV={})),function(i){i[i.NONE=0]="NONE",i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(AS||(AS={}));class Sxe{free(){this.raw&&this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return De.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return De.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Ixe{constructor(e,t){this.raw=t||new xxe(e)}free(){this.raw&&this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Sxe;this.raw.drainContactForceEvents(n=>{t.raw=n,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.NONE=0]="NONE",i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(MO||(MO={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(RV||(RV={})),function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"}(vS||(vS={}));class WV{constructor(e,t,n,r){this.colliderSet=e,this.handle=t,this._parent=n,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=Dr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return De.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Vi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setEnabled(e){this.colliderSet.raw.coSetEnabled(this.handle,e)}isEnabled(){return this.colliderSet.raw.coIsEnabled(this.handle)}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,n,r){let s=De.intoRaw(t),o=De.intoRaw(n),a=Vi.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,s,o,a),s.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return De.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}setHalfExtents(e){const t=De.intoRaw(e);this.colliderSet.raw.coSetHalfExtents(this.handle,t)}radius(){return this.colliderSet.raw.coRadius(this.handle)}setRadius(e){this.colliderSet.raw.coSetRadius(this.handle,e)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}setRoundRadius(e){this.colliderSet.raw.coSetRoundRadius(this.handle,e)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}setHalfHeight(e){this.colliderSet.raw.coSetHalfHeight(this.handle,e)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return De.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=De.intoRaw(e),n=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),n}projectPoint(e,t){let n=De.intoRaw(e),r=US.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,n,t));return n.free(),r}intersectsRay(e,t){let n=De.intoRaw(e.origin),r=De.intoRaw(e.dir),s=this.colliderSet.raw.coIntersectsRay(this.handle,n,r,t);return n.free(),r.free(),s}castShape(e,t,n,r,s,o,a){let l=De.intoRaw(e),c=De.intoRaw(n),h=Vi.intoRaw(r),d=De.intoRaw(s),p=t.intoRaw(),f=tx.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,l,p,c,h,d,o,a));return l.free(),c.free(),h.free(),d.free(),p.free(),f}castCollider(e,t,n,r,s){let o=De.intoRaw(e),a=De.intoRaw(n),l=qO.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,o,t.handle,a,r,s));return o.free(),a.free(),l}intersectsShape(e,t,n){let r=De.intoRaw(t),s=Vi.intoRaw(n),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,s);return r.free(),s.free(),o.free(),a}contactShape(e,t,n,r){let s=De.intoRaw(t),o=Vi.intoRaw(n),a=e.intoRaw(),l=ex.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,s,o,r));return s.free(),o.free(),a.free(),l}contactCollider(e,t){return ex.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,n){let r=De.intoRaw(e.origin),s=De.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,s,t,n);return r.free(),s.free(),o}castRayAndGetNormal(e,t,n){let r=De.intoRaw(e.origin),s=De.intoRaw(e.dir),o=NS.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,s,t,n));return r.free(),s.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(DA||(DA={}));class hn{constructor(e){this.enabled=!0,this.shape=e,this.massPropsMode=DA.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Vi.identity(),this.translation=De.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=tr.Average,this.restitutionCombineRule=tr.Average,this.activeCollisionTypes=vS.DEFAULT,this.activeEvents=AS.NONE,this.activeHooks=MO.NONE,this.mass=0,this.centerOfMass=De.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=De.zeros(),this.angularInertiaLocalFrame=Vi.identity()}static ball(e){const t=new TO(e);return new hn(t)}static capsule(e,t){const n=new OV(e,t);return new hn(n)}static segment(e,t){const n=new LV(e,t);return new hn(n)}static triangle(e,t,n){const r=new FV(e,t,n);return new hn(r)}static roundTriangle(e,t,n,r){const s=new UV(e,t,n,r);return new hn(s)}static polyline(e,t){const n=new NV(e,t);return new hn(n)}static trimesh(e,t){const n=new QV(e,t);return new hn(n)}static cuboid(e,t,n){const r=new PV(e,t,n);return new hn(r)}static roundCuboid(e,t,n,r){const s=new kV(e,t,n,r);return new hn(s)}static heightfield(e,t,n,r){const s=new zV(e,t,n,r);return new hn(s)}static cylinder(e,t){const n=new jV(e,t);return new hn(n)}static roundCylinder(e,t,n){const r=new GV(e,t,n);return new hn(r)}static cone(e,t){const n=new HV(e,t);return new hn(n)}static roundCone(e,t,n){const r=new VV(e,t,n);return new hn(r)}static convexHull(e){const t=new BO(e,null);return new hn(t)}static convexMesh(e,t){const n=new BO(e,t);return new hn(n)}static roundConvexHull(e,t){const n=new RO(e,null,t);return new hn(n)}static roundConvexMesh(e,t,n){const r=new RO(e,t,n);return new hn(r)}setTranslation(e,t,n){if(typeof e!="number"||typeof t!="number"||typeof n!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:n},this}setRotation(e){return Vi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setEnabled(e){return this.enabled=e,this}setDensity(e){return this.massPropsMode=DA.Density,this.density=e,this}setMass(e){return this.massPropsMode=DA.Mass,this.mass=e,this}setMassProperties(e,t,n,r){return this.massPropsMode=DA.MassProps,this.mass=e,De.copy(this.centerOfMass,t),De.copy(this.principalAngularInertia,n),Vi.copy(this.angularInertiaLocalFrame,r),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}for(var $xe={byteLength:function(i){var e=qV(i),t=e[0],n=e[1];return 3*(t+n)/4-n},toByteArray:function(i){var e,t,n=qV(i),r=n[0],s=n[1],o=new Mxe(function(c,h,d){return 3*(h+d)/4-d}(0,r,s)),a=0,l=s>0?r-4:r;for(t=0;t<l;t+=4)e=La[i.charCodeAt(t)]<<18|La[i.charCodeAt(t+1)]<<12|La[i.charCodeAt(t+2)]<<6|La[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return s===2&&(e=La[i.charCodeAt(t)]<<2|La[i.charCodeAt(t+1)]>>4,o[a++]=255&e),s===1&&(e=La[i.charCodeAt(t)]<<10|La[i.charCodeAt(t+1)]<<4|La[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,n=t%3,r=[],s=16383,o=0,a=t-n;o<a;o+=s)r.push(Bxe(i,o,o+s>a?a:o+s));return n===1?(e=i[t-1],r.push(Sc[e>>2]+Sc[e<<4&63]+"==")):n===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Sc[e>>10]+Sc[e>>4&63]+Sc[e<<2&63]+"=")),r.join("")}},Sc=[],La=[],Mxe=typeof Uint8Array<"u"?Uint8Array:Array,DO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",PA=0,Txe=DO.length;PA<Txe;++PA)Sc[PA]=DO[PA],La[DO.charCodeAt(PA)]=PA;function qV(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Bxe(i,e,t){for(var n,r,s=[],o=e;o<t;o+=3)n=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),s.push(Sc[(r=n)>>18&63]+Sc[r>>12&63]+Sc[r>>6&63]+Sc[63&r]);return s.join("")}La["-".charCodeAt(0)]=62,La["_".charCodeAt(0)]=63;const Rxe=Symbol("object"),PO=new ra(()=>new E,20);class XV{constructor(e,t,n,r,s,o){u(this,"_point"),u(this,"_normal"),u(this,"_tangentVelocity"),u(this,"distance"),u(this,"impulse"),u(this,"friction"),this._point=e,this.distance=t,this._normal=n,this.impulse=r,this.friction=s,this._tangentVelocity=o}get point(){return PO.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return PO.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return PO.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class YV{constructor(e,t,n){u(this,"contacts"),u(this,"me"),u(this,"_collider"),u(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=n}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class JV{constructor(e,t){u(this,"object"),u(this,"collider"),this.object=e,this.collider=t}}const rs=ee("debugphysics"),kO=ee("debugcolliderplacement"),OO=ee("debugcollisions"),Dxe=ee("showcolliders"),LO=ee("debugraycasts"),wo=Symbol("needle component"),io=Symbol("physics body"),KV=Symbol("rigidbody");let Ff;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,rs&&console.log("Use Rapier",!1,globalThis.false);const yS=class{constructor(){u(this,"debugRenderColliders",!1),u(this,"debugRenderRaycasts",!1),u(this,"context"),u(this,"_initializePromise"),u(this,"_isInitialized",!1),u(this,"rapierRay",new Cxe({x:0,y:0,z:0},{x:0,y:0,z:1})),u(this,"raycastVectorsBuffer",new ra(()=>new E,10)),u(this,"rapierSphere",null),u(this,"rapierColliderArray",[]),u(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1}),u(this,"rapierForwardVector",{x:0,y:0,z:1}),u(this,"enabled",!1),u(this,"_tempPosition",new E),u(this,"_tempQuaternion",new Ce),u(this,"_tempScale",new E),u(this,"_tempMatrix",new ge),u(this,"_isUpdatingPhysicsWorld",!1),u(this,"_world"),u(this,"_hasCreatedWorld",!1),u(this,"eventQueue"),u(this,"collisionHandler"),u(this,"objects",[]),u(this,"bodies",[]),u(this,"_meshCache",new Map),u(this,"_gravity",{x:0,y:-9.81,z:0}),u(this,"lines"),u(this,"_tempCenterPos",new E),u(this,"_tempCenterVec",new E),u(this,"_tempCenterQuaternion",new Ce)}removeBody(i){var e,t,n;if(!i)return;this.validate();const r=i[io];if(i[io]=null,r&&this.world){const s=this.objects.findIndex(o=>o===i);if(s>=0){const o=this.bodies[s];if(this.bodies.splice(s,1),this.objects.splice(s,1),o instanceof WV){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[wo]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof DV&&(o.numColliders()<=0?(n=this.world)==null||n.removeRigidBody(o):rt()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const n=i,r=n[io];r&&this.syncPhysicsBody(n.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[io];t&&(this.internalUpdateColliderProperties(e,t),e.sharedMaterial&&this.updatePhysicsMaterial(e))}else{const e=i,t=this.internal_getRigidbody(e);t&&this.internalUpdateRigidbodyProperties(e,t)}}addForce(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.addForce(e,t):console.warn("Rigidbody doesn't exist: can not apply force")}addImpulse(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.applyImpulse(e,t):console.warn("Rigidbody doesn't exist: can not apply impulse")}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.applyImpulse(e,t):console.warn("Rigidbody doesn't exist: can not apply impulse")}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?e.wakeUp():console.warn("Rigidbody doesn't exist: can not wake up")}isSleeping(i){this.validate();const e=this.internal_getRigidbody(i);return e?.isSleeping()}setAngularVelocity(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.setAngvel(e,t):console.warn("Rigidbody doesn't exist: can not set angular velocity")}setLinearVelocity(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.setLinvel(e,t):console.warn("Rigidbody doesn't exist: can not set linear velocity")}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return rs&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&rs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||rs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t){var n;let r=t?.maxDistance,s=t?.solid;r===void 0&&(r=1/0),s===void 0&&(s=!0);const o=this.getPhysicsRay(this.rapierRay,i,e);if(!o)return null;(this.debugRenderRaycasts||LO)&&At.DrawRay(o.origin,o.dir,255,1);const a=(n=this.world)==null?void 0:n.castRay(o,r,s,t?.queryFilterFlags,t?.filterGroups,void 0,void 0,l=>{const c=l[wo];return t!=null&&t.filterPredicate?t.filterPredicate(c):!(c!=null&&c.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),c=this.raycastVectorsBuffer.get();return c.set(l.x,l.y,l.z),{point:c,collider:a.collider[wo]}}return null}raycastAndGetNormal(i,e,t){var n;let r=t?.maxDistance,s=t?.solid;r===void 0&&(r=1/0),s===void 0&&(s=!0);const o=this.getPhysicsRay(this.rapierRay,i,e);if(!o)return null;(this.debugRenderRaycasts||LO)&&At.DrawRay(o.origin,o.dir,255,1);const a=(n=this.world)==null?void 0:n.castRayAndGetNormal(o,r,s,t?.queryFilterFlags,t?.filterGroups,void 0,void 0,l=>{const c=l[wo];return t!=null&&t.filterPredicate?t.filterPredicate(c):!(c!=null&&c.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),c=a.normal,h=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return h.set(l.x,l.y,l.z),d.set(c.x,c.y,c.z),{point:h,normal:d,collider:a.collider[wo]}}return null}getPhysicsRay(i,e,t){var n,r,s;const o=(n=this.context)==null?void 0:n.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(rs&&console.warn("Converting screenspace to raycast space",c),(s=this.context)==null||s.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=Tt(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new TO(e)),this.rapierSphere.radius=e,(this.debugRenderRaycasts||LO)&&At.DrawWireSphere(i,e,3359999,1),this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const n=t[wo],r=new JV(n.gameObject,n);return this.rapierColliderArray.push(r),!0},void 0,void 0,void 0,void 0,t=>t.isSensor()?!1:t[wo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,n;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((n=this.world)==null||n.free())}async addBoxCollider(i,e){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const t=i.gameObject,n=zi(t,this._tempPosition).multiply(e);n.multiplyScalar(.5),n.x<0&&(n.x=Math.abs(n.x)),n.y<0&&(n.y=Math.abs(n.y)),n.z<0&&(n.z=Math.abs(n.z)),n.x==0&&(n.x=1e-7),n.y==0&&(n.y=1e-7),n.z==0&&(n.z=1e-7);const r=hn.cuboid(n.x,n.y,n.z);this.createCollider(i,r)}async addSphereCollider(i){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const e=hn.ball(.5);this.createCollider(i,e),this.updateProperties(i)}async addCapsuleCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const n=i.gameObject,r=zi(n,this._tempPosition);r.x=Math.abs(r.x),r.y=Math.abs(r.y);const s=t*r.x;e=Math.max(e,s*2);const o=$e.clamp(e*.5*r.y-t*r.x,0,Number.MAX_SAFE_INTEGER),a=hn.capsule(o,s);this.createCollider(i,a)}async addMeshCollider(i,e,t,n){var r,s,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){rs&&console.warn("Missing mesh geometry",e.name);return}(s=(r=a.index)==null?void 0:r.array)!=null&&s.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=Cae(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(n.x-1)>1e-4||Math.abs(n.y-1)>1e-4||Math.abs(n.z-1)>1e-4){const d=a.uuid+"_"+n.x+"_"+n.y+"_"+n.z+"_"+t;if(this._meshCache.has(d))rs&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{(rs||rt())&&console.warn(`Your MeshCollider "${i.name}" is scaled: consider applying the scale to the collider mesh instead (${n.x}, ${n.y}, ${n.z})`);const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*n.x,p[f+1]=l[f+1]*n.y,p[f+2]=l[f+2]*n.z;l=p,this._meshCache.set(d,p)}}const h=t?hn.convexHull(l):hn.trimesh(l,c);h&&this.createCollider(i,h)}updatePhysicsMaterial(i){if(!i)return;const e=i.sharedMaterial,t=i[io];if(t&&e){if(e.bounciness!==void 0&&t.setRestitution(e.bounciness),e.bounceCombine!==void 0)switch(e.bounceCombine){case Er.Average:t.setRestitutionCombineRule(tr.Average);break;case Er.Maximum:t.setRestitutionCombineRule(tr.Max);break;case Er.Minimum:t.setRestitutionCombineRule(tr.Min);break;case Er.Multiply:t.setRestitutionCombineRule(tr.Multiply);break}if(e.dynamicFriction!==void 0&&t.setFriction(e.dynamicFriction),e.frictionCombine!==void 0)switch(e.frictionCombine){case Er.Average:t.setFrictionCombineRule(tr.Average);break;case Er.Maximum:t.setFrictionCombineRule(tr.Max);break;case Er.Minimum:t.setFrictionCombineRule(tr.Min);break;case Er.Multiply:t.setFrictionCombineRule(tr.Multiply);break}}}getBody(i){return i?i[io]:null}getComponent(i){return i?i[wo]:null}createCollider(i,e){var t;if(!this.world)throw new Error("Physics world not initialized");const n=this._tempMatrix;let r;i.attachedRigidbody?r=this.getRigidbody(i,this._tempMatrix):(rs&&console.log("Create collider without rigidbody",i.name),n.makeRotationFromQuaternion(Ti(i.gameObject)),n.setPosition(Tt(i.gameObject))),n.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),this.tryApplyCenter(i,this._tempPosition),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const s=i.sharedMaterial;if(s){if(s.bounciness!==void 0&&e.setRestitution(s.bounciness),s.bounceCombine!==void 0)switch(s.bounceCombine){case Er.Average:e.setRestitutionCombineRule(tr.Average);break;case Er.Maximum:e.setRestitutionCombineRule(tr.Max);break;case Er.Minimum:e.setRestitutionCombineRule(tr.Min);break;case Er.Multiply:e.setRestitutionCombineRule(tr.Multiply);break}if(s.dynamicFriction!==void 0&&e.setFriction(s.dynamicFriction),s.frictionCombine!==void 0)switch(s.frictionCombine){case Er.Average:e.setFrictionCombineRule(tr.Average);break;case Er.Maximum:e.setFrictionCombineRule(tr.Max);break;case Er.Minimum:e.setFrictionCombineRule(tr.Min);break;case Er.Multiply:e.setFrictionCombineRule(tr.Multiply);break}}((t=i.attachedRigidbody)==null?void 0:t.autoMass)===!1&&(e.setDensity(1e-6),e.setMass(1e-6));try{const o=this.world.createCollider(e,r);return o[wo]=i,i[io]=o,o.setActiveEvents(AS.COLLISION_EVENTS),o.setActiveCollisionTypes(vS.ALL),this.objects.push(i),this.bodies.push(o),this.updateColliderCollisionGroups(i),o}catch(o){return console.error('Error creating collider "'+i.name+`"
7502
- Error:`,o),null}}updateColliderCollisionGroups(i){const e=i[io],t=i.membership;let n=0;if(t==null)n=65535;else for(let o=0;o<t.length;o++){const a=t[o];a>31?console.error(`Rapier only supports 32 layers, layer ${a} is not supported`):n|=1<<Math.floor(a)}const r=i.filter;let s=0;if(r==null)s=65535;else for(let o=0;o<r.length;o++){const a=r[o];a>31?console.error(`Rapier only supports 32 layers, layer ${a} is not supported`):s|=1<<Math.floor(a)}e.setCollisionGroups(n<<16|s)}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null;if(i.attachedRigidbody){const n=i.attachedRigidbody;if(t=n[io],!t){const r=n.isKinematic&&!kO;rs&&console.log("Create rigidbody",r);const s=r?Ff.RigidBodyDesc.kinematicPositionBased():Ff.RigidBodyDesc.dynamic(),o=Tt(i.attachedRigidbody.gameObject);s.setTranslation(o.x,o.y,o.z),s.setRotation(Ti(i.attachedRigidbody.gameObject)),s.centerOfMass=new Ff.Vector3(n.centerOfMass.x,n.centerOfMass.y,n.centerOfMass.z),t=this.world.createRigidBody(s),this.bodies.push(t),this.objects.push(n)}t[wo]=n,n[io]=t,this.internalUpdateRigidbodyProperties(n,t),this.getRigidbodyRelativeMatrix(i.gameObject,n.gameObject,e),i[KV]=t}else{const n=Ff.RigidBodyDesc.kinematicPositionBased(),r=Tt(i.gameObject);n.setTranslation(r.x,r.y,r.z),n.setRotation(Ti(i.gameObject)),t=this.world.createRigidBody(n),e.identity(),t[wo]=null}return t}internal_getRigidbody(i){return i.isCollider===!0?i[KV]:i[io]}internalUpdateColliderProperties(i,e){const t=e.shape;let n=!1;switch(t.type){case zn.Ball:{const d=t,p=i,f=i.gameObject,m=zi(f,this._tempPosition),A=Math.abs(p.radius*m.x);n=d.radius!==A,d.radius=A,n&&e.setShape(d);break}case zn.Cuboid:const r=t,s=i,o=i.gameObject,a=zi(o,this._tempPosition),l=s.size.x*.5*a.x,c=s.size.y*.5*a.y,h=s.size.z*.5*a.z;n=r.halfExtents.x!==l||r.halfExtents.y!==c||r.halfExtents.z!==h,r.halfExtents.x=l,r.halfExtents.y=c,r.halfExtents.z=h,n&&e.setShape(r);break}if(n){const r=i.attachedRigidbody;if(r!=null&&r.autoMass){const s=this.getBody(r);s?.recomputeMassPropertiesFromColliders()}}this.updateColliderCollisionGroups(i),i.isTrigger!==e.isSensor()&&e.setSensor(i.isTrigger)}internalUpdateRigidbodyProperties(i,e){if(e.enableCcd(i.collisionDetectionMode!==EC.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),i.dominanceGroup<=127&&i.dominanceGroup>=-127?e.setDominanceGroup(Math.floor(i.dominanceGroup)):e.setDominanceGroup(0),i.autoMass){e.setAdditionalMass(0,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1);e.recomputeMassPropertiesFromColliders()}else{e.setAdditionalMass(i.mass,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1e-7);e.recomputeMassPropertiesFromColliders()}e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!1),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!1),i.isKinematic?e.setBodyType(Ff.RigidBodyType.KinematicPositionBased,!1):e.setBodyType(Ff.RigidBodyType.Dynamic,!1)}step(i){if(this.world&&this.enabled){if(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Ixe(!1)),i===void 0||i<=0){this._isUpdatingPhysicsWorld=!1;return}else i!==void 0&&(this.world.timestep=$e.lerp(this.world.timestep,i,.8));try{this.world.step(this.eventQueue)}catch(e){console.warn("Error running physics step",e)}this._isUpdatingPhysicsWorld=!1}}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Pxe(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()),this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,n,r;if(rs||kO||Dxe||this.debugRenderColliders===!0){if(!this.lines){const o=new Xi({color:7855479,fog:!1}),a=new gt;this.lines=new Ns(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const s=i.debugRender();this.lines.geometry.setAttribute("position",new et(s.vertices,3)),this.lines.geometry.setAttribute("color",new et(s.colors,4)),(this.context.time.frame%30===0||((n=this.lines.geometry.boundingSphere)==null?void 0:n.radius)===0)&&this.lines.geometry.computeBoundingSphere()}else this.lines&&((r=this.context)==null||r.scene.remove(this.lines))}syncObjects(){if(!kO)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],n=e;if(n?.isCollider===!0&&!n.attachedRigidbody){const a=t.parent();a?this.syncPhysicsBody(e.gameObject,a,!0,!0):this.syncPhysicsBody(e.gameObject,t,!0,!0);continue}const r=t.translation(),s=t.rotation();if(Number.isNaN(r.x)||Number.isNaN(s.x)){!n.__COLLIDER_NAN&&rt()&&(console.warn("Collider has NaN values",n.name,n.gameObject,t),n.__COLLIDER_NAN=!0);continue}const o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(s.x,s.y,s.z,s.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion),l=zi(e.gameObject);a.multiply(l),r.x-=a.x,r.y-=a.y,r.z-=a.z}pp(e.gameObject,r.x,r.y,r.z),nB(e.gameObject,s.x,s.y,s.z,s.w)}}syncPhysicsBody(i,e,t,n){if(e instanceof DV){const r=Tt(i,this._tempPosition),s=Ti(i,this._tempQuaternion);switch(e.bodyType()){case Wb.Fixed:case Wb.KinematicPositionBased:case Wb.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),n&&e.setNextKinematicRotation(s);break;default:t&&e.setTranslation(r,!1),n&&e.setRotation(s,!1);break}}else if(e instanceof WV){const r=Tt(i,this._tempPosition),s=Ti(i,this._tempQuaternion),o=e[wo];if(this.tryApplyCenter(o,r),t){const a=e.translation();(a.x!==r.x||a.y!==r.y||a.z!==r.z)&&e.setTranslation(r)}if(n){const a=e.rotation();(a.x!==s.x||a.y!==s.y||a.z!==s.z||a.w!==s.w)&&e.setRotation(s)}}}tryApplyCenter(i,e){const t=i.center;t&&i.gameObject&&(t.x!==0||t.y!==0||t.z!==0)&&(this._tempCenterPos.x=-t.x,this._tempCenterPos.y=t.y,this._tempCenterPos.z=t.z,zi(i.gameObject,this._tempCenterVec),this._tempCenterPos.multiply(this._tempCenterVec),i.attachedRigidbody?this._tempCenterPos.applyQuaternion(i.gameObject.quaternion):(Ti(i.gameObject,this._tempCenterQuaternion),this._tempCenterPos.applyQuaternion(this._tempCenterQuaternion)),e.x+=this._tempCenterPos.x,e.y+=this._tempCenterPos.y,e.z+=this._tempCenterPos.z)}getRigidbodyRelativeMatrix(i,e,t,n){if(n===void 0&&(n=yS._matricesBuffer,n.length=0),i===e){const r=zi(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let s=n.length-1;s>=0;s--)t.multiply(n[s]);return t}return n.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,n),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[io],n=e[io];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=Uh.fixed(yS.centerConnectionPos,yS.centerConnectionRot,this._tempPosition,this._tempQuaternion),s=this.world.createImpulseJoint(r,t,n,!0);rs&&console.log("ADD FIXED JOINT",s)}addHingeJoint(i,e,t,n){if(!this.world){console.error("Physics world not initialized");return}const r=i[io],s=e[io];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=Ff.JointData.revolute(t,this._tempPosition,n),a=this.world.createImpulseJoint(o,r,s,!0);rs&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const n=i.matrixWorld,r=e.matrixWorld;n.elements[0]=1,n.elements[5]=1,n.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,t.copy(r).premultiply(n.invert()).invert()}};let qb=yS;u(qb,"_didLoadPhysicsEngine",!1),u(qb,"_matricesBuffer",[]),u(qb,"centerConnectionPos",{x:0,y:0,z:0}),u(qb,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Pxe{constructor(e,t){u(this,"world"),u(this,"eventQueue"),u(this,"activeCollisions",[]),u(this,"activeCollisionsStay",[]),u(this,"activeTriggers",[]),this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,n)=>{const r=this.world.getCollider(e),s=this.world.getCollider(t);if(!r||!s)return;const o=r[wo],a=s[wo];OO&&console.log("EVT",o.name,a.name,n,r,s),o&&a&&(n?(this.onCollisionStarted(o,r,a,s),this.onCollisionStarted(a,s,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,n,r){let s=null;if(e.isTrigger||n.isTrigger)Vp(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(n),this.activeTriggers.push({collider:e,component:o,otherCollider:n})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{Vp(o,c=>{var h;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||OO){if(!s){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),y=a.solverContactFriction(m),b=a.solverContactTangentVelocity(m),x=new XV(A,g,f,v,y,b);p.push(x),OO&&At.DrawDirection(A,f,16711680,3,!0)}}s=new YV(o,n,p)}if(d){const p={collider:e,component:c,collision:s};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(h=c.onCollisionEnter)==null||h.call(c,s)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){if(e.collision.collider.destroyed)continue;const n=e.collision;t.onCollisionStay(n)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const n=e.otherCollider;if(n.destroyed)continue;t.onTriggerStay(n)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let n=0;n<this.activeCollisions.length;n++){const r=this.activeCollisions[n],s=r.collider;if(s.destroyed||r.collision.collider.destroyed){this.activeCollisions.splice(n,1),n--;continue}if(s===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(n,1),n--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let n=0;n<this.activeCollisionsStay.length;n++){const r=this.activeCollisionsStay[n],s=r.collider;if(s.destroyed||r.collision.collider.destroyed){this.activeCollisionsStay.splice(n,1),n--;continue}if(s===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(n,1),n--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let n=0;n<this.activeTriggers.length;n++){const r=this.activeTriggers[n],s=r.collider;if(s.destroyed||r.otherCollider.destroyed){this.activeTriggers.splice(n,1),n--;continue}if(s===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(n,1),n--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}class kxe{static async createComparisonScene(e){const{files:t}=e,n=await Promise.all(t.map(m=>new ti(m).loadAssetAsync())),r=new Fr;let s=0;for(const m of n)if(m instanceof ve){m.position.y=s,r.add(m);const A=lu([m]);s+=A.getSize(new E).y,s+=.1}const o=new Dt(20);r.add(o);const a=e.environment||"https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/studio_small_09_1k.exr";if(a){let m=null;if(a.endsWith(".hdr")){const A=(await Promise.resolve().then(()=>Fde)).RGBELoader;m=new A}else if(a.endsWith(".exr")){const A=(await Promise.resolve().then(()=>Lde)).EXRLoader;m=new A}if(m){const A=await m.loadAsync(a).catch(v=>(console.error(v),null));A&&(A.mapping=ro,A.needsUpdate=!0,r.background=A,r.environment=A,r.backgroundBlurriness=.75)}else console.warn("Unsupported environment map format",a)}const l=lu(r.children),c=l.getCenter(new E),h=l.getSize(new E),d=Math.max(h.x,h.y,h.z)/(2*Math.tan(Math.PI*o.fov/360));o.position.set(c.x,c.y,d),o.lookAt(c);const p=new y8(o,e.domElement||document.body);p.target=c,p.update();const f=(e.domElement||document.body).getBoundingClientRect();return o.aspect=f.width/f.height,o.updateProjectionMatrix(),{scene:r,camera:o}}}function Oxe(i,e,t,n="image/webp",r){return ZV({context:i,width:e,height:t,mimeType:n,camera:r})}function ZV(i={mimeType:"image/png",transparent:!1}){i||(i={});let{context:e,width:t,height:n,camera:r}=i;const{mimeType:s}=i;if(!e&&(e=hi.Current,!e))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=e.mainCamera,!r))return console.error("No camera found"),null;const o=e.renderer.domElement.width,a=e.renderer.domElement.height;t||(t=o),n||(n=a);const l=window.devicePixelRatio||1;t/=l,n/=l,e.renderer.domElement.style.width=t+"px",e.renderer.domElement.style.height=n+"px";const c=e.renderer.getClearColor(new _e);try{i!=null&&i.transparent&&e.renderer.setClearColor(0,0);const h=e.renderer.domElement;e.renderer.setSize(t,n,!1),r instanceof Dt&&e.updateAspect(r,t,n);const d=i.render_events!==!1,p=new Array;d&&(kg(e.scene,Mn,p),p.forEach(m=>m?.onBeforeRender())),e.renderNow(),d&&p.forEach(m=>m.onAfterRender());const f=h.toDataURL(s);return i.download_filename&&$V(f,i.download_filename),f}finally{e.renderer.setSize(o,a,!1),e.updateSize(),e.renderer.setClearColor(c)}return null}let Xb=null;function $V(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Xb||(Xb=document.createElement("a")),Xb.href=i,Xb.download=e,Xb.click()}}let FO=0;function eW(i){i?FO++:FO--}function Lxe(){return FO>0}class tW{constructor(e){u(this,"writer"),this.writer=e}writeNode(e){}}class Fxe extends tW{beforeWriteNode(e,t){At.isGizmo(e)&&(t.keep=!1)}}class Uxe extends tW{beforeWriteTexture(e,t){e.isRenderTargetTexture&&(t.newTexture=UD(new wi(1,1,1,0)))}}const Nxe={binary:!0,animations:!0};async function Qxe(i){if(!i.context)throw new Error("No context provided to exportAsGLTF");i.scene||(i.scene=i.context.scene);const e={...Nxe,...i},{context:t}=e,n=new RE;n.register(a=>new X6(a)),n.register(a=>new Fxe(a)),n.register(a=>new Uxe(a)),ZP(n,e.context);const r={binary:e.binary,animations:jxe(t,e.scene,[])},s=new zxe;console.log("Exporting GLTF",r),s.onBeforeExport(e),eW(!0);const o=await n.parseAsync(e.scene,r).catch(a=>(console.error(a),null));if(eW(!1),s.onAfterExport(e),!o)throw new Error("Failed to export GLTF");if(e.downloadAs!=null){let a=null;if(o instanceof ArrayBuffer?a=new Blob([o],{type:"application/octet-stream"}):console.error("Can not download GLTF as a blob",o),a){const l=URL.createObjectURL(a),c=document.createElement("a");c.href=l;let h=e.downloadAs;!h.endsWith(".glb")&&!h.endsWith(".gltf")&&(h+=e.binary?".glb":".gltf"),c.download=h,c.click()}}return o}const iW=Symbol("needle:weight");class zxe{constructor(){u(this,"_undo",[])}onBeforeExport(e){e.context.animations.mixers.forEach(t=>{const n=zv.tryGetActionsFromMixer(t);if(n)for(let r=0;r<n.length;r++){const s=n[r];s[iW]=s.weight,s.weight=0,this._undo.push(()=>{s.weight=s[iW]})}t.update(0)})}onAfterExport(e){this._undo.forEach(t=>t()),this._undo.length=0}}function jxe(i,e,t){i.animations.mixers.forEach(r=>{const s=zv.tryGetActionsFromMixer(r);if(s)for(let o=0;o<s.length;o++){const a=s[o].getClip();t.push(a)}}),Array.isArray(e)||(e=[e]);for(const r of e)zv.tryGetAnimationClipsFromObjectHierarchy(r,t);const n=new Set(t);return Array.from(n)}Object.defineProperty(Dt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(Dt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(Dt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});const bS=ee("debugmissingcamera");hi.registerCallback(Ei.MissingCamera,i=>{var e,t,n;bS&&console.warn("Creating missing camera");const r=i.context.scene,s=new Dt;s.name="Default Fallback Camera",r.add(s);const o=new Ni;o.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",(n=i.context.domElement.getAttribute("skybox-image"))!=null&&n.length||0>0||i.context.lightmaps.tryGetSkybox(o.sourceId)?o.clearFlags=Zp.Skybox:o.clearFlags=Zp.SolidColor,o.backgroundColor=new wi(.5,.5,.5,1),o.fieldOfView=35,o.backgroundBlurriness=.2;const a=Wp(s,o,!0);s.position.x=0,s.position.y=1,s.position.z=2;const l=i.context.domElement;return l?.cameraControls!=!1&&nW(i.context,a),a}),hi.registerCallback(Ei.ContextCreated,i=>{if(!i.context.mainCamera){bS&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls==!0){const t=j3(i.context.mainCamera);if(t?.isCameraController==!0){bS&&console.log("Will not auto-fit because a camera controller exists");return}nW(i.context)}});function nW(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(bS&&console.log("Creating default camera controls",e?.name),t){const n=ay(t,vi);n.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");n.autoRotate=r!==void 0&&(r===""||r==="true"),n.autoRotateSpeed=.5,n.autoFit=!0}else console.warn("Missing camera object, can not add orbit controls")}const UO={Context:kt,glTF:{loadFromURL:EO}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=UO;function rW(i){for(const e in i)UO[e]=i[e]}rW(fpe),rW(Kbe);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:UO[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=BZ;class Gxe{constructor(e){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Backoff must be a positive integer");this.backoff=e}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class Hxe{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}class Vxe{constructor(e,t,n){if(this.i=0,this._retries=0,e<0)throw new Error("Initial must be a positive number or zero");if(t<0)throw new Error("Increment must be a positive number or zero");if(n!==void 0&&n<0)throw new Error("Max must be undefined, a positive number or zero");if(n!==void 0&&n<e)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=e,this.increment=t,this.max=n}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class Wxe{constructor(){this.elements=[]}add(e){this.elements.push(e)}clear(){this.elements.length=0}forEach(e){this.elements.forEach(e)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class qxe{constructor(e){if(!Number.isInteger(e)||e<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(e+1),this.head=0,this.tail=0}add(e){this.elements[this.head]=e,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(e){for(let t=this.tail;t!==this.head;t=(t+1)%this.elements.length)e(this.elements[t])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const e=this.peek();return e!==void 0&&(this.tail=(this.tail+1)%this.elements.length),e}}var Oi;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry",i.reconnect="reconnect"})(Oi||(Oi={}));class sW{constructor(e,t,n){var r,s,o,a,l,c,h,d,p,f,m,A,v,g,y;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(Oi.open,b),this.handleErrorEvent=b=>this.handleEvent(Oi.error,b),this.handleCloseEvent=b=>this.handleEvent(Oi.close,b),this.handleMessageEvent=b=>this.handleEvent(Oi.message,b),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(r=n?.retry)===null||r===void 0?void 0:r.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(o=n?.retry)===null||o===void 0?void 0:o.backoff},listeners:{open:[...(l=(a=n?.listeners)===null||a===void 0?void 0:a.open)!==null&&l!==void 0?l:[]],close:[...(h=(c=n?.listeners)===null||c===void 0?void 0:c.close)!==null&&h!==void 0?h:[]],error:[...(p=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&p!==void 0?p:[]],message:[...(m=(f=n?.listeners)===null||f===void 0?void 0:f.message)!==null&&m!==void 0?m:[]],retry:[...(v=(A=n?.listeners)===null||A===void 0?void 0:A.retry)!==null&&v!==void 0?v:[]],reconnect:[...(y=(g=n?.listeners)===null||g===void 0?void 0:g.reconnect)!==null&&y!==void 0?y:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const r=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(Oi.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(Oi.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(Oi.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(Oi.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(Oi.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(Oi.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(Oi.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(Oi.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],r=[];n.forEach(({listener:s,options:o})=>{s(this,t),(o===void 0||o.once===void 0||!o.once)&&r.push({listener:s,options:o})}),this._options.listeners[e]=r}handleEvent(e,t){switch(e){case Oi.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case Oi.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},r=new CustomEvent(Oi.reconnect,{detail:n});this.dispatchEvent(Oi.reconnect,r),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case Oi.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const r=new CustomEvent(Oi.retry,{detail:n});this.handleEvent(Oi.retry,r)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class Xxe{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(Oi.open,e,t),this}onClose(e,t){return this.addListener(Oi.close,e,t),this}onError(e,t){return this.addListener(Oi.error,e,t),this}onMessage(e,t){return this.addListener(Oi.message,e,t),this}onRetry(e,t){return this.addListener(Oi.retry,e,t),this}onReconnect(e,t){return this.addListener(Oi.reconnect,e,t),this}build(){return new sW(this._url,this._protocols,this._options)}addListener(e,t,n){var r,s,o,a,l,c,h,d,p,f,m,A,v,g,y,b,x,w,I,M,T;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(o=(s=(r=this._options)===null||r===void 0?void 0:r.listeners)===null||s===void 0?void 0:s.open)!==null&&o!==void 0?o:[],close:(c=(l=(a=this._options)===null||a===void 0?void 0:a.listeners)===null||l===void 0?void 0:l.close)!==null&&c!==void 0?c:[],error:(p=(d=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||d===void 0?void 0:d.error)!==null&&p!==void 0?p:[],message:(A=(m=(f=this._options)===null||f===void 0?void 0:f.listeners)===null||m===void 0?void 0:m.message)!==null&&A!==void 0?A:[],retry:(y=(g=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||g===void 0?void 0:g.retry)!==null&&y!==void 0?y:[],reconnect:(w=(x=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||x===void 0?void 0:x.reconnect)!==null&&w!==void 0?w:[],[e]:[...(T=(M=(I=this._options)===null||I===void 0?void 0:I.listeners)===null||M===void 0?void 0:M[e])!==null&&T!==void 0?T:[],{listener:t,options:n}]}}),this}}const Yxe=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:Wxe,ConstantBackoff:Gxe,ExponentialBackoff:Hxe,LinearBackoff:Vxe,RingQueue:qxe,Websocket:sW,WebsocketBuilder:Xxe,get WebsocketEvent(){return Oi}},Symbol.toStringTag,{value:"Module"})),Fa={node:"node",material:"material",camera:"camera",light:"light"},Uf="KHR_animation_pointer",Jxe={CUBICSPLINE:void 0,LINEAR:Il,STEP:qh},oW=Ht.findNode;let aW=!1;class Kxe{constructor(e){this.parser=e,this.name=Uf,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){aW||(aW=!0,Ht.findNode=function(e,t){if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),r=n.indexOf("."),s=r<0?n:n.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===s||a.material.name===s)&&(o=a.material,o!==null&&(n.endsWith(".map")?o=o.map:n.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let r;for(let s=1;s<n.length;s++){const o=n[s];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const s=oW(e,n[2]);return s||console.warn(Uf+": Property binding not found",t,e,e.name,n),s}return r}return oW(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,n=t.extensions&&t.extensions[Uf]&&t.path&&t.path==="pointer";if(!n)return null;let r,s=Fa.node,o;if(n){const l=t.extensions[Uf];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?s=Fa.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?s=Fa.light:c.startsWith("/cameras/")&&(s=Fa.camera),o=this._tryResolveTargetId(c,s),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(s){case Fa.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case Fa.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case Fa.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case Fa.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(c=h.resolvePath(c)),t.extensions[Uf].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return s===Fa.node?a=this.parser.getDependency("node",o):s===Fa.material?a=this.parser.getDependency("material",o):s===Fa.light?a=this.parser.getDependency("light",o):s===Fa.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",s),a}createAnimationTracksWithAnimationPointer(e,t,n,r,s){if(!(s.extensions&&s.extensions[Uf]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[Uf].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof lo&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",h(this.parser));return a}h(this.parser);function h(d){o=l.join(".");let p;switch(n.itemSize){case 1:p=Gc;break;case 2:case 3:p=Rl;break;case 4:o.endsWith(".quaternion")?p=na:p=R_;break}const f=r.interpolation!==void 0?Jxe[r.interpolation]:Il;let m=d._getArrayFromAccessor(n);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let y=0,b=m.length/4;y<b;y+=1)v[y]=m[y*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,r=this.parser,s=n.animations[e],o=s.name?s.name:"animation_"+e,a=[],l=[],c=[],h=[],d=[];for(let p=0,f=s.channels.length;p<f;p++){const m=s.channels[p],A=s.samplers[m.sampler],v=m.target,g=s.parameters!==void 0?s.parameters[A.input]:A.input,y=s.parameters!==void 0?s.parameters[A.output]:A.output;let b=t.loadAnimationTargetFromChannelWithAnimationPointer(m);b||(b=t.loadAnimationTargetFromChannel(m)),a.push(b),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",y)),h.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],y=[];for(let b=0,x=f.length;b<x;b++){const w=f[b],I=m[b],M=A[b],T=v[b],D=g[b];if(w===void 0)continue;w.updateMatrix&&(w.updateMatrix(),w.matrixAutoUpdate=!0);let S=t.createAnimationTracksWithAnimationPointer(w,I,M,T,D);if(S||(S=r._createAnimationTracks(w,I,M,T,D)),S)for(let B=0;B<S.length;B++)y.push(S[B])}return new Qs(o,void 0,y)})}}const Zxe=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Kxe},Symbol.toStringTag,{value:"Module"}));export{Rxe as $physicsKey,fi as ActionBuilder,w2 as ActionCollection,Aa as ActionModel,DG as Addressables,uy as AlignmentConstraint,Bg as AmbientMode,xs as Animation,Yp as AnimationCurve,Sy as AnimationExtension,kC as AnimationTrackHandler,Vr as Animator,ed as AnimatorConditionMode,Zo as AnimatorController,pP as AnimatorControllerParameterType,Ey as AnimatorStateInfo,My as Antialiasing,Gu as Application,tC as ApplicationEvents,Nj as AssetDatabase,ti as AssetReference,Cd as AudioExtension,Ku as AudioListener,In as AudioSource,wy as AudioTrackHandler,ef as Avatar,nf as AvatarBlink_Simple,Wg as AvatarEyeLook_Rotation,wP as AvatarLoader,qr as AvatarMarker,GC as AvatarModel,Py as Avatar_Brain_LookAt,Oy as Avatar_MouthShapes,bP as Avatar_MustacheShake,ic as Avatar_POI,Ug as Axes,qg as AxesHelper,pB as BUILD_TIME,Na as BaseUIComponent,EP as BasicIKConstraint,HC as BehaviorExtension,yr as BehaviorModel,Re as Behaviour,rf as Bloom,Yg as BoxCollider,of as BoxGizmo,rc as BoxHelperComponent,Ch as Button,gh as ButtonsFactory,N8 as CallDirection,Lg as CallInfo,Ni as Camera,vy as CameraTargetReachedEvent,Xr as Canvas,sd as CanvasGroup,wh as CapsuleCollider,Zg as ChangeMaterialOnClick,cf as ChangeTransformOnClick,df as CharacterController,Sh as CharacterControllerInput,Hy as ChromaticAberration,ra as CircularBuffer,Zp as ClearFlags,Kl as ClipExtrapolation,zo as Collider,YV as Collision,EC as CollisionDetectionMode,lc as ColorAdjustments,gf as ColorBySpeedModule,nb as ColorOverLifetimeModule,Re as Component,Dv as ComponentEvents,Pv as ComponentLifecycleEvents,hH as ConnectionEvents,XV as ContactPoint,hc as ContactShadows,kt as Context,ipe as ContextArgs,Ei as ContextEvent,hi as ContextRegistry,OC as ControlTrackHandler,pd as CustomBranding,gl as CustomShader,lC as DefaultReflectionMode,pk as Deletable,EE as DeleteBox,yl as DepthOfField,SE as DeviceFlag,fk as DocumentExtension,Pa as DragControls,P6 as DragMode,fd as DropListener,wf as Duplicatable,cc as EmissionModule,eA as EmphasizeOnClick,yB as EngineLoadingView,Un as EventList,_C as EventListEvent,Ea as EventSystem,TE as EventTrigger,ek as FieldWithDefault,U1 as FileReference,kG as FileReferenceSerializer,F6 as FileSpawnModel,L6 as File_Event,bk as FixedJoint,xk as FlyControls,mA as Fog,Gi as FrameEvent,Aw as GENERATOR,te as GameObject,At as Gizmos,fb as GltfExport,Ik as GltfExportBox,Of as GltfLoadEvent,fV as GltfLoadEventType,ld as Gradient,af as Graphic,SC as GraphicRaycaster,Ja as Graphics,vA as GridHelper,UP as GridLayoutGroup,Cf as GroundProjectedEnv,Du as GroupActionModel,YH as HideFlags,zP as HideOnStart,ub as HingeJoint,FP as HorizontalLayoutGroup,npe as HostData,Kg as Image,L1 as ImageReference,PG as ImageReferenceSerializer,hd as InheritVelocityModule,QG as Input,Hl as InputEventQueue,on as InputEvents,Ef as InputField,Ky as InstanceHandle,Jy as InstancingHandler,Qa as InstancingUtil,QH as InstantiateEvent,Pr as InstantiateIdProvider,Cl as InstantiateOptions,dk as Interactable,Sde as JoinedRoomResponse,Oue as KeyEventArgs,wa as Keyframe,gb as LODGroup,Sf as LODModel,Ide as LeftRoomResponse,_o as Light,RH as LightData,Zn as LimitVelocityOverLifetimeModule,vne as LoadingElementOptions,Rk as LogStats,Bo as LogType,If as LookAt,Jp as LookAtConstraint,Jr as MainModule,hP as MarkerType,Qy as MaskableGraphic,$e as Mathf,sf as MeshCollider,eb as MeshRenderer,dt as MinMaxCurve,bo as MinMaxGradient,pi as NEEDLE_progressive,jv as NEKeyboardEvent,dh as NEPointerEvent,hi as NeedleEngine,SO as NeedleEngineHTMLElement,wO as NeedleGltfLoader,uc as NeedleMenu,b1 as NeedlePatchesKey,uj as NeedleUSDZExporter,cD as NeedleXRController,_t as NeedleXRSession,pH as NeedleXRSync,AH as NeedleXRUtils,FE as NestedGltf,dH as NetworkConnection,nc as NetworkedStreamEvents,$b as NetworkedStreams,bA as Networking,HH as NewInstanceModel,Mi as NoiseModule,Fo as ObjectRaycaster,ey as ObjectUtils,Mf as OffsetConstraint,dw as OneEuroFilter,JT as OneEuroFilterXYZ,xA as OpenURL,vi as OrbitControls,Jg as Outline,uH as OwnershipEvent,PD as OwnershipModel,nd as Padding,ib as ParticleBurst,$E as ParticleSubEmitter,er as ParticleSystem,Ad as ParticleSystemBaseBehaviour,ka as ParticleSystemRenderer,cE as ParticleSystemShapeType,zC as PeerHandle,aH as PeerNetworking,EH as Physics,xE as PhysicsExtension,Er as PhysicsMaterialCombine,Sb as PixelationEffect,uf as PlayAnimationOnClick,od as PlayAudioOnClick,$u as PlayableDirector,QA as PlayerColor,Ma as PlayerState,P8 as PlayerStateEvent,Gg as PlayerSync,SH as PlayerView,IH as PlayerViewManager,UA as PointerEventData,Q1 as PointerType,ws as PostProcessingEffect,KC as PostProcessingHandler,tA as PreliminaryAction,jy as PreliminaryTrigger,Gp as PrimitiveType,ei as Progress,Z_ as PromiseAllWithErrors,pT as PromiseErrorResult,wi as RGBAColor,qb as RapierPhysics,XC as RawImage,dl as RaycastOptions,PP as Rect,Cs as RectTransform,rA as ReflectionProbe,NC as RegisteredAnimationInfo,xc as RemoteSkybox,Fg as RenderTexture,f8 as RenderTextureSerializer,Mn as Renderer,BH as RendererData,Zy as RendererLightmap,ki as Rigidbody,Nn as RigidbodyConstraints,Wt as RoomEvents,Ho as RotationBySpeedModule,Ta as RotationOverLifetimeModule,rE as SceneLightSettings,Ts as SceneSwitcher,yd as ScreenCapture,Ph as ScreenSpaceAmbientOcclusion,bl as ScreenSpaceAmbientOcclusionN8,ya as SendQueue,Z2 as SerializationContext,hf as SetActiveOnClick,Bb as ShadowCatcher,An as ShapeModule,by as SignalAsset,zg as SignalReceiver,Qg as SignalReceiverEvent,Cy as SignalTrackHandler,DP as Size,eo as SizeBySpeedModule,cd as SizeOverLifetimeModule,tk as SkinnedMeshRenderer,bd as SmoothFollow,Ay as SpatialGrabRaycaster,Rb as SpatialHtml,kb as SpatialTrigger,_c as SpatialTriggerReceiver,rS as SpectatorCamera,Xg as SphereCollider,CH as SphereIntersection,JV as SphereOverlapResult,Rh as Sprite,hA as SpriteData,Ba as SpriteRenderer,ob as SpriteSheet,pfe as StateMachineBehaviour,F8 as StreamEndedEvent,U8 as StreamReceivedEvent,Eb as SubEmitterSystem,oS as SyncedCamera,wc as SyncedRoom,Yu as SyncedTransform,jP as TapGestureTrigger,yE as TeleportTarget,pO as TestRunner,kxe as TestSceneUtils,fO as TestSimulateUserData,Ss as Text,_E as TextBuilder,ab as TextExtension,Kr as TextureSheetAnimationModule,Cc as TiltShiftEffect,PH as Time,iA as ToneMapping,xy as TrackHandler,Uo as TrackType,ln as TrailModule,Mr as TransformData,Df as TransformGizmo,br as TriggerBuilder,Pp as TriggerModel,q as TypeStore,IC as UIRaycastUtils,my as UIRootComponent,qs as USDObject,hj as USDWriter,Qn as USDZExporter,dd as USDZText,wE as USDZUIExtension,iD as Upload_Result,m8 as UriSerializer,cb as UsageMarker,Mde as UserJoinedOrLeftRoomModel,Za as VERSION,_2 as VariantAction,vn as VelocityOverLifetimeModule,LP as VerticalLayoutGroup,hr as VideoPlayer,Vu as ViewDevice,Pf as Vignette,Gy as VisibilityAction,tf as Voip,Xy as Volume,Bt as VolumeParameter,Iy as VolumeProfile,Ode as WaitForFrames,bH as WaitForPromise,yH as WaitForSeconds,Lh as Watch,cS as WebARCameraBackground,to as WebARSessionRoot,Tr as WebXR,pA as WebXRButtonFactory,TA as WebXRImageTracking,Ec as WebXRImageTrackingModel,xd as WebXRPlaneTracking,MA as WebXRTrackedImage,Fb as XRControllerFollow,pc as XRControllerModel,Ra as XRControllerMovement,Qo as XRFlag,uS as XRRig,$s as XRState,tc as XRStateFlag,vO as __Ignore,Hj as __internalNotifyObjectDestroyed,Yc as activeInHierarchyFieldName,RN as addAttributeChangeCallback,Xl as addComponent,Ege as addCustomExtensionPlugin,U6 as addFile,N6 as addFileFromUrl,rxe as addGltfLoadEventListener,Wp as addNewComponent,y1 as addPatch,bC as apply,Axe as applyHMRChanges,GH as beginListenDestroy,Q6 as beginListenFileSpawn,VH as beginListenInstantiate,fD as binaryIdentifierCasts,tpe as build_scene_functions,mp as builtinComponentKeyName,AB as calculateProgress01,NN as clearBalloonMessages,NN as clearOverlayMessages,Cpe as colorSerializer,wC as componentSerializer,J3 as copyTexture,CO as createLoader,M8 as createMotion,Zs as debugNet,Zv as debugOwner,D0 as deepClone,kl as delay,MN as delayForFrames,P1 as deserializeObject,_a as destroy,o8 as destroyComponentInstance,ji as disposeObjectResources,_h as disposeStream,RG as download,rD as download_file,H0 as editorGuidKeyName,VP as effectsOrder,Dm as enableSpatialConsole,Tpe as eventListSerializer,Qxe as exportAsGLTF,oy as findByGuid,KD as findObjectOfType,c8 as findObjectsOfType,R2 as findResourceUsers,K3 as fitObjectIntoVolume,Vp as foreachComponent,YD as foreachComponentEnumerator,Lie as forward,PN as generateQRCode,fC as generateSeed,lu as getBoundingBox,j3 as getCameraController,qp as getComponent,cy as getComponentInChildren,hy as getComponentInParent,ly as getComponents,kg as getComponentsInChildren,xC as getComponentsInParent,oj as getFormattedDate,Ao as getIconElement,zD as getIconTexture,zZ as getIp,jZ as getIpAndLocation,QZ as getIpCloudflare,Xa as getLoader,ay as getOrAddComponent,ee as getParam,Nie as getParentHierarchyPath,LZ as getPath,_de as getPeerOptions,sH as getPeerjsInstance,Qle as getResourceUserCount,dp as getTempQuaternion,En as getTempVector,R0 as getUrlParams,rB as getWorldDirection,sB as getWorldEuler,Tt as getWorldPosition,Ti as getWorldQuaternion,N0 as getWorldRotation,zi as getWorldScale,Jc as hasCommercialLicense,fB as hasIndieLicense,rP as hasPointerEventComponent,cu as hasProLicense,nD as hash,nQ as hideDebugConsole,fj as imageToCanvas,Pg as instantiate,$P as invokeAfterImportPluginHooks,LG as invokeXRSessionEnd,OG as invokeXRSessionStart,JH as isActiveInHierarchy,Dg as isActiveSelf,BN as isAndroidDevice,Y3 as isAnimationAction,DZ as isDebugMode,ap as isDesktop,Hp as isDestroyed,rt as isDevEnvironment,Ule as isDisposed,Lxe as isExporting,_N as isHostedOnGlitch,pxe as isHotReloading,kH as isIconElement,zs as isLocalNetwork,To as isMobileDevice,lp as isMozillaXR,K_ as isQuest,zj as isResourceTrackingEnabled,Tm as isSafari,AC as isUsingInstancing,cp as isiOS,EO as loadSync,mw as logHierarchy,Bie as lookAtInverse,U0 as lookAtObject,kZ as makeId,hT as makeIdFromRandomWords,hl as makeNameSafeForUSD,KH as markAsInstancedRendered,dT as microphonePermissionsGranted,RZ as nameof,wN as nameofFactory,p8 as objectSerializer,Eue as offXRSessionEnd,Cue as offXRSessionStart,Fpe as onAfterRender,Lpe as onBeforeRender,kpe as onClear,Ope as onDestroy,Ppe as onInitialized,b8 as onStart,x8 as onUpdate,oD as onXRSessionEnd,N1 as onXRSessionStart,gV as parseSync,Z3 as placeOnSurface,$3 as postprocessFBXMaterials,Npe as prefix,CN as pushState,OZ as randomNumber,mD as registerBinaryType,uC as registerComponent,JP as registerComponentExtension,Ia as registerCustomEffectType,ZP as registerExportExtensions,KP as registerExtensions,fxe as registerHotReloadType,sT as registerLoader,qH as registerPrefabProvider,ule as registerType,TN as relativePathPrefix,DN as removeAttributeChangeCallback,JD as removeComponent,Sge as removeCustomImportExtensionType,sxe as removeGltfLoadEventListener,kle as removePatch,ou as resolveUrl,IN as sanitizeString,$V as saveImage,Oxe as screenshot,ZV as screenshot2,jH as sendDestroyed,_ as serializable,wG as serializeObject,Ag as serializeable,sy as setActive,FN as setAllowBalloonMessages,WZ as setAllowOverlayMessages,$T as setAutoFitEnabled,KT as setCameraController,$H as setDestroyed,qie as setDevEnvironment,B2 as setDisposable,qD as setDontDestroy,lT as setOrAddParamsToUrl,PZ as setParam,q_ as setParamWithoutReload,wde as setPeerOptions,Fle as setResourceTrackingEnabled,cT as setState,oB as setWorldEuler,mr as setWorldPosition,pp as setWorldPositionXYZ,oa as setWorldQuaternion,nB as setWorldQuaternionXYZW,aB as setWorldRotation,Q0 as setWorldRotationXYZ,Rm as setWorldScale,lB as showBalloonError,nn as showBalloonMessage,Pi as showBalloonWarning,dB as showDebugConsole,Mie as slerp,pC as syncDestroy,vP as syncField,VD as syncInstantiate,Qie as textureToCanvas,VG as tryCastBinary,uV as tryDetermineFileTypeFromBinary,hV as tryDetermineFileTypeFromURL,Im as tryFindObject,WG as tryGetGuid,mxe as unregisterHotReloadType,uT as unwatchWrite,BG as upload_file,G3 as useForAutoFit,Hr as validate,Y_ as watchWrite};
7501
+ `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e){var t;this.onSetupAR();const n=this.getAROverlayContainer();this._overlay_ar.onBegin(this._context,n,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Qb),this.classList.remove(zb);const e=this.getAROverlayContainer();cn&&console.warn("onSetupAR:",e),e&&(e.classList.add(Qb),e.classList.remove(zb)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,dQ))}onSetupVR(){this.classList.remove(Qb),this.classList.remove(zb),this.foreachHtmlElement(e=>this.setupElementsForMode(e,xV))}onSetupDesktop(){this.classList.remove(Qb),this.classList.add(zb);const e=this.getAROverlayContainer();e&&(e.classList.remove(Qb),e.classList.add(zb)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,_V))}setupElementsForMode(e,t,n=null){var r,s;if(!(e===((s=(r=this._context)==null?void 0:r.renderer)==null?void 0:s.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const o of axe)e.classList.contains(o)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const n=this.children[t];n.style&&e(n)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(cn&&console.log("using custom draco decoder path",e),S4(e));const t=this.getAttribute("dracoDecoderType");t&&(cn&&console.log("using custom draco decoder type",t),I4(t));const n=this.getAttribute("ktx2DecoderPath");n&&(cn&&console.log("using custom ktx2 decoder path",n),M4(n))}}typeof window<"u"&&!window.customElements.get(bV)&&window.customElements.define(bV,SO);function cxe(i){if(i.startsWith("blob:"))return"blob";const e=i.split("/");let t=e[e.length-1];const n=t.indexOf("?");n>0&&(t=t.substring(0,n));const r=t.indexOf("=");r>0&&(t=t.substring(r));const s=t.split(".").pop();if((s==="glb"||s==="gltf")&&(t=t.substring(0,t.length-4)),t=decodeURIComponent(t),t.length>3){let o="";for(let a=0;a<t.length;a++){let l=t[a];if(l===" "&&o.length<=0)continue;const c=o.length===0,h=l>="0"&&l<="9";c==!1&&l===l.toUpperCase()&&!h?o+=" "+l:(c&&(l=l.toUpperCase()),o+=l)}return cn&&console.log("displayName",t,o),o}return cn&&console.log("displayName",t),t}const hxe=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:SO},Symbol.toStringTag,{value:"Module"}));function uxe(){Gu.registerWaitForAllowAudio(()=>{const i=L_.getContext();i.addEventListener("statechange",()=>{setTimeout(()=>{const e=i.state;(e==="suspended"||e==="interrupted")&&i.resume().then(()=>{console.log("AudioContext resumed successfully")}).catch(t=>{console.log("Failed to resume AudioContext: "+t)})},500)})})}setTimeout(uxe,1e3);const dS=ee("debughotreload");let jb=!1;const Gb=new Map;function dxe(){return jb}function pxe(i){var e;if(jb)return;const t=i.constructor.name;Gb.has(t)?(e=Gb.get(t))==null||e.push(i):Gb.set(t,[i])}function fxe(i){if(jb)return;const e=i.constructor.name,t=Gb.get(e);if(!t)return;const n=t.indexOf(i);n!==-1&&t.splice(n,1)}let wV=!1;function mxe(){if(dS||wV)return;wV=!0;const i=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}i.apply(console,e)}}function gxe(i){dS&&console.log("[HMR] Apply changes",i,Object.keys(i)),mxe();for(const e of Object.keys(i))try{jb=!0;const t=q.get(e);if(!t){dS&&console.log("[HMR] Type not found: "+e);continue}const n=i[e],r=Gb.get(n.name);let s="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?s+=" x"+o:s+=" - no instances",console.log(s);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(n.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new n,h=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&A&&ch(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in h)if(h[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],y=g.name,b="bound ";if(y===b)continue;const x=g.name.substring(b.length),w=n.prototype[x];w&&(d[v]=w.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&A&&k2(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(dS)console.error(t);else return!1}finally{jb=!1,Ol(Bo.Log,"Script changes applied (HMR)")}return!0}let Ue;const Hb=new Array(128).fill(void 0);Hb.push(void 0,null,!0,!1),Hb.length;let pS=null;function CV(){return pS!==null&&pS.byteLength!==0||(pS=new Int32Array(Ue.memory.buffer)),pS}const Axe=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Axe.decode();function pt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}let fS=null;function vxe(){return fS!==null&&fS.byteLength!==0||(fS=new Float32Array(Ue.memory.buffer)),fS}let Vb=128;function EV(i){if(Vb==1)throw new Error("out of js stack");return Hb[--Vb]=i,Vb}let mS=null;function yxe(){return mS!==null&&mS.byteLength!==0||(mS=new Uint32Array(Ue.memory.buffer)),mS}let Ko=0;function Lf(i,e){const t=e(4*i.length,4)>>>0;return vxe().set(i,t/4),Ko=i.length,t}function gS(i,e){const t=e(4*i.length,4)>>>0;return yxe().set(i,t/4),Ko=i.length,t}const ns=Object.freeze({Ball:0,0:"Ball",Cuboid:1,1:"Cuboid",Capsule:2,2:"Capsule",Segment:3,3:"Segment",Polyline:4,4:"Polyline",Triangle:5,5:"Triangle",TriMesh:6,6:"TriMesh",HeightField:7,7:"HeightField",Compound:8,8:"Compound",ConvexPolyhedron:9,9:"ConvexPolyhedron",Cylinder:10,10:"Cylinder",Cone:11,11:"Cone",RoundCuboid:12,12:"RoundCuboid",RoundTriangle:13,13:"RoundTriangle",RoundCylinder:14,14:"RoundCylinder",RoundCone:15,15:"RoundCone",RoundConvexPolyhedron:16,16:"RoundConvexPolyhedron",HalfSpace:17,17:"HalfSpace"});class bxe{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_raweventqueue_free(e)}constructor(e){const t=Ue.raweventqueue_new(e);return this.__wbg_ptr=t>>>0,this}drainCollisionEvents(e){try{Ue.raweventqueue_drainCollisionEvents(this.__wbg_ptr,EV(e))}finally{Hb[Vb++]=void 0}}drainContactForceEvents(e){try{Ue.raweventqueue_drainContactForceEvents(this.__wbg_ptr,EV(e))}finally{Hb[Vb++]=void 0}}clear(){Ue.raweventqueue_clear(this.__wbg_ptr)}}class Rs{static __wrap(e){e>>>=0;const t=Object.create(Rs.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawgenericjoint_free(e)}static generic(e,t,n,r){pt(e,st),pt(t,st),pt(n,st);const s=Ue.rawgenericjoint_generic(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return s===0?void 0:Rs.__wrap(s)}static spring(e,t,n,r,s){pt(r,st),pt(s,st);const o=Ue.rawgenericjoint_spring(e,t,n,r.__wbg_ptr,s.__wbg_ptr);return Rs.__wrap(o)}static rope(e,t,n){pt(t,st),pt(n,st);const r=Ue.rawgenericjoint_rope(e,t.__wbg_ptr,n.__wbg_ptr);return Rs.__wrap(r)}static spherical(e,t){pt(e,st),pt(t,st);const n=Ue.rawgenericjoint_spherical(e.__wbg_ptr,t.__wbg_ptr);return Rs.__wrap(n)}static prismatic(e,t,n,r,s,o){pt(e,st),pt(t,st),pt(n,st);const a=Ue.rawgenericjoint_prismatic(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r,s,o);return a===0?void 0:Rs.__wrap(a)}static fixed(e,t,n,r){pt(e,st),pt(t,ss),pt(n,st),pt(r,ss);const s=Ue.rawgenericjoint_fixed(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr);return Rs.__wrap(s)}static revolute(e,t,n){pt(e,st),pt(t,st),pt(n,st);const r=Ue.rawgenericjoint_revolute(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr);return r===0?void 0:Rs.__wrap(r)}}class GO{static __wrap(e){e>>>=0;const t=Object.create(GO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawpointprojection_free(e)}point(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return st.__wrap(e)}isInside(){return Ue.rawpointprojection_isInside(this.__wbg_ptr)!==0}}class HO{static __wrap(e){e>>>=0;const t=Object.create(HO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrayintersection_free(e)}normal(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return st.__wrap(e)}toi(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}featureType(){return Ue.rawpointcolliderprojection_featureType(this.__wbg_ptr)}featureId(){try{const n=Ue.__wbindgen_add_to_stack_pointer(-16);Ue.rawpointcolliderprojection_featureId(n,this.__wbg_ptr);var e=CV()[n/4+0],t=CV()[n/4+1];return e===0?void 0:t>>>0}finally{Ue.__wbindgen_add_to_stack_pointer(16)}}}class ss{static __wrap(e){e>>>=0;const t=Object.create(ss.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrotation_free(e)}constructor(e,t,n,r){const s=Ue.rawrotation_new(e,t,n,r);return this.__wbg_ptr=s>>>0,this}static identity(){const e=Ue.rawrotation_identity();return ss.__wrap(e)}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}get w(){return Ue.rawintegrationparameters_erp(this.__wbg_ptr)}}class jt{static __wrap(e){e>>>=0;const t=Object.create(jt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshape_free(e)}static cuboid(e,t,n){const r=Ue.rawshape_cuboid(e,t,n);return jt.__wrap(r)}static roundCuboid(e,t,n,r){const s=Ue.rawshape_roundCuboid(e,t,n,r);return jt.__wrap(s)}static ball(e){const t=Ue.rawshape_ball(e);return jt.__wrap(t)}static halfspace(e){pt(e,st);const t=Ue.rawshape_halfspace(e.__wbg_ptr);return jt.__wrap(t)}static capsule(e,t){const n=Ue.rawshape_capsule(e,t);return jt.__wrap(n)}static cylinder(e,t){const n=Ue.rawshape_cylinder(e,t);return jt.__wrap(n)}static roundCylinder(e,t,n){const r=Ue.rawshape_roundCylinder(e,t,n);return jt.__wrap(r)}static cone(e,t){const n=Ue.rawshape_cone(e,t);return jt.__wrap(n)}static roundCone(e,t,n){const r=Ue.rawshape_roundCone(e,t,n);return jt.__wrap(r)}static polyline(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_polyline(n,r,s,o);return jt.__wrap(a)}static trimesh(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_trimesh(n,r,s,o);return jt.__wrap(a)}static heightfield(e,t,n,r){const s=Lf(n,Ue.__wbindgen_malloc),o=Ko;pt(r,st);const a=Ue.rawshape_heightfield(e,t,s,o,r.__wbg_ptr);return jt.__wrap(a)}static segment(e,t){pt(e,st),pt(t,st);const n=Ue.rawshape_segment(e.__wbg_ptr,t.__wbg_ptr);return jt.__wrap(n)}static triangle(e,t,n){pt(e,st),pt(t,st),pt(n,st);const r=Ue.rawshape_triangle(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr);return jt.__wrap(r)}static roundTriangle(e,t,n,r){pt(e,st),pt(t,st),pt(n,st);const s=Ue.rawshape_roundTriangle(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return jt.__wrap(s)}static convexHull(e){const t=Lf(e,Ue.__wbindgen_malloc),n=Ko,r=Ue.rawshape_convexHull(t,n);return r===0?void 0:jt.__wrap(r)}static roundConvexHull(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=Ue.rawshape_roundConvexHull(n,r,t);return s===0?void 0:jt.__wrap(s)}static convexMesh(e,t){const n=Lf(e,Ue.__wbindgen_malloc),r=Ko,s=gS(t,Ue.__wbindgen_malloc),o=Ko,a=Ue.rawshape_convexMesh(n,r,s,o);return a===0?void 0:jt.__wrap(a)}static roundConvexMesh(e,t,n){const r=Lf(e,Ue.__wbindgen_malloc),s=Ko,o=gS(t,Ue.__wbindgen_malloc),a=Ko,l=Ue.rawshape_roundConvexMesh(r,s,o,a,n);return l===0?void 0:jt.__wrap(l)}castShape(e,t,n,r,s,o,a,l,c){pt(e,st),pt(t,ss),pt(n,st),pt(r,jt),pt(s,st),pt(o,ss),pt(a,st);const h=Ue.rawshape_castShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr,o.__wbg_ptr,a.__wbg_ptr,l,c);return h===0?void 0:WO.__wrap(h)}intersectsShape(e,t,n,r,s){return pt(e,st),pt(t,ss),pt(n,jt),pt(r,st),pt(s,ss),Ue.rawshape_intersectsShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr)!==0}contactShape(e,t,n,r,s,o){pt(e,st),pt(t,ss),pt(n,jt),pt(r,st),pt(s,ss);const a=Ue.rawshape_contactShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s.__wbg_ptr,o);return a===0?void 0:VO.__wrap(a)}containsPoint(e,t,n){return pt(e,st),pt(t,ss),pt(n,st),Ue.rawshape_containsPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr)!==0}projectPoint(e,t,n,r){pt(e,st),pt(t,ss),pt(n,st);const s=Ue.rawshape_projectPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r);return GO.__wrap(s)}intersectsRay(e,t,n,r,s){return pt(e,st),pt(t,ss),pt(n,st),pt(r,st),Ue.rawshape_intersectsRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s)!==0}castRay(e,t,n,r,s,o){return pt(e,st),pt(t,ss),pt(n,st),pt(r,st),Ue.rawshape_castRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s,o)}castRayAndGetNormal(e,t,n,r,s,o){pt(e,st),pt(t,ss),pt(n,st),pt(r,st);const a=Ue.rawshape_castRayAndGetNormal(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,s,o);return a===0?void 0:HO.__wrap(a)}}class VO{static __wrap(e){e>>>=0;const t=Object.create(VO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapecontact_free(e)}distance(){return Ue.rawkinematiccharactercontroller_maxSlopeClimbAngle(this.__wbg_ptr)}point1(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return st.__wrap(e)}point2(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return st.__wrap(e)}normal1(){const e=Ue.rawshapecollidertoi_witness2(this.__wbg_ptr);return st.__wrap(e)}normal2(){const e=Ue.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr);return st.__wrap(e)}}class WO{static __wrap(e){e>>>=0;const t=Object.create(WO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapetoi_free(e)}toi(){return Ue.rawrotation_x(this.__wbg_ptr)}witness1(){const e=Ue.rawshapetoi_witness1(this.__wbg_ptr);return st.__wrap(e)}witness2(){const e=Ue.rawcontactforceevent_total_force(this.__wbg_ptr);return st.__wrap(e)}normal1(){const e=Ue.rawshapetoi_normal1(this.__wbg_ptr);return st.__wrap(e)}normal2(){const e=Ue.rawshapetoi_normal2(this.__wbg_ptr);return st.__wrap(e)}}class st{static __wrap(e){e>>>=0;const t=Object.create(st.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawvector_free(e)}static zero(){const e=Ue.rawvector_zero();return st.__wrap(e)}constructor(e,t,n){const r=Ue.rawvector_new(e,t,n);return this.__wbg_ptr=r>>>0,this}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}set x(e){Ue.rawvector_set_x(this.__wbg_ptr,e)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}set y(e){Ue.rawintegrationparameters_set_dt(this.__wbg_ptr,e)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}set z(e){Ue.rawvector_set_z(this.__wbg_ptr,e)}xyz(){const e=Ue.rawvector_xyz(this.__wbg_ptr);return st.__wrap(e)}yxz(){const e=Ue.rawvector_yxz(this.__wbg_ptr);return st.__wrap(e)}zxy(){const e=Ue.rawvector_zxy(this.__wbg_ptr);return st.__wrap(e)}xzy(){const e=Ue.rawvector_xzy(this.__wbg_ptr);return st.__wrap(e)}yzx(){const e=Ue.rawvector_yzx(this.__wbg_ptr);return st.__wrap(e)}zyx(){const e=Ue.rawvector_zyx(this.__wbg_ptr);return st.__wrap(e)}}class xxe{constructor(e,t,n){this.x=e,this.y=t,this.z=n}}class De{static new(e,t,n){return new xxe(e,t,n)}static intoRaw(e){return new st(e.x,e.y,e.z)}static zeros(){return De.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=De.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class SV{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.w=r}}class Vi{static identity(){return new SV(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new SV(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new ss(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}class _xe{constructor(e){this.elements=e}get m11(){return this.elements[0]}get m12(){return this.elements[1]}get m21(){return this.m12}get m13(){return this.elements[2]}get m31(){return this.m13}get m22(){return this.elements[3]}get m23(){return this.elements[4]}get m32(){return this.m23}get m33(){return this.elements[5]}}class IV{static fromRaw(e){const t=new _xe(e.elements());return e.free(),t}}var Wb,Bs,MV,TV,tr,IO,zn,BV,AS,MO,RV,vS,DA;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Wb||(Wb={}));class DV{constructor(e,t,n){this.rawSet=e,this.colliderSet=t,this.handle=n}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,n,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,n,r)}restrictTranslations(e,t,n,r){this.setEnabledTranslations(e,t,n,r)}setEnabledRotations(e,t,n,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,n,r)}restrictRotations(e,t,n,r){this.setEnabledRotations(e,t,n,r)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}additionalSolverIterations(){return this.rawSet.rbAdditionalSolverIterations(this.handle)}setAdditionalSolverIterations(e){this.rawSet.rbSetAdditionalSolverIterations(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return De.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Vi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return De.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Vi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let n=De.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,n,t),n.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let n=De.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,n,t),n.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return De.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return De.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}effectiveInvMass(){return De.fromRaw(this.rawSet.rbEffectiveInvMass(this.handle))}invMass(){return this.rawSet.rbInvMass(this.handle)}localCom(){return De.fromRaw(this.rawSet.rbLocalCom(this.handle))}worldCom(){return De.fromRaw(this.rawSet.rbWorldCom(this.handle))}invPrincipalInertiaSqrt(){return De.fromRaw(this.rawSet.rbInvPrincipalInertiaSqrt(this.handle))}principalInertia(){return De.fromRaw(this.rawSet.rbPrincipalInertia(this.handle))}principalInertiaLocalFrame(){return Vi.fromRaw(this.rawSet.rbPrincipalInertiaLocalFrame(this.handle))}effectiveWorldInvInertiaSqrt(){return IV.fromRaw(this.rawSet.rbEffectiveWorldInvInertiaSqrt(this.handle))}effectiveAngularInertia(){return IV.fromRaw(this.rawSet.rbEffectiveAngularInertia(this.handle))}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){return this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}setEnabled(e){this.rawSet.rbSetEnabled(this.handle,e)}isEnabled(){return this.rawSet.rbIsEnabled(this.handle)}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e,t){return this.rawSet.rbSetBodyType(this.handle,e,t)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,n,r,s){let o=De.intoRaw(t),a=De.intoRaw(n),l=Vi.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,s),o.free(),a.free(),l.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const n=De.intoRaw(e);this.rawSet.rbAddForce(this.handle,n,t),n.free()}applyImpulse(e,t){const n=De.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,n,t),n.free()}addTorque(e,t){const n=De.intoRaw(e);this.rawSet.rbAddTorque(this.handle,n,t),n.free()}applyTorqueImpulse(e,t){const n=De.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,n,t),n.free()}addForceAtPoint(e,t,n){const r=De.intoRaw(e),s=De.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,s,n),r.free(),s.free()}applyImpulseAtPoint(e,t,n){const r=De.intoRaw(e),s=De.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,s,n),r.free(),s.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Rope=3]="Rope",i[i.Spring=4]="Spring",i[i.Spherical=5]="Spherical",i[i.Generic=6]="Generic"})(Bs||(Bs={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(MV||(MV={})),function(i){i[i.X=1]="X",i[i.Y=2]="Y",i[i.Z=4]="Z",i[i.AngX=8]="AngX",i[i.AngY=16]="AngY",i[i.AngZ=32]="AngZ"}(TV||(TV={}));class Uh{constructor(){}static fixed(e,t,n,r){let s=new Uh;return s.anchor1=e,s.anchor2=n,s.frame1=t,s.frame2=r,s.jointType=Bs.Fixed,s}static spring(e,t,n,r,s){let o=new Uh;return o.anchor1=r,o.anchor2=s,o.length=e,o.stiffness=t,o.damping=n,o.jointType=Bs.Spring,o}static rope(e,t,n){let r=new Uh;return r.anchor1=t,r.anchor2=n,r.length=e,r.jointType=Bs.Rope,r}static generic(e,t,n,r){let s=new Uh;return s.anchor1=e,s.anchor2=t,s.axis=n,s.axesMask=r,s.jointType=Bs.Generic,s}static spherical(e,t){let n=new Uh;return n.anchor1=e,n.anchor2=t,n.jointType=Bs.Spherical,n}static prismatic(e,t,n){let r=new Uh;return r.anchor1=e,r.anchor2=t,r.axis=n,r.jointType=Bs.Prismatic,r}static revolute(e,t,n){let r=new Uh;return r.anchor1=e,r.anchor2=t,r.axis=n,r.jointType=Bs.Revolute,r}intoRaw(){let e,t,n=De.intoRaw(this.anchor1),r=De.intoRaw(this.anchor2),s=!1,o=0,a=0;switch(this.jointType){case Bs.Fixed:let l=Vi.intoRaw(this.frame1),c=Vi.intoRaw(this.frame2);t=Rs.fixed(n,l,r,c),l.free(),c.free();break;case Bs.Spring:t=Rs.spring(this.length,this.stiffness,this.damping,n,r);break;case Bs.Rope:t=Rs.rope(this.length,n,r);break;case Bs.Prismatic:e=De.intoRaw(this.axis),this.limitsEnabled&&(s=!0,o=this.limits[0],a=this.limits[1]),t=Rs.prismatic(n,r,e,s,o,a),e.free();break;case Bs.Generic:e=De.intoRaw(this.axis);let h=this.axesMask;t=Rs.generic(n,r,e,h);break;case Bs.Spherical:t=Rs.spherical(n,r);break;case Bs.Revolute:e=De.intoRaw(this.axis),t=Rs.revolute(n,r,e),e.free()}return n.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(tr||(tr={}));class ex{constructor(e,t,n,r,s){this.distance=e,this.point1=t,this.point2=n,this.normal1=r,this.normal2=s}static fromRaw(e){if(!e)return null;const t=new ex(e.distance(),De.fromRaw(e.point1()),De.fromRaw(e.point2()),De.fromRaw(e.normal1()),De.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(IO||(IO={}));class US{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new US(De.fromRaw(e.point()),e.isInside());return e.free(),t}}class wxe{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class NS{constructor(e,t,n,r){this.featureType=IO.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),n!==void 0&&(this.featureType=n)}static fromRaw(e){if(!e)return null;const t=new NS(e.toi(),De.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class tx{constructor(e,t,n,r,s){this.toi=e,this.witness1=t,this.witness2=n,this.normal1=r,this.normal2=s}static fromRaw(e,t){if(!t)return null;const n=new tx(t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),n}}class qO extends tx{constructor(e,t,n,r,s,o){super(t,n,r,s,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const n=new qO(e.get(t.colliderHandle()),t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),n}}class Dr{static fromRaw(e,t){const n=e.coShapeType(t);let r,s,o,a,l,c,h;switch(n){case ns.Ball:return new TO(e.coRadius(t));case ns.Cuboid:return r=e.coHalfExtents(t),new PV(r.x,r.y,r.z);case ns.RoundCuboid:return r=e.coHalfExtents(t),s=e.coRoundRadius(t),new kV(r.x,r.y,r.z,s);case ns.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new OV(l,c);case ns.Segment:return o=e.coVertices(t),new LV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]));case ns.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new NV(o,a);case ns.Triangle:return o=e.coVertices(t),new FV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]));case ns.RoundTriangle:return o=e.coVertices(t),s=e.coRoundRadius(t),new UV(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]),s);case ns.HalfSpace:return h=De.fromRaw(e.coHalfspaceNormal(t)),new Cxe(h);case ns.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new QV(o,a);case ns.HeightField:const d=e.coHeightfieldScale(t),p=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),m=e.coHeightfieldNCols(t);return new zV(f,m,p,d);case ns.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new BO(o,a);case ns.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),s=e.coRoundRadius(t),new RO(o,a,s);case ns.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new jV(l,c);case ns.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),s=e.coRoundRadius(t),new GV(l,c,s);case ns.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new HV(l,c);case ns.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),s=e.coRoundRadius(t),new VV(l,c,s);default:throw new Error("unknown shape type: "+n)}}castShape(e,t,n,r,s,o,a,l,c){let h=De.intoRaw(e),d=Vi.intoRaw(t),p=De.intoRaw(n),f=De.intoRaw(s),m=Vi.intoRaw(o),A=De.intoRaw(a),v=this.intoRaw(),g=r.intoRaw(),y=tx.fromRaw(null,v.castShape(h,d,p,g,f,m,A,l,c));return h.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g.free(),y}intersectsShape(e,t,n,r,s){let o=De.intoRaw(e),a=Vi.intoRaw(t),l=De.intoRaw(r),c=Vi.intoRaw(s),h=this.intoRaw(),d=n.intoRaw(),p=h.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),h.free(),d.free(),p}contactShape(e,t,n,r,s,o){let a=De.intoRaw(e),l=Vi.intoRaw(t),c=De.intoRaw(r),h=Vi.intoRaw(s),d=this.intoRaw(),p=n.intoRaw(),f=ex.fromRaw(d.contactShape(a,l,p,c,h,o));return a.free(),l.free(),c.free(),h.free(),d.free(),p.free(),f}containsPoint(e,t,n){let r=De.intoRaw(e),s=Vi.intoRaw(t),o=De.intoRaw(n),a=this.intoRaw(),l=a.containsPoint(r,s,o);return r.free(),s.free(),o.free(),a.free(),l}projectPoint(e,t,n,r){let s=De.intoRaw(e),o=Vi.intoRaw(t),a=De.intoRaw(n),l=this.intoRaw(),c=US.fromRaw(l.projectPoint(s,o,a,r));return s.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,n,r){let s=De.intoRaw(t),o=Vi.intoRaw(n),a=De.intoRaw(e.origin),l=De.intoRaw(e.dir),c=this.intoRaw(),h=c.intersectsRay(s,o,a,l,r);return s.free(),o.free(),a.free(),l.free(),c.free(),h}castRay(e,t,n,r,s){let o=De.intoRaw(t),a=Vi.intoRaw(n),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),h=this.intoRaw(),d=h.castRay(o,a,l,c,r,s);return o.free(),a.free(),l.free(),c.free(),h.free(),d}castRayAndGetNormal(e,t,n,r,s){let o=De.intoRaw(t),a=Vi.intoRaw(n),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),h=this.intoRaw(),d=NS.fromRaw(h.castRayAndGetNormal(o,a,l,c,r,s));return o.free(),a.free(),l.free(),c.free(),h.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron",i[i.HalfSpace=17]="HalfSpace"})(zn||(zn={}));class TO extends Dr{constructor(e){super(),this.type=zn.Ball,this.radius=e}intoRaw(){return jt.ball(this.radius)}}class Cxe extends Dr{constructor(e){super(),this.type=zn.HalfSpace,this.normal=e}intoRaw(){let e=De.intoRaw(this.normal),t=jt.halfspace(e);return e.free(),t}}class PV extends Dr{constructor(e,t,n){super(),this.type=zn.Cuboid,this.halfExtents=De.new(e,t,n)}intoRaw(){return jt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class kV extends Dr{constructor(e,t,n,r){super(),this.type=zn.RoundCuboid,this.halfExtents=De.new(e,t,n),this.borderRadius=r}intoRaw(){return jt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class OV extends Dr{constructor(e,t){super(),this.type=zn.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return jt.capsule(this.halfHeight,this.radius)}}class LV extends Dr{constructor(e,t){super(),this.type=zn.Segment,this.a=e,this.b=t}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=jt.segment(e,t);return e.free(),t.free(),n}}class FV extends Dr{constructor(e,t,n){super(),this.type=zn.Triangle,this.a=e,this.b=t,this.c=n}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=De.intoRaw(this.c),r=jt.triangle(e,t,n);return e.free(),t.free(),n.free(),r}}class UV extends Dr{constructor(e,t,n,r){super(),this.type=zn.RoundTriangle,this.a=e,this.b=t,this.c=n,this.borderRadius=r}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),n=De.intoRaw(this.c),r=jt.roundTriangle(e,t,n,this.borderRadius);return e.free(),t.free(),n.free(),r}}class NV extends Dr{constructor(e,t){super(),this.type=zn.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return jt.polyline(this.vertices,this.indices)}}class QV extends Dr{constructor(e,t){super(),this.type=zn.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return jt.trimesh(this.vertices,this.indices)}}class BO extends Dr{constructor(e,t){super(),this.type=zn.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?jt.convexMesh(this.vertices,this.indices):jt.convexHull(this.vertices)}}class RO extends Dr{constructor(e,t,n){super(),this.type=zn.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=n}intoRaw(){return this.indices?jt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):jt.roundConvexHull(this.vertices,this.borderRadius)}}class zV extends Dr{constructor(e,t,n,r){super(),this.type=zn.HeightField,this.nrows=e,this.ncols=t,this.heights=n,this.scale=r}intoRaw(){let e=De.intoRaw(this.scale),t=jt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class jV extends Dr{constructor(e,t){super(),this.type=zn.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return jt.cylinder(this.halfHeight,this.radius)}}class GV extends Dr{constructor(e,t,n){super(),this.type=zn.RoundCylinder,this.borderRadius=n,this.halfHeight=e,this.radius=t}intoRaw(){return jt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class HV extends Dr{constructor(e,t){super(),this.type=zn.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return jt.cone(this.halfHeight,this.radius)}}class VV extends Dr{constructor(e,t,n){super(),this.type=zn.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=n}intoRaw(){return jt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(BV||(BV={})),function(i){i[i.NONE=0]="NONE",i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(AS||(AS={}));class Exe{free(){this.raw&&this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return De.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return De.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Sxe{constructor(e,t){this.raw=t||new bxe(e)}free(){this.raw&&this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Exe;this.raw.drainContactForceEvents(n=>{t.raw=n,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.NONE=0]="NONE",i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(MO||(MO={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(RV||(RV={})),function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"}(vS||(vS={}));class WV{constructor(e,t,n,r){this.colliderSet=e,this.handle=t,this._parent=n,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=Dr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return De.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Vi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setEnabled(e){this.colliderSet.raw.coSetEnabled(this.handle,e)}isEnabled(){return this.colliderSet.raw.coIsEnabled(this.handle)}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,n,r){let s=De.intoRaw(t),o=De.intoRaw(n),a=Vi.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,s,o,a),s.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return De.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}setHalfExtents(e){const t=De.intoRaw(e);this.colliderSet.raw.coSetHalfExtents(this.handle,t)}radius(){return this.colliderSet.raw.coRadius(this.handle)}setRadius(e){this.colliderSet.raw.coSetRadius(this.handle,e)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}setRoundRadius(e){this.colliderSet.raw.coSetRoundRadius(this.handle,e)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}setHalfHeight(e){this.colliderSet.raw.coSetHalfHeight(this.handle,e)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return De.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=De.intoRaw(e),n=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),n}projectPoint(e,t){let n=De.intoRaw(e),r=US.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,n,t));return n.free(),r}intersectsRay(e,t){let n=De.intoRaw(e.origin),r=De.intoRaw(e.dir),s=this.colliderSet.raw.coIntersectsRay(this.handle,n,r,t);return n.free(),r.free(),s}castShape(e,t,n,r,s,o,a){let l=De.intoRaw(e),c=De.intoRaw(n),h=Vi.intoRaw(r),d=De.intoRaw(s),p=t.intoRaw(),f=tx.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,l,p,c,h,d,o,a));return l.free(),c.free(),h.free(),d.free(),p.free(),f}castCollider(e,t,n,r,s){let o=De.intoRaw(e),a=De.intoRaw(n),l=qO.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,o,t.handle,a,r,s));return o.free(),a.free(),l}intersectsShape(e,t,n){let r=De.intoRaw(t),s=Vi.intoRaw(n),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,s);return r.free(),s.free(),o.free(),a}contactShape(e,t,n,r){let s=De.intoRaw(t),o=Vi.intoRaw(n),a=e.intoRaw(),l=ex.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,s,o,r));return s.free(),o.free(),a.free(),l}contactCollider(e,t){return ex.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,n){let r=De.intoRaw(e.origin),s=De.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,s,t,n);return r.free(),s.free(),o}castRayAndGetNormal(e,t,n){let r=De.intoRaw(e.origin),s=De.intoRaw(e.dir),o=NS.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,s,t,n));return r.free(),s.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(DA||(DA={}));class hn{constructor(e){this.enabled=!0,this.shape=e,this.massPropsMode=DA.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Vi.identity(),this.translation=De.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=tr.Average,this.restitutionCombineRule=tr.Average,this.activeCollisionTypes=vS.DEFAULT,this.activeEvents=AS.NONE,this.activeHooks=MO.NONE,this.mass=0,this.centerOfMass=De.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=De.zeros(),this.angularInertiaLocalFrame=Vi.identity()}static ball(e){const t=new TO(e);return new hn(t)}static capsule(e,t){const n=new OV(e,t);return new hn(n)}static segment(e,t){const n=new LV(e,t);return new hn(n)}static triangle(e,t,n){const r=new FV(e,t,n);return new hn(r)}static roundTriangle(e,t,n,r){const s=new UV(e,t,n,r);return new hn(s)}static polyline(e,t){const n=new NV(e,t);return new hn(n)}static trimesh(e,t){const n=new QV(e,t);return new hn(n)}static cuboid(e,t,n){const r=new PV(e,t,n);return new hn(r)}static roundCuboid(e,t,n,r){const s=new kV(e,t,n,r);return new hn(s)}static heightfield(e,t,n,r){const s=new zV(e,t,n,r);return new hn(s)}static cylinder(e,t){const n=new jV(e,t);return new hn(n)}static roundCylinder(e,t,n){const r=new GV(e,t,n);return new hn(r)}static cone(e,t){const n=new HV(e,t);return new hn(n)}static roundCone(e,t,n){const r=new VV(e,t,n);return new hn(r)}static convexHull(e){const t=new BO(e,null);return new hn(t)}static convexMesh(e,t){const n=new BO(e,t);return new hn(n)}static roundConvexHull(e,t){const n=new RO(e,null,t);return new hn(n)}static roundConvexMesh(e,t,n){const r=new RO(e,t,n);return new hn(r)}setTranslation(e,t,n){if(typeof e!="number"||typeof t!="number"||typeof n!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:n},this}setRotation(e){return Vi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setEnabled(e){return this.enabled=e,this}setDensity(e){return this.massPropsMode=DA.Density,this.density=e,this}setMass(e){return this.massPropsMode=DA.Mass,this.mass=e,this}setMassProperties(e,t,n,r){return this.massPropsMode=DA.MassProps,this.mass=e,De.copy(this.centerOfMass,t),De.copy(this.principalAngularInertia,n),Vi.copy(this.angularInertiaLocalFrame,r),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}for(var Zxe={byteLength:function(i){var e=qV(i),t=e[0],n=e[1];return 3*(t+n)/4-n},toByteArray:function(i){var e,t,n=qV(i),r=n[0],s=n[1],o=new Ixe(function(c,h,d){return 3*(h+d)/4-d}(0,r,s)),a=0,l=s>0?r-4:r;for(t=0;t<l;t+=4)e=La[i.charCodeAt(t)]<<18|La[i.charCodeAt(t+1)]<<12|La[i.charCodeAt(t+2)]<<6|La[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return s===2&&(e=La[i.charCodeAt(t)]<<2|La[i.charCodeAt(t+1)]>>4,o[a++]=255&e),s===1&&(e=La[i.charCodeAt(t)]<<10|La[i.charCodeAt(t+1)]<<4|La[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,n=t%3,r=[],s=16383,o=0,a=t-n;o<a;o+=s)r.push(Txe(i,o,o+s>a?a:o+s));return n===1?(e=i[t-1],r.push(Sc[e>>2]+Sc[e<<4&63]+"==")):n===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Sc[e>>10]+Sc[e>>4&63]+Sc[e<<2&63]+"=")),r.join("")}},Sc=[],La=[],Ixe=typeof Uint8Array<"u"?Uint8Array:Array,DO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",PA=0,Mxe=DO.length;PA<Mxe;++PA)Sc[PA]=DO[PA],La[DO.charCodeAt(PA)]=PA;function qV(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Txe(i,e,t){for(var n,r,s=[],o=e;o<t;o+=3)n=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),s.push(Sc[(r=n)>>18&63]+Sc[r>>12&63]+Sc[r>>6&63]+Sc[63&r]);return s.join("")}La["-".charCodeAt(0)]=62,La["_".charCodeAt(0)]=63;const Bxe=Symbol("object"),PO=new ra(()=>new E,20);class XV{constructor(e,t,n,r,s,o){u(this,"_point"),u(this,"_normal"),u(this,"_tangentVelocity"),u(this,"distance"),u(this,"impulse"),u(this,"friction"),this._point=e,this.distance=t,this._normal=n,this.impulse=r,this.friction=s,this._tangentVelocity=o}get point(){return PO.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return PO.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return PO.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class YV{constructor(e,t,n){u(this,"contacts"),u(this,"me"),u(this,"_collider"),u(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=n}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class JV{constructor(e,t){u(this,"object"),u(this,"collider"),this.object=e,this.collider=t}}const rs=ee("debugphysics"),kO=ee("debugcolliderplacement"),OO=ee("debugcollisions"),Rxe=ee("showcolliders"),LO=ee("debugraycasts"),wo=Symbol("needle component"),io=Symbol("physics body"),KV=Symbol("rigidbody");let Ff;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,rs&&console.log("Use Rapier",!1,globalThis.false);const yS=class{constructor(){u(this,"debugRenderColliders",!1),u(this,"debugRenderRaycasts",!1),u(this,"context"),u(this,"_initializePromise"),u(this,"_isInitialized",!1),u(this,"rapierRay",new wxe({x:0,y:0,z:0},{x:0,y:0,z:1})),u(this,"raycastVectorsBuffer",new ra(()=>new E,10)),u(this,"rapierSphere",null),u(this,"rapierColliderArray",[]),u(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1}),u(this,"rapierForwardVector",{x:0,y:0,z:1}),u(this,"enabled",!1),u(this,"_tempPosition",new E),u(this,"_tempQuaternion",new Ce),u(this,"_tempScale",new E),u(this,"_tempMatrix",new ge),u(this,"_isUpdatingPhysicsWorld",!1),u(this,"_world"),u(this,"_hasCreatedWorld",!1),u(this,"eventQueue"),u(this,"collisionHandler"),u(this,"objects",[]),u(this,"bodies",[]),u(this,"_meshCache",new Map),u(this,"_gravity",{x:0,y:-9.81,z:0}),u(this,"lines"),u(this,"_tempCenterPos",new E),u(this,"_tempCenterVec",new E),u(this,"_tempCenterQuaternion",new Ce)}removeBody(i){var e,t,n;if(!i)return;this.validate();const r=i[io];if(i[io]=null,r&&this.world){const s=this.objects.findIndex(o=>o===i);if(s>=0){const o=this.bodies[s];if(this.bodies.splice(s,1),this.objects.splice(s,1),o instanceof WV){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[wo]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof DV&&(o.numColliders()<=0?(n=this.world)==null||n.removeRigidBody(o):rt()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const n=i,r=n[io];r&&this.syncPhysicsBody(n.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[io];t&&(this.internalUpdateColliderProperties(e,t),e.sharedMaterial&&this.updatePhysicsMaterial(e))}else{const e=i,t=this.internal_getRigidbody(e);t&&this.internalUpdateRigidbodyProperties(e,t)}}addForce(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.addForce(e,t):console.warn("Rigidbody doesn't exist: can not apply force")}addImpulse(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.applyImpulse(e,t):console.warn("Rigidbody doesn't exist: can not apply impulse")}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.applyImpulse(e,t):console.warn("Rigidbody doesn't exist: can not apply impulse")}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?e.wakeUp():console.warn("Rigidbody doesn't exist: can not wake up")}isSleeping(i){this.validate();const e=this.internal_getRigidbody(i);return e?.isSleeping()}setAngularVelocity(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.setAngvel(e,t):console.warn("Rigidbody doesn't exist: can not set angular velocity")}setLinearVelocity(i,e,t){this.validate();const n=this.internal_getRigidbody(i);n?n.setLinvel(e,t):console.warn("Rigidbody doesn't exist: can not set linear velocity")}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return rs&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&rs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||rs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t){var n;let r=t?.maxDistance,s=t?.solid;r===void 0&&(r=1/0),s===void 0&&(s=!0);const o=this.getPhysicsRay(this.rapierRay,i,e);if(!o)return null;(this.debugRenderRaycasts||LO)&&At.DrawRay(o.origin,o.dir,255,1);const a=(n=this.world)==null?void 0:n.castRay(o,r,s,t?.queryFilterFlags,t?.filterGroups,void 0,void 0,l=>{const c=l[wo];return t!=null&&t.filterPredicate?t.filterPredicate(c):!(c!=null&&c.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),c=this.raycastVectorsBuffer.get();return c.set(l.x,l.y,l.z),{point:c,collider:a.collider[wo]}}return null}raycastAndGetNormal(i,e,t){var n;let r=t?.maxDistance,s=t?.solid;r===void 0&&(r=1/0),s===void 0&&(s=!0);const o=this.getPhysicsRay(this.rapierRay,i,e);if(!o)return null;(this.debugRenderRaycasts||LO)&&At.DrawRay(o.origin,o.dir,255,1);const a=(n=this.world)==null?void 0:n.castRayAndGetNormal(o,r,s,t?.queryFilterFlags,t?.filterGroups,void 0,void 0,l=>{const c=l[wo];return t!=null&&t.filterPredicate?t.filterPredicate(c):!(c!=null&&c.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),c=a.normal,h=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return h.set(l.x,l.y,l.z),d.set(c.x,c.y,c.z),{point:h,normal:d,collider:a.collider[wo]}}return null}getPhysicsRay(i,e,t){var n,r,s;const o=(n=this.context)==null?void 0:n.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(rs&&console.warn("Converting screenspace to raycast space",c),(s=this.context)==null||s.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=Tt(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new TO(e)),this.rapierSphere.radius=e,(this.debugRenderRaycasts||LO)&&At.DrawWireSphere(i,e,3359999,1),this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const n=t[wo],r=new JV(n.gameObject,n);return this.rapierColliderArray.push(r),!0},void 0,void 0,void 0,void 0,t=>t.isSensor()?!1:t[wo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,n;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((n=this.world)==null||n.free())}async addBoxCollider(i,e){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const t=i.gameObject,n=zi(t,this._tempPosition).multiply(e);n.multiplyScalar(.5),n.x<0&&(n.x=Math.abs(n.x)),n.y<0&&(n.y=Math.abs(n.y)),n.z<0&&(n.z=Math.abs(n.z)),n.x==0&&(n.x=1e-7),n.y==0&&(n.y=1e-7),n.z==0&&(n.z=1e-7);const r=hn.cuboid(n.x,n.y,n.z);this.createCollider(i,r)}async addSphereCollider(i){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const e=hn.ball(.5);this.createCollider(i,e),this.updateProperties(i)}async addCapsuleCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}const n=i.gameObject,r=zi(n,this._tempPosition);r.x=Math.abs(r.x),r.y=Math.abs(r.y);const s=t*r.x;e=Math.max(e,s*2);const o=$e.clamp(e*.5*r.y-t*r.x,0,Number.MAX_SAFE_INTEGER),a=hn.capsule(o,s);this.createCollider(i,a)}async addMeshCollider(i,e,t,n){var r,s,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){rs&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){rs&&console.warn("Missing mesh geometry",e.name);return}(s=(r=a.index)==null?void 0:r.array)!=null&&s.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=Cae(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(n.x-1)>1e-4||Math.abs(n.y-1)>1e-4||Math.abs(n.z-1)>1e-4){const d=a.uuid+"_"+n.x+"_"+n.y+"_"+n.z+"_"+t;if(this._meshCache.has(d))rs&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{(rs||rt())&&console.warn(`Your MeshCollider "${i.name}" is scaled: consider applying the scale to the collider mesh instead (${n.x}, ${n.y}, ${n.z})`);const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*n.x,p[f+1]=l[f+1]*n.y,p[f+2]=l[f+2]*n.z;l=p,this._meshCache.set(d,p)}}const h=t?hn.convexHull(l):hn.trimesh(l,c);h&&this.createCollider(i,h)}updatePhysicsMaterial(i){if(!i)return;const e=i.sharedMaterial,t=i[io];if(t&&e){if(e.bounciness!==void 0&&t.setRestitution(e.bounciness),e.bounceCombine!==void 0)switch(e.bounceCombine){case Er.Average:t.setRestitutionCombineRule(tr.Average);break;case Er.Maximum:t.setRestitutionCombineRule(tr.Max);break;case Er.Minimum:t.setRestitutionCombineRule(tr.Min);break;case Er.Multiply:t.setRestitutionCombineRule(tr.Multiply);break}if(e.dynamicFriction!==void 0&&t.setFriction(e.dynamicFriction),e.frictionCombine!==void 0)switch(e.frictionCombine){case Er.Average:t.setFrictionCombineRule(tr.Average);break;case Er.Maximum:t.setFrictionCombineRule(tr.Max);break;case Er.Minimum:t.setFrictionCombineRule(tr.Min);break;case Er.Multiply:t.setFrictionCombineRule(tr.Multiply);break}}}getBody(i){return i?i[io]:null}getComponent(i){return i?i[wo]:null}createCollider(i,e){var t;if(!this.world)throw new Error("Physics world not initialized");const n=this._tempMatrix;let r;i.attachedRigidbody?r=this.getRigidbody(i,this._tempMatrix):(rs&&console.log("Create collider without rigidbody",i.name),n.makeRotationFromQuaternion(Ti(i.gameObject)),n.setPosition(Tt(i.gameObject))),n.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),this.tryApplyCenter(i,this._tempPosition),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const s=i.sharedMaterial;if(s){if(s.bounciness!==void 0&&e.setRestitution(s.bounciness),s.bounceCombine!==void 0)switch(s.bounceCombine){case Er.Average:e.setRestitutionCombineRule(tr.Average);break;case Er.Maximum:e.setRestitutionCombineRule(tr.Max);break;case Er.Minimum:e.setRestitutionCombineRule(tr.Min);break;case Er.Multiply:e.setRestitutionCombineRule(tr.Multiply);break}if(s.dynamicFriction!==void 0&&e.setFriction(s.dynamicFriction),s.frictionCombine!==void 0)switch(s.frictionCombine){case Er.Average:e.setFrictionCombineRule(tr.Average);break;case Er.Maximum:e.setFrictionCombineRule(tr.Max);break;case Er.Minimum:e.setFrictionCombineRule(tr.Min);break;case Er.Multiply:e.setFrictionCombineRule(tr.Multiply);break}}((t=i.attachedRigidbody)==null?void 0:t.autoMass)===!1&&(e.setDensity(1e-6),e.setMass(1e-6));try{const o=this.world.createCollider(e,r);return o[wo]=i,i[io]=o,o.setActiveEvents(AS.COLLISION_EVENTS),o.setActiveCollisionTypes(vS.ALL),this.objects.push(i),this.bodies.push(o),this.updateColliderCollisionGroups(i),o}catch(o){return console.error('Error creating collider "'+i.name+`"
7502
+ Error:`,o),null}}updateColliderCollisionGroups(i){const e=i[io],t=i.membership;let n=0;if(t==null)n=65535;else for(let o=0;o<t.length;o++){const a=t[o];a>31?console.error(`Rapier only supports 32 layers, layer ${a} is not supported`):n|=1<<Math.floor(a)}const r=i.filter;let s=0;if(r==null)s=65535;else for(let o=0;o<r.length;o++){const a=r[o];a>31?console.error(`Rapier only supports 32 layers, layer ${a} is not supported`):s|=1<<Math.floor(a)}e.setCollisionGroups(n<<16|s)}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null;if(i.attachedRigidbody){const n=i.attachedRigidbody;if(t=n[io],!t){const r=n.isKinematic&&!kO;rs&&console.log("Create rigidbody",r);const s=r?Ff.RigidBodyDesc.kinematicPositionBased():Ff.RigidBodyDesc.dynamic(),o=Tt(i.attachedRigidbody.gameObject);s.setTranslation(o.x,o.y,o.z),s.setRotation(Ti(i.attachedRigidbody.gameObject)),s.centerOfMass=new Ff.Vector3(n.centerOfMass.x,n.centerOfMass.y,n.centerOfMass.z),t=this.world.createRigidBody(s),this.bodies.push(t),this.objects.push(n)}t[wo]=n,n[io]=t,this.internalUpdateRigidbodyProperties(n,t),this.getRigidbodyRelativeMatrix(i.gameObject,n.gameObject,e),i[KV]=t}else{const n=Ff.RigidBodyDesc.kinematicPositionBased(),r=Tt(i.gameObject);n.setTranslation(r.x,r.y,r.z),n.setRotation(Ti(i.gameObject)),t=this.world.createRigidBody(n),e.identity(),t[wo]=null}return t}internal_getRigidbody(i){return i.isCollider===!0?i[KV]:i[io]}internalUpdateColliderProperties(i,e){const t=e.shape;let n=!1;switch(t.type){case zn.Ball:{const d=t,p=i,f=i.gameObject,m=zi(f,this._tempPosition),A=Math.abs(p.radius*m.x);n=d.radius!==A,d.radius=A,n&&e.setShape(d);break}case zn.Cuboid:const r=t,s=i,o=i.gameObject,a=zi(o,this._tempPosition),l=s.size.x*.5*a.x,c=s.size.y*.5*a.y,h=s.size.z*.5*a.z;n=r.halfExtents.x!==l||r.halfExtents.y!==c||r.halfExtents.z!==h,r.halfExtents.x=l,r.halfExtents.y=c,r.halfExtents.z=h,n&&e.setShape(r);break}if(n){const r=i.attachedRigidbody;if(r!=null&&r.autoMass){const s=this.getBody(r);s?.recomputeMassPropertiesFromColliders()}}this.updateColliderCollisionGroups(i),i.isTrigger!==e.isSensor()&&e.setSensor(i.isTrigger)}internalUpdateRigidbodyProperties(i,e){if(e.enableCcd(i.collisionDetectionMode!==EC.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),i.dominanceGroup<=127&&i.dominanceGroup>=-127?e.setDominanceGroup(Math.floor(i.dominanceGroup)):e.setDominanceGroup(0),i.autoMass){e.setAdditionalMass(0,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1);e.recomputeMassPropertiesFromColliders()}else{e.setAdditionalMass(i.mass,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1e-7);e.recomputeMassPropertiesFromColliders()}e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!1),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!1),i.isKinematic?e.setBodyType(Ff.RigidBodyType.KinematicPositionBased,!1):e.setBodyType(Ff.RigidBodyType.Dynamic,!1)}step(i){if(this.world&&this.enabled){if(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Sxe(!1)),i===void 0||i<=0){this._isUpdatingPhysicsWorld=!1;return}else i!==void 0&&(this.world.timestep=$e.lerp(this.world.timestep,i,.8));try{this.world.step(this.eventQueue)}catch(e){console.warn("Error running physics step",e)}this._isUpdatingPhysicsWorld=!1}}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Dxe(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()),this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,n,r;if(rs||kO||Rxe||this.debugRenderColliders===!0){if(!this.lines){const o=new Xi({color:7855479,fog:!1}),a=new gt;this.lines=new Ns(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const s=i.debugRender();this.lines.geometry.setAttribute("position",new et(s.vertices,3)),this.lines.geometry.setAttribute("color",new et(s.colors,4)),(this.context.time.frame%30===0||((n=this.lines.geometry.boundingSphere)==null?void 0:n.radius)===0)&&this.lines.geometry.computeBoundingSphere()}else this.lines&&((r=this.context)==null||r.scene.remove(this.lines))}syncObjects(){if(!kO)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],n=e;if(n?.isCollider===!0&&!n.attachedRigidbody){const a=t.parent();a?this.syncPhysicsBody(e.gameObject,a,!0,!0):this.syncPhysicsBody(e.gameObject,t,!0,!0);continue}const r=t.translation(),s=t.rotation();if(Number.isNaN(r.x)||Number.isNaN(s.x)){!n.__COLLIDER_NAN&&rt()&&(console.warn("Collider has NaN values",n.name,n.gameObject,t),n.__COLLIDER_NAN=!0);continue}const o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(s.x,s.y,s.z,s.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion),l=zi(e.gameObject);a.multiply(l),r.x-=a.x,r.y-=a.y,r.z-=a.z}pp(e.gameObject,r.x,r.y,r.z),nB(e.gameObject,s.x,s.y,s.z,s.w)}}syncPhysicsBody(i,e,t,n){if(e instanceof DV){const r=Tt(i,this._tempPosition),s=Ti(i,this._tempQuaternion);switch(e.bodyType()){case Wb.Fixed:case Wb.KinematicPositionBased:case Wb.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),n&&e.setNextKinematicRotation(s);break;default:t&&e.setTranslation(r,!1),n&&e.setRotation(s,!1);break}}else if(e instanceof WV){const r=Tt(i,this._tempPosition),s=Ti(i,this._tempQuaternion),o=e[wo];if(this.tryApplyCenter(o,r),t){const a=e.translation();(a.x!==r.x||a.y!==r.y||a.z!==r.z)&&e.setTranslation(r)}if(n){const a=e.rotation();(a.x!==s.x||a.y!==s.y||a.z!==s.z||a.w!==s.w)&&e.setRotation(s)}}}tryApplyCenter(i,e){const t=i.center;t&&i.gameObject&&(t.x!==0||t.y!==0||t.z!==0)&&(this._tempCenterPos.x=-t.x,this._tempCenterPos.y=t.y,this._tempCenterPos.z=t.z,zi(i.gameObject,this._tempCenterVec),this._tempCenterPos.multiply(this._tempCenterVec),i.attachedRigidbody?this._tempCenterPos.applyQuaternion(i.gameObject.quaternion):(Ti(i.gameObject,this._tempCenterQuaternion),this._tempCenterPos.applyQuaternion(this._tempCenterQuaternion)),e.x+=this._tempCenterPos.x,e.y+=this._tempCenterPos.y,e.z+=this._tempCenterPos.z)}getRigidbodyRelativeMatrix(i,e,t,n){if(n===void 0&&(n=yS._matricesBuffer,n.length=0),i===e){const r=zi(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let s=n.length-1;s>=0;s--)t.multiply(n[s]);return t}return n.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,n),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[io],n=e[io];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=Uh.fixed(yS.centerConnectionPos,yS.centerConnectionRot,this._tempPosition,this._tempQuaternion),s=this.world.createImpulseJoint(r,t,n,!0);rs&&console.log("ADD FIXED JOINT",s)}addHingeJoint(i,e,t,n){if(!this.world){console.error("Physics world not initialized");return}const r=i[io],s=e[io];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=Ff.JointData.revolute(t,this._tempPosition,n),a=this.world.createImpulseJoint(o,r,s,!0);rs&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const n=i.matrixWorld,r=e.matrixWorld;n.elements[0]=1,n.elements[5]=1,n.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,t.copy(r).premultiply(n.invert()).invert()}};let qb=yS;u(qb,"_didLoadPhysicsEngine",!1),u(qb,"_matricesBuffer",[]),u(qb,"centerConnectionPos",{x:0,y:0,z:0}),u(qb,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Dxe{constructor(e,t){u(this,"world"),u(this,"eventQueue"),u(this,"activeCollisions",[]),u(this,"activeCollisionsStay",[]),u(this,"activeTriggers",[]),this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,n)=>{const r=this.world.getCollider(e),s=this.world.getCollider(t);if(!r||!s)return;const o=r[wo],a=s[wo];OO&&console.log("EVT",o.name,a.name,n,r,s),o&&a&&(n?(this.onCollisionStarted(o,r,a,s),this.onCollisionStarted(a,s,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,n,r){let s=null;if(e.isTrigger||n.isTrigger)Vp(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(n),this.activeTriggers.push({collider:e,component:o,otherCollider:n})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{Vp(o,c=>{var h;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||OO){if(!s){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),y=a.solverContactFriction(m),b=a.solverContactTangentVelocity(m),x=new XV(A,g,f,v,y,b);p.push(x),OO&&At.DrawDirection(A,f,16711680,3,!0)}}s=new YV(o,n,p)}if(d){const p={collider:e,component:c,collision:s};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(h=c.onCollisionEnter)==null||h.call(c,s)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){if(e.collision.collider.destroyed)continue;const n=e.collision;t.onCollisionStay(n)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const n=e.otherCollider;if(n.destroyed)continue;t.onTriggerStay(n)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let n=0;n<this.activeCollisions.length;n++){const r=this.activeCollisions[n],s=r.collider;if(s.destroyed||r.collision.collider.destroyed){this.activeCollisions.splice(n,1),n--;continue}if(s===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(n,1),n--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let n=0;n<this.activeCollisionsStay.length;n++){const r=this.activeCollisionsStay[n],s=r.collider;if(s.destroyed||r.collision.collider.destroyed){this.activeCollisionsStay.splice(n,1),n--;continue}if(s===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(n,1),n--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let n=0;n<this.activeTriggers.length;n++){const r=this.activeTriggers[n],s=r.collider;if(s.destroyed||r.otherCollider.destroyed){this.activeTriggers.splice(n,1),n--;continue}if(s===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(n,1),n--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}class Pxe{static async createComparisonScene(e){const{files:t}=e,n=await Promise.all(t.map(m=>new ti(m).loadAssetAsync())),r=new Fr;let s=0;for(const m of n)if(m instanceof ve){m.position.y=s,r.add(m);const A=lu([m]);s+=A.getSize(new E).y,s+=.1}const o=new Dt(20);r.add(o);const a=e.environment||"https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/studio_small_09_1k.exr";if(a){let m=null;if(a.endsWith(".hdr")){const A=(await Promise.resolve().then(()=>Fde)).RGBELoader;m=new A}else if(a.endsWith(".exr")){const A=(await Promise.resolve().then(()=>Lde)).EXRLoader;m=new A}if(m){const A=await m.loadAsync(a).catch(v=>(console.error(v),null));A&&(A.mapping=ro,A.needsUpdate=!0,r.background=A,r.environment=A,r.backgroundBlurriness=.75)}else console.warn("Unsupported environment map format",a)}const l=lu(r.children),c=l.getCenter(new E),h=l.getSize(new E),d=Math.max(h.x,h.y,h.z)/(2*Math.tan(Math.PI*o.fov/360));o.position.set(c.x,c.y,d),o.lookAt(c);const p=new y8(o,e.domElement||document.body);p.target=c,p.update();const f=(e.domElement||document.body).getBoundingClientRect();return o.aspect=f.width/f.height,o.updateProjectionMatrix(),{scene:r,camera:o}}}function kxe(i,e,t,n="image/webp",r){return ZV({context:i,width:e,height:t,mimeType:n,camera:r})}function ZV(i={mimeType:"image/png",transparent:!1}){i||(i={});let{context:e,width:t,height:n,camera:r}=i;const{mimeType:s}=i;if(!e&&(e=hi.Current,!e))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=e.mainCamera,!r))return console.error("No camera found"),null;const o=e.renderer.domElement.width,a=e.renderer.domElement.height;t||(t=o),n||(n=a);const l=window.devicePixelRatio||1;t/=l,n/=l,e.renderer.domElement.style.width=t+"px",e.renderer.domElement.style.height=n+"px";const c=e.renderer.getClearColor(new _e);try{i!=null&&i.transparent&&e.renderer.setClearColor(0,0);const h=e.renderer.domElement;e.renderer.setSize(t,n,!1),r instanceof Dt&&e.updateAspect(r,t,n);const d=i.render_events!==!1,p=new Array;d&&(kg(e.scene,Mn,p),p.forEach(m=>m?.onBeforeRender())),e.renderNow(),d&&p.forEach(m=>m.onAfterRender());const f=h.toDataURL(s);return i.download_filename&&$V(f,i.download_filename),f}finally{e.renderer.setSize(o,a,!1),e.updateSize(),e.renderer.setClearColor(c)}return null}let Xb=null;function $V(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Xb||(Xb=document.createElement("a")),Xb.href=i,Xb.download=e,Xb.click()}}let FO=0;function eW(i){i?FO++:FO--}function Oxe(){return FO>0}class tW{constructor(e){u(this,"writer"),this.writer=e}writeNode(e){}}class Lxe extends tW{beforeWriteNode(e,t){At.isGizmo(e)&&(t.keep=!1)}}class Fxe extends tW{beforeWriteTexture(e,t){e.isRenderTargetTexture&&(t.newTexture=UD(new wi(1,1,1,0)))}}const Uxe={binary:!0,animations:!0};async function Nxe(i){if(!i.context)throw new Error("No context provided to exportAsGLTF");i.scene||(i.scene=i.context.scene);const e={...Uxe,...i},{context:t}=e,n=new RE;n.register(a=>new X6(a)),n.register(a=>new Lxe(a)),n.register(a=>new Fxe(a)),ZP(n,e.context);const r={binary:e.binary,animations:zxe(t,e.scene,[])},s=new Qxe;console.log("Exporting GLTF",r),s.onBeforeExport(e),eW(!0);const o=await n.parseAsync(e.scene,r).catch(a=>(console.error(a),null));if(eW(!1),s.onAfterExport(e),!o)throw new Error("Failed to export GLTF");if(e.downloadAs!=null){let a=null;if(o instanceof ArrayBuffer?a=new Blob([o],{type:"application/octet-stream"}):console.error("Can not download GLTF as a blob",o),a){const l=URL.createObjectURL(a),c=document.createElement("a");c.href=l;let h=e.downloadAs;!h.endsWith(".glb")&&!h.endsWith(".gltf")&&(h+=e.binary?".glb":".gltf"),c.download=h,c.click()}}return o}const iW=Symbol("needle:weight");class Qxe{constructor(){u(this,"_undo",[])}onBeforeExport(e){e.context.animations.mixers.forEach(t=>{const n=zv.tryGetActionsFromMixer(t);if(n)for(let r=0;r<n.length;r++){const s=n[r];s[iW]=s.weight,s.weight=0,this._undo.push(()=>{s.weight=s[iW]})}t.update(0)})}onAfterExport(e){this._undo.forEach(t=>t()),this._undo.length=0}}function zxe(i,e,t){i.animations.mixers.forEach(r=>{const s=zv.tryGetActionsFromMixer(r);if(s)for(let o=0;o<s.length;o++){const a=s[o].getClip();t.push(a)}}),Array.isArray(e)||(e=[e]);for(const r of e)zv.tryGetAnimationClipsFromObjectHierarchy(r,t);const n=new Set(t);return Array.from(n)}Object.defineProperty(Dt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(Dt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(Dt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});const bS=ee("debugmissingcamera");hi.registerCallback(Ei.MissingCamera,i=>{var e,t,n;bS&&console.warn("Creating missing camera");const r=i.context.scene,s=new Dt;s.name="Default Fallback Camera",r.add(s);const o=new Ni;o.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",(n=i.context.domElement.getAttribute("skybox-image"))!=null&&n.length||0>0||i.context.lightmaps.tryGetSkybox(o.sourceId)?o.clearFlags=Zp.Skybox:o.clearFlags=Zp.SolidColor,o.backgroundColor=new wi(.5,.5,.5,1),o.fieldOfView=35,o.backgroundBlurriness=.2;const a=Wp(s,o,!0);s.position.x=0,s.position.y=1,s.position.z=2;const l=i.context.domElement;return l?.cameraControls!=!1&&nW(i.context,a),a}),hi.registerCallback(Ei.ContextCreated,i=>{if(!i.context.mainCamera){bS&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls==!0){const t=j3(i.context.mainCamera);if(t?.isCameraController==!0){bS&&console.log("Will not auto-fit because a camera controller exists");return}nW(i.context)}});function nW(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(bS&&console.log("Creating default camera controls",e?.name),t){const n=ay(t,vi);n.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");n.autoRotate=r!==void 0&&(r===""||r==="true"),n.autoRotateSpeed=.5,n.autoFit=!0}else console.warn("Missing camera object, can not add orbit controls")}const UO={Context:kt,glTF:{loadFromURL:EO}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=UO;function rW(i){for(const e in i)UO[e]=i[e]}rW(fpe),rW(Kbe);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:UO[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=BZ;class jxe{constructor(e){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Backoff must be a positive integer");this.backoff=e}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class Gxe{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}class Hxe{constructor(e,t,n){if(this.i=0,this._retries=0,e<0)throw new Error("Initial must be a positive number or zero");if(t<0)throw new Error("Increment must be a positive number or zero");if(n!==void 0&&n<0)throw new Error("Max must be undefined, a positive number or zero");if(n!==void 0&&n<e)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=e,this.increment=t,this.max=n}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class Vxe{constructor(){this.elements=[]}add(e){this.elements.push(e)}clear(){this.elements.length=0}forEach(e){this.elements.forEach(e)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class Wxe{constructor(e){if(!Number.isInteger(e)||e<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(e+1),this.head=0,this.tail=0}add(e){this.elements[this.head]=e,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(e){for(let t=this.tail;t!==this.head;t=(t+1)%this.elements.length)e(this.elements[t])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const e=this.peek();return e!==void 0&&(this.tail=(this.tail+1)%this.elements.length),e}}var Oi;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry",i.reconnect="reconnect"})(Oi||(Oi={}));class sW{constructor(e,t,n){var r,s,o,a,l,c,h,d,p,f,m,A,v,g,y;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(Oi.open,b),this.handleErrorEvent=b=>this.handleEvent(Oi.error,b),this.handleCloseEvent=b=>this.handleEvent(Oi.close,b),this.handleMessageEvent=b=>this.handleEvent(Oi.message,b),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(r=n?.retry)===null||r===void 0?void 0:r.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(o=n?.retry)===null||o===void 0?void 0:o.backoff},listeners:{open:[...(l=(a=n?.listeners)===null||a===void 0?void 0:a.open)!==null&&l!==void 0?l:[]],close:[...(h=(c=n?.listeners)===null||c===void 0?void 0:c.close)!==null&&h!==void 0?h:[]],error:[...(p=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&p!==void 0?p:[]],message:[...(m=(f=n?.listeners)===null||f===void 0?void 0:f.message)!==null&&m!==void 0?m:[]],retry:[...(v=(A=n?.listeners)===null||A===void 0?void 0:A.retry)!==null&&v!==void 0?v:[]],reconnect:[...(y=(g=n?.listeners)===null||g===void 0?void 0:g.reconnect)!==null&&y!==void 0?y:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const r=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(Oi.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(Oi.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(Oi.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(Oi.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(Oi.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(Oi.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(Oi.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(Oi.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],r=[];n.forEach(({listener:s,options:o})=>{s(this,t),(o===void 0||o.once===void 0||!o.once)&&r.push({listener:s,options:o})}),this._options.listeners[e]=r}handleEvent(e,t){switch(e){case Oi.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case Oi.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},r=new CustomEvent(Oi.reconnect,{detail:n});this.dispatchEvent(Oi.reconnect,r),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case Oi.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const r=new CustomEvent(Oi.retry,{detail:n});this.handleEvent(Oi.retry,r)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class qxe{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(Oi.open,e,t),this}onClose(e,t){return this.addListener(Oi.close,e,t),this}onError(e,t){return this.addListener(Oi.error,e,t),this}onMessage(e,t){return this.addListener(Oi.message,e,t),this}onRetry(e,t){return this.addListener(Oi.retry,e,t),this}onReconnect(e,t){return this.addListener(Oi.reconnect,e,t),this}build(){return new sW(this._url,this._protocols,this._options)}addListener(e,t,n){var r,s,o,a,l,c,h,d,p,f,m,A,v,g,y,b,x,w,I,M,T;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(o=(s=(r=this._options)===null||r===void 0?void 0:r.listeners)===null||s===void 0?void 0:s.open)!==null&&o!==void 0?o:[],close:(c=(l=(a=this._options)===null||a===void 0?void 0:a.listeners)===null||l===void 0?void 0:l.close)!==null&&c!==void 0?c:[],error:(p=(d=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||d===void 0?void 0:d.error)!==null&&p!==void 0?p:[],message:(A=(m=(f=this._options)===null||f===void 0?void 0:f.listeners)===null||m===void 0?void 0:m.message)!==null&&A!==void 0?A:[],retry:(y=(g=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||g===void 0?void 0:g.retry)!==null&&y!==void 0?y:[],reconnect:(w=(x=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||x===void 0?void 0:x.reconnect)!==null&&w!==void 0?w:[],[e]:[...(T=(M=(I=this._options)===null||I===void 0?void 0:I.listeners)===null||M===void 0?void 0:M[e])!==null&&T!==void 0?T:[],{listener:t,options:n}]}}),this}}const Xxe=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:Vxe,ConstantBackoff:jxe,ExponentialBackoff:Gxe,LinearBackoff:Hxe,RingQueue:Wxe,Websocket:sW,WebsocketBuilder:qxe,get WebsocketEvent(){return Oi}},Symbol.toStringTag,{value:"Module"})),Fa={node:"node",material:"material",camera:"camera",light:"light"},Uf="KHR_animation_pointer",Yxe={CUBICSPLINE:void 0,LINEAR:Il,STEP:qh},oW=Ht.findNode;let aW=!1;class Jxe{constructor(e){this.parser=e,this.name=Uf,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){aW||(aW=!0,Ht.findNode=function(e,t){if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),r=n.indexOf("."),s=r<0?n:n.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===s||a.material.name===s)&&(o=a.material,o!==null&&(n.endsWith(".map")?o=o.map:n.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let r;for(let s=1;s<n.length;s++){const o=n[s];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const s=oW(e,n[2]);return s||console.warn(Uf+": Property binding not found",t,e,e.name,n),s}return r}return oW(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,n=t.extensions&&t.extensions[Uf]&&t.path&&t.path==="pointer";if(!n)return null;let r,s=Fa.node,o;if(n){const l=t.extensions[Uf];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?s=Fa.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?s=Fa.light:c.startsWith("/cameras/")&&(s=Fa.camera),o=this._tryResolveTargetId(c,s),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(s){case Fa.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case Fa.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case Fa.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case Fa.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(c=h.resolvePath(c)),t.extensions[Uf].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return s===Fa.node?a=this.parser.getDependency("node",o):s===Fa.material?a=this.parser.getDependency("material",o):s===Fa.light?a=this.parser.getDependency("light",o):s===Fa.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",s),a}createAnimationTracksWithAnimationPointer(e,t,n,r,s){if(!(s.extensions&&s.extensions[Uf]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[Uf].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof lo&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",h(this.parser));return a}h(this.parser);function h(d){o=l.join(".");let p;switch(n.itemSize){case 1:p=Gc;break;case 2:case 3:p=Rl;break;case 4:o.endsWith(".quaternion")?p=na:p=R_;break}const f=r.interpolation!==void 0?Yxe[r.interpolation]:Il;let m=d._getArrayFromAccessor(n);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let y=0,b=m.length/4;y<b;y+=1)v[y]=m[y*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,r=this.parser,s=n.animations[e],o=s.name?s.name:"animation_"+e,a=[],l=[],c=[],h=[],d=[];for(let p=0,f=s.channels.length;p<f;p++){const m=s.channels[p],A=s.samplers[m.sampler],v=m.target,g=s.parameters!==void 0?s.parameters[A.input]:A.input,y=s.parameters!==void 0?s.parameters[A.output]:A.output;let b=t.loadAnimationTargetFromChannelWithAnimationPointer(m);b||(b=t.loadAnimationTargetFromChannel(m)),a.push(b),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",y)),h.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],y=[];for(let b=0,x=f.length;b<x;b++){const w=f[b],I=m[b],M=A[b],T=v[b],D=g[b];if(w===void 0)continue;w.updateMatrix&&(w.updateMatrix(),w.matrixAutoUpdate=!0);let S=t.createAnimationTracksWithAnimationPointer(w,I,M,T,D);if(S||(S=r._createAnimationTracks(w,I,M,T,D)),S)for(let B=0;B<S.length;B++)y.push(S[B])}return new Qs(o,void 0,y)})}}const Kxe=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Jxe},Symbol.toStringTag,{value:"Module"}));export{Bxe as $physicsKey,fi as ActionBuilder,w2 as ActionCollection,Aa as ActionModel,DG as Addressables,uy as AlignmentConstraint,Bg as AmbientMode,xs as Animation,Yp as AnimationCurve,Sy as AnimationExtension,kC as AnimationTrackHandler,Vr as Animator,ed as AnimatorConditionMode,Zo as AnimatorController,pP as AnimatorControllerParameterType,Ey as AnimatorStateInfo,My as Antialiasing,Gu as Application,tC as ApplicationEvents,Nj as AssetDatabase,ti as AssetReference,Cd as AudioExtension,Ku as AudioListener,In as AudioSource,wy as AudioTrackHandler,ef as Avatar,nf as AvatarBlink_Simple,Wg as AvatarEyeLook_Rotation,wP as AvatarLoader,qr as AvatarMarker,GC as AvatarModel,Py as Avatar_Brain_LookAt,Oy as Avatar_MouthShapes,bP as Avatar_MustacheShake,ic as Avatar_POI,Ug as Axes,qg as AxesHelper,pB as BUILD_TIME,Na as BaseUIComponent,EP as BasicIKConstraint,HC as BehaviorExtension,yr as BehaviorModel,Re as Behaviour,rf as Bloom,Yg as BoxCollider,of as BoxGizmo,rc as BoxHelperComponent,Ch as Button,gh as ButtonsFactory,N8 as CallDirection,Lg as CallInfo,Ni as Camera,vy as CameraTargetReachedEvent,Xr as Canvas,sd as CanvasGroup,wh as CapsuleCollider,Zg as ChangeMaterialOnClick,cf as ChangeTransformOnClick,df as CharacterController,Sh as CharacterControllerInput,Hy as ChromaticAberration,ra as CircularBuffer,Zp as ClearFlags,Kl as ClipExtrapolation,zo as Collider,YV as Collision,EC as CollisionDetectionMode,lc as ColorAdjustments,gf as ColorBySpeedModule,nb as ColorOverLifetimeModule,Re as Component,Dv as ComponentEvents,Pv as ComponentLifecycleEvents,hH as ConnectionEvents,XV as ContactPoint,hc as ContactShadows,kt as Context,ipe as ContextArgs,Ei as ContextEvent,hi as ContextRegistry,OC as ControlTrackHandler,pd as CustomBranding,gl as CustomShader,lC as DefaultReflectionMode,pk as Deletable,EE as DeleteBox,yl as DepthOfField,SE as DeviceFlag,fk as DocumentExtension,Pa as DragControls,P6 as DragMode,fd as DropListener,wf as Duplicatable,cc as EmissionModule,eA as EmphasizeOnClick,yB as EngineLoadingView,Un as EventList,_C as EventListEvent,Ea as EventSystem,TE as EventTrigger,ek as FieldWithDefault,U1 as FileReference,kG as FileReferenceSerializer,F6 as FileSpawnModel,L6 as File_Event,bk as FixedJoint,xk as FlyControls,mA as Fog,Gi as FrameEvent,Aw as GENERATOR,te as GameObject,At as Gizmos,fb as GltfExport,Ik as GltfExportBox,Of as GltfLoadEvent,fV as GltfLoadEventType,ld as Gradient,af as Graphic,SC as GraphicRaycaster,Ja as Graphics,vA as GridHelper,UP as GridLayoutGroup,Cf as GroundProjectedEnv,Du as GroupActionModel,YH as HideFlags,zP as HideOnStart,ub as HingeJoint,FP as HorizontalLayoutGroup,npe as HostData,Kg as Image,L1 as ImageReference,PG as ImageReferenceSerializer,hd as InheritVelocityModule,QG as Input,Hl as InputEventQueue,on as InputEvents,Ef as InputField,Ky as InstanceHandle,Jy as InstancingHandler,Qa as InstancingUtil,QH as InstantiateEvent,Pr as InstantiateIdProvider,Cl as InstantiateOptions,dk as Interactable,Sde as JoinedRoomResponse,Oue as KeyEventArgs,wa as Keyframe,gb as LODGroup,Sf as LODModel,Ide as LeftRoomResponse,_o as Light,RH as LightData,Zn as LimitVelocityOverLifetimeModule,vne as LoadingElementOptions,Rk as LogStats,Bo as LogType,If as LookAt,Jp as LookAtConstraint,Jr as MainModule,hP as MarkerType,Qy as MaskableGraphic,$e as Mathf,sf as MeshCollider,eb as MeshRenderer,dt as MinMaxCurve,bo as MinMaxGradient,pi as NEEDLE_progressive,jv as NEKeyboardEvent,dh as NEPointerEvent,hi as NeedleEngine,SO as NeedleEngineHTMLElement,wO as NeedleGltfLoader,uc as NeedleMenu,b1 as NeedlePatchesKey,uj as NeedleUSDZExporter,cD as NeedleXRController,_t as NeedleXRSession,pH as NeedleXRSync,AH as NeedleXRUtils,FE as NestedGltf,dH as NetworkConnection,nc as NetworkedStreamEvents,$b as NetworkedStreams,bA as Networking,HH as NewInstanceModel,Mi as NoiseModule,Fo as ObjectRaycaster,ey as ObjectUtils,Mf as OffsetConstraint,dw as OneEuroFilter,JT as OneEuroFilterXYZ,xA as OpenURL,vi as OrbitControls,Jg as Outline,uH as OwnershipEvent,PD as OwnershipModel,nd as Padding,ib as ParticleBurst,$E as ParticleSubEmitter,er as ParticleSystem,Ad as ParticleSystemBaseBehaviour,ka as ParticleSystemRenderer,cE as ParticleSystemShapeType,zC as PeerHandle,aH as PeerNetworking,EH as Physics,xE as PhysicsExtension,Er as PhysicsMaterialCombine,Sb as PixelationEffect,uf as PlayAnimationOnClick,od as PlayAudioOnClick,$u as PlayableDirector,QA as PlayerColor,Ma as PlayerState,P8 as PlayerStateEvent,Gg as PlayerSync,SH as PlayerView,IH as PlayerViewManager,UA as PointerEventData,Q1 as PointerType,ws as PostProcessingEffect,KC as PostProcessingHandler,tA as PreliminaryAction,jy as PreliminaryTrigger,Gp as PrimitiveType,ei as Progress,Z_ as PromiseAllWithErrors,pT as PromiseErrorResult,wi as RGBAColor,qb as RapierPhysics,XC as RawImage,dl as RaycastOptions,PP as Rect,Cs as RectTransform,rA as ReflectionProbe,NC as RegisteredAnimationInfo,xc as RemoteSkybox,Fg as RenderTexture,f8 as RenderTextureSerializer,Mn as Renderer,BH as RendererData,Zy as RendererLightmap,ki as Rigidbody,Nn as RigidbodyConstraints,Wt as RoomEvents,Ho as RotationBySpeedModule,Ta as RotationOverLifetimeModule,rE as SceneLightSettings,Ts as SceneSwitcher,yd as ScreenCapture,Ph as ScreenSpaceAmbientOcclusion,bl as ScreenSpaceAmbientOcclusionN8,ya as SendQueue,Z2 as SerializationContext,hf as SetActiveOnClick,Bb as ShadowCatcher,An as ShapeModule,by as SignalAsset,zg as SignalReceiver,Qg as SignalReceiverEvent,Cy as SignalTrackHandler,DP as Size,eo as SizeBySpeedModule,cd as SizeOverLifetimeModule,tk as SkinnedMeshRenderer,bd as SmoothFollow,Ay as SpatialGrabRaycaster,Rb as SpatialHtml,kb as SpatialTrigger,_c as SpatialTriggerReceiver,rS as SpectatorCamera,Xg as SphereCollider,CH as SphereIntersection,JV as SphereOverlapResult,Rh as Sprite,hA as SpriteData,Ba as SpriteRenderer,ob as SpriteSheet,pfe as StateMachineBehaviour,F8 as StreamEndedEvent,U8 as StreamReceivedEvent,Eb as SubEmitterSystem,oS as SyncedCamera,wc as SyncedRoom,Yu as SyncedTransform,jP as TapGestureTrigger,yE as TeleportTarget,pO as TestRunner,Pxe as TestSceneUtils,fO as TestSimulateUserData,Ss as Text,_E as TextBuilder,ab as TextExtension,Kr as TextureSheetAnimationModule,Cc as TiltShiftEffect,PH as Time,iA as ToneMapping,xy as TrackHandler,Uo as TrackType,ln as TrailModule,Mr as TransformData,Df as TransformGizmo,br as TriggerBuilder,Pp as TriggerModel,q as TypeStore,IC as UIRaycastUtils,my as UIRootComponent,qs as USDObject,hj as USDWriter,Qn as USDZExporter,dd as USDZText,wE as USDZUIExtension,iD as Upload_Result,m8 as UriSerializer,cb as UsageMarker,Mde as UserJoinedOrLeftRoomModel,Za as VERSION,_2 as VariantAction,vn as VelocityOverLifetimeModule,LP as VerticalLayoutGroup,hr as VideoPlayer,Vu as ViewDevice,Pf as Vignette,Gy as VisibilityAction,tf as Voip,Xy as Volume,Bt as VolumeParameter,Iy as VolumeProfile,Ode as WaitForFrames,bH as WaitForPromise,yH as WaitForSeconds,Lh as Watch,cS as WebARCameraBackground,to as WebARSessionRoot,Tr as WebXR,pA as WebXRButtonFactory,TA as WebXRImageTracking,Ec as WebXRImageTrackingModel,xd as WebXRPlaneTracking,MA as WebXRTrackedImage,Fb as XRControllerFollow,pc as XRControllerModel,Ra as XRControllerMovement,Qo as XRFlag,uS as XRRig,$s as XRState,tc as XRStateFlag,vO as __Ignore,Hj as __internalNotifyObjectDestroyed,Yc as activeInHierarchyFieldName,RN as addAttributeChangeCallback,Xl as addComponent,Ege as addCustomExtensionPlugin,U6 as addFile,N6 as addFileFromUrl,rxe as addGltfLoadEventListener,Wp as addNewComponent,y1 as addPatch,bC as apply,gxe as applyHMRChanges,GH as beginListenDestroy,Q6 as beginListenFileSpawn,VH as beginListenInstantiate,fD as binaryIdentifierCasts,tpe as build_scene_functions,mp as builtinComponentKeyName,AB as calculateProgress01,NN as clearBalloonMessages,NN as clearOverlayMessages,Cpe as colorSerializer,wC as componentSerializer,J3 as copyTexture,CO as createLoader,M8 as createMotion,Zs as debugNet,Zv as debugOwner,D0 as deepClone,kl as delay,MN as delayForFrames,P1 as deserializeObject,_a as destroy,o8 as destroyComponentInstance,ji as disposeObjectResources,_h as disposeStream,RG as download,rD as download_file,H0 as editorGuidKeyName,VP as effectsOrder,Dm as enableSpatialConsole,Tpe as eventListSerializer,Nxe as exportAsGLTF,oy as findByGuid,KD as findObjectOfType,c8 as findObjectsOfType,R2 as findResourceUsers,K3 as fitObjectIntoVolume,Vp as foreachComponent,YD as foreachComponentEnumerator,Lie as forward,PN as generateQRCode,fC as generateSeed,lu as getBoundingBox,j3 as getCameraController,qp as getComponent,cy as getComponentInChildren,hy as getComponentInParent,ly as getComponents,kg as getComponentsInChildren,xC as getComponentsInParent,oj as getFormattedDate,Ao as getIconElement,zD as getIconTexture,zZ as getIp,jZ as getIpAndLocation,QZ as getIpCloudflare,Xa as getLoader,ay as getOrAddComponent,ee as getParam,Nie as getParentHierarchyPath,LZ as getPath,_de as getPeerOptions,sH as getPeerjsInstance,Qle as getResourceUserCount,dp as getTempQuaternion,En as getTempVector,R0 as getUrlParams,rB as getWorldDirection,sB as getWorldEuler,Tt as getWorldPosition,Ti as getWorldQuaternion,N0 as getWorldRotation,zi as getWorldScale,Jc as hasCommercialLicense,fB as hasIndieLicense,rP as hasPointerEventComponent,cu as hasProLicense,nD as hash,nQ as hideDebugConsole,fj as imageToCanvas,Pg as instantiate,$P as invokeAfterImportPluginHooks,LG as invokeXRSessionEnd,OG as invokeXRSessionStart,JH as isActiveInHierarchy,Dg as isActiveSelf,BN as isAndroidDevice,Y3 as isAnimationAction,DZ as isDebugMode,ap as isDesktop,Hp as isDestroyed,rt as isDevEnvironment,Ule as isDisposed,Oxe as isExporting,_N as isHostedOnGlitch,dxe as isHotReloading,kH as isIconElement,zs as isLocalNetwork,To as isMobileDevice,lp as isMozillaXR,K_ as isQuest,zj as isResourceTrackingEnabled,Tm as isSafari,AC as isUsingInstancing,cp as isiOS,EO as loadSync,mw as logHierarchy,Bie as lookAtInverse,U0 as lookAtObject,kZ as makeId,hT as makeIdFromRandomWords,hl as makeNameSafeForUSD,KH as markAsInstancedRendered,dT as microphonePermissionsGranted,RZ as nameof,wN as nameofFactory,p8 as objectSerializer,Eue as offXRSessionEnd,Cue as offXRSessionStart,Fpe as onAfterRender,Lpe as onBeforeRender,kpe as onClear,Ope as onDestroy,Ppe as onInitialized,b8 as onStart,x8 as onUpdate,oD as onXRSessionEnd,N1 as onXRSessionStart,gV as parseSync,Z3 as placeOnSurface,$3 as postprocessFBXMaterials,Npe as prefix,CN as pushState,OZ as randomNumber,mD as registerBinaryType,uC as registerComponent,JP as registerComponentExtension,Ia as registerCustomEffectType,ZP as registerExportExtensions,KP as registerExtensions,pxe as registerHotReloadType,sT as registerLoader,qH as registerPrefabProvider,ule as registerType,TN as relativePathPrefix,DN as removeAttributeChangeCallback,JD as removeComponent,Sge as removeCustomImportExtensionType,sxe as removeGltfLoadEventListener,kle as removePatch,ou as resolveUrl,IN as sanitizeString,$V as saveImage,kxe as screenshot,ZV as screenshot2,jH as sendDestroyed,_ as serializable,wG as serializeObject,Ag as serializeable,sy as setActive,FN as setAllowBalloonMessages,WZ as setAllowOverlayMessages,$T as setAutoFitEnabled,KT as setCameraController,$H as setDestroyed,qie as setDevEnvironment,B2 as setDisposable,qD as setDontDestroy,lT as setOrAddParamsToUrl,PZ as setParam,q_ as setParamWithoutReload,wde as setPeerOptions,Fle as setResourceTrackingEnabled,cT as setState,oB as setWorldEuler,mr as setWorldPosition,pp as setWorldPositionXYZ,oa as setWorldQuaternion,nB as setWorldQuaternionXYZW,aB as setWorldRotation,Q0 as setWorldRotationXYZ,Rm as setWorldScale,lB as showBalloonError,nn as showBalloonMessage,Pi as showBalloonWarning,dB as showDebugConsole,Mie as slerp,pC as syncDestroy,vP as syncField,VD as syncInstantiate,Qie as textureToCanvas,VG as tryCastBinary,uV as tryDetermineFileTypeFromBinary,hV as tryDetermineFileTypeFromURL,Im as tryFindObject,WG as tryGetGuid,fxe as unregisterHotReloadType,uT as unwatchWrite,BG as upload_file,G3 as useForAutoFit,Hr as validate,Y_ as watchWrite};