@needle-tools/engine 3.45.1-beta.6 → 3.45.1-beta.7
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 +5 -0
- package/dist/needle-engine.js +13 -9
- package/dist/needle-engine.light.js +13 -9
- package/dist/needle-engine.light.min.js +3 -2
- package/dist/needle-engine.light.umd.cjs +3 -2
- package/dist/needle-engine.min.js +3 -2
- package/dist/needle-engine.umd.cjs +23 -22
- package/lib/engine/engine_element.js +1 -0
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +7 -5
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/package.json +1 -1
- package/plugins/common/npm.js +16 -0
- package/plugins/vite/index.js +2 -0
- package/plugins/vite/npm.js +8 -0
- package/src/engine/engine_element.ts +1 -0
- package/src/engine/xr/NeedleXRSession.ts +7 -5
|
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+e.toString())}const s=qa()||F1()&<();if((
|
|
|
4344
4344
|
#__vconsole .vc-mask {
|
|
4345
4345
|
overflow: hidden;
|
|
4346
4346
|
}
|
|
4347
|
-
`,Qo==null||Qo.prepend(i),s===!0&&hD()<=0&&O5(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function nne(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ko==null||Ko.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function sne(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function rne(){const s=document.querySelector("#__vconsole");return s||null}const F5=ie("debugdefines");Ry('if(!globalThis[""3.45.1-beta.
|
|
4347
|
+
`,Qo==null||Qo.prepend(i),s===!0&&hD()<=0&&O5(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function nne(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ko==null||Ko.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function sne(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function rne(){const s=document.querySelector("#__vconsole");return s||null}const F5=ie("debugdefines");Ry('if(!globalThis[""3.45.1-beta.7""]) globalThis[""3.45.1-beta.7""] = "0.0.0";');Ry('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Ry('if(!globalThis[""Tue Jul 16 2024 16:20:17 GMT+0200 (Central European Summer Time)""]) globalThis[""Tue Jul 16 2024 16:20:17 GMT+0200 (Central European Summer Time)""] = "unknown";');Ry('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.1-beta.7";');Ry('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Ry('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Jul 16 2024 16:20:17 GMT+0200 (Central European Summer Time)";');const La="3.45.1-beta.7",V1="undefined",jD="Tue Jul 16 2024 16:20:17 GMT+0200 (Central European Summer Time)";F5&&console.log(`Engine version: ${La} (generator: ${V1})
|
|
4348
4348
|
Project built at ${jD}`);const Bh="needle_isActiveInHierarchy",Tf="builtin_components",GA="needle_editor_guid";function Ry(s){try{(0,eval)(s)}catch(e){F5&&console.error(e)}}const one='<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>',ane=btoa(one),lne="data:image/svg+xml;base64,"+ane,cne=lne,hne=`<?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(hne);const une='<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>',dne=btoa(une),fne="data:image/svg+xml;charset=utf-8;base64,"+dne,pne=fne,Pa=ie("debuglicense");let Jf="basic";Pa&&console.log("License Type: "+Jf);function ed(){switch(Jf){case"pro":case"enterprise":return!0}return!1}function WD(){switch(Jf){case"indie":return!0}return!1}function Dh(){return ed()||WD()}const U5=[];function mne(s){if(ed()||WD())return s(!0);U5.push(s)}function gne(s){for(const e of U5)try{e(s)}catch{}}di.registerCallback(Ii.ContextRegistered,s=>{Ane(s.context),bne(),vne(s.context)});let td,RP=!1,fA="";async function yne(){if(td)return td;if(Jf==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+La+"&generator="+encodeURIComponent(V1),e=await fetch(s,{method:"GET"}).catch(t=>{Pa&&console.error("License check failed",t)});(e==null?void 0:e.status)===200?(RP=!1,Pa&&console.log("License check succeeded"),Jf="pro",gne(!0)):(e==null?void 0:e.status)===403?(RP=!0,fA=await e.text()):Pa&&console.log("License check failed with status "+(e==null?void 0:e.status))}catch(s){Pa&&console.error("License check failed",s)}else Pa&&console.log('Runtime license check is skipped because license is already applied as "'+Jf+'"')}td=yne();async function vne(s){function e(){const n=document.createElement("div");n.className="needle-forbidden",n.style.cssText=`
|
|
4349
4349
|
position: fixed;
|
|
4350
4350
|
top: 0;
|
|
@@ -5232,7 +5232,7 @@ a=extmap-allow-mixed`)!==-1){const r=n.sdp.split(`
|
|
|
5232
5232
|
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},s}()),Y3={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"},que=function(){function s(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=Y3,this.browser=qv.getBrowser(),this.browserVersion=qv.getVersion(),this.supports=function(){var e={browser:qv.isBrowserSupported(),webRTC:qv.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(Y3),e.audioVideo=!0;var i=void 0;try{i=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!i.ordered;try{i.binaryType="blob",e.binaryBlob=!qv.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{t&&t.close()}return e}(),this.pack=U3.pack,this.unpack=U3.unpack,this._dataCount=1}return s.prototype.noop=function(){},s.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},s.prototype.chunk=function(e){for(var t=[],i=e.size,n=Math.ceil(i/Si.chunkedMTU),r=0,o=0;o<i;){var a=Math.min(i,o+Si.chunkedMTU),l=e.slice(o,a),c={__peerData:this._dataCount,n:r,data:l,total:n};t.push(c),o=a,r++}return this._dataCount++,t},s.prototype.blobToArrayBuffer=function(e,t){var i=new FileReader;return i.onload=function(n){n.target&&t(n.target.result)},i.readAsArrayBuffer(e),i},s.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i)&255;return t.buffer},s.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},s.prototype.isSecure=function(){return location.protocol==="https:"},s}(),Si=new que,C6={};Ic(C6,"Peer",()=>xB,s=>xB=s);var F_={},Xue=Object.prototype.hasOwnProperty,oo="~";function V0(){}Object.create&&(V0.prototype=Object.create(null),new V0().__proto__||(oo=!1));function Yue(s,e,t){this.fn=s,this.context=e,this.once=t||!1}function E6(s,e,t,i,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var r=new Yue(t,i||s,n),o=oo?oo+e:e;return s._events[o]?s._events[o].fn?s._events[o]=[s._events[o],r]:s._events[o].push(r):(s._events[o]=r,s._eventsCount++),s}function RS(s,e){--s._eventsCount===0?s._events=new V0:delete s._events[e]}function Lr(){this._events=new V0,this._eventsCount=0}Lr.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)Xue.call(t,i)&&e.push(oo?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Lr.prototype.listeners=function(e){var t=oo?oo+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n<r;n++)o[n]=i[n].fn;return o};Lr.prototype.listenerCount=function(e){var t=oo?oo+e:e,i=this._events[t];return i?i.fn?1:i.length:0};Lr.prototype.emit=function(e,t,i,n,r,o){var a=oo?oo+e:e;if(!this._events[a])return!1;var l=this._events[a],c=arguments.length,h,u;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,i),!0;case 4:return l.fn.call(l.context,t,i,n),!0;case 5:return l.fn.call(l.context,t,i,n,r),!0;case 6:return l.fn.call(l.context,t,i,n,r,o),!0}for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];l.fn.apply(l.context,h)}else{var f=l.length,p;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,i);break;case 4:l[u].fn.call(l[u].context,t,i,n);break;default:if(!h)for(p=1,h=new Array(c-1);p<c;p++)h[p-1]=arguments[p];l[u].fn.apply(l[u].context,h)}}return!0};Lr.prototype.on=function(e,t,i){return E6(this,e,t,i,!1)};Lr.prototype.once=function(e,t,i){return E6(this,e,t,i,!0)};Lr.prototype.removeListener=function(e,t,i,n){var r=oo?oo+e:e;if(!this._events[r])return this;if(!t)return RS(this,r),this;var o=this._events[r];if(o.fn)o.fn===t&&(!n||o.once)&&(!i||o.context===i)&&RS(this,r);else{for(var a=0,l=[],c=o.length;a<c;a++)(o[a].fn!==t||n&&!o[a].once||i&&o[a].context!==i)&&l.push(o[a]);l.length?this._events[r]=l.length===1?l[0]:l:RS(this,r)}return this};Lr.prototype.removeAllListeners=function(e){var t;return e?(t=oo?oo+e:e,this._events[t]&&RS(this,t)):(this._events=new V0,this._eventsCount=0),this};Lr.prototype.off=Lr.prototype.removeListener;Lr.prototype.addListener=Lr.prototype.on;Lr.prefixed=oo;Lr.EventEmitter=Lr;F_=Lr;var mt={};Ic(mt,"LogLevel",()=>mo,s=>mo=s);Ic(mt,"default",()=>K3,s=>K3=s);var hf=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},uf=function(s,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,r;i<n;i++)(r||!(i in e))&&(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return s.concat(r||Array.prototype.slice.call(e))},Kue="PeerJS: ",mo;(function(s){s[s.Disabled=0]="Disabled",s[s.Errors=1]="Errors",s[s.Warnings=2]="Warnings",s[s.All=3]="All"})(mo||(mo={}));var Jue=function(){function s(){this._logLevel=mo.Disabled}return Object.defineProperty(s.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),s.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=mo.All&&this._print.apply(this,uf([mo.All],hf(e),!1))},s.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=mo.Warnings&&this._print.apply(this,uf([mo.Warnings],hf(e),!1))},s.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=mo.Errors&&this._print.apply(this,uf([mo.Errors],hf(e),!1))},s.prototype.setLogFunction=function(e){this._print=e},s.prototype._print=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];var n=uf([Kue],hf(t),!1);for(var r in n)n[r]instanceof Error&&(n[r]="("+n[r].name+") "+n[r].message);e>=mo.All?console.log.apply(console,uf([],hf(n),!1)):e>=mo.Warnings?console.warn.apply(console,uf(["WARNING"],hf(n),!1)):e>=mo.Errors&&console.error.apply(console,uf(["ERROR"],hf(n),!1))},s}(),K3=new Jue,M6={};Ic(M6,"Socket",()=>J3,s=>J3=s);var vl;(function(s){s.Data="data",s.Media="media"})(vl||(vl={}));var Vn;(function(s){s.BrowserIncompatible="browser-incompatible",s.Disconnected="disconnected",s.InvalidID="invalid-id",s.InvalidKey="invalid-key",s.Network="network",s.PeerUnavailable="peer-unavailable",s.SslUnavailable="ssl-unavailable",s.ServerError="server-error",s.SocketError="socket-error",s.SocketClosed="socket-closed",s.UnavailableID="unavailable-id",s.WebRTC="webrtc"})(Vn||(Vn={}));var ch;(function(s){s.Binary="binary",s.BinaryUTF8="binary-utf8",s.JSON="json"})(ch||(ch={}));var Mh;(function(s){s.Message="message",s.Disconnected="disconnected",s.Error="error",s.Close="close"})(Mh||(Mh={}));var $s;(function(s){s.Heartbeat="HEARTBEAT",s.Candidate="CANDIDATE",s.Offer="OFFER",s.Answer="ANSWER",s.Open="OPEN",s.Error="ERROR",s.IdTaken="ID-TAKEN",s.InvalidKey="INVALID-KEY",s.Leave="LEAVE",s.Expire="EXPIRE"})($s||($s={}));var kO={};kO=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ückler <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>","Sören 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 Zue=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),$ue=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},ede=function(s,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,r;i<n;i++)(r||!(i in e))&&(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return s.concat(r||Array.prototype.slice.call(e))},tde=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},J3=function(s){Zue(e,s);function e(t,i,n,r,o,a){a===void 0&&(a=5e3);var l=s.call(this)||this;l.pingInterval=a,l._disconnected=!0,l._messagesQueue=[];var c=t?"wss://":"ws://";return l._baseUrl=c+i+":"+n+r+"peerjs?key="+o,l}return e.prototype.start=function(t,i){var n=this;this._id=t;var r="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(r+"&version="+kO.version),this._disconnected=!1,this._socket.onmessage=function(o){var a;try{a=JSON.parse(o.data),mt.default.log("Server message received:",a)}catch{mt.default.log("Invalid server message",o.data);return}n.emit(Mh.Message,a)},this._socket.onclose=function(o){n._disconnected||(mt.default.log("Socket closed.",o),n._cleanup(),n._disconnected=!0,n.emit(Mh.Disconnected))},this._socket.onopen=function(){n._disconnected||(n._sendQueuedMessages(),mt.default.log("Socket open"),n._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){mt.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:$s.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,i,n=ede([],$ue(this._messagesQueue),!1);this._messagesQueue=[];try{for(var r=tde(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.send(a)}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit(Mh.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(t);this._socket.send(i)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e}(F_.EventEmitter),_B={};Ic(_B,"MediaConnection",()=>ez,s=>ez=s);var FO={};Ic(FO,"Negotiator",()=>Z3,s=>Z3=s);var xC=function(){return xC=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},xC.apply(this,arguments)},gw=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{c(i.next(h))}catch(u){o(u)}}function l(h){try{c(i.throw(h))}catch(u){o(u)}}function c(h){h.done?r(h.value):n(h.value).then(a,l)}c((i=i.apply(s,e||[])).next())})},yw=function(s,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(r=c[0]&2?n.return:c[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,c[1])).done)return r;switch(n=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){t.label=c[1];break}if(c[0]===6&&t.label<r[1]){t.label=r[1],r=c;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(c);break}r[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(s,t)}catch(h){c=[6,h],n=0}finally{i=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Z3=function(){function s(e){this.connection=e}return s.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===vl.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===vl.Data){var i=this.connection,n={ordered:!!e.reliable},r=t.createDataChannel(i.label,n);i.initialize(r)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},s.prototype._startPeerConnection=function(){mt.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},s.prototype._setupListeners=function(e){var t=this,i=this.connection.peer,n=this.connection.connectionId,r=this.connection.type,o=this.connection.provider;mt.default.log("Listening for ICE candidates."),e.onicecandidate=function(a){!a.candidate||!a.candidate.candidate||(mt.default.log("Received ICE candidates for ".concat(i,":"),a.candidate),o.socket.send({type:$s.Candidate,payload:{candidate:a.candidate,type:r,connectionId:n},dst:i}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":mt.default.log("iceConnectionState is failed, closing connections to "+i),t.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),t.connection.close();break;case"closed":mt.default.log("iceConnectionState is closed, closing connections to "+i),t.connection.emit("error",new Error("Connection to "+i+" closed.")),t.connection.close();break;case"disconnected":mt.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":e.onicecandidate=Si.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},mt.default.log("Listening for data channel"),e.ondatachannel=function(a){mt.default.log("Received data channel");var l=a.channel,c=o.getConnection(i,n);c.initialize(l)},mt.default.log("Listening for remote stream"),e.ontrack=function(a){mt.default.log("Received remote stream");var l=a.streams[0],c=o.getConnection(i,n);if(c.type===vl.Media){var h=c;t._addStreamToMediaConnection(l,h)}}},s.prototype.cleanup=function(){mt.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",i=!1;if(this.connection.type===vl.Data){var n=this.connection,r=n.dataChannel;r&&(i=!!r.readyState&&r.readyState!=="closed")}(t||i)&&e.close()}},s.prototype._makeOffer=function(){return gw(this,void 0,Promise,function(){var e,t,i,n,r,o,a;return yw(this,function(l){switch(l.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,l.label=1;case 1:return l.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:i=l.sent(),mt.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),l.label=3;case 3:return l.trys.push([3,5,,6]),[4,e.setLocalDescription(i)];case 4:return l.sent(),mt.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),n={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:Si.browser},this.connection.type===vl.Data&&(r=this.connection,n=xC(xC({},n),{label:r.label,reliable:r.reliable,serialization:r.serialization})),t.socket.send({type:$s.Offer,payload:n,dst:this.connection.peer}),[3,6];case 5:return o=l.sent(),o!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(Vn.WebRTC,o),mt.default.log("Failed to setLocalDescription, ",o)),[3,6];case 6:return[3,8];case 7:return a=l.sent(),t.emitError(Vn.WebRTC,a),mt.default.log("Failed to createOffer, ",a),[3,8];case 8:return[2]}})})},s.prototype._makeAnswer=function(){return gw(this,void 0,Promise,function(){var e,t,i,n,r;return yw(this,function(o){switch(o.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,o.label=1;case 1:return o.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:i=o.sent(),mt.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,e.setLocalDescription(i)];case 4:return o.sent(),mt.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),t.socket.send({type:$s.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:Si.browser},dst:this.connection.peer}),[3,6];case 5:return n=o.sent(),t.emitError(Vn.WebRTC,n),mt.default.log("Failed to setLocalDescription, ",n),[3,6];case 6:return[3,8];case 7:return r=o.sent(),t.emitError(Vn.WebRTC,r),mt.default.log("Failed to create answer, ",r),[3,8];case 8:return[2]}})})},s.prototype.handleSDP=function(e,t){return gw(this,void 0,Promise,function(){var i,n,r,o;return yw(this,function(a){switch(a.label){case 0:t=new RTCSessionDescription(t),i=this.connection.peerConnection,n=this.connection.provider,mt.default.log("Setting remote description",t),r=this,a.label=1;case 1:return a.trys.push([1,5,,6]),[4,i.setRemoteDescription(t)];case 2:return a.sent(),mt.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,r._makeAnswer()];case 3:a.sent(),a.label=4;case 4:return[3,6];case 5:return o=a.sent(),n.emitError(Vn.WebRTC,o),mt.default.log("Failed to setRemoteDescription, ",o),[3,6];case 6:return[2]}})})},s.prototype.handleCandidate=function(e){return gw(this,void 0,Promise,function(){var t,i,n,r,o,a;return yw(this,function(l){switch(l.label){case 0:mt.default.log("handleCandidate:",e),t=e.candidate,i=e.sdpMLineIndex,n=e.sdpMid,r=this.connection.peerConnection,o=this.connection.provider,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,r.addIceCandidate(new RTCIceCandidate({sdpMid:n,sdpMLineIndex:i,candidate:t}))];case 2:return l.sent(),mt.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return a=l.sent(),o.emitError(Vn.WebRTC,a),mt.default.log("Failed to handleCandidate, ",a),[3,4];case 4:return[2]}})})},s.prototype._addTracksToConnection=function(e,t){if(mt.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return mt.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(i){t.addTrack(i,e)})},s.prototype._addStreamToMediaConnection=function(e,t){mt.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},s}(),UO={};Ic(UO,"BaseConnection",()=>$3,s=>$3=s);var ide=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),$3=function(s){ide(e,s);function e(t,i,n){var r=s.call(this)||this;return r.peer=t,r.provider=i,r.options=n,r._open=!1,r.metadata=n.metadata,r}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e}(F_.EventEmitter),nde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),wC=function(){return wC=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},wC.apply(this,arguments)},sde=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ez=function(s){nde(e,s);function e(t,i,n){var r=s.call(this,t,i,n)||this;return r._localStream=r.options._stream,r.connectionId=r.options.connectionId||e.ID_PREFIX+Si.randomToken(),r._negotiator=new FO.Negotiator(r),r._localStream&&r._negotiator.startConnection({_stream:r._localStream,originator:!0}),r}return Object.defineProperty(e.prototype,"type",{get:function(){return vl.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){mt.default.log("Receiving stream",t),this._remoteStream=t,s.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var i=t.type,n=t.payload;switch(t.type){case $s.Answer:this._negotiator.handleSDP(i,n.sdp),this._open=!0;break;case $s.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:mt.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,i){var n,r;if(i===void 0&&(i={}),this._localStream){mt.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(wC(wC({},this.options._payload),{_stream:t}));var o=this.provider._getMessages(this.connectionId);try{for(var a=sde(o),l=a.next();!l.done;l=a.next()){var c=l.value;this.handleMessage(c)}}catch(h){n={error:h}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,s.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e}(UO.BaseConnection),bB={};Ic(bB,"DataConnection",()=>iz,s=>iz=s);var T6={};Ic(T6,"EncodingQueue",()=>tz,s=>tz=s);var rde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),tz=function(s){rde(e,s);function e(){var t=s.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(i){t._processing=!1,i.target&&t.emit("done",i.target.result),t.doNextTask()},t.fileReader.onerror=function(i){mt.default.error("EncodingQueue error:",i),t._processing=!1,t.destroy(),t.emit("error",i)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e}(F_.EventEmitter),ode=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),ade=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},iz=function(s){ode(e,s);function e(t,i,n){var r=s.call(this,t,i,n)||this;return r.stringify=JSON.stringify,r.parse=JSON.parse,r._buffer=[],r._bufferSize=0,r._buffering=!1,r._chunkedData={},r._encodingQueue=new T6.EncodingQueue,r.connectionId=r.options.connectionId||e.ID_PREFIX+Si.randomToken(),r.label=r.options.label||r.connectionId,r.serialization=r.options.serialization||ch.Binary,r.reliable=!!r.options.reliable,r._encodingQueue.on("done",function(o){r._bufferedSend(o)}),r._encodingQueue.on("error",function(){mt.default.error("DC#".concat(r.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),r.close()}),r._negotiator=new FO.Negotiator(r),r._negotiator.startConnection(r.options._payload||{originator:!0}),r}return Object.defineProperty(e.prototype,"type",{get:function(){return vl.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!Si.supports.binaryBlob||Si.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){mt.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(i){mt.default.log("DC#".concat(t.connectionId," dc onmessage:"),i.data),t._handleDataMessage(i)},this.dataChannel.onclose=function(){mt.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var i=this,n=t.data,r=n.constructor,o=this.serialization===ch.Binary||this.serialization===ch.BinaryUTF8,a=n;if(o){if(r===Blob){Si.blobToArrayBuffer(n,function(c){var h=Si.unpack(c);i.emit("data",h)});return}else if(r===ArrayBuffer)a=Si.unpack(n);else if(r===String){var l=Si.binaryStringToArrayBuffer(n);a=Si.unpack(l)}}else this.serialization===ch.JSON&&(a=this.parse(n));if(a.__peerData){this._handleChunk(a);return}s.prototype.emit.call(this,"data",a)},e.prototype._handleChunk=function(t){var i=t.__peerData,n=this._chunkedData[i]||{data:[],count:0,total:t.total};if(n.data[t.n]=t.data,n.count++,this._chunkedData[i]=n,n.total===n.count){delete this._chunkedData[i];var r=new Blob(n.data);this._handleDataMessage({data:r})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,s.prototype.emit.call(this,"close"))},e.prototype.send=function(t,i){if(!this.open){s.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===ch.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===ch.Binary||this.serialization===ch.BinaryUTF8){var n=Si.pack(t);if(!i&&n.size>Si.chunkedMTU){this._sendChunks(n);return}Si.supports.binaryBlob?this._bufferedSend(n):this._encodingQueue.enque(n)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(n){return mt.default.error("DC#:".concat(this.connectionId," Error when sending:"),n),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var i,n,r=Si.chunk(t);mt.default.log("DC#".concat(this.connectionId," Try to send ").concat(r.length," chunks..."));try{for(var o=ade(r),a=o.next();!a.done;a=o.next()){var l=a.value;this.send(l,!0)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.handleMessage=function(t){var i=t.payload;switch(t.type){case $s.Answer:this._negotiator.handleSDP(t.type,i.sdp);break;case $s.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:mt.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e}(UO.BaseConnection),I6={};Ic(I6,"API",()=>rz,s=>rz=s);var nz=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{c(i.next(h))}catch(u){o(u)}}function l(h){try{c(i.throw(h))}catch(u){o(u)}}function c(h){h.done?r(h.value):n(h.value).then(a,l)}c((i=i.apply(s,e||[])).next())})},sz=function(s,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(r=c[0]&2?n.return:c[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,c[1])).done)return r;switch(n=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){t.label=c[1];break}if(c[0]===6&&t.label<r[1]){t.label=r[1],r=c;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(c);break}r[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(s,t)}catch(h){c=[6,h],n=0}finally{i=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},rz=function(){function s(e){this._options=e}return s.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",i=this._options,n=i.host,r=i.port,o=i.path,a=i.key,l=new URL("".concat(t,"://").concat(n,":").concat(r).concat(o).concat(a,"/").concat(e));return l.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),l.searchParams.set("version",kO.version),fetch(l.href,{referrerPolicy:this._options.referrerPolicy})},s.prototype.retrieveId=function(){return nz(this,void 0,Promise,function(){var e,t,i;return sz(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=n.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=n.sent(),mt.default.error("Error retrieving ID",t),i="",this._options.path==="/"&&this._options.host!==Si.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]}})})},s.prototype.listAllPeers=function(){return nz(this,void 0,Promise,function(){var e,t,i;return sz(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=n.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===Si.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw i=n.sent(),mt.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},s}(),lde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),ZA=function(){return ZA=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},ZA.apply(this,arguments)},Xv=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},cde=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},xB=function(s){lde(e,s);function e(t,i){var n=s.call(this)||this;n._id=null,n._lastServerId=null,n._destroyed=!1,n._disconnected=!1,n._open=!1,n._connections=new Map,n._lostMessages=new Map;var r;return t&&t.constructor==Object?i=t:t&&(r=t.toString()),i=ZA({debug:0,host:Si.CLOUD_HOST,port:Si.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:Si.randomToken(),config:Si.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),n._options=i,n._options.host==="/"&&(n._options.host=window.location.hostname),n._options.path&&(n._options.path[0]!=="/"&&(n._options.path="/"+n._options.path),n._options.path[n._options.path.length-1]!=="/"&&(n._options.path+="/")),n._options.secure===void 0&&n._options.host!==Si.CLOUD_HOST?n._options.secure=Si.isSecure():n._options.host==Si.CLOUD_HOST&&(n._options.secure=!0),n._options.logFunction&&mt.default.setLogFunction(n._options.logFunction),mt.default.logLevel=n._options.debug||0,n._api=new I6.API(i),n._socket=n._createServerConnection(),!Si.supports.audioVideo&&!Si.supports.data?(n._delayedAbort(Vn.BrowserIncompatible,"The current browser does not support WebRTC"),n):r&&!Si.validateId(r)?(n._delayedAbort(Vn.InvalidID,'ID "'.concat(r,'" is invalid')),n):(r?n._initialize(r):n._api.retrieveId().then(function(o){return n._initialize(o)}).catch(function(o){return n._abort(Vn.ServerError,o)}),n)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,i,n=Object.create(null);try{for(var r=Xv(this._connections),o=r.next();!o.done;o=r.next()){var a=cde(o.value,2),l=a[0],c=a[1];n[l]=c}}catch(h){t={error:h}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,i=new M6.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(Mh.Message,function(n){t._handleMessage(n)}),i.on(Mh.Error,function(n){t._abort(Vn.SocketError,n)}),i.on(Mh.Disconnected,function(){t.disconnected||(t.emitError(Vn.Network,"Lost connection to server."),t.disconnect())}),i.on(Mh.Close,function(){t.disconnected||t._abort(Vn.SocketClosed,"Underlying socket is already closed.")}),i},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var i,n,r=t.type,o=t.payload,a=t.src;switch(r){case $s.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case $s.Error:this._abort(Vn.ServerError,o.msg);break;case $s.IdTaken:this._abort(Vn.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case $s.InvalidKey:this._abort(Vn.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case $s.Leave:mt.default.log("Received leave message from ".concat(a)),this._cleanupPeer(a),this._connections.delete(a);break;case $s.Expire:this.emitError(Vn.PeerUnavailable,"Could not connect to peer ".concat(a));break;case $s.Offer:var m=o.connectionId,v=this.getConnection(a,m);if(v&&(v.close(),mt.default.warn("Offer received for existing Connection ID:".concat(m))),o.type===vl.Media){var l=new _B.MediaConnection(a,this,{connectionId:m,_payload:o,metadata:o.metadata});v=l,this._addConnection(a,v),this.emit("call",l)}else if(o.type===vl.Data){var c=new bB.DataConnection(a,this,{connectionId:m,_payload:o,metadata:o.metadata,label:o.label,serialization:o.serialization,reliable:o.reliable});v=c,this._addConnection(a,v),this.emit("connection",c)}else{mt.default.warn("Received malformed connection type:".concat(o.type));return}var h=this._getMessages(m);try{for(var u=Xv(h),f=u.next();!f.done;f=u.next()){var p=f.value;v.handleMessage(p)}}catch(g){i={error:g}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}break;default:if(!o){mt.default.warn("You received a malformed message from ".concat(a," of type ").concat(r));return}var m=o.connectionId,v=this.getConnection(a,m);v&&v.peerConnection?v.handleMessage(t):m?this._storeMessage(m,t):mt.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,i){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(i)},e.prototype._getMessages=function(t){var i=this._lostMessages.get(t);return i?(this._lostMessages.delete(t),i):[]},e.prototype.connect=function(t,i){if(i===void 0&&(i={}),this.disconnected){mt.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(Vn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var n=new bB.DataConnection(t,this,i);return this._addConnection(t,n),n},e.prototype.call=function(t,i,n){if(n===void 0&&(n={}),this.disconnected){mt.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(Vn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){mt.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var r=new _B.MediaConnection(t,this,ZA(ZA({},n),{_stream:i}));return this._addConnection(t,r),r},e.prototype._addConnection=function(t,i){mt.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(i)},e.prototype._removeConnection=function(t){var i=this._connections.get(t.peer);if(i){var n=i.indexOf(t);n!==-1&&i.splice(n,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,i){var n,r,o=this._connections.get(t);if(!o)return null;try{for(var a=Xv(o),l=a.next();!l.done;l=a.next()){var c=l.value;if(c.connectionId===i)return c}}catch(h){n={error:h}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return null},e.prototype._delayedAbort=function(t,i){var n=this;setTimeout(function(){n._abort(t,i)},0)},e.prototype._abort=function(t,i){mt.default.error("Aborting!"),this.emitError(t,i),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,i){mt.default.error("Error:",i);var n;typeof i=="string"?n=new Error(i):n=i,n.type=t,this.emit("error",n)},e.prototype.destroy=function(){this.destroyed||(mt.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,i;try{for(var n=Xv(this._connections.keys()),r=n.next();!r.done;r=n.next()){var o=r.value;this._cleanupPeer(o),this._connections.delete(o)}}catch(a){t={error:a}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var i,n,r=this._connections.get(t);if(r)try{for(var o=Xv(r),a=o.next();!a.done;a=o.next()){var l=a.value;l.close()}}catch(c){i={error:c}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;mt.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)mt.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)mt.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var i=this;t===void 0&&(t=function(n){}),this._api.listAllPeers().then(function(n){return t(n)}).catch(function(n){return i._abort(Vn.ServerError,n)})},e.DEFAULT_KEY="peerjs",e}(F_.EventEmitter),wB=C6.Peer;const hde=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return xB},default:wB,util:Si},Symbol.toStringTag,{value:"Module"}));let NO;function ude(){return NO}function dde(s){NO=s}function R6(s,e){return e||(e={}),e={...NO,...e},s?new wB(s,e):new wB(e)}async function oz(){const s=await Promise.resolve().then(()=>hde);return console.log(s),s.default===void 0?s:s.default}class P6{constructor(){d(this,"_host");d(this,"_client");d(this,"_clientData");this.onEnable()}get isHost(){return this._host!==void 0}onEnable(){const e="HOST-5980e65c-8438-453e-8b35-f13c736dcd81";this.trySetupHost(e)}async trySetupHost(e){const t=await oz(),i=new t(e);i.on("error",n=>{console.error(n),this._host=void 0,this.trySetupClient(e)}),i.on("open",n=>{this._host=new pde(i)})}async trySetupClient(e){const t=await oz();this._client=new t,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(e,{metadata:{id:i}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",n=>{console.log("<<",n)})})}}class fde{constructor(e){d(this,"_peer");this._peer=e}}class pde extends fde{constructor(t){var i;super(t);d(this,"_connections",[]);console.log("I AM THE HOST"),(i=this._peer)==null||i.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}get isHost(){return!0}onConnection(t){console.log("host connection",t),t.on("open",()=>{this._connections.push(t),this.broadcastConnection(t)})}broadcastConnection(t){const i=this._connections.map(n=>{var r;return(r=n.metadata)==null?void 0:r.id}).filter(n=>n!==void 0);this.broadcast({type:"connection-list",connections:i})}broadcast(t){if(t!=null){console.log(">>",t);for(const i in this._peer.connections){const n=this._peer.connections[i];if(n)if(Array.isArray(n))for(const r of n)r&&r.send(t);else console.warn(n)}}}}const az="https://urls.needle.tools/default-networking-backend/index";let wu="wss://needle-tiny-starter.glitch.me/socket";const Jr=!!ie("debugnet"),EA=!!(Jr||ie("debugowner")),lz=ie("debugnetbin");var B6=(s=>(s.ConnectionInfo="connection-start-info",s))(B6||{}),Xt=(s=>(s.Join="join-room",s.Leave="leave-room",s.JoinedRoom="joined-room",s.LeftRoom="left-room",s.UserJoinedRoom="user-joined-room",s.UserLeftRoom="user-left-room",s.RoomStateSent="room-state-sent",s))(Xt||{});class mde{constructor(){d(this,"room");d(this,"viewId");d(this,"allowEditing");d(this,"inRoom")}}class gde{constructor(){d(this,"room")}}class yde{constructor(){d(this,"userId")}}var D6=(s=>(s.RequestHasOwner="request-has-owner",s.ResponseHasOwner="response-has-owner",s.RequestIsOwner="request-is-owner",s.ResponseIsOwner="response-is-owner",s.RequestOwnership="request-ownership",s.GainedOwnership="gained-ownership",s.RemoveOwnership="remove-ownership",s.LostOwnership="lost-ownership",s.GainedOwnershipBroadcast="gained-ownership-broadcast",s.LostOwnershipBroadcast="lost-ownership-broadcast",s))(D6||{});class zO{constructor(e,t){d(this,"guid");d(this,"connection");d(this,"_hasOwnership",!1);d(this,"_isOwned");d(this,"_gainSubscription");d(this,"_lostSubscription");d(this,"_hasOwnerResponse");d(this,"_isWaitingForOwnershipResponseCallback",null);this.connection=e,this.guid=t,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),e.beginListen("lost-ownership",this._lostSubscription),e.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),e.beginListen("response-has-owner",this._hasOwnerResponse)}get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(e){e.guid===this.guid&&(this._isOwned=e.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(e){e.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=e.value,e.value||(EA&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((e,t)=>{this.requestOwnership();let i=0;const n=()=>{if(i++>10)return t("Timeout");setTimeout(()=>{this.hasOwnership?e(this):n()},100)};n()})}requestOwnership(){return EA&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(e){e.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===e.owner?(EA&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(e){e===this.guid&&(EA&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class O6{constructor(e){d(this,"context");d(this,"_peer",null);d(this,"_usersInRoomCopy",[]);d(this,"_defaultMessagesBuffer",[]);d(this,"_defaultMessagesBufferArray",[]);d(this,"netWebSocketUrlProvider");d(this,"_listeners",{});d(this,"_listenersBinary",{});d(this,"connected",!1);d(this,"channelId");d(this,"_connectionId",null);d(this,"_ws");d(this,"_waitingForSocket",{});d(this,"_isInRoom",!1);d(this,"_currentRoomName",null);d(this,"_currentRoomViewId",null);d(this,"_currentRoomAllowEditing",!0);d(this,"_currentInRoom",[]);d(this,"_state",{});d(this,"_currentDelay",-1);d(this,"_connectingToWebsocketPromise",null);this.context=e}get peer(){return this._peer||(this._peer=new P6),this._peer}tryGetState(e){return e==="invalid"?null:this._state[e]}get connectionId(){return this._connectionId}get isDebugEnabled(){return Jr}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const e=new URL(window.location.href);return e.searchParams.set("view",this.currentRoomViewId),e.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){var e;return((e=this._ws)==null?void 0:e.url)??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(e){return this._currentInRoom.indexOf(e)!==-1}usersInRoom(e=null){e||(e=this._usersInRoomCopy),e.length=0;for(const t of this._currentInRoom)e.push(t);return e}joinRoom(e,t=!1){return e?e.length>1024?(console.error('Room name too long, can not join: "'+e+'". Max length is 1024 characters.'),!1):(this.connect(),Jr&&console.log("join: "+e),this.send("join-room",{room:e,viewOnly:t},gl.OnConnection),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}leaveRoom(e=null){return e||(e=this.currentRoomName),e?(this.send("leave-room",{room:e}),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}send(e,t=null,i=gl.Queued){if(t===null&&(t={}),i===gl.Queued){this._defaultMessagesBuffer.push({key:e,value:t});return}return this.sendWithWebsocket(e,t,i)}sendDeleteRemoteState(e){this.send("delete-state",{guid:e,dontSave:!0}),delete this._state[e]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(e){var t;lz&&console.log("<< send binary",this.context.time.frame,e.length/1024+" KB"),(t=this._ws)==null||t.send(e)}sendBufferedMessagesNow(){var i;if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const e=Object.keys(this._defaultMessagesBuffer).length;for(const n in this._defaultMessagesBuffer){const r=this._defaultMessagesBuffer[n];if(e<=1){this.sendWithWebsocket(r.key,r.value,gl.Immediate);break}const o=this.toMessage(r.key,r.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&Jr&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const t=JSON.stringify(this._defaultMessagesBufferArray);(i=this._ws)==null||i.send(t)}beginListen(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),t}stopListening(e,t){return this.stopListen(e,t)}stopListen(e,t){if(!t||!this._listeners[e])return;const i=this._listeners[e].indexOf(t);i>=0&&this._listeners[e].splice(i,1)}beginListenBinary(e,t){return this._listenersBinary[e]||(this._listenersBinary[e]=[]),this._listenersBinary[e].push(t),t}stopListenBinary(e,t){if(!this._listenersBinary[e])return;const i=this._listenersBinary[e].indexOf(t);i>=0&&this._listenersBinary[e].splice(i,1)}registerProvider(e){this.netWebSocketUrlProvider=e}async connect(){var t;if(this.connected)return Promise.resolve(!0);Jr&&console.log("connecting");const e=(t=this.netWebSocketUrlProvider)==null?void 0:t.getWebsocketUrl();return e?wu=e:AV()&&(wu="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){var e;(e=this._ws)==null||e.close(),this._ws=void 0}connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(e,t)=>{var c,h;let i=!1;const n=u=>{i||(i=!0,e(u))};if(wu===void 0&&(console.log("Fetch default backend url: "+az),wu=await(await fetch(az)).text()),wu===void 0){n(!1);return}console.log(`⊡ Connecting to networking backend on
|
|
5233
5233
|
`+wu);const r=await Promise.resolve().then(()=>$be),o=((c=r.default)==null?void 0:c.WebsocketBuilder)??r.WebsocketBuilder,a=((h=r.default)==null?void 0:h.ExponentialBackoff)??r.ExponentialBackoff,l=new o(wu).withMaxRetries(3).withBackoff(new a(2e3,2)).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=l,this.connected=!0,console.log(`⊞ Connected to networking backend
|
|
5234
5234
|
`+wu),n(!0),this.onSendQueued(gl.OnConnection)}).onClose(u=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,n(!1)}).onError(u=>{console.error("⊠ Websocket error"),n(!1)}).onRetry(()=>{console.log("Retry connecting to networking websocket")}).build();l.addEventListener(r.WebsocketEvent.message,(u,f)=>{this.onMessage(u,f)})})}onMessage(e,t){const i=t.data;try{if(typeof i!="string"){i.size&&this.handleIncomingBinaryMessage(i);return}const n=JSON.parse(i);if(Array.isArray(n))for(const r of n)this.handleIncomingStringMessage(r);else this.handleIncomingStringMessage(n);return}catch(n){Jr&&i==="pong"?console.log("<<",i):lt()&&console.error("Failed to parse message",n)}}async handleIncomingBinaryMessage(e){lz&&console.log("<< bin",this.context.time.frame);const t=await e.arrayBuffer();var i=new Uint8Array(t);const n=new H0(i),r=n.getBufferIdentifier(),o=this._listenersBinary[r],a=NQ(n),l=zQ(a);if(l&&typeof l=="string"&&(this._state[l]=a),!o)return;const c=a??n;for(const h of o)h(c)}handleIncomingStringMessage(e){var n,r;if(Jr&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const l=e.data;l&&(console.assert(l.id!==void 0&&l.id!==null&&l.id.length>0,"server did not send connection id",l.id),console.log("Your id is: "+l.id,this.context.alias??""),this._connectionId=l.id)}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(Jr&&console.log(e),e){this._isInRoom=!0;const l=e;this._currentRoomName=l.room,this._currentRoomViewId=l.viewId,this._currentRoomAllowEditing=l.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...l.inRoom),Jr&&console.log("joined room with",this._currentInRoom,this.context.alias??"");const c=new URL(window.location.href);c.searchParams.has("room")&&c.searchParams.delete("room"),c.searchParams.set("view",this._currentRoomViewId),console.log("Room view id: "+this._currentRoomViewId+`
|
|
5235
|
-
`+c.href)}this.onSendQueued(gl.OnRoomJoin);break;case"left-room":e.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(e.data){const l=e.data;this._currentInRoom.push(l.userId),Jr&&console.log(l.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const l=e.data,c=this._currentInRoom.indexOf(l.userId);c>=0&&(Jr&&console.log(l.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(c,1)),l.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Jr&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const a=(n=e.data)==null?void 0:n.time;a&&(this._currentDelay=this.context.time.time-a),Jr&&console.log("Current latency: "+this._currentDelay.toFixed(4)+" sec","Clients in room: "+((r=this._currentInRoom)==null?void 0:r.length));break}const t=e.data;t&&(this._state[t.guid]=t);let i=this._listeners[e.key];if(i){i=[...i];for(const o of i)try{o(e.data)}catch(a){console.error('Error invoking callback for "'+e.key+'"',a)}}}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,i=gl.OnRoomJoin){if(!this._ws){const r=this._waitingForSocket[i]||[];r.push(()=>this.sendWithWebsocket(e,t,i)),this._waitingForSocket[i]=r;return}const n=JSON.stringify(this.toMessage(e,t));Jr&&console.log(">>",e),this._ws.send(n)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const i of t)i();t.length=0}}}const $A=ie("debugwebxr");class SI{constructor(e,t){d(this,"controllerStates",[]);d(this,"userId");d(this,"context");d(this,"userStateEvtName");d(this,"onReceivedControllerState",e=>{$A&&console.log(`XRSync: Received change for ${this.userId}: ${e.type} ${e.handedness}; tracked=${e.isTracking}`);let t=!1;for(let i=0;i<this.controllerStates.length;i++)if(this.controllerStates[i].index===e.index){this.controllerStates[i]=e,t=!0;break}t||this.controllerStates.push(e)});this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const i=this.controllerStates[t];let n=!1;for(let r=0;r<e.controllers.length;r++)e.controllers[r].index===i.index&&(n=!0);n||($A&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(i))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(i=>i.index===e.index);if(t){let i=!1;i||(i=t.isTracking!=e.isTracking),i&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const i={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),$A&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class L6{constructor(e){d(this,"context");d(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||($A&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new SI(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new SI(e,this.context))}});d(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const e=this._states.get(this.context.connection.connectionId);e==null||e.dispose(),this._states.delete(this.context.connection.connectionId)}});d(this,"onOtherUserJoinedRoom",e=>{const t=e.userId;this._states.has(t)||($A&&console.log("XRSync: Remote user joined room",t),this._states.set(t,new SI(t,this.context)))});d(this,"onOtherUserLeftRoom",e=>{const t=e.userId;if(!this._states.has(t)){const i=this._states.get(t);i==null||i.dispose(),this._states.delete(t)}});d(this,"_states",new Map);this.context=e,this.context.connection.beginListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.isTracking)||!1}getDeviceType(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.type)||"unknown"}destroy(){this.context.connection.stopListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.update(e)}}onExitXR(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.onExitXR(e)}}}class cz{constructor(){d(this,"_fadeToColorQuad");d(this,"_fadeToColorMaterial");d(this,"_requestedFadeValue",0);d(this,"_transitionPromise",null);d(this,"_transitionResolve",null);this._fadeToColorMaterial=new ni({color:0,transparent:!0,depthTest:!1,fog:!1,side:xi}),this._fadeToColorQuad=new fe(new os(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const i=this._fadeToColorQuad,n=this._fadeToColorMaterial;i.parent!==e&&n.opacity>0?e.add(i):n.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const r=this._requestedFadeValue;n.opacity=it.lerp(n.opacity,r,t/.03),Math.abs(n.opacity-r)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}}var Cp=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s))(Cp||{});class U_{static createPrimitive(e,t){let i;switch(e){case"Quad":case 0:{const r=new os(1,1,1,1),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break;case"Cube":case 1:{const r=new Xi(1,1,1),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break;case"Sphere":case 2:{const r=new Wa(.5,16,16),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break}return this.applyDefaultObjectOptions(i,t),i}static createSprite(e){const i=new u1({color:16777215});e!=null&&e.texture&&"map"in i&&(i.map=e.texture);const n=new L2(i);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){t!=null&&t.name&&(e.name=t.name),t!=null&&t.position&&e.position.set(t.position.x,t.position.y,t.position.z),t!=null&&t.rotation&&e.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),t!=null&&t.scale&&e.scale.set(t.scale.x,t.scale.y,t.scale.z)}}const ak=class{constructor(e,t,i){d(this,"_session");d(this,"_mode");d(this,"_init");d(this,"_renderer");d(this,"_camera");d(this,"_scene");d(this,"onEnd",()=>{var e;(e=this._session)==null||e.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()});d(this,"_lastTime",0);d(this,"onFrame",(e,t)=>{const i=e-this._lastTime;this.update(e,i),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)});d(this,"_objects",[]);this._mode=e,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new Gh({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new Gt,this._scene=new rr,this._scene.fog=new h1(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(e,t){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(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(e,t);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new ak(e,t,i),this._active):(i.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 wc(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 e={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,e}async onBeforeHandoff(){await wc(1e3),this._scene.clear()}setupScene(){this._scene.background=new Ae(0),this._scene.add(new L1(5,10,1118481,1118481));const e=new vp(16777215,1);e.position.set(0,20,0),e.castShadow=!1,this._scene.add(e);const t=new vp(16777215,1);t.position.set(0,-1,0),t.castShadow=!1,this._scene.add(t);const i=new yp(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const n=50;for(let r=0;r<100;r++){const o=new Pr({color:2236962,metalness:1,roughness:.8});this.isAR&&(o.emissive=new Ae(Math.random(),Math.random(),Math.random()),o.emissiveIntensity=Math.random());const a=it.random(0,1)>.5?Cp.Sphere:Cp.Cube,l=U_.createPrimitive(a,{material:o});l.position.x=it.random(-n,n),l.position.y=it.random(-2,n),l.position.z=it.random(-n,n),l.rotation.x=it.random(0,Math.PI*2),l.rotation.y=it.random(0,Math.PI*2),l.rotation.z=it.random(0,Math.PI*2),l.scale.multiplyScalar(.5+Math.random()*10);const c=l.position.distanceTo(this._camera.position)-l.scale.x;c<1&&l.position.multiplyScalar(1+1/c),this._objects.push(l),this._scene.add(l)}}update(e,t){const i=e*4e-4;for(let n=0;n<this._objects.length;n++){const r=this._objects[n];r.position.y+=Math.sin(i+n*.5)*.005,r.rotateY(.002)}}};let qu=ak;d(qu,"_active",null),d(qu,"_requestInFlight",!1);const Cs=ie("debugwebxr"),vde=ie("stats");function Ade(s){let e=null;const t=s;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=s,e}_de();async function _de(){var s;if(ie("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],di.addContextCreatedCallback(async t=>{if(!e)return;hy(!0);const i=await e;if(i){const n=xt.getDefaultSessionInit("immersive-vr");xt.setSession("immersive-vr",i,n,t.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(s=navigator.xr)==null||s.addEventListener("sessiongranted",async()=>{hy(!0),console.log("Received Session Granted..."),await wc(100);const e=sessionStorage.getItem("needle_xr_session_mode"),t=sessionStorage.getItem("needle_xr_session_init")??null,i=t?JSON.parse(t):null;let n=null;if(k6()&&(await qu.start(e||"immersive-vr",i||xt.getDefaultSessionInit("immersive-vr")),await wde(),n=await qu.handoff()),n)xt.setSession(n.mode,n.session,n.init,Ot.Current);else if(e&&t){console.log("Session Granted: Restore last session");const r=JSON.parse(t);xt.start(e,r).catch(o=>console.warn(o))}else xt.start("immersive-vr").catch(r=>console.warn("Session Granted failed:",r))},{once:!0})}}function bde(s,e){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function xde(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const GO=new Set;di.registerCallback(Ii.ContextCreationStart,async s=>{GO.add(s.context)});di.registerCallback(Ii.ContextCreated,async s=>{GO.delete(s.context)});function k6(){return GO.size>0}function wde(){return new Promise(s=>{const e=Date.now(),t=setInterval(()=>{(!k6()||Date.now()-e>6e4)&&(clearInterval(t),s())},100)})}Ap()&<()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&xt.active&&xt.stop()});const dh=class{constructor(e,t,i,n){d(this,"context");d(this,"session");d(this,"mode");d(this,"controllers",[]);d(this,"_rigScale",1);d(this,"_lastRigScaleUpdate",-1);d(this,"_rigs",[]);d(this,"_viewerHitTestSource",null);d(this,"_defaultRig");d(this,"_xr_scripts");d(this,"_xr_update_scripts",[]);d(this,"_inactive_scripts",[]);d(this,"_controllerAdded");d(this,"_controllerRemoved");d(this,"_originalCameraWorldPosition");d(this,"_originalCameraWorldRotation");d(this,"_originalCameraWorldScale");d(this,"_originalCameraParent");d(this,"_mainCamera",null);d(this,"onRendererSessionSet",()=>{var e;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(e=this.context.mainCameraComponent)==null||e.applyClearFlags())});d(this,"onInputSourceAdded",e=>{if(e.targetRayMode==="screen")return;let t=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===e){t=n;break}if(this.controllers.find(n=>n.inputSource===e)){console.warn("Controller already exists for input source",t);return}Cs&&console.log("Adding controller",t);const i=new PO(this,e,t);this._newControllers.push(i)});d(this,"_ended",!1);d(this,"_newControllers",[]);d(this,"onEnd",e=>{var n,r,o;if(this._ended)return;this._ended=!0,Cs&&console.log("XR Session ended"),xde(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,Md(this.onBefore,$i.LateUpdate);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);t>=0&&this.context.pre_render_callbacks.splice(t,1);const i=this.context.post_render_callbacks.indexOf(this.onAfterRender);i>=0&&this.context.post_render_callbacks.splice(i,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var a;(a=this.context.mainCameraComponent)==null||a.applyClearFlags()}),kQ({session:this});for(const a of dh._xrEndListeners)a({xr:this});for(let a=0;a<this.controllers.length;a++)this.disconnectInputSource(this.controllers[a].inputSource);for(const a of this._xr_scripts)(n=a==null?void 0:a.onLeaveXR)==null||n.call(a,{xr:this});(r=this.sync)==null||r.onExitXR(this),this.context.mainCamera&&((o=this._originalCameraParent)==null||o.add(this.context.mainCamera),this._originalCameraWorldPosition&&ys(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&za(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&cy(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),hy(!1)});d(this,"_didStart",!1);d(this,"onBefore",e=>{var n,r,o,a,l,c,h,u;const t=e.xrFrame;if(!t)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((n=this.rig)==null?void 0:n.isActive)==!1&&(Cs&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&((r=this._mainCamera)!=null&&r.gameObject)&&((a=(o=this._mainCamera)==null?void 0:o.gameObject)==null?void 0:a.parent)!==this.rig.gameObject&&this.rig.gameObject.add((l=this._mainCamera)==null?void 0:l.gameObject),this.internalUpdateState(),this.applyCustomForward();const i={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const f=[...this.context.new_scripts_xr];for(let p=0;p<f.length;p++){const m=this.context.new_scripts_xr[p];if(!m||m.destroyed||((c=m.supportsXR)==null?void 0:c.call(m,this.mode))==!1){this.context.new_scripts_xr.splice(p,1);continue}if(!m.activeAndEnabled){this.context.new_scripts_xr.splice(p,1),this.markInactive(m);continue}if(this.addScript(m)){this.invokeCallback_EnterXR(m);for(const v of this.controllers)this.invokeCallback_ControllerAdded(m,v)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const p=Sc(this.context.scene.children);if(p){const m=p.getSize(pi()),v=this._defaultRig.gameObject;v.position.set(p.min.x+m.x*.5,p.min.y,p.max.z+m.z*.5+1.5);const g=p.getCenter(pi());g.y=v.position.y,v.lookAt(g)}}LQ({session:this});for(const p of dh._xrStartListeners)p(i);const f=[...this._xr_scripts];Cs&&console.log("NeedleXRSession start, handle scripts:",f);for(const p of f){if(p.destroyed){this._script_to_remove.push(p);continue}if(!p.activeAndEnabled){this.markInactive(p);continue}this.invokeCallback_EnterXR(p);for(const m of this.controllers)this.invokeCallback_ControllerAdded(p,m)}}this.syncCameraCullingMask();for(const f of this.controllers)f.onUpdate(t);if(this._newControllers.length>0){const f=[...this._newControllers];this._newControllers.length=0;for(const p of f)if(p.connected){this.controllers.push(p);for(const m of this._xr_scripts){if(m.destroyed){this._script_to_remove.push(m);continue}m.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(m,p)}}this.controllers.sort((p,m)=>p.index-m.index)}for(const f of this._xr_update_scripts){if(f.destroyed===!0){this._script_to_remove.push(f);continue}if(f.activeAndEnabled===!1){this.markInactive(f);continue}f.onUpdateXR&&f.onUpdateXR(i)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const f=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const p of f)!p.destroyed&&this.running&&((h=p.onLeaveXR)==null||h.call(p,i)),this.removeScript(p)}(u=this.sync)==null||u.onUpdate(this),this.onRenderDebug()});d(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)});d(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),Ap()){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){const t=e.xr.enabled,i=e.getRenderTarget();e.xr.enabled=!1,e.setRenderTarget(null),e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i)}}});d(this,"_script_to_remove",[]);d(this,"_camera");d(this,"_cameraRenderParent",new ve().rotateY(Math.PI));d(this,"_previousCameraParent");d(this,"_customforward",!0);d(this,"originalCameraNearPlane");d(this,"_viewerPose");d(this,"_transformOrientation",new Ce);d(this,"_transformPosition",new w);d(this,"_transition");var r,o;bde(e,n.init),this.session=t,this.mode=e,this.context=i,(Cs||ie("console"))&&hy(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(a=>typeof a.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,Ed(this.onBefore,$i.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=n.init.optionalFeatures)!=null&&r.includes("hit-test")||(o=n.init.requiredFeatures)!=null&&o.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(a=>{var l,c;return(c=(l=t.requestHitTestSource)==null?void 0:l.call(t,{space:a}))==null?void 0:c.then(h=>this._viewerHitTestSource=h)}).catch(a=>console.warn(a)),this.context.mainCamera&&(this._originalCameraWorldPosition=kt(this.context.mainCamera,new w),this._originalCameraWorldRotation=Ri(this.context.mainCamera,new Ce),this._originalCameraWorldScale=Ki(this.context.mainCamera,new w),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new Eue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let a=0;a<t.inputSources.length;a++){const l=t.inputSources[a];if(!l.handedness){console.warn("Input source in xr session has no handedness - ignoring",a);continue}this.onInputSourceAdded(l)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",a=>{for(const l of a.removed)this.disconnectInputSource(l);for(const l of a.added)this.onInputSourceAdded(l)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(e){return this._sync||(this._sync=new L6(e)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var e;return((e=this._activeSession)==null?void 0:e.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(e=>e.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(e){var t;return((t=this.xrSystem)==null?void 0:t.isSessionSupported(e).catch(i=>(Cs&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(e){this._sessionRequestStartListeners.push(e)}static offSessionRequestStart(e){const t=this._sessionRequestStartListeners.indexOf(e);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static onSessionRequestEnd(e){this._sessionRequestEndListeners.push(e)}static offSessionRequestEnd(e){const t=this._sessionRequestEndListeners.indexOf(e);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static onXRSessionStart(e){this._xrStartListeners.push(e)}static offXRSessionStart(e){const t=this._xrStartListeners.indexOf(e);t>=0&&this._xrStartListeners.splice(t,1)}static onXRSessionEnd(e){this._xrEndListeners.push(e)}static offXRSessionEnd(e){const t=this._xrEndListeners.indexOf(e);t>=0&&this._xrEndListeners.splice(t,1)}static onControllerAdded(e){this._controllerAddedListeners.push(e)}static offControllerAdded(e){const t=this._controllerAddedListeners.indexOf(e);t>=0&&this._controllerAddedListeners.splice(t,1)}static onControllerRemoved(e){this._controllerRemovedListeners.push(e)}static offControllerRemoved(e){const t=this._controllerRemovedListeners.indexOf(e);t>=0&&this._controllerRemovedListeners.splice(t,1)}static offerSession(e,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+e),t=="default"&&(t=this.getDefaultSessionInit(e)),navigator.xr.offerSession(e,{...t}).then(n=>dh.setSession(e,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(e){switch(e){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",e),{}}}static async start(e,t,i){var o,a,l,c;if(lt()&&ie("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await qu.start(e,t||dh.getDefaultSessionInit(e)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Cs||lt())&&Ni("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(i||(i=Ot.Current),i||(i=di.All[0]),!i)throw new Error("No Needle Engine Context found");switch(t||(t={}),e){case"immersive-ar":{if(await((o=this.xrSystem)==null?void 0:o.isSessionSupported("immersive-ar"))!==!0)return console.error(e+" is not supported by this browser."),null;const u=this.getDefaultSessionInit(e),f=Ade(i.domElement);f&&!F1()&&(u.domOverlay={root:f},u.optionalFeatures.push("dom-overlay")),t={...u,...t}}break;case"immersive-vr":{if(await((a=this.xrSystem)==null?void 0:a.isSessionSupported("immersive-vr"))!==!0)return console.error(e+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(e),...t}}break;default:console.warn("No default session init for mode",e);break}t.optionalFeatures??(t.optionalFeatures=[]),t.requiredFeatures??(t.requiredFeatures=[]),await qu.stop();const n=e=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Cs?console.log(`%cRequesting ${e} session`,"font-weight:bold;",t,n):console.log(`%cRequesting ${e} session`,"font-weight:bold;");for(const h of n)h.onBeforeXR&&h.onBeforeXR(e,t);for(const h of this._sessionRequestStartListeners)h({mode:e,init:t});Cs&&pn("Requesting "+e+" session ("+Date.now()+")"),this._currentSessionRequest=(l=navigator.xr)==null?void 0:l.requestSession(e,t),this._currentSessionRequestMode=e;const r=await((c=this._currentSessionRequest)==null?void 0:c.catch(h=>{console.error(h,"Code: "+h.code),h.code===9&&Ni("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:"&&Ni("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const h of this._sessionRequestEndListeners)h({mode:e,init:t,newSession:r||null});return r?this.setSession(e,r,t,i):(console.warn("XR Session request was rejected"),null)}static setSession(e,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=e=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new dh(e,t,n,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),Cs?console.log(`%cStarted ${e} session`,"font-weight:bold;",r):console.log(`%cStarted ${e} session`,"font-weight:bold;"),this._activeSession}static stop(){var e;(e=this._activeSession)==null||e.end()}get sync(){return dh._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(e=>e.isLeft)}get rightController(){return this.controllers.find(e=>e.isRight)}getController(e){return typeof e=="number"?this.controllers[e]||null:this.controllers.find(t=>t.side===e)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(e=>e.inputSource.targetRayMode==="tracked-pointer")||lt()&&Ap()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const e=this.frame.getImageTrackingResults();for(const t of e)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const e=this._rigs[0]??null;return e!=null&&e.gameObject&&Ep(e.gameObject)||(e==null?void 0:e.isActive)===!1?(this.updateActiveXRRig(),this._rigs[0]??null):e}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(e){this._rigs.indexOf(e)>=0||(e.priority===void 0&&(e.priority=0),this._rigs.push(e),this.updateActiveXRRig())}removeRig(e){const t=this._rigs.indexOf(e);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(e){const t=this._rigs.indexOf(e);this._rigs.splice(t,1),this._rigs.unshift(e),this.updateActiveXRRig()}updateActiveXRRig(){const e=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 t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(Ep(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(e!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}Cs&&(e===t?console.log("Updated Active XR Rig:",t,"prev:",e):console.log("Updated Active XRRig:",t," (the same as before)"))}getHitTest(e){if(e)return this.getControllerHitTest(e);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(e){const t=e.hitTestSource;if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===e.inputSource)for(const r of n.results)return this.convertHitTestResult(r);return null}convertHitTestResult(e){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&e.getPose(t);if(i){const n=pi(i.transform.position),r=Uf(i.transform.orientation),o=this.context.mainCamera;if((o==null?void 0:o.parent)!==this._cameraRenderParent&&n.applyMatrix4(bC),o!=null&&o.parent){n.applyMatrix4(o.parent.matrixWorld),r.multiply(Ca);const a=Ri(o.parent);a.premultiply(Ca),r.premultiply(a)}return{hit:e,position:n,quaternion:r}}return null}convertSpace(e){const t=pi(e.position);t.applyMatrix4(bC);const i=Uf(e.orientation);return i.premultiply(Ca),{position:t,quaternion:i}}disconnectInputSource(e){const t=(i,n,r)=>{if(i.inputSource===e){Cs&&console.log("Disconnecting controller",i.index),this.controllers.splice(r,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const o={xr:this,controller:i,change:"removed"};for(const a of this._xr_scripts)a.onXRControllerRemoved&&a.onXRControllerRemoved(o);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const n=this.controllers[i];t(n,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const n=this._newControllers[i];t(n,this._newControllers,i)}}end(){this._ended||this.session.end().catch(e=>console.warn(e))}onRenderDebug(){if(Cs)for(const e of this.controllers)e.onRenderDebug();if((Cs||vde)&&this.rig){const e=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;e.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;e.add(i.multiplyScalar(2.5));let n="";if(n+=this.context.time.smoothedFps.toFixed(1),Cs)for(const r of this.controllers)n+=`
|
|
5235
|
+
`+c.href)}this.onSendQueued(gl.OnRoomJoin);break;case"left-room":e.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(e.data){const l=e.data;this._currentInRoom.push(l.userId),Jr&&console.log(l.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const l=e.data,c=this._currentInRoom.indexOf(l.userId);c>=0&&(Jr&&console.log(l.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(c,1)),l.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Jr&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const a=(n=e.data)==null?void 0:n.time;a&&(this._currentDelay=this.context.time.time-a),Jr&&console.log("Current latency: "+this._currentDelay.toFixed(4)+" sec","Clients in room: "+((r=this._currentInRoom)==null?void 0:r.length));break}const t=e.data;t&&(this._state[t.guid]=t);let i=this._listeners[e.key];if(i){i=[...i];for(const o of i)try{o(e.data)}catch(a){console.error('Error invoking callback for "'+e.key+'"',a)}}}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,i=gl.OnRoomJoin){if(!this._ws){const r=this._waitingForSocket[i]||[];r.push(()=>this.sendWithWebsocket(e,t,i)),this._waitingForSocket[i]=r;return}const n=JSON.stringify(this.toMessage(e,t));Jr&&console.log(">>",e),this._ws.send(n)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const i of t)i();t.length=0}}}const $A=ie("debugwebxr");class SI{constructor(e,t){d(this,"controllerStates",[]);d(this,"userId");d(this,"context");d(this,"userStateEvtName");d(this,"onReceivedControllerState",e=>{$A&&console.log(`XRSync: Received change for ${this.userId}: ${e.type} ${e.handedness}; tracked=${e.isTracking}`);let t=!1;for(let i=0;i<this.controllerStates.length;i++)if(this.controllerStates[i].index===e.index){this.controllerStates[i]=e,t=!0;break}t||this.controllerStates.push(e)});this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const i=this.controllerStates[t];let n=!1;for(let r=0;r<e.controllers.length;r++)e.controllers[r].index===i.index&&(n=!0);n||($A&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(i))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(i=>i.index===e.index);if(t){let i=!1;i||(i=t.isTracking!=e.isTracking),i&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const i={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),$A&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class L6{constructor(e){d(this,"context");d(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||($A&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new SI(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new SI(e,this.context))}});d(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const e=this._states.get(this.context.connection.connectionId);e==null||e.dispose(),this._states.delete(this.context.connection.connectionId)}});d(this,"onOtherUserJoinedRoom",e=>{const t=e.userId;this._states.has(t)||($A&&console.log("XRSync: Remote user joined room",t),this._states.set(t,new SI(t,this.context)))});d(this,"onOtherUserLeftRoom",e=>{const t=e.userId;if(!this._states.has(t)){const i=this._states.get(t);i==null||i.dispose(),this._states.delete(t)}});d(this,"_states",new Map);this.context=e,this.context.connection.beginListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.isTracking)||!1}getDeviceType(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.type)||"unknown"}destroy(){this.context.connection.stopListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.update(e)}}onExitXR(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.onExitXR(e)}}}class cz{constructor(){d(this,"_fadeToColorQuad");d(this,"_fadeToColorMaterial");d(this,"_requestedFadeValue",0);d(this,"_transitionPromise",null);d(this,"_transitionResolve",null);this._fadeToColorMaterial=new ni({color:0,transparent:!0,depthTest:!1,fog:!1,side:xi}),this._fadeToColorQuad=new fe(new os(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const i=this._fadeToColorQuad,n=this._fadeToColorMaterial;i.parent!==e&&n.opacity>0?e.add(i):n.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const r=this._requestedFadeValue;n.opacity=it.lerp(n.opacity,r,t/.03),Math.abs(n.opacity-r)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}}var Cp=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s))(Cp||{});class U_{static createPrimitive(e,t){let i;switch(e){case"Quad":case 0:{const r=new os(1,1,1,1),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break;case"Cube":case 1:{const r=new Xi(1,1,1),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break;case"Sphere":case 2:{const r=new Wa(.5,16,16),o=(t==null?void 0:t.material)??new Pr({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new fe(r,o)}break}return this.applyDefaultObjectOptions(i,t),i}static createSprite(e){const i=new u1({color:16777215});e!=null&&e.texture&&"map"in i&&(i.map=e.texture);const n=new L2(i);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){t!=null&&t.name&&(e.name=t.name),t!=null&&t.position&&e.position.set(t.position.x,t.position.y,t.position.z),t!=null&&t.rotation&&e.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),t!=null&&t.scale&&e.scale.set(t.scale.x,t.scale.y,t.scale.z)}}const ak=class{constructor(e,t,i){d(this,"_session");d(this,"_mode");d(this,"_init");d(this,"_renderer");d(this,"_camera");d(this,"_scene");d(this,"onEnd",()=>{var e;(e=this._session)==null||e.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()});d(this,"_lastTime",0);d(this,"onFrame",(e,t)=>{const i=e-this._lastTime;this.update(e,i),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)});d(this,"_objects",[]);this._mode=e,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new Gh({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new Gt,this._scene=new rr,this._scene.fog=new h1(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(e,t){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(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(e,t);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new ak(e,t,i),this._active):(i.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 wc(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 e={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,e}async onBeforeHandoff(){await wc(1e3),this._scene.clear()}setupScene(){this._scene.background=new Ae(0),this._scene.add(new L1(5,10,1118481,1118481));const e=new vp(16777215,1);e.position.set(0,20,0),e.castShadow=!1,this._scene.add(e);const t=new vp(16777215,1);t.position.set(0,-1,0),t.castShadow=!1,this._scene.add(t);const i=new yp(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const n=50;for(let r=0;r<100;r++){const o=new Pr({color:2236962,metalness:1,roughness:.8});this.isAR&&(o.emissive=new Ae(Math.random(),Math.random(),Math.random()),o.emissiveIntensity=Math.random());const a=it.random(0,1)>.5?Cp.Sphere:Cp.Cube,l=U_.createPrimitive(a,{material:o});l.position.x=it.random(-n,n),l.position.y=it.random(-2,n),l.position.z=it.random(-n,n),l.rotation.x=it.random(0,Math.PI*2),l.rotation.y=it.random(0,Math.PI*2),l.rotation.z=it.random(0,Math.PI*2),l.scale.multiplyScalar(.5+Math.random()*10);const c=l.position.distanceTo(this._camera.position)-l.scale.x;c<1&&l.position.multiplyScalar(1+1/c),this._objects.push(l),this._scene.add(l)}}update(e,t){const i=e*4e-4;for(let n=0;n<this._objects.length;n++){const r=this._objects[n];r.position.y+=Math.sin(i+n*.5)*.005,r.rotateY(.002)}}};let qu=ak;d(qu,"_active",null),d(qu,"_requestInFlight",!1);const Cs=ie("debugwebxr"),vde=ie("stats");function Ade(s){let e=null;const t=s;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=s,e}_de();async function _de(){var s;if(ie("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],di.addContextCreatedCallback(async t=>{if(!e)return;hy(!0);const i=await e;if(i){const n=xt.getDefaultSessionInit("immersive-vr");xt.setSession("immersive-vr",i,n,t.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(s=navigator.xr)==null||s.addEventListener("sessiongranted",async()=>{hy(!0),console.log("Received Session Granted..."),await wc(100);const e=sessionStorage.getItem("needle_xr_session_mode"),t=sessionStorage.getItem("needle_xr_session_init")??null,i=t?JSON.parse(t):null;let n=null;if(k6()&&(await qu.start(e||"immersive-vr",i||xt.getDefaultSessionInit("immersive-vr")),await wde(),n=await qu.handoff()),n)xt.setSession(n.mode,n.session,n.init,Ot.Current);else if(e&&t){console.log("Session Granted: Restore last session");const r=JSON.parse(t);xt.start(e,r).catch(o=>console.warn(o))}else xt.start("immersive-vr").catch(r=>console.warn("Session Granted failed:",r))},{once:!0})}}function bde(s,e){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function xde(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const GO=new Set;di.registerCallback(Ii.ContextCreationStart,async s=>{GO.add(s.context)});di.registerCallback(Ii.ContextCreated,async s=>{GO.delete(s.context)});function k6(){return GO.size>0}function wde(){return new Promise(s=>{const e=Date.now(),t=setInterval(()=>{(!k6()||Date.now()-e>6e4)&&(clearInterval(t),s())},100)})}Ap()&<()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&xt.active&&xt.stop()});const dh=class{constructor(e,t,i,n){d(this,"context");d(this,"session");d(this,"mode");d(this,"controllers",[]);d(this,"_rigScale",1);d(this,"_lastRigScaleUpdate",-1);d(this,"_rigs",[]);d(this,"_viewerHitTestSource",null);d(this,"_defaultRig");d(this,"_xr_scripts");d(this,"_xr_update_scripts",[]);d(this,"_inactive_scripts",[]);d(this,"_controllerAdded");d(this,"_controllerRemoved");d(this,"_originalCameraWorldPosition");d(this,"_originalCameraWorldRotation");d(this,"_originalCameraWorldScale");d(this,"_originalCameraParent");d(this,"_mainCamera",null);d(this,"onRendererSessionSet",()=>{var e;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(e=this.context.mainCameraComponent)==null||e.applyClearFlags())});d(this,"onInputSourceAdded",e=>{if(e.targetRayMode==="screen")return;let t=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===e){t=n;break}if(this.controllers.find(n=>n.inputSource===e)){console.warn("Controller already exists for input source",t);return}Cs&&console.log("Adding controller",t);const i=new PO(this,e,t);this._newControllers.push(i)});d(this,"_ended",!1);d(this,"_newControllers",[]);d(this,"onEnd",e=>{var n,r,o;if(this._ended)return;this._ended=!0,Cs&&console.log("XR Session ended"),xde(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,Md(this.onBefore,$i.LateUpdate);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);t>=0&&this.context.pre_render_callbacks.splice(t,1);const i=this.context.post_render_callbacks.indexOf(this.onAfterRender);i>=0&&this.context.post_render_callbacks.splice(i,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var a;(a=this.context.mainCameraComponent)==null||a.applyClearFlags()}),kQ({session:this});for(const a of dh._xrEndListeners)a({xr:this});for(let a=0;a<this.controllers.length;a++)this.disconnectInputSource(this.controllers[a].inputSource);for(const a of this._xr_scripts)(n=a==null?void 0:a.onLeaveXR)==null||n.call(a,{xr:this});(r=this.sync)==null||r.onExitXR(this),this.context.mainCamera&&((o=this._originalCameraParent)==null||o.add(this.context.mainCamera),this._originalCameraWorldPosition&&ys(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&za(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&cy(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),hy(!1)});d(this,"_didStart",!1);d(this,"onBefore",e=>{var n,r,o,a,l,c,h,u;const t=e.xrFrame;if(!t)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((n=this.rig)==null?void 0:n.isActive)==!1&&(Cs&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&((r=this._mainCamera)!=null&&r.gameObject)&&((a=(o=this._mainCamera)==null?void 0:o.gameObject)==null?void 0:a.parent)!==this.rig.gameObject&&this.rig.gameObject.add((l=this._mainCamera)==null?void 0:l.gameObject),this.internalUpdateState(),this.applyCustomForward();const i={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const f=[...this.context.new_scripts_xr];for(let p=0;p<f.length;p++){const m=this.context.new_scripts_xr[p];if(!m||m.destroyed||((c=m.supportsXR)==null?void 0:c.call(m,this.mode))==!1){this.context.new_scripts_xr.splice(p,1);continue}if(!m.activeAndEnabled){this.context.new_scripts_xr.splice(p,1),this.markInactive(m);continue}if(this.addScript(m)){this.invokeCallback_EnterXR(m);for(const v of this.controllers)this.invokeCallback_ControllerAdded(m,v)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const p=Sc(this.context.scene.children);if(p){const m=p.getSize(pi());if(m.length()>0){const v=this._defaultRig.gameObject;v.position.set(p.min.x+m.x*.5,p.min.y,p.max.z+m.z*.5+1.5);const g=p.getCenter(pi());g.y=v.position.y,v.lookAt(g)}}}LQ({session:this});for(const p of dh._xrStartListeners)p(i);const f=[...this._xr_scripts];Cs&&console.log("NeedleXRSession start, handle scripts:",f);for(const p of f){if(p.destroyed){this._script_to_remove.push(p);continue}if(!p.activeAndEnabled){this.markInactive(p);continue}this.invokeCallback_EnterXR(p);for(const m of this.controllers)this.invokeCallback_ControllerAdded(p,m)}}this.syncCameraCullingMask();for(const f of this.controllers)f.onUpdate(t);if(this._newControllers.length>0){const f=[...this._newControllers];this._newControllers.length=0;for(const p of f)if(p.connected){this.controllers.push(p);for(const m of this._xr_scripts){if(m.destroyed){this._script_to_remove.push(m);continue}m.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(m,p)}}this.controllers.sort((p,m)=>p.index-m.index)}for(const f of this._xr_update_scripts){if(f.destroyed===!0){this._script_to_remove.push(f);continue}if(f.activeAndEnabled===!1){this.markInactive(f);continue}f.onUpdateXR&&f.onUpdateXR(i)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const f=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const p of f)!p.destroyed&&this.running&&((h=p.onLeaveXR)==null||h.call(p,i)),this.removeScript(p)}(u=this.sync)==null||u.onUpdate(this),this.onRenderDebug()});d(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)});d(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),Ap()){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){const t=e.xr.enabled,i=e.getRenderTarget();e.xr.enabled=!1,e.setRenderTarget(null),e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i)}}});d(this,"_script_to_remove",[]);d(this,"_camera");d(this,"_cameraRenderParent",new ve().rotateY(Math.PI));d(this,"_previousCameraParent");d(this,"_customforward",!0);d(this,"originalCameraNearPlane");d(this,"_viewerPose");d(this,"_transformOrientation",new Ce);d(this,"_transformPosition",new w);d(this,"_transition");var r,o;bde(e,n.init),this.session=t,this.mode=e,this.context=i,(Cs||ie("console"))&&hy(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(a=>typeof a.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,Ed(this.onBefore,$i.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=n.init.optionalFeatures)!=null&&r.includes("hit-test")||(o=n.init.requiredFeatures)!=null&&o.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(a=>{var l,c;return(c=(l=t.requestHitTestSource)==null?void 0:l.call(t,{space:a}))==null?void 0:c.then(h=>this._viewerHitTestSource=h)}).catch(a=>console.warn(a)),this.context.mainCamera&&(this._originalCameraWorldPosition=kt(this.context.mainCamera,new w),this._originalCameraWorldRotation=Ri(this.context.mainCamera,new Ce),this._originalCameraWorldScale=Ki(this.context.mainCamera,new w),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new Eue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let a=0;a<t.inputSources.length;a++){const l=t.inputSources[a];if(!l.handedness){console.warn("Input source in xr session has no handedness - ignoring",a);continue}this.onInputSourceAdded(l)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",a=>{for(const l of a.removed)this.disconnectInputSource(l);for(const l of a.added)this.onInputSourceAdded(l)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(e){return this._sync||(this._sync=new L6(e)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var e;return((e=this._activeSession)==null?void 0:e.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(e=>e.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(e){var t;return((t=this.xrSystem)==null?void 0:t.isSessionSupported(e).catch(i=>(Cs&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(e){this._sessionRequestStartListeners.push(e)}static offSessionRequestStart(e){const t=this._sessionRequestStartListeners.indexOf(e);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static onSessionRequestEnd(e){this._sessionRequestEndListeners.push(e)}static offSessionRequestEnd(e){const t=this._sessionRequestEndListeners.indexOf(e);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static onXRSessionStart(e){this._xrStartListeners.push(e)}static offXRSessionStart(e){const t=this._xrStartListeners.indexOf(e);t>=0&&this._xrStartListeners.splice(t,1)}static onXRSessionEnd(e){this._xrEndListeners.push(e)}static offXRSessionEnd(e){const t=this._xrEndListeners.indexOf(e);t>=0&&this._xrEndListeners.splice(t,1)}static onControllerAdded(e){this._controllerAddedListeners.push(e)}static offControllerAdded(e){const t=this._controllerAddedListeners.indexOf(e);t>=0&&this._controllerAddedListeners.splice(t,1)}static onControllerRemoved(e){this._controllerRemovedListeners.push(e)}static offControllerRemoved(e){const t=this._controllerRemovedListeners.indexOf(e);t>=0&&this._controllerRemovedListeners.splice(t,1)}static offerSession(e,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+e),t=="default"&&(t=this.getDefaultSessionInit(e)),navigator.xr.offerSession(e,{...t}).then(n=>dh.setSession(e,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(e){switch(e){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",e),{}}}static async start(e,t,i){var o,a,l,c;if(lt()&&ie("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await qu.start(e,t||dh.getDefaultSessionInit(e)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Cs||lt())&&Ni("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(i||(i=Ot.Current),i||(i=di.All[0]),!i)throw new Error("No Needle Engine Context found");switch(t||(t={}),e){case"immersive-ar":{if(await((o=this.xrSystem)==null?void 0:o.isSessionSupported("immersive-ar"))!==!0)return console.error(e+" is not supported by this browser."),null;const u=this.getDefaultSessionInit(e),f=Ade(i.domElement);f&&!F1()&&(u.domOverlay={root:f},u.optionalFeatures.push("dom-overlay")),t={...u,...t}}break;case"immersive-vr":{if(await((a=this.xrSystem)==null?void 0:a.isSessionSupported("immersive-vr"))!==!0)return console.error(e+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(e),...t}}break;default:console.warn("No default session init for mode",e);break}t.optionalFeatures??(t.optionalFeatures=[]),t.requiredFeatures??(t.requiredFeatures=[]),await qu.stop();const n=e=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Cs?console.log(`%cRequesting ${e} session`,"font-weight:bold;",t,n):console.log(`%cRequesting ${e} session`,"font-weight:bold;");for(const h of n)h.onBeforeXR&&h.onBeforeXR(e,t);for(const h of this._sessionRequestStartListeners)h({mode:e,init:t});Cs&&pn("Requesting "+e+" session ("+Date.now()+")"),this._currentSessionRequest=(l=navigator.xr)==null?void 0:l.requestSession(e,t),this._currentSessionRequestMode=e;const r=await((c=this._currentSessionRequest)==null?void 0:c.catch(h=>{console.error(h,"Code: "+h.code),h.code===9&&Ni("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:"&&Ni("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const h of this._sessionRequestEndListeners)h({mode:e,init:t,newSession:r||null});return r?this.setSession(e,r,t,i):(console.warn("XR Session request was rejected"),null)}static setSession(e,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=e=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new dh(e,t,n,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),Cs?console.log(`%cStarted ${e} session`,"font-weight:bold;",r):console.log(`%cStarted ${e} session`,"font-weight:bold;"),this._activeSession}static stop(){var e;(e=this._activeSession)==null||e.end()}get sync(){return dh._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(e=>e.isLeft)}get rightController(){return this.controllers.find(e=>e.isRight)}getController(e){return typeof e=="number"?this.controllers[e]||null:this.controllers.find(t=>t.side===e)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(e=>e.inputSource.targetRayMode==="tracked-pointer")||lt()&&Ap()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const e=this.frame.getImageTrackingResults();for(const t of e)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const e=this._rigs[0]??null;return e!=null&&e.gameObject&&Ep(e.gameObject)||(e==null?void 0:e.isActive)===!1?(this.updateActiveXRRig(),this._rigs[0]??null):e}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(e){this._rigs.indexOf(e)>=0||(e.priority===void 0&&(e.priority=0),this._rigs.push(e),this.updateActiveXRRig())}removeRig(e){const t=this._rigs.indexOf(e);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(e){const t=this._rigs.indexOf(e);this._rigs.splice(t,1),this._rigs.unshift(e),this.updateActiveXRRig()}updateActiveXRRig(){const e=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 t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(Ep(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(e!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}Cs&&(e===t?console.log("Updated Active XR Rig:",t,"prev:",e):console.log("Updated Active XRRig:",t," (the same as before)"))}getHitTest(e){if(e)return this.getControllerHitTest(e);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(e){const t=e.hitTestSource;if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===e.inputSource)for(const r of n.results)return this.convertHitTestResult(r);return null}convertHitTestResult(e){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&e.getPose(t);if(i){const n=pi(i.transform.position),r=Uf(i.transform.orientation),o=this.context.mainCamera;if((o==null?void 0:o.parent)!==this._cameraRenderParent&&n.applyMatrix4(bC),o!=null&&o.parent){n.applyMatrix4(o.parent.matrixWorld),r.multiply(Ca);const a=Ri(o.parent);a.premultiply(Ca),r.premultiply(a)}return{hit:e,position:n,quaternion:r}}return null}convertSpace(e){const t=pi(e.position);t.applyMatrix4(bC);const i=Uf(e.orientation);return i.premultiply(Ca),{position:t,quaternion:i}}disconnectInputSource(e){const t=(i,n,r)=>{if(i.inputSource===e){Cs&&console.log("Disconnecting controller",i.index),this.controllers.splice(r,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const o={xr:this,controller:i,change:"removed"};for(const a of this._xr_scripts)a.onXRControllerRemoved&&a.onXRControllerRemoved(o);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const n=this.controllers[i];t(n,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const n=this._newControllers[i];t(n,this._newControllers,i)}}end(){this._ended||this.session.end().catch(e=>console.warn(e))}onRenderDebug(){if(Cs)for(const e of this.controllers)e.onRenderDebug();if((Cs||vde)&&this.rig){const e=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;e.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;e.add(i.multiplyScalar(2.5));let n="";if(n+=this.context.time.smoothedFps.toFixed(1),Cs)for(const r of this.controllers)n+=`
|
|
5236
5236
|
${r.hand?"hand":"ctrl"} ${r.inputSource.handedness}[${r.index}] con:${r.connected} tr:${r.isTracking}`;_t.DrawLabel(e,n)}}addScript(e){return this._xr_scripts.includes(e)?!1:(Cs&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}removeScript(e,t=!0){Cs&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const r=this._inactive_scripts.indexOf(e);r>=0&&this._inactive_scripts.splice(r,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){var i;const e=this.context.xrCamera,t=(i=this.context.mainCameraComponent)==null?void 0:i.cullingMask;if(e&&t!==void 0){for(const n of e.cameras)n.layers.mask=t;e.layers.mask=t}else if(e){for(const n of e.cameras)n.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const r=t[n];if(r)try{r({xr:this,controller:e,change:i})}catch(o){console.error(o)}}}applyCustomForward(){var e;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(e=this._previousCameraParent)==null||e.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let t=.02;if(this.rig){const i=Ki(this.rig.gameObject);t*=i.x}this._camera instanceof Gt&&this._camera.near>t&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=t)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Gt&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}get transition(){return this._transition||(this._transition=new cz),this._transition}fadeTransition(){return this._transition||(this._transition=new cz),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof Gt&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){var e;(e=this._transition)==null||e.remove()}};let xt=dh;d(xt,"_sync",null),d(xt,"_currentSessionRequestMode",null),d(xt,"_currentSessionRequest"),d(xt,"_activeSession"),d(xt,"_sessionRequestStartListeners",[]),d(xt,"_sessionRequestEndListeners",[]),d(xt,"_xrStartListeners",[]),d(xt,"_xrEndListeners",[]),d(xt,"_controllerAddedListeners",[]),d(xt,"_controllerRemovedListeners",[]),d(xt,"onEnd",()=>{Cs&&console.log("XR Session ended"),dh._activeSession=null});const CI=ie("debugwebxr");class F6{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(CI&&console.log("FOUND AVATAR HEAD",e.name),i.head=new Zt("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(CI&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new Zt("",t,e)),!i.rightHand&&n.includes("right")&&(CI&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new Zt("",t,e)));for(let r=0;r<e.children.length;r++){if(i.head&&i.leftHand&&i.rightHand)return;const o=e.children[r];this.tryFindAvatarObjects(o,t,i)}}}var SC=(s=>(s.Visible="application-visible",s.Hidden="application-hidden",s.MuteChanged="application-mutechanged",s))(SC||{});let CC=!1;const Pg=[];function Fy(){if(CC)return;lt()&&console.debug("User interaction registered: audio can now be played"),CC=!0;const s=[...Pg];Pg.length=0,s.forEach(e=>e())}document.addEventListener("pointerdown",Fy);document.addEventListener("click",Fy);document.addEventListener("dragstart",Fy);document.addEventListener("touchstart",Fy);document.addEventListener("keydown",Fy);xt.onXRSessionStart(()=>{Fy()});const lk=class extends EventTarget{constructor(t){super();d(this,"_mute",!1);d(this,"context");d(this,"_isVisible",!0);this.context=t,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return CC}static registerWaitForInteraction(t){if(t!==null){if(CC){t();return}Pg.indexOf(t)===-1&&Pg.push(t)}}static unregisterWaitForInteraction(t){const i=Pg.indexOf(t);i!==-1&&Pg.splice(i,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 vc=lk;d(vc,"registerWaitForAllowAudio",lk.registerWaitForInteraction);function*U6(s,e=null){const t=e?e.time:Ot.Current.time,i=t.time;for(;t.time-i<s;)yield}function*Sde(s){for(let e=0;e<s;e++)yield}function*N6(s){let e=!0;for(s.then(()=>e=!1),s.catch(()=>e=!1);e;)yield}class Q0 extends J2{constructor(e){super(e),this.type=gs}parse(e){const R=Math.pow(2.7182818,2.2);function C(B,N){let Z=0;for(let G=0;G<65536;++G)(G==0||B[G>>3]&1<<(G&7))&&(N[Z++]=G);const P=Z-1;for(;Z<65536;)N[Z++]=0;return P}function I(B){for(let N=0;N<16384;N++)B[N]={},B[N].len=0,B[N].lit=0,B[N].p=null}const F={l:0,c:0,lc:0};function U(B,N,Z,P,G){for(;Z<B;)N=N<<8|Xe(P,G),Z+=8;Z-=B,F.l=N>>Z&(1<<B)-1,F.c=N,F.lc=Z}const O=new Array(59);function Q(B){for(let Z=0;Z<=58;++Z)O[Z]=0;for(let Z=0;Z<65537;++Z)O[B[Z]]+=1;let N=0;for(let Z=58;Z>0;--Z){const P=N+O[Z]>>1;O[Z]=N,N=P}for(let Z=0;Z<65537;++Z){const P=B[Z];P>0&&(B[Z]=P|O[P]++<<6)}}function D(B,N,Z,P,G,V){const Y=N;let K=0,pe=0;for(;P<=G;P++){if(Y.value-N.value>Z)return!1;U(6,K,pe,B,Y);const he=F.l;if(K=F.c,pe=F.lc,V[P]=he,he==63){if(Y.value-N.value>Z)throw new Error("Something wrong with hufUnpackEncTable");U(8,K,pe,B,Y);let be=F.l+6;if(K=F.c,pe=F.lc,P+be>G+1)throw new Error("Something wrong with hufUnpackEncTable");for(;be--;)V[P++]=0;P--}else if(he>=59){let be=he-59+2;if(P+be>G+1)throw new Error("Something wrong with hufUnpackEncTable");for(;be--;)V[P++]=0;P--}}Q(V)}function k(B){return B&63}function z(B){return B>>6}function q(B,N,Z,P){for(;N<=Z;N++){const G=z(B[N]),V=k(B[N]);if(G>>V)throw new Error("Invalid table entry");if(V>14){const Y=P[G>>V-14];if(Y.len)throw new Error("Invalid table entry");if(Y.lit++,Y.p){const K=Y.p;Y.p=new Array(Y.lit);for(let pe=0;pe<Y.lit-1;++pe)Y.p[pe]=K[pe]}else Y.p=new Array(1);Y.p[Y.lit-1]=N}else if(V){let Y=0;for(let K=1<<14-V;K>0;K--){const pe=P[(G<<14-V)+Y];if(pe.len||pe.p)throw new Error("Invalid table entry");pe.len=V,pe.lit=N,Y++}}}return!0}const X={c:0,lc:0};function se(B,N,Z,P){B=B<<8|Xe(Z,P),N+=8,X.c=B,X.lc=N}const le={c:0,lc:0};function Me(B,N,Z,P,G,V,Y,K,pe){if(B==N){P<8&&(se(Z,P,G,V),Z=X.c,P=X.lc),P-=8;let he=Z>>P;if(he=new Uint8Array([he])[0],K.value+he>pe)return!1;const be=Y[K.value-1];for(;he-- >0;)Y[K.value++]=be}else if(K.value<pe)Y[K.value++]=B;else return!1;le.c=Z,le.lc=P}function ne(B){return B&65535}function ge(B){const N=ne(B);return N>32767?N-65536:N}const Se={a:0,b:0};function Le(B,N){const Z=ge(B),G=ge(N),V=Z+(G&1)+(G>>1),Y=V,K=V-G;Se.a=Y,Se.b=K}function We(B,N){const Z=ne(B),P=ne(N),G=Z-(P>>1)&65535,V=P+G-32768&65535;Se.a=V,Se.b=G}function Ve(B,N,Z,P,G,V,Y){const K=Y<16384,pe=Z>G?G:Z;let he=1,be,Be;for(;he<=pe;)he<<=1;for(he>>=1,be=he,he>>=1;he>=1;){Be=0;const Oe=Be+V*(G-be),je=V*he,Je=V*be,et=P*he,ht=P*be;let Mt,_i,Qt,Pt;for(;Be<=Oe;Be+=Je){let Oi=Be;const Ct=Be+P*(Z-be);for(;Oi<=Ct;Oi+=ht){const Hi=Oi+et,Gr=Oi+je,an=Gr+et;K?(Le(B[Oi+N],B[Gr+N]),Mt=Se.a,Qt=Se.b,Le(B[Hi+N],B[an+N]),_i=Se.a,Pt=Se.b,Le(Mt,_i),B[Oi+N]=Se.a,B[Hi+N]=Se.b,Le(Qt,Pt),B[Gr+N]=Se.a,B[an+N]=Se.b):(We(B[Oi+N],B[Gr+N]),Mt=Se.a,Qt=Se.b,We(B[Hi+N],B[an+N]),_i=Se.a,Pt=Se.b,We(Mt,_i),B[Oi+N]=Se.a,B[Hi+N]=Se.b,We(Qt,Pt),B[Gr+N]=Se.a,B[an+N]=Se.b)}if(Z&he){const Hi=Oi+je;K?Le(B[Oi+N],B[Hi+N]):We(B[Oi+N],B[Hi+N]),Mt=Se.a,B[Hi+N]=Se.b,B[Oi+N]=Mt}}if(G&he){let Oi=Be;const Ct=Be+P*(Z-be);for(;Oi<=Ct;Oi+=ht){const Hi=Oi+et;K?Le(B[Oi+N],B[Hi+N]):We(B[Oi+N],B[Hi+N]),Mt=Se.a,B[Hi+N]=Se.b,B[Oi+N]=Mt}}be=he,he>>=1}return Be}function gt(B,N,Z,P,G,V,Y,K,pe){let he=0,be=0;const Be=Y,Oe=Math.trunc(P.value+(G+7)/8);for(;P.value<Oe;)for(se(he,be,Z,P),he=X.c,be=X.lc;be>=14;){const Je=he>>be-14&16383,et=N[Je];if(et.len)be-=et.len,Me(et.lit,V,he,be,Z,P,K,pe,Be),he=le.c,be=le.lc;else{if(!et.p)throw new Error("hufDecode issues");let ht;for(ht=0;ht<et.lit;ht++){const Mt=k(B[et.p[ht]]);for(;be<Mt&&P.value<Oe;)se(he,be,Z,P),he=X.c,be=X.lc;if(be>=Mt&&z(B[et.p[ht]])==(he>>be-Mt&(1<<Mt)-1)){be-=Mt,Me(et.p[ht],V,he,be,Z,P,K,pe,Be),he=le.c,be=le.lc;break}}if(ht==et.lit)throw new Error("hufDecode issues")}}const je=8-G&7;for(he>>=je,be-=je;be>0;){const Je=N[he<<14-be&16383];if(Je.len)be-=Je.len,Me(Je.lit,V,he,be,Z,P,K,pe,Be),he=le.c,be=le.lc;else throw new Error("hufDecode issues")}return!0}function st(B,N,Z,P,G,V){const Y={value:0},K=Z.value,pe=ft(N,Z),he=ft(N,Z);Z.value+=4;const be=ft(N,Z);if(Z.value+=4,pe<0||pe>=65537||he<0||he>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const Be=new Array(65537),Oe=new Array(16384);I(Oe);const je=P-(Z.value-K);if(D(B,Z,je,pe,he,Be),be>8*(P-(Z.value-K)))throw new Error("Something wrong with hufUncompress");q(Be,pe,he,Oe),gt(Be,Oe,B,Z,be,he,V,G,Y)}function W(B,N,Z){for(let P=0;P<Z;++P)N[P]=B[N[P]]}function Ge(B){for(let N=1;N<B.length;N++){const Z=B[N-1]+B[N]-128;B[N]=Z}}function xe(B,N){let Z=0,P=Math.floor((B.length+1)/2),G=0;const V=B.length-1;for(;!(G>V||(N[G++]=B[Z++],G>V));)N[G++]=B[P++]}function Ne(B){let N=B.byteLength;const Z=new Array;let P=0;const G=new DataView(B);for(;N>0;){const V=G.getInt8(P++);if(V<0){const Y=-V;N-=Y+1;for(let K=0;K<Y;K++)Z.push(G.getUint8(P++))}else{const Y=V;N-=2;const K=G.getUint8(P++);for(let pe=0;pe<Y+1;pe++)Z.push(K)}}return Z}function Ee(B,N,Z,P,G,V){let Y=new DataView(V.buffer);const K=Z[B.idx[0]].width,pe=Z[B.idx[0]].height,he=3,be=Math.floor(K/8),Be=Math.ceil(K/8),Oe=Math.ceil(pe/8),je=K-(Be-1)*8,Je=pe-(Oe-1)*8,et={value:0},ht=new Array(he),Mt=new Array(he),_i=new Array(he),Qt=new Array(he),Pt=new Array(he);for(let Ct=0;Ct<he;++Ct)Pt[Ct]=N[B.idx[Ct]],ht[Ct]=Ct<1?0:ht[Ct-1]+Be*Oe,Mt[Ct]=new Float32Array(64),_i[Ct]=new Uint16Array(64),Qt[Ct]=new Uint16Array(Be*64);for(let Ct=0;Ct<Oe;++Ct){let Hi=8;Ct==Oe-1&&(Hi=Je);let Gr=8;for(let vi=0;vi<Be;++vi){vi==Be-1&&(Gr=je);for(let Wt=0;Wt<he;++Wt)_i[Wt].fill(0),_i[Wt][0]=G[ht[Wt]++],tt(et,P,_i[Wt]),$e(_i[Wt],Mt[Wt]),at(Mt[Wt]);Ft(Mt);for(let Wt=0;Wt<he;++Wt)H(Mt[Wt],Qt[Wt],vi*64)}let an=0;for(let vi=0;vi<he;++vi){const Wt=Z[B.idx[vi]].type;for(let zs=8*Ct;zs<8*Ct+Hi;++zs){an=Pt[vi][zs];for(let Nc=0;Nc<be;++Nc){const _n=Nc*64+(zs&7)*8;Y.setUint16(an+0*2*Wt,Qt[vi][_n+0],!0),Y.setUint16(an+1*2*Wt,Qt[vi][_n+1],!0),Y.setUint16(an+2*2*Wt,Qt[vi][_n+2],!0),Y.setUint16(an+3*2*Wt,Qt[vi][_n+3],!0),Y.setUint16(an+4*2*Wt,Qt[vi][_n+4],!0),Y.setUint16(an+5*2*Wt,Qt[vi][_n+5],!0),Y.setUint16(an+6*2*Wt,Qt[vi][_n+6],!0),Y.setUint16(an+7*2*Wt,Qt[vi][_n+7],!0),an+=8*2*Wt}}if(be!=Be)for(let zs=8*Ct;zs<8*Ct+Hi;++zs){const Nc=Pt[vi][zs]+8*be*2*Wt,_n=be*64+(zs&7)*8;for(let eu=0;eu<Gr;++eu)Y.setUint16(Nc+eu*2*Wt,Qt[vi][_n+eu],!0)}}}const Oi=new Uint16Array(K);Y=new DataView(V.buffer);for(let Ct=0;Ct<he;++Ct){Z[B.idx[Ct]].decoded=!0;const Hi=Z[B.idx[Ct]].type;if(Z[Ct].type==2)for(let Gr=0;Gr<pe;++Gr){const an=Pt[Ct][Gr];for(let vi=0;vi<K;++vi)Oi[vi]=Y.getUint16(an+vi*2*Hi,!0);for(let vi=0;vi<K;++vi)Y.setFloat32(an+vi*2*Hi,ae(Oi[vi]),!0)}}}function tt(B,N,Z){let P,G=1;for(;G<64;)P=N[B.value],P==65280?G=64:P>>8==255?G+=P&255:(Z[G]=P,G++),B.value++}function $e(B,N){N[0]=ae(B[0]),N[1]=ae(B[1]),N[2]=ae(B[5]),N[3]=ae(B[6]),N[4]=ae(B[14]),N[5]=ae(B[15]),N[6]=ae(B[27]),N[7]=ae(B[28]),N[8]=ae(B[2]),N[9]=ae(B[4]),N[10]=ae(B[7]),N[11]=ae(B[13]),N[12]=ae(B[16]),N[13]=ae(B[26]),N[14]=ae(B[29]),N[15]=ae(B[42]),N[16]=ae(B[3]),N[17]=ae(B[8]),N[18]=ae(B[12]),N[19]=ae(B[17]),N[20]=ae(B[25]),N[21]=ae(B[30]),N[22]=ae(B[41]),N[23]=ae(B[43]),N[24]=ae(B[9]),N[25]=ae(B[11]),N[26]=ae(B[18]),N[27]=ae(B[24]),N[28]=ae(B[31]),N[29]=ae(B[40]),N[30]=ae(B[44]),N[31]=ae(B[53]),N[32]=ae(B[10]),N[33]=ae(B[19]),N[34]=ae(B[23]),N[35]=ae(B[32]),N[36]=ae(B[39]),N[37]=ae(B[45]),N[38]=ae(B[52]),N[39]=ae(B[54]),N[40]=ae(B[20]),N[41]=ae(B[22]),N[42]=ae(B[33]),N[43]=ae(B[38]),N[44]=ae(B[46]),N[45]=ae(B[51]),N[46]=ae(B[55]),N[47]=ae(B[60]),N[48]=ae(B[21]),N[49]=ae(B[34]),N[50]=ae(B[37]),N[51]=ae(B[47]),N[52]=ae(B[50]),N[53]=ae(B[56]),N[54]=ae(B[59]),N[55]=ae(B[61]),N[56]=ae(B[35]),N[57]=ae(B[36]),N[58]=ae(B[48]),N[59]=ae(B[49]),N[60]=ae(B[57]),N[61]=ae(B[58]),N[62]=ae(B[62]),N[63]=ae(B[63])}function at(B){const N=.5*Math.cos(.7853975),Z=.5*Math.cos(3.14159/16),P=.5*Math.cos(3.14159/8),G=.5*Math.cos(3*3.14159/16),V=.5*Math.cos(5*3.14159/16),Y=.5*Math.cos(3*3.14159/8),K=.5*Math.cos(7*3.14159/16),pe=new Array(4),he=new Array(4),be=new Array(4),Be=new Array(4);for(let Oe=0;Oe<8;++Oe){const je=Oe*8;pe[0]=P*B[je+2],pe[1]=Y*B[je+2],pe[2]=P*B[je+6],pe[3]=Y*B[je+6],he[0]=Z*B[je+1]+G*B[je+3]+V*B[je+5]+K*B[je+7],he[1]=G*B[je+1]-K*B[je+3]-Z*B[je+5]-V*B[je+7],he[2]=V*B[je+1]-Z*B[je+3]+K*B[je+5]+G*B[je+7],he[3]=K*B[je+1]-V*B[je+3]+G*B[je+5]-Z*B[je+7],be[0]=N*(B[je+0]+B[je+4]),be[3]=N*(B[je+0]-B[je+4]),be[1]=pe[0]+pe[3],be[2]=pe[1]-pe[2],Be[0]=be[0]+be[1],Be[1]=be[3]+be[2],Be[2]=be[3]-be[2],Be[3]=be[0]-be[1],B[je+0]=Be[0]+he[0],B[je+1]=Be[1]+he[1],B[je+2]=Be[2]+he[2],B[je+3]=Be[3]+he[3],B[je+4]=Be[3]-he[3],B[je+5]=Be[2]-he[2],B[je+6]=Be[1]-he[1],B[je+7]=Be[0]-he[0]}for(let Oe=0;Oe<8;++Oe)pe[0]=P*B[16+Oe],pe[1]=Y*B[16+Oe],pe[2]=P*B[48+Oe],pe[3]=Y*B[48+Oe],he[0]=Z*B[8+Oe]+G*B[24+Oe]+V*B[40+Oe]+K*B[56+Oe],he[1]=G*B[8+Oe]-K*B[24+Oe]-Z*B[40+Oe]-V*B[56+Oe],he[2]=V*B[8+Oe]-Z*B[24+Oe]+K*B[40+Oe]+G*B[56+Oe],he[3]=K*B[8+Oe]-V*B[24+Oe]+G*B[40+Oe]-Z*B[56+Oe],be[0]=N*(B[Oe]+B[32+Oe]),be[3]=N*(B[Oe]-B[32+Oe]),be[1]=pe[0]+pe[3],be[2]=pe[1]-pe[2],Be[0]=be[0]+be[1],Be[1]=be[3]+be[2],Be[2]=be[3]-be[2],Be[3]=be[0]-be[1],B[0+Oe]=Be[0]+he[0],B[8+Oe]=Be[1]+he[1],B[16+Oe]=Be[2]+he[2],B[24+Oe]=Be[3]+he[3],B[32+Oe]=Be[3]-he[3],B[40+Oe]=Be[2]-he[2],B[48+Oe]=Be[1]-he[1],B[56+Oe]=Be[0]-he[0]}function Ft(B){for(let N=0;N<64;++N){const Z=B[0][N],P=B[1][N],G=B[2][N];B[0][N]=Z+1.5747*G,B[1][N]=Z-.1873*P-.4682*G,B[2][N]=Z+1.8556*P}}function H(B,N,Z){for(let P=0;P<64;++P)N[Z+P]=kf.toHalfFloat(L(B[P]))}function L(B){return B<=1?Math.sign(B)*Math.pow(Math.abs(B),2.2):Math.sign(B)*Math.pow(R,Math.abs(B)-1)}function me(B){return new DataView(B.array.buffer,B.offset.value,B.size)}function _e(B){const N=B.viewer.buffer.slice(B.offset.value,B.offset.value+B.size),Z=new Uint8Array(Ne(N)),P=new Uint8Array(Z.length);return Ge(Z),xe(Z,P),new DataView(P.buffer)}function Pe(B){const N=B.array.slice(B.offset.value,B.offset.value+B.size),Z=gA(N),P=new Uint8Array(Z.length);return Ge(Z),xe(Z,P),new DataView(P.buffer)}function Te(B){const N=B.viewer,Z={value:B.offset.value},P=new Uint16Array(B.width*B.scanlineBlockSize*(B.channels*B.type)),G=new Uint8Array(8192);let V=0;const Y=new Array(B.channels);for(let Je=0;Je<B.channels;Je++)Y[Je]={},Y[Je].start=V,Y[Je].end=Y[Je].start,Y[Je].nx=B.width,Y[Je].ny=B.lines,Y[Je].size=B.type,V+=Y[Je].nx*Y[Je].ny*Y[Je].size;const K=$(N,Z),pe=$(N,Z);if(pe>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(K<=pe)for(let Je=0;Je<pe-K+1;Je++)G[Je+K]=pt(N,Z);const he=new Uint16Array(65536),be=C(G,he),Be=ft(N,Z);st(B.array,N,Z,Be,P,V);for(let Je=0;Je<B.channels;++Je){const et=Y[Je];for(let ht=0;ht<Y[Je].size;++ht)Ve(P,et.start+ht,et.nx,et.size,et.ny,et.nx*et.size,be)}W(he,P,V);let Oe=0;const je=new Uint8Array(P.buffer.byteLength);for(let Je=0;Je<B.lines;Je++)for(let et=0;et<B.channels;et++){const ht=Y[et],Mt=ht.nx*ht.size,_i=new Uint8Array(P.buffer,ht.end*2,Mt*2);je.set(_i,Oe),Oe+=Mt*2,ht.end+=Mt}return new DataView(je.buffer)}function bt(B){const N=B.array.slice(B.offset.value,B.offset.value+B.size),Z=gA(N),P=B.lines*B.channels*B.width,G=B.type==1?new Uint16Array(P):new Uint32Array(P);let V=0,Y=0;const K=new Array(4);for(let pe=0;pe<B.lines;pe++)for(let he=0;he<B.channels;he++){let be=0;switch(B.type){case 1:K[0]=V,K[1]=K[0]+B.width,V=K[1]+B.width;for(let Be=0;Be<B.width;++Be){const Oe=Z[K[0]++]<<8|Z[K[1]++];be+=Oe,G[Y]=be,Y++}break;case 2:K[0]=V,K[1]=K[0]+B.width,K[2]=K[1]+B.width,V=K[2]+B.width;for(let Be=0;Be<B.width;++Be){const Oe=Z[K[0]++]<<24|Z[K[1]++]<<16|Z[K[2]++]<<8;be+=Oe,G[Y]=be,Y++}break}}return new DataView(G.buffer)}function dt(B){const N=B.viewer,Z={value:B.offset.value},P=new Uint8Array(B.width*B.lines*(B.channels*B.type*2)),G={version:rt(N,Z),unknownUncompressedSize:rt(N,Z),unknownCompressedSize:rt(N,Z),acCompressedSize:rt(N,Z),dcCompressedSize:rt(N,Z),rleCompressedSize:rt(N,Z),rleUncompressedSize:rt(N,Z),rleRawSize:rt(N,Z),totalAcUncompressedCount:rt(N,Z),totalDcUncompressedCount:rt(N,Z),acCompression:rt(N,Z)};if(G.version<2)throw new Error("EXRLoader.parse: "+$h.compression+" version "+G.version+" is unsupported");const V=new Array;let Y=$(N,Z)-2;for(;Y>0;){const et=ke(N.buffer,Z),ht=pt(N,Z),Mt=ht>>2&3,_i=(ht>>4)-1,Qt=new Int8Array([_i])[0],Pt=pt(N,Z);V.push({name:et,index:Qt,type:Pt,compression:Mt}),Y-=et.length+3}const K=$h.channels,pe=new Array(B.channels);for(let et=0;et<B.channels;++et){const ht=pe[et]={},Mt=K[et];ht.name=Mt.name,ht.compression=0,ht.decoded=!1,ht.type=Mt.pixelType,ht.pLinear=Mt.pLinear,ht.width=B.width,ht.height=B.lines}const he={idx:new Array(3)};for(let et=0;et<B.channels;++et){const ht=pe[et];for(let Mt=0;Mt<V.length;++Mt){const _i=V[Mt];ht.name==_i.name&&(ht.compression=_i.compression,_i.index>=0&&(he.idx[_i.index]=et),ht.offset=et)}}let be,Be,Oe;if(G.acCompressedSize>0)switch(G.acCompression){case 0:be=new Uint16Array(G.totalAcUncompressedCount),st(B.array,N,Z,G.acCompressedSize,be,G.totalAcUncompressedCount);break;case 1:const et=B.array.slice(Z.value,Z.value+G.totalAcUncompressedCount),ht=gA(et);be=new Uint16Array(ht.buffer),Z.value+=G.totalAcUncompressedCount;break}if(G.dcCompressedSize>0){const et={array:B.array,offset:Z,size:G.dcCompressedSize};Be=new Uint16Array(Pe(et).buffer),Z.value+=G.dcCompressedSize}if(G.rleRawSize>0){const et=B.array.slice(Z.value,Z.value+G.rleCompressedSize),ht=gA(et);Oe=Ne(ht.buffer),Z.value+=G.rleCompressedSize}let je=0;const Je=new Array(pe.length);for(let et=0;et<Je.length;++et)Je[et]=new Array;for(let et=0;et<B.lines;++et)for(let ht=0;ht<pe.length;++ht)Je[ht].push(je),je+=pe[ht].width*B.type*2;Ee(he,Je,pe,be,Be,P);for(let et=0;et<pe.length;++et){const ht=pe[et];if(!ht.decoded)switch(ht.compression){case 2:let Mt=0,_i=0;for(let Qt=0;Qt<B.lines;++Qt){let Pt=Je[et][Mt];for(let Oi=0;Oi<ht.width;++Oi){for(let Ct=0;Ct<2*ht.type;++Ct)P[Pt++]=Oe[_i+Ct*ht.width*ht.height];_i++}Mt++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(P.buffer)}function ke(B,N){const Z=new Uint8Array(B);let P=0;for(;Z[N.value+P]!=0;)P+=1;const G=new TextDecoder().decode(Z.slice(N.value,N.value+P));return N.value=N.value+P+1,G}function Qe(B,N,Z){const P=new TextDecoder().decode(new Uint8Array(B).slice(N.value,N.value+Z));return N.value=N.value+Z,P}function St(B,N){const Z=ei(B,N),P=ft(B,N);return[Z,P]}function Fe(B,N){const Z=ft(B,N),P=ft(B,N);return[Z,P]}function ei(B,N){const Z=B.getInt32(N.value,!0);return N.value=N.value+4,Z}function ft(B,N){const Z=B.getUint32(N.value,!0);return N.value=N.value+4,Z}function Xe(B,N){const Z=B[N.value];return N.value=N.value+1,Z}function pt(B,N){const Z=B.getUint8(N.value);return N.value=N.value+1,Z}const rt=function(B,N){let Z;return"getBigInt64"in DataView.prototype?Z=Number(B.getBigInt64(N.value,!0)):Z=B.getUint32(N.value+4,!0)+Number(B.getUint32(N.value,!0)<<32),N.value+=8,Z};function Bt(B,N){const Z=B.getFloat32(N.value,!0);return N.value+=4,Z}function j(B,N){return kf.toHalfFloat(Bt(B,N))}function ae(B){const N=(B&31744)>>10,Z=B&1023;return(B>>15?-1:1)*(N?N===31?Z?NaN:1/0:Math.pow(2,N-15)*(1+Z/1024):6103515625e-14*(Z/1024))}function $(B,N){const Z=B.getUint16(N.value,!0);return N.value+=2,Z}function De(B,N){return ae($(B,N))}function ce(B,N,Z,P){const G=Z.value,V=[];for(;Z.value<G+P-1;){const Y=ke(N,Z),K=ei(B,Z),pe=pt(B,Z);Z.value+=3;const he=ei(B,Z),be=ei(B,Z);V.push({name:Y,pixelType:K,pLinear:pe,xSampling:he,ySampling:be})}return Z.value+=1,V}function He(B,N){const Z=Bt(B,N),P=Bt(B,N),G=Bt(B,N),V=Bt(B,N),Y=Bt(B,N),K=Bt(B,N),pe=Bt(B,N),he=Bt(B,N);return{redX:Z,redY:P,greenX:G,greenY:V,blueX:Y,blueY:K,whiteX:pe,whiteY:he}}function Ye(B,N){const Z=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],P=pt(B,N);return Z[P]}function ti(B,N){const Z=ft(B,N),P=ft(B,N),G=ft(B,N),V=ft(B,N);return{xMin:Z,yMin:P,xMax:G,yMax:V}}function Ti(B,N){const Z=["INCREASING_Y"],P=pt(B,N);return Z[P]}function rn(B,N){const Z=Bt(B,N),P=Bt(B,N);return[Z,P]}function on(B,N){const Z=Bt(B,N),P=Bt(B,N),G=Bt(B,N);return[Z,P,G]}function si(B,N,Z,P,G){if(P==="string"||P==="stringvector"||P==="iccProfile")return Qe(N,Z,G);if(P==="chlist")return ce(B,N,Z,G);if(P==="chromaticities")return He(B,Z);if(P==="compression")return Ye(B,Z);if(P==="box2i")return ti(B,Z);if(P==="lineOrder")return Ti(B,Z);if(P==="float")return Bt(B,Z);if(P==="v2f")return rn(B,Z);if(P==="v3f")return on(B,Z);if(P==="int")return ei(B,Z);if(P==="rational")return St(B,Z);if(P==="timecode")return Fe(B,Z);if(P==="preview")return Z.value+=G,"skipped";Z.value+=G}function An(B,N,Z){const P={};if(B.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");P.version=B.getUint8(4);const G=B.getUint8(5);P.spec={singleTile:!!(G&2),longName:!!(G&4),deepFormat:!!(G&8),multiPart:!!(G&16)},Z.value=8;let V=!0;for(;V;){const Y=ke(N,Z);if(Y==0)V=!1;else{const K=ke(N,Z),pe=ft(B,Z),he=si(B,N,Z,K,pe);he===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${K}'.`):P[Y]=he}}if(G&-5)throw console.error("THREE.EXRHeader:",P),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return P}function In(B,N,Z,P,G){const V={size:0,viewer:N,array:Z,offset:P,width:B.dataWindow.xMax-B.dataWindow.xMin+1,height:B.dataWindow.yMax-B.dataWindow.yMin+1,channels:B.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:B.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:Fi};switch(B.compression){case"NO_COMPRESSION":V.lines=1,V.uncompress=me;break;case"RLE_COMPRESSION":V.lines=1,V.uncompress=_e;break;case"ZIPS_COMPRESSION":V.lines=1,V.uncompress=Pe;break;case"ZIP_COMPRESSION":V.lines=16,V.uncompress=Pe;break;case"PIZ_COMPRESSION":V.lines=32,V.uncompress=Te;break;case"PXR24_COMPRESSION":V.lines=16,V.uncompress=bt;break;case"DWAA_COMPRESSION":V.lines=32,V.uncompress=dt;break;case"DWAB_COMPRESSION":V.lines=256,V.uncompress=dt;break;default:throw new Error("EXRLoader.parse: "+B.compression+" is unsupported")}if(V.scanlineBlockSize=V.lines,V.type==1)switch(G){case Wn:V.getter=De,V.inputSize=2;break;case gs:V.getter=$,V.inputSize=2;break}else if(V.type==2)switch(G){case Wn:V.getter=Bt,V.inputSize=4;break;case gs:V.getter=j,V.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+V.type+" for "+B.compression+".");V.blockCount=(B.dataWindow.yMax+1)/V.scanlineBlockSize;for(let K=0;K<V.blockCount;K++)rt(N,P);V.outputChannels=V.channels==3?4:V.channels;const Y=V.width*V.height*V.outputChannels;switch(G){case Wn:V.byteArray=new Float32Array(Y),V.channels<V.outputChannels&&V.byteArray.fill(1,0,Y);break;case gs:V.byteArray=new Uint16Array(Y),V.channels<V.outputChannels&&V.byteArray.fill(15360,0,Y);break;default:console.error("THREE.EXRLoader: unsupported type: ",G);break}return V.bytesPerLine=V.width*V.inputSize*V.channels,V.outputChannels==4?(V.format=nn,V.colorSpace=Fi):(V.format=Cy,V.colorSpace=vo),V}const Bo=new DataView(e),Zh=new Uint8Array(e),Do={value:0},$h=An(Bo,e,Do),$t=In($h,Bo,Zh,Do,this.type),pv={value:0},Pb={R:0,G:1,B:2,A:3,Y:0};for(let B=0;B<$t.height/$t.scanlineBlockSize;B++){const N=ft(Bo,Do);$t.size=ft(Bo,Do),$t.lines=N+$t.scanlineBlockSize>$t.height?$t.height-N:$t.scanlineBlockSize;const P=$t.size<$t.lines*$t.bytesPerLine?$t.uncompress($t):me($t);Do.value+=$t.size;for(let G=0;G<$t.scanlineBlockSize;G++){const V=G+B*$t.scanlineBlockSize;if(V>=$t.height)break;for(let Y=0;Y<$t.channels;Y++){const K=Pb[$h.channels[Y].name];for(let pe=0;pe<$t.width;pe++){pv.value=(G*($t.channels*$t.width)+Y*$t.width+pe)*$t.inputSize;const he=($t.height-1-V)*($t.width*$t.outputChannels)+pe*$t.outputChannels+K;$t.byteArray[he]=$t.getter(P,pv)}}}}return{header:$h,width:$t.width,height:$t.height,data:$t.byteArray,format:$t.format,colorSpace:$t.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,i,n){function r(o,a){o.colorSpace=a.colorSpace,o.minFilter=Lt,o.magFilter=Lt,o.generateMipmaps=!1,o.flipY=!1,t&&t(o,a)}return super.load(e,r,i,n)}}const Cde=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:Q0},Symbol.toStringTag,{value:"Module"}));class EC extends J2{constructor(e){super(e),this.type=gs}parse(e){const o=function(T,R){switch(T){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(R||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(R||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(R||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(R||""))}},h=`
|
|
5237
5237
|
`,u=function(T,R,C){R=R||1024;let F=T.pos,U=-1,O=0,Q="",D=String.fromCharCode.apply(null,new Uint16Array(T.subarray(F,F+128)));for(;0>(U=D.indexOf(h))&&O<R&&F<T.byteLength;)Q+=D,O+=D.length,F+=128,D+=String.fromCharCode.apply(null,new Uint16Array(T.subarray(F,F+128)));return-1<U?(C!==!1&&(T.pos+=O+U+1),Q+D.slice(0,U)):!1},f=function(T){const R=/^#\?(\S+)/,C=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,I=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,F=/^\s*FORMAT=(\S+)\s*$/,U=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,O={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let Q,D;for((T.pos>=T.byteLength||!(Q=u(T)))&&o(1,"no header found"),(D=Q.match(R))||o(3,"bad initial token"),O.valid|=1,O.programtype=D[1],O.string+=Q+`
|
|
5238
5238
|
`;Q=u(T),Q!==!1;){if(O.string+=Q+`
|
|
@@ -7686,6 +7686,7 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
|
|
|
7686
7686
|
display: block;
|
|
7687
7687
|
width: max(600px, 100%);
|
|
7688
7688
|
height: max(300px, 100%);
|
|
7689
|
+
touch-action: none;
|
|
7689
7690
|
}
|
|
7690
7691
|
|
|
7691
7692
|
@media (max-width: 600px) {
|