@needle-tools/engine 3.45.2-beta → 3.45.2-beta.1

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 s=qa()||H1()&&lt();if((
4344
4344
  #__vconsole .vc-mask {
4345
4345
  overflow: hidden;
4346
4346
  }
4347
- `,Qo==null||Qo.prepend(i),s===!0&&dD()<=0&&L5(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function rne(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ko==null||Ko.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function one(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function ane(){const s=document.querySelector("#__vconsole");return s||null}const U5=ie("debugdefines");Iy('if(!globalThis[""3.45.2-beta""]) globalThis[""3.45.2-beta""] = "0.0.0";');Iy('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Iy('if(!globalThis[""Wed Jul 17 2024 17:50:18 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Jul 17 2024 17:50:18 GMT+0200 (Central European Summer Time)""] = "unknown";');Iy('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta";');Iy('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Iy('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Jul 17 2024 17:50:18 GMT+0200 (Central European Summer Time)";');const La="3.45.2-beta",X1="undefined",qD="Wed Jul 17 2024 17:50:18 GMT+0200 (Central European Summer Time)";U5&&console.log(`Engine version: ${La} (generator: ${X1})
4347
+ `,Qo==null||Qo.prepend(i),s===!0&&dD()<=0&&L5(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function rne(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ko==null||Ko.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function one(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function ane(){const s=document.querySelector("#__vconsole");return s||null}const U5=ie("debugdefines");Iy('if(!globalThis[""3.45.2-beta.1""]) globalThis[""3.45.2-beta.1""] = "0.0.0";');Iy('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Iy('if(!globalThis[""Wed Jul 17 2024 19:33:36 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Jul 17 2024 19:33:36 GMT+0200 (Central European Summer Time)""] = "unknown";');Iy('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta.1";');Iy('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Iy('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Jul 17 2024 19:33:36 GMT+0200 (Central European Summer Time)";');const La="3.45.2-beta.1",X1="undefined",qD="Wed Jul 17 2024 19:33:36 GMT+0200 (Central European Summer Time)";U5&&console.log(`Engine version: ${La} (generator: ${X1})
4348
4348
  Project built at ${qD}`);const Oh="needle_isActiveInHierarchy",If="builtin_components",GA="needle_editor_guid";function Iy(s){try{(0,eval)(s)}catch(e){U5&&console.error(e)}}const lne='<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>',cne=btoa(lne),hne="data:image/svg+xml;base64,"+cne,une=hne,dne=`<?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(dne);const fne='<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>',pne=btoa(fne),mne="data:image/svg+xml;charset=utf-8;base64,"+pne,gne=mne,Pa=ie("debuglicense");let Zf="basic";Pa&&console.log("License Type: "+Zf);function ed(){switch(Zf){case"pro":case"enterprise":return!0}return!1}function XD(){switch(Zf){case"indie":return!0}return!1}function Lh(){return ed()||XD()}const N5=[];function yne(s){if(ed()||XD())return s(!0);N5.push(s)}function vne(s){for(const e of N5)try{e(s)}catch{}}di.registerCallback(Ii.ContextRegistered,s=>{bne(s.context),wne(),_ne(s.context)});let td,DP=!1,fA="";async function Ane(){if(td)return td;if(Zf==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+La+"&generator="+encodeURIComponent(X1),e=await fetch(s,{method:"GET"}).catch(t=>{Pa&&console.error("License check failed",t)});(e==null?void 0:e.status)===200?(DP=!1,Pa&&console.log("License check succeeded"),Zf="pro",vne(!0)):(e==null?void 0:e.status)===403?(DP=!0,fA=await e.text()):Pa&&console.log("License check failed with status "+(e==null?void 0:e.status))}catch(s){Pa&&console.error("License check failed",s)}else Pa&&console.log('Runtime license check is skipped because license is already applied as "'+Zf+'"')}td=Ane();async function _ne(s){function e(){const n=document.createElement("div");n.className="needle-forbidden",n.style.cssText=`
4349
4349
  position: fixed;
4350
4350
  top: 0;
@@ -5148,7 +5148,7 @@ in script ${i}.ts
5148
5148
  *
5149
5149
  * @author Feross Aboukhadijeh <https://feross.org>
5150
5150
  * @license MIT
5151
- */var nue=function(s){return s!=null&&(PQ(s)||sue(s)||!!s._isBuffer)};function PQ(s){return!!s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function sue(s){return typeof s.readFloatLE=="function"&&typeof s.slice=="function"&&PQ(s.slice(0,0))}(function(){var s=iue,e=P3.utf8,t=nue,i=P3.bin,n=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=s.bytesToWords(r),l=r.length*8,c=1732584193,h=-271733879,u=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[l>>>5]|=128<<l%32,a[(l+64>>>9<<4)+14]=l;for(var m=n._ff,y=n._gg,g=n._hh,v=n._ii,p=0;p<a.length;p+=16){var _=c,A=h,b=u,S=f;c=m(c,h,u,f,a[p+0],7,-680876936),f=m(f,c,h,u,a[p+1],12,-389564586),u=m(u,f,c,h,a[p+2],17,606105819),h=m(h,u,f,c,a[p+3],22,-1044525330),c=m(c,h,u,f,a[p+4],7,-176418897),f=m(f,c,h,u,a[p+5],12,1200080426),u=m(u,f,c,h,a[p+6],17,-1473231341),h=m(h,u,f,c,a[p+7],22,-45705983),c=m(c,h,u,f,a[p+8],7,1770035416),f=m(f,c,h,u,a[p+9],12,-1958414417),u=m(u,f,c,h,a[p+10],17,-42063),h=m(h,u,f,c,a[p+11],22,-1990404162),c=m(c,h,u,f,a[p+12],7,1804603682),f=m(f,c,h,u,a[p+13],12,-40341101),u=m(u,f,c,h,a[p+14],17,-1502002290),h=m(h,u,f,c,a[p+15],22,1236535329),c=y(c,h,u,f,a[p+1],5,-165796510),f=y(f,c,h,u,a[p+6],9,-1069501632),u=y(u,f,c,h,a[p+11],14,643717713),h=y(h,u,f,c,a[p+0],20,-373897302),c=y(c,h,u,f,a[p+5],5,-701558691),f=y(f,c,h,u,a[p+10],9,38016083),u=y(u,f,c,h,a[p+15],14,-660478335),h=y(h,u,f,c,a[p+4],20,-405537848),c=y(c,h,u,f,a[p+9],5,568446438),f=y(f,c,h,u,a[p+14],9,-1019803690),u=y(u,f,c,h,a[p+3],14,-187363961),h=y(h,u,f,c,a[p+8],20,1163531501),c=y(c,h,u,f,a[p+13],5,-1444681467),f=y(f,c,h,u,a[p+2],9,-51403784),u=y(u,f,c,h,a[p+7],14,1735328473),h=y(h,u,f,c,a[p+12],20,-1926607734),c=g(c,h,u,f,a[p+5],4,-378558),f=g(f,c,h,u,a[p+8],11,-2022574463),u=g(u,f,c,h,a[p+11],16,1839030562),h=g(h,u,f,c,a[p+14],23,-35309556),c=g(c,h,u,f,a[p+1],4,-1530992060),f=g(f,c,h,u,a[p+4],11,1272893353),u=g(u,f,c,h,a[p+7],16,-155497632),h=g(h,u,f,c,a[p+10],23,-1094730640),c=g(c,h,u,f,a[p+13],4,681279174),f=g(f,c,h,u,a[p+0],11,-358537222),u=g(u,f,c,h,a[p+3],16,-722521979),h=g(h,u,f,c,a[p+6],23,76029189),c=g(c,h,u,f,a[p+9],4,-640364487),f=g(f,c,h,u,a[p+12],11,-421815835),u=g(u,f,c,h,a[p+15],16,530742520),h=g(h,u,f,c,a[p+2],23,-995338651),c=v(c,h,u,f,a[p+0],6,-198630844),f=v(f,c,h,u,a[p+7],10,1126891415),u=v(u,f,c,h,a[p+14],15,-1416354905),h=v(h,u,f,c,a[p+5],21,-57434055),c=v(c,h,u,f,a[p+12],6,1700485571),f=v(f,c,h,u,a[p+3],10,-1894986606),u=v(u,f,c,h,a[p+10],15,-1051523),h=v(h,u,f,c,a[p+1],21,-2054922799),c=v(c,h,u,f,a[p+8],6,1873313359),f=v(f,c,h,u,a[p+15],10,-30611744),u=v(u,f,c,h,a[p+6],15,-1560198380),h=v(h,u,f,c,a[p+13],21,1309151649),c=v(c,h,u,f,a[p+4],6,-145523070),f=v(f,c,h,u,a[p+11],10,-1120210379),u=v(u,f,c,h,a[p+2],15,718787259),h=v(h,u,f,c,a[p+9],21,-343485551),c=c+_>>>0,h=h+A>>>0,u=u+b>>>0,f=f+S>>>0}return s.endian([c,h,u,f])};n._ff=function(r,o,a,l,c,h,u){var f=r+(o&a|~o&l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._gg=function(r,o,a,l,c,h,u){var f=r+(o&l|a&~l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._hh=function(r,o,a,l,c,h,u){var f=r+(o^a^l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._ii=function(r,o,a,l,c,h,u){var f=r+(a^(o|~l))+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._blocksize=16,n._digestsize=16,IQ.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=s.wordsToBytes(n(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):s.bytesToHex(a)}})();var rue=IQ.exports;const oue=cE(rue);class fB{constructor(e,t,i,n){d(this,"success");d(this,"filename");d(this,"hash");d(this,"size");d(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=n}}async function BQ(s,e){const t=await s.arrayBuffer(),i=IO(t),n=s.name.split(".").pop(),r=i+"."+n,o=s.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},c=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(c.success||console.warn("exists check did fail"),c.exists)return console.log("file already exists",i),new fB(!0,r,i,s.size);console.log("begin uploading file",o,s.size);const h=new FormData;h.append("file",s);const u={};u.filesize=s.size,o&&(u.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:h,headers:u})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new fB(p.success,r,i,s.size);return m.url=e,m}function IO(s){return oue(new Uint8Array(s))}async function RO(s,e,t,i,n=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:s});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();n||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const l=IO(a);return n||console.assert(l===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function DQ(s,e){var h;const t=await fetch(s),i=(h=t.body)==null?void 0:h.getReader(),n=t.headers.get("Content-Length"),r=n?parseInt(n):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:u,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),u)break}const l=new Uint8Array(o);let c=0;for(const u of a)l.set(u,c),c+=u.length;return l}const xu=ie("debugaddressables");class OQ{constructor(e){d(this,"_context");d(this,"_assetReferences",{});d(this,"preUpdate",()=>{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const e=this._context.pre_update_callbacks.indexOf(this.preUpdate);e>=0&&this._context.pre_update_callbacks.splice(e,1);for(const t in this._assetReferences){const i=this._assetReferences[t];i==null||i.unload()}this._assetReferences={}}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const xI=Symbol("assetReference"),Df=class{constructor(e,t,i=null){d(this,"_loading");d(this,"_asset");d(this,"_glbRoot");d(this,"_url");d(this,"_progressListeners",[]);d(this,"_hash");d(this,"_hashedUri");d(this,"_isLoadingRawBinary",!1);d(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),sj(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(e,t){if(!t&&(t=Ot.Current,!t))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const i=t.addressables,n=i.findAssetReference(e);if(n)return n;const r=new Df(e,t.hash);return i.registerAssetReference(r),r}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Ot.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const n=wd(e,t);xu&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",n);const r=i.addressables,o=r.findAssetReference(n);if(o)return o;const a=new Df(n,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:"))}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Cp(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(xu&&console.log("Unload",this.asset),this.asset.scene&&Ga(this.asset.scene,!0,!0),Ga(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,xu&&console.log("Preload",this._hashedUri);const e=await DQ(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(xu&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading.then(n=>this.asset);const t=Ot.Current;this._rawBinary?(this._loading=Cl().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(xu&&console.log("Load async",this.uri),this._loading=Cl().loadSync(t,this._hashedUri,this.uri,null,n=>{this.raiseProgressEvent(n)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[xI]=this,this._glbRoot&&(this._glbRoot[xI]=this),this.asset&&(this.asset[xI]=this),xC(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const n=Ot.Current,r=new Bl;if(e instanceof ve?r.parent=e:e&&(Object.assign(r,e),r.cloneAssign(e)),r.parent||(r.parent=n.scene),this.mustLoad&&await this.loadAssetAsync(),xu&&console.log("Instantiate",this.uri,"parent:",e),this.asset){xu&&console.log("Add to scene",this.asset);let o=Df.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,Df.currentlyInstantiating.set(this.uri,o),t){r.context=n;const a=this.asset;a.guid=this.uri;const l=WO(a,r,void 0,i);if(l)return l}else{const a=Uy(this.asset,r);if(a)return a}}finally{n.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,Df.currentlyInstantiating.set(this.uri,o)})}}else xu&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let Zt=Df;d(Zt,"currentlyInstantiating",new Map);class aue extends Xa{constructor(){super([Zt],"AssetReferenceSerializer")}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?Zt.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ve){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,n=t.context,r=i.guid??i.uuid,o=n.addressables.findAssetReference(r);if(o)return o;const a=new Zt(r,void 0,i);return n.addressables.registerAssetReference(a),a}return null}}new aue;const lue=Promise.resolve(null),u0=class{constructor(e){d(this,"url");d(this,"_bitmap");d(this,"_bitmapObject");d(this,"loader",null);this.url=e}static getOrCreate(e){let t=u0.imageReferences.get(e);return t||(t=new u0(e),u0.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new mc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):lue}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(n=>(this._bitmapObject=n,e(n),n))}),i.addEventListener("error",n=>{console.error("Failed to load image:"+this.url,n),e(null)}),i.src=this.url}),this._bitmap)}};let qg=u0;d(qg,"imageReferences",new Map);class LQ extends Xa{constructor(){super([qg],"ImageReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=wd(t.gltfId,e);return qg.getOrCreate(i)}}}new LQ;const d0=class{constructor(e){d(this,"url");d(this,"res");this.url=e}static getOrCreate(e){let t=d0.cache.get(e);return t||(t=new d0(e),d0.cache.set(e,t)),t}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.text())}};let Xg=d0;d(Xg,"cache",new Map);class kQ extends Xa{constructor(){super([Xg],"FileReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=wd(t.gltfId,e);return Xg.getOrCreate(i)}}}new kQ;class cue{constructor(e){d(this,"context");d(this,"mixers",[]);this.context=e}onDestroy(){this.mixers.forEach(e=>e.stopAllAction()),this.mixers.length=0}registerAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(e)||this.mixers.push(e)}unregisterAnimationMixer(e){if(!e)return;const t=this.mixers.indexOf(e);t!==-1&&this.mixers.splice(t,1)}}class my{static tryGetActionsFromMixer(e){const t=e._actions;return t||null}static tryGetAnimationClipsFromObjectHierarchy(e,t){if(t||(t=new Array),e)e.animations&&t.push(...e.animations);else return t;if(e.children)for(const i of e.children)this.tryGetAnimationClipsFromObjectHierarchy(i,t);return t}static assignAnimationsFromFile(e,t){if(!e||!e.animations)return;for(let n=0;n<e.animations.length;n++){const r=e.animations[n];if(!(!r.tracks||r.tracks.length<=0))for(const o in r.tracks){const a=r.tracks[o],l=Kt.parseTrackName(a.name);let c=Kt.findNode(e.scene,l.nodeName);if(!c){const u=a.__objectName??a.name.substring(0,a.name.indexOf("."));if(c=e.scene.getObjectByProperty("uuid",u),!c)continue}let h=i(c);if(!h){if(!(t!=null&&t.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}h=t.createAnimationComponent(e.scene,r)}h.addClip&&h.addClip(r)}}function i(n){var o;if(!n)return null;const r=(o=n.userData)==null?void 0:o.components;if(r&&r.length>0){for(let a=0;a<r.length;a++)if(r[a].isAnimationComponent===!0)return n}return i(n.parent)}}}const gy=[];function hE(s){gy.indexOf(s)===-1&&gy.push(s)}function hue(s){const e=gy.indexOf(s);e!==-1&&gy.splice(e,1)}const yy=[];function PO(s){yy.indexOf(s)===-1&&yy.push(s)}function uue(s){const e=yy.indexOf(s);e!==-1&&yy.splice(e,1)}function FQ(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let e=0;e<gy.length;e++)gy[e](s)}function UQ(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let e=0;e<yy.length;e++)yy[e](s)}const Ps={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function NQ(s){const e=await fetch(s);if(e.ok)return e.json();throw new Error(e.statusText)}async function due(s){if(!s)throw new Error("No basePath supplied");return await NQ(`${s}/profilesList.json`)}async function fue(s,e,t=null,i=!0){if(!s)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const n=await due(e);let r;if(s.profiles.some(l=>{const c=n[l];return c&&(r={profileId:l,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}),!!r}),!r){if(!t)throw new Error("No matching profile name found");const l=n[t];if(!l)throw new Error(`No matching profile name found and default profile "${t}" missing.`);r={profileId:t,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}}const o=await NQ(r.profilePath);let a;if(i){let l;if(s.handedness==="any"?l=o.layouts[Object.keys(o.layouts)[0]]:l=o.layouts[s.handedness],!l)throw new Error(`No matching handedness, ${s.handedness}, in profile ${r.profileId}`);l.assetPath&&(a=r.profilePath.replace("profile.json",l.assetPath))}return{profile:o,assetPath:a}}const pue={xAxis:0,yAxis:0,button:0,state:Ps.ComponentState.DEFAULT};function mue(s=0,e=0){let t=s,i=e;if(Math.sqrt(s*s+e*e)>1){const o=Math.atan2(e,s);t=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:i*.5+.5}}let gue=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ps.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(pue)}updateFromComponent({xAxis:e,yAxis:t,button:i,state:n}){const{normalizedXAxis:r,normalizedYAxis:o}=mue(e,t);switch(this.componentProperty){case Ps.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?r:.5;break;case Ps.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?o:.5;break;case Ps.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case Ps.ComponentProperty.STATE:this.valueNodeProperty===Ps.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(n):this.value=this.states.includes(n)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},yue=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(i=>{const n=new gue(t.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ps.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=Ps.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Ps.ComponentState.PRESSED:(t.touched||this.values.button>Ps.ButtonTouchThreshold)&&(this.values.state=Ps.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Ps.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ps.AxisTouchThreshold&&(this.values.state=Ps.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Ps.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ps.AxisTouchThreshold&&(this.values.state=Ps.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}},vue=class{constructor(e,t,i){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=i,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(n=>{const r=this.layoutDescription.components[n];this.components[n]=new yue(n,r)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}};const qr=new w,B3=new w,D3=new Ce,Aue=ie("debuggizmos"),Ul=8947848,pl=class{constructor(){}static isGizmo(e){return e[pB]!==void 0}static DrawLabel(e,t,i=.05,n=0,r,o,a){var h;if(!pl.enabled)return null;r||(r=Ul);const l=((h=xt.active)==null?void 0:h.rigScale)??1,c=Pn.getTextLabel(n,t,i*l,r,o);return a instanceof ve&&a.add(c),c.position.x=e.x,c.position.y=e.y,c.position.z=e.z,c}static DrawRay(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getLine(n),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),qr.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+qr.x,e.y+qr.y,e.z+qr.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(e,t,i=Ul,n=0,r=!0,o=1){if(!pl.enabled)return;const a=Pn.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(qr.set(0,0,-o),D3.set(t.x,t.y,t.z,t.w),qr.applyQuaternion(D3)):(qr.set(t.x,t.y,t.z),qr.multiplyScalar(o)),l.setXYZ(1,e.x+qr.x,e.y+qr.y,e.z+qr.z),l.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getLine(n),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireSphere(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getSphere(t,n,!0);wp(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getSphere(t,n,!1);wp(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getBox(n);o.position.set(e.x,e.y,e.z),o.scale.set(t.x,t.y,t.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(e,t=Ul,i=0,n=!0){if(!pl.enabled)return;const r=Pn.getBox(i);r.position.copy(e.getCenter(qr)),r.scale.copy(e.getSize(qr)),r.material.color.set(t),r.material.depthTest=n,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawArrow(e,t,i=Ul,n=0,r=!0,o=!1){if(!pl.enabled)return;const a=Pn.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),qr.set(t.x,t.y,t.z).sub(B3.set(e.x,e.y,e.z)).normalize());const c=qr.set(t.x,t.y,t.z).sub(B3.set(e.x,e.y,e.z)).length()*.1;a.scale.set(c,c,c),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(e,t,i,n,r)}static DrawWireMesh(e){const t=Pn.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrix.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrix.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.color.set(e.color??Ul),t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0}};let _t=pl;d(_t,"enabled",!0),d(_t,"_up",new w(0,1,0));const _ue=new Xi(1,1,1);function BO(s=null){const e=new Ae(s??14540253),t=new X2(_ue);return new Dr(t,new Zi({color:e}))}const pB=Symbol("GizmoCache");class Pn{static ensureFont(){let e=Qi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Qi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");t==null||t.addEventListener("ready",()=>{Qi.update()})}}static getTextLabel(e,t,i,n,r){this.ensureFont();let o=this.textLabelCache.pop(),a=1;r&&typeof r=="string"&&(r==null?void 0:r.length)>=8&&r.startsWith("#")?(a=parseInt(r.substring(7),16)/255,r=r.substring(0,7),Aue&&console.log(r,a)):typeof r=="object"&&r.a!==void 0&&(a=r.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre"};if(o)o.set(l);else{o=new kD(l);const c=this,h=o;h.setText=function(u){this.set({textContent:u}),c.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ot.Current,o,e,this.textLabelCache),o}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new Xi(1,1,1);t=new fe(i)}return this.registerTimedObject(Ot.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new Dn;let i=t.geometry.getAttribute("position");i||(i=new ot(new Float32Array(2*3),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(Ot.Current,t,e,this.linesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new fe(new Wa(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(Ot.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new fe(new Hn(0,.5,1,8))),this.registerTimedObject(Ot.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new fe,t.material=new ni),this.registerTimedObject(Ot.Current,t,e,this.mesh),t}static registerTimedObject(e,t,i,n){const r=this.contextBeforeRenderCallbacks.get(e),o=this.contextPostRenderCallbacks.get(e);if(r){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==r){const a=e.pre_render_callbacks.indexOf(r);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(r)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(o){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==o){const a=e.post_render_callbacks.indexOf(o);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(o)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[pB]=n,t.isGizmo=!0,this.timedObjectsBuffer.push(t),i<=0&&e.currentFrameEvent>=$i.OnBeforeRender?this.timesBuffer.push(0):this.timesBuffer.push(Ot.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static onBeforeRender(e,t){this.tmuiNeedsUpdate&&Qi.update();for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof Qi.MeshUIBaseElement){if(Cp(n))continue;const r=e.isInVR,o=!1,a=!r;I_(n,e.mainCamera,o,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let r=t.length-1;r>=0;r--){const o=t[r];n>i[r]&&(t.splice(r,1),i.splice(r,1),o.removeFromParent(),Cp(o)!=!0&&o[pB].push(o))}}}d(Pn,"familyName","needle-gizmos"),d(Pn,"linesCache",[]),d(Pn,"spheresCache",[]),d(Pn,"boxesCache",[]),d(Pn,"arrowHeadsCache",[]),d(Pn,"mesh",[]),d(Pn,"textLabelCache",[]),d(Pn,"timedObjectsBuffer",new Array),d(Pn,"timesBuffer",new Array),d(Pn,"contextPostRenderCallbacks",new Map),d(Pn,"contextBeforeRenderCallbacks",new Map),d(Pn,"tmuiNeedsUpdate",!1);const hs=ie("debuginput");var uE=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(uE||{}),fn=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(fn||{});class hh extends PointerEvent{constructor(t,i,n){super(t,n);d(this,"deviceIndex");d(this,"origin");d(this,"source");d(this,"mode");d(this,"_ray");d(this,"space");d(this,"isClick",!1);d(this,"isDoubleClick",!1);d(this,"_used",!1);d(this,"_pointerid");d(this,"_pointerType");d(this,"_type");d(this,"metadata",{});d(this,"intersections",new Array);d(this,"_immediatePropagationStopped",!1);d(this,"_propagationStopped",!1);this._pointerid=n.pointerId,this._pointerType=n.pointerType,this._type=t,this.deviceIndex=n.deviceIndex,this.origin=n.origin,this.source=i,this.mode=n.mode,this._ray=n.ray,this.space=n.device}get ray(){return this._ray||(this._ray=new Mo(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(t){this._ray=t}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation(),hs&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class xA extends KeyboardEvent{constructor(t,i,n){super(t,n);d(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class bue{constructor(e){d(this,"key");d(this,"keyType");d(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var $l=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))($l||{});class zQ{constructor(e){d(this,"_eventListeners",{});d(this,"_doubleClickTimeThreshold",.2);d(this,"_longPressTimeThreshold",1);d(this,"_specialCursorTrigger",0);d(this,"context");d(this,"_pointerDown",[!1]);d(this,"_pointerUp",[!1]);d(this,"_pointerClick",[!1]);d(this,"_pointerDoubleClick",[!1]);d(this,"_pointerPressed",[!1]);d(this,"_pointerPositions",[new ee]);d(this,"_pointerPositionsLastFrame",[new ee]);d(this,"_pointerPositionsDelta",[new ee]);d(this,"_pointerPositionsRC",[new ee]);d(this,"_pointerPositionDown",[new ee]);d(this,"_pointerDownTime",[]);d(this,"_pointerUpTime",[]);d(this,"_pointerUpTimestamp",[]);d(this,"_pointerIds",[]);d(this,"_pointerTypes",[""]);d(this,"_mouseWheelChanged",[!1]);d(this,"_mouseWheelDeltaY",[0]);d(this,"_pointerEvent",[]);d(this,"_pointerUsed",[]);d(this,"_pointerSpace",[]);d(this,"_pressedStack",new Map);d(this,"_htmlEventSource");d(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1});d(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0});d(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType});d(this,"keysPressed",{});d(this,"onKeyDown",e=>{if(hs&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new xA("keydown",e,e);this.onDispatchEvent(i)});d(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new xA("keypress",e,e);this.onDispatchEvent(i)});d(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new xA("keyup",e,e);this.onDispatchEvent(i)});d(this,"onWheelWindow",e=>{document.pointerLockElement&&this.onMouseWheel(e)});d(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY});d(this,"onPointerDown",e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const t=this.getPointerId(e);hs&&pn(`pointer down #${t}, identifier:${e.pointerId}`);const i=this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),n=new hh("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:i,pressure:e.pressure});this.onDown(n)});d(this,"onPointerMove",e=>{if(this.context.isInAR)return;let t=e.button;e.pointerType==="mouse"&&(t=this.getFirstPressedButtonForPointer(0)??0);const i=this.getPointerId(e,t);t===-1&&(t=i);const n=this.getAndUpdateSpatialObjectForScreenPosition(i,e.clientX,e.clientY),r=new hh("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:i,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:n,pressure:e.pressure});this.onMove(r)});d(this,"onPointerCancel",e=>{this.context.isInAR||(hs&&console.log("Pointer cancel",e),this.onPointerUp(e))});d(this,"onPointerUp",e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const t=this.getPointerId(e),i=new hh("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),pressure:e.pressure});this.onUp(i),this._pointerIds[t]=-1,hs&&console.log("ID="+t,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])});d(this,"onTouchStart",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),o=new hh("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onDown(o)}});d(this,"onTouchMove",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),o=new hh("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onMove(o)}});d(this,"onTouchEnd",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=new hh("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.force});this.onUp(r),this._pointerIds[n]=-1}});d(this,"tempNearPlaneVector",new w);d(this,"tempFarPlaneVector",new w);d(this,"tempLookMatrix",new ye);this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(e,t,i){if(this._eventListeners[e]||(this._eventListeners[e]=[]),!t||typeof t!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}i?i={...i}:i={};let n=0;(i==null?void 0:i.queue)!=null&&(n=i.queue);const r=this._eventListeners[e],o=r.find(a=>a.priority===n);o?o.listeners.push({callback:t,options:i}):(r.push({priority:n,listeners:[{callback:t,options:i}]}),r.sort((a,l)=>a.priority-l.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e]||!t)return;const n=this._eventListeners[e];if((i==null?void 0:i.queue)!=null){const r=n.find(a=>a.priority===i.queue);if(!r)return;const o=r.listeners.findIndex(a=>a.callback===t);o>=0&&r.listeners.splice(o,1)}else for(const r of n){const o=r.listeners.findIndex(a=>a.callback===t);o>=0&&r.listeners.splice(o,1)}}dispatchEvent(e){var i,n,r,o;let t=!1;if(e instanceof xA){const a=this._eventListeners[e.type];if(a)for(const l of a)for(let c=0;c<l.listeners.length;c++){const h=l.listeners[c];if((n=(i=h.options)==null?void 0:i.signal)!=null&&n.aborted){l.listeners.splice(c,1),c--;continue}h.options.once&&(l.listeners.splice(c,1),c--),h.callback(e)}}if(e instanceof hh){const a=this._eventListeners[e.type];if(a)for(const l of a){if(t)break;for(let c=0;c<l.listeners.length;c++){const h=l.listeners[c];if((o=(r=h.options)==null?void 0:r.signal)!=null&&o.aborted){l.listeners.splice(c,1),c--;continue}if(e.immediatePropagationStopped){t=!0,hs&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,hs&&console.log("propagationStopped",e.type));h.options.once&&(l.listeners.splice(c,1),c--),h.callback(e)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(e,t=!0){if(e>=this._pointerUsed.length){if(e>=this._pointerIds.length)return;for(;this._pointerUsed.length<=e;)this._pointerUsed.push(!1)}this._pointerUsed[e]=t}getPointerUsed(e){return e>=this._pointerUsed.length?!1:this._pointerUsed[e]}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let n=!1;for(const r of e)if(i===r){n=!0;break}if(!n)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.startFrame===this.context.time.frameCount)return t.key}return null}getKeyPressed(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.pressed)return t.key}return null}isKeyDown(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyDown(n))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[e].pressed}isKeyUp(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyUp(n))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[e].pressed}isKeyPressed(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyPressed(n))return!0;return!1}return(i=this.keysPressed[e])==null?void 0:i.pressed}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":hs&&pn("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":hs&&pn("Create Pointer move"),this.onMove(e);break;case"pointerup":hs&&pn("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){return e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1,e}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var e,t;window.removeEventListener("contextmenu",this.onContextMenu),(e=this._htmlEventSource)==null||e.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(t=this._htmlEventSource)==null||t.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}canReceiveInput(e){var t;return e.target===((t=this.context.renderer)==null?void 0:t.domElement)||e.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&e.target===document.body&&Kf()?!0:(hs&&console.warn("CanReceiveInput:False for",e.target),!1)}getPointerId(e,t){return e.pointerType==="mouse"?0+(t??e.button):this.getPointerIndex(e.pointerId)}getButtonName(e){const t=e.button;if(e.pointerType==="mouse")switch(t){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(e,t,i){let n=this._pointerSpace[e];n||(n=new ve,this._pointerSpace[e]=n),this._pointerSpace[e]=n;const r=this.context.mainCamera;if(r){const o=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(o);const a=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(r),a.unproject(r);const l=r.worldUp||pi(0,1,0).applyQuaternion(Ri(r));this.tempLookMatrix.lookAt(a,o,l),n.position.set(o.x,o.y,o.z),n.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return n}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,n=e.clientY,r=i>=t.x&&i<=t.right&&n>=t.y&&n<=t.bottom;return hs&&!r&&console.log("Not in rect",t,i,n),r}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)&&console.warn(`pointerId is already pressed: ${t}`,hs?e:""),hs&&console.log(e.pointerType,"DOWN",t),!!this.isInRect(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new ee);for(this._pointerPositionDown[t].set(e.clientX,e.clientY);t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.time,this.updatePointerPosition(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||(this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){hs&&console.log(e.pointerType,"UP",t,"was not down");return}for(hs&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0);t>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t,this._pointerUsed,!1),this.updatePointerPosition(e),!this._pointerPositionDown[t]){hs&&Ni("Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const n=e.clientX-this._pointerPositionDown[t].x,r=e.clientY-this._pointerPositionDown[t].y;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(n)<5&&Math.abs(r)<5){hs&&console.log("CLICK",t),this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const o=this._pointerUpTime[t],a=this.context.time.time-o;a<this._doubleClickTimeThreshold&&a>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}this._pointerUpTime[t]=this.context.time.time,this.onDispatchEvent(e)}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new ee);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new ee);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const n=this._pointerPositionsDelta[t];let r=e.clientX-i.x,o=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const h=e.source;r===0&&h.movementX!==0&&(r=h.movementX||0),o===0&&h.movementY!==0&&(o=h.movementY||0)}n.x+=r,n.y+=o,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,l=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new ee);const c=this._pointerPositionsRC[t];c.set(a,l),this.convertScreenspaceToRaycastSpace(c)}getPointerIndex(e){let t=-1;for(let i=0;i<this._pointerIds.length;i++){if(this._pointerIds[i]===e)return i;t===-1&&this._pointerIds[i]===-1&&(t=i)}return t!==-1?(this._pointerIds[t]=e,t):(hs&&console.log("PUSH pointerId:",e),this._pointerIds.push(e),this._pointerIds.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=Ot.Current;try{Ot.Current=this.context,this.dispatchEvent(e)}finally{Ot.Current=t}}}const EC=new ye().makeRotationY(Math.PI),Ca=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI),xue=ie("debugwebxr");class wue{constructor(){d(this,"priority",-1e5);d(this,"gameObject");if(this.gameObject=new ve,this.gameObject.name="Implicit XR Rig",xue){const e=BO(16733661);e.position.y+=.5,this.gameObject.add(e)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const wu=ie("debugwebxr"),mw=ie("debugcustomgesture"),Sue="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",Cue="generic-trigger";class DO{constructor(e,t,i){d(this,"xr");d(this,"inputSource");d(this,"index",0);d(this,"emitEvents",!0);d(this,"_connected",!0);d(this,"_isTracking",!1);d(this,"_hitTestSource");d(this,"_hasSelectEvent",!1);d(this,"_handJointPoses",new Map);d(this,"_gripPosition",new w);d(this,"_gripQuaternion",new Ce);d(this,"_linearVelocity",new w);d(this,"_rayPosition",new w);d(this,"_rayQuaternion",new Ce);d(this,"_gripWorldPosition",new w);d(this,"_gripWorldQuaternion",new Ce);d(this,"_rayWorldPosition",new w);d(this,"_rayWorldQuaternion",new Ce);d(this,"_ray");d(this,"_object");d(this,"model",null);d(this,"_debugAxesHelper",new na(.2));d(this,"onPointerHits",e=>{});d(this,"_needleGamepadButtons",{});d(this,"_buttonMap",new Map);d(this,"_motioncontroller");d(this,"_layout");d(this,"getMotionController");d(this,"_selectButtonIndex");d(this,"_squeezeButtonIndex");d(this,"onSelectStart",e=>{var n,r,o,a;if(this.inputSource!==e.inputSource)return;this.onUpdateFrame(e.frame),this._hasSelectEvent=!0;const t=(n=this._layout)==null?void 0:n.selectComponentId,i=(a=(o=(r=this._layout)==null?void 0:r.components[t])==null?void 0:o.gamepadIndices)==null?void 0:a.button;i!==void 0&&(this._selectButtonIndex=i),!mw&&(wu&&_t.DrawDirection(this.rayWorldPosition,pi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(fn.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,e))});d(this,"onSelectEnd",e=>{mw||this.inputSource===e.inputSource&&this.emitPointerEvent(fn.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)});d(this,"onSequeezeStart",e=>{var t,i,n;this.inputSource===e.inputSource&&(this._squeezeButtonIndex=(n=(i=(t=this._layout)==null?void 0:t.components["xr-standard-squeeze"])==null?void 0:i.gamepadIndices)==null?void 0:n.button,this._squeezeButtonIndex!==void 0&&(wu&&_t.DrawDirection(this.rayWorldPosition,pi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(fn.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)))});d(this,"onSequeezeEnd",e=>{this.inputSource===e.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(fn.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)});d(this,"states",{});d(this,"_didMoveLastFrame",!1);d(this,"_lastPointerMovePosition",new w);d(this,"_lastPointerMoveQuaternion",new Ce);d(this,"pointerInit");var n,r,o;this.xr=e,this.inputSource=t,this.index=i,this._object=new ve,wu&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new Mo,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((o=(r=(n=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:r.call(n,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(a=>this._hitTestSource=a))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(e){var i,n;if(!this.hand||!((i=this.xr.frame)!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let t=(n=this._handJointPoses)==null?void 0:n.get(e);return t||(t=this.xr.frame.getJointPose(e,this.xr.referenceSpace),t&&this._handJointPoses.set(e,t),t)}get gripPosition(){return pi(this._gripPosition).applyMatrix4(EC)}get gripQuaternion(){return Nf(this._gripQuaternion).premultiply(Ca)}get gripLinearVelocity(){return pi(this._linearVelocity).applyQuaternion(Ca)}get rayPosition(){return pi(this._rayPosition).applyMatrix4(EC)}get rayQuaternion(){return Nf(this._rayQuaternion).premultiply(Ca)}get gripWorldPosition(){return pi(this._gripWorldPosition)}get gripWorldQuaternion(){return Nf(this._gripWorldQuaternion)}get rayWorldPosition(){return pi(this._rayWorldPosition)}updateRayWorldPosition(){var t;const e=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return Nf(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var i;const e=(i=this.xr.context.mainCamera)==null?void 0:i.parent,t=e?Ri(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(Ca),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(pi(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var e;return(e=this.getMotionController)==null?void 0:e.then(t=>(t==null?void 0:t.assetUrl)||null)}onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var n;_t.DrawWireSphere(this.rayWorldPosition,.02),_t.DrawDirection(this.rayWorldPosition,pi(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),t=this.inputSource.profiles.join(`
5151
+ */var nue=function(s){return s!=null&&(PQ(s)||sue(s)||!!s._isBuffer)};function PQ(s){return!!s.constructor&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function sue(s){return typeof s.readFloatLE=="function"&&typeof s.slice=="function"&&PQ(s.slice(0,0))}(function(){var s=iue,e=P3.utf8,t=nue,i=P3.bin,n=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=s.bytesToWords(r),l=r.length*8,c=1732584193,h=-271733879,u=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[l>>>5]|=128<<l%32,a[(l+64>>>9<<4)+14]=l;for(var m=n._ff,y=n._gg,g=n._hh,v=n._ii,p=0;p<a.length;p+=16){var _=c,A=h,b=u,S=f;c=m(c,h,u,f,a[p+0],7,-680876936),f=m(f,c,h,u,a[p+1],12,-389564586),u=m(u,f,c,h,a[p+2],17,606105819),h=m(h,u,f,c,a[p+3],22,-1044525330),c=m(c,h,u,f,a[p+4],7,-176418897),f=m(f,c,h,u,a[p+5],12,1200080426),u=m(u,f,c,h,a[p+6],17,-1473231341),h=m(h,u,f,c,a[p+7],22,-45705983),c=m(c,h,u,f,a[p+8],7,1770035416),f=m(f,c,h,u,a[p+9],12,-1958414417),u=m(u,f,c,h,a[p+10],17,-42063),h=m(h,u,f,c,a[p+11],22,-1990404162),c=m(c,h,u,f,a[p+12],7,1804603682),f=m(f,c,h,u,a[p+13],12,-40341101),u=m(u,f,c,h,a[p+14],17,-1502002290),h=m(h,u,f,c,a[p+15],22,1236535329),c=y(c,h,u,f,a[p+1],5,-165796510),f=y(f,c,h,u,a[p+6],9,-1069501632),u=y(u,f,c,h,a[p+11],14,643717713),h=y(h,u,f,c,a[p+0],20,-373897302),c=y(c,h,u,f,a[p+5],5,-701558691),f=y(f,c,h,u,a[p+10],9,38016083),u=y(u,f,c,h,a[p+15],14,-660478335),h=y(h,u,f,c,a[p+4],20,-405537848),c=y(c,h,u,f,a[p+9],5,568446438),f=y(f,c,h,u,a[p+14],9,-1019803690),u=y(u,f,c,h,a[p+3],14,-187363961),h=y(h,u,f,c,a[p+8],20,1163531501),c=y(c,h,u,f,a[p+13],5,-1444681467),f=y(f,c,h,u,a[p+2],9,-51403784),u=y(u,f,c,h,a[p+7],14,1735328473),h=y(h,u,f,c,a[p+12],20,-1926607734),c=g(c,h,u,f,a[p+5],4,-378558),f=g(f,c,h,u,a[p+8],11,-2022574463),u=g(u,f,c,h,a[p+11],16,1839030562),h=g(h,u,f,c,a[p+14],23,-35309556),c=g(c,h,u,f,a[p+1],4,-1530992060),f=g(f,c,h,u,a[p+4],11,1272893353),u=g(u,f,c,h,a[p+7],16,-155497632),h=g(h,u,f,c,a[p+10],23,-1094730640),c=g(c,h,u,f,a[p+13],4,681279174),f=g(f,c,h,u,a[p+0],11,-358537222),u=g(u,f,c,h,a[p+3],16,-722521979),h=g(h,u,f,c,a[p+6],23,76029189),c=g(c,h,u,f,a[p+9],4,-640364487),f=g(f,c,h,u,a[p+12],11,-421815835),u=g(u,f,c,h,a[p+15],16,530742520),h=g(h,u,f,c,a[p+2],23,-995338651),c=v(c,h,u,f,a[p+0],6,-198630844),f=v(f,c,h,u,a[p+7],10,1126891415),u=v(u,f,c,h,a[p+14],15,-1416354905),h=v(h,u,f,c,a[p+5],21,-57434055),c=v(c,h,u,f,a[p+12],6,1700485571),f=v(f,c,h,u,a[p+3],10,-1894986606),u=v(u,f,c,h,a[p+10],15,-1051523),h=v(h,u,f,c,a[p+1],21,-2054922799),c=v(c,h,u,f,a[p+8],6,1873313359),f=v(f,c,h,u,a[p+15],10,-30611744),u=v(u,f,c,h,a[p+6],15,-1560198380),h=v(h,u,f,c,a[p+13],21,1309151649),c=v(c,h,u,f,a[p+4],6,-145523070),f=v(f,c,h,u,a[p+11],10,-1120210379),u=v(u,f,c,h,a[p+2],15,718787259),h=v(h,u,f,c,a[p+9],21,-343485551),c=c+_>>>0,h=h+A>>>0,u=u+b>>>0,f=f+S>>>0}return s.endian([c,h,u,f])};n._ff=function(r,o,a,l,c,h,u){var f=r+(o&a|~o&l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._gg=function(r,o,a,l,c,h,u){var f=r+(o&l|a&~l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._hh=function(r,o,a,l,c,h,u){var f=r+(o^a^l)+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._ii=function(r,o,a,l,c,h,u){var f=r+(a^(o|~l))+(c>>>0)+u;return(f<<h|f>>>32-h)+o},n._blocksize=16,n._digestsize=16,IQ.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=s.wordsToBytes(n(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):s.bytesToHex(a)}})();var rue=IQ.exports;const oue=cE(rue);class fB{constructor(e,t,i,n){d(this,"success");d(this,"filename");d(this,"hash");d(this,"size");d(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=n}}async function BQ(s,e){const t=await s.arrayBuffer(),i=IO(t),n=s.name.split(".").pop(),r=i+"."+n,o=s.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},c=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(c.success||console.warn("exists check did fail"),c.exists)return console.log("file already exists",i),new fB(!0,r,i,s.size);console.log("begin uploading file",o,s.size);const h=new FormData;h.append("file",s);const u={};u.filesize=s.size,o&&(u.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:h,headers:u})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new fB(p.success,r,i,s.size);return m.url=e,m}function IO(s){return oue(new Uint8Array(s))}async function RO(s,e,t,i,n=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:s});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();n||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const l=IO(a);return n||console.assert(l===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function DQ(s,e){var h;const t=await fetch(s),i=(h=t.body)==null?void 0:h.getReader(),n=t.headers.get("Content-Length"),r=n?parseInt(n):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:u,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),u)break}const l=new Uint8Array(o);let c=0;for(const u of a)l.set(u,c),c+=u.length;return l}const xu=ie("debugaddressables");class OQ{constructor(e){d(this,"_context");d(this,"_assetReferences",{});d(this,"preUpdate",()=>{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const e=this._context.pre_update_callbacks.indexOf(this.preUpdate);e>=0&&this._context.pre_update_callbacks.splice(e,1);for(const t in this._assetReferences){const i=this._assetReferences[t];i==null||i.unload()}this._assetReferences={}}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const xI=Symbol("assetReference"),Df=class{constructor(e,t,i=null){d(this,"_loading");d(this,"_asset");d(this,"_glbRoot");d(this,"_url");d(this,"_progressListeners",[]);d(this,"_hash");d(this,"_hashedUri");d(this,"_isLoadingRawBinary",!1);d(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),sj(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(e,t){if(!t&&(t=Ot.Current,!t))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const i=t.addressables,n=i.findAssetReference(e);if(n)return n;const r=new Df(e,t.hash);return i.registerAssetReference(r),r}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Ot.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const n=wd(e,t);xu&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",n);const r=i.addressables,o=r.findAssetReference(n);if(o)return o;const a=new Df(n,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:")||this._url.startsWith("www.")||this._url.includes("/"))}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Cp(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(xu&&console.log("Unload",this.asset),this.asset.scene&&Ga(this.asset.scene,!0,!0),Ga(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,xu&&console.log("Preload",this._hashedUri);const e=await DQ(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(xu&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading.then(n=>this.asset);const t=Ot.Current;this._rawBinary?(this._loading=Cl().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(xu&&console.log("Load async",this.uri),this._loading=Cl().loadSync(t,this._hashedUri,this.uri,null,n=>{this.raiseProgressEvent(n)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[xI]=this,this._glbRoot&&(this._glbRoot[xI]=this),this.asset&&(this.asset[xI]=this),xC(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const n=Ot.Current,r=new Bl;if(e instanceof ve?r.parent=e:e&&(Object.assign(r,e),r.cloneAssign(e)),r.parent||(r.parent=n.scene),this.mustLoad&&await this.loadAssetAsync(),xu&&console.log("Instantiate",this.uri,"parent:",e),this.asset){xu&&console.log("Add to scene",this.asset);let o=Df.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,Df.currentlyInstantiating.set(this.uri,o),t){r.context=n;const a=this.asset;a.guid=this.uri;const l=WO(a,r,void 0,i);if(l)return l}else{const a=Uy(this.asset,r);if(a)return a}}finally{n.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,Df.currentlyInstantiating.set(this.uri,o)})}}else xu&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let Zt=Df;d(Zt,"currentlyInstantiating",new Map);class aue extends Xa{constructor(){super([Zt],"AssetReferenceSerializer")}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?Zt.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ve){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,n=t.context,r=i.guid??i.uuid,o=n.addressables.findAssetReference(r);if(o)return o;const a=new Zt(r,void 0,i);return n.addressables.registerAssetReference(a),a}return null}}new aue;const lue=Promise.resolve(null),u0=class{constructor(e){d(this,"url");d(this,"_bitmap");d(this,"_bitmapObject");d(this,"loader",null);this.url=e}static getOrCreate(e){let t=u0.imageReferences.get(e);return t||(t=new u0(e),u0.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new mc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):lue}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(n=>(this._bitmapObject=n,e(n),n))}),i.addEventListener("error",n=>{console.error("Failed to load image:"+this.url,n),e(null)}),i.src=this.url}),this._bitmap)}};let qg=u0;d(qg,"imageReferences",new Map);class LQ extends Xa{constructor(){super([qg],"ImageReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=wd(t.gltfId,e);return qg.getOrCreate(i)}}}new LQ;const d0=class{constructor(e){d(this,"url");d(this,"res");this.url=e}static getOrCreate(e){let t=d0.cache.get(e);return t||(t=new d0(e),d0.cache.set(e,t)),t}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.text())}};let Xg=d0;d(Xg,"cache",new Map);class kQ extends Xa{constructor(){super([Xg],"FileReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=wd(t.gltfId,e);return Xg.getOrCreate(i)}}}new kQ;class cue{constructor(e){d(this,"context");d(this,"mixers",[]);this.context=e}onDestroy(){this.mixers.forEach(e=>e.stopAllAction()),this.mixers.length=0}registerAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(e)||this.mixers.push(e)}unregisterAnimationMixer(e){if(!e)return;const t=this.mixers.indexOf(e);t!==-1&&this.mixers.splice(t,1)}}class my{static tryGetActionsFromMixer(e){const t=e._actions;return t||null}static tryGetAnimationClipsFromObjectHierarchy(e,t){if(t||(t=new Array),e)e.animations&&t.push(...e.animations);else return t;if(e.children)for(const i of e.children)this.tryGetAnimationClipsFromObjectHierarchy(i,t);return t}static assignAnimationsFromFile(e,t){if(!e||!e.animations)return;for(let n=0;n<e.animations.length;n++){const r=e.animations[n];if(!(!r.tracks||r.tracks.length<=0))for(const o in r.tracks){const a=r.tracks[o],l=Kt.parseTrackName(a.name);let c=Kt.findNode(e.scene,l.nodeName);if(!c){const u=a.__objectName??a.name.substring(0,a.name.indexOf("."));if(c=e.scene.getObjectByProperty("uuid",u),!c)continue}let h=i(c);if(!h){if(!(t!=null&&t.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}h=t.createAnimationComponent(e.scene,r)}h.addClip&&h.addClip(r)}}function i(n){var o;if(!n)return null;const r=(o=n.userData)==null?void 0:o.components;if(r&&r.length>0){for(let a=0;a<r.length;a++)if(r[a].isAnimationComponent===!0)return n}return i(n.parent)}}}const gy=[];function hE(s){gy.indexOf(s)===-1&&gy.push(s)}function hue(s){const e=gy.indexOf(s);e!==-1&&gy.splice(e,1)}const yy=[];function PO(s){yy.indexOf(s)===-1&&yy.push(s)}function uue(s){const e=yy.indexOf(s);e!==-1&&yy.splice(e,1)}function FQ(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let e=0;e<gy.length;e++)gy[e](s)}function UQ(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let e=0;e<yy.length;e++)yy[e](s)}const Ps={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function NQ(s){const e=await fetch(s);if(e.ok)return e.json();throw new Error(e.statusText)}async function due(s){if(!s)throw new Error("No basePath supplied");return await NQ(`${s}/profilesList.json`)}async function fue(s,e,t=null,i=!0){if(!s)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const n=await due(e);let r;if(s.profiles.some(l=>{const c=n[l];return c&&(r={profileId:l,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}),!!r}),!r){if(!t)throw new Error("No matching profile name found");const l=n[t];if(!l)throw new Error(`No matching profile name found and default profile "${t}" missing.`);r={profileId:t,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}}const o=await NQ(r.profilePath);let a;if(i){let l;if(s.handedness==="any"?l=o.layouts[Object.keys(o.layouts)[0]]:l=o.layouts[s.handedness],!l)throw new Error(`No matching handedness, ${s.handedness}, in profile ${r.profileId}`);l.assetPath&&(a=r.profilePath.replace("profile.json",l.assetPath))}return{profile:o,assetPath:a}}const pue={xAxis:0,yAxis:0,button:0,state:Ps.ComponentState.DEFAULT};function mue(s=0,e=0){let t=s,i=e;if(Math.sqrt(s*s+e*e)>1){const o=Math.atan2(e,s);t=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:i*.5+.5}}let gue=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ps.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(pue)}updateFromComponent({xAxis:e,yAxis:t,button:i,state:n}){const{normalizedXAxis:r,normalizedYAxis:o}=mue(e,t);switch(this.componentProperty){case Ps.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?r:.5;break;case Ps.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?o:.5;break;case Ps.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case Ps.ComponentProperty.STATE:this.valueNodeProperty===Ps.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(n):this.value=this.states.includes(n)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},yue=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(i=>{const n=new gue(t.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ps.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=Ps.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Ps.ComponentState.PRESSED:(t.touched||this.values.button>Ps.ButtonTouchThreshold)&&(this.values.state=Ps.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Ps.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ps.AxisTouchThreshold&&(this.values.state=Ps.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Ps.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ps.AxisTouchThreshold&&(this.values.state=Ps.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}},vue=class{constructor(e,t,i){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=i,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(n=>{const r=this.layoutDescription.components[n];this.components[n]=new yue(n,r)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}};const qr=new w,B3=new w,D3=new Ce,Aue=ie("debuggizmos"),Ul=8947848,pl=class{constructor(){}static isGizmo(e){return e[pB]!==void 0}static DrawLabel(e,t,i=.05,n=0,r,o,a){var h;if(!pl.enabled)return null;r||(r=Ul);const l=((h=xt.active)==null?void 0:h.rigScale)??1,c=Pn.getTextLabel(n,t,i*l,r,o);return a instanceof ve&&a.add(c),c.position.x=e.x,c.position.y=e.y,c.position.z=e.z,c}static DrawRay(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getLine(n),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),qr.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+qr.x,e.y+qr.y,e.z+qr.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(e,t,i=Ul,n=0,r=!0,o=1){if(!pl.enabled)return;const a=Pn.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(qr.set(0,0,-o),D3.set(t.x,t.y,t.z,t.w),qr.applyQuaternion(D3)):(qr.set(t.x,t.y,t.z),qr.multiplyScalar(o)),l.setXYZ(1,e.x+qr.x,e.y+qr.y,e.z+qr.z),l.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getLine(n),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireSphere(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getSphere(t,n,!0);wp(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getSphere(t,n,!1);wp(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(e,t,i=Ul,n=0,r=!0){if(!pl.enabled)return;const o=Pn.getBox(n);o.position.set(e.x,e.y,e.z),o.scale.set(t.x,t.y,t.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(e,t=Ul,i=0,n=!0){if(!pl.enabled)return;const r=Pn.getBox(i);r.position.copy(e.getCenter(qr)),r.scale.copy(e.getSize(qr)),r.material.color.set(t),r.material.depthTest=n,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawArrow(e,t,i=Ul,n=0,r=!0,o=!1){if(!pl.enabled)return;const a=Pn.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),qr.set(t.x,t.y,t.z).sub(B3.set(e.x,e.y,e.z)).normalize());const c=qr.set(t.x,t.y,t.z).sub(B3.set(e.x,e.y,e.z)).length()*.1;a.scale.set(c,c,c),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(e,t,i,n,r)}static DrawWireMesh(e){const t=Pn.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrix.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrix.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.color.set(e.color??Ul),t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0}};let _t=pl;d(_t,"enabled",!0),d(_t,"_up",new w(0,1,0));const _ue=new Xi(1,1,1);function BO(s=null){const e=new Ae(s??14540253),t=new X2(_ue);return new Dr(t,new Zi({color:e}))}const pB=Symbol("GizmoCache");class Pn{static ensureFont(){let e=Qi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Qi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");t==null||t.addEventListener("ready",()=>{Qi.update()})}}static getTextLabel(e,t,i,n,r){this.ensureFont();let o=this.textLabelCache.pop(),a=1;r&&typeof r=="string"&&(r==null?void 0:r.length)>=8&&r.startsWith("#")?(a=parseInt(r.substring(7),16)/255,r=r.substring(0,7),Aue&&console.log(r,a)):typeof r=="object"&&r.a!==void 0&&(a=r.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre"};if(o)o.set(l);else{o=new kD(l);const c=this,h=o;h.setText=function(u){this.set({textContent:u}),c.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ot.Current,o,e,this.textLabelCache),o}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new Xi(1,1,1);t=new fe(i)}return this.registerTimedObject(Ot.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new Dn;let i=t.geometry.getAttribute("position");i||(i=new ot(new Float32Array(2*3),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(Ot.Current,t,e,this.linesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new fe(new Wa(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(Ot.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new fe(new Hn(0,.5,1,8))),this.registerTimedObject(Ot.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new fe,t.material=new ni),this.registerTimedObject(Ot.Current,t,e,this.mesh),t}static registerTimedObject(e,t,i,n){const r=this.contextBeforeRenderCallbacks.get(e),o=this.contextPostRenderCallbacks.get(e);if(r){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==r){const a=e.pre_render_callbacks.indexOf(r);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(r)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(o){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==o){const a=e.post_render_callbacks.indexOf(o);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(o)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[pB]=n,t.isGizmo=!0,this.timedObjectsBuffer.push(t),i<=0&&e.currentFrameEvent>=$i.OnBeforeRender?this.timesBuffer.push(0):this.timesBuffer.push(Ot.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static onBeforeRender(e,t){this.tmuiNeedsUpdate&&Qi.update();for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof Qi.MeshUIBaseElement){if(Cp(n))continue;const r=e.isInVR,o=!1,a=!r;I_(n,e.mainCamera,o,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let r=t.length-1;r>=0;r--){const o=t[r];n>i[r]&&(t.splice(r,1),i.splice(r,1),o.removeFromParent(),Cp(o)!=!0&&o[pB].push(o))}}}d(Pn,"familyName","needle-gizmos"),d(Pn,"linesCache",[]),d(Pn,"spheresCache",[]),d(Pn,"boxesCache",[]),d(Pn,"arrowHeadsCache",[]),d(Pn,"mesh",[]),d(Pn,"textLabelCache",[]),d(Pn,"timedObjectsBuffer",new Array),d(Pn,"timesBuffer",new Array),d(Pn,"contextPostRenderCallbacks",new Map),d(Pn,"contextBeforeRenderCallbacks",new Map),d(Pn,"tmuiNeedsUpdate",!1);const hs=ie("debuginput");var uE=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(uE||{}),fn=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(fn||{});class hh extends PointerEvent{constructor(t,i,n){super(t,n);d(this,"deviceIndex");d(this,"origin");d(this,"source");d(this,"mode");d(this,"_ray");d(this,"space");d(this,"isClick",!1);d(this,"isDoubleClick",!1);d(this,"_used",!1);d(this,"_pointerid");d(this,"_pointerType");d(this,"_type");d(this,"metadata",{});d(this,"intersections",new Array);d(this,"_immediatePropagationStopped",!1);d(this,"_propagationStopped",!1);this._pointerid=n.pointerId,this._pointerType=n.pointerType,this._type=t,this.deviceIndex=n.deviceIndex,this.origin=n.origin,this.source=i,this.mode=n.mode,this._ray=n.ray,this.space=n.device}get ray(){return this._ray||(this._ray=new Mo(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(t){this._ray=t}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation(),hs&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class xA extends KeyboardEvent{constructor(t,i,n){super(t,n);d(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class bue{constructor(e){d(this,"key");d(this,"keyType");d(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var $l=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))($l||{});class zQ{constructor(e){d(this,"_eventListeners",{});d(this,"_doubleClickTimeThreshold",.2);d(this,"_longPressTimeThreshold",1);d(this,"_specialCursorTrigger",0);d(this,"context");d(this,"_pointerDown",[!1]);d(this,"_pointerUp",[!1]);d(this,"_pointerClick",[!1]);d(this,"_pointerDoubleClick",[!1]);d(this,"_pointerPressed",[!1]);d(this,"_pointerPositions",[new ee]);d(this,"_pointerPositionsLastFrame",[new ee]);d(this,"_pointerPositionsDelta",[new ee]);d(this,"_pointerPositionsRC",[new ee]);d(this,"_pointerPositionDown",[new ee]);d(this,"_pointerDownTime",[]);d(this,"_pointerUpTime",[]);d(this,"_pointerUpTimestamp",[]);d(this,"_pointerIds",[]);d(this,"_pointerTypes",[""]);d(this,"_mouseWheelChanged",[!1]);d(this,"_mouseWheelDeltaY",[0]);d(this,"_pointerEvent",[]);d(this,"_pointerUsed",[]);d(this,"_pointerSpace",[]);d(this,"_pressedStack",new Map);d(this,"_htmlEventSource");d(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1});d(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0});d(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType});d(this,"keysPressed",{});d(this,"onKeyDown",e=>{if(hs&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new xA("keydown",e,e);this.onDispatchEvent(i)});d(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new xA("keypress",e,e);this.onDispatchEvent(i)});d(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new xA("keyup",e,e);this.onDispatchEvent(i)});d(this,"onWheelWindow",e=>{document.pointerLockElement&&this.onMouseWheel(e)});d(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY});d(this,"onPointerDown",e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const t=this.getPointerId(e);hs&&pn(`pointer down #${t}, identifier:${e.pointerId}`);const i=this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),n=new hh("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:i,pressure:e.pressure});this.onDown(n)});d(this,"onPointerMove",e=>{if(this.context.isInAR)return;let t=e.button;e.pointerType==="mouse"&&(t=this.getFirstPressedButtonForPointer(0)??0);const i=this.getPointerId(e,t);t===-1&&(t=i);const n=this.getAndUpdateSpatialObjectForScreenPosition(i,e.clientX,e.clientY),r=new hh("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:i,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:n,pressure:e.pressure});this.onMove(r)});d(this,"onPointerCancel",e=>{this.context.isInAR||(hs&&console.log("Pointer cancel",e),this.onPointerUp(e))});d(this,"onPointerUp",e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const t=this.getPointerId(e),i=new hh("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),pressure:e.pressure});this.onUp(i),this._pointerIds[t]=-1,hs&&console.log("ID="+t,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])});d(this,"onTouchStart",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),o=new hh("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onDown(o)}});d(this,"onTouchMove",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),o=new hh("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onMove(o)}});d(this,"onTouchEnd",e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),r=new hh("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.force});this.onUp(r),this._pointerIds[n]=-1}});d(this,"tempNearPlaneVector",new w);d(this,"tempFarPlaneVector",new w);d(this,"tempLookMatrix",new ye);this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(e,t,i){if(this._eventListeners[e]||(this._eventListeners[e]=[]),!t||typeof t!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}i?i={...i}:i={};let n=0;(i==null?void 0:i.queue)!=null&&(n=i.queue);const r=this._eventListeners[e],o=r.find(a=>a.priority===n);o?o.listeners.push({callback:t,options:i}):(r.push({priority:n,listeners:[{callback:t,options:i}]}),r.sort((a,l)=>a.priority-l.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e]||!t)return;const n=this._eventListeners[e];if((i==null?void 0:i.queue)!=null){const r=n.find(a=>a.priority===i.queue);if(!r)return;const o=r.listeners.findIndex(a=>a.callback===t);o>=0&&r.listeners.splice(o,1)}else for(const r of n){const o=r.listeners.findIndex(a=>a.callback===t);o>=0&&r.listeners.splice(o,1)}}dispatchEvent(e){var i,n,r,o;let t=!1;if(e instanceof xA){const a=this._eventListeners[e.type];if(a)for(const l of a)for(let c=0;c<l.listeners.length;c++){const h=l.listeners[c];if((n=(i=h.options)==null?void 0:i.signal)!=null&&n.aborted){l.listeners.splice(c,1),c--;continue}h.options.once&&(l.listeners.splice(c,1),c--),h.callback(e)}}if(e instanceof hh){const a=this._eventListeners[e.type];if(a)for(const l of a){if(t)break;for(let c=0;c<l.listeners.length;c++){const h=l.listeners[c];if((o=(r=h.options)==null?void 0:r.signal)!=null&&o.aborted){l.listeners.splice(c,1),c--;continue}if(e.immediatePropagationStopped){t=!0,hs&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,hs&&console.log("propagationStopped",e.type));h.options.once&&(l.listeners.splice(c,1),c--),h.callback(e)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(e,t=!0){if(e>=this._pointerUsed.length){if(e>=this._pointerIds.length)return;for(;this._pointerUsed.length<=e;)this._pointerUsed.push(!1)}this._pointerUsed[e]=t}getPointerUsed(e){return e>=this._pointerUsed.length?!1:this._pointerUsed[e]}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let n=!1;for(const r of e)if(i===r){n=!0;break}if(!n)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.startFrame===this.context.time.frameCount)return t.key}return null}getKeyPressed(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.pressed)return t.key}return null}isKeyDown(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyDown(n))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[e].pressed}isKeyUp(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyUp(n))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[e].pressed}isKeyPressed(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyPressed(n))return!0;return!1}return(i=this.keysPressed[e])==null?void 0:i.pressed}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":hs&&pn("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":hs&&pn("Create Pointer move"),this.onMove(e);break;case"pointerup":hs&&pn("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){return e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1,e}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var e,t;window.removeEventListener("contextmenu",this.onContextMenu),(e=this._htmlEventSource)==null||e.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(t=this._htmlEventSource)==null||t.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}canReceiveInput(e){var t;return e.target===((t=this.context.renderer)==null?void 0:t.domElement)||e.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&e.target===document.body&&Kf()?!0:(hs&&console.warn("CanReceiveInput:False for",e.target),!1)}getPointerId(e,t){return e.pointerType==="mouse"?0+(t??e.button):this.getPointerIndex(e.pointerId)}getButtonName(e){const t=e.button;if(e.pointerType==="mouse")switch(t){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(e,t,i){let n=this._pointerSpace[e];n||(n=new ve,this._pointerSpace[e]=n),this._pointerSpace[e]=n;const r=this.context.mainCamera;if(r){const o=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(o);const a=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(r),a.unproject(r);const l=r.worldUp||pi(0,1,0).applyQuaternion(Ri(r));this.tempLookMatrix.lookAt(a,o,l),n.position.set(o.x,o.y,o.z),n.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return n}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,n=e.clientY,r=i>=t.x&&i<=t.right&&n>=t.y&&n<=t.bottom;return hs&&!r&&console.log("Not in rect",t,i,n),r}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)&&console.warn(`pointerId is already pressed: ${t}`,hs?e:""),hs&&console.log(e.pointerType,"DOWN",t),!!this.isInRect(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new ee);for(this._pointerPositionDown[t].set(e.clientX,e.clientY);t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.time,this.updatePointerPosition(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||(this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){hs&&console.log(e.pointerType,"UP",t,"was not down");return}for(hs&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0);t>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t,this._pointerUsed,!1),this.updatePointerPosition(e),!this._pointerPositionDown[t]){hs&&Ni("Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const n=e.clientX-this._pointerPositionDown[t].x,r=e.clientY-this._pointerPositionDown[t].y;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(n)<5&&Math.abs(r)<5){hs&&console.log("CLICK",t),this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const o=this._pointerUpTime[t],a=this.context.time.time-o;a<this._doubleClickTimeThreshold&&a>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}this._pointerUpTime[t]=this.context.time.time,this.onDispatchEvent(e)}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new ee);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new ee);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const n=this._pointerPositionsDelta[t];let r=e.clientX-i.x,o=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const h=e.source;r===0&&h.movementX!==0&&(r=h.movementX||0),o===0&&h.movementY!==0&&(o=h.movementY||0)}n.x+=r,n.y+=o,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,l=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new ee);const c=this._pointerPositionsRC[t];c.set(a,l),this.convertScreenspaceToRaycastSpace(c)}getPointerIndex(e){let t=-1;for(let i=0;i<this._pointerIds.length;i++){if(this._pointerIds[i]===e)return i;t===-1&&this._pointerIds[i]===-1&&(t=i)}return t!==-1?(this._pointerIds[t]=e,t):(hs&&console.log("PUSH pointerId:",e),this._pointerIds.push(e),this._pointerIds.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=Ot.Current;try{Ot.Current=this.context,this.dispatchEvent(e)}finally{Ot.Current=t}}}const EC=new ye().makeRotationY(Math.PI),Ca=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI),xue=ie("debugwebxr");class wue{constructor(){d(this,"priority",-1e5);d(this,"gameObject");if(this.gameObject=new ve,this.gameObject.name="Implicit XR Rig",xue){const e=BO(16733661);e.position.y+=.5,this.gameObject.add(e)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const wu=ie("debugwebxr"),mw=ie("debugcustomgesture"),Sue="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",Cue="generic-trigger";class DO{constructor(e,t,i){d(this,"xr");d(this,"inputSource");d(this,"index",0);d(this,"emitEvents",!0);d(this,"_connected",!0);d(this,"_isTracking",!1);d(this,"_hitTestSource");d(this,"_hasSelectEvent",!1);d(this,"_handJointPoses",new Map);d(this,"_gripPosition",new w);d(this,"_gripQuaternion",new Ce);d(this,"_linearVelocity",new w);d(this,"_rayPosition",new w);d(this,"_rayQuaternion",new Ce);d(this,"_gripWorldPosition",new w);d(this,"_gripWorldQuaternion",new Ce);d(this,"_rayWorldPosition",new w);d(this,"_rayWorldQuaternion",new Ce);d(this,"_ray");d(this,"_object");d(this,"model",null);d(this,"_debugAxesHelper",new na(.2));d(this,"onPointerHits",e=>{});d(this,"_needleGamepadButtons",{});d(this,"_buttonMap",new Map);d(this,"_motioncontroller");d(this,"_layout");d(this,"getMotionController");d(this,"_selectButtonIndex");d(this,"_squeezeButtonIndex");d(this,"onSelectStart",e=>{var n,r,o,a;if(this.inputSource!==e.inputSource)return;this.onUpdateFrame(e.frame),this._hasSelectEvent=!0;const t=(n=this._layout)==null?void 0:n.selectComponentId,i=(a=(o=(r=this._layout)==null?void 0:r.components[t])==null?void 0:o.gamepadIndices)==null?void 0:a.button;i!==void 0&&(this._selectButtonIndex=i),!mw&&(wu&&_t.DrawDirection(this.rayWorldPosition,pi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(fn.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,e))});d(this,"onSelectEnd",e=>{mw||this.inputSource===e.inputSource&&this.emitPointerEvent(fn.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)});d(this,"onSequeezeStart",e=>{var t,i,n;this.inputSource===e.inputSource&&(this._squeezeButtonIndex=(n=(i=(t=this._layout)==null?void 0:t.components["xr-standard-squeeze"])==null?void 0:i.gamepadIndices)==null?void 0:n.button,this._squeezeButtonIndex!==void 0&&(wu&&_t.DrawDirection(this.rayWorldPosition,pi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(fn.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)))});d(this,"onSequeezeEnd",e=>{this.inputSource===e.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(fn.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)});d(this,"states",{});d(this,"_didMoveLastFrame",!1);d(this,"_lastPointerMovePosition",new w);d(this,"_lastPointerMoveQuaternion",new Ce);d(this,"pointerInit");var n,r,o;this.xr=e,this.inputSource=t,this.index=i,this._object=new ve,wu&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new Mo,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((o=(r=(n=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:r.call(n,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(a=>this._hitTestSource=a))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(e){var i,n;if(!this.hand||!((i=this.xr.frame)!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let t=(n=this._handJointPoses)==null?void 0:n.get(e);return t||(t=this.xr.frame.getJointPose(e,this.xr.referenceSpace),t&&this._handJointPoses.set(e,t),t)}get gripPosition(){return pi(this._gripPosition).applyMatrix4(EC)}get gripQuaternion(){return Nf(this._gripQuaternion).premultiply(Ca)}get gripLinearVelocity(){return pi(this._linearVelocity).applyQuaternion(Ca)}get rayPosition(){return pi(this._rayPosition).applyMatrix4(EC)}get rayQuaternion(){return Nf(this._rayQuaternion).premultiply(Ca)}get gripWorldPosition(){return pi(this._gripWorldPosition)}get gripWorldQuaternion(){return Nf(this._gripWorldQuaternion)}get rayWorldPosition(){return pi(this._rayWorldPosition)}updateRayWorldPosition(){var t;const e=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return Nf(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var i;const e=(i=this.xr.context.mainCamera)==null?void 0:i.parent,t=e?Ri(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(Ca),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(pi(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var e;return(e=this.getMotionController)==null?void 0:e.then(t=>(t==null?void 0:t.assetUrl)||null)}onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var n;_t.DrawWireSphere(this.rayWorldPosition,.02),_t.DrawDirection(this.rayWorldPosition,pi(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),t=this.inputSource.profiles.join(`
5152
5152
  `);let i=`Controller[${this.index}] ${this.side}
5153
5153
  C:${this.connected?"yes":"no"} T:${this.isTracking?"yes":"no"} Hand:${this.inputSource.hand?"yes":"no"}`;this.inputSource.hand&&(i+=`
5154
5154
  Pinch: ${(n=this.getGesture("pinch"))==null?void 0:n.value.toFixed(3)}`),i+=`
@@ -7586,7 +7586,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
7586
7586
  outputColor = sharp;
7587
7587
  }
7588
7588
 
7589
- `;class TW extends ro{constructor(){super("Sharpening",I0e,{vertexShader:T0e,blendFunction:jt.NORMAL,uniforms:new Map([["amount",new we(1)],["radius",new we(1)]])})}}const vf=ie("debugpost"),aR=Symbol("needle:postprocessing-handler"),lR=Symbol("needle:previous-autoclear-state");class rM{constructor(e){d(this,"_composer",null);d(this,"_lastVolumeComponents");d(this,"_effects",[]);d(this,"_isActive",!1);d(this,"context");this.context=e}get isActive(){return this._isActive}get composer(){return this._composer}apply(e){this._isActive=!0,this.onApply(this.context,e)}unapply(){var i;if(vf&&console.log("Unapplying postprocessing effects"),this._isActive=!1,this._lastVolumeComponents){for(const n of this._lastVolumeComponents)n.unapply();this._lastVolumeComponents.length=0}const e=this.context;e[aR]===this&&delete e[aR],e.composer===this._composer&&((i=e.composer)==null||i.dispose(),e.composer=null),typeof e.renderer[lR]=="boolean"&&(e.renderer.autoClear=e.renderer[lR])}dispose(){this.unapply();for(const e of this._effects)e.dispose();this._effects.length=0,this._composer=null}onApply(e,t){if(!t)return;e[aR]=this,vf&&console.log("refreshing volume profile",t),this._lastVolumeComponents=[...t],this._effects.length=0;const i={handler:this,components:this._lastVolumeComponents};for(let n=0;n<this._lastVolumeComponents.length;n++){const r=this._lastVolumeComponents[n];if(r.context=e,r.apply){if(r.active){if(!e.mainCameraComponent){console.error("No camera in scene found or available yet - can not create postprocessing effects");return}const o=r.apply(i);if(!o)continue;Array.isArray(o)?this._effects.push(...o):this._effects.push(o)}}else r.active&&Ni("Volume component is not a VolumeComponent: "+r.__type)}if(this.context.renderer.toneMapping!=io&&!this._effects.find(n=>n instanceof wC)){const n=new wC;this._effects.push(n)}this.applyEffects(e)}applyEffects(e){const t=this._effects;if(t.length<=0)return;const i=e.mainCameraComponent,n=e.renderer,r=e.scene,o=i.cam;n[lR]=n.autoClear;const a=n.capabilities.maxSamples;this._composer||(this._composer=new bO(n,{frameBufferType:ms,stencilBuffer:!0,multisampling:Math.min(qa()?4:8,a)})),e.composer&&e.composer!==this._composer&&console.warn("There's already an active EffectComposer in your scene: replacing it with a new one. This might cause unexpected behaviour. Make sure to only use one PostprocessingManager/Volume in your scene."),e.composer=this._composer;const l=e.composer;l.setMainCamera(o),l.setRenderer(n),l.setMainScene(r);for(const h of l.passes)h.dispose();l.removeAllPasses();const c=new lE(r,o);c.name="Render To Screen",c.mainScene=r,l.addPass(c);try{this.orderEffects();const h=[];for(const u of t)if(u instanceof ro)h.push(u);else if(u instanceof lr){const f=new M3(o,...h);f.mainScene=r,f.name=h.map(p=>p.constructor.name).join(", "),f.enabled=!0,h.length=0,l.addPass(u)}if(h.length>0){const u=new M3(o,...h);u.name=h.map(f=>f.name).join(" "),u.mainScene=r,u.enabled=!0,l.addPass(u)}}catch(h){console.error("Error while applying postprocessing effects",h),l.removeAllPasses()}vf&&console.log("PostProcessing Passes",t,"->",l.passes)}orderEffects(){var t;vf&&console.log("Before ordering effects",[...this._effects]);const e=this._effects;e.sort((i,n)=>{const r=e2.findIndex(a=>i.constructor.name.endsWith(a.name)),o=e2.findIndex(a=>n.constructor.name.endsWith(a.name));return r<0?(vf&&console.warn("Unknown effect found: ",i.constructor.name),-1):o<0?(vf&&console.warn("Unknown effect found: ",n.constructor.name),1):r<0?1:o<0?-1:r-o}),vf&&console.log("After ordering effects",[...this._effects]);for(let i=0;i<e.length;i++){const n=e[i];if(((t=n==null?void 0:n.configuration)==null?void 0:t.gammaCorrection)!==void 0){const r=i===e.length-1;n.configuration.gammaCorrection=r}}}}const e2=[SQ,CO,_Q,bQ,EW,xQ,gQ,fQ,wO,AQ,wQ,vQ,wC,yQ,dQ,TW];async function jL(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>dbe);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var R0e=Object.defineProperty,P0e=Object.getOwnPropertyDescriptor,Sb=(s,e,t,i)=>{for(var n=i>1?void 0:i?P0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&R0e(e,t,n),n};const Ia=ie("debugskybox");jL("skybox-image");jL("environment-image");function q4(s,e,t,i,n){const r=new Ec;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,re.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Ia&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return MV(s.domElement,n,o),r.addEventListener("destroy",()=>{Ia&&console.log("Destroyed attribute remote skybox",n),TV(s.domElement,n,o)}),r.setSkybox(e)}di.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Ia&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==od.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=q4(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Ia&&console.log("Creating remote environment to load "+i);const o=q4(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?V1(n):Promise.resolve()});function IW(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function X4(s){const t=IW().find(i=>i.src===s);return t?(Ia&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function B0e(s){const e=await s;vO(e,!0),Wi(e)}function D0e(s,e){const t=IW();for(;t.length>5;){const i=t.shift();i&&B0e(i.texture)}e.then(i=>vO(i,!1)),t.push({src:s,texture:e})}class Ec extends Ie{constructor(){super(...arguments);d(this,"url");d(this,"allowDrop",!0);d(this,"background",!0);d(this,"environment",!0);d(this,"allowNetworking",!0);d(this,"_loader");d(this,"_prevUrl");d(this,"_prevLoadedEnvironment");d(this,"_prevEnvironment",null);d(this,"_prevBackground",null);d(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);d(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});d(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Ia&&console.log(a),a==="text/uri-list"){const l=t.dataTransfer.getData(a);Ia&&console.log(a,l);let c=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(l))==null?void 0:i.groups)==null?void 0:n.name;if(c||(c=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(l))==null?void 0:r.groups)==null?void 0:o.name),Ia&&console.log(c),c){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+c+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${h}`),t.preventDefault(),this.setSkybox(h);break}else if(this.isValidTextureType(l)){console.log("[Remote Skybox] Setting skybox from url: "+l),t.preventDefault(),this.setSkybox(l);break}else{console.warn(`[RemoteSkybox] Unknown url ${l}. 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 h=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:l,apply:u=>{t.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(h)}}else if(a=="Files"){const l=t.dataTransfer.files.item(0);if(Ia&&console.log(a,l),!l)continue;if(!this.isValidTextureType(l.name)){console.warn(`[RemoteSkybox]: File "${l.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(X4(l.name)===null){const c=new Blob([l]),h=URL.createObjectURL(c);t.preventDefault(),this.setSkybox(h,l.name)}else t.preventDefault(),this.setSkybox(l.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Gi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||(t=O0e(t,this.environment,this.background),!t))return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Ia&&console.log("Set remote skybox url: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof mc&&(n.colorSpace=At),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var c,h,u,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=X4(i);if(n){const m=await n;if(((h=(c=m.source)==null?void 0:c.data)==null?void 0:h.length)>0||(p=(f=(u=m.source)==null?void 0:u.data)==null?void 0:f.data)!=null&&p.length)return m}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof W0||(this._loader=new W0):o?this._loader instanceof PC||(this._loader=new PC):this._loader instanceof mc||(this._loader=new mc),Ia&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return D0e(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=ty,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),Ia&&console.log("Set remote skybox",this.url,!Gi.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Gi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))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)}}Sb([$O(Ec.prototype.urlChangedSyncField),x(URL)],Ec.prototype,"url",2);Sb([x()],Ec.prototype,"allowDrop",2);Sb([x()],Ec.prototype,"background",2);Sb([x()],Ec.prototype,"environment",2);Sb([x()],Ec.prototype,"allowNetworking",2);function O0e(s,e,t){const i=e&&!t;switch(s==null?void 0:s.toLowerCase()){case"studio":return i?"https://cdn.needle.tools/static/skybox/modelviewer-Neutral-small.hdr":"https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";case"blurred-skybox":return i?"https://cdn.needle.tools/static/skybox/blurred-skybox-small.exr":"https://cdn.needle.tools/static/skybox/blurred-skybox.exr";case"quicklook-ar":return i?"https://cdn.needle.tools/static/skybox/QuickLook-ARMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";case"quicklook":return i?"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr"}return s===void 0?null:s}var L0e=Object.defineProperty,k0e=Object.getOwnPropertyDescriptor,ha=(s,e,t,i)=>{for(var n=i>1?void 0:i?k0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&L0e(e,t,n),n};const jo=ie("debugsceneswitcher"),QS="scene";jL(QS);const Tu=Promise.resolve(!1);class zr extends Ie{constructor(){super(...arguments);d(this,"autoLoadFirstScene",!0);d(this,"scenes",[]);d(this,"loadingScene");d(this,"queryParameterName","scene");d(this,"useSceneName",!0);d(this,"clamp",!0);d(this,"useHistory",!0);d(this,"useKeyboard",!0);d(this,"useSwipe",!0);d(this,"useSceneLighting",!0);d(this,"preloadNext",1);d(this,"preloadPrevious",1);d(this,"preloadConcurrent",2);d(this,"_currentIndex",-1);d(this,"_currentScene");d(this,"_engineElementOverserver");d(this,"_preloadScheduler");d(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);jo&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});d(this,"normalizedSwipeThresholdX",.1);d(this,"_didSwipe",!1);d(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});d(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});d(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});d(this,"__lastSwitchScene");d(this,"__lastSwitchScenePromise");d(this,"_currentlyLoadingScene");d(this,"_lastLoadingScene");d(this,"_loadingScenePromise");d(this,"_isCurrentlyLoading",!1);d(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=[]);for(const t of this.scenes)t&&!t.hasUrl&&t.asset instanceof ve&&t.asset.removeFromParent();jo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(fn.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===QS){const n=this.context.domElement.getAttribute(QS);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new F0e(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 t=this.context.domElement.getAttribute(QS);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(fn.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new Zt(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(jo&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(l=>l.uri===t);if(!a){const l=Zt.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(l)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return Tu}if(!((o=this.scenes)!=null&&o.length))return Tu;if(t<0){if(this.clamp)return Tu;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return Tu;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof Zt)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){jo&&console.log("UNLOAD",t.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.hasUrl?this._currentScene.unload():this._currentScene.asset instanceof ve&&this._currentScene.asset.removeFromParent()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((l,c)=>{this._currentLoadingProgress=c,this.dispatchEvent(c)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return jo&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return jo&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(jo&&console.log("ADD",t.uri),this._currentScene=t,re.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let h=i.toString();if(this.useSceneName&&(h=Y4(t.uri)),(r=this.queryParameterName)!=null&&r.length)aC(this.queryParameterName,h,this.useHistory);else{const u=history.state,f=this.guid+"::"+i;u!==f&&history.pushState(f,"unused",location.href)}}const l=this.tryGetSceneEventListener(t.asset);if(l!=null&&l.sceneOpened){const h=l.sceneOpened(this);h instanceof Promise&&await h}const c=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(c),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof Zt)return i.preload()}return Tu}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return Tu;const t=ie(this.queryParameterName);return typeof t=="boolean"?Tu:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&Y4(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return so()&&console.warn('Can not find scene: "'+t+'"',this),Tu}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){jo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}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 t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){jo&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=re.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}ha([x()],zr.prototype,"autoLoadFirstScene",2);ha([x(Zt)],zr.prototype,"scenes",2);ha([x(Zt)],zr.prototype,"loadingScene",2);ha([x()],zr.prototype,"queryParameterName",2);ha([x()],zr.prototype,"useSceneName",2);ha([x()],zr.prototype,"clamp",2);ha([x()],zr.prototype,"useHistory",2);ha([x()],zr.prototype,"useKeyboard",2);ha([x()],zr.prototype,"useSwipe",2);ha([x()],zr.prototype,"useSceneLighting",2);ha([x()],zr.prototype,"preloadNext",2);ha([x()],zr.prototype,"preloadPrevious",2);ha([x()],zr.prototype,"preloadConcurrent",2);function Y4(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class F0e{constructor(e,t=1,i=1,n=2){d(this,"maxLoadAhead");d(this,"maxLoadBehind");d(this,"maxConcurrent");d(this,"_isRunning",!1);d(this,"_switcher");d(this,"_loadTasks",[]);d(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;jo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(jo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=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>=n.length)return;const c=n[l];new U0e(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==null?void 0:e.isLoaded())===!1)return!1}return!0}}class U0e{constructor(e,t,i){d(this,"index");d(this,"asset");d(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(jo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),jo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function N0e(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function z0e(s){await N0e(),s()}var G0e=Object.defineProperty,H0e=Object.getOwnPropertyDescriptor,ua=(s,e,t,i)=>{for(var n=i>1?void 0:i?H0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&G0e(e,t,n),n};const Ms=ie("debugvideo");var RW=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))(RW||{}),PW=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(PW||{}),BW=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(BW||{});class bs extends Ie{constructor(){super();d(this,"playOnAwake",!0);d(this,"aspectMode",0);d(this,"clip",null);d(this,"source",1);d(this,"_url",null);d(this,"renderMode");d(this,"targetMaterialProperty");d(this,"targetMaterialRenderer");d(this,"targetTexture");d(this,"time",0);d(this,"_playbackSpeed",1);d(this,"_isLooping",!1);d(this,"_muted",!1);d(this,"_audioOutputMode",2);d(this,"playInBackground",!0);d(this,"_crossOrigin","anonymous");d(this,"_videoElement",null);d(this,"_videoTexture",null);d(this,"_videoMaterial",null);d(this,"_isPlaying",!1);d(this,"wasPlaying",!1);d(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});d(this,"_receivedInput",!1);d(this,"_overlay",null);d(this,"_targetObjects");d(this,"_updateAspectRoutineId",-1);d(this,"_hls");d(this,"onHlsAvailable",()=>{var t;Ms&&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),(t=this._videoElement)==null||t.play(),Ms&&console.log("HLS: loaded",this.clip))});z0e(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ie("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(t){const n=this._url!==t;this.__didAwake?n&&this.setClipURL(t??""):this._url=t}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):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 t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&lt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Ms&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this._url!==t&&(this._url=t,this.source=1,Ms&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")||t.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;Ms&&console.log("VideoPlayer.onEnable",PW[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){Ms&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Ms&&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),Ms&&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)}),Ms&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Ms&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),Ms&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(Ms&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(Ms&&console.log("Set Video src",i),this._videoElement.src=i):(Ms&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new VH(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=At,t&&this.handleBeginPlaying(t),Ms&&console.log("Video: handle playing done...",i,t),!0):(Ms&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new V0e(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),Ms&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=re.getComponent(this.gameObject,Nn))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,BW[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",l=this._videoMaterial;if(!this.targetMaterialProperty)l[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:l[a]=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(),t&&(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 t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,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 t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const l=Ki(o.parent);a=l.x/l.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(Ms&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}ua([x()],bs.prototype,"playOnAwake",2);ua([x()],bs.prototype,"aspectMode",2);ua([x(URL)],bs.prototype,"clip",2);ua([x()],bs.prototype,"source",2);ua([x(URL)],bs.prototype,"url",1);ua([x()],bs.prototype,"renderMode",2);ua([x()],bs.prototype,"targetMaterialProperty",2);ua([x(Nn)],bs.prototype,"targetMaterialRenderer",2);ua([x(Vt)],bs.prototype,"targetTexture",2);ua([x()],bs.prototype,"time",2);ua([x()],bs.prototype,"playbackSpeed",1);ua([x()],bs.prototype,"isLooping",1);ua([x()],bs.prototype,"audioOutputMode",1);class V0e{constructor(e){d(this,"context");d(this,"_videos",[]);d(this,"_screenspaceModeQuad");d(this,"_isInScreenspaceMode",!1);d(this,"_input");this.context=e,this._input=new Q0e(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 n;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=z_.createPrimitive(Sp.Quad,{material:new j0e(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Q0e{constructor(e){d(this,"_onResizeScreenFn");d(this,"_onKeyUpFn");d(this,"_onMouseWheelFn");d(this,"context");d(this,"overlay");d(this,"_material");d(this,"_isPinching",!1);d(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=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new ee;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new ee(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,l=r.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 j0e extends Dt{constructor(t){super();d(this,"_offset",new ee);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ze(0,0,1,1)}},this.vertexShader=`
7589
+ `;class TW extends ro{constructor(){super("Sharpening",I0e,{vertexShader:T0e,blendFunction:jt.NORMAL,uniforms:new Map([["amount",new we(1)],["radius",new we(1)]])})}}const vf=ie("debugpost"),aR=Symbol("needle:postprocessing-handler"),lR=Symbol("needle:previous-autoclear-state");class rM{constructor(e){d(this,"_composer",null);d(this,"_lastVolumeComponents");d(this,"_effects",[]);d(this,"_isActive",!1);d(this,"context");this.context=e}get isActive(){return this._isActive}get composer(){return this._composer}apply(e){this._isActive=!0,this.onApply(this.context,e)}unapply(){var i;if(vf&&console.log("Unapplying postprocessing effects"),this._isActive=!1,this._lastVolumeComponents){for(const n of this._lastVolumeComponents)n.unapply();this._lastVolumeComponents.length=0}const e=this.context;e[aR]===this&&delete e[aR],e.composer===this._composer&&((i=e.composer)==null||i.dispose(),e.composer=null),typeof e.renderer[lR]=="boolean"&&(e.renderer.autoClear=e.renderer[lR])}dispose(){this.unapply();for(const e of this._effects)e.dispose();this._effects.length=0,this._composer=null}onApply(e,t){if(!t)return;e[aR]=this,vf&&console.log("refreshing volume profile",t),this._lastVolumeComponents=[...t],this._effects.length=0;const i={handler:this,components:this._lastVolumeComponents};for(let n=0;n<this._lastVolumeComponents.length;n++){const r=this._lastVolumeComponents[n];if(r.context=e,r.apply){if(r.active){if(!e.mainCameraComponent){console.error("No camera in scene found or available yet - can not create postprocessing effects");return}const o=r.apply(i);if(!o)continue;Array.isArray(o)?this._effects.push(...o):this._effects.push(o)}}else r.active&&Ni("Volume component is not a VolumeComponent: "+r.__type)}if(this.context.renderer.toneMapping!=io&&!this._effects.find(n=>n instanceof wC)){const n=new wC;this._effects.push(n)}this.applyEffects(e)}applyEffects(e){const t=this._effects;if(t.length<=0)return;const i=e.mainCameraComponent,n=e.renderer,r=e.scene,o=i.cam;n[lR]=n.autoClear;const a=n.capabilities.maxSamples;this._composer||(this._composer=new bO(n,{frameBufferType:ms,stencilBuffer:!0,multisampling:Math.min(qa()?4:8,a)})),e.composer&&e.composer!==this._composer&&console.warn("There's already an active EffectComposer in your scene: replacing it with a new one. This might cause unexpected behaviour. Make sure to only use one PostprocessingManager/Volume in your scene."),e.composer=this._composer;const l=e.composer;l.setMainCamera(o),l.setRenderer(n),l.setMainScene(r);for(const h of l.passes)h.dispose();l.removeAllPasses();const c=new lE(r,o);c.name="Render To Screen",c.mainScene=r,l.addPass(c);try{this.orderEffects();const h=[];for(const u of t)if(u instanceof ro)h.push(u);else if(u instanceof lr){const f=new M3(o,...h);f.mainScene=r,f.name=h.map(p=>p.constructor.name).join(", "),f.enabled=!0,h.length=0,l.addPass(u)}if(h.length>0){const u=new M3(o,...h);u.name=h.map(f=>f.name).join(" "),u.mainScene=r,u.enabled=!0,l.addPass(u)}}catch(h){console.error("Error while applying postprocessing effects",h),l.removeAllPasses()}vf&&console.log("PostProcessing Passes",t,"->",l.passes)}orderEffects(){var t;vf&&console.log("Before ordering effects",[...this._effects]);const e=this._effects;e.sort((i,n)=>{const r=e2.findIndex(a=>i.constructor.name.endsWith(a.name)),o=e2.findIndex(a=>n.constructor.name.endsWith(a.name));return r<0?(vf&&console.warn("Unknown effect found: ",i.constructor.name),-1):o<0?(vf&&console.warn("Unknown effect found: ",n.constructor.name),1):r<0?1:o<0?-1:r-o}),vf&&console.log("After ordering effects",[...this._effects]);for(let i=0;i<e.length;i++){const n=e[i];if(((t=n==null?void 0:n.configuration)==null?void 0:t.gammaCorrection)!==void 0){const r=i===e.length-1;n.configuration.gammaCorrection=r}}}}const e2=[SQ,CO,_Q,bQ,EW,xQ,gQ,fQ,wO,AQ,wQ,vQ,wC,yQ,dQ,TW];async function jL(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>dbe);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var R0e=Object.defineProperty,P0e=Object.getOwnPropertyDescriptor,Sb=(s,e,t,i)=>{for(var n=i>1?void 0:i?P0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&R0e(e,t,n),n};const Ia=ie("debugskybox");jL("skybox-image");jL("environment-image");function q4(s,e,t,i,n){const r=new Ec;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,re.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Ia&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return MV(s.domElement,n,o),r.addEventListener("destroy",()=>{Ia&&console.log("Destroyed attribute remote skybox",n),TV(s.domElement,n,o)}),r.setSkybox(e)}di.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Ia&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==od.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=q4(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Ia&&console.log("Creating remote environment to load "+i);const o=q4(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?V1(n):Promise.resolve()});function IW(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function X4(s){const t=IW().find(i=>i.src===s);return t?(Ia&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function B0e(s){const e=await s;vO(e,!0),Wi(e)}function D0e(s,e){const t=IW();for(;t.length>5;){const i=t.shift();i&&B0e(i.texture)}e.then(i=>vO(i,!1)),t.push({src:s,texture:e})}class Ec extends Ie{constructor(){super(...arguments);d(this,"url");d(this,"allowDrop",!0);d(this,"background",!0);d(this,"environment",!0);d(this,"allowNetworking",!0);d(this,"_loader");d(this,"_prevUrl");d(this,"_prevLoadedEnvironment");d(this,"_prevEnvironment",null);d(this,"_prevBackground",null);d(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);d(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});d(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Ia&&console.log(a),a==="text/uri-list"){const l=t.dataTransfer.getData(a);Ia&&console.log(a,l);let c=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(l))==null?void 0:i.groups)==null?void 0:n.name;if(c||(c=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(l))==null?void 0:r.groups)==null?void 0:o.name),Ia&&console.log(c),c){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+c+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${h}`),t.preventDefault(),this.setSkybox(h);break}else if(this.isValidTextureType(l)){console.log("[Remote Skybox] Setting skybox from url: "+l),t.preventDefault(),this.setSkybox(l);break}else{console.warn(`[RemoteSkybox] Unknown url ${l}. 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 h=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:l,apply:u=>{t.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(h)}}else if(a=="Files"){const l=t.dataTransfer.files.item(0);if(Ia&&console.log(a,l),!l)continue;if(!this.isValidTextureType(l.name)){console.warn(`[RemoteSkybox]: File "${l.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(X4(l.name)===null){const c=new Blob([l]),h=URL.createObjectURL(c);t.preventDefault(),this.setSkybox(h,l.name)}else t.preventDefault(),this.setSkybox(l.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Gi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||(t=O0e(t,this.environment,this.background),!t))return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Ia&&console.log("Set remote skybox url: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof mc&&(n.colorSpace=At),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var c,h,u,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=X4(i);if(n){const m=await n;if(((h=(c=m.source)==null?void 0:c.data)==null?void 0:h.length)>0||(p=(f=(u=m.source)==null?void 0:u.data)==null?void 0:f.data)!=null&&p.length)return m}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof W0||(this._loader=new W0):o?this._loader instanceof PC||(this._loader=new PC):this._loader instanceof mc||(this._loader=new mc),Ia&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return D0e(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=ty,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),Ia&&console.log("Set remote skybox",this.url,!Gi.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Gi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))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)}}Sb([$O(Ec.prototype.urlChangedSyncField),x(URL)],Ec.prototype,"url",2);Sb([x()],Ec.prototype,"allowDrop",2);Sb([x()],Ec.prototype,"background",2);Sb([x()],Ec.prototype,"environment",2);Sb([x()],Ec.prototype,"allowNetworking",2);function O0e(s,e,t){const i=e&&!t;switch(s==null?void 0:s.toLowerCase()){case"studio":return i?"https://cdn.needle.tools/static/skybox/modelviewer-Neutral-small.hdr":"https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";case"blurred-skybox":return i?"https://cdn.needle.tools/static/skybox/blurred-skybox-small.exr":"https://cdn.needle.tools/static/skybox/blurred-skybox.exr";case"quicklook-ar":return i?"https://cdn.needle.tools/static/skybox/QuickLook-ARMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";case"quicklook":return i?"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode-small.exr":"https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr"}return s===void 0?null:s}var L0e=Object.defineProperty,k0e=Object.getOwnPropertyDescriptor,ha=(s,e,t,i)=>{for(var n=i>1?void 0:i?k0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&L0e(e,t,n),n};const jo=ie("debugsceneswitcher"),QS="scene";jL(QS);const Tu=Promise.resolve(!1);class zr extends Ie{constructor(){super(...arguments);d(this,"autoLoadFirstScene",!0);d(this,"scenes",[]);d(this,"loadingScene");d(this,"queryParameterName","scene");d(this,"useSceneName",!0);d(this,"clamp",!0);d(this,"useHistory",!0);d(this,"useKeyboard",!0);d(this,"useSwipe",!0);d(this,"useSceneLighting",!0);d(this,"preloadNext",1);d(this,"preloadPrevious",1);d(this,"preloadConcurrent",2);d(this,"_currentIndex",-1);d(this,"_currentScene");d(this,"_engineElementOverserver");d(this,"_preloadScheduler");d(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);jo&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});d(this,"normalizedSwipeThresholdX",.1);d(this,"_didSwipe",!1);d(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});d(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});d(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});d(this,"__lastSwitchScene");d(this,"__lastSwitchScenePromise");d(this,"_currentlyLoadingScene");d(this,"_lastLoadingScene");d(this,"_loadingScenePromise");d(this,"_isCurrentlyLoading",!1);d(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=[]);for(const t of this.scenes)t&&!t.hasUrl&&t.asset instanceof ve&&t.asset.removeFromParent();jo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(fn.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===QS){const n=this.context.domElement.getAttribute(QS);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new F0e(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 t=this.context.domElement.getAttribute(QS);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(fn.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new Zt(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(jo&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(l=>l.uri===t);if(!a){const l=Zt.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(l)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return Tu}if(!((o=this.scenes)!=null&&o.length))return Tu;if(t<0){if(this.clamp)return Tu;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return Tu;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof Zt)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){jo&&console.log("UNLOAD",this._currentScene.url,"HasURL?: "+this._currentScene.hasUrl);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.hasUrl?this._currentScene.unload():this._currentScene.asset instanceof ve&&this._currentScene.asset.removeFromParent()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((l,c)=>{this._currentLoadingProgress=c,this.dispatchEvent(c)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return jo&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return jo&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(jo&&console.log("ADD",t.uri),this._currentScene=t,re.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let h=i.toString();if(this.useSceneName&&(h=Y4(t.uri)),(r=this.queryParameterName)!=null&&r.length)aC(this.queryParameterName,h,this.useHistory);else{const u=history.state,f=this.guid+"::"+i;u!==f&&history.pushState(f,"unused",location.href)}}const l=this.tryGetSceneEventListener(t.asset);if(l!=null&&l.sceneOpened){const h=l.sceneOpened(this);h instanceof Promise&&await h}const c=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(c),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof Zt)return i.preload()}return Tu}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return Tu;const t=ie(this.queryParameterName);return typeof t=="boolean"?Tu:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&Y4(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return so()&&console.warn('Can not find scene: "'+t+'"',this),Tu}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){jo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}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 t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){jo&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=re.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}ha([x()],zr.prototype,"autoLoadFirstScene",2);ha([x(Zt)],zr.prototype,"scenes",2);ha([x(Zt)],zr.prototype,"loadingScene",2);ha([x()],zr.prototype,"queryParameterName",2);ha([x()],zr.prototype,"useSceneName",2);ha([x()],zr.prototype,"clamp",2);ha([x()],zr.prototype,"useHistory",2);ha([x()],zr.prototype,"useKeyboard",2);ha([x()],zr.prototype,"useSwipe",2);ha([x()],zr.prototype,"useSceneLighting",2);ha([x()],zr.prototype,"preloadNext",2);ha([x()],zr.prototype,"preloadPrevious",2);ha([x()],zr.prototype,"preloadConcurrent",2);function Y4(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class F0e{constructor(e,t=1,i=1,n=2){d(this,"maxLoadAhead");d(this,"maxLoadBehind");d(this,"maxConcurrent");d(this,"_isRunning",!1);d(this,"_switcher");d(this,"_loadTasks",[]);d(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;jo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(jo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=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>=n.length)return;const c=n[l];new U0e(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==null?void 0:e.isLoaded())===!1)return!1}return!0}}class U0e{constructor(e,t,i){d(this,"index");d(this,"asset");d(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(jo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),jo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function N0e(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function z0e(s){await N0e(),s()}var G0e=Object.defineProperty,H0e=Object.getOwnPropertyDescriptor,ua=(s,e,t,i)=>{for(var n=i>1?void 0:i?H0e(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&G0e(e,t,n),n};const Ms=ie("debugvideo");var RW=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))(RW||{}),PW=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(PW||{}),BW=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(BW||{});class bs extends Ie{constructor(){super();d(this,"playOnAwake",!0);d(this,"aspectMode",0);d(this,"clip",null);d(this,"source",1);d(this,"_url",null);d(this,"renderMode");d(this,"targetMaterialProperty");d(this,"targetMaterialRenderer");d(this,"targetTexture");d(this,"time",0);d(this,"_playbackSpeed",1);d(this,"_isLooping",!1);d(this,"_muted",!1);d(this,"_audioOutputMode",2);d(this,"playInBackground",!0);d(this,"_crossOrigin","anonymous");d(this,"_videoElement",null);d(this,"_videoTexture",null);d(this,"_videoMaterial",null);d(this,"_isPlaying",!1);d(this,"wasPlaying",!1);d(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});d(this,"_receivedInput",!1);d(this,"_overlay",null);d(this,"_targetObjects");d(this,"_updateAspectRoutineId",-1);d(this,"_hls");d(this,"onHlsAvailable",()=>{var t;Ms&&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),(t=this._videoElement)==null||t.play(),Ms&&console.log("HLS: loaded",this.clip))});z0e(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ie("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(t){const n=this._url!==t;this.__didAwake?n&&this.setClipURL(t??""):this._url=t}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):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 t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&lt()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Ms&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this._url!==t&&(this._url=t,this.source=1,Ms&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")||t.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;Ms&&console.log("VideoPlayer.onEnable",PW[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){Ms&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Ms&&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),Ms&&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)}),Ms&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Ms&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),Ms&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(Ms&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(Ms&&console.log("Set Video src",i),this._videoElement.src=i):(Ms&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new VH(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=At,t&&this.handleBeginPlaying(t),Ms&&console.log("Video: handle playing done...",i,t),!0):(Ms&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new V0e(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),Ms&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=re.getComponent(this.gameObject,Nn))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,BW[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",l=this._videoMaterial;if(!this.targetMaterialProperty)l[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:l[a]=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(),t&&(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 t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,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 t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const l=Ki(o.parent);a=l.x/l.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(Ms&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}ua([x()],bs.prototype,"playOnAwake",2);ua([x()],bs.prototype,"aspectMode",2);ua([x(URL)],bs.prototype,"clip",2);ua([x()],bs.prototype,"source",2);ua([x(URL)],bs.prototype,"url",1);ua([x()],bs.prototype,"renderMode",2);ua([x()],bs.prototype,"targetMaterialProperty",2);ua([x(Nn)],bs.prototype,"targetMaterialRenderer",2);ua([x(Vt)],bs.prototype,"targetTexture",2);ua([x()],bs.prototype,"time",2);ua([x()],bs.prototype,"playbackSpeed",1);ua([x()],bs.prototype,"isLooping",1);ua([x()],bs.prototype,"audioOutputMode",1);class V0e{constructor(e){d(this,"context");d(this,"_videos",[]);d(this,"_screenspaceModeQuad");d(this,"_isInScreenspaceMode",!1);d(this,"_input");this.context=e,this._input=new Q0e(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 n;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=z_.createPrimitive(Sp.Quad,{material:new j0e(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Q0e{constructor(e){d(this,"_onResizeScreenFn");d(this,"_onKeyUpFn");d(this,"_onMouseWheelFn");d(this,"context");d(this,"overlay");d(this,"_material");d(this,"_isPinching",!1);d(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=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new ee;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new ee(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,l=r.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 j0e extends Dt{constructor(t){super();d(this,"_offset",new ee);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ze(0,0,1,1)}},this.vertexShader=`
7590
7590
  uniform sampler2D map;
7591
7591
  uniform float screenAspect;
7592
7592
  uniform vec4 offsetScale;