@needle-tools/engine 3.41.1-alpha → 3.41.1-alpha.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.
- package/CHANGELOG.md +1 -1
- package/dist/needle-engine.js +7 -7
- package/dist/needle-engine.light.js +7 -7
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine/xr/NeedleXRSession.js +4 -4
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/xr/NeedleXRSession.ts +5 -5
|
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+A.toString())}const t=Jo()||J0()&&oe();if((
|
|
|
4344
4344
|
#__vconsole .vc-mask {
|
|
4345
4345
|
overflow: hidden;
|
|
4346
4346
|
}
|
|
4347
|
-
`,ds?.prepend(i),t===!0&&kU()<=0&&PH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function RgA(){const t=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+t._id+" iframe");return t.on("renderTab",function(e){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let g=globalThis["needle:codegen_files"][0];const I=g.indexOf("?");I>-1&&(g=g.substring(0,I));const o=location.protocol+"//"+location.host+location.pathname+"/"+g,s=encodeURIComponent(o);t.fullUrl="https://viewer.needle.tools?inspect&file="+s;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),t.on("show",function(){const e=A();e&&e.src!==t.fullUrl&&(e.src=t.fullUrl)}),t.on("hide",function(){const e=A();e&&(e.src="")}),t.on("addTopBar",function(e){var i=new Array;i.push({name:"Open in new window \u2197",onClick:function(g){window.open(t.fullUrl,"_blank"),ls?.hide()}}),i.push({name:"Reload",onClick:function(g){const I=A();I&&(I.src=t.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(g){const I=A();I.requestFullscreen?I.requestFullscreen():I.webkitRequestFullscreen instanceof Function&&I.webkitRequestFullscreen()}}),e(i)}),t}function UgA(){return document.querySelector("#__vconsole .vc-switch")||null}function FgA(){return document.querySelector("#__vconsole")||null}const VH=tA("debugdefines");$h('if(!globalThis[""3.41.1-alpha""]) globalThis[""3.41.1-alpha""] = "0.0.0";'),$h('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),$h('if(!globalThis[""Mon Jun 24 2024
|
|
4347
|
+
`,ds?.prepend(i),t===!0&&kU()<=0&&PH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function RgA(){const t=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+t._id+" iframe");return t.on("renderTab",function(e){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let g=globalThis["needle:codegen_files"][0];const I=g.indexOf("?");I>-1&&(g=g.substring(0,I));const o=location.protocol+"//"+location.host+location.pathname+"/"+g,s=encodeURIComponent(o);t.fullUrl="https://viewer.needle.tools?inspect&file="+s;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),t.on("show",function(){const e=A();e&&e.src!==t.fullUrl&&(e.src=t.fullUrl)}),t.on("hide",function(){const e=A();e&&(e.src="")}),t.on("addTopBar",function(e){var i=new Array;i.push({name:"Open in new window \u2197",onClick:function(g){window.open(t.fullUrl,"_blank"),ls?.hide()}}),i.push({name:"Reload",onClick:function(g){const I=A();I&&(I.src=t.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(g){const I=A();I.requestFullscreen?I.requestFullscreen():I.webkitRequestFullscreen instanceof Function&&I.webkitRequestFullscreen()}}),e(i)}),t}function UgA(){return document.querySelector("#__vconsole .vc-switch")||null}function FgA(){return document.querySelector("#__vconsole")||null}const VH=tA("debugdefines");$h('if(!globalThis[""3.41.1-alpha.1""]) globalThis[""3.41.1-alpha.1""] = "0.0.0";'),$h('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),$h('if(!globalThis[""Mon Jun 24 2024 16:20:52 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Jun 24 2024 16:20:52 GMT+0200 (Central European Summer Time)""] = "unknown";'),$h('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.41.1-alpha.1";'),$h('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),$h('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Jun 24 2024 16:20:52 GMT+0200 (Central European Summer Time)";');const na="3.41.1-alpha.1",iS="undefined",mF="Mon Jun 24 2024 16:20:52 GMT+0200 (Central European Summer Time)";VH&&console.log(`Engine version: ${na} (generator: ${iS})
|
|
4348
4348
|
Project built at ${mF}`);const aC="needle_isActiveInHierarchy",bQ="builtin_components",yu="needle_editor_guid";function $h(t){try{(0,eval)(t)}catch(A){VH&&console.error(A)}}const NgA='<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>',bgA=btoa(NgA),KgA="data:image/svg+xml;base64,"+bgA,vgA=KgA,JgA=`<?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(JgA);const xgA='<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>',qgA=btoa(xgA),LgA="data:image/svg+xml;charset=utf-8;base64,"+qgA,_gA=LgA,us=tA("debuglicense");let KQ="basic";us&&console.log("License Type: "+KQ);function kr(){switch(KQ){case"pro":case"enterprise":return!0}return!1}function fF(){switch(KQ){case"indie":return!0}return!1}function nC(){return kr()||fF()}const zH=[];function TgA(t){if(kr()||fF())return t(!0);zH.push(t)}function YgA(t){for(const A of zH)try{A(t)}catch{}}Ct.registerCallback(kt.ContextRegistered,t=>{PgA(t.context),WgA(),OgA(t.context)});let vQ,kF=!1,gS="";async function HgA(){if(vQ)return vQ;if(KQ==="basic")try{const t="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+na+"&generator="+encodeURIComponent(iS),A=await fetch(t,{method:"GET"}).catch(e=>{us&&console.error("License check failed",e)});A?.status===200?(kF=!1,us&&console.log("License check succeeded"),KQ="pro",YgA(!0)):A?.status===403?(kF=!0,gS=await A.text()):us&&console.log("License check failed with status "+A?.status)}catch(t){us&&console.error("License check failed",t)}else us&&console.log('Runtime license check is skipped because license is already applied as "'+KQ+'"')}vQ=HgA();async function OgA(t){function A(){const g=document.createElement("div");g.className="needle-forbidden",g.style.cssText=`
|
|
4349
4349
|
position: fixed;
|
|
4350
4350
|
top: 0;
|
|
@@ -5234,7 +5234,7 @@ a=extmap-allow-mixed`)!==-1){const g=i.sdp.split(`
|
|
|
5234
5234
|
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},t}()),F3={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},KQA=function(){function t(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=F3,this.browser=mp.getBrowser(),this.browserVersion=mp.getVersion(),this.supports=function(){var A={browser:mp.isBrowserSupported(),webRTC:mp.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!A.webRTC)return A;var e;try{e=new RTCPeerConnection(F3),A.audioVideo=!0;var i=void 0;try{i=e.createDataChannel("_PEERJSTEST",{ordered:!0}),A.data=!0,A.reliable=!!i.ordered;try{i.binaryType="blob",A.binaryBlob=!mp.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{e&&e.close()}return A}(),this.pack=q4.pack,this.unpack=q4.unpack,this._dataCount=1}return t.prototype.noop=function(){},t.prototype.validateId=function(A){return!A||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(A)},t.prototype.chunk=function(A){for(var e=[],i=A.size,g=Math.ceil(i/Gt.chunkedMTU),I=0,o=0;o<i;){var s=Math.min(i,o+Gt.chunkedMTU),a=A.slice(o,s),n={__peerData:this._dataCount,n:I,data:a,total:g};e.push(n),o=s,I++}return this._dataCount++,e},t.prototype.blobToArrayBuffer=function(A,e){var i=new FileReader;return i.onload=function(g){g.target&&e(g.target.result)},i.readAsArrayBuffer(A),i},t.prototype.binaryStringToArrayBuffer=function(A){for(var e=new Uint8Array(A.length),i=0;i<A.length;i++)e[i]=A.charCodeAt(i)&255;return e.buffer},t.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},t.prototype.isSecure=function(){return location.protocol==="https:"},t}(),Gt=new KQA,N3={};an(N3,"Peer",()=>TK,t=>TK=t);var fp={},vQA=Object.prototype.hasOwnProperty,Io="~";function kp(){}Object.create&&(kp.prototype=Object.create(null),new kp().__proto__||(Io=!1));function JQA(t,A,e){this.fn=t,this.context=A,this.once=e||!1}function b3(t,A,e,i,g){if(typeof e!="function")throw new TypeError("The listener must be a function");var I=new JQA(e,i||t,g),o=Io?Io+A:A;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],I]:t._events[o].push(I):(t._events[o]=I,t._eventsCount++),t}function Jm(t,A){--t._eventsCount===0?t._events=new kp:delete t._events[A]}function UI(){this._events=new kp,this._eventsCount=0}UI.prototype.eventNames=function(){var t=[],A,e;if(this._eventsCount===0)return t;for(e in A=this._events)vQA.call(A,e)&&t.push(Io?e.slice(1):e);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(A)):t},UI.prototype.listeners=function(t){var A=Io?Io+t:t,e=this._events[A];if(!e)return[];if(e.fn)return[e.fn];for(var i=0,g=e.length,I=new Array(g);i<g;i++)I[i]=e[i].fn;return I},UI.prototype.listenerCount=function(t){var A=Io?Io+t:t,e=this._events[A];return e?e.fn?1:e.length:0},UI.prototype.emit=function(t,A,e,i,g,I){var o=Io?Io+t:t;if(!this._events[o])return!1;var s=this._events[o],a=arguments.length,n,C;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),a){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,A),!0;case 3:return s.fn.call(s.context,A,e),!0;case 4:return s.fn.call(s.context,A,e,i),!0;case 5:return s.fn.call(s.context,A,e,i,g),!0;case 6:return s.fn.call(s.context,A,e,i,g,I),!0}for(C=1,n=new Array(a-1);C<a;C++)n[C-1]=arguments[C];s.fn.apply(s.context,n)}else{var r=s.length,Q;for(C=0;C<r;C++)switch(s[C].once&&this.removeListener(t,s[C].fn,void 0,!0),a){case 1:s[C].fn.call(s[C].context);break;case 2:s[C].fn.call(s[C].context,A);break;case 3:s[C].fn.call(s[C].context,A,e);break;case 4:s[C].fn.call(s[C].context,A,e,i);break;default:if(!n)for(Q=1,n=new Array(a-1);Q<a;Q++)n[Q-1]=arguments[Q];s[C].fn.apply(s[C].context,n)}}return!0},UI.prototype.on=function(t,A,e){return b3(this,t,A,e,!1)},UI.prototype.once=function(t,A,e){return b3(this,t,A,e,!0)},UI.prototype.removeListener=function(t,A,e,i){var g=Io?Io+t:t;if(!this._events[g])return this;if(!A)return Jm(this,g),this;var I=this._events[g];if(I.fn)I.fn===A&&(!i||I.once)&&(!e||I.context===e)&&Jm(this,g);else{for(var o=0,s=[],a=I.length;o<a;o++)(I[o].fn!==A||i&&!I[o].once||e&&I[o].context!==e)&&s.push(I[o]);s.length?this._events[g]=s.length===1?s[0]:s:Jm(this,g)}return this},UI.prototype.removeAllListeners=function(t){var A;return t?(A=Io?Io+t:t,this._events[A]&&Jm(this,A)):(this._events=new kp,this._eventsCount=0),this},UI.prototype.off=UI.prototype.removeListener,UI.prototype.addListener=UI.prototype.on,UI.prefixed=Io,UI.EventEmitter=UI,fp=UI;var Be={};an(Be,"LogLevel",()=>fo,t=>fo=t),an(Be,"default",()=>K3,t=>K3=t);var oE=function(t,A){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),g,I=[],o;try{for(;(A===void 0||A-- >0)&&!(g=i.next()).done;)I.push(g.value)}catch(s){o={error:s}}finally{try{g&&!g.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return I},sE=function(t,A,e){if(e||arguments.length===2)for(var i=0,g=A.length,I;i<g;i++)(I||!(i in A))&&(I||(I=Array.prototype.slice.call(A,0,i)),I[i]=A[i]);return t.concat(I||Array.prototype.slice.call(A))},xQA="PeerJS: ",fo;(function(t){t[t.Disabled=0]="Disabled",t[t.Errors=1]="Errors",t[t.Warnings=2]="Warnings",t[t.All=3]="All"})(fo||(fo={}));var qQA=function(){function t(){this._logLevel=fo.Disabled}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(A){this._logLevel=A},enumerable:!1,configurable:!0}),t.prototype.log=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this._logLevel>=fo.All&&this._print.apply(this,sE([fo.All],oE(A),!1))},t.prototype.warn=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this._logLevel>=fo.Warnings&&this._print.apply(this,sE([fo.Warnings],oE(A),!1))},t.prototype.error=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this._logLevel>=fo.Errors&&this._print.apply(this,sE([fo.Errors],oE(A),!1))},t.prototype.setLogFunction=function(A){this._print=A},t.prototype._print=function(A){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var g=sE([xQA],oE(e),!1);for(var I in g)g[I]instanceof Error&&(g[I]="("+g[I].name+") "+g[I].message);A>=fo.All?console.log.apply(console,sE([],oE(g),!1)):A>=fo.Warnings?console.warn.apply(console,sE(["WARNING"],oE(g),!1)):A>=fo.Errors&&console.error.apply(console,sE(["ERROR"],oE(g),!1))},t}(),K3=new qQA,v3={};an(v3,"Socket",()=>J3,t=>J3=t);var wa;(function(t){t.Data="data",t.Media="media"})(wa||(wa={}));var Zi;(function(t){t.BrowserIncompatible="browser-incompatible",t.Disconnected="disconnected",t.InvalidID="invalid-id",t.InvalidKey="invalid-key",t.Network="network",t.PeerUnavailable="peer-unavailable",t.SslUnavailable="ssl-unavailable",t.ServerError="server-error",t.SocketError="socket-error",t.SocketClosed="socket-closed",t.UnavailableID="unavailable-id",t.WebRTC="webrtc"})(Zi||(Zi={}));var kC;(function(t){t.Binary="binary",t.BinaryUTF8="binary-utf8",t.JSON="json"})(kC||(kC={}));var GC;(function(t){t.Message="message",t.Disconnected="disconnected",t.Error="error",t.Close="close"})(GC||(GC={}));var eI;(function(t){t.Heartbeat="HEARTBEAT",t.Candidate="CANDIDATE",t.Offer="OFFER",t.Answer="ANSWER",t.Open="OPEN",t.Error="ERROR",t.IdTaken="ID-TAKEN",t.InvalidKey="INVALID-KEY",t.Leave="LEAVE",t.Expire="EXPIRE"})(eI||(eI={}));var JK={};JK=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz St\xFCckler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","So\u0308ren Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var LQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),_QA=function(t,A){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),g,I=[],o;try{for(;(A===void 0||A-- >0)&&!(g=i.next()).done;)I.push(g.value)}catch(s){o={error:s}}finally{try{g&&!g.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return I},TQA=function(t,A,e){if(e||arguments.length===2)for(var i=0,g=A.length,I;i<g;i++)(I||!(i in A))&&(I||(I=Array.prototype.slice.call(A,0,i)),I[i]=A[i]);return t.concat(I||Array.prototype.slice.call(A))},YQA=function(t){var A=typeof Symbol=="function"&&Symbol.iterator,e=A&&t[A],i=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(A?"Object is not iterable.":"Symbol.iterator is not defined.")},J3=function(t){LQA(A,t);function A(e,i,g,I,o,s){s===void 0&&(s=5e3);var a=t.call(this)||this;a.pingInterval=s,a._disconnected=!0,a._messagesQueue=[];var n=e?"wss://":"ws://";return a._baseUrl=n+i+":"+g+I+"peerjs?key="+o,a}return A.prototype.start=function(e,i){var g=this;this._id=e;var I="".concat(this._baseUrl,"&id=").concat(e,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(I+"&version="+JK.version),this._disconnected=!1,this._socket.onmessage=function(o){var s;try{s=JSON.parse(o.data),Be.default.log("Server message received:",s)}catch{Be.default.log("Invalid server message",o.data);return}g.emit(GC.Message,s)},this._socket.onclose=function(o){g._disconnected||(Be.default.log("Socket closed.",o),g._cleanup(),g._disconnected=!0,g.emit(GC.Disconnected))},this._socket.onopen=function(){g._disconnected||(g._sendQueuedMessages(),Be.default.log("Socket open"),g._scheduleHeartbeat())})},A.prototype._scheduleHeartbeat=function(){var e=this;this._wsPingTimer=setTimeout(function(){e._sendHeartbeat()},this.pingInterval)},A.prototype._sendHeartbeat=function(){if(!this._wsOpen()){Be.default.log("Cannot send heartbeat, because socket closed");return}var e=JSON.stringify({type:eI.Heartbeat});this._socket.send(e),this._scheduleHeartbeat()},A.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},A.prototype._sendQueuedMessages=function(){var e,i,g=TQA([],_QA(this._messagesQueue),!1);this._messagesQueue=[];try{for(var I=YQA(g),o=I.next();!o.done;o=I.next()){var s=o.value;this.send(s)}}catch(a){e={error:a}}finally{try{o&&!o.done&&(i=I.return)&&i.call(I)}finally{if(e)throw e.error}}},A.prototype.send=function(e){if(!this._disconnected){if(!this._id){this._messagesQueue.push(e);return}if(!e.type){this.emit(GC.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(e);this._socket.send(i)}}},A.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},A.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},A}(fp.EventEmitter),xK={};an(xK,"MediaConnection",()=>L3,t=>L3=t);var qK={};an(qK,"Negotiator",()=>x3,t=>x3=t);var xm=function(){return xm=Object.assign||function(t){for(var A,e=1,i=arguments.length;e<i;e++){A=arguments[e];for(var g in A)Object.prototype.hasOwnProperty.call(A,g)&&(t[g]=A[g])}return t},xm.apply(this,arguments)},qm=function(t,A,e,i){function g(I){return I instanceof e?I:new e(function(o){o(I)})}return new(e||(e=Promise))(function(I,o){function s(C){try{n(i.next(C))}catch(r){o(r)}}function a(C){try{n(i.throw(C))}catch(r){o(r)}}function n(C){C.done?I(C.value):g(C.value).then(s,a)}n((i=i.apply(t,A||[])).next())})},Lm=function(t,A){var e={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},i,g,I,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(n){return function(C){return a([n,C])}}function a(n){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,g&&(I=n[0]&2?g.return:n[0]?g.throw||((I=g.return)&&I.call(g),0):g.next)&&!(I=I.call(g,n[1])).done)return I;switch(g=0,I&&(n=[n[0]&2,I.value]),n[0]){case 0:case 1:I=n;break;case 4:return e.label++,{value:n[1],done:!1};case 5:e.label++,g=n[1],n=[0];continue;case 7:n=e.ops.pop(),e.trys.pop();continue;default:if(I=e.trys,!(I=I.length>0&&I[I.length-1])&&(n[0]===6||n[0]===2)){e=0;continue}if(n[0]===3&&(!I||n[1]>I[0]&&n[1]<I[3])){e.label=n[1];break}if(n[0]===6&&e.label<I[1]){e.label=I[1],I=n;break}if(I&&e.label<I[2]){e.label=I[2],e.ops.push(n);break}I[2]&&e.ops.pop(),e.trys.pop();continue}n=A.call(t,e)}catch(C){n=[6,C],g=0}finally{i=I=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},x3=function(){function t(A){this.connection=A}return t.prototype.startConnection=function(A){var e=this._startPeerConnection();if(this.connection.peerConnection=e,this.connection.type===wa.Media&&A._stream&&this._addTracksToConnection(A._stream,e),A.originator){if(this.connection.type===wa.Data){var i=this.connection,g={ordered:!!A.reliable},I=e.createDataChannel(i.label,g);i.initialize(I)}this._makeOffer()}else this.handleSDP("OFFER",A.sdp)},t.prototype._startPeerConnection=function(){Be.default.log("Creating RTCPeerConnection.");var A=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(A),A},t.prototype._setupListeners=function(A){var e=this,i=this.connection.peer,g=this.connection.connectionId,I=this.connection.type,o=this.connection.provider;Be.default.log("Listening for ICE candidates."),A.onicecandidate=function(s){!s.candidate||!s.candidate.candidate||(Be.default.log("Received ICE candidates for ".concat(i,":"),s.candidate),o.socket.send({type:eI.Candidate,payload:{candidate:s.candidate,type:I,connectionId:g},dst:i}))},A.oniceconnectionstatechange=function(){switch(A.iceConnectionState){case"failed":Be.default.log("iceConnectionState is failed, closing connections to "+i),e.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),e.connection.close();break;case"closed":Be.default.log("iceConnectionState is closed, closing connections to "+i),e.connection.emit("error",new Error("Connection to "+i+" closed.")),e.connection.close();break;case"disconnected":Be.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":A.onicecandidate=Gt.noop;break}e.connection.emit("iceStateChanged",A.iceConnectionState)},Be.default.log("Listening for data channel"),A.ondatachannel=function(s){Be.default.log("Received data channel");var a=s.channel,n=o.getConnection(i,g);n.initialize(a)},Be.default.log("Listening for remote stream"),A.ontrack=function(s){Be.default.log("Received remote stream");var a=s.streams[0],n=o.getConnection(i,g);if(n.type===wa.Media){var C=n;e._addStreamToMediaConnection(a,C)}}},t.prototype.cleanup=function(){Be.default.log("Cleaning up PeerConnection to "+this.connection.peer);var A=this.connection.peerConnection;if(A){this.connection.peerConnection=null,A.onicecandidate=A.oniceconnectionstatechange=A.ondatachannel=A.ontrack=function(){};var e=A.signalingState!=="closed",i=!1;if(this.connection.type===wa.Data){var g=this.connection,I=g.dataChannel;I&&(i=!!I.readyState&&I.readyState!=="closed")}(e||i)&&A.close()}},t.prototype._makeOffer=function(){return qm(this,void 0,Promise,function(){var A,e,i,g,I,o,s;return Lm(this,function(a){switch(a.label){case 0:A=this.connection.peerConnection,e=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,A.createOffer(this.connection.options.constraints)];case 2:i=a.sent(),Be.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,A.setLocalDescription(i)];case 4:return a.sent(),Be.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),g={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:Gt.browser},this.connection.type===wa.Data&&(I=this.connection,g=xm(xm({},g),{label:I.label,reliable:I.reliable,serialization:I.serialization})),e.socket.send({type:eI.Offer,payload:g,dst:this.connection.peer}),[3,6];case 5:return o=a.sent(),o!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(e.emitError(Zi.WebRTC,o),Be.default.log("Failed to setLocalDescription, ",o)),[3,6];case 6:return[3,8];case 7:return s=a.sent(),e.emitError(Zi.WebRTC,s),Be.default.log("Failed to createOffer, ",s),[3,8];case 8:return[2]}})})},t.prototype._makeAnswer=function(){return qm(this,void 0,Promise,function(){var A,e,i,g,I;return Lm(this,function(o){switch(o.label){case 0:A=this.connection.peerConnection,e=this.connection.provider,o.label=1;case 1:return o.trys.push([1,7,,8]),[4,A.createAnswer()];case 2:i=o.sent(),Be.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,A.setLocalDescription(i)];case 4:return o.sent(),Be.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),e.socket.send({type:eI.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:Gt.browser},dst:this.connection.peer}),[3,6];case 5:return g=o.sent(),e.emitError(Zi.WebRTC,g),Be.default.log("Failed to setLocalDescription, ",g),[3,6];case 6:return[3,8];case 7:return I=o.sent(),e.emitError(Zi.WebRTC,I),Be.default.log("Failed to create answer, ",I),[3,8];case 8:return[2]}})})},t.prototype.handleSDP=function(A,e){return qm(this,void 0,Promise,function(){var i,g,I,o;return Lm(this,function(s){switch(s.label){case 0:e=new RTCSessionDescription(e),i=this.connection.peerConnection,g=this.connection.provider,Be.default.log("Setting remote description",e),I=this,s.label=1;case 1:return s.trys.push([1,5,,6]),[4,i.setRemoteDescription(e)];case 2:return s.sent(),Be.default.log("Set remoteDescription:".concat(A," for:").concat(this.connection.peer)),A!=="OFFER"?[3,4]:[4,I._makeAnswer()];case 3:s.sent(),s.label=4;case 4:return[3,6];case 5:return o=s.sent(),g.emitError(Zi.WebRTC,o),Be.default.log("Failed to setRemoteDescription, ",o),[3,6];case 6:return[2]}})})},t.prototype.handleCandidate=function(A){return qm(this,void 0,Promise,function(){var e,i,g,I,o,s;return Lm(this,function(a){switch(a.label){case 0:Be.default.log("handleCandidate:",A),e=A.candidate,i=A.sdpMLineIndex,g=A.sdpMid,I=this.connection.peerConnection,o=this.connection.provider,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,I.addIceCandidate(new RTCIceCandidate({sdpMid:g,sdpMLineIndex:i,candidate:e}))];case 2:return a.sent(),Be.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return s=a.sent(),o.emitError(Zi.WebRTC,s),Be.default.log("Failed to handleCandidate, ",s),[3,4];case 4:return[2]}})})},t.prototype._addTracksToConnection=function(A,e){if(Be.default.log("add tracks from stream ".concat(A.id," to peer connection")),!e.addTrack)return Be.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");A.getTracks().forEach(function(i){e.addTrack(i,A)})},t.prototype._addStreamToMediaConnection=function(A,e){Be.default.log("add stream ".concat(A.id," to media connection ").concat(e.connectionId)),e.addStream(A)},t}(),LK={};an(LK,"BaseConnection",()=>q3,t=>q3=t);var HQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),q3=function(t){HQA(A,t);function A(e,i,g){var I=t.call(this)||this;return I.peer=e,I.provider=i,I.options=g,I._open=!1,I.metadata=g.metadata,I}return Object.defineProperty(A.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),A}(fp.EventEmitter),OQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),_m=function(){return _m=Object.assign||function(t){for(var A,e=1,i=arguments.length;e<i;e++){A=arguments[e];for(var g in A)Object.prototype.hasOwnProperty.call(A,g)&&(t[g]=A[g])}return t},_m.apply(this,arguments)},PQA=function(t){var A=typeof Symbol=="function"&&Symbol.iterator,e=A&&t[A],i=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(A?"Object is not iterable.":"Symbol.iterator is not defined.")},L3=function(t){OQA(A,t);function A(e,i,g){var I=t.call(this,e,i,g)||this;return I._localStream=I.options._stream,I.connectionId=I.options.connectionId||A.ID_PREFIX+Gt.randomToken(),I._negotiator=new qK.Negotiator(I),I._localStream&&I._negotiator.startConnection({_stream:I._localStream,originator:!0}),I}return Object.defineProperty(A.prototype,"type",{get:function(){return wa.Media},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),A.prototype.addStream=function(e){Be.default.log("Receiving stream",e),this._remoteStream=e,t.prototype.emit.call(this,"stream",e)},A.prototype.handleMessage=function(e){var i=e.type,g=e.payload;switch(e.type){case eI.Answer:this._negotiator.handleSDP(i,g.sdp),this._open=!0;break;case eI.Candidate:this._negotiator.handleCandidate(g.candidate);break;default:Be.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},A.prototype.answer=function(e,i){var g,I;if(i===void 0&&(i={}),this._localStream){Be.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=e,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(_m(_m({},this.options._payload),{_stream:e}));var o=this.provider._getMessages(this.connectionId);try{for(var s=PQA(o),a=s.next();!a.done;a=s.next()){var n=a.value;this.handleMessage(n)}}catch(C){g={error:C}}finally{try{a&&!a.done&&(I=s.return)&&I.call(s)}finally{if(g)throw g.error}}this._open=!0},A.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,t.prototype.emit.call(this,"close"))},A.ID_PREFIX="mc_",A}(LK.BaseConnection),_K={};an(_K,"DataConnection",()=>Y3,t=>Y3=t);var _3={};an(_3,"EncodingQueue",()=>T3,t=>T3=t);var jQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),T3=function(t){jQA(A,t);function A(){var e=t.call(this)||this;return e.fileReader=new FileReader,e._queue=[],e._processing=!1,e.fileReader.onload=function(i){e._processing=!1,i.target&&e.emit("done",i.target.result),e.doNextTask()},e.fileReader.onerror=function(i){Be.default.error("EncodingQueue error:",i),e._processing=!1,e.destroy(),e.emit("error",i)},e}return Object.defineProperty(A.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),A.prototype.enque=function(e){this.queue.push(e),!this.processing&&this.doNextTask()},A.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},A.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},A}(fp.EventEmitter),WQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),ZQA=function(t){var A=typeof Symbol=="function"&&Symbol.iterator,e=A&&t[A],i=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(A?"Object is not iterable.":"Symbol.iterator is not defined.")},Y3=function(t){WQA(A,t);function A(e,i,g){var I=t.call(this,e,i,g)||this;return I.stringify=JSON.stringify,I.parse=JSON.parse,I._buffer=[],I._bufferSize=0,I._buffering=!1,I._chunkedData={},I._encodingQueue=new _3.EncodingQueue,I.connectionId=I.options.connectionId||A.ID_PREFIX+Gt.randomToken(),I.label=I.options.label||I.connectionId,I.serialization=I.options.serialization||kC.Binary,I.reliable=!!I.options.reliable,I._encodingQueue.on("done",function(o){I._bufferedSend(o)}),I._encodingQueue.on("error",function(){Be.default.error("DC#".concat(I.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),I.close()}),I._negotiator=new qK.Negotiator(I),I._negotiator.startConnection(I.options._payload||{originator:!0}),I}return Object.defineProperty(A.prototype,"type",{get:function(){return wa.Data},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),A.prototype.initialize=function(e){this._dc=e,this._configureDataChannel()},A.prototype._configureDataChannel=function(){var e=this;(!Gt.supports.binaryBlob||Gt.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){Be.default.log("DC#".concat(e.connectionId," dc connection success")),e._open=!0,e.emit("open")},this.dataChannel.onmessage=function(i){Be.default.log("DC#".concat(e.connectionId," dc onmessage:"),i.data),e._handleDataMessage(i)},this.dataChannel.onclose=function(){Be.default.log("DC#".concat(e.connectionId," dc closed for:"),e.peer),e.close()}},A.prototype._handleDataMessage=function(e){var i=this,g=e.data,I=g.constructor,o=this.serialization===kC.Binary||this.serialization===kC.BinaryUTF8,s=g;if(o){if(I===Blob){Gt.blobToArrayBuffer(g,function(n){var C=Gt.unpack(n);i.emit("data",C)});return}else if(I===ArrayBuffer)s=Gt.unpack(g);else if(I===String){var a=Gt.binaryStringToArrayBuffer(g);s=Gt.unpack(a)}}else this.serialization===kC.JSON&&(s=this.parse(g));if(s.__peerData){this._handleChunk(s);return}t.prototype.emit.call(this,"data",s)},A.prototype._handleChunk=function(e){var i=e.__peerData,g=this._chunkedData[i]||{data:[],count:0,total:e.total};if(g.data[e.n]=e.data,g.count++,this._chunkedData[i]=g,g.total===g.count){delete this._chunkedData[i];var I=new Blob(g.data);this._handleDataMessage({data:I})}},A.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,t.prototype.emit.call(this,"close"))},A.prototype.send=function(e,i){if(!this.open){t.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===kC.JSON)this._bufferedSend(this.stringify(e));else if(this.serialization===kC.Binary||this.serialization===kC.BinaryUTF8){var g=Gt.pack(e);if(!i&&g.size>Gt.chunkedMTU){this._sendChunks(g);return}Gt.supports.binaryBlob?this._bufferedSend(g):this._encodingQueue.enque(g)}else this._bufferedSend(e)},A.prototype._bufferedSend=function(e){(this._buffering||!this._trySend(e))&&(this._buffer.push(e),this._bufferSize=this._buffer.length)},A.prototype._trySend=function(e){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>A.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(e)}catch(g){return Be.default.error("DC#:".concat(this.connectionId," Error when sending:"),g),this._buffering=!0,this.close(),!1}return!0},A.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var e=this._buffer[0];this._trySend(e)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},A.prototype._sendChunks=function(e){var i,g,I=Gt.chunk(e);Be.default.log("DC#".concat(this.connectionId," Try to send ").concat(I.length," chunks..."));try{for(var o=ZQA(I),s=o.next();!s.done;s=o.next()){var a=s.value;this.send(a,!0)}}catch(n){i={error:n}}finally{try{s&&!s.done&&(g=o.return)&&g.call(o)}finally{if(i)throw i.error}}},A.prototype.handleMessage=function(e){var i=e.payload;switch(e.type){case eI.Answer:this._negotiator.handleSDP(e.type,i.sdp);break;case eI.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:Be.default.warn("Unrecognized message type:",e.type,"from peer:",this.peer);break}},A.ID_PREFIX="dc_",A.MAX_BUFFERED_AMOUNT=8388608,A}(LK.BaseConnection),H3={};an(H3,"API",()=>j3,t=>j3=t);var O3=function(t,A,e,i){function g(I){return I instanceof e?I:new e(function(o){o(I)})}return new(e||(e=Promise))(function(I,o){function s(C){try{n(i.next(C))}catch(r){o(r)}}function a(C){try{n(i.throw(C))}catch(r){o(r)}}function n(C){C.done?I(C.value):g(C.value).then(s,a)}n((i=i.apply(t,A||[])).next())})},P3=function(t,A){var e={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},i,g,I,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(n){return function(C){return a([n,C])}}function a(n){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,g&&(I=n[0]&2?g.return:n[0]?g.throw||((I=g.return)&&I.call(g),0):g.next)&&!(I=I.call(g,n[1])).done)return I;switch(g=0,I&&(n=[n[0]&2,I.value]),n[0]){case 0:case 1:I=n;break;case 4:return e.label++,{value:n[1],done:!1};case 5:e.label++,g=n[1],n=[0];continue;case 7:n=e.ops.pop(),e.trys.pop();continue;default:if(I=e.trys,!(I=I.length>0&&I[I.length-1])&&(n[0]===6||n[0]===2)){e=0;continue}if(n[0]===3&&(!I||n[1]>I[0]&&n[1]<I[3])){e.label=n[1];break}if(n[0]===6&&e.label<I[1]){e.label=I[1],I=n;break}if(I&&e.label<I[2]){e.label=I[2],e.ops.push(n);break}I[2]&&e.ops.pop(),e.trys.pop();continue}n=A.call(t,e)}catch(C){n=[6,C],g=0}finally{i=I=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},j3=function(){function t(A){this._options=A}return t.prototype._buildRequest=function(A){var e=this._options.secure?"https":"http",i=this._options,g=i.host,I=i.port,o=i.path,s=i.key,a=new URL("".concat(e,"://").concat(g,":").concat(I).concat(o).concat(s,"/").concat(A));return a.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),a.searchParams.set("version",JK.version),fetch(a.href,{referrerPolicy:this._options.referrerPolicy})},t.prototype.retrieveId=function(){return O3(this,void 0,Promise,function(){var A,e,i;return P3(this,function(g){switch(g.label){case 0:return g.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(A=g.sent(),A.status!==200)throw new Error("Error. Status:".concat(A.status));return[2,A.text()];case 2:throw e=g.sent(),Be.default.error("Error retrieving ID",e),i="",this._options.path==="/"&&this._options.host!==Gt.CLOUD_HOST&&(i=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+i);case 3:return[2]}})})},t.prototype.listAllPeers=function(){return O3(this,void 0,Promise,function(){var A,e,i;return P3(this,function(g){switch(g.label){case 0:return g.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(A=g.sent(),A.status!==200)throw A.status===401?(e="",this._options.host===Gt.CLOUD_HOST?e="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":e="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+e)):new Error("Error. Status:".concat(A.status));return[2,A.json()];case 2:throw i=g.sent(),Be.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},t}(),VQA=function(){var t=function(A,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,g){i.__proto__=g}||function(i,g){for(var I in g)Object.prototype.hasOwnProperty.call(g,I)&&(i[I]=g[I])},t(A,e)};return function(A,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(A,e);function i(){this.constructor=A}A.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),Gp=function(){return Gp=Object.assign||function(t){for(var A,e=1,i=arguments.length;e<i;e++){A=arguments[e];for(var g in A)Object.prototype.hasOwnProperty.call(A,g)&&(t[g]=A[g])}return t},Gp.apply(this,arguments)},Mp=function(t){var A=typeof Symbol=="function"&&Symbol.iterator,e=A&&t[A],i=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(A?"Object is not iterable.":"Symbol.iterator is not defined.")},zQA=function(t,A){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),g,I=[],o;try{for(;(A===void 0||A-- >0)&&!(g=i.next()).done;)I.push(g.value)}catch(s){o={error:s}}finally{try{g&&!g.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return I},TK=function(t){VQA(A,t);function A(e,i){var g=t.call(this)||this;g._id=null,g._lastServerId=null,g._destroyed=!1,g._disconnected=!1,g._open=!1,g._connections=new Map,g._lostMessages=new Map;var I;return e&&e.constructor==Object?i=e:e&&(I=e.toString()),i=Gp({debug:0,host:Gt.CLOUD_HOST,port:Gt.CLOUD_PORT,path:"/",key:A.DEFAULT_KEY,token:Gt.randomToken(),config:Gt.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),g._options=i,g._options.host==="/"&&(g._options.host=window.location.hostname),g._options.path&&(g._options.path[0]!=="/"&&(g._options.path="/"+g._options.path),g._options.path[g._options.path.length-1]!=="/"&&(g._options.path+="/")),g._options.secure===void 0&&g._options.host!==Gt.CLOUD_HOST?g._options.secure=Gt.isSecure():g._options.host==Gt.CLOUD_HOST&&(g._options.secure=!0),g._options.logFunction&&Be.default.setLogFunction(g._options.logFunction),Be.default.logLevel=g._options.debug||0,g._api=new H3.API(i),g._socket=g._createServerConnection(),!Gt.supports.audioVideo&&!Gt.supports.data?(g._delayedAbort(Zi.BrowserIncompatible,"The current browser does not support WebRTC"),g):I&&!Gt.validateId(I)?(g._delayedAbort(Zi.InvalidID,'ID "'.concat(I,'" is invalid')),g):(I?g._initialize(I):g._api.retrieveId().then(function(o){return g._initialize(o)}).catch(function(o){return g._abort(Zi.ServerError,o)}),g)}return Object.defineProperty(A.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"connections",{get:function(){var e,i,g=Object.create(null);try{for(var I=Mp(this._connections),o=I.next();!o.done;o=I.next()){var s=zQA(o.value,2),a=s[0],n=s[1];g[a]=n}}catch(C){e={error:C}}finally{try{o&&!o.done&&(i=I.return)&&i.call(I)}finally{if(e)throw e.error}}return g},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),A.prototype._createServerConnection=function(){var e=this,i=new v3.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(GC.Message,function(g){e._handleMessage(g)}),i.on(GC.Error,function(g){e._abort(Zi.SocketError,g)}),i.on(GC.Disconnected,function(){e.disconnected||(e.emitError(Zi.Network,"Lost connection to server."),e.disconnect())}),i.on(GC.Close,function(){e.disconnected||e._abort(Zi.SocketClosed,"Underlying socket is already closed.")}),i},A.prototype._initialize=function(e){this._id=e,this.socket.start(e,this._options.token)},A.prototype._handleMessage=function(e){var i,g,I=e.type,o=e.payload,s=e.src;switch(I){case eI.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case eI.Error:this._abort(Zi.ServerError,o.msg);break;case eI.IdTaken:this._abort(Zi.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case eI.InvalidKey:this._abort(Zi.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case eI.Leave:Be.default.log("Received leave message from ".concat(s)),this._cleanupPeer(s),this._connections.delete(s);break;case eI.Expire:this.emitError(Zi.PeerUnavailable,"Could not connect to peer ".concat(s));break;case eI.Offer:var h=o.connectionId,l=this.getConnection(s,h);if(l&&(l.close(),Be.default.warn("Offer received for existing Connection ID:".concat(h))),o.type===wa.Media){var a=new xK.MediaConnection(s,this,{connectionId:h,_payload:o,metadata:o.metadata});l=a,this._addConnection(s,l),this.emit("call",a)}else if(o.type===wa.Data){var n=new _K.DataConnection(s,this,{connectionId:h,_payload:o,metadata:o.metadata,label:o.label,serialization:o.serialization,reliable:o.reliable});l=n,this._addConnection(s,l),this.emit("connection",n)}else{Be.default.warn("Received malformed connection type:".concat(o.type));return}var C=this._getMessages(h);try{for(var r=Mp(C),Q=r.next();!Q.done;Q=r.next()){var E=Q.value;l.handleMessage(E)}}catch(d){i={error:d}}finally{try{Q&&!Q.done&&(g=r.return)&&g.call(r)}finally{if(i)throw i.error}}break;default:if(!o){Be.default.warn("You received a malformed message from ".concat(s," of type ").concat(I));return}var h=o.connectionId,l=this.getConnection(s,h);l&&l.peerConnection?l.handleMessage(e):h?this._storeMessage(h,e):Be.default.warn("You received an unrecognized message:",e);break}},A.prototype._storeMessage=function(e,i){this._lostMessages.has(e)||this._lostMessages.set(e,[]),this._lostMessages.get(e).push(i)},A.prototype._getMessages=function(e){var i=this._lostMessages.get(e);return i?(this._lostMessages.delete(e),i):[]},A.prototype.connect=function(e,i){if(i===void 0&&(i={}),this.disconnected){Be.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(Zi.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var g=new _K.DataConnection(e,this,i);return this._addConnection(e,g),g},A.prototype.call=function(e,i,g){if(g===void 0&&(g={}),this.disconnected){Be.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(Zi.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){Be.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var I=new xK.MediaConnection(e,this,Gp(Gp({},g),{_stream:i}));return this._addConnection(e,I),I},A.prototype._addConnection=function(e,i){Be.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(e)),this._connections.has(e)||this._connections.set(e,[]),this._connections.get(e).push(i)},A.prototype._removeConnection=function(e){var i=this._connections.get(e.peer);if(i){var g=i.indexOf(e);g!==-1&&i.splice(g,1)}this._lostMessages.delete(e.connectionId)},A.prototype.getConnection=function(e,i){var g,I,o=this._connections.get(e);if(!o)return null;try{for(var s=Mp(o),a=s.next();!a.done;a=s.next()){var n=a.value;if(n.connectionId===i)return n}}catch(C){g={error:C}}finally{try{a&&!a.done&&(I=s.return)&&I.call(s)}finally{if(g)throw g.error}}return null},A.prototype._delayedAbort=function(e,i){var g=this;setTimeout(function(){g._abort(e,i)},0)},A.prototype._abort=function(e,i){Be.default.error("Aborting!"),this.emitError(e,i),this._lastServerId?this.disconnect():this.destroy()},A.prototype.emitError=function(e,i){Be.default.error("Error:",i);var g;typeof i=="string"?g=new Error(i):g=i,g.type=e,this.emit("error",g)},A.prototype.destroy=function(){this.destroyed||(Be.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},A.prototype._cleanup=function(){var e,i;try{for(var g=Mp(this._connections.keys()),I=g.next();!I.done;I=g.next()){var o=I.value;this._cleanupPeer(o),this._connections.delete(o)}}catch(s){e={error:s}}finally{try{I&&!I.done&&(i=g.return)&&i.call(g)}finally{if(e)throw e.error}}this.socket.removeAllListeners()},A.prototype._cleanupPeer=function(e){var i,g,I=this._connections.get(e);if(I)try{for(var o=Mp(I),s=o.next();!s.done;s=o.next()){var a=s.value;a.close()}}catch(n){i={error:n}}finally{try{s&&!s.done&&(g=o.return)&&g.call(o)}finally{if(i)throw i.error}}},A.prototype.disconnect=function(){if(!this.disconnected){var e=this.id;Be.default.log("Disconnect peer with ID:".concat(e)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=e,this._id=null,this.emit("disconnected",e)}},A.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)Be.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)Be.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},A.prototype.listAllPeers=function(e){var i=this;e===void 0&&(e=function(g){}),this._api.listAllPeers().then(function(g){return e(g)}).catch(function(g){return i._abort(Zi.ServerError,g)})},A.DEFAULT_KEY="peerjs",A}(fp.EventEmitter),YK=N3.Peer;const XQA=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return TK},default:YK,util:Gt},Symbol.toStringTag,{value:"Module"}));let HK;function $QA(){return HK}function AEA(t){HK=t}function W3(t,A){return A||(A={}),A={...HK,...A},t?new YK(t,A):new YK(A)}async function Z3(){const t=await Promise.resolve().then(()=>XQA);return console.log(t),t.default===void 0?t:t.default}class V3{constructor(){B(this,"_host"),B(this,"_client"),B(this,"_clientData"),this.onEnable()}get isHost(){return this._host!==void 0}onEnable(){const A="HOST-5980e65c-8438-453e-8b35-f13c736dcd81";this.trySetupHost(A)}async trySetupHost(A){const e=await Z3(),i=new e(A);i.on("error",g=>{console.error(g),this._host=void 0,this.trySetupClient(A)}),i.on("open",g=>{this._host=new tEA(i)})}async trySetupClient(A){const e=await Z3();this._client=new e,this._client.on("error",i=>{console.error("Client error",i)}),this._client.on("open",i=>{console.log("client connected",i),this._clientData=this._client.connect(A,{metadata:{id:i}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",g=>{console.log("<<",g)})})}}class eEA{constructor(A){B(this,"_peer"),this._peer=A}}class tEA extends eEA{constructor(A){var e;super(A),B(this,"_connections",[]),console.log("I AM THE HOST"),(e=this._peer)==null||e.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}get isHost(){return!0}onConnection(A){console.log("host connection",A),A.on("open",()=>{this._connections.push(A),this.broadcastConnection(A)})}broadcastConnection(A){const e=this._connections.map(i=>{var g;return(g=i.metadata)==null?void 0:g.id}).filter(i=>i!==void 0);this.broadcast({type:"connection-list",connections:e})}broadcast(A){if(A!=null){console.log(">>",A);for(const e in this._peer.connections){const i=this._peer.connections[e];if(i)if(Array.isArray(i))for(const g of i)g&&g.send(A);else console.warn(i)}}}}const z3="https://urls.needle.tools/default-networking-backend/index";let IB="wss://needle-tiny-starter.glitch.me/socket";const oo=!!tA("debugnet"),Rp=!!(oo||tA("debugowner")),X3=tA("debugnetbin");var $3=(t=>(t.ConnectionInfo="connection-start-info",t))($3||{}),gt=(t=>(t.Join="join-room",t.Leave="leave-room",t.JoinedRoom="joined-room",t.LeftRoom="left-room",t.UserJoinedRoom="user-joined-room",t.UserLeftRoom="user-left-room",t.RoomStateSent="room-state-sent",t))(gt||{});class iEA{constructor(){B(this,"room"),B(this,"viewId"),B(this,"allowEditing"),B(this,"inRoom")}}class gEA{constructor(){B(this,"room")}}class IEA{constructor(){B(this,"userId")}}var Aj=(t=>(t.RequestHasOwner="request-has-owner",t.ResponseHasOwner="response-has-owner",t.RequestIsOwner="request-is-owner",t.ResponseIsOwner="response-is-owner",t.RequestOwnership="request-ownership",t.GainedOwnership="gained-ownership",t.RemoveOwnership="remove-ownership",t.LostOwnership="lost-ownership",t.GainedOwnershipBroadcast="gained-ownership-broadcast",t.LostOwnershipBroadcast="lost-ownership-broadcast",t))(Aj||{});class OK{constructor(A,e){B(this,"guid"),B(this,"connection"),B(this,"_hasOwnership",!1),B(this,"_isOwned"),B(this,"_gainSubscription"),B(this,"_lostSubscription"),B(this,"_hasOwnerResponse"),B(this,"_isWaitingForOwnershipResponseCallback",null),this.connection=A,this.guid=e,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),A.beginListen("lost-ownership",this._lostSubscription),A.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),A.beginListen("response-has-owner",this._hasOwnerResponse)}get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(A){A.guid===this.guid&&(this._isOwned=A.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(A){A.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=A.value,A.value||(Rp&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((A,e)=>{this.requestOwnership();let i=0;const g=()=>{if(i++>10)return e("Timeout");setTimeout(()=>{this.hasOwnership?A(this):g()},100)};g()})}requestOwnership(){return Rp&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(A){A.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===A.owner?(Rp&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(A){A===this.guid&&(Rp&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class ej{constructor(A){B(this,"context"),B(this,"_peer",null),B(this,"_usersInRoomCopy",[]),B(this,"_defaultMessagesBuffer",[]),B(this,"_defaultMessagesBufferArray",[]),B(this,"netWebSocketUrlProvider"),B(this,"_listeners",{}),B(this,"_listenersBinary",{}),B(this,"connected",!1),B(this,"channelId"),B(this,"_connectionId",null),B(this,"_ws"),B(this,"_waitingForSocket",{}),B(this,"_isInRoom",!1),B(this,"_currentRoomName",null),B(this,"_currentRoomViewId",null),B(this,"_currentRoomAllowEditing",!0),B(this,"_currentInRoom",[]),B(this,"_state",{}),B(this,"_currentDelay",-1),B(this,"_connectingToWebsocketPromise",null),this.context=A}get peer(){return this._peer||(this._peer=new V3),this._peer}tryGetState(A){return A==="invalid"?null:this._state[A]}get connectionId(){return this._connectionId}get isDebugEnabled(){return oo}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const A=new URL(window.location.href);return A.searchParams.set("view",this.currentRoomViewId),A.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){var A;return((A=this._ws)==null?void 0:A.url)??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(A){return this._currentInRoom.indexOf(A)!==-1}usersInRoom(A=null){A||(A=this._usersInRoomCopy),A.length=0;for(const e of this._currentInRoom)A.push(e);return A}joinRoom(A,e=!1){return A?A.length>1024?(console.error('Room name too long, can not join: "'+A+'". Max length is 1024 characters.'),!1):(this.connect(),oo&&console.log("join: "+A),this.send("join-room",{room:A,viewOnly:e},Ms.OnConnection),!0):(console.error('Missing room name, can not join: "'+A+'"'),!1)}leaveRoom(A=null){return A||(A=this.currentRoomName),A?(this.send("leave-room",{room:A}),!0):(console.error('Missing room name, can not join: "'+A+'"'),!1)}send(A,e=null,i=Ms.Queued){if(e===null&&(e={}),i===Ms.Queued){this._defaultMessagesBuffer.push({key:A,value:e});return}return this.sendWithWebsocket(A,e,i)}sendDeleteRemoteState(A){this.send("delete-state",{guid:A,dontSave:!0}),delete this._state[A]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(A){var e;X3&&console.log("<< send binary",this.context.time.frame,A.length/1024+" KB"),(e=this._ws)==null||e.send(A)}sendBufferedMessagesNow(){var A;if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const e=Object.keys(this._defaultMessagesBuffer).length;for(const g in this._defaultMessagesBuffer){const I=this._defaultMessagesBuffer[g];if(e<=1){this.sendWithWebsocket(I.key,I.value,Ms.Immediate);break}const o=this.toMessage(I.key,I.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&oo&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const i=JSON.stringify(this._defaultMessagesBufferArray);(A=this._ws)==null||A.send(i)}beginListen(A,e){return this._listeners[A]||(this._listeners[A]=[]),this._listeners[A].push(e),e}stopListening(A,e){return this.stopListen(A,e)}stopListen(A,e){if(!e||!this._listeners[A])return;const i=this._listeners[A].indexOf(e);i>=0&&this._listeners[A].splice(i,1)}beginListenBinary(A,e){return this._listenersBinary[A]||(this._listenersBinary[A]=[]),this._listenersBinary[A].push(e),e}stopListenBinary(A,e){if(!this._listenersBinary[A])return;const i=this._listenersBinary[A].indexOf(e);i>=0&&this._listenersBinary[A].splice(i,1)}registerProvider(A){this.netWebSocketUrlProvider=A}async connect(){var A;if(this.connected)return Promise.resolve(!0);oo&&console.log("connecting");const e=(A=this.netWebSocketUrlProvider)==null?void 0:A.getWebsocketUrl();return e?IB=e:QY()&&(IB="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){var A;(A=this._ws)==null||A.close(),this._ws=void 0}connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(A,e)=>{var i;let g=!1;const I=n=>{g||(g=!0,A(n))};if(IB===void 0&&(console.log("Fetch default backend url: "+z3),IB=await(await fetch(z3)).text()),IB===void 0){I(!1);return}console.log(`\u22A1 Connecting to networking backend on
|
|
5235
5235
|
`+IB);const o=await Promise.resolve().then(()=>S0A),s=((i=o.default)==null?void 0:i.WebsocketBuilder)??o.WebsocketBuilder,a=new s(IB).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=a,this.connected=!0,console.log(`\u229E Connected to networking backend
|
|
5236
5236
|
`+IB),I(!0),this.onSendQueued(Ms.OnConnection)}).onClose(n=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,I(!1)}).onError((n,C)=>{console.error("\u22A0 Websocket error",n,C),I(!1)}).onRetry(()=>{console.log("Retry connecting to networking websocket")}).build();a.addEventListener(o.WebsocketEvent.message,(n,C)=>{this.onMessage(n,C)})})}onMessage(A,e){const i=e.data;try{if(typeof i!="string"){i.size&&this.handleIncomingBinaryMessage(i);return}const g=JSON.parse(i);if(Array.isArray(g))for(const I of g)this.handleIncomingStringMessage(I);else this.handleIncomingStringMessage(g);return}catch(g){oo&&i==="pong"?console.log("<<",i):oe()&&console.error("Failed to parse message",g)}}async handleIncomingBinaryMessage(A){X3&&console.log("<< bin",this.context.time.frame);const e=await A.arrayBuffer();var i=new Uint8Array(e);const g=new Jw(i),I=g.getBufferIdentifier(),o=this._listenersBinary[I],s=b4(g),a=K4(s);if(a&&typeof a=="string"&&(this._state[a]=s),!o)return;const n=s??g;for(const C of o)C(n)}handleIncomingStringMessage(A){var e,i;if(oo&&console.log("<<",A.key??A),A.key)switch(A.key){case"connection-start-info":if(A.data){const s=A.data;s&&(console.assert(s.id!==void 0&&s.id!==null&&s.id.length>0,"server did not send connection id",s.id),console.log("Your id is: "+s.id,this.context.alias??""),this._connectionId=s.id)}else console.warn("Expected connection id in "+A.key);break;case"joined-room":if(oo&&console.log(A),A){this._isInRoom=!0;const s=A;this._currentRoomName=s.room,this._currentRoomViewId=s.viewId,this._currentRoomAllowEditing=s.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...s.inRoom),oo&&console.log("joined room with",this._currentInRoom,this.context.alias??"");const a=new URL(window.location.href);a.searchParams.has("room")&&a.searchParams.delete("room"),a.searchParams.set("view",this._currentRoomViewId),console.log("Room view id: "+this._currentRoomViewId+`
|
|
5237
|
-
`+a.href)}this.onSendQueued(Ms.OnRoomJoin);break;case"left-room":A.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(A.data){const s=A.data;this._currentInRoom.push(s.userId),oo&&console.log(s.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(A.data){const s=A.data,a=this._currentInRoom.indexOf(s.userId);a>=0&&(oo&&console.log(s.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(a,1)),s.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":oo&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const o=(e=A.data)==null?void 0:e.time;o&&(this._currentDelay=this.context.time.time-o),oo&&console.log("Current latency: "+this._currentDelay.toFixed(1)+" sec","Clients in room: "+((i=this._currentInRoom)==null?void 0:i.length));break}let g=this._listeners[A.key];if(g){g=[...g];for(const o of g)try{o(A.data)}catch(s){console.error('Error invoking callback for "'+A.key+'"',s)}}const I=A.data;I&&(this._state[I.guid]=I)}toMessage(A,e){return{key:A,data:e}}sendWithWebsocket(A,e,i=Ms.OnRoomJoin){if(!this._ws){const I=this._waitingForSocket[i]||[];I.push(()=>this.sendWithWebsocket(A,e,i)),this._waitingForSocket[i]=I;return}const g=JSON.stringify(this.toMessage(A,e));oo&&console.log(">>",A),this._ws.send(g)}onSendQueued(A){const e=this._waitingForSocket[A];if(e){for(const i of e)i();e.length=0}}}const Up=tA("debugwebxr");class PK{constructor(A,e){B(this,"controllerStates",[]),B(this,"userId"),B(this,"context"),B(this,"userStateEvtName"),B(this,"onReceivedControllerState",i=>{Up&&console.log(`XRSync: Received change for ${this.userId}: ${i.type} ${i.handedness}; tracked=${i.isTracking}`);let g=!1;for(let I=0;I<this.controllerStates.length;I++)if(this.controllerStates[I].index===i.index){this.controllerStates[I]=i,g=!0;break}g||this.controllerStates.push(i)}),this.userId=A,this.context=e,this.userStateEvtName="xr-sync-user-state-"+A,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(A){if(this.context.connection.isConnected!=!1){for(let e=this.controllerStates.length-1;e>=0;e--){const i=this.controllerStates[e];let g=!1;for(let I=0;I<A.controllers.length;I++)A.controllers[I].index===i.index&&(g=!0);g||(Up&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(e,1),this.sendControllerRemoved(i))}for(const e of A.controllers)this.updateControllerStates(e)}}onExitXR(A){for(const e of this.controllerStates)this.sendControllerRemoved(e);this.controllerStates.length=0}sendControllerRemoved(A){A.isTracking=!1,A.guid="",this.context.connection.send(this.userStateEvtName,A),this.context.connection.sendDeleteRemoteState(A.guid)}updateControllerStates(A){const e=this.controllerStates.find(i=>i.index===A.index);if(e){let i=!1;i||(i=e.isTracking!=A.isTracking),i&&(e.isTracking=A.isTracking,this.context.connection.send(this.userStateEvtName,e))}else{const i={guid:this.userId+"-"+A.index,isTracking:A.isTracking,handedness:A.side,index:A.index,type:A.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),Up&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class tj{constructor(A){B(this,"context"),B(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(Up&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new PK(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new PK(e,this.context))}}),B(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const e=this._states.get(this.context.connection.connectionId);e?.dispose(),this._states.delete(this.context.connection.connectionId)}}),B(this,"onOtherUserJoinedRoom",e=>{const i=e.userId;this._states.has(i)||(Up&&console.log("XRSync: Remote user joined room",i),this._states.set(i,new PK(i,this.context)))}),B(this,"onOtherUserLeftRoom",e=>{const i=e.userId;if(!this._states.has(i)){const g=this._states.get(i);g?.dispose(),this._states.delete(i)}}),B(this,"_states",new Map),this.context=A,this.context.connection.beginListen(gt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(gt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(gt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(gt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(A){return A?this._states.has(A):!1}isTracking(A,e){if(!A)return;const i=this._states.get(A);if(!i)return;const g=i.controllerStates.find(I=>I.handedness===e);return g?.isTracking||!1}getDeviceType(A,e){if(!A)return;const i=this._states.get(A);if(!i)return;const g=i.controllerStates.find(I=>I.handedness===e);return g?.type||"unknown"}destroy(){this.context.connection.stopListen(gt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(gt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(gt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(gt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e?.update(A)}}onExitXR(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e?.onExitXR(A)}}}class ij{constructor(){B(this,"_fadeToColorQuad"),B(this,"_fadeToColorMaterial"),B(this,"_requestedFadeValue",0),B(this,"_transitionPromise",null),B(this,"_transitionResolve",null),this._fadeToColorMaterial=new At({color:0,transparent:!0,depthTest:!1,fog:!1,side:pt}),this._fadeToColorQuad=new lA(new Qg(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(A,e){const i=this._fadeToColorQuad,g=this._fadeToColorMaterial;i.parent!==A&&g.opacity>0?A.add(i):g.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const I=this._requestedFadeValue;g.opacity=ee.lerp(g.opacity,I,e/.03),Math.abs(g.opacity-I)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const A=new Promise(e=>{this._transitionResolve=e});return this._transitionPromise=A,A}}var aE=(t=>(t[t.Quad=0]="Quad",t[t.Cube=1]="Cube",t[t.Sphere=2]="Sphere",t))(aE||{});class Fp{static createPrimitive(A,e){let i;switch(A){case"Quad":case 0:{const g=new Qg(1,1,1,1),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break;case"Cube":case 1:{const g=new zt(1,1,1),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break;case"Sphere":case 2:{const g=new ba(.5,16,16),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break}return this.applyDefaultObjectOptions(i,e),i}static createSprite(A){const e=new Py({color:16777215});A!=null&&A.texture&&"map"in e&&(e.map=A.texture);const i=new fR(e);return this.applyDefaultObjectOptions(i,A),i}static applyDefaultObjectOptions(A,e){e!=null&&e.name&&(A.name=e.name),e!=null&&e.position&&A.position.set(e.position.x,e.position.y,e.position.z),e!=null&&e.rotation&&A.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e!=null&&e.scale&&A.scale.set(e.scale.x,e.scale.y,e.scale.z)}}const gj=class{constructor(t,A,e){B(this,"_session"),B(this,"_mode"),B(this,"_init"),B(this,"_renderer"),B(this,"_camera"),B(this,"_scene"),B(this,"onEnd",()=>{var i;(i=this._session)==null||i.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),B(this,"_lastTime",0),B(this,"onFrame",(i,g)=>{const I=i-this._lastTime;this.update(i,I),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),B(this,"_objects",[]),this._mode=t,this._init=A,this._session=e,this._session.addEventListener("end",this.onEnd),this._renderer=new eC({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(e),this._renderer.xr.enabled=!0,this._camera=new Ne,this._scene=new Zg,this._scene.fog=new Oy(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(t,A){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!A)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const e=await navigator.xr.requestSession(t,A);return e.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new gj(t,A,e),this._active):(e.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await Wa(100)),this._active=null}get isAR(){return this._mode==="immersive-ar"}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const t={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,t}async onBeforeHandoff(){await Wa(1e3),this._scene.clear()}setupScene(){this._scene.background=new fA(0),this._scene.add(new G0(5,10,1118481,1118481));const t=new uQ(16777215,1);t.position.set(0,20,0),t.castShadow=!1,this._scene.add(t);const A=new uQ(16777215,1);A.position.set(0,-1,0),A.castShadow=!1,this._scene.add(A);const e=new dQ(16777215,1,100,1);e.position.set(0,2,0),e.castShadow=!1,e.distance=200,this._scene.add(e);const i=50;for(let g=0;g<100;g++){const I=new yI({color:2236962,metalness:1,roughness:.8});this.isAR&&(I.emissive=new fA(Math.random(),Math.random(),Math.random()),I.emissiveIntensity=Math.random());const o=ee.random(0,1)>.5?aE.Sphere:aE.Cube,s=Fp.createPrimitive(o,{material:I});s.position.x=ee.random(-i,i),s.position.y=ee.random(-2,i),s.position.z=ee.random(-i,i),s.rotation.x=ee.random(0,Math.PI*2),s.rotation.y=ee.random(0,Math.PI*2),s.rotation.z=ee.random(0,Math.PI*2),s.scale.multiplyScalar(.5+Math.random()*10);const a=s.position.distanceTo(this._camera.position)-s.scale.x;a<1&&s.position.multiplyScalar(1+1/a),this._objects.push(s),this._scene.add(s)}}update(t,A){const e=t*4e-4;for(let i=0;i<this._objects.length;i++){const g=this._objects[i];g.position.y+=Math.sin(e+i*.5)*.005,g.rotateY(.002)}}};let jc=gj;B(jc,"_active",null),B(jc,"_requestInFlight",!1);const Kg=tA("debugwebxr"),oEA=tA("stats");function sEA(t){let A=null;const e=t;return e.getAROverlayContainer?A=e.getAROverlayContainer():A=t,A}aEA();async function aEA(){var t;if(tA("debugasap")){let A=globalThis["needle:XRSession"];if(A instanceof Promise){delete globalThis["needle:XRSession"],Ct.addContextCreatedCallback(async e=>{if(!A)return;Xh(!0);const i=await A;if(i){const g=ye.getDefaultSessionInit("immersive-vr");ye.setSession("immersive-vr",i,g,e.context)}else console.error("NeedleXRSession: ASAP session was rejected");A=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(t=navigator.xr)==null||t.addEventListener("sessiongranted",async()=>{Xh(!0),console.log("Received Session Granted..."),await Wa(100);const A=sessionStorage.getItem("needle_xr_session_mode"),e=sessionStorage.getItem("needle_xr_session_init")??null,i=e?JSON.parse(e):null;let g=null;if(Ij()&&(await jc.start(A||"immersive-vr",i||ye.getDefaultSessionInit("immersive-vr")),await rEA(),g=await jc.handoff()),g)ye.setSession(g.mode,g.session,g.init,Ke.Current);else if(A&&e){console.log("Session Granted: Restore last session");const I=JSON.parse(e);ye.start(A,I).catch(o=>console.warn(o))}else ye.start("immersive-vr").catch(I=>console.warn("Session Granted failed:",I))},{once:!0})}}function nEA(t,A){sessionStorage.setItem("needle_xr_session_mode",t),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(A))}function CEA(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const jK=new Set;Ct.registerCallback(kt.ContextCreationStart,async t=>{jK.add(t.context)}),Ct.registerCallback(kt.ContextCreated,async t=>{jK.delete(t.context)});function Ij(){return jK.size>0}function rEA(){return new Promise(t=>{const A=Date.now(),e=setInterval(()=>{(!Ij()||Date.now()-A>6e4)&&(clearInterval(e),t())},100)})}fQ()&&oe()&&window.addEventListener("keydown",t=>{(t.key==="x"||t.key==="Escape")&&ye.active&&ye.stop()});const oB=class{constructor(t,A,e,i){B(this,"context"),B(this,"session"),B(this,"mode"),B(this,"controllers",[]),B(this,"_rigScale",1),B(this,"_lastRigScaleUpdate",-1),B(this,"_rigs",[]),B(this,"_viewerHitTestSource",null),B(this,"_defaultRig"),B(this,"_xr_scripts"),B(this,"_xr_update_scripts",[]),B(this,"_inactive_scripts",[]),B(this,"_controllerAdded"),B(this,"_controllerRemoved"),B(this,"_originalCameraWorldPosition"),B(this,"_originalCameraWorldRotation"),B(this,"_originalCameraWorldScale"),B(this,"_originalCameraParent"),B(this,"_mainCamera",null),B(this,"onRendererSessionSet",()=>{var o;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(o=this.context.mainCameraComponent)==null||o.applyClearFlags())}),B(this,"onInputSourceAdded",o=>{if(o.targetRayMode==="screen")return;let s=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===o){s=n;break}if(this.controllers.find(n=>n.inputSource===o)){console.warn("Controller already exists for input source",s);return}Kg&&console.log("Adding controller",s);const a=new DK(this,o,s);this._newControllers.push(a)}),B(this,"_ended",!1),B(this,"_newControllers",[]),B(this,"onEnd",o=>{var s,a,n;if(this._ended)return;this._ended=!0,Kg&&console.log("XR Session ended"),CEA(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,iB(this.onBefore,Zt.LateUpdate);const C=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);C>=0&&this.context.pre_render_callbacks.splice(C,1);const r=this.context.post_render_callbacks.indexOf(this.onAfterRender);r>=0&&this.context.post_render_callbacks.splice(r,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var Q;(Q=this.context.mainCameraComponent)==null||Q.applyClearFlags()}),m4({session:this});for(const Q of oB._xrEndListeners)Q({xr:this});for(let Q=0;Q<this.controllers.length;Q++)this.disconnectInputSource(this.controllers[Q].inputSource);for(const Q of this._xr_scripts)(s=Q?.onLeaveXR)==null||s.call(Q,{xr:this});(a=this.sync)==null||a.onExitXR(this),this.context.mainCamera&&((n=this._originalCameraParent)==null||n.add(this.context.mainCamera),this._originalCameraWorldPosition&&SI(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&cs(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&cu(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),Xh(!1)}),B(this,"_didStart",!1),B(this,"onBefore",o=>{var s,a,n,C,r,Q,E,h;const l=o.xrFrame;if(!l)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((s=this.rig)==null?void 0:s.isActive)==!1&&(Kg&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(a=this._mainCamera)!=null&&a.gameObject&&((C=(n=this._mainCamera)==null?void 0:n.gameObject)==null?void 0:C.parent)!==this.rig.gameObject&&this.rig.gameObject.add((r=this._mainCamera)==null?void 0:r.gameObject),this.internalUpdateState(),this.applyCustomForward();const d={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const c=[...this.context.new_scripts_xr];for(let u=0;u<c.length;u++){const p=this.context.new_scripts_xr[u];if(!p||p.destroyed||((Q=p.supportsXR)==null?void 0:Q.call(p,this.mode))==!1){this.context.new_scripts_xr.splice(u,1);continue}if(!p.activeAndEnabled){this.context.new_scripts_xr.splice(u,1),this.markInactive(p);continue}if(this.addScript(p)){this.invokeCallback_EnterXR(p);for(const D of this.controllers)this.invokeCallback_ControllerAdded(p,D)}}}}else{this._didStart=!0,S4({session:this});for(const u of oB._xrStartListeners)u(d);const c=[...this._xr_scripts];Kg&&console.log("NeedleXRSession start, handle scripts:",c);for(const u of c){if(u.destroyed){this._script_to_remove.push(u);continue}if(!u.activeAndEnabled){this.markInactive(u);continue}this.invokeCallback_EnterXR(u);for(const p of this.controllers)this.invokeCallback_ControllerAdded(u,p)}}this.syncCameraCullingMask();for(const c of this.controllers)c.onUpdate(l);if(this._newControllers.length>0){const c=[...this._newControllers];this._newControllers.length=0;for(const u of c)if(u.connected){this.controllers.push(u);for(const p of this._xr_scripts){if(p.destroyed){this._script_to_remove.push(p);continue}p.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(p,u)}}this.controllers.sort((u,p)=>u.index-p.index)}for(const c of this._xr_update_scripts){if(c.destroyed===!0){this._script_to_remove.push(c);continue}if(c.activeAndEnabled===!1){this.markInactive(c);continue}c.onUpdateXR&&c.onUpdateXR(d)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const c=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const u of c)!u.destroyed&&this.running&&((E=u.onLeaveXR)==null||E.call(u,d)),this.removeScript(u)}(h=this.sync)==null||h.onUpdate(this),this.onRenderDebug()}),B(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),B(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),fQ()){const o=this.context.renderer;if(o.xr.isPresenting&&this.context.mainCamera){const s=o.xr.enabled,a=o.getRenderTarget();o.xr.enabled=!1,o.setRenderTarget(null),o.render(this.context.scene,this.context.mainCamera),o.xr.enabled=s,o.setRenderTarget(a)}}}),B(this,"_script_to_remove",[]),B(this,"_camera"),B(this,"_cameraRenderParent",new wA().rotateY(Math.PI)),B(this,"_previousCameraParent"),B(this,"_customforward",!0),B(this,"originalCameraNearPlane"),B(this,"_viewerPose"),B(this,"_transformOrientation",new GA),B(this,"_transformPosition",new f),B(this,"_transition");var g,I;nEA(t,i.init),this.session=A,this.mode=t,this.context=e,(Kg||tA("console"))&&Xh(!0),this._xr_scripts=[...i.scripts],this._xr_update_scripts=this._xr_scripts.filter(o=>typeof o.onUpdateXR=="function"),this._controllerAdded=i.controller_added,this._controllerRemoved=i.controller_removed,tB(this.onBefore,Zt.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((g=i.init.optionalFeatures)!=null&&g.includes("hit-test")||(I=i.init.requiredFeatures)!=null&&I.includes("hit-test"))&&A.requestReferenceSpace("viewer").then(o=>{var s,a;return(a=(s=A.requestHitTestSource)==null?void 0:s.call(A,{space:o}))==null?void 0:a.then(n=>this._viewerHitTestSource=n)}).catch(o=>console.warn(o)),this.context.mainCamera&&(this._originalCameraWorldPosition=xe(this.context.mainCamera,new f),this._originalCameraWorldRotation=Kt(this.context.mainCamera,new GA),this._originalCameraWorldScale=ei(this.context.mainCamera,new f),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new EQA,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let o=0;o<A.inputSources.length;o++){const s=A.inputSources[o];if(!s.handedness){console.warn("Input source in xr session has no handedness - ignoring",o);continue}this.onInputSourceAdded(s)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",o=>{for(const s of o.removed)this.disconnectInputSource(s);for(const s of o.added)this.onInputSourceAdded(s)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(t){return this._sync||(this._sync=new tj(t)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var t;return((t=this._activeSession)==null?void 0:t.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(t=>t.some(A=>A)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(t){var A;return((A=this.xrSystem)==null?void 0:A.isSessionSupported(t).catch(e=>(Kg&&console.error(e),!1)))??Promise.resolve(!1)}static onSessionRequestStart(t){this._sessionRequestStartListeners.push(t)}static offSessionRequestStart(t){const A=this._sessionRequestStartListeners.indexOf(t);A>=0&&this._sessionRequestStartListeners.splice(A,1)}static onSessionRequestEnd(t){this._sessionRequestEndListeners.push(t)}static offSessionRequestEnd(t){const A=this._sessionRequestEndListeners.indexOf(t);A>=0&&this._sessionRequestEndListeners.splice(A,1)}static onXRSessionStart(t){this._xrStartListeners.push(t)}static offXRSessionStart(t){const A=this._xrStartListeners.indexOf(t);A>=0&&this._xrStartListeners.splice(A,1)}static onXRSessionEnd(t){this._xrEndListeners.push(t)}static offXRSessionEnd(t){const A=this._xrEndListeners.indexOf(t);A>=0&&this._xrEndListeners.splice(A,1)}static onControllerAdded(t){this._controllerAddedListeners.push(t)}static offControllerAdded(t){const A=this._controllerAddedListeners.indexOf(t);A>=0&&this._controllerAddedListeners.splice(A,1)}static onControllerRemoved(t){this._controllerRemovedListeners.push(t)}static offControllerRemoved(t){const A=this._controllerRemovedListeners.indexOf(t);A>=0&&this._controllerRemovedListeners.splice(A,1)}static offerSession(t,A,e){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+t),A=="default"&&(A=this.getDefaultSessionInit(t)),navigator.xr.offerSession(t,{...A}).then(i=>oB.setSession(t,i,A,e)).catch(i=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(t){switch(t){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",t),{}}}static async start(t,A,e){var i,g,I,o;if(oe()&&tA("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await jc.start(t,A||oB.getDefaultSessionInit(t)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Kg||oe())&&Yt("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(e||(e=Ke.Current),e||(e=Ct.All[0]),!e)throw new Error("No Needle Engine Context found");switch(A||(A={}),A.optionalFeatures??(A.optionalFeatures=[]),A.requiredFeatures??(A.requiredFeatures=[]),t){case"immersive-ar":{if(await((i=this.xrSystem)==null?void 0:i.isSessionSupported("immersive-ar"))!==!0)return console.error(t+" is not supported by this browser."),null;const n=this.getDefaultSessionInit(t),C=sEA(e.domElement);C&&!J0()&&(n.domOverlay={root:C},n.optionalFeatures.push("dom-overlay")),A={...n,...A}}break;case"immersive-vr":{if(await((g=this.xrSystem)==null?void 0:g.isSessionSupported("immersive-vr"))!==!0)return console.error(t+" is not supported by this browser."),null;A={...this.getDefaultSessionInit(t),...A}}break;default:console.warn("No default session init for mode",t);break}await jc.stop();const s=t=="immersive-ar"?e.scripts_immersive_ar:e.scripts_immersive_vr;Kg?console.log(`%cRequesting ${t} session`,"font-weight:bold;",A,s):console.log(`%cRequesting ${t} session`,"font-weight:bold;");for(const n of s)n.onBeforeXR&&n.onBeforeXR(t,A);for(const n of this._sessionRequestStartListeners)n({mode:t,init:A});Kg&&pi("Requesting "+t+" session ("+Date.now()+")"),this._currentSessionRequest=(I=navigator.xr)==null?void 0:I.requestSession(t,A),this._currentSessionRequestMode=t;const a=await((o=this._currentSessionRequest)==null?void 0:o.catch(n=>{console.error(n,"Code: "+n.code),n.code===9&&Yt("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&Yt("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const n of this._sessionRequestEndListeners)n({mode:t,init:A,newSession:a||null});return a?this.setSession(t,a,A,e):(console.warn("XR Session request was rejected"),null)}static setSession(t,A,e,i){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const g=t=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;return this._activeSession=new oB(t,A,i,{scripts:g,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:e}),A.addEventListener("end",this.onEnd),Kg?console.log(`%cStarted ${t} session`,"font-weight:bold;",g):console.log(`%cStarted ${t} session`,"font-weight:bold;"),this._activeSession}static stop(){var t;(t=this._activeSession)==null||t.end()}get sync(){return oB._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(t=>t.isLeft)}get rightController(){return this.controllers.find(t=>t.isRight)}getController(t){return typeof t=="number"?this.controllers[t]||null:this.controllers.find(A=>A.side===t)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(t=>t.inputSource.targetRayMode==="tracked-pointer")||oe()&&fQ()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const t=this.frame.getImageTrackingResults();for(const A of t)if(A.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const t=this._rigs[0]??null;return t!=null&&t.gameObject&&nE(t.gameObject)||t?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):t}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(t){this._rigs.indexOf(t)>=0||(t.priority===void 0&&(t.priority=0),this._rigs.push(t),this.updateActiveXRRig())}removeRig(t){const A=this._rigs.indexOf(t);A!==-1&&(this._rigs.splice(A,1),this.updateActiveXRRig())}setRigActive(t){const A=this._rigs.indexOf(t);this._rigs.splice(A,1),this._rigs.unshift(t),this.updateActiveXRRig()}updateActiveXRRig(){const t=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let A=this._rigs[0];A&&A.priority===void 0&&(A.priority=0);for(let e=1;e<this._rigs.length;e++){const i=this._rigs[e];if(i.isActive){if(nE(i.gameObject)){this._rigs.splice(e,1),e--;continue}(!A||A.isActive===!1||i.priority!==void 0&&i.priority>A.priority)&&(A=i)}}if(t!==A){const e=this._rigs.indexOf(A);e>=0&&this._rigs.splice(e,1),this._rigs.unshift(A)}Kg&&(t===A?console.log("Updated Active XR Rig:",A,"prev:",t):console.log("Updated Active XRRig:",A," (the same as before)"))}getHitTest(t){if(t)return this.getControllerHitTest(t);if(!this._viewerHitTestSource)return null;const A=this._viewerHitTestSource,e=this.frame.getHitTestResults(A);if(e.length>0){const i=e[0];return this.convertHitTestResult(i)}return null}getControllerHitTest(t){const A=t.hitTestSource;if(!A)return null;const e=this.frame.getHitTestResultsForTransientInput(A);for(const i of e)if(i.inputSource===t.inputSource)for(const g of i.results)return this.convertHitTestResult(g);return null}convertHitTestResult(t){const A=this.context.renderer.xr.getReferenceSpace(),e=A&&t.getPose(A);if(e){const i=bi(e.transform.position),g=UQ(e.transform.orientation),I=this.context.mainCamera;if(I?.parent!==this._cameraRenderParent&&i.applyMatrix4(Gm),I!=null&&I.parent){i.applyMatrix4(I.parent.matrixWorld),g.multiply(Us);const o=Kt(I.parent);o.premultiply(Us),g.premultiply(o)}return{hit:t,position:i,quaternion:g}}return null}convertSpace(t){const A=bi(t.position);A.applyMatrix4(Gm);const e=UQ(t.orientation);return e.premultiply(Us),{position:A,quaternion:e}}disconnectInputSource(t){const A=(e,i,g)=>{if(e.inputSource===t){Kg&&console.log("Disconnecting controller",e.index),this.controllers.splice(g,1),this.invokeControllerEvent(e,this._controllerRemoved,"removed");const I={xr:this,controller:e,change:"removed"};for(const o of this._xr_scripts)o.onXRControllerRemoved&&o.onXRControllerRemoved(I);e.onDisconnected()}};for(let e=this.controllers.length-1;e>=0;e--){const i=this.controllers[e];A(i,this.controllers,e)}for(let e=this._newControllers.length-1;e>=0;e--){const i=this._newControllers[e];A(i,this._newControllers,e)}}end(){this._ended||this.session.end().catch(t=>console.warn(t))}onRenderDebug(){if(Kg)for(const t of this.controllers)t.onRenderDebug();if((Kg||oEA)&&this.rig){const t=this.rig.gameObject.worldPosition,A=this.rig.gameObject.worldForward;t.add(A.multiplyScalar(1.5));const e=this.rig.gameObject.worldUp;t.add(e.multiplyScalar(2.5));let i="";if(i+=this.context.time.smoothedFps.toFixed(1),Kg)for(const g of this.controllers)i+=`
|
|
5237
|
+
`+a.href)}this.onSendQueued(Ms.OnRoomJoin);break;case"left-room":A.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(A.data){const s=A.data;this._currentInRoom.push(s.userId),oo&&console.log(s.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(A.data){const s=A.data,a=this._currentInRoom.indexOf(s.userId);a>=0&&(oo&&console.log(s.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(a,1)),s.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":oo&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const o=(e=A.data)==null?void 0:e.time;o&&(this._currentDelay=this.context.time.time-o),oo&&console.log("Current latency: "+this._currentDelay.toFixed(1)+" sec","Clients in room: "+((i=this._currentInRoom)==null?void 0:i.length));break}let g=this._listeners[A.key];if(g){g=[...g];for(const o of g)try{o(A.data)}catch(s){console.error('Error invoking callback for "'+A.key+'"',s)}}const I=A.data;I&&(this._state[I.guid]=I)}toMessage(A,e){return{key:A,data:e}}sendWithWebsocket(A,e,i=Ms.OnRoomJoin){if(!this._ws){const I=this._waitingForSocket[i]||[];I.push(()=>this.sendWithWebsocket(A,e,i)),this._waitingForSocket[i]=I;return}const g=JSON.stringify(this.toMessage(A,e));oo&&console.log(">>",A),this._ws.send(g)}onSendQueued(A){const e=this._waitingForSocket[A];if(e){for(const i of e)i();e.length=0}}}const Up=tA("debugwebxr");class PK{constructor(A,e){B(this,"controllerStates",[]),B(this,"userId"),B(this,"context"),B(this,"userStateEvtName"),B(this,"onReceivedControllerState",i=>{Up&&console.log(`XRSync: Received change for ${this.userId}: ${i.type} ${i.handedness}; tracked=${i.isTracking}`);let g=!1;for(let I=0;I<this.controllerStates.length;I++)if(this.controllerStates[I].index===i.index){this.controllerStates[I]=i,g=!0;break}g||this.controllerStates.push(i)}),this.userId=A,this.context=e,this.userStateEvtName="xr-sync-user-state-"+A,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(A){if(this.context.connection.isConnected!=!1){for(let e=this.controllerStates.length-1;e>=0;e--){const i=this.controllerStates[e];let g=!1;for(let I=0;I<A.controllers.length;I++)A.controllers[I].index===i.index&&(g=!0);g||(Up&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(e,1),this.sendControllerRemoved(i))}for(const e of A.controllers)this.updateControllerStates(e)}}onExitXR(A){for(const e of this.controllerStates)this.sendControllerRemoved(e);this.controllerStates.length=0}sendControllerRemoved(A){A.isTracking=!1,A.guid="",this.context.connection.send(this.userStateEvtName,A),this.context.connection.sendDeleteRemoteState(A.guid)}updateControllerStates(A){const e=this.controllerStates.find(i=>i.index===A.index);if(e){let i=!1;i||(i=e.isTracking!=A.isTracking),i&&(e.isTracking=A.isTracking,this.context.connection.send(this.userStateEvtName,e))}else{const i={guid:this.userId+"-"+A.index,isTracking:A.isTracking,handedness:A.side,index:A.index,type:A.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),Up&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class tj{constructor(A){B(this,"context"),B(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(Up&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new PK(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new PK(e,this.context))}}),B(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const e=this._states.get(this.context.connection.connectionId);e?.dispose(),this._states.delete(this.context.connection.connectionId)}}),B(this,"onOtherUserJoinedRoom",e=>{const i=e.userId;this._states.has(i)||(Up&&console.log("XRSync: Remote user joined room",i),this._states.set(i,new PK(i,this.context)))}),B(this,"onOtherUserLeftRoom",e=>{const i=e.userId;if(!this._states.has(i)){const g=this._states.get(i);g?.dispose(),this._states.delete(i)}}),B(this,"_states",new Map),this.context=A,this.context.connection.beginListen(gt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(gt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(gt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(gt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(A){return A?this._states.has(A):!1}isTracking(A,e){if(!A)return;const i=this._states.get(A);if(!i)return;const g=i.controllerStates.find(I=>I.handedness===e);return g?.isTracking||!1}getDeviceType(A,e){if(!A)return;const i=this._states.get(A);if(!i)return;const g=i.controllerStates.find(I=>I.handedness===e);return g?.type||"unknown"}destroy(){this.context.connection.stopListen(gt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(gt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(gt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(gt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e?.update(A)}}onExitXR(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e?.onExitXR(A)}}}class ij{constructor(){B(this,"_fadeToColorQuad"),B(this,"_fadeToColorMaterial"),B(this,"_requestedFadeValue",0),B(this,"_transitionPromise",null),B(this,"_transitionResolve",null),this._fadeToColorMaterial=new At({color:0,transparent:!0,depthTest:!1,fog:!1,side:pt}),this._fadeToColorQuad=new lA(new Qg(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(A,e){const i=this._fadeToColorQuad,g=this._fadeToColorMaterial;i.parent!==A&&g.opacity>0?A.add(i):g.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const I=this._requestedFadeValue;g.opacity=ee.lerp(g.opacity,I,e/.03),Math.abs(g.opacity-I)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const A=new Promise(e=>{this._transitionResolve=e});return this._transitionPromise=A,A}}var aE=(t=>(t[t.Quad=0]="Quad",t[t.Cube=1]="Cube",t[t.Sphere=2]="Sphere",t))(aE||{});class Fp{static createPrimitive(A,e){let i;switch(A){case"Quad":case 0:{const g=new Qg(1,1,1,1),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break;case"Cube":case 1:{const g=new zt(1,1,1),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break;case"Sphere":case 2:{const g=new ba(.5,16,16),I=e?.material??new yI({color:16777215});e!=null&&e.texture&&"map"in I&&(I.map=e.texture),i=new lA(g,I)}break}return this.applyDefaultObjectOptions(i,e),i}static createSprite(A){const e=new Py({color:16777215});A!=null&&A.texture&&"map"in e&&(e.map=A.texture);const i=new fR(e);return this.applyDefaultObjectOptions(i,A),i}static applyDefaultObjectOptions(A,e){e!=null&&e.name&&(A.name=e.name),e!=null&&e.position&&A.position.set(e.position.x,e.position.y,e.position.z),e!=null&&e.rotation&&A.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e!=null&&e.scale&&A.scale.set(e.scale.x,e.scale.y,e.scale.z)}}const gj=class{constructor(t,A,e){B(this,"_session"),B(this,"_mode"),B(this,"_init"),B(this,"_renderer"),B(this,"_camera"),B(this,"_scene"),B(this,"onEnd",()=>{var i;(i=this._session)==null||i.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),B(this,"_lastTime",0),B(this,"onFrame",(i,g)=>{const I=i-this._lastTime;this.update(i,I),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),B(this,"_objects",[]),this._mode=t,this._init=A,this._session=e,this._session.addEventListener("end",this.onEnd),this._renderer=new eC({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(e),this._renderer.xr.enabled=!0,this._camera=new Ne,this._scene=new Zg,this._scene.fog=new Oy(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(t,A){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!A)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const e=await navigator.xr.requestSession(t,A);return e.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new gj(t,A,e),this._active):(e.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await Wa(100)),this._active=null}get isAR(){return this._mode==="immersive-ar"}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const t={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,t}async onBeforeHandoff(){await Wa(1e3),this._scene.clear()}setupScene(){this._scene.background=new fA(0),this._scene.add(new G0(5,10,1118481,1118481));const t=new uQ(16777215,1);t.position.set(0,20,0),t.castShadow=!1,this._scene.add(t);const A=new uQ(16777215,1);A.position.set(0,-1,0),A.castShadow=!1,this._scene.add(A);const e=new dQ(16777215,1,100,1);e.position.set(0,2,0),e.castShadow=!1,e.distance=200,this._scene.add(e);const i=50;for(let g=0;g<100;g++){const I=new yI({color:2236962,metalness:1,roughness:.8});this.isAR&&(I.emissive=new fA(Math.random(),Math.random(),Math.random()),I.emissiveIntensity=Math.random());const o=ee.random(0,1)>.5?aE.Sphere:aE.Cube,s=Fp.createPrimitive(o,{material:I});s.position.x=ee.random(-i,i),s.position.y=ee.random(-2,i),s.position.z=ee.random(-i,i),s.rotation.x=ee.random(0,Math.PI*2),s.rotation.y=ee.random(0,Math.PI*2),s.rotation.z=ee.random(0,Math.PI*2),s.scale.multiplyScalar(.5+Math.random()*10);const a=s.position.distanceTo(this._camera.position)-s.scale.x;a<1&&s.position.multiplyScalar(1+1/a),this._objects.push(s),this._scene.add(s)}}update(t,A){const e=t*4e-4;for(let i=0;i<this._objects.length;i++){const g=this._objects[i];g.position.y+=Math.sin(e+i*.5)*.005,g.rotateY(.002)}}};let jc=gj;B(jc,"_active",null),B(jc,"_requestInFlight",!1);const Kg=tA("debugwebxr"),oEA=tA("stats");function sEA(t){let A=null;const e=t;return e.getAROverlayContainer?A=e.getAROverlayContainer():A=t,A}aEA();async function aEA(){var t;if(tA("debugasap")){let A=globalThis["needle:XRSession"];if(A instanceof Promise){delete globalThis["needle:XRSession"],Ct.addContextCreatedCallback(async e=>{if(!A)return;Xh(!0);const i=await A;if(i){const g=ye.getDefaultSessionInit("immersive-vr");ye.setSession("immersive-vr",i,g,e.context)}else console.error("NeedleXRSession: ASAP session was rejected");A=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(t=navigator.xr)==null||t.addEventListener("sessiongranted",async()=>{Xh(!0),console.log("Received Session Granted..."),await Wa(100);const A=sessionStorage.getItem("needle_xr_session_mode"),e=sessionStorage.getItem("needle_xr_session_init")??null,i=e?JSON.parse(e):null;let g=null;if(Ij()&&(await jc.start(A||"immersive-vr",i||ye.getDefaultSessionInit("immersive-vr")),await rEA(),g=await jc.handoff()),g)ye.setSession(g.mode,g.session,g.init,Ke.Current);else if(A&&e){console.log("Session Granted: Restore last session");const I=JSON.parse(e);ye.start(A,I).catch(o=>console.warn(o))}else ye.start("immersive-vr").catch(I=>console.warn("Session Granted failed:",I))},{once:!0})}}function nEA(t,A){sessionStorage.setItem("needle_xr_session_mode",t),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(A))}function CEA(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const jK=new Set;Ct.registerCallback(kt.ContextCreationStart,async t=>{jK.add(t.context)}),Ct.registerCallback(kt.ContextCreated,async t=>{jK.delete(t.context)});function Ij(){return jK.size>0}function rEA(){return new Promise(t=>{const A=Date.now(),e=setInterval(()=>{(!Ij()||Date.now()-A>6e4)&&(clearInterval(e),t())},100)})}fQ()&&oe()&&window.addEventListener("keydown",t=>{(t.key==="x"||t.key==="Escape")&&ye.active&&ye.stop()});const oB=class{constructor(t,A,e,i){B(this,"context"),B(this,"session"),B(this,"mode"),B(this,"controllers",[]),B(this,"_rigScale",1),B(this,"_lastRigScaleUpdate",-1),B(this,"_rigs",[]),B(this,"_viewerHitTestSource",null),B(this,"_defaultRig"),B(this,"_xr_scripts"),B(this,"_xr_update_scripts",[]),B(this,"_inactive_scripts",[]),B(this,"_controllerAdded"),B(this,"_controllerRemoved"),B(this,"_originalCameraWorldPosition"),B(this,"_originalCameraWorldRotation"),B(this,"_originalCameraWorldScale"),B(this,"_originalCameraParent"),B(this,"_mainCamera",null),B(this,"onRendererSessionSet",()=>{var o;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(o=this.context.mainCameraComponent)==null||o.applyClearFlags())}),B(this,"onInputSourceAdded",o=>{if(o.targetRayMode==="screen")return;let s=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===o){s=n;break}if(this.controllers.find(n=>n.inputSource===o)){console.warn("Controller already exists for input source",s);return}Kg&&console.log("Adding controller",s);const a=new DK(this,o,s);this._newControllers.push(a)}),B(this,"_ended",!1),B(this,"_newControllers",[]),B(this,"onEnd",o=>{var s,a,n;if(this._ended)return;this._ended=!0,Kg&&console.log("XR Session ended"),CEA(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,iB(this.onBefore,Zt.LateUpdate);const C=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);C>=0&&this.context.pre_render_callbacks.splice(C,1);const r=this.context.post_render_callbacks.indexOf(this.onAfterRender);r>=0&&this.context.post_render_callbacks.splice(r,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var Q;(Q=this.context.mainCameraComponent)==null||Q.applyClearFlags()}),m4({session:this});for(const Q of oB._xrEndListeners)Q({xr:this});for(let Q=0;Q<this.controllers.length;Q++)this.disconnectInputSource(this.controllers[Q].inputSource);for(const Q of this._xr_scripts)(s=Q?.onLeaveXR)==null||s.call(Q,{xr:this});(a=this.sync)==null||a.onExitXR(this),this.context.mainCamera&&((n=this._originalCameraParent)==null||n.add(this.context.mainCamera),this._originalCameraWorldPosition&&SI(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&cs(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&cu(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),Xh(!1)}),B(this,"_didStart",!1),B(this,"onBefore",o=>{var s,a,n,C,r,Q,E,h;const l=o.xrFrame;if(!l)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((s=this.rig)==null?void 0:s.isActive)==!1&&(Kg&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(a=this._mainCamera)!=null&&a.gameObject&&((C=(n=this._mainCamera)==null?void 0:n.gameObject)==null?void 0:C.parent)!==this.rig.gameObject&&this.rig.gameObject.add((r=this._mainCamera)==null?void 0:r.gameObject),this.internalUpdateState(),this.applyCustomForward();const d={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const c=[...this.context.new_scripts_xr];for(let u=0;u<c.length;u++){const p=this.context.new_scripts_xr[u];if(!p||p.destroyed||((Q=p.supportsXR)==null?void 0:Q.call(p,this.mode))==!1){this.context.new_scripts_xr.splice(u,1);continue}if(!p.activeAndEnabled){this.context.new_scripts_xr.splice(u,1),this.markInactive(p);continue}if(this.addScript(p)){this.invokeCallback_EnterXR(p);for(const D of this.controllers)this.invokeCallback_ControllerAdded(p,D)}}}}else{this._didStart=!0,S4({session:this});for(const u of oB._xrStartListeners)u(d);const c=[...this._xr_scripts];Kg&&console.log("NeedleXRSession start, handle scripts:",c);for(const u of c){if(u.destroyed){this._script_to_remove.push(u);continue}if(!u.activeAndEnabled){this.markInactive(u);continue}this.invokeCallback_EnterXR(u);for(const p of this.controllers)this.invokeCallback_ControllerAdded(u,p)}}this.syncCameraCullingMask();for(const c of this.controllers)c.onUpdate(l);if(this._newControllers.length>0){const c=[...this._newControllers];this._newControllers.length=0;for(const u of c)if(u.connected){this.controllers.push(u);for(const p of this._xr_scripts){if(p.destroyed){this._script_to_remove.push(p);continue}p.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(p,u)}}this.controllers.sort((u,p)=>u.index-p.index)}for(const c of this._xr_update_scripts){if(c.destroyed===!0){this._script_to_remove.push(c);continue}if(c.activeAndEnabled===!1){this.markInactive(c);continue}c.onUpdateXR&&c.onUpdateXR(d)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const c=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const u of c)!u.destroyed&&this.running&&((E=u.onLeaveXR)==null||E.call(u,d)),this.removeScript(u)}(h=this.sync)==null||h.onUpdate(this),this.onRenderDebug()}),B(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),B(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),fQ()){const o=this.context.renderer;if(o.xr.isPresenting&&this.context.mainCamera){const s=o.xr.enabled,a=o.getRenderTarget();o.xr.enabled=!1,o.setRenderTarget(null),o.render(this.context.scene,this.context.mainCamera),o.xr.enabled=s,o.setRenderTarget(a)}}}),B(this,"_script_to_remove",[]),B(this,"_camera"),B(this,"_cameraRenderParent",new wA().rotateY(Math.PI)),B(this,"_previousCameraParent"),B(this,"_customforward",!0),B(this,"originalCameraNearPlane"),B(this,"_viewerPose"),B(this,"_transformOrientation",new GA),B(this,"_transformPosition",new f),B(this,"_transition");var g,I;nEA(t,i.init),this.session=A,this.mode=t,this.context=e,(Kg||tA("console"))&&Xh(!0),this._xr_scripts=[...i.scripts],this._xr_update_scripts=this._xr_scripts.filter(o=>typeof o.onUpdateXR=="function"),this._controllerAdded=i.controller_added,this._controllerRemoved=i.controller_removed,tB(this.onBefore,Zt.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((g=i.init.optionalFeatures)!=null&&g.includes("hit-test")||(I=i.init.requiredFeatures)!=null&&I.includes("hit-test"))&&A.requestReferenceSpace("viewer").then(o=>{var s,a;return(a=(s=A.requestHitTestSource)==null?void 0:s.call(A,{space:o}))==null?void 0:a.then(n=>this._viewerHitTestSource=n)}).catch(o=>console.warn(o)),this.context.mainCamera&&(this._originalCameraWorldPosition=xe(this.context.mainCamera,new f),this._originalCameraWorldRotation=Kt(this.context.mainCamera,new GA),this._originalCameraWorldScale=ei(this.context.mainCamera,new f),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new EQA,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let o=0;o<A.inputSources.length;o++){const s=A.inputSources[o];if(!s.handedness){console.warn("Input source in xr session has no handedness - ignoring",o);continue}this.onInputSourceAdded(s)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",o=>{for(const s of o.removed)this.disconnectInputSource(s);for(const s of o.added)this.onInputSourceAdded(s)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(t){return this._sync||(this._sync=new tj(t)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var t;return((t=this._activeSession)==null?void 0:t.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(t=>t.some(A=>A)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(t){var A;return((A=this.xrSystem)==null?void 0:A.isSessionSupported(t).catch(e=>(Kg&&console.error(e),!1)))??Promise.resolve(!1)}static onSessionRequestStart(t){this._sessionRequestStartListeners.push(t)}static offSessionRequestStart(t){const A=this._sessionRequestStartListeners.indexOf(t);A>=0&&this._sessionRequestStartListeners.splice(A,1)}static onSessionRequestEnd(t){this._sessionRequestEndListeners.push(t)}static offSessionRequestEnd(t){const A=this._sessionRequestEndListeners.indexOf(t);A>=0&&this._sessionRequestEndListeners.splice(A,1)}static onXRSessionStart(t){this._xrStartListeners.push(t)}static offXRSessionStart(t){const A=this._xrStartListeners.indexOf(t);A>=0&&this._xrStartListeners.splice(A,1)}static onXRSessionEnd(t){this._xrEndListeners.push(t)}static offXRSessionEnd(t){const A=this._xrEndListeners.indexOf(t);A>=0&&this._xrEndListeners.splice(A,1)}static onControllerAdded(t){this._controllerAddedListeners.push(t)}static offControllerAdded(t){const A=this._controllerAddedListeners.indexOf(t);A>=0&&this._controllerAddedListeners.splice(A,1)}static onControllerRemoved(t){this._controllerRemovedListeners.push(t)}static offControllerRemoved(t){const A=this._controllerRemovedListeners.indexOf(t);A>=0&&this._controllerRemovedListeners.splice(A,1)}static offerSession(t,A,e){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+t),A=="default"&&(A=this.getDefaultSessionInit(t)),navigator.xr.offerSession(t,{...A}).then(i=>oB.setSession(t,i,A,e)).catch(i=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(t){switch(t){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",t),{}}}static async start(t,A,e){var i,g,I,o;if(oe()&&tA("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await jc.start(t,A||oB.getDefaultSessionInit(t)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Kg||oe())&&Yt("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(e||(e=Ke.Current),e||(e=Ct.All[0]),!e)throw new Error("No Needle Engine Context found");switch(A||(A={}),t){case"immersive-ar":{if(await((i=this.xrSystem)==null?void 0:i.isSessionSupported("immersive-ar"))!==!0)return console.error(t+" is not supported by this browser."),null;const n=this.getDefaultSessionInit(t),C=sEA(e.domElement);C&&!J0()&&(n.domOverlay={root:C},n.optionalFeatures.push("dom-overlay")),A={...n,...A}}break;case"immersive-vr":{if(await((g=this.xrSystem)==null?void 0:g.isSessionSupported("immersive-vr"))!==!0)return console.error(t+" is not supported by this browser."),null;A={...this.getDefaultSessionInit(t),...A}}break;default:console.warn("No default session init for mode",t);break}A.optionalFeatures??(A.optionalFeatures=[]),A.requiredFeatures??(A.requiredFeatures=[]),await jc.stop();const s=t=="immersive-ar"?e.scripts_immersive_ar:e.scripts_immersive_vr;Kg?console.log(`%cRequesting ${t} session`,"font-weight:bold;",A,s):console.log(`%cRequesting ${t} session`,"font-weight:bold;");for(const n of s)n.onBeforeXR&&n.onBeforeXR(t,A);for(const n of this._sessionRequestStartListeners)n({mode:t,init:A});Kg&&pi("Requesting "+t+" session ("+Date.now()+")"),this._currentSessionRequest=(I=navigator.xr)==null?void 0:I.requestSession(t,A),this._currentSessionRequestMode=t;const a=await((o=this._currentSessionRequest)==null?void 0:o.catch(n=>{console.error(n,"Code: "+n.code),n.code===9&&Yt("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&Yt("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const n of this._sessionRequestEndListeners)n({mode:t,init:A,newSession:a||null});return a?this.setSession(t,a,A,e):(console.warn("XR Session request was rejected"),null)}static setSession(t,A,e,i){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const g=t=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;return this._activeSession=new oB(t,A,i,{scripts:g,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:e}),A.addEventListener("end",this.onEnd),Kg?console.log(`%cStarted ${t} session`,"font-weight:bold;",g):console.log(`%cStarted ${t} session`,"font-weight:bold;"),this._activeSession}static stop(){var t;(t=this._activeSession)==null||t.end()}get sync(){return oB._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(t=>t.isLeft)}get rightController(){return this.controllers.find(t=>t.isRight)}getController(t){return typeof t=="number"?this.controllers[t]||null:this.controllers.find(A=>A.side===t)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(t=>t.inputSource.targetRayMode==="tracked-pointer")||oe()&&fQ()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const t=this.frame.getImageTrackingResults();for(const A of t)if(A.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const t=this._rigs[0]??null;return t!=null&&t.gameObject&&nE(t.gameObject)||t?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):t}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(t){this._rigs.indexOf(t)>=0||(t.priority===void 0&&(t.priority=0),this._rigs.push(t),this.updateActiveXRRig())}removeRig(t){const A=this._rigs.indexOf(t);A!==-1&&(this._rigs.splice(A,1),this.updateActiveXRRig())}setRigActive(t){const A=this._rigs.indexOf(t);this._rigs.splice(A,1),this._rigs.unshift(t),this.updateActiveXRRig()}updateActiveXRRig(){const t=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let A=this._rigs[0];A&&A.priority===void 0&&(A.priority=0);for(let e=1;e<this._rigs.length;e++){const i=this._rigs[e];if(i.isActive){if(nE(i.gameObject)){this._rigs.splice(e,1),e--;continue}(!A||A.isActive===!1||i.priority!==void 0&&i.priority>A.priority)&&(A=i)}}if(t!==A){const e=this._rigs.indexOf(A);e>=0&&this._rigs.splice(e,1),this._rigs.unshift(A)}Kg&&(t===A?console.log("Updated Active XR Rig:",A,"prev:",t):console.log("Updated Active XRRig:",A," (the same as before)"))}getHitTest(t){if(t)return this.getControllerHitTest(t);if(!this._viewerHitTestSource)return null;const A=this._viewerHitTestSource,e=this.frame.getHitTestResults(A);if(e.length>0){const i=e[0];return this.convertHitTestResult(i)}return null}getControllerHitTest(t){const A=t.hitTestSource;if(!A)return null;const e=this.frame.getHitTestResultsForTransientInput(A);for(const i of e)if(i.inputSource===t.inputSource)for(const g of i.results)return this.convertHitTestResult(g);return null}convertHitTestResult(t){const A=this.context.renderer.xr.getReferenceSpace(),e=A&&t.getPose(A);if(e){const i=bi(e.transform.position),g=UQ(e.transform.orientation),I=this.context.mainCamera;if(I?.parent!==this._cameraRenderParent&&i.applyMatrix4(Gm),I!=null&&I.parent){i.applyMatrix4(I.parent.matrixWorld),g.multiply(Us);const o=Kt(I.parent);o.premultiply(Us),g.premultiply(o)}return{hit:t,position:i,quaternion:g}}return null}convertSpace(t){const A=bi(t.position);A.applyMatrix4(Gm);const e=UQ(t.orientation);return e.premultiply(Us),{position:A,quaternion:e}}disconnectInputSource(t){const A=(e,i,g)=>{if(e.inputSource===t){Kg&&console.log("Disconnecting controller",e.index),this.controllers.splice(g,1),this.invokeControllerEvent(e,this._controllerRemoved,"removed");const I={xr:this,controller:e,change:"removed"};for(const o of this._xr_scripts)o.onXRControllerRemoved&&o.onXRControllerRemoved(I);e.onDisconnected()}};for(let e=this.controllers.length-1;e>=0;e--){const i=this.controllers[e];A(i,this.controllers,e)}for(let e=this._newControllers.length-1;e>=0;e--){const i=this._newControllers[e];A(i,this._newControllers,e)}}end(){this._ended||this.session.end().catch(t=>console.warn(t))}onRenderDebug(){if(Kg)for(const t of this.controllers)t.onRenderDebug();if((Kg||oEA)&&this.rig){const t=this.rig.gameObject.worldPosition,A=this.rig.gameObject.worldForward;t.add(A.multiplyScalar(1.5));const e=this.rig.gameObject.worldUp;t.add(e.multiplyScalar(2.5));let i="";if(i+=this.context.time.smoothedFps.toFixed(1),Kg)for(const g of this.controllers)i+=`
|
|
5238
5238
|
${g.hand?"hand":"ctrl"} ${g.inputSource.handedness}[${g.index}] con:${g.connected} tr:${g.isTracking}`;De.DrawLabel(t,i)}}addScript(t){return this._xr_scripts.includes(t)?!1:(Kg&&console.log("Register new XRScript",t),this._xr_scripts.push(t),typeof t.onUpdateXR=="function"&&this._xr_update_scripts.push(t),!0)}markInactive(t){if(!(this._inactive_scripts.indexOf(t)>=0)){this.removeScript(t,!1),this._inactive_scripts.push(t);for(const A of this.controllers)this.invokeCallback_ControllerRemoved(t,A);this.invokeCallback_LeaveXR(t)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let t=this._inactive_scripts.length-1;t>=0;t--){const A=this._inactive_scripts[t];if(A.activeAndEnabled){this._inactive_scripts.splice(t,1),this.addScript(A),this.invokeCallback_EnterXR(A);for(const e of this.controllers)this.invokeCallback_ControllerAdded(A,e)}}}removeScript(t,A=!0){Kg&&console.log("Remove XRScript",t);const e=this._xr_scripts.indexOf(t);e>=0&&this._xr_scripts.splice(e,1);const i=this._xr_update_scripts.indexOf(t);if(i>=0&&this._xr_update_scripts.splice(i,1),A){const g=this._inactive_scripts.indexOf(t);g>=0&&this._inactive_scripts.splice(g,1)}}invokeCallback_EnterXR(t){t.onEnterXR&&t.onEnterXR({xr:this})}invokeCallback_ControllerAdded(t,A){t.onXRControllerAdded&&t.onXRControllerAdded({xr:this,controller:A,change:"added"})}invokeCallback_ControllerRemoved(t,A){t.onXRControllerRemoved&&t.onXRControllerRemoved({xr:this,controller:A,change:"removed"})}invokeCallback_LeaveXR(t){t.onLeaveXR&&!t.destroyed&&t.onLeaveXR({xr:this})}syncCameraCullingMask(){var t;const A=this.context.xrCamera,e=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(A&&e!==void 0){for(const i of A.cameras)i.layers.mask=e;A.layers.mask=e}else if(A){for(const i of A.cameras)i.layers.enableAll();A.layers.enableAll()}}invokeControllerEvent(t,A,e){for(let i=A.length-1;i>=0;i--){const g=A[i];if(g)try{g({xr:this,controller:t,change:e})}catch(I){console.error(I)}}}applyCustomForward(){var t;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(t=this._previousCameraParent)==null||t.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let A=.02;if(this.rig){const e=ei(this.rig.gameObject);A*=e.x}this._camera instanceof Ne&&this._camera.near>A&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=A)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Ne&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const t=this.context.renderer.xr.getReferenceSpace();if(!t){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(t),this._viewerPose){const A=this._viewerPose.transform;this._transformPosition.set(A.position.x,A.position.y,A.position.z),this._transformOrientation.set(A.orientation.x,A.orientation.y,A.orientation.z,A.orientation.w)}}get transition(){return this._transition||(this._transition=new ij),this._transition}fadeTransition(){return this._transition||(this._transition=new ij),this._transition.fadeTransition()}updateFade(t){this._transition&&t instanceof Ne&&this._transition.update(t,this.context.time.deltaTime)}onUpdateFade_PostRender(){var t;(t=this._transition)==null||t.remove()}};let ye=oB;B(ye,"_sync",null),B(ye,"_currentSessionRequestMode",null),B(ye,"_currentSessionRequest"),B(ye,"_activeSession"),B(ye,"_sessionRequestStartListeners",[]),B(ye,"_sessionRequestEndListeners",[]),B(ye,"_xrStartListeners",[]),B(ye,"_xrEndListeners",[]),B(ye,"_controllerAddedListeners",[]),B(ye,"_controllerRemovedListeners",[]),B(ye,"onEnd",()=>{Kg&&console.log("XR Session ended"),oB._activeSession=null});const WK=tA("debugwebxr");class oj{static tryFindAvatarObjects(A,e,i){if(i.head&&i.leftHand&&i.rightHand)return;const g=A.name.toLocaleLowerCase();!i.head&&g.includes("head")&&(WK&&console.log("FOUND AVATAR HEAD",A.name),i.head=new it("",e,A)),g.includes("hand")&&(!i.leftHand&&g.includes("left")&&(WK&&console.log("FOUND AVATAR LEFT HAND",A.name),i.leftHand=new it("",e,A)),!i.rightHand&&g.includes("right")&&(WK&&console.log("FOUND AVATAR RIGHT HAND",A.name),i.rightHand=new it("",e,A)));for(let I=0;I<A.children.length;I++){if(i.head&&i.leftHand&&i.rightHand)return;const o=A.children[I];this.tryFindAvatarObjects(o,e,i)}}}var Tm=(t=>(t.Visible="application-visible",t.Hidden="application-hidden",t.MuteChanged="application-mutechanged",t))(Tm||{});let Ym=!1;const Wc=[];function Zc(){if(Ym)return;oe()&&console.debug("User interaction registered: audio can now be played"),Ym=!0;const t=[...Wc];Wc.length=0,t.forEach(A=>A())}document.addEventListener("pointerdown",Zc),document.addEventListener("click",Zc),document.addEventListener("dragstart",Zc),document.addEventListener("touchstart",Zc),document.addEventListener("keydown",Zc),ye.onXRSessionStart(()=>{Zc()});const sj=class extends EventTarget{constructor(t){super(),B(this,"_mute",!1),B(this,"context"),B(this,"_isVisible",!0),this.context=t,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return Ym}static registerWaitForInteraction(t){if(t!==null){if(Ym){t();return}Wc.indexOf(t)===-1&&Wc.push(t)}}static unregisterWaitForInteraction(t){const A=Wc.indexOf(t);A!==-1&&Wc.splice(A,1)}get muted(){return this._mute}set muted(t){t!==this._mute&&(this._mute=t,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(t){switch(t.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}};let sB=sj;B(sB,"registerWaitForAllowAudio",sj.registerWaitForInteraction);function*aj(t,A=null){const e=A?A.time:Ke.Current.time,i=e.time;for(;e.time-i<t;)yield}function*BEA(t){for(let A=0;A<t;A++)yield}function*nj(t){let A=!0;for(t.then(()=>A=!1),t.catch(()=>A=!1);A;)yield}class Np extends eU{constructor(A){super(A),this.type=di}parse(A){const e=Math.pow(2.7182818,2.2);function i(S,F){let T=0;for(let L=0;L<65536;++L)(L==0||S[L>>3]&1<<(L&7))&&(F[T++]=L);const AA=T-1;for(;T<65536;)F[T++]=0;return AA}function g(S){for(let F=0;F<16384;F++)S[F]={},S[F].len=0,S[F].lit=0,S[F].p=null}const I={l:0,c:0,lc:0};function o(S,F,T,AA,L){for(;T<S;)F=F<<8|j(AA,L),T+=8;T-=S,I.l=F>>T&(1<<S)-1,I.c=F,I.lc=T}const s=new Array(59);function a(S){for(let T=0;T<=58;++T)s[T]=0;for(let T=0;T<65537;++T)s[S[T]]+=1;let F=0;for(let T=58;T>0;--T){const AA=F+s[T]>>1;s[T]=F,F=AA}for(let T=0;T<65537;++T){const AA=S[T];AA>0&&(S[T]=AA|s[AA]++<<6)}}function n(S,F,T,AA,L,X){const P=F;let CA=0,BA=0;for(;AA<=L;AA++){if(P.value-F.value>T)return!1;o(6,CA,BA,S,P);const mA=I.l;if(CA=I.c,BA=I.lc,X[AA]=mA,mA==63){if(P.value-F.value>T)throw new Error("Something wrong with hufUnpackEncTable");o(8,CA,BA,S,P);let NA=I.l+6;if(CA=I.c,BA=I.lc,AA+NA>L+1)throw new Error("Something wrong with hufUnpackEncTable");for(;NA--;)X[AA++]=0;AA--}else if(mA>=59){let NA=mA-59+2;if(AA+NA>L+1)throw new Error("Something wrong with hufUnpackEncTable");for(;NA--;)X[AA++]=0;AA--}}a(X)}function C(S){return S&63}function r(S){return S>>6}function Q(S,F,T,AA){for(;F<=T;F++){const L=r(S[F]),X=C(S[F]);if(L>>X)throw new Error("Invalid table entry");if(X>14){const P=AA[L>>X-14];if(P.len)throw new Error("Invalid table entry");if(P.lit++,P.p){const CA=P.p;P.p=new Array(P.lit);for(let BA=0;BA<P.lit-1;++BA)P.p[BA]=CA[BA]}else P.p=new Array(1);P.p[P.lit-1]=F}else if(X){let P=0;for(let CA=1<<14-X;CA>0;CA--){const BA=AA[(L<<14-X)+P];if(BA.len||BA.p)throw new Error("Invalid table entry");BA.len=X,BA.lit=F,P++}}}return!0}const E={c:0,lc:0};function h(S,F,T,AA){S=S<<8|j(T,AA),F+=8,E.c=S,E.lc=F}const l={c:0,lc:0};function d(S,F,T,AA,L,X,P,CA,BA){if(S==F){AA<8&&(h(T,AA,L,X),T=E.c,AA=E.lc),AA-=8;let mA=T>>AA;if(mA=new Uint8Array([mA])[0],CA.value+mA>BA)return!1;const NA=P[CA.value-1];for(;mA-- >0;)P[CA.value++]=NA}else if(CA.value<BA)P[CA.value++]=S;else return!1;l.c=T,l.lc=AA}function c(S){return S&65535}function u(S){const F=c(S);return F>32767?F-65536:F}const p={a:0,b:0};function D(S,F){const T=u(S),AA=u(F),L=T+(AA&1)+(AA>>1),X=L,P=L-AA;p.a=X,p.b=P}function y(S,F){const T=c(S),AA=c(F),L=T-(AA>>1)&65535,X=AA+L-32768&65535;p.a=X,p.b=L}function k(S,F,T,AA,L,X,P){const CA=P<16384,BA=T>L?L:T;let mA=1,NA,WA;for(;mA<=BA;)mA<<=1;for(mA>>=1,NA=mA,mA>>=1;mA>=1;){WA=0;const jA=WA+X*(L-NA),zA=X*mA,he=X*NA,ge=AA*mA,pe=AA*NA;let ze,_t,si,Sg;for(;WA<=jA;WA+=he){let xt=WA;const at=WA+AA*(T-NA);for(;xt<=at;xt+=pe){const Ti=xt+ge,Qo=xt+zA,Ag=Qo+ge;CA?(D(S[xt+F],S[Qo+F]),ze=p.a,si=p.b,D(S[Ti+F],S[Ag+F]),_t=p.a,Sg=p.b,D(ze,_t),S[xt+F]=p.a,S[Ti+F]=p.b,D(si,Sg),S[Qo+F]=p.a,S[Ag+F]=p.b):(y(S[xt+F],S[Qo+F]),ze=p.a,si=p.b,y(S[Ti+F],S[Ag+F]),_t=p.a,Sg=p.b,y(ze,_t),S[xt+F]=p.a,S[Ti+F]=p.b,y(si,Sg),S[Qo+F]=p.a,S[Ag+F]=p.b)}if(T&mA){const Ti=xt+zA;CA?D(S[xt+F],S[Ti+F]):y(S[xt+F],S[Ti+F]),ze=p.a,S[Ti+F]=p.b,S[xt+F]=ze}}if(L&mA){let xt=WA;const at=WA+AA*(T-NA);for(;xt<=at;xt+=pe){const Ti=xt+ge;CA?D(S[xt+F],S[Ti+F]):y(S[xt+F],S[Ti+F]),ze=p.a,S[Ti+F]=p.b,S[xt+F]=ze}}NA=mA,mA>>=1}return WA}function G(S,F,T,AA,L,X,P,CA,BA){let mA=0,NA=0;const WA=P,jA=Math.trunc(AA.value+(L+7)/8);for(;AA.value<jA;)for(h(mA,NA,T,AA),mA=E.c,NA=E.lc;NA>=14;){const he=mA>>NA-14&16383,ge=F[he];if(ge.len)NA-=ge.len,d(ge.lit,X,mA,NA,T,AA,CA,BA,WA),mA=l.c,NA=l.lc;else{if(!ge.p)throw new Error("hufDecode issues");let pe;for(pe=0;pe<ge.lit;pe++){const ze=C(S[ge.p[pe]]);for(;NA<ze&&AA.value<jA;)h(mA,NA,T,AA),mA=E.c,NA=E.lc;if(NA>=ze&&r(S[ge.p[pe]])==(mA>>NA-ze&(1<<ze)-1)){NA-=ze,d(ge.p[pe],X,mA,NA,T,AA,CA,BA,WA),mA=l.c,NA=l.lc;break}}if(pe==ge.lit)throw new Error("hufDecode issues")}}const zA=8-L&7;for(mA>>=zA,NA-=zA;NA>0;){const he=F[mA<<14-NA&16383];if(he.len)NA-=he.len,d(he.lit,X,mA,NA,T,AA,CA,BA,WA),mA=l.c,NA=l.lc;else throw new Error("hufDecode issues")}return!0}function R(S,F,T,AA,L,X){const P={value:0},CA=T.value,BA=dA(F,T),mA=dA(F,T);T.value+=4;const NA=dA(F,T);if(T.value+=4,BA<0||BA>=65537||mA<0||mA>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const WA=new Array(65537),jA=new Array(16384);g(jA);const zA=AA-(T.value-CA);if(n(S,T,zA,BA,mA,WA),NA>8*(AA-(T.value-CA)))throw new Error("Something wrong with hufUncompress");Q(WA,BA,mA,jA),G(WA,jA,S,T,NA,mA,X,L,P)}function N(S,F,T){for(let AA=0;AA<T;++AA)F[AA]=S[F[AA]]}function m(S){for(let F=1;F<S.length;F++){const T=S[F-1]+S[F]-128;S[F]=T}}function U(S,F){let T=0,AA=Math.floor((S.length+1)/2),L=0;const X=S.length-1;for(;!(L>X||(F[L++]=S[T++],L>X));)F[L++]=S[AA++]}function q(S){let F=S.byteLength;const T=new Array;let AA=0;const L=new DataView(S);for(;F>0;){const X=L.getInt8(AA++);if(X<0){const P=-X;F-=P+1;for(let CA=0;CA<P;CA++)T.push(L.getUint8(AA++))}else{const P=X;F-=2;const CA=L.getUint8(AA++);for(let BA=0;BA<P+1;BA++)T.push(CA)}}return T}function Y(S,F,T,AA,L,X){let P=new DataView(X.buffer);const CA=T[S.idx[0]].width,BA=T[S.idx[0]].height,mA=3,NA=Math.floor(CA/8),WA=Math.ceil(CA/8),jA=Math.ceil(BA/8),zA=CA-(WA-1)*8,he=BA-(jA-1)*8,ge={value:0},pe=new Array(mA),ze=new Array(mA),_t=new Array(mA),si=new Array(mA),Sg=new Array(mA);for(let at=0;at<mA;++at)Sg[at]=F[S.idx[at]],pe[at]=at<1?0:pe[at-1]+WA*jA,ze[at]=new Float32Array(64),_t[at]=new Uint16Array(64),si[at]=new Uint16Array(WA*64);for(let at=0;at<jA;++at){let Ti=8;at==jA-1&&(Ti=he);let Qo=8;for(let x=0;x<WA;++x){x==WA-1&&(Qo=zA);for(let gA=0;gA<mA;++gA)_t[gA].fill(0),_t[gA][0]=L[pe[gA]++],J(ge,AA,_t[gA]),O(_t[gA],ze[gA]),b(ze[gA]);v(ze);for(let gA=0;gA<mA;++gA)_(ze[gA],si[gA],x*64)}let Ag=0;for(let x=0;x<mA;++x){const gA=T[S.idx[x]].type;for(let cA=8*at;cA<8*at+Ti;++cA){Ag=Sg[x][cA];for(let uA=0;uA<NA;++uA){const rA=uA*64+(cA&7)*8;P.setUint16(Ag+0*2*gA,si[x][rA+0],!0),P.setUint16(Ag+1*2*gA,si[x][rA+1],!0),P.setUint16(Ag+2*2*gA,si[x][rA+2],!0),P.setUint16(Ag+3*2*gA,si[x][rA+3],!0),P.setUint16(Ag+4*2*gA,si[x][rA+4],!0),P.setUint16(Ag+5*2*gA,si[x][rA+5],!0),P.setUint16(Ag+6*2*gA,si[x][rA+6],!0),P.setUint16(Ag+7*2*gA,si[x][rA+7],!0),Ag+=8*2*gA}}if(NA!=WA)for(let cA=8*at;cA<8*at+Ti;++cA){const uA=Sg[x][cA]+8*NA*2*gA,rA=NA*64+(cA&7)*8;for(let XA=0;XA<Qo;++XA)P.setUint16(uA+XA*2*gA,si[x][rA+XA],!0)}}}const xt=new Uint16Array(CA);P=new DataView(X.buffer);for(let at=0;at<mA;++at){T[S.idx[at]].decoded=!0;const Ti=T[S.idx[at]].type;if(T[at].type==2)for(let Qo=0;Qo<BA;++Qo){const Ag=Sg[at][Qo];for(let x=0;x<CA;++x)xt[x]=P.getUint16(Ag+x*2*Ti,!0);for(let x=0;x<CA;++x)P.setFloat32(Ag+x*2*Ti,DA(xt[x]),!0)}}}function J(S,F,T){let AA,L=1;for(;L<64;)AA=F[S.value],AA==65280?L=64:AA>>8==255?L+=AA&255:(T[L]=AA,L++),S.value++}function O(S,F){F[0]=DA(S[0]),F[1]=DA(S[1]),F[2]=DA(S[5]),F[3]=DA(S[6]),F[4]=DA(S[14]),F[5]=DA(S[15]),F[6]=DA(S[27]),F[7]=DA(S[28]),F[8]=DA(S[2]),F[9]=DA(S[4]),F[10]=DA(S[7]),F[11]=DA(S[13]),F[12]=DA(S[16]),F[13]=DA(S[26]),F[14]=DA(S[29]),F[15]=DA(S[42]),F[16]=DA(S[3]),F[17]=DA(S[8]),F[18]=DA(S[12]),F[19]=DA(S[17]),F[20]=DA(S[25]),F[21]=DA(S[30]),F[22]=DA(S[41]),F[23]=DA(S[43]),F[24]=DA(S[9]),F[25]=DA(S[11]),F[26]=DA(S[18]),F[27]=DA(S[24]),F[28]=DA(S[31]),F[29]=DA(S[40]),F[30]=DA(S[44]),F[31]=DA(S[53]),F[32]=DA(S[10]),F[33]=DA(S[19]),F[34]=DA(S[23]),F[35]=DA(S[32]),F[36]=DA(S[39]),F[37]=DA(S[45]),F[38]=DA(S[52]),F[39]=DA(S[54]),F[40]=DA(S[20]),F[41]=DA(S[22]),F[42]=DA(S[33]),F[43]=DA(S[38]),F[44]=DA(S[46]),F[45]=DA(S[51]),F[46]=DA(S[55]),F[47]=DA(S[60]),F[48]=DA(S[21]),F[49]=DA(S[34]),F[50]=DA(S[37]),F[51]=DA(S[47]),F[52]=DA(S[50]),F[53]=DA(S[56]),F[54]=DA(S[59]),F[55]=DA(S[61]),F[56]=DA(S[35]),F[57]=DA(S[36]),F[58]=DA(S[48]),F[59]=DA(S[49]),F[60]=DA(S[57]),F[61]=DA(S[58]),F[62]=DA(S[62]),F[63]=DA(S[63])}function b(S){const F=.5*Math.cos(.7853975),T=.5*Math.cos(3.14159/16),AA=.5*Math.cos(3.14159/8),L=.5*Math.cos(3*3.14159/16),X=.5*Math.cos(5*3.14159/16),P=.5*Math.cos(3*3.14159/8),CA=.5*Math.cos(7*3.14159/16),BA=new Array(4),mA=new Array(4),NA=new Array(4),WA=new Array(4);for(let jA=0;jA<8;++jA){const zA=jA*8;BA[0]=AA*S[zA+2],BA[1]=P*S[zA+2],BA[2]=AA*S[zA+6],BA[3]=P*S[zA+6],mA[0]=T*S[zA+1]+L*S[zA+3]+X*S[zA+5]+CA*S[zA+7],mA[1]=L*S[zA+1]-CA*S[zA+3]-T*S[zA+5]-X*S[zA+7],mA[2]=X*S[zA+1]-T*S[zA+3]+CA*S[zA+5]+L*S[zA+7],mA[3]=CA*S[zA+1]-X*S[zA+3]+L*S[zA+5]-T*S[zA+7],NA[0]=F*(S[zA+0]+S[zA+4]),NA[3]=F*(S[zA+0]-S[zA+4]),NA[1]=BA[0]+BA[3],NA[2]=BA[1]-BA[2],WA[0]=NA[0]+NA[1],WA[1]=NA[3]+NA[2],WA[2]=NA[3]-NA[2],WA[3]=NA[0]-NA[1],S[zA+0]=WA[0]+mA[0],S[zA+1]=WA[1]+mA[1],S[zA+2]=WA[2]+mA[2],S[zA+3]=WA[3]+mA[3],S[zA+4]=WA[3]-mA[3],S[zA+5]=WA[2]-mA[2],S[zA+6]=WA[1]-mA[1],S[zA+7]=WA[0]-mA[0]}for(let jA=0;jA<8;++jA)BA[0]=AA*S[16+jA],BA[1]=P*S[16+jA],BA[2]=AA*S[48+jA],BA[3]=P*S[48+jA],mA[0]=T*S[8+jA]+L*S[24+jA]+X*S[40+jA]+CA*S[56+jA],mA[1]=L*S[8+jA]-CA*S[24+jA]-T*S[40+jA]-X*S[56+jA],mA[2]=X*S[8+jA]-T*S[24+jA]+CA*S[40+jA]+L*S[56+jA],mA[3]=CA*S[8+jA]-X*S[24+jA]+L*S[40+jA]-T*S[56+jA],NA[0]=F*(S[jA]+S[32+jA]),NA[3]=F*(S[jA]-S[32+jA]),NA[1]=BA[0]+BA[3],NA[2]=BA[1]-BA[2],WA[0]=NA[0]+NA[1],WA[1]=NA[3]+NA[2],WA[2]=NA[3]-NA[2],WA[3]=NA[0]-NA[1],S[0+jA]=WA[0]+mA[0],S[8+jA]=WA[1]+mA[1],S[16+jA]=WA[2]+mA[2],S[24+jA]=WA[3]+mA[3],S[32+jA]=WA[3]-mA[3],S[40+jA]=WA[2]-mA[2],S[48+jA]=WA[1]-mA[1],S[56+jA]=WA[0]-mA[0]}function v(S){for(let F=0;F<64;++F){const T=S[0][F],AA=S[1][F],L=S[2][F];S[0][F]=T+1.5747*L,S[1][F]=T-.1873*AA-.4682*L,S[2][F]=T+1.8556*AA}}function _(S,F,T){for(let AA=0;AA<64;++AA)F[T+AA]=iQ.toHalfFloat(Z(S[AA]))}function Z(S){return S<=1?Math.sign(S)*Math.pow(Math.abs(S),2.2):Math.sign(S)*Math.pow(e,Math.abs(S)-1)}function V(S){return new DataView(S.array.buffer,S.offset.value,S.size)}function IA(S){const F=S.viewer.buffer.slice(S.offset.value,S.offset.value+S.size),T=new Uint8Array(q(F)),AA=new Uint8Array(T.length);return m(T),U(T,AA),new DataView(AA.buffer)}function yA(S){const F=S.array.slice(S.offset.value,S.offset.value+S.size),T=tp(F),AA=new Uint8Array(T.length);return m(T),U(T,AA),new DataView(AA.buffer)}function vA(S){const F=S.viewer,T={value:S.offset.value},AA=new Uint16Array(S.width*S.scanlineBlockSize*(S.channels*S.type)),L=new Uint8Array(8192);let X=0;const P=new Array(S.channels);for(let he=0;he<S.channels;he++)P[he]={},P[he].start=X,P[he].end=P[he].start,P[he].nx=S.width,P[he].ny=S.lines,P[he].size=S.type,X+=P[he].nx*P[he].ny*P[he].size;const CA=Ae(F,T),BA=Ae(F,T);if(BA>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(CA<=BA)for(let he=0;he<BA-CA+1;he++)L[he+CA]=_A(F,T);const mA=new Uint16Array(65536),NA=i(L,mA),WA=dA(F,T);R(S.array,F,T,WA,AA,X);for(let he=0;he<S.channels;++he){const ge=P[he];for(let pe=0;pe<P[he].size;++pe)k(AA,ge.start+pe,ge.nx,ge.size,ge.ny,ge.nx*ge.size,NA)}N(mA,AA,X);let jA=0;const zA=new Uint8Array(AA.buffer.byteLength);for(let he=0;he<S.lines;he++)for(let ge=0;ge<S.channels;ge++){const pe=P[ge],ze=pe.nx*pe.size,_t=new Uint8Array(AA.buffer,pe.end*2,ze*2);zA.set(_t,jA),jA+=ze*2,pe.end+=ze}return new DataView(zA.buffer)}function sA(S){const F=S.array.slice(S.offset.value,S.offset.value+S.size),T=tp(F),AA=S.lines*S.channels*S.width,L=S.type==1?new Uint16Array(AA):new Uint32Array(AA);let X=0,P=0;const CA=new Array(4);for(let BA=0;BA<S.lines;BA++)for(let mA=0;mA<S.channels;mA++){let NA=0;switch(S.type){case 1:CA[0]=X,CA[1]=CA[0]+S.width,X=CA[1]+S.width;for(let WA=0;WA<S.width;++WA){const jA=T[CA[0]++]<<8|T[CA[1]++];NA+=jA,L[P]=NA,P++}break;case 2:CA[0]=X,CA[1]=CA[0]+S.width,CA[2]=CA[1]+S.width,X=CA[2]+S.width;for(let WA=0;WA<S.width;++WA){const jA=T[CA[0]++]<<24|T[CA[1]++]<<16|T[CA[2]++]<<8;NA+=jA,L[P]=NA,P++}break}}return new DataView(L.buffer)}function SA(S){const F=S.viewer,T={value:S.offset.value},AA=new Uint8Array(S.width*S.lines*(S.channels*S.type*2)),L={version:UA(F,T),unknownUncompressedSize:UA(F,T),unknownCompressedSize:UA(F,T),acCompressedSize:UA(F,T),dcCompressedSize:UA(F,T),rleCompressedSize:UA(F,T),rleUncompressedSize:UA(F,T),rleRawSize:UA(F,T),totalAcUncompressedCount:UA(F,T),totalDcUncompressedCount:UA(F,T),acCompression:UA(F,T)};if(L.version<2)throw new Error("EXRLoader.parse: "+Ze.compression+" version "+L.version+" is unsupported");const X=new Array;let P=Ae(F,T)-2;for(;P>0;){const ge=FA(F.buffer,T),pe=_A(F,T),ze=pe>>2&3,_t=(pe>>4)-1,si=new Int8Array([_t])[0],Sg=_A(F,T);X.push({name:ge,index:si,type:Sg,compression:ze}),P-=ge.length+3}const CA=Ze.channels,BA=new Array(S.channels);for(let ge=0;ge<S.channels;++ge){const pe=BA[ge]={},ze=CA[ge];pe.name=ze.name,pe.compression=0,pe.decoded=!1,pe.type=ze.pixelType,pe.pLinear=ze.pLinear,pe.width=S.width,pe.height=S.lines}const mA={idx:new Array(3)};for(let ge=0;ge<S.channels;++ge){const pe=BA[ge];for(let ze=0;ze<X.length;++ze){const _t=X[ze];pe.name==_t.name&&(pe.compression=_t.compression,_t.index>=0&&(mA.idx[_t.index]=ge),pe.offset=ge)}}let NA,WA,jA;if(L.acCompressedSize>0)switch(L.acCompression){case 0:NA=new Uint16Array(L.totalAcUncompressedCount),R(S.array,F,T,L.acCompressedSize,NA,L.totalAcUncompressedCount);break;case 1:const ge=S.array.slice(T.value,T.value+L.totalAcUncompressedCount),pe=tp(ge);NA=new Uint16Array(pe.buffer),T.value+=L.totalAcUncompressedCount;break}if(L.dcCompressedSize>0){const ge={array:S.array,offset:T,size:L.dcCompressedSize};WA=new Uint16Array(yA(ge).buffer),T.value+=L.dcCompressedSize}if(L.rleRawSize>0){const ge=S.array.slice(T.value,T.value+L.rleCompressedSize),pe=tp(ge);jA=q(pe.buffer),T.value+=L.rleCompressedSize}let zA=0;const he=new Array(BA.length);for(let ge=0;ge<he.length;++ge)he[ge]=new Array;for(let ge=0;ge<S.lines;++ge)for(let pe=0;pe<BA.length;++pe)he[pe].push(zA),zA+=BA[pe].width*S.type*2;Y(mA,he,BA,NA,WA,AA);for(let ge=0;ge<BA.length;++ge){const pe=BA[ge];if(!pe.decoded)switch(pe.compression){case 2:let ze=0,_t=0;for(let si=0;si<S.lines;++si){let Sg=he[ge][ze];for(let xt=0;xt<pe.width;++xt){for(let at=0;at<2*pe.type;++at)AA[Sg++]=jA[_t+at*pe.width*pe.height];_t++}ze++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(AA.buffer)}function FA(S,F){const T=new Uint8Array(S);let AA=0;for(;T[F.value+AA]!=0;)AA+=1;const L=new TextDecoder().decode(T.slice(F.value,F.value+AA));return F.value=F.value+AA+1,L}function VA(S,F,T){const AA=new TextDecoder().decode(new Uint8Array(S).slice(F.value,F.value+T));return F.value=F.value+T,AA}function $A(S,F){const T=se(S,F),AA=dA(S,F);return[T,AA]}function JA(S,F){const T=dA(S,F),AA=dA(S,F);return[T,AA]}function se(S,F){const T=S.getInt32(F.value,!0);return F.value=F.value+4,T}function dA(S,F){const T=S.getUint32(F.value,!0);return F.value=F.value+4,T}function j(S,F){const T=S[F.value];return F.value=F.value+1,T}function _A(S,F){const T=S.getUint8(F.value);return F.value=F.value+1,T}const UA=function(S,F){let T;return"getBigInt64"in DataView.prototype?T=Number(S.getBigInt64(F.value,!0)):T=S.getUint32(F.value+4,!0)+Number(S.getUint32(F.value,!0)<<32),F.value+=8,T};function RA(S,F){const T=S.getFloat32(F.value,!0);return F.value+=4,T}function OA(S,F){return iQ.toHalfFloat(RA(S,F))}function DA(S){const F=(S&31744)>>10,T=S&1023;return(S>>15?-1:1)*(F?F===31?T?NaN:1/0:Math.pow(2,F-15)*(1+T/1024):6103515625e-14*(T/1024))}function Ae(S,F){const T=S.getUint16(F.value,!0);return F.value+=2,T}function ae(S,F){return DA(Ae(S,F))}function fe(S,F,T,AA){const L=T.value,X=[];for(;T.value<L+AA-1;){const P=FA(F,T),CA=se(S,T),BA=_A(S,T);T.value+=3;const mA=se(S,T),NA=se(S,T);X.push({name:P,pixelType:CA,pLinear:BA,xSampling:mA,ySampling:NA})}return T.value+=1,X}function H(S,F){const T=RA(S,F),AA=RA(S,F),L=RA(S,F),X=RA(S,F),P=RA(S,F),CA=RA(S,F),BA=RA(S,F),mA=RA(S,F);return{redX:T,redY:AA,greenX:L,greenY:X,blueX:P,blueY:CA,whiteX:BA,whiteY:mA}}function K(S,F){const T=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],AA=_A(S,F);return T[AA]}function QA(S,F){const T=dA(S,F),AA=dA(S,F),L=dA(S,F),X=dA(S,F);return{xMin:T,yMin:AA,xMax:L,yMax:X}}function MA(S,F){const T=["INCREASING_Y"],AA=_A(S,F);return T[AA]}function xA(S,F){const T=RA(S,F),AA=RA(S,F);return[T,AA]}function bA(S,F){const T=RA(S,F),AA=RA(S,F),L=RA(S,F);return[T,AA,L]}function ce(S,F,T,AA,L){if(AA==="string"||AA==="stringvector"||AA==="iccProfile")return VA(F,T,L);if(AA==="chlist")return fe(S,F,T,L);if(AA==="chromaticities")return H(S,T);if(AA==="compression")return K(S,T);if(AA==="box2i")return QA(S,T);if(AA==="lineOrder")return MA(S,T);if(AA==="float")return RA(S,T);if(AA==="v2f")return xA(S,T);if(AA==="v3f")return bA(S,T);if(AA==="int")return se(S,T);if(AA==="rational")return $A(S,T);if(AA==="timecode")return JA(S,T);if(AA==="preview")return T.value+=L,"skipped";T.value+=L}function ne(S,F,T){const AA={};if(S.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");AA.version=S.getUint8(4);const L=S.getUint8(5);AA.spec={singleTile:!!(L&2),longName:!!(L&4),deepFormat:!!(L&8),multiPart:!!(L&16)},T.value=8;let X=!0;for(;X;){const P=FA(F,T);if(P==0)X=!1;else{const CA=FA(F,T),BA=dA(S,T),mA=ce(S,F,T,CA,BA);mA===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${CA}'.`):AA[P]=mA}}if(L&-5)throw console.error("THREE.EXRHeader:",AA),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return AA}function TA(S,F,T,AA,L){const X={size:0,viewer:F,array:T,offset:AA,width:S.dataWindow.xMax-S.dataWindow.xMin+1,height:S.dataWindow.yMax-S.dataWindow.yMin+1,channels:S.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:S.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:mt};switch(S.compression){case"NO_COMPRESSION":X.lines=1,X.uncompress=V;break;case"RLE_COMPRESSION":X.lines=1,X.uncompress=IA;break;case"ZIPS_COMPRESSION":X.lines=1,X.uncompress=yA;break;case"ZIP_COMPRESSION":X.lines=16,X.uncompress=yA;break;case"PIZ_COMPRESSION":X.lines=32,X.uncompress=vA;break;case"PXR24_COMPRESSION":X.lines=16,X.uncompress=sA;break;case"DWAA_COMPRESSION":X.lines=32,X.uncompress=SA;break;case"DWAB_COMPRESSION":X.lines=256,X.uncompress=SA;break;default:throw new Error("EXRLoader.parse: "+S.compression+" is unsupported")}if(X.scanlineBlockSize=X.lines,X.type==1)switch(L){case $t:X.getter=ae,X.inputSize=2;break;case di:X.getter=Ae,X.inputSize=2;break}else if(X.type==2)switch(L){case $t:X.getter=RA,X.inputSize=4;break;case di:X.getter=OA,X.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+X.type+" for "+S.compression+".");X.blockCount=(S.dataWindow.yMax+1)/X.scanlineBlockSize;for(let CA=0;CA<X.blockCount;CA++)UA(F,AA);X.outputChannels=X.channels==3?4:X.channels;const P=X.width*X.height*X.outputChannels;switch(L){case $t:X.byteArray=new Float32Array(P),X.channels<X.outputChannels&&X.byteArray.fill(1,0,P);break;case di:X.byteArray=new Uint16Array(P),X.channels<X.outputChannels&&X.byteArray.fill(15360,0,P);break;default:console.error("THREE.EXRLoader: unsupported type: ",L);break}return X.bytesPerLine=X.width*X.inputSize*X.channels,X.outputChannels==4?(X.format=St,X.colorSpace=mt):(X.format=Aa,X.colorSpace=TI),X}const HA=new DataView(A),we=new Uint8Array(A),LA={value:0},Ze=ne(HA,A,LA),qA=TA(Ze,HA,we,LA,this.type),ue={value:0},Ce={R:0,G:1,B:2,A:3,Y:0};for(let S=0;S<qA.height/qA.scanlineBlockSize;S++){const F=dA(HA,LA);qA.size=dA(HA,LA),qA.lines=F+qA.scanlineBlockSize>qA.height?qA.height-F:qA.scanlineBlockSize;const T=qA.size<qA.lines*qA.bytesPerLine?qA.uncompress(qA):V(qA);LA.value+=qA.size;for(let AA=0;AA<qA.scanlineBlockSize;AA++){const L=AA+S*qA.scanlineBlockSize;if(L>=qA.height)break;for(let X=0;X<qA.channels;X++){const P=Ce[Ze.channels[X].name];for(let CA=0;CA<qA.width;CA++){ue.value=(AA*(qA.channels*qA.width)+X*qA.width+CA)*qA.inputSize;const BA=(qA.height-1-L)*(qA.width*qA.outputChannels)+CA*qA.outputChannels+P;qA.byteArray[BA]=qA.getter(T,ue)}}}}return{header:Ze,width:qA.width,height:qA.height,data:qA.byteArray,format:qA.format,colorSpace:qA.colorSpace,type:this.type}}setDataType(A){return this.type=A,this}load(A,e,i,g){function I(o,s){o.colorSpace=s.colorSpace,o.minFilter=ke,o.magFilter=ke,o.generateMipmaps=!1,o.flipY=!1,e&&e(o,s)}return super.load(A,I,i,g)}}const QEA=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:Np},Symbol.toStringTag,{value:"Module"}));class Hm extends eU{constructor(A){super(A),this.type=di}parse(A){const e=function(c,u){switch(c){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(u||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(u||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(u||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(u||""))}},i=`
|
|
5239
5239
|
`,g=function(c,u,p){u=u||1024;let D=c.pos,y=-1,k=0,G="",R=String.fromCharCode.apply(null,new Uint16Array(c.subarray(D,D+128)));for(;0>(y=R.indexOf(i))&&k<u&&D<c.byteLength;)G+=R,k+=R.length,D+=128,R+=String.fromCharCode.apply(null,new Uint16Array(c.subarray(D,D+128)));return-1<y?(p!==!1&&(c.pos+=k+y+1),G+R.slice(0,y)):!1},I=function(c){const u=/^#\?(\S+)/,p=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,D=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*FORMAT=(\S+)\s*$/,k=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,G={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let R,N;for((c.pos>=c.byteLength||!(R=g(c)))&&e(1,"no header found"),(N=R.match(u))||e(3,"bad initial token"),G.valid|=1,G.programtype=N[1],G.string+=R+`
|
|
5240
5240
|
`;R=g(c),R!==!1;){if(G.string+=R+`
|