function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = []
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
import{_ as Lh,l as qo,d as Fh,r as Cs,o as Nh,i as kh,w as Ko,a as Ke,c as it,b as ui,e as Uh,f as zo,F as Mn,g as Yo,h as Gh,j as Jo,k as Oh,u as Se,t as jo,s as nt,m as Ph,n as Rn,p as Hh,q as $h}from"./index-D4A_hFNd.js";import{C as Wl,A as Vh,a as xo,L as fn,F as pt,S as Ee,b as ee,B as bo,c as Te,d as Le,T as qh,e as ro,f as Xl,g as js,h as Kh,P as Zl,D as ec,M as Ue,i as st,V as De,j as Ve,k as N,I as zh,l as Yh,O as Ai,m as tc,n as Jh,o as jh,p as ae,q as fs,R as mt,r as Wh,s as Hi,t as Xh,u as nn,v as Ft,w as ei,x as Zh,y as pe,z as eu,E as tu,G as su,H as iu,J as $i,K as ti,N as rn,Q as mn,U as nu,W as ru,X as ou,Y as To,Z as Wo,_ as In,$ as ms,a0 as En,a1 as Cn,a2 as Bn,a3 as Me,a4 as yn,a5 as sc,a6 as Mo,a7 as au,a8 as Ge,a9 as Xo,aa as Zo,ab as ea,ac as Dt,ad as Ro,ae as Au,af as lu,ag as Ie,ah as cu,ai as Ws,aj as we,ak as hu,al as uu,am as du,an as gu,ao as pu,ap as fu,aq as mu,ar as Iu,as as Eu,at as $e,au as Qe,av as ic,aw as Cu,ax as Bu,ay as yu,az as on,aA as Ps,aB as Hs,aC as ta,aD as wn,aE as Is,aF as cs,aG as wu,aH as It,aI as Do,aJ as nc,aK as Qu,aL as vu,aM as rc,aN as Su,aO as Vi,aP as _o,aQ as oc,aR as si,aS as an,aT as xu,aU as bu,aV as Tu,aW as Mu,aX as Ru,aY as sa,aZ as ac,a_ as Du,a$ as di,b0 as Ac,b1 as Lo,b2 as _u,b3 as ia,b4 as Lu,b5 as na,b6 as Fu,b7 as Nu,b8 as lc,b9 as ku,ba as Uu,bb as Gu,bc as cc,bd as hc,be as Ou,bf as Pu,bg as Hu}from"./three.module-BW0MBeo0.js";/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const qi=window,Fo=qi.ShadowRoot&&(qi.ShadyCSS===void 0||qi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,uc=Symbol(),ra=new WeakMap;let $u=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==uc)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Fo&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=ra.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&ra.set(t,e))}return e}toString(){return this.cssText}};const Vu=o=>new $u(typeof o=="string"?o:o+"",void 0,uc),qu=(o,e)=>{Fo?o.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):e.forEach(t=>{const s=document.createElement("style"),i=qi.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=t.cssText,o.appendChild(s)})},oa=Fo?o=>o:o=>o instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return Vu(t)})(o):o;/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Dn;const An=window,aa=An.trustedTypes,Ku=aa?aa.emptyScript:"",Aa=An.reactiveElementPolyfillSupport,oo={toAttribute(o,e){switch(e){case Boolean:o=o?Ku:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,e){let t=o;switch(e){case Boolean:t=o!==null;break;case Number:t=o===null?null:Number(o);break;case Object:case Array:try{t=JSON.parse(o)}catch{t=null}}return t}},dc=(o,e)=>e!==o&&(e==e||o==o),_n={attribute:!0,type:String,converter:oo,reflect:!1,hasChanged:dc},ao="finalized";let _t=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),((t=this.h)!==null&&t!==void 0?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach((t,s)=>{const i=this._$Ep(s,t);i!==void 0&&(this._$Ev.set(i,s),e.push(i))}),e}static createProperty(e,t=_n){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s=typeof e=="symbol"?Symbol():"__"+e,i=this.getPropertyDescriptor(e,s,t);i!==void 0&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const n=this[e];this[t]=i,this.requestUpdate(e,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||_n}static finalize(){if(this.hasOwnProperty(ao))return!1;this[ao]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,s=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of s)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const i of s)t.unshift(oa(i))}else e!==void 0&&t.push(oa(e));return t}static _$Ep(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(t=>t(this))}addController(e){var t,s;((t=this._$ES)!==null&&t!==void 0?t:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)===null||s===void 0||s.call(e))}removeController(e){var t;(t=this._$ES)===null||t===void 0||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])})}createRenderRoot(){var e;const t=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return qu(t,this.constructor.elementStyles),t}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(t=>{var s;return(s=t.hostConnected)===null||s===void 0?void 0:s.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(t=>{var s;return(s=t.hostDisconnected)===null||s===void 0?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$EO(e,t,s=_n){var i;const n=this.constructor._$Ep(e,s);if(n!==void 0&&s.reflect===!0){const r=(((i=s.converter)===null||i===void 0?void 0:i.toAttribute)!==void 0?s.converter:oo).toAttribute(t,s.type);this._$El=e,r==null?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var s;const i=this.constructor,n=i._$Ev.get(e);if(n!==void 0&&this._$El!==n){const r=i.getPropertyOptions(n),a=typeof r.converter=="function"?{fromAttribute:r.converter}:((s=r.converter)===null||s===void 0?void 0:s.fromAttribute)!==void 0?r.converter:oo;this._$El=n,this[n]=a.fromAttribute(t,r.type),this._$El=null}}requestUpdate(e,t,s){let i=!0;e!==void 0&&(((s=s||this.constructor.getPropertyOptions(e)).hasChanged||dc)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),s.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,s))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((i,n)=>this[n]=i),this._$Ei=void 0);let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostUpdate)===null||n===void 0?void 0:n.call(i)}),this.update(s)):this._$Ek()}catch(i){throw t=!1,this._$Ek(),i}t&&this._$AE(s)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)===null||t===void 0||t.forEach(s=>{var i;return(i=s.hostUpdated)===null||i===void 0?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((t,s)=>this._$EO(s,this[s],t)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};_t[ao]=!0,_t.elementProperties=new Map,_t.elementStyles=[],_t.shadowRootOptions={mode:"open"},Aa==null||Aa({ReactiveElement:_t}),((Dn=An.reactiveElementVersions)!==null&&Dn!==void 0?Dn:An.reactiveElementVersions=[]).push("1.6.3");/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Ln;const ln=window,hs=ln.trustedTypes,la=hs?hs.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ao="$lit$",ht=`lit$${(Math.random()+"").slice(9)}$`,gc="?"+ht,zu=`<${gc}>`,Nt=document,ii=()=>Nt.createComment(""),ni=o=>o===null||typeof o!="object"&&typeof o!="function",pc=Array.isArray,Yu=o=>pc(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",Fn=`[ 	
\f\r]`,Bs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ca=/-->/g,ha=/>/g,Bt=RegExp(`>|${Fn}(?:([^\\s"'>=/]+)(${Fn}*=${Fn}*(?:[^ 	
\f\r"'\`<>=]|("|')|))|$)`,"g"),ua=/'/g,da=/"/g,fc=/^(?:script|style|textarea|title)$/i,Ju=o=>(e,...t)=>({_$litType$:o,strings:e,values:t}),Qn=Ju(1),us=Symbol.for("lit-noChange"),ie=Symbol.for("lit-nothing"),ga=new WeakMap,Lt=Nt.createTreeWalker(Nt,129,null,!1);function mc(o,e){if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return la!==void 0?la.createHTML(e):e}const ju=(o,e)=>{const t=o.length-1,s=[];let i,n=e===2?"<svg>":"",r=Bs;for(let a=0;a<t;a++){const A=o[a];let l,c,h=-1,d=0;for(;d<A.length&&(r.lastIndex=d,c=r.exec(A),c!==null);)d=r.lastIndex,r===Bs?c[1]==="!--"?r=ca:c[1]!==void 0?r=ha:c[2]!==void 0?(fc.test(c[2])&&(i=RegExp("</"+c[2],"g")),r=Bt):c[3]!==void 0&&(r=Bt):r===Bt?c[0]===">"?(r=i??Bs,h=-1):c[1]===void 0?h=-2:(h=r.lastIndex-c[2].length,l=c[1],r=c[3]===void 0?Bt:c[3]==='"'?da:ua):r===da||r===ua?r=Bt:r===ca||r===ha?r=Bs:(r=Bt,i=void 0);const u=r===Bt&&o[a+1].startsWith("/>")?" ":"";n+=r===Bs?A+zu:h>=0?(s.push(l),A.slice(0,h)+Ao+A.slice(h)+ht+u):A+ht+(h===-2?(s.push(void 0),a):u)}return[mc(o,n+(o[t]||"<?>")+(e===2?"</svg>":"")),s]};class ri{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let n=0,r=0;const a=e.length-1,A=this.parts,[l,c]=ju(e,t);if(this.el=ri.createElement(l,s),Lt.currentNode=this.el.content,t===2){const h=this.el.content,d=h.firstChild;d.remove(),h.append(...d.childNodes)}for(;(i=Lt.nextNode())!==null&&A.length<a;){if(i.nodeType===1){if(i.hasAttributes()){const h=[];for(const d of i.getAttributeNames())if(d.endsWith(Ao)||d.startsWith(ht)){const u=c[r++];if(h.push(d),u!==void 0){const g=i.getAttribute(u.toLowerCase()+Ao).split(ht),p=/([.?@])?(.*)/.exec(u);A.push({type:1,index:n,name:p[2],strings:g,ctor:p[1]==="."?Xu:p[1]==="?"?ed:p[1]==="@"?td:vn})}else A.push({type:6,index:n})}for(const d of h)i.removeAttribute(d)}if(fc.test(i.tagName)){const h=i.textContent.split(ht),d=h.length-1;if(d>0){i.textContent=hs?hs.emptyScript:"";for(let u=0;u<d;u++)i.append(h[u],ii()),Lt.nextNode(),A.push({type:2,index:++n});i.append(h[d],ii())}}}else if(i.nodeType===8)if(i.data===gc)A.push({type:2,index:n});else{let h=-1;for(;(h=i.data.indexOf(ht,h+1))!==-1;)A.push({type:7,index:n}),h+=ht.length-1}n++}}static createElement(e,t){const s=Nt.createElement("template");return s.innerHTML=e,s}}function ds(o,e,t=o,s){var i,n,r,a;if(e===us)return e;let A=s!==void 0?(i=t._$Co)===null||i===void 0?void 0:i[s]:t._$Cl;const l=ni(e)?void 0:e._$litDirective$;return(A==null?void 0:A.constructor)!==l&&((n=A==null?void 0:A._$AO)===null||n===void 0||n.call(A,!1),l===void 0?A=void 0:(A=new l(o),A._$AT(o,t,s)),s!==void 0?((r=(a=t)._$Co)!==null&&r!==void 0?r:a._$Co=[])[s]=A:t._$Cl=A),A!==void 0&&(e=ds(o,A._$AS(o,e.values),A,s)),e}class Wu{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:s},parts:i}=this._$AD,n=((t=e==null?void 0:e.creationScope)!==null&&t!==void 0?t:Nt).importNode(s,!0);Lt.currentNode=n;let r=Lt.nextNode(),a=0,A=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new li(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new sd(r,this,e)),this._$AV.push(c),l=i[++A]}a!==(l==null?void 0:l.index)&&(r=Lt.nextNode(),a++)}return Lt.currentNode=Nt,n}v(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class li{constructor(e,t,s,i){var n;this.type=2,this._$AH=ie,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=i,this._$Cp=(n=i==null?void 0:i.isConnected)===null||n===void 0||n}get _$AU(){var e,t;return(t=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&t!==void 0?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ds(this,e,t),ni(e)?e===ie||e==null||e===""?(this._$AH!==ie&&this._$AR(),this._$AH=ie):e!==this._$AH&&e!==us&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Yu(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==ie&&ni(this._$AH)?this._$AA.nextSibling.data=e:this.$(Nt.createTextNode(e)),this._$AH=e}g(e){var t;const{values:s,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ri.createElement(mc(i.h,i.h[0]),this.options)),i);if(((t=this._$AH)===null||t===void 0?void 0:t._$AD)===n)this._$AH.v(s);else{const r=new Wu(n,this),a=r.u(this.options);r.v(s),this.$(a),this._$AH=r}}_$AC(e){let t=ga.get(e.strings);return t===void 0&&ga.set(e.strings,t=new ri(e)),t}T(e){pc(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const n of e)i===t.length?t.push(s=new li(this.k(ii()),this.k(ii()),this,this.options)):s=t[i],s._$AI(n),i++;i<t.length&&(this._$AR(s&&s._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)===null||s===void 0||s.call(this,!1,!0,t);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cp=e,(t=this._$AP)===null||t===void 0||t.call(this,e))}}class vn{constructor(e,t,s,i,n){this.type=1,this._$AH=ie,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=ie}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,s,i){const n=this.strings;let r=!1;if(n===void 0)e=ds(this,e,t,0),r=!ni(e)||e!==this._$AH&&e!==us,r&&(this._$AH=e);else{const a=e;let A,l;for(e=n[0],A=0;A<n.length-1;A++)l=ds(this,a[s+A],t,A),l===us&&(l=this._$AH[A]),r||(r=!ni(l)||l!==this._$AH[A]),l===ie?e=ie:e!==ie&&(e+=(l??"")+n[A+1]),this._$AH[A]=l}r&&!i&&this.j(e)}j(e){e===ie?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Xu extends vn{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ie?void 0:e}}const Zu=hs?hs.emptyScript:"";class ed extends vn{constructor(){super(...arguments),this.type=4}j(e){e&&e!==ie?this.element.setAttribute(this.name,Zu):this.element.removeAttribute(this.name)}}class td extends vn{constructor(e,t,s,i,n){super(e,t,s,i,n),this.type=5}_$AI(e,t=this){var s;if((e=(s=ds(this,e,t,0))!==null&&s!==void 0?s:ie)===us)return;const i=this._$AH,n=e===ie&&i!==ie||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==ie&&(i===ie||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,s;typeof this._$AH=="function"?this._$AH.call((s=(t=this.options)===null||t===void 0?void 0:t.host)!==null&&s!==void 0?s:this.element,e):this._$AH.handleEvent(e)}}class sd{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){ds(this,e)}}const pa=ln.litHtmlPolyfillSupport;pa==null||pa(ri,li),((Ln=ln.litHtmlVersions)!==null&&Ln!==void 0?Ln:ln.litHtmlVersions=[]).push("2.8.0");const Ic=(o,e,t)=>{var s,i;const n=(s=t==null?void 0:t.renderBefore)!==null&&s!==void 0?s:e;let r=n._$litPart$;if(r===void 0){const a=(i=t==null?void 0:t.renderBefore)!==null&&i!==void 0?i:null;n._$litPart$=r=new li(e.insertBefore(ii(),a),a,void 0,t??{})}return r._$AI(o),r};/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Nn,kn;class Ki extends _t{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const s=super.createRenderRoot();return(e=(t=this.renderOptions).renderBefore)!==null&&e!==void 0||(t.renderBefore=s.firstChild),s}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ic(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return us}}Ki.finalized=!0,Ki._$litElement$=!0,(Nn=globalThis.litElementHydrateSupport)===null||Nn===void 0||Nn.call(globalThis,{LitElement:Ki});const fa=globalThis.litElementPolyfillSupport;fa==null||fa({LitElement:Ki});((kn=globalThis.litElementVersions)!==null&&kn!==void 0?kn:globalThis.litElementVersions=[]).push("3.3.3");/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const id=(o,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(t){t.createProperty(e.key,o)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(t){t.createProperty(e.key,o)}},nd=(o,e,t)=>{e.constructor.createProperty(t,o)};function F(o){return(e,t)=>t!==void 0?nd(o,e,t):id(o,e)}/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Un;((Un=window.HTMLSlotElement)===null||Un===void 0?void 0:Un.prototype.assignedElements)!=null;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ec=navigator.xr!=null&&self.XRSession!=null&&navigator.xr.isSessionSupported!=null,Cc=Ec&&self.XRSession.prototype.requestHitTestSource!=null,Gn=self.ResizeObserver!=null,On=self.IntersectionObserver!=null,Bc=Cc;(()=>{const o=navigator.userAgent||navigator.vendor||self.opera;let e=!1;return(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(o)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(o.substr(0,4)))&&(e=!0),e})();const rd=/android/i.test(navigator.userAgent),od=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,ad=/firefox/i.test(navigator.userAgent),Ad=/OculusBrowser/.test(navigator.userAgent),ld=rd&&!ad&&!Ad,cd=!!(window.webkit&&window.webkit.messageHandlers),ma=(()=>{if(od){if(cd)return!!/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{const o=document.createElement("a");return!!(o.relList&&o.relList.supports&&o.relList.supports("ar"))}}else return!1})();/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yc=o=>o&&o!=="null"?hd(o):null,Ia=()=>{if(Bc)return;const o=[];throw Ec||o.push("WebXR Device API"),Cc||o.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${o.join(", ")}`)},hd=o=>new URL(o,window.location.toString()).toString(),ud=(o,e)=>{let t=null;const s=(...i)=>{t==null&&(o(...i),t=self.setTimeout(()=>t=null,e))};return s.flush=()=>{t!=null&&(self.clearTimeout(t),t=null)},s},Ea=(o,e)=>{let t=null;return(...s)=>{t!=null&&self.clearTimeout(t),t=self.setTimeout(()=>{t=null,o(...s)},e)}},ke=(o,e,t)=>Math.max(e,Math.min(t,o)),dd=1,lo=(()=>{const o=(()=>{var e;if(!((e=document.documentElement.getAttribute("itemtype"))===null||e===void 0)&&e.includes("schema.org/SearchResultsPage"))return!0;const t=document.head!=null?Array.from(document.head.querySelectorAll("meta")):[];for(const s of t)if(s.name==="viewport")return!0;return!1})();return o||console.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.'),()=>o?window.devicePixelRatio:dd})(),wc=(()=>{const o="model-viewer-debug-mode",e=new RegExp(`[?&]${o}(&|$)`);return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(e)})(),gd=(o=0)=>new Promise(e=>setTimeout(e,o)),pd=(o,e,t=null)=>new Promise(s=>{function i(n){(!t||t(n))&&(s(n),o.removeEventListener(e,i))}o.addEventListener(e,i)});/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var yt=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const fd=.5,md=0,Id=1,Ed=1,$s=Symbol("currentEnvironmentMap"),Vs=Symbol("currentBackground"),cn=Symbol("updateEnvironment"),gi=Symbol("cancelEnvironmentUpdate"),Cd=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=md,this.shadowSoftness=Id,this.exposure=Ed,this.toneMapping="auto",this.skyboxHeight="0",this[e]=null,this[t]=null,this[s]=null}updated(r){super.updated(r),r.has("shadowIntensity")&&(this[v].setShadowIntensity(this.shadowIntensity*fd),this[ce]()),r.has("shadowSoftness")&&(this[v].setShadowSoftness(this.shadowSoftness),this[ce]()),r.has("exposure")&&(this[v].exposure=this.exposure,this[ce]()),r.has("toneMapping")&&(this[v].toneMapping=this.toneMapping==="commerce"?Wl:this.toneMapping==="agx"?Vh:xo,this[ce]()),(r.has("environmentImage")||r.has("skyboxImage"))&&this[gs]()&&this[cn](),r.has("skyboxHeight")&&(this[v].setGroundedSkybox(),this[ce]())}hasBakedShadow(){return this[v].bakedShadows.size>0}async[(e=$s,t=Vs,s=gi,cn)](){const{skyboxImage:r,environmentImage:a}=this;this[gi]!=null&&(this[gi](),this[gi]=null);const{textureUtils:A}=this[V];if(A==null)return;const l=this[kt].beginActivity("environment-update");try{const{environmentMap:c,skybox:h}=await A.generateEnvironmentMapAndSkybox(yc(r),a,d=>l(ke(d,0,1)));this[$s]!==c&&(this[$s]=c,this.dispatchEvent(new CustomEvent("environment-change"))),h!=null?this[Vs]=h.name===c.name?c:h:this[Vs]=null,this[v].setEnvironmentAndSkybox(this[$s],this[Vs])}catch(c){if(c instanceof Error)throw this[v].setEnvironmentAndSkybox(null,null),c}finally{l(1)}}}return yt([F({type:String,attribute:"environment-image"})],i.prototype,"environmentImage",void 0),yt([F({type:String,attribute:"skybox-image"})],i.prototype,"skyboxImage",void 0),yt([F({type:Number,attribute:"shadow-intensity"})],i.prototype,"shadowIntensity",void 0),yt([F({type:Number,attribute:"shadow-softness"})],i.prototype,"shadowSoftness",void 0),yt([F({type:Number})],i.prototype,"exposure",void 0),yt([F({type:String,attribute:"tone-mapping"})],i.prototype,"toneMapping",void 0),yt([F({type:String,attribute:"skybox-height"})],i.prototype,"skyboxHeight",void 0),i};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Bd=Qn`
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000">
    <!-- NOTE(cdata): This SVG filter is a stop-gap until we can implement
         support for dynamic re-coloring of UI components -->
    <defs>
      <filter id="drop-shadow" x="-100%" y="-100%" width="300%" height="300%">
        <feGaussianBlur in="SourceAlpha" stdDeviation="1"/>
        <feOffset dx="0" dy="0" result="offsetblur"/>
        <feFlood flood-color="#000000"/>
        <feComposite in2="offsetblur" operator="in"/>
        <feMerge>
          <feMergeNode/>
          <feMergeNode in="SourceGraphic"/>
        </feMerge>
      </filter>
    </defs>
    <path filter="url(#drop-shadow)" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
    <path d="M0 0h24v24H0z" fill="none"/>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yd=Qn`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="36">
    <defs>
        <path id="A" d="M.001.232h24.997V36H.001z" />
    </defs>
    <g transform="translate(-11 -4)" fill="none" fill-rule="evenodd">
        <path fill-opacity="0" fill="#fff" d="M0 0h44v44H0z" />
        <g transform="translate(11 3)">
            <path d="M8.733 11.165c.04-1.108.766-2.027 1.743-2.307a2.54 2.54 0 0 1 .628-.089c.16 0 .314.017.463.044 1.088.2 1.9 1.092 1.9 2.16v8.88h1.26c2.943-1.39 5-4.45 5-8.025a9.01 9.01 0 0 0-1.9-5.56l-.43-.5c-.765-.838-1.683-1.522-2.712-2-1.057-.49-2.226-.77-3.46-.77s-2.4.278-3.46.77c-1.03.478-1.947 1.162-2.71 2l-.43.5a9.01 9.01 0 0 0-1.9 5.56 9.04 9.04 0 0 0 .094 1.305c.03.21.088.41.13.617l.136.624c.083.286.196.56.305.832l.124.333a8.78 8.78 0 0 0 .509.953l.065.122a8.69 8.69 0 0 0 3.521 3.191l1.11.537v-9.178z" fill-opacity=".5" fill="#e4e4e4" />
            <path d="M22.94 26.218l-2.76 7.74c-.172.485-.676.8-1.253.8H12.24c-1.606 0-3.092-.68-3.98-1.82-1.592-2.048-3.647-3.822-6.11-5.27-.095-.055-.15-.137-.152-.23-.004-.1.046-.196.193-.297.56-.393 1.234-.6 1.926-.6a3.43 3.43 0 0 1 .691.069l4.922.994V10.972c0-.663.615-1.203 1.37-1.203s1.373.54 1.373 1.203v9.882h2.953c.273 0 .533.073.757.21l6.257 3.874c.027.017.045.042.07.06.41.296.586.77.426 1.22M4.1 16.614c-.024-.04-.042-.083-.065-.122a8.69 8.69 0 0 1-.509-.953c-.048-.107-.08-.223-.124-.333l-.305-.832c-.058-.202-.09-.416-.136-.624l-.13-.617a9.03 9.03 0 0 1-.094-1.305c0-2.107.714-4.04 1.9-5.56l.43-.5c.764-.84 1.682-1.523 2.71-2 1.058-.49 2.226-.77 3.46-.77s2.402.28 3.46.77c1.03.477 1.947 1.16 2.712 2l.428.5a9 9 0 0 1 1.901 5.559c0 3.577-2.056 6.636-5 8.026h-1.26v-8.882c0-1.067-.822-1.96-1.9-2.16-.15-.028-.304-.044-.463-.044-.22 0-.427.037-.628.09-.977.28-1.703 1.198-1.743 2.306v9.178l-1.11-.537C6.18 19.098 4.96 18 4.1 16.614M22.97 24.09l-6.256-3.874c-.102-.063-.218-.098-.33-.144 2.683-1.8 4.354-4.855 4.354-8.243 0-.486-.037-.964-.104-1.43a9.97 9.97 0 0 0-1.57-4.128l-.295-.408-.066-.092a10.05 10.05 0 0 0-.949-1.078c-.342-.334-.708-.643-1.094-.922-1.155-.834-2.492-1.412-3.94-1.65l-.732-.088-.748-.03a9.29 9.29 0 0 0-1.482.119c-1.447.238-2.786.816-3.94 1.65a9.33 9.33 0 0 0-.813.686 9.59 9.59 0 0 0-.845.877l-.385.437-.36.5-.288.468-.418.778-.04.09c-.593 1.28-.93 2.71-.93 4.222 0 3.832 2.182 7.342 5.56 8.938l1.437.68v4.946L5 25.64a4.44 4.44 0 0 0-.888-.086c-.017 0-.034.003-.05.003-.252.004-.503.033-.75.08a5.08 5.08 0 0 0-.237.056c-.193.046-.382.107-.568.18-.075.03-.15.057-.225.1-.25.114-.494.244-.723.405a1.31 1.31 0 0 0-.566 1.122 1.28 1.28 0 0 0 .645 1.051C4 29.925 5.96 31.614 7.473 33.563a5.06 5.06 0 0 0 .434.491c1.086 1.082 2.656 1.713 4.326 1.715h6.697c.748-.001 1.43-.333 1.858-.872.142-.18.256-.38.336-.602l2.757-7.74c.094-.26.13-.53.112-.794s-.088-.52-.203-.76a2.19 2.19 0 0 0-.821-.91" fill-opacity=".6" fill="#000" />
            <path d="M22.444 24.94l-6.257-3.874a1.45 1.45 0 0 0-.757-.211h-2.953v-9.88c0-.663-.616-1.203-1.373-1.203s-1.37.54-1.37 1.203v16.643l-4.922-.994a3.44 3.44 0 0 0-.692-.069 3.35 3.35 0 0 0-1.925.598c-.147.102-.198.198-.194.298.004.094.058.176.153.23 2.462 1.448 4.517 3.22 6.11 5.27.887 1.14 2.373 1.82 3.98 1.82h6.686c.577 0 1.08-.326 1.253-.8l2.76-7.74c.16-.448-.017-.923-.426-1.22-.025-.02-.043-.043-.07-.06z" fill="#fff" />
            <g transform="translate(0 .769)">
                <mask id="B" fill="#fff">
                    <use xlink:href="#A" />
                </mask>
                <path d="M23.993 24.992a1.96 1.96 0 0 1-.111.794l-2.758 7.74c-.08.22-.194.423-.336.602-.427.54-1.11.87-1.857.872h-6.698c-1.67-.002-3.24-.633-4.326-1.715-.154-.154-.3-.318-.434-.49C5.96 30.846 4 29.157 1.646 27.773c-.385-.225-.626-.618-.645-1.05a1.31 1.31 0 0 1 .566-1.122 4.56 4.56 0 0 1 .723-.405l.225-.1a4.3 4.3 0 0 1 .568-.18l.237-.056c.248-.046.5-.075.75-.08.018 0 .034-.003.05-.003.303-.001.597.027.89.086l3.722.752V20.68l-1.436-.68c-3.377-1.596-5.56-5.106-5.56-8.938 0-1.51.336-2.94.93-4.222.015-.03.025-.06.04-.09.127-.267.268-.525.418-.778.093-.16.186-.316.288-.468.063-.095.133-.186.2-.277L3.773 5c.118-.155.26-.29.385-.437.266-.3.544-.604.845-.877a9.33 9.33 0 0 1 .813-.686C6.97 2.167 8.31 1.59 9.757 1.35a9.27 9.27 0 0 1 1.481-.119 8.82 8.82 0 0 1 .748.031c.247.02.49.05.733.088 1.448.238 2.786.816 3.94 1.65.387.28.752.588 1.094.922a9.94 9.94 0 0 1 .949 1.078l.066.092c.102.133.203.268.295.408a9.97 9.97 0 0 1 1.571 4.128c.066.467.103.945.103 1.43 0 3.388-1.67 6.453-4.353 8.243.11.046.227.08.33.144l6.256 3.874c.37.23.645.55.82.9.115.24.185.498.203.76m.697-1.195c-.265-.55-.677-1.007-1.194-1.326l-5.323-3.297c2.255-2.037 3.564-4.97 3.564-8.114 0-2.19-.637-4.304-1.84-6.114-.126-.188-.26-.37-.4-.552-.645-.848-1.402-1.6-2.252-2.204C15.472.91 13.393.232 11.238.232A10.21 10.21 0 0 0 5.23 2.19c-.848.614-1.606 1.356-2.253 2.205-.136.18-.272.363-.398.55C1.374 6.756.737 8.87.737 11.06c0 4.218 2.407 8.08 6.133 9.842l.863.41v3.092l-2.525-.51c-.356-.07-.717-.106-1.076-.106a5.45 5.45 0 0 0-3.14.996c-.653.46-1.022 1.202-.99 1.983a2.28 2.28 0 0 0 1.138 1.872c2.24 1.318 4.106 2.923 5.543 4.772 1.26 1.62 3.333 2.59 5.55 2.592h6.698c1.42-.001 2.68-.86 3.134-2.138l2.76-7.74c.272-.757.224-1.584-.134-2.325" fill-opacity=".05" fill="#000" mask="url(#B)" />
            </g>
        </g>
    </g>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const wd=Qn`
<svg version="1.1" id="view_x5F_in_x5F_AR_x5F_icon"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px"
	 viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<rect id="Bounding_Box" x="0" y="0" fill="none" width="24" height="24"/>
<g id="Art_layer">
	<path d="M3,4c0-0.55,0.45-1,1-1h2V1H4C2.35,1,1,2.35,1,4v2h2V4z"/>
	<path d="M20,3c0.55,0,1,0.45,1,1v2h2V4c0-1.65-1.35-3-3-3h-2v2H20z"/>
	<path d="M4,21c-0.55,0-1-0.45-1-1v-2H1v2c0,1.65,1.35,3,3,3h2v-2H4z"/>
	<path d="M20,21c0.55,0,1-0.45,1-1v-2h2v2c0,1.65-1.35,3-3,3h-2v-2H20z"/>
	<g>
		<path d="M18.25,7.6l-5.5-3.18c-0.46-0.27-1.04-0.27-1.5,0L5.75,7.6C5.29,7.87,5,8.36,5,8.9v6.35c0,0.54,0.29,1.03,0.75,1.3
			l5.5,3.18c0.46,0.27,1.04,0.27,1.5,0l5.5-3.18c0.46-0.27,0.75-0.76,0.75-1.3V8.9C19,8.36,18.71,7.87,18.25,7.6z M7,14.96v-4.62
			l4,2.32v4.61L7,14.96z M12,10.93L8,8.61l4-2.31l4,2.31L12,10.93z M13,17.27v-4.61l4-2.32v4.62L13,17.27z"/>
	</g>
</g>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Qd=Qn`
<style>
:host {
  display: block;
  position: relative;
  contain: strict;
  width: 300px;
  height: 150px;
}

.container {
  position: relative;
  overflow: hidden;
}

.userInput {
  width: 100%;
  height: 100%;
  display: none;
  position: relative;
  outline-offset: -1px;
  outline-width: 1px;
}

canvas {
  position: absolute;
  display: none;
  pointer-events: none;
  /* NOTE(cdata): Chrome 76 and below apparently have a bug
   * that causes our canvas not to display pixels unless it is
   * on its own render layer
   * @see https://github.com/google/model-viewer/pull/755#issuecomment-536597893
   */
  transform: translateZ(0);
}

.show {
  display: block;
}

/* Adapted from HTML5 Boilerplate
 *
 * @see https://github.com/h5bp/html5-boilerplate/blob/ceb4620c78fc82e13534fc44202a3f168754873f/dist/css/main.css#L122-L133 */
.screen-reader-only {
  border: 0;
  left: 0;
  top: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  pointer-events: none;
}

.slot {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.slot > * {
  pointer-events: initial;
}

.annotation-wrapper ::slotted(*) {
  opacity: var(--max-hotspot-opacity, 1);
  transition: opacity 0.3s;
}

.pointer-tumbling .annotation-wrapper ::slotted(*) {
  pointer-events: none;
}

.annotation-wrapper ::slotted(*) {
  pointer-events: initial;
}

.annotation-wrapper.hide ::slotted(*) {
  opacity: var(--min-hotspot-opacity, 0.25);
}

.slot.poster {
  display: none;
  background-color: inherit;
}

.slot.poster.show {
  display: inherit;
}

.slot.poster > * {
  pointer-events: initial;
}

.slot.poster:not(.show) > * {
  pointer-events: none;
}

#default-poster {
  width: 100%;
  height: 100%;
  /* The default poster is a <button> so we need to set display
   * to prevent it from being affected by text-align: */
  display: block;
  position: absolute;
  border: none;
  padding: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff0;
}

#default-progress-bar {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

#default-progress-bar > .bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--progress-bar-height, 5px);
  background-color: var(--progress-bar-color, rgba(0, 0, 0, 0.4));
  transition: transform 0.09s;
  transform-origin: top left;
  transform: scaleX(0);
  overflow: hidden;
}

#default-progress-bar > .bar.hide {
  transition: opacity 0.3s 1s;
  opacity: 0;
}

.centered {
  align-items: center;
  justify-content: center;
}

.cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.slot.interaction-prompt {
  display: var(--interaction-prompt-display, flex);
  overflow: hidden;
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.3s;
}

.slot.interaction-prompt.visible {
  opacity: 1;
}

.animated-container {
  will-change: transform, opacity;
  opacity: 0;
  transition: opacity 0.3s;
}

.slot.interaction-prompt > * {
  pointer-events: none;
}

.slot.ar-button {
  -moz-user-select: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;

  display: var(--ar-button-display, block);
}

.slot.ar-button:not(.enabled) {
  display: none;
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background-color: #fff;
  box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15);
  border-radius: 100px;
}

.fab > * {
  opacity: 0.87;
}

#default-ar-button {
  position: absolute;
  bottom: 16px;
  right: 16px;
  transform: scale(var(--ar-button-scale, 1));
  transform-origin: bottom right;
}

.slot.pan-target {
  display: block;
  position: absolute;
  width: 0;
  height: 0;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  background-color: transparent;
  opacity: 0;
  transition: opacity 0.3s;
}

#default-pan-target {
  width: 6px;
  height: 6px;
  border-radius: 6px;
  border: 1px solid white;
  box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.8);
}

.slot.default {
  pointer-events: none;
}

.slot.progress-bar {
  pointer-events: none;
}

.slot.exit-webxr-ar-button {
  pointer-events: none;
}

.slot.exit-webxr-ar-button:not(.enabled) {
  display: none;
}

#default-exit-webxr-ar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
}

#default-exit-webxr-ar-button > svg {
  fill: #fff;
}
</style>
<div class="container">
  <div class="userInput" tabindex="0" role="img"
      aria-label="3D model">
      <div class="slot canvas">
        <slot name="canvas">
          <canvas></canvas>
        </slot>
      </div>

  </div>

  <!-- NOTE(cdata): We need to wrap slots because browsers without ShadowDOM
        will have their <slot> elements removed by ShadyCSS -->
  <div class="slot poster">
    <slot name="poster">
      <button type="button" id="default-poster" aria-hidden="true" aria-label="Loading 3D model"></button>
    </slot>
  </div>

  <div class="slot ar-button">
    <slot name="ar-button">
      <a id="default-ar-button" part="default-ar-button" class="fab"
          tabindex="2"
          role="button"
          href="javascript:void(0);"
          aria-label="View in your space">
        ${wd}
      </a>
    </slot>
  </div>

  <div class="slot pan-target">
    <slot name="pan-target">
      <div id="default-pan-target">
      </div>
    </slot>
  </div>

  <div class="slot interaction-prompt cover centered">
    <div id="prompt" class="animated-container">
      <slot name="interaction-prompt" aria-hidden="true">
        ${yd}
      </slot>
    </div>
  </div>

  <div id="finger0" class="animated-container cover">
    <slot name="finger0" aria-hidden="true">
    </slot>
  </div>
  <div id="finger1" class="animated-container cover">
    <slot name="finger1" aria-hidden="true">
    </slot>
  </div>

  <div class="slot default">
    <slot></slot>

    <div class="slot progress-bar">
      <slot name="progress-bar">
        <div id="default-progress-bar" aria-hidden="true">
          <div class="bar" part="default-progress-bar"></div>
        </div>
      </slot>
    </div>

    <div class="slot exit-webxr-ar-button">
      <slot name="exit-webxr-ar-button">
        <a id="default-exit-webxr-ar-button" part="default-exit-webxr-ar-button"
            tabindex="3"
            aria-label="Exit AR"
            aria-hidden="true">
          ${Bd}
        </a>
      </slot>
    </div>
  </div>
</div>
<div class="screen-reader-only" role="region" aria-label="Live announcements">
  <span id="status" role="status"></span>
</div>`,vd=o=>{Ic(Qd,o)},Pn=new WeakMap;class Sd extends fn{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,i){const n=new pt(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,r=>{this.parse(r,t,i)},s,i)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,Ee).catch(s)}decodeDracoFile(e,t,s,i,n=ee,r=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const s=JSON.stringify(t);if(Pn.has(e)){const A=Pn.get(e);if(A.key===s)return A.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const n=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(n,r).then(A=>(i=A,new Promise((l,c)=>{i._callbacks[n]={resolve:l,reject:c},i.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(A=>this._createGeometry(A.geometry));return a.catch(()=>!0).then(()=>{i&&n&&this._releaseTask(i,n)}),Pn.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new bo;e.index&&t.setIndex(new Te(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const i=e.attributes[s],n=i.name,r=i.array,a=i.itemSize,A=new Te(r,a);n==="color"&&(this._assignVertexColorSpace(A,i.vertexColorSpace),A.normalized=!(r instanceof Float32Array)),t.setAttribute(n,A)}return t}_assignVertexColorSpace(e,t){if(t!==Ee)return;const s=new Le;for(let i=0,n=e.count;i<n;i++)s.fromBufferAttribute(e,i).convertSRGBToLinear(),e.setXYZ(i,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new pt(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((i,n)=>{s.load(e,i,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const i=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const n=xd.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(n){const r=n.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,n){return i._taskLoad>n._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function xd(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(c){o.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(o)});break;case"decode":const A=a.buffer,l=a.taskConfig;e.then(c=>{const h=c.draco,d=new h.Decoder;try{const u=t(h,d,new Int8Array(A),l),g=u.attributes.map(p=>p.array.buffer);u.index&&g.push(u.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:u},g)}catch(u){console.error(u),self.postMessage({type:"error",id:a.id,error:u.message})}finally{h.destroy(d)}});break}};function t(r,a,A,l){const c=l.attributeIDs,h=l.attributeTypes;let d,u;const g=a.GetEncodedGeometryType(A);if(g===r.TRIANGULAR_MESH)d=new r.Mesh,u=a.DecodeArrayToMesh(A,A.byteLength,d);else if(g===r.POINT_CLOUD)d=new r.PointCloud,u=a.DecodeArrayToPointCloud(A,A.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const p={index:null,attributes:[]};for(const f in c){const I=self[h[f]];let C,w;if(l.useUniqueIDs)w=c[f],C=a.GetAttributeByUniqueId(d,w);else{if(w=a.GetAttributeId(d,r[c[f]]),w===-1)continue;C=a.GetAttribute(d,w)}const m=i(r,a,d,f,I,C);f==="color"&&(m.vertexColorSpace=l.vertexColorSpace),p.attributes.push(m)}return g===r.TRIANGULAR_MESH&&(p.index=s(r,a,d)),r.destroy(d),p}function s(r,a,A){const c=A.num_faces()*3,h=c*4,d=r._malloc(h);a.GetTrianglesUInt32Array(A,h,d);const u=new Uint32Array(r.HEAPF32.buffer,d,c).slice();return r._free(d),{array:u,itemSize:1}}function i(r,a,A,l,c,h){const d=h.num_components(),g=A.num_points()*d,p=g*c.BYTES_PER_ELEMENT,f=n(r,c),I=r._malloc(p);a.GetAttributeDataArrayForAllPoints(A,h,f,p,I);const C=new c(r.HEAPF32.buffer,I,g).slice();return r._free(I),{name:l,array:C,itemSize:d}}function n(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}function Ca(o,e){if(e===qh)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===ro||e===Xl){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let A=0;A<a.count;A++)r.push(A);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const s=t.count-2,i=[];if(e===ro)for(let r=1;r<=s;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=o.clone();return n.setIndex(i),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class bd extends fn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new _d(t)}),this.register(function(t){return new Hd(t)}),this.register(function(t){return new $d(t)}),this.register(function(t){return new Vd(t)}),this.register(function(t){return new Fd(t)}),this.register(function(t){return new Nd(t)}),this.register(function(t){return new kd(t)}),this.register(function(t){return new Ud(t)}),this.register(function(t){return new Dd(t)}),this.register(function(t){return new Gd(t)}),this.register(function(t){return new Ld(t)}),this.register(function(t){return new Pd(t)}),this.register(function(t){return new Od(t)}),this.register(function(t){return new Md(t)}),this.register(function(t){return new qd(t)}),this.register(function(t){return new Kd(t)})}load(e,t,s,i){const n=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=js.extractUrlBase(e);r=js.resolveURL(l,this.path)}else r=js.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){i?i(l):console.error(l),n.manager.itemError(e),n.manager.itemEnd(e)},A=new pt(this.manager);A.setPath(this.path),A.setResponseType("arraybuffer"),A.setRequestHeader(this.requestHeader),A.setWithCredentials(this.withCredentials),A.load(e,function(l){try{n.parse(l,r,function(c){t(c),n.manager.itemEnd(e)},a)}catch(c){a(c)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,i){let n;const r={},a={},A=new TextDecoder;if(typeof e=="string")n=JSON.parse(e);else if(e instanceof ArrayBuffer)if(A.decode(new Uint8Array(e,0,4))===Qc){try{r[H.KHR_BINARY_GLTF]=new zd(e)}catch(h){i&&i(h);return}n=JSON.parse(r[H.KHR_BINARY_GLTF].content)}else n=JSON.parse(A.decode(e));else n=e;if(n.asset===void 0||n.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new og(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const h=this.pluginCallbacks[c](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,r[h.name]=!0}if(n.extensionsUsed)for(let c=0;c<n.extensionsUsed.length;++c){const h=n.extensionsUsed[c],d=n.extensionsRequired||[];switch(h){case H.KHR_MATERIALS_UNLIT:r[h]=new Rd;break;case H.KHR_DRACO_MESH_COMPRESSION:r[h]=new Yd(n,this.dracoLoader);break;case H.KHR_TEXTURE_TRANSFORM:r[h]=new Jd;break;case H.KHR_MESH_QUANTIZATION:r[h]=new jd;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(s,i)}parseAsync(e,t){const s=this;return new Promise(function(i,n){s.parse(e,t,i,n)})}}function Td(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const H={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Md{constructor(e){this.parser=e,this.name=H.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s<i;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let i=t.cache.get(s);if(i)return i;const n=t.json,A=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let l;const c=new Le(16777215);A.color!==void 0&&c.setRGB(A.color[0],A.color[1],A.color[2],ee);const h=A.range!==void 0?A.range:0;switch(A.type){case"directional":l=new ec(c),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Zl(c),l.distance=h;break;case"spot":l=new Kh(c),l.distance=h,A.spot=A.spot||{},A.spot.innerConeAngle=A.spot.innerConeAngle!==void 0?A.spot.innerConeAngle:0,A.spot.outerConeAngle=A.spot.outerConeAngle!==void 0?A.spot.outerConeAngle:Math.PI/4,l.angle=A.spot.outerConeAngle,l.penumbra=1-A.spot.innerConeAngle/A.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+A.type)}return l.position.set(0,0,0),l.decay=2,lt(l,A),A.intensity!==void 0&&(l.intensity=A.intensity),l.name=t.createUniqueName(A.name||"light_"+e),i=Promise.resolve(l),t.cache.add(s,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],a=(n.extensions&&n.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(A){return s._getNodeRef(t.cache,a,A)})}}let Rd=class{constructor(){this.name=H.KHR_MATERIALS_UNLIT}getMaterialType(){return Ue}extendParams(e,t,s){const i=[];e.color=new Le(1,1,1),e.opacity=1;const n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){const r=n.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],ee),e.opacity=r[3]}n.baseColorTexture!==void 0&&i.push(s.assignTexture(e,"map",n.baseColorTexture,Ee))}return Promise.all(i)}},Dd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return n!==void 0&&(t.emissiveIntensity=n),Promise.resolve()}},_d=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&n.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&n.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(n.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new De(a,a)}return Promise.all(n)}},Ld=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&n.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&n.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(n)}},Fd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[];t.sheenColor=new Le(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],ee)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&n.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,Ee)),r.sheenRoughnessTexture!==void 0&&n.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(n)}},Nd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&n.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(n)}},kd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&n.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new Le().setRGB(a[0],a[1],a[2],ee),Promise.all(n)}},Ud=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}},Gd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&n.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new Le().setRGB(a[0],a[1],a[2],ee),r.specularColorTexture!==void 0&&n.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,Ee)),Promise.all(n)}},Od=class{constructor(e){this.parser=e,this.name=H.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&n.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(n)}},Pd=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:st}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&n.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(n)}};class Hd{constructor(e){this.parser=e,this.name=H.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,i=s.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const n=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,r)}}class $d{constructor(e){this.parser=e,this.name=H.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const r=n.extensions[t],a=i.images[r.source];let A=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(A=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,r.source,A);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Vd{constructor(e){this.parser=e,this.name=H.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const r=n.extensions[t],a=i.images[r.source];let A=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(A=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,r.source,A);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class qd{constructor(e){this.name=H.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const i=s.extensions[this.name],n=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(a){const A=i.byteOffset||0,l=i.byteLength||0,c=i.count,h=i.byteStride,d=new Uint8Array(a,A,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,h,d,i.mode,i.filter).then(function(u){return u.buffer}):r.ready.then(function(){const u=new ArrayBuffer(c*h);return r.decodeGltfBuffer(new Uint8Array(u),c,h,d,i.mode,i.filter),u})})}else return null}}let Kd=class{constructor(e){this.name=H.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const i=t.meshes[s.mesh];for(const l of i.primitives)if(l.mode!==be.TRIANGLES&&l.mode!==be.TRIANGLE_STRIP&&l.mode!==be.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],A={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(c=>(A[l]=c,A[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,u=[];for(const g of h){const p=new Ve,f=new N,I=new In,C=new N(1,1,1),w=new zh(g.geometry,g.material,d);for(let m=0;m<d;m++)A.TRANSLATION&&f.fromBufferAttribute(A.TRANSLATION,m),A.ROTATION&&I.fromBufferAttribute(A.ROTATION,m),A.SCALE&&C.fromBufferAttribute(A.SCALE,m),w.setMatrixAt(m,p.compose(f,I,C));for(const m in A)if(m==="_COLOR_0"){const E=A[m];w.instanceColor=new Yh(E.array,E.itemSize,E.normalized)}else m!=="TRANSLATION"&&m!=="ROTATION"&&m!=="SCALE"&&g.geometry.setAttribute(m,A[m]);Ai.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),u.push(w)}return c.isGroup?(c.clear(),c.add(...u),c):u[0]}))}};const Qc="glTF",ys=12,Ba={JSON:1313821514,BIN:5130562};class zd{constructor(e){this.name=H.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ys),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Qc)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ys,n=new DataView(e,ys);let r=0;for(;r<i;){const a=n.getUint32(r,!0);r+=4;const A=n.getUint32(r,!0);if(r+=4,A===Ba.JSON){const l=new Uint8Array(e,ys+r,a);this.content=s.decode(l)}else if(A===Ba.BIN){const l=ys+r;this.body=e.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Yd{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=H.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,i=this.dracoLoader,n=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},A={},l={};for(const c in r){const h=co[c]||c.toLowerCase();a[h]=r[c]}for(const c in e.attributes){const h=co[c]||c.toLowerCase();if(r[c]!==void 0){const d=s.accessors[e.attributes[c]],u=As[d.componentType];l[h]=u.name,A[h]=d.normalized===!0}}return t.getDependency("bufferView",n).then(function(c){return new Promise(function(h,d){i.decodeDracoFile(c,function(u){for(const g in u.attributes){const p=u.attributes[g],f=A[g];f!==void 0&&(p.normalized=f)}h(u)},a,l,ee,d)})})}}class Jd{constructor(){this.name=H.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class jd{constructor(){this.name=H.KHR_MESH_QUANTIZATION}}class vc extends Au{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let r=0;r!==i;r++)t[r]=s[n+r];return t}interpolate_(e,t,s,i){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,A=a*2,l=a*3,c=i-t,h=(s-t)/c,d=h*h,u=d*h,g=e*l,p=g-l,f=-2*u+3*d,I=u-d,C=1-f,w=I-d+h;for(let m=0;m!==a;m++){const E=r[p+m+a],B=r[p+m+A]*c,Q=r[g+m+a],y=r[g+m]*c;n[m]=C*E+w*B+f*Q+I*y}return n}}const Wd=new In;class Xd extends vc{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return Wd.fromArray(n).normalize().toArray(n),n}}const be={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},As={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ya={9728:ms,9729:ae,9984:En,9985:Cn,9986:Bn,9987:fs},wa={33071:Me,33648:yn,10497:mt},Hn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},co={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},rt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zd={CUBICSPLINE:void 0,LINEAR:To,STEP:sc},$n={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function eg(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new nn({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Mo})),o.DefaultMaterial}function wt(o,e,t){for(const s in t.extensions)o[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function lt(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function tg(o,e,t){let s=!1,i=!1,n=!1;for(let l=0,c=e.length;l<c;l++){const h=e[l];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(n=!0),s&&i&&n)break}if(!s&&!i&&!n)return Promise.resolve(o);const r=[],a=[],A=[];for(let l=0,c=e.length;l<c;l++){const h=e[l];if(s){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):o.attributes.position;r.push(d)}if(i){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):o.attributes.normal;a.push(d)}if(n){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):o.attributes.color;A.push(d)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(A)]).then(function(l){const c=l[0],h=l[1],d=l[2];return s&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=h),n&&(o.morphAttributes.color=d),o.morphTargetsRelative=!0,o})}function sg(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let s=0,i=t.length;s<i;s++)o.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ig(o){let e;const t=o.extensions&&o.extensions[H.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Vn(t.attributes):e=o.indices+":"+Vn(o.attributes)+":"+o.mode,o.targets!==void 0)for(let s=0,i=o.targets.length;s<i;s++)e+=":"+Vn(o.targets[s]);return e}function Vn(o){let e="";const t=Object.keys(o).sort();for(let s=0,i=t.length;s<i;s++)e+=t[s]+":"+o[t[s]]+";";return e}function ho(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function ng(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const rg=new Ve;class og{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Td,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,i=!1,n=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,n=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||i&&n<98?this.textureLoader=new tc(this.options.manager):this.textureLoader=new Jh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new pt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,i=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:s,userData:{}};return wt(n,a,i),lt(a,i),Promise.all(s._invokeAll(function(A){return A.afterRoot&&A.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const r=t[i].joints;for(let a=0,A=r.length;a<A;a++)e[r[a]].isBone=!0}for(let i=0,n=e.length;i<n;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const i=s.clone(),n=(r,a)=>{const A=this.associations.get(r);A!=null&&this.associations.set(a,A);for(const[l,c]of r.children.entries())n(c,a.children[l])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const i=e(t[s]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let i=0;i<t.length;i++){const n=e(t[i]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let i=this.cache.get(s);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(n){return n.loadNode&&n.loadNode(t)});break;case"mesh":i=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(s,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(n,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[H.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(n,r){s.load(js.resolveURL(t.uri,i.path),n,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const i=t.byteLength||0,n=t.byteOffset||0;return s.slice(n,n+i)})}loadAccessor(e){const t=this,s=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=Hn[i.type],a=As[i.componentType],A=i.normalized===!0,l=new a(i.count*r);return Promise.resolve(new Te(l,r,A))}const n=[];return i.bufferView!==void 0?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),i.sparse!==void 0&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then(function(r){const a=r[0],A=Hn[i.type],l=As[i.componentType],c=l.BYTES_PER_ELEMENT,h=c*A,d=i.byteOffset||0,u=i.bufferView!==void 0?s.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let p,f;if(u&&u!==h){const I=Math.floor(d/u),C="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+I+":"+i.count;let w=t.cache.get(C);w||(p=new l(a,I*u,i.count*u/c),w=new jh(p,u/c),t.cache.add(C,w)),f=new au(w,A,d%u/c,g)}else a===null?p=new l(i.count*A):p=new l(a,d,i.count*A),f=new Te(p,A,g);if(i.sparse!==void 0){const I=Hn.SCALAR,C=As[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,m=i.sparse.values.byteOffset||0,E=new C(r[1],w,i.sparse.count*I),B=new l(r[2],m,i.sparse.count*A);a!==null&&(f=new Te(f.array.slice(),f.itemSize,f.normalized));for(let Q=0,y=E.length;Q<y;Q++){const S=E[Q];if(f.setX(S,B[Q*A]),A>=2&&f.setY(S,B[Q*A+1]),A>=3&&f.setZ(S,B[Q*A+2]),A>=4&&f.setW(S,B[Q*A+3]),A>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let a=this.textureLoader;if(r.uri){const A=s.manager.getHandler(r.uri);A!==null&&(a=A)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,s){const i=this,n=this.json,r=n.textures[e],a=n.images[t],A=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[A])return this.textureCache[A];const l=this.loadImageSource(t,s).then(function(c){c.flipY=!1,c.name=r.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const d=(n.samplers||{})[r.sampler]||{};return c.magFilter=ya[d.magFilter]||ae,c.minFilter=ya[d.minFilter]||fs,c.wrapS=wa[d.wrapS]||mt,c.wrapT=wa[d.wrapT]||mt,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[A]=l,l}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],a=self.URL||self.webkitURL;let A=r.uri||"",l=!1;if(r.bufferView!==void 0)A=s.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const d=new Blob([h],{type:r.mimeType});return A=a.createObjectURL(d),A});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(A).then(function(h){return new Promise(function(d,u){let g=d;t.isImageBitmapLoader===!0&&(g=function(p){const f=new Ge(p);f.needsUpdate=!0,d(f)}),t.load(js.resolveURL(h,n.path),g,void 0,u)})}).then(function(h){return l===!0&&a.revokeObjectURL(A),h.userData.mimeType=r.mimeType||ng(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",A),h});return this.sourceCache[e]=c,c}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),n.extensions[H.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[H.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const A=n.associations.get(r);r=n.extensions[H.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),n.associations.set(r,A)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=t.attributes.tangent===void 0,n=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new Wh,Hi.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,A.sizeAttenuation=!1,this.cache.add(a,A)),s=A}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new Xh,Hi.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,this.cache.add(a,A)),s=A}if(i||n||r){let a="ClonedMaterial:"+s.uuid+":";i&&(a+="derivative-tangents:"),n&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let A=this.cache.get(a);A||(A=s.clone(),n&&(A.vertexColors=!0),r&&(A.flatShading=!0),i&&(A.normalScale&&(A.normalScale.y*=-1),A.clearcoatNormalScale&&(A.clearcoatNormalScale.y*=-1)),this.cache.add(a,A),this.associations.set(A,this.associations.get(s))),s=A}e.material=s}getMaterialType(){return nn}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let r;const a={},A=n.extensions||{},l=[];if(A[H.KHR_MATERIALS_UNLIT]){const h=i[H.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(a,n,t))}else{const h=n.pbrMetallicRoughness||{};if(a.color=new Le(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],ee),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,Ee)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}n.doubleSided===!0&&(a.side=Ft);const c=n.alphaMode||$n.OPAQUE;if(c===$n.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===$n.MASK&&(a.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&r!==Ue&&(l.push(t.assignTexture(a,"normalMap",n.normalTexture)),a.normalScale=new De(1,1),n.normalTexture.scale!==void 0)){const h=n.normalTexture.scale;a.normalScale.set(h,h)}if(n.occlusionTexture!==void 0&&r!==Ue&&(l.push(t.assignTexture(a,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&r!==Ue){const h=n.emissiveFactor;a.emissive=new Le().setRGB(h[0],h[1],h[2],ee)}return n.emissiveTexture!==void 0&&r!==Ue&&l.push(t.assignTexture(a,"emissiveMap",n.emissiveTexture,Ee)),Promise.all(l).then(function(){const h=new r(a);return n.name&&(h.name=n.name),lt(h,n),t.associations.set(h,{materials:e}),n.extensions&&wt(i,h,n),h})}createUniqueName(e){const t=ei.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(a){return s[H.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(A){return Qa(A,a,t)})}const r=[];for(let a=0,A=e.length;a<A;a++){const l=e[a],c=ig(l),h=i[c];if(h)r.push(h.promise);else{let d;l.extensions&&l.extensions[H.KHR_DRACO_MESH_COMPRESSION]?d=n(l):d=Qa(new bo,l,t),i[c]={primitive:l,promise:d},r.push(d)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,i=this.extensions,n=s.meshes[e],r=n.primitives,a=[];for(let A=0,l=r.length;A<l;A++){const c=r[A].material===void 0?eg(this.cache):this.getDependency("material",r[A].material);a.push(c)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(A){const l=A.slice(0,A.length-1),c=A[A.length-1],h=[];for(let u=0,g=c.length;u<g;u++){const p=c[u],f=r[u];let I;const C=l[u];if(f.mode===be.TRIANGLES||f.mode===be.TRIANGLE_STRIP||f.mode===be.TRIANGLE_FAN||f.mode===void 0)I=n.isSkinnedMesh===!0?new Zh(p,C):new pe(p,C),I.isSkinnedMesh===!0&&I.normalizeSkinWeights(),f.mode===be.TRIANGLE_STRIP?I.geometry=Ca(I.geometry,Xl):f.mode===be.TRIANGLE_FAN&&(I.geometry=Ca(I.geometry,ro));else if(f.mode===be.LINES)I=new eu(p,C);else if(f.mode===be.LINE_STRIP)I=new tu(p,C);else if(f.mode===be.LINE_LOOP)I=new su(p,C);else if(f.mode===be.POINTS)I=new iu(p,C);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(I.geometry.morphAttributes).length>0&&sg(I,n),I.name=t.createUniqueName(n.name||"mesh_"+e),lt(I,n),f.extensions&&wt(i,I,f),t.assignFinalMaterial(I),h.push(I)}for(let u=0,g=h.length;u<g;u++)t.associations.set(h[u],{meshes:e,primitives:u});if(h.length===1)return n.extensions&&wt(i,h[0],n),h[0];const d=new $i;n.extensions&&wt(i,d,n),t.associations.set(d,{meshes:e});for(let u=0,g=h.length;u<g;u++)d.add(h[u]);return d})}loadCamera(e){let t;const s=this.json.cameras[e],i=s[s.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new ti(rn.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):s.type==="orthographic"&&(t=new mn(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),lt(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let i=0,n=t.joints.length;i<n;i++)s.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(i){const n=i.pop(),r=i,a=[],A=[];for(let l=0,c=r.length;l<c;l++){const h=r[l];if(h){a.push(h);const d=new Ve;n!==null&&d.fromArray(n.array,l*16),A.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new nu(a,A)})}loadAnimation(e){const t=this.json,s=this,i=t.animations[e],n=i.name?i.name:"animation_"+e,r=[],a=[],A=[],l=[],c=[];for(let h=0,d=i.channels.length;h<d;h++){const u=i.channels[h],g=i.samplers[u.sampler],p=u.target,f=p.node,I=i.parameters!==void 0?i.parameters[g.input]:g.input,C=i.parameters!==void 0?i.parameters[g.output]:g.output;p.node!==void 0&&(r.push(this.getDependency("node",f)),a.push(this.getDependency("accessor",I)),A.push(this.getDependency("accessor",C)),l.push(g),c.push(p))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(A),Promise.all(l),Promise.all(c)]).then(function(h){const d=h[0],u=h[1],g=h[2],p=h[3],f=h[4],I=[];for(let C=0,w=d.length;C<w;C++){const m=d[C],E=u[C],B=g[C],Q=p[C],y=f[C];if(m===void 0)continue;m.updateMatrix&&m.updateMatrix();const S=s._createAnimationTracks(m,E,B,Q,y);if(S)for(let x=0;x<S.length;x++)I.push(S[x])}return new ru(n,void 0,I)})}createNodeMesh(e){const t=this.json,s=this,i=t.nodes[e];return i.mesh===void 0?null:s.getDependency("mesh",i.mesh).then(function(n){const r=s._getNodeRef(s.meshCache,i.mesh,n);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let A=0,l=i.weights.length;A<l;A++)a.morphTargetInfluences[A]=i.weights[A]}),r})}loadNode(e){const t=this.json,s=this,i=t.nodes[e],n=s._loadNodeShallow(e),r=[],a=i.children||[];for(let l=0,c=a.length;l<c;l++)r.push(s.getDependency("node",a[l]));const A=i.skin===void 0?Promise.resolve(null):s.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),A]).then(function(l){const c=l[0],h=l[1],d=l[2];d!==null&&c.traverse(function(u){u.isSkinnedMesh&&u.bind(d,rg)});for(let u=0,g=h.length;u<g;u++)c.add(h[u]);return c})}_loadNodeShallow(e){const t=this.json,s=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const n=t.nodes[e],r=n.name?i.createUniqueName(n.name):"",a=[],A=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return A&&a.push(A),n.camera!==void 0&&a.push(i.getDependency("camera",n.camera).then(function(l){return i._getNodeRef(i.cameraCache,n.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let c;if(n.isBone===!0?c=new ou:l.length>1?c=new $i:l.length===1?c=l[0]:c=new Ai,c!==l[0])for(let h=0,d=l.length;h<d;h++)c.add(l[h]);if(n.name&&(c.userData.name=n.name,c.name=r),lt(c,n),n.extensions&&wt(s,c,n),n.matrix!==void 0){const h=new Ve;h.fromArray(n.matrix),c.applyMatrix4(h)}else n.translation!==void 0&&c.position.fromArray(n.translation),n.rotation!==void 0&&c.quaternion.fromArray(n.rotation),n.scale!==void 0&&c.scale.fromArray(n.scale);return i.associations.has(c)||i.associations.set(c,{}),i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],i=this,n=new $i;s.name&&(n.name=i.createUniqueName(s.name)),lt(n,s),s.extensions&&wt(t,n,s);const r=s.nodes||[],a=[];for(let A=0,l=r.length;A<l;A++)a.push(i.getDependency("node",r[A]));return Promise.all(a).then(function(A){for(let c=0,h=A.length;c<h;c++)n.add(A[c]);const l=c=>{const h=new Map;for(const[d,u]of i.associations)(d instanceof Hi||d instanceof Ge)&&h.set(d,u);return c.traverse(d=>{const u=i.associations.get(d);u!=null&&h.set(d,u)}),h};return i.associations=l(n),n})}_createAnimationTracks(e,t,s,i,n){const r=[],a=e.name?e.name:e.uuid,A=[];rt[n.path]===rt.weights?e.traverse(function(d){d.morphTargetInfluences&&A.push(d.name?d.name:d.uuid)}):A.push(a);let l;switch(rt[n.path]){case rt.weights:l=Zo;break;case rt.rotation:l=ea;break;case rt.position:case rt.scale:l=Xo;break;default:switch(s.itemSize){case 1:l=Zo;break;case 2:case 3:default:l=Xo;break}break}const c=i.interpolation!==void 0?Zd[i.interpolation]:To,h=this._getArrayFromAccessor(s);for(let d=0,u=A.length;d<u;d++){const g=new l(A[d]+"."+rt[n.path],t.array,h,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),r.push(g)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=ho(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*s;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const i=this instanceof ea?Xd:vc;return new i(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ag(o,e,t){const s=e.attributes,i=new Dt;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],A=a.min,l=a.max;if(A!==void 0&&l!==void 0){if(i.set(new N(A[0],A[1],A[2]),new N(l[0],l[1],l[2])),a.normalized){const c=ho(As[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=e.targets;if(n!==void 0){const a=new N,A=new N;for(let l=0,c=n.length;l<c;l++){const h=n[l];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],u=d.min,g=d.max;if(u!==void 0&&g!==void 0){if(A.setX(Math.max(Math.abs(u[0]),Math.abs(g[0]))),A.setY(Math.max(Math.abs(u[1]),Math.abs(g[1]))),A.setZ(Math.max(Math.abs(u[2]),Math.abs(g[2]))),d.normalized){const p=ho(As[d.componentType]);A.multiplyScalar(p)}a.max(A)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new Ro;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Qa(o,e,t){const s=e.attributes,i=[];function n(r,a){return t.getDependency("accessor",r).then(function(A){o.setAttribute(a,A)})}for(const r in s){const a=co[r]||r.toLowerCase();a in o.attributes||i.push(n(s[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return Wo.workingColorSpace!==ee&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Wo.workingColorSpace}" not supported.`),lt(o,e),ag(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?tg(o,e.targets,t):o})}class Ag{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:i,msg:n,transfer:r}=this.queue.shift();this.workersResolve[e]=i,this.workers[e].postMessage(n,r)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(s=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=s,this.workers[i].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const lg=0,va=2,cg=1,Sa=2,hg=0,ug=1,dg=10,gg=0,Sc=9,xc=15,bc=16,Tc=22,Mc=37,Rc=43,Dc=76,_c=83,Lc=97,Fc=100,Nc=103,kc=109,Uc=165,Gc=166;class pg{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class ws{constructor(e,t,s,i){this._dataView=new DataView(e.buffer,e.byteOffset+t,s),this._littleEndian=i,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const s=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==t&&i<e;)i++,this._offset++;return i<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+s,i)}}const ue=[171,75,84,88,32,50,48,187,13,10,26,10];function xa(o){return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function fg(o){const e=new Uint8Array(o.buffer,o.byteOffset,ue.length);if(e[0]!==ue[0]||e[1]!==ue[1]||e[2]!==ue[2]||e[3]!==ue[3]||e[4]!==ue[4]||e[5]!==ue[5]||e[6]!==ue[6]||e[7]!==ue[7]||e[8]!==ue[8]||e[9]!==ue[9]||e[10]!==ue[10]||e[11]!==ue[11])throw new Error("Missing KTX 2.0 identifier.");const t=new pg,s=17*Uint32Array.BYTES_PER_ELEMENT,i=new ws(o,ue.length,s,!0);t.vkFormat=i._nextUint32(),t.typeSize=i._nextUint32(),t.pixelWidth=i._nextUint32(),t.pixelHeight=i._nextUint32(),t.pixelDepth=i._nextUint32(),t.layerCount=i._nextUint32(),t.faceCount=i._nextUint32();const n=i._nextUint32();t.supercompressionScheme=i._nextUint32();const r=i._nextUint32(),a=i._nextUint32(),A=i._nextUint32(),l=i._nextUint32(),c=i._nextUint64(),h=i._nextUint64(),d=new ws(o,ue.length+s,3*n*8,!0);for(let D=0;D<n;D++)t.levels.push({levelData:new Uint8Array(o.buffer,o.byteOffset+d._nextUint64(),d._nextUint64()),uncompressedByteLength:d._nextUint64()});const u=new ws(o,r,a,!0),g={vendorId:u._skip(4)._nextUint16(),descriptorType:u._nextUint16(),versionNumber:u._nextUint16(),descriptorBlockSize:u._nextUint16(),colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},p=(g.descriptorBlockSize/4-6)/4;for(let D=0;D<p;D++){const O={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelType:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&O.channelType?(O.sampleLower=u._nextInt32(),O.sampleUpper=u._nextInt32()):(O.sampleLower=u._nextUint32(),O.sampleUpper=u._nextUint32()),g.samples[D]=O}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(g);const f=new ws(o,A,l,!0);for(;f._offset<l;){const D=f._nextUint32(),O=f._scan(D),z=xa(O),$=f._scan(D-O.byteLength);t.keyValue[z]=z.match(/^ktx/i)?xa($):$,f._offset%4&&f._skip(4-f._offset%4)}if(h<=0)return t;const I=new ws(o,c,h,!0),C=I._nextUint16(),w=I._nextUint16(),m=I._nextUint32(),E=I._nextUint32(),B=I._nextUint32(),Q=I._nextUint32(),y=[];for(let D=0;D<n;D++)y.push({imageFlags:I._nextUint32(),rgbSliceByteOffset:I._nextUint32(),rgbSliceByteLength:I._nextUint32(),alphaSliceByteOffset:I._nextUint32(),alphaSliceByteLength:I._nextUint32()});const S=c+I._offset,x=S+m,R=x+E,_=R+B,U=new Uint8Array(o.buffer,o.byteOffset+S,m),T=new Uint8Array(o.buffer,o.byteOffset+x,E),M=new Uint8Array(o.buffer,o.byteOffset+R,B),k=new Uint8Array(o.buffer,o.byteOffset+_,Q);return t.globalData={endpointCount:C,selectorCount:w,imageDescs:y,endpointsData:U,selectorsData:T,tablesData:M,extendedData:k},t}let qn,et,uo;const Kn={env:{emscripten_notify_memory_growth:function(o){uo=new Uint8Array(et.exports.memory.buffer)}}};class mg{init(){return qn||(qn=typeof fetch<"u"?fetch("data:application/wasm;base64,"+ba).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,Kn)).then(this._init):WebAssembly.instantiate(Buffer.from(ba,"base64"),Kn).then(this._init),qn)}_init(e){et=e.instance,Kn.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!et)throw new Error("ZSTDDecoder: Await .init() before decoding.");const s=e.byteLength,i=et.exports.malloc(s);uo.set(e,i),t=t||Number(et.exports.ZSTD_findDecompressedSize(i,s));const n=et.exports.malloc(t),r=et.exports.ZSTD_decompress(n,t,i,s),a=uo.slice(n,n+r);return et.exports.free(i),et.exports.free(n),a}}const ba=" ",zn=new WeakMap;let Yn=0,Jn;class Oe extends fn{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Ag,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new pt(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new pt(this.manager);s.setPath(this.transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const i=s.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then(([n,r])=>{const a=Oe.BasisWorker.toString(),A=["/* constants */","let _EngineFormat = "+JSON.stringify(Oe.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Oe.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Oe.BasisFormat),"/* basis_transcoder.js */",n,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([A])),this.transcoderBinary=r,this.workerPool.setWorkerCreator(()=>{const l=new Worker(this.workerSourceURL),c=this.transcoderBinary.slice(0);return l.postMessage({type:"init",config:this.workerConfig,transcoderBinary:c},[c]),l})}),Yn>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Yn++}return this.transcoderPending}load(e,t,s,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new pt(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(e,r=>{if(zn.has(r))return zn.get(r).promise.then(t).catch(i);this._createTexture(r).then(a=>t?t(a):null).catch(i)},s,i)}_createTextureFrom(e,t){const{faces:s,width:i,height:n,format:r,type:a,error:A,dfdFlags:l}=e;if(a==="error")return Promise.reject(A);let c;if(t.faceCount===6)c=new lu(s,r,Ie);else{const h=s[0].mipmaps;c=t.layerCount>1?new cu(h,i,n,t.layerCount,r,Ie):new Ws(h,i,n,r,Ie)}return c.minFilter=s[0].mipmaps.length===1?ae:fs,c.magFilter=ae,c.generateMipmaps=!1,c.needsUpdate=!0,c.colorSpace=Oc(t),c.premultiplyAlpha=!!(l&cg),c}async _createTexture(e,t={}){const s=fg(new Uint8Array(e));if(s.vkFormat!==gg)return Eg(s);const i=t,n=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:i},[e])).then(r=>this._createTextureFrom(r.data,s));return zn.set(e,{promise:n}),n}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Yn--,this}}Oe.BasisFormat={ETC1S:0,UASTC_4x4:1};Oe.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16};Oe.EngineFormat={RGBAFormat:we,RGBA_ASTC_4x4_Format:hu,RGBA_BPTC_Format:uu,RGBA_ETC2_EAC_Format:du,RGBA_PVRTC_4BPPV1_Format:gu,RGBA_S3TC_DXT5_Format:pu,RGB_ETC1_Format:fu,RGB_ETC2_Format:mu,RGB_PVRTC_4BPPV1_Format:Iu,RGB_S3TC_DXT1_Format:Eu};Oe.BasisWorker=function(){let o,e,t;const s=_EngineFormat,i=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",function(g){const p=g.data;switch(p.type){case"init":o=p.config,r(p.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:f,buffers:I,width:C,height:w,hasAlpha:m,format:E,dfdFlags:B}=a(p.buffer);self.postMessage({type:"transcode",id:p.id,faces:f,width:C,height:w,hasAlpha:m,format:E,dfdFlags:B},I)}catch(f){console.error(f),self.postMessage({type:"error",id:p.id,error:f.message})}});break}});function r(g){e=new Promise(p=>{t={wasmBinary:g,onRuntimeInitialized:p},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const p=new t.KTX2File(new Uint8Array(g));function f(){p.close(),p.delete()}if(!p.isValid())throw f(),new Error("THREE.KTX2Loader:	Invalid or unsupported .ktx2 file");const I=p.isUASTC()?n.UASTC_4x4:n.ETC1S,C=p.getWidth(),w=p.getHeight(),m=p.getLayers()||1,E=p.getLevels(),B=p.getFaces(),Q=p.getHasAlpha(),y=p.getDFDFlags(),{transcoderFormat:S,engineFormat:x}=h(I,C,w,Q);if(!C||!w||!E)throw f(),new Error("THREE.KTX2Loader:	Invalid texture");if(!p.startTranscoding())throw f(),new Error("THREE.KTX2Loader: .startTranscoding failed");const R=[],_=[];for(let U=0;U<B;U++){const T=[];for(let M=0;M<E;M++){const k=[];let D,O;for(let $=0;$<m;$++){const Y=p.getImageLevelInfo(M,$,U);U===0&&M===0&&$===0&&(Y.origWidth%4!==0||Y.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),E>1?(D=Y.origWidth,O=Y.origHeight):(D=Y.width,O=Y.height);const Z=new Uint8Array(p.getImageTranscodedSizeInBytes(M,$,0,S));if(!p.transcodeImage(Z,M,$,U,S,0,-1,-1))throw f(),new Error("THREE.KTX2Loader: .transcodeImage failed.");k.push(Z)}const z=u(k);T.push({data:z,width:D,height:O}),_.push(z.buffer)}R.push({mipmaps:T,width:C,height:w,format:x})}return f(),{faces:R,buffers:_,width:C,height:w,hasAlpha:Q,format:x,dfdFlags:y}}const A=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[i.ASTC_4x4,i.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.BC7_M5,i.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.BC1,i.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.ETC1,i.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.PVRTC1_4_RGB,i.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],l=A.sort(function(g,p){return g.priorityETC1S-p.priorityETC1S}),c=A.sort(function(g,p){return g.priorityUASTC-p.priorityUASTC});function h(g,p,f,I){let C,w;const m=g===n.ETC1S?l:c;for(let E=0;E<m.length;E++){const B=m[E];if(o[B.if]&&B.basisFormat.includes(g)&&!(I&&B.transcoderFormat.length<2)&&!(B.needsPowerOfTwo&&!(d(p)&&d(f))))return C=B.transcoderFormat[I?1:0],w=B.engineFormat[I?1:0],{transcoderFormat:C,engineFormat:w}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),C=i.RGBA32,w=s.RGBAFormat,{transcoderFormat:C,engineFormat:w}}function d(g){return g<=2?!0:(g&g-1)===0&&g!==0}function u(g){if(g.length===1)return g[0];let p=0;for(let C=0;C<g.length;C++){const w=g[C];p+=w.byteLength}const f=new Uint8Array(p);let I=0;for(let C=0;C<g.length;C++){const w=g[C];f.set(w,I),I+=w.byteLength}return f}};const Ig=new Set([we,Ps,Hs]),jn={[kc]:we,[Lc]:we,[Mc]:we,[Rc]:we,[Nc]:Ps,[_c]:Ps,[bc]:Ps,[Tc]:Ps,[Fc]:Hs,[Dc]:Hs,[xc]:Hs,[Sc]:Hs,[Gc]:ta,[Uc]:ta},Wn={[kc]:$e,[Lc]:Qe,[Mc]:Ie,[Rc]:Ie,[Nc]:$e,[_c]:Qe,[bc]:Ie,[Tc]:Ie,[Fc]:$e,[Dc]:Qe,[xc]:Ie,[Sc]:Ie,[Gc]:Ie,[Uc]:Ie};async function Eg(o){const{vkFormat:e}=o;if(jn[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;o.supercompressionScheme===va&&(Jn||(Jn=new Promise(async n=>{const r=new mg;await r.init(),n(r)})),t=await Jn);const s=[];for(let n=0;n<o.levels.length;n++){const r=Math.max(1,o.pixelWidth>>n),a=Math.max(1,o.pixelHeight>>n),A=o.pixelDepth?Math.max(1,o.pixelDepth>>n):0,l=o.levels[n];let c;if(o.supercompressionScheme===lg)c=l.levelData;else if(o.supercompressionScheme===va)c=t.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let h;Wn[e]===$e?h=new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):Wn[e]===Qe?h=new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):h=c,s.push({data:h,width:r,height:a,depth:A})}let i;if(Ig.has(jn[e]))i=o.pixelDepth===0?new ic(s[0].data,o.pixelWidth,o.pixelHeight):new Cu(s[0].data,o.pixelWidth,o.pixelHeight,o.pixelDepth);else{if(o.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");i=new Ws(s,o.pixelWidth,o.pixelHeight)}return i.mipmaps=s,i.type=Wn[e],i.format=jn[e],i.colorSpace=Oc(o),i.needsUpdate=!0,Promise.resolve(i)}function Oc(o){const e=o.dataFormatDescriptor[0];return e.colorPrimaries===ug?e.transferFunction===Sa?Ee:ee:e.colorPrimaries===dg?e.transferFunction===Sa?Bu:yu:e.colorPrimaries===hg?on:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),on)}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Ta,Ma;const _e=Symbol("retainerCount"),ze=Symbol("recentlyUsed"),pi=Symbol("evict"),Qs=Symbol("evictionThreshold"),Xn=Symbol("cache");class Cg{constructor(e,t=5){this[Ta]=new Map,this[Ma]=[],this[Xn]=e,this[Qs]=t}set evictionThreshold(e){this[Qs]=e,this[pi]()}get evictionThreshold(){return this[Qs]}get cache(){return this[Xn]}retainerCount(e){return this[_e].get(e)||0}reset(){this[_e].clear(),this[ze]=[]}retain(e){this[_e].has(e)||this[_e].set(e,0),this[_e].set(e,this[_e].get(e)+1);const t=this[ze].indexOf(e);t!==-1&&this[ze].splice(t,1),this[ze].unshift(e),this[pi]()}release(e){this[_e].has(e)&&this[_e].set(e,Math.max(this[_e].get(e)-1,0)),this[pi]()}[(Ta=_e,Ma=ze,pi)](){if(!(this[ze].length<this[Qs]))for(let e=this[ze].length-1;e>=this[Qs];--e){const t=this[ze][e];this[_e].get(t)===0&&(this[Xn].delete(t),this[ze].splice(e,1))}}}/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Bg=o=>{const e=[],t=new Set;for(const s of o){let i=s,n=0;for(;t.has(i);)i=s+"."+ ++n;t.add(i),e.push(i)}return e},yg=o=>{const e=new Map;for(const t of o.mappings)for(const s of t.variants)e.set(s,{material:null,gltfMaterialIndex:t.material});return e};class wg{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,s=t.json;if(s.extensions===void 0||s.extensions[this.name]===void 0)return null;const n=s.extensions[this.name].variants||[],r=Bg(n.map(a=>a.name));for(const a of e.scenes)a.traverse(A=>{const l=A;if(!l.material)return;const c=t.associations.get(l);if(c==null||c.meshes==null||c.primitives==null)return;const g=s.meshes[c.meshes].primitives[c.primitives].extensions;!g||!g[this.name]||(l.userData.variantMaterials=yg(g[this.name]))});return e.userData.variants=r,Promise.resolve()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Pc,Ra;Ge.DEFAULT_ANISOTROPY=4;const Qg=(o,e,t=()=>{})=>{const s=i=>{const n=i.loaded/i.total;t(Math.max(0,Math.min(1,isFinite(n)?n:1)))};return new Promise((i,n)=>{e.load(o,i,s,n)})},vg=o=>new Promise((e,t)=>{const s=document.createElement("script");document.body.appendChild(s),s.onload=e,s.onerror=t,s.async=!0,s.src=o}),Ye=new Map,Zn=new Map;let Da;const _a=new Sd;let La;const er=new Oe;let tr,sr;const xt=Symbol("loader"),ct=Symbol("evictionPolicy"),Fa=Symbol("GLTFInstance");class se extends wn{constructor(e){super(),this[Ra]=new bd().register(t=>new wg(t)),this[Fa]=e,this[xt].setDRACOLoader(_a),this[xt].setKTX2Loader(er)}static setDRACODecoderLocation(e){Da=e,_a.setDecoderPath(e)}static getDRACODecoderLocation(){return Da}static setKTX2TranscoderLocation(e){La=e,er.setTranscoderPath(e)}static getKTX2TranscoderLocation(){return La}static setMeshoptDecoderLocation(e){tr!==e&&(tr=e,sr=vg(e).then(()=>MeshoptDecoder.ready).then(()=>MeshoptDecoder))}static getMeshoptDecoderLocation(){return tr}static initializeKTX2Loader(e){er.detectSupport(e)}static get cache(){return Ye}static clearCache(){Ye.forEach((e,t)=>{this.delete(t)}),this[ct].reset()}static has(e){return Ye.has(e)}static async delete(e){if(!this.has(e))return;const t=Ye.get(e);Zn.delete(e),Ye.delete(e),(await t).dispose()}static hasFinishedLoading(e){return!!Zn.get(e)}get[(Pc=ct,Ra=xt,ct)](){return this.constructor[ct]}async preload(e,t,s=()=>{}){if(this[xt].setWithCredentials(se.withCredentials),this.dispatchEvent({type:"preload",element:t,src:e}),!Ye.has(e)){sr!=null&&this[xt].setMeshoptDecoder(await sr);const i=Qg(e,this[xt],a=>{s(a*.8)}),n=this[Fa],r=i.then(a=>n.prepare(a)).then(a=>(s(.9),new n(a))).catch(a=>(console.error(a),new n));Ye.set(e,r)}await Ye.get(e),Zn.set(e,!0),s&&s(1)}async load(e,t,s=()=>{}){await this.preload(e,t,s);const n=await(await Ye.get(e)).clone();return this[ct].retain(e),n.dispose=()=>{this[ct].release(e)},n}}se[Pc]=new Cg(se);class Sg extends Ai{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new De(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof Element&&t.element.parentNode!==null&&t.element.parentNode.removeChild(t.element)})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const Ot=new N,Na=new Ve,ka=new Ve,Ua=new N,Ga=new N;class xg{constructor(e={}){const t=this;let s,i,n,r;const a={objects:new WeakMap},A=e.element!==void 0?e.element:document.createElement("div");A.style.overflow="hidden",this.domElement=A,this.getSize=function(){return{width:s,height:i}},this.render=function(u,g){u.matrixWorldAutoUpdate===!0&&u.updateMatrixWorld(),g.parent===null&&g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),Na.copy(g.matrixWorldInverse),ka.multiplyMatrices(g.projectionMatrix,Na),l(u,u,g),d(u)},this.setSize=function(u,g){s=u,i=g,n=s/2,r=i/2,A.style.width=u+"px",A.style.height=g+"px"};function l(u,g,p){if(u.isCSS2DObject){Ot.setFromMatrixPosition(u.matrixWorld),Ot.applyMatrix4(ka);const f=u.visible===!0&&Ot.z>=-1&&Ot.z<=1&&u.layers.test(p.layers)===!0;if(u.element.style.display=f===!0?"":"none",f===!0){u.onBeforeRender(t,g,p);const C=u.element;C.style.transform="translate("+-100*u.center.x+"%,"+-100*u.center.y+"%)translate("+(Ot.x*n+n)+"px,"+(-Ot.y*r+r)+"px)",C.parentNode!==A&&A.appendChild(C),u.onAfterRender(t,g,p)}const I={distanceToCameraSquared:c(p,u)};a.objects.set(u,I)}for(let f=0,I=u.children.length;f<I;f++)l(u.children[f],g,p)}function c(u,g){return Ua.setFromMatrixPosition(u.matrixWorld),Ga.setFromMatrixPosition(g.matrixWorld),Ua.distanceToSquared(Ga)}function h(u){const g=[];return u.traverse(function(p){p.isCSS2DObject&&g.push(p)}),g}function d(u){const g=h(u).sort(function(f,I){if(f.renderOrder!==I.renderOrder)return I.renderOrder-f.renderOrder;const C=a.objects.get(f).distanceToCameraSquared,w=a.objects.get(I).distanceToCameraSquared;return C-w}),p=g.length;for(let f=0,I=g.length;f<I;f++)g[f].element.style.zIndex=p-f}}}function fi(o,e,t){let s=t;const i=new N;return o.updateWorldMatrix(!0,!0),o.traverseVisible(n=>{const{geometry:r}=n;if(r!==void 0){const{position:a}=r.attributes;if(a!==void 0)for(let A=0,l=a.count;A<l;A++)n.isMesh?n.getVertexPosition(A,i):i.fromBufferAttribute(a,A),n.isSkinnedMesh||i.applyMatrix4(n.matrixWorld),s=e(s,i)}}),s}let vs,ir,Pt,mi;function zi(o,e=1/0,t=null){ir||(ir=new Is(2,2,1,1)),Pt||(Pt=new cs({uniforms:{blitTexture:new wu(o)},vertexShader:`
			varying vec2 vUv;
			void main(){
				vUv = uv;
				gl_Position = vec4(position.xy * 1.0,0.,.999999);
			}`,fragmentShader:`
			uniform sampler2D blitTexture; 
			varying vec2 vUv;

			void main(){ 
				gl_FragColor = vec4(vUv.xy, 0, 1);
				
				#ifdef IS_SRGB
				gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );
				#else
				gl_FragColor = texture2D( blitTexture, vUv);
				#endif
			}`})),Pt.uniforms.blitTexture.value=o,Pt.defines.IS_SRGB=o.colorSpace==Ee,Pt.needsUpdate=!0,mi||(mi=new pe(ir,Pt),mi.frustrumCulled=!1);const s=new ti,i=new It;i.add(mi),t===null&&(t=vs=new Do({antialias:!1}));const n=Math.min(o.image.width,e),r=Math.min(o.image.height,e);t.setSize(n,r),t.clear(),t.render(i,s);const a=document.createElement("canvas"),A=a.getContext("2d");a.width=n,a.height=r,A.drawImage(t.domElement,0,0,n,r);const l=new nc(a);return l.minFilter=o.minFilter,l.magFilter=o.magFilter,l.wrapS=o.wrapS,l.wrapT=o.wrapT,l.name=o.name,vs&&(vs.forceContextLoss(),vs.dispose(),vs=null),l}const Oa={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class No{constructor(){this.pluginCallbacks=[],this.register(function(e){return new kg(e)}),this.register(function(e){return new Ug(e)}),this.register(function(e){return new Pg(e)}),this.register(function(e){return new Hg(e)}),this.register(function(e){return new $g(e)}),this.register(function(e){return new Vg(e)}),this.register(function(e){return new Gg(e)}),this.register(function(e){return new Og(e)}),this.register(function(e){return new qg(e)}),this.register(function(e){return new Kg(e)}),this.register(function(e){return new zg(e)}),this.register(function(e){return new Yg(e)}),this.register(function(e){return new Jg(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,i){const n=new Ng,r=[];for(let a=0,A=this.pluginCallbacks.length;a<A;a++)r.push(this.pluginCallbacks[a](n));n.setPlugins(r),n.write(e,t,i).catch(s)}parseAsync(e,t){const s=this;return new Promise(function(i,n){s.parse(e,i,n,t)})}}const P={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},nr="KHR_mesh_quantization",ve={};ve[ms]=P.NEAREST;ve[En]=P.NEAREST_MIPMAP_NEAREST;ve[Bn]=P.NEAREST_MIPMAP_LINEAR;ve[ae]=P.LINEAR;ve[Cn]=P.LINEAR_MIPMAP_NEAREST;ve[fs]=P.LINEAR_MIPMAP_LINEAR;ve[Me]=P.CLAMP_TO_EDGE;ve[mt]=P.REPEAT;ve[yn]=P.MIRRORED_REPEAT;const Pa={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},bg=new Le,Ha=12,Tg=1179937895,Mg=2,$a=8,Rg=1313821514,Dg=5130562;function qs(o,e){return o.length===e.length&&o.every(function(t,s){return t===e[s]})}function _g(o){return new TextEncoder().encode(o).buffer}function Lg(o){return qs(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Fg(o,e,t){const s={min:new Array(o.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(o.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+t;i++)for(let n=0;n<o.itemSize;n++){let r;o.itemSize>4?r=o.array[i*o.itemSize+n]:(n===0?r=o.getX(i):n===1?r=o.getY(i):n===2?r=o.getZ(i):n===3&&(r=o.getW(i)),o.normalized===!0&&(r=rn.normalize(r,o.array))),s.min[n]=Math.min(s.min[n],r),s.max[n]=Math.max(s.max[n],r)}return s}function Hc(o){return Math.ceil(o/4)*4}function rr(o,e=0){const t=Hc(o.byteLength);if(t!==o.byteLength){const s=new Uint8Array(t);if(s.set(new Uint8Array(o)),e!==0)for(let i=o.byteLength;i<t;i++)s[i]=e;return s.buffer}return o}function Va(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function qa(o,e){if(o.toBlob!==void 0)return new Promise(s=>o.toBlob(s,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),o.convertToBlob({type:e,quality:t})}class Ng{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,s={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,n=i.buffers,r=i.json;s=i.options;const a=i.extensionsUsed,A=i.extensionsRequired,l=new Blob(n,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(A);if(c.length>0&&(r.extensionsUsed=c),h.length>0&&(r.extensionsRequired=h),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=l.size),s.binary===!0){const d=new FileReader;d.readAsArrayBuffer(l),d.onloadend=function(){const u=rr(d.result),g=new DataView(new ArrayBuffer($a));g.setUint32(0,u.byteLength,!0),g.setUint32(4,Dg,!0);const p=rr(_g(JSON.stringify(r)),32),f=new DataView(new ArrayBuffer($a));f.setUint32(0,p.byteLength,!0),f.setUint32(4,Rg,!0);const I=new ArrayBuffer(Ha),C=new DataView(I);C.setUint32(0,Tg,!0),C.setUint32(4,Mg,!0);const w=Ha+f.byteLength+p.byteLength+g.byteLength+u.byteLength;C.setUint32(8,w,!0);const m=new Blob([I,f,p,g,u],{type:"application/octet-stream"}),E=new FileReader;E.readAsArrayBuffer(m),E.onloadend=function(){t(E.result)}}}else if(r.buffers&&r.buffers.length>0){const d=new FileReader;d.readAsDataURL(l),d.onloadend=function(){const u=d.result;r.buffers[0].uri=u,t(r)}}else t(r)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const s=this.options,i=this.extensionsUsed;try{const n=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&n.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const r in n.gltfExtensions)t.extensions[r]=n.gltfExtensions[r],i[r]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(n){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+n.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const s=new N;for(let i=0,n=e.count;i<n;i++)if(Math.abs(s.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const s=e.clone(),i=new N;for(let n=0,r=s.count;n<r;n++)i.fromBufferAttribute(s,n),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),s.setXYZ(n,i.x,i.y,i.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1;const i={};(t.offset.x!==0||t.offset.y!==0)&&(i.offset=t.offset.toArray(),s=!0),t.rotation!==0&&(i.rotation=t.rotation,s=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(i.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function s(u){return u.colorSpace===Ee?function(p){return p<.04045?p*.0773993808:Math.pow(p*.9478672986+.0521327014,2.4)}:function(p){return p}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof Ws&&(e=zi(e)),t instanceof Ws&&(t=zi(t));const i=e?e.image:null,n=t?t.image:null,r=Math.max(i?i.width:0,n?n.width:0),a=Math.max(i?i.height:0,n?n.height:0),A=Va();A.width=r,A.height=a;const l=A.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,r,a);const c=l.getImageData(0,0,r,a);if(i){l.drawImage(i,0,0,r,a);const u=s(e),g=l.getImageData(0,0,r,a).data;for(let p=2;p<g.length;p+=4)c.data[p]=u(g[p]/256)*256}if(n){l.drawImage(n,0,0,r,a);const u=s(t),g=l.getImageData(0,0,r,a).data;for(let p=1;p<g.length;p+=4)c.data[p]=u(g[p]/256)*256}l.putImageData(c,0,0);const d=(e||t).clone();return d.source=new Qu(A),d.colorSpace=on,d.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),d}processBuffer(e){const t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,i,n){const r=this.json;r.bufferViews||(r.bufferViews=[]);let a;switch(t){case P.BYTE:case P.UNSIGNED_BYTE:a=1;break;case P.SHORT:case P.UNSIGNED_SHORT:a=2;break;default:a=4}const A=Hc(i*e.itemSize*a),l=new DataView(new ArrayBuffer(A));let c=0;for(let u=s;u<s+i;u++)for(let g=0;g<e.itemSize;g++){let p;e.itemSize>4?p=e.array[u*e.itemSize+g]:(g===0?p=e.getX(u):g===1?p=e.getY(u):g===2?p=e.getZ(u):g===3&&(p=e.getW(u)),e.normalized===!0&&(p=rn.normalize(p,e.array))),t===P.FLOAT?l.setFloat32(c,p,!0):t===P.INT?l.setInt32(c,p,!0):t===P.UNSIGNED_INT?l.setUint32(c,p,!0):t===P.SHORT?l.setInt16(c,p,!0):t===P.UNSIGNED_SHORT?l.setUint16(c,p,!0):t===P.BYTE?l.setInt8(c,p):t===P.UNSIGNED_BYTE&&l.setUint8(c,p),c+=a}const h={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:A};return n!==void 0&&(h.target=n),n===P.ARRAY_BUFFER&&(h.byteStride=e.itemSize*a),this.byteOffset+=A,r.bufferViews.push(h),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise(function(i){const n=new FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){const r=rr(n.result),a={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};t.byteOffset+=r.byteLength,i(s.bufferViews.push(a)-1)}})}processAccessor(e,t,s,i){const n=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=P.FLOAT;else if(e.array.constructor===Int32Array)a=P.INT;else if(e.array.constructor===Uint32Array)a=P.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=P.SHORT;else if(e.array.constructor===Uint16Array)a=P.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=P.BYTE;else if(e.array.constructor===Uint8Array)a=P.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(s===void 0&&(s=0),(i===void 0||i===1/0)&&(i=e.count),i===0)return null;const A=Fg(e,s,i);let l;t!==void 0&&(l=e===t.index?P.ELEMENT_ARRAY_BUFFER:P.ARRAY_BUFFER);const c=this.processBufferView(e,a,s,i,l),h={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:i,max:A.max,min:A.min,type:r[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),n.accessors||(n.accessors=[]),n.accessors.push(h)-1}processImage(e,t,s,i="image/png"){if(e!==null){const n=this,r=n.cache,a=n.json,A=n.options,l=n.pending;r.images.has(e)||r.images.set(e,{});const c=r.images.get(e),h=i+":flipY/"+s.toString();if(c[h]!==void 0)return c[h];a.images||(a.images=[]);const d={mimeType:i},u=Va();u.width=Math.min(e.width,A.maxTextureSize),u.height=Math.min(e.height,A.maxTextureSize);const g=u.getContext("2d");if(s===!0&&(g.translate(0,u.height),g.scale(1,-1)),e.data!==void 0){t!==we&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>A.maxTextureSize||e.height>A.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const f=new Uint8ClampedArray(e.height*e.width*4);for(let I=0;I<f.length;I+=4)f[I+0]=e.data[I+0],f[I+1]=e.data[I+1],f[I+2]=e.data[I+2],f[I+3]=e.data[I+3];g.putImageData(new ImageData(f,e.width,e.height),0,0)}else g.drawImage(e,0,0,u.width,u.height);A.binary===!0?l.push(qa(u,i).then(f=>n.processBufferViewImage(f)).then(f=>{d.bufferView=f})):u.toDataURL!==void 0?d.uri=u.toDataURL(i):l.push(qa(u,i).then(f=>new FileReader().readAsDataURL(f)).then(f=>{d.uri=f}));const p=a.images.push(d)-1;return c[h]=p,p}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const s={magFilter:ve[e.magFilter],minFilter:ve[e.minFilter],wrapS:ve[e.wrapS],wrapT:ve[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){const s=this.options,i=this.cache,n=this.json;if(i.textures.has(e))return i.textures.get(e);n.textures||(n.textures=[]),e instanceof Ws&&(e=zi(e,s.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll(function(l){l.writeTexture&&l.writeTexture(e,a)});const A=n.textures.push(a)-1;return i.textures.set(e,A),A}processMaterial(e){const t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const n=e.color.toArray().concat([e.opacity]);if(qs(n,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),A={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(A,a),i.pbrMetallicRoughness.metallicRoughnessTexture=A}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),i.emissiveTexture=l}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===Ft&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const r=s.materials.push(i)-1;return t.materials.set(e,r),r}processMesh(e){const t=this.cache,s=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let m=0,E=e.material.length;m<E;m++)i.push(e.material[m].uuid);else i.push(e.material.uuid);const n=i.join(":");if(t.meshes.has(n))return t.meshes.get(n);const r=e.geometry;let a;e.isLineSegments?a=P.LINES:e.isLineLoop?a=P.LINE_LOOP:e.isLine?a=P.LINE_STRIP:e.isPoints?a=P.POINTS:a=e.material.wireframe?P.LINES:P.TRIANGLES;const A={},l={},c=[],h=[],d={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},u=r.getAttribute("normal");u!==void 0&&!this.isNormalizedNormalAttribute(u)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(u)));let g=null;for(let m in r.attributes){if(m.slice(0,5)==="morph")continue;const E=r.attributes[m];if(m=d[m]||m.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(m)||(m="_"+m),t.attributes.has(this.getUID(E))){l[m]=t.attributes.get(this.getUID(E));continue}g=null;const Q=E.array;m==="JOINTS_0"&&!(Q instanceof Uint16Array)&&!(Q instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new Te(new Uint16Array(Q),E.itemSize,E.normalized));const y=this.processAccessor(g||E,r);y!==null&&(m.startsWith("_")||this.detectMeshQuantization(m,E),l[m]=y,t.attributes.set(this.getUID(E),y))}if(u!==void 0&&r.setAttribute("normal",u),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const m=[],E=[],B={};if(e.morphTargetDictionary!==void 0)for(const Q in e.morphTargetDictionary)B[e.morphTargetDictionary[Q]]=Q;for(let Q=0;Q<e.morphTargetInfluences.length;++Q){const y={};let S=!1;for(const x in r.morphAttributes){if(x!=="position"&&x!=="normal"){S||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),S=!0);continue}const R=r.morphAttributes[x][Q],_=x.toUpperCase(),U=r.attributes[x];if(t.attributes.has(this.getUID(R,!0))){y[_]=t.attributes.get(this.getUID(R,!0));continue}const T=R.clone();if(!r.morphTargetsRelative)for(let M=0,k=R.count;M<k;M++)for(let D=0;D<R.itemSize;D++)D===0&&T.setX(M,R.getX(M)-U.getX(M)),D===1&&T.setY(M,R.getY(M)-U.getY(M)),D===2&&T.setZ(M,R.getZ(M)-U.getZ(M)),D===3&&T.setW(M,R.getW(M)-U.getW(M));y[_]=this.processAccessor(T,r),t.attributes.set(this.getUID(U,!0),y[_])}h.push(y),m.push(e.morphTargetInfluences[Q]),e.morphTargetDictionary!==void 0&&E.push(B[Q])}A.weights=m,E.length>0&&(A.extras={},A.extras.targetNames=E)}const p=Array.isArray(e.material);if(p&&r.groups.length===0)return null;let f=!1;if(p&&r.index===null){const m=[];for(let E=0,B=r.attributes.position.count;E<B;E++)m[E]=E;r.setIndex(m),f=!0}const I=p?e.material:[e.material],C=p?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let m=0,E=C.length;m<E;m++){const B={mode:a,attributes:l};if(this.serializeUserData(r,B),h.length>0&&(B.targets=h),r.index!==null){let y=this.getUID(r.index);(C[m].start!==void 0||C[m].count!==void 0)&&(y+=":"+C[m].start+":"+C[m].count),t.attributes.has(y)?B.indices=t.attributes.get(y):(B.indices=this.processAccessor(r.index,r,C[m].start,C[m].count),t.attributes.set(y,B.indices)),B.indices===null&&delete B.indices}const Q=this.processMaterial(I[C[m].materialIndex]);Q!==null&&(B.material=Q),c.push(B)}f===!0&&r.setIndex(null),A.primitives=c,s.meshes||(s.meshes=[]),this._invokeAll(function(m){m.writeMesh&&m.writeMesh(e,A)});const w=s.meshes.push(A)-1;return t.meshes.set(n,w),w}detectMeshQuantization(e,t){if(this.extensionsUsed[nr])return;let s;switch(t.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}t.normalized&&(s+=" normalized");const i=e.split("_",1)[0];Oa[i]&&Oa[i].includes(s)&&(this.extensionsUsed[nr]=!0,this.extensionsRequired[nr]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const s=e.isOrthographicCamera,i={type:s?"orthographic":"perspective"};return s?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:rn.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const s=this.json,i=this.nodeMap;s.animations||(s.animations=[]),e=No.Utils.mergeMorphTargetTracks(e.clone(),t);const n=e.tracks,r=[],a=[];for(let A=0;A<n.length;++A){const l=n[A],c=ei.parseTrackName(l.name);let h=ei.findNode(t,c.nodeName);const d=Pa[c.propertyName];if(c.objectName==="bones"&&(h.isSkinnedMesh===!0?h=h.skeleton.getBoneByName(c.objectIndex):h=void 0),!h||!d)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name),null;const u=1;let g=l.values.length/l.times.length;d===Pa.morphTargetInfluences&&(g/=h.morphTargetInfluences.length);let p;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(p="CUBICSPLINE",g/=3):l.getInterpolation()===sc?p="STEP":p="LINEAR",a.push({input:this.processAccessor(new Te(l.times,u)),output:this.processAccessor(new Te(l.values,g)),interpolation:p}),r.push({sampler:a.length-1,target:{node:i.get(h),path:d}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:r}),s.animations.length-1}processSkin(e){const t=this.json,s=this.nodeMap,i=t.nodes[s.get(e)],n=e.skeleton;if(n===void 0)return null;const r=e.skeleton.bones[0];if(r===void 0)return null;const a=[],A=new Float32Array(n.bones.length*16),l=new Ve;for(let h=0;h<n.bones.length;++h)a.push(s.get(n.bones[h])),l.copy(n.boneInverses[h]),l.multiply(e.bindMatrix).toArray(A,h*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Te(A,16)),joints:a,skeleton:s.get(r)}),i.skin=t.skins.length-1}processNode(e){const t=this.json,s=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const n={};if(s.trs){const a=e.quaternion.toArray(),A=e.position.toArray(),l=e.scale.toArray();qs(a,[0,0,0,1])||(n.rotation=a),qs(A,[0,0,0])||(n.translation=A),qs(l,[1,1,1])||(n.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),Lg(e.matrix)===!1&&(n.matrix=e.matrix.elements);if(e.name!==""&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(n.mesh=a)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let A=0,l=e.children.length;A<l;A++){const c=e.children[A];if(c.visible||s.onlyVisible===!1){const h=this.processNode(c);h!==null&&a.push(h)}}a.length>0&&(n.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,n)});const r=t.nodes.push(n)-1;return i.set(e,r),r}processScene(e){const t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);const n=[];for(let r=0,a=e.children.length;r<a;r++){const A=e.children[r];if(A.visible||s.onlyVisible===!1){const l=this.processNode(A);l!==null&&n.push(l)}}n.length>0&&(i.nodes=n),this.serializeUserData(e,i)}processObjects(e){const t=new It;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(i){i.beforeParse&&i.beforeParse(e)});const s=[];for(let i=0;i<e.length;i++)e[i]instanceof It?this.processScene(e[i]):s.push(e[i]);s.length>0&&this.processObjects(s);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i],e[0]);this._invokeAll(function(i){i.afterParse&&i.afterParse(e)})}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}}class kg{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const s=this.writer,i=s.json,n=s.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},n[this.name]=!0);const a=i.extensions[this.name].lights;a.push(r),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Ug{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Gg{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.clearcoatFactor=e.clearcoat,e.clearcoatMap){const r={index:s.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};s.applyTextureTransform(r,e.clearcoatMap),n.clearcoatTexture=r}if(n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const r={index:s.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};s.applyTextureTransform(r,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){const r={index:s.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};s.applyTextureTransform(r,e.clearcoatNormalMap),n.clearcoatNormalTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Og{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.iridescenceFactor=e.iridescence,e.iridescenceMap){const r={index:s.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};s.applyTextureTransform(r,e.iridescenceMap),n.iridescenceTexture=r}if(n.iridescenceIor=e.iridescenceIOR,n.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],n.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const r={index:s.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};s.applyTextureTransform(r,e.iridescenceThicknessMap),n.iridescenceThicknessTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Pg{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.transmissionFactor=e.transmission,e.transmissionMap){const r={index:s.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};s.applyTextureTransform(r,e.transmissionMap),n.transmissionTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Hg{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.thicknessFactor=e.thickness,e.thicknessMap){const r={index:s.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};s.applyTextureTransform(r,e.thicknessMap),n.thicknessTexture=r}n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class $g{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const i=this.writer.extensionsUsed,n={};n.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Vg{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(bg)&&!e.specularIntensityMap&&!e.specularColorMap)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.specularIntensityMap){const r={index:s.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};s.applyTextureTransform(r,e.specularIntensityMap),n.specularTexture=r}if(e.specularColorMap){const r={index:s.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};s.applyTextureTransform(r,e.specularColorMap),n.specularColorTexture=r}n.specularFactor=e.specularIntensity,n.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class qg{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.sheenRoughnessMap){const r={index:s.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};s.applyTextureTransform(r,e.sheenRoughnessMap),n.sheenRoughnessTexture=r}if(e.sheenColorMap){const r={index:s.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};s.applyTextureTransform(r,e.sheenColorMap),n.sheenColorTexture=r}n.sheenRoughnessFactor=e.sheenRoughness,n.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Kg{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.anisotropyMap){const r={index:s.processTexture(e.anisotropyMap)};s.applyTextureTransform(r,e.anisotropyMap),n.anisotropyTexture=r}n.anisotropyStrength=e.anisotropy,n.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class zg{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const i=this.writer.extensionsUsed,n={};n.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Yg{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.bumpMap){const r={index:s.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};s.applyTextureTransform(r,e.bumpMap),n.bumpTexture=r}n.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Jg{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const s=this.writer,i=e,n=new Float32Array(i.count*3),r=new Float32Array(i.count*4),a=new Float32Array(i.count*3),A=new Ve,l=new N,c=new In,h=new N;for(let u=0;u<i.count;u++)i.getMatrixAt(u,A),A.decompose(l,c,h),l.toArray(n,u*3),c.toArray(r,u*4),h.toArray(a,u*3);const d={TRANSLATION:s.processAccessor(new Te(n,3)),ROTATION:s.processAccessor(new Te(r,4)),SCALE:s.processAccessor(new Te(a,3))};i.instanceColor&&(d._COLOR_0=s.processAccessor(i.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:d},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}}No.Utils={insertKeyframe:function(o,e){const s=o.getValueSize(),i=new o.TimeBufferType(o.times.length+1),n=new o.ValueBufferType(o.values.length+s),r=o.createInterpolant(new o.ValueBufferType(s));let a;if(o.times.length===0){i[0]=e;for(let A=0;A<s;A++)n[A]=0;a=0}else if(e<o.times[0]){if(Math.abs(o.times[0]-e)<.001)return 0;i[0]=e,i.set(o.times,1),n.set(r.evaluate(e),0),n.set(o.values,s),a=0}else if(e>o.times[o.times.length-1]){if(Math.abs(o.times[o.times.length-1]-e)<.001)return o.times.length-1;i[i.length-1]=e,i.set(o.times,0),n.set(o.values,0),n.set(r.evaluate(e),o.values.length),a=i.length-1}else for(let A=0;A<o.times.length;A++){if(Math.abs(o.times[A]-e)<.001)return A;if(o.times[A]<e&&o.times[A+1]>e){i.set(o.times.slice(0,A+1),0),i[A+1]=e,i.set(o.times.slice(A+1),A+2),n.set(o.values.slice(0,(A+1)*s),0),n.set(r.evaluate(e),(A+1)*s),n.set(o.values.slice((A+1)*s),(A+2)*s),a=A+1;break}}return o.times=i,o.values=n,a},mergeMorphTargetTracks:function(o,e){const t=[],s={},i=o.tracks;for(let n=0;n<i.length;++n){let r=i[n];const a=ei.parseTrackName(r.name),A=ei.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(To)}const l=A.morphTargetInfluences.length,c=A.morphTargetDictionary[a.propertyIndex];if(c===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let h;if(s[A.uuid]===void 0){h=r.clone();const u=new h.ValueBufferType(l*h.times.length);for(let g=0;g<h.times.length;g++)u[g*l+c]=h.values[g];h.name=(a.nodeName||"")+".morphTargetInfluences",h.values=u,s[A.uuid]=h,t.push(h);continue}const d=r.createInterpolant(new r.ValueBufferType(1));h=s[A.uuid];for(let u=0;u<h.times.length;u++)h.values[u*l+c]=d.evaluate(h.times[u]);for(let u=0;u<r.times.length;u++){const g=this.insertKeyframe(h,r.times[u]);h.values[g*l+c]=r.values[u]}}return o.tracks=t,o}};/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ka=o=>o.material!==void 0&&o.userData&&o.userData.variantMaterials&&!!Array.from(o.userData.variantMaterials.values()).filter(e=>Yi(e.material)),Yi=o=>o&&o.isMaterial&&!Array.isArray(o);class jg{constructor(e){this.writer=e,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(e){const t=new Set;for(const s of e)s.traverse(i=>{if(!Ka(i))return;const n=i.userData.variantMaterials,r=i.userData.variantData;for(const[a,A]of r){const l=n.get(A.index);l&&Yi(l.material)&&t.add(a)}});t.forEach(s=>this.variantNames.push(s))}writeMesh(e,t){if(!Ka(e))return;const s=e.userData,i=s.variantMaterials,n=s.variantData,r=new Map,a=new Map,A=Array.from(n.values()).sort((h,d)=>h.index-d.index);for(const[h,d]of A.entries())a.set(d.index,h);for(const h of n.values()){const d=i.get(h.index);if(!d||!Yi(d.material))continue;const u=this.writer.processMaterial(d.material);r.has(u)||r.set(u,{material:u,variants:[]}),r.get(u).variants.push(a.get(h.index))}const l=Array.from(r.values()).map(h=>h.variants.sort((d,u)=>d-u)&&h).sort((h,d)=>h.material-d.material);if(l.length===0)return;const c=Yi(s.originalMaterial)?this.writer.processMaterial(s.originalMaterial):-1;for(const h of t.primitives)c>=0&&(h.material=c),h.extensions=h.extensions||{},h.extensions[this.name]={mappings:l}}afterParse(){if(this.variantNames.length===0)return;const e=this.writer.json;e.extensions=e.extensions||{};const t=this.variantNames.map(s=>({name:s}));e.extensions[this.name]={variants:t},this.writer.extensionsUsed[this.name]=!0}}class Wg{constructor(e,t,s,i,n){this.xrLight=e,this.renderer=t,this.lightProbe=s,this.xrWebGLBinding=null,this.estimationStartCallback=n,this.frameCallback=this.onXRFrame.bind(this);const r=t.xr.getSession();if(i&&"XRWebGLBinding"in window){const a=new rc(16);e.environment=a.texture;const A=t.getContext();switch(r.preferredReflectionFormat){case"srgba8":A.getExtension("EXT_sRGB");break;case"rgba16f":A.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(r,A),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}r.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const i=t.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const n=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/n,i.primaryLightIntensity.y/n,i.primaryLightIntensity.z/n),this.xrLight.directionalLight.intensity=n,this.xrLight.directionalLight.position.copy(i.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class Xg extends $i{constructor(e,t=!0){super(),this.lightProbe=new vu,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new ec,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let s=null,i=!1;e.xr.addEventListener("sessionstart",()=>{const n=e.xr.getSession();"requestLightProbe"in n&&n.requestLightProbe({reflectionFormat:n.preferredReflectionFormat}).then(r=>{s=new Wg(this,e,r,t,()=>{i=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{s&&(s.dispose(),s=null),i&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{s&&(s.dispose(),s=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const $c=1e4,Zg=.001,Vc=50;class ye{constructor(e=Vc){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(e)}setDecayTime(e){this.naturalFrequency=1/Math.max(Zg,e)}update(e,t,s,i){const n=2e-4*this.naturalFrequency;if(e==null||i===0||e===t&&this.velocity===0)return t;if(s<0)return e;const r=e-t,a=this.velocity+this.naturalFrequency*r,A=r+s*a,l=Math.exp(-this.naturalFrequency*s),c=(a-this.naturalFrequency*A)*l,h=-this.naturalFrequency*(c+a*l);return Math.abs(c)<n*Math.abs(i)&&h*r>=0?(this.velocity=0,t):(this.velocity=c,t+A*l)}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const ns=.2,za=.03,ep=.75,qc=12,tp=Math.PI/(2*qc),Ya=new De,Ii=(o,e,t)=>{let s=e>0?t>0?0:-Math.PI/2:t>0?Math.PI/2:Math.PI;for(let i=0;i<=qc;++i)o.push(e+(ns-za)*Math.cos(s),t+(ns-za)*Math.sin(s),0,e+ns*Math.cos(s),t+ns*Math.sin(s),0),s+=tp};class Ja extends pe{constructor(e,t){const s=new bo,i=[],n=[],{size:r,boundingBox:a}=e,A=r.x/2,l=(t==="back"?r.y:r.z)/2;Ii(n,A,l),Ii(n,-A,l),Ii(n,-A,-l),Ii(n,A,-l);const c=n.length/3;for(let u=0;u<c-2;u+=2)i.push(u,u+1,u+3,u,u+3,u+2);const h=c-2;i.push(h,h+1,1,h,1,0),s.setAttribute("position",new Su(n,3)),s.setIndex(i),super(s),this.side=t;const d=this.material;switch(d.side=Ft,d.transparent=!0,d.opacity=0,this.goalOpacity=0,this.opacityDamper=new ye,this.hitPlane=new pe(new Is(2*(A+ns),2*(l+ns))),this.hitPlane.visible=!1,this.hitPlane.material.side=Ft,this.add(this.hitPlane),a.getCenter(this.position),t){case"bottom":this.rotateX(-Math.PI/2),this.shadowHeight=a.min.y,this.position.y=this.shadowHeight;break;case"back":this.shadowHeight=a.min.z,this.position.z=this.shadowHeight}e.target.add(this),this.offsetHeight=0}getHit(e,t,s){Ya.set(t,-s),this.hitPlane.visible=!0;const i=e.positionAndNormalFromPoint(Ya,this.hitPlane);return this.hitPlane.visible=!1,i==null?null:i.position}getExpandedHit(e,t,s){this.hitPlane.scale.set(1e3,1e3,1e3),this.hitPlane.updateMatrixWorld();const i=this.getHit(e,t,s);return this.hitPlane.scale.set(1,1,1),i}set offsetHeight(e){e-=.001,this.side==="back"?this.position.z=this.shadowHeight+e:this.position.y=this.shadowHeight+e}get offsetHeight(){return this.side==="back"?this.position.z-this.shadowHeight:this.position.y-this.shadowHeight}set show(e){this.goalOpacity=e?ep:0}updateOpacity(e){const t=this.material;t.opacity=this.opacityDamper.update(t.opacity,this.goalOpacity,e,1),this.visible=t.opacity>0}dispose(){var e;const{geometry:t,material:s}=this.hitPlane;t.dispose(),s.dispose(),this.geometry.dispose(),this.material.dispose(),(e=this.parent)===null||e===void 0||e.remove(this)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const he=(o,e)=>({type:"number",number:o,unit:e}),tt=(()=>{const o={};return t=>{const s=t;if(s in o)return o[s];const i=[];let n=0;for(;t;){if(++n>1e3){t="";break}const r=Kc(t),a=r.nodes[0];if(a==null||a.terms.length===0)break;i.push(a),t=r.remainingInput}return o[s]=i}})(),Kc=(()=>{const o=/^(\-\-|[a-z\u0240-\uffff])/i,e=/^([\*\+\/]|[\-]\s)/i,t=/^[\),]/,s="(",i="#";return n=>{const r=[];for(;n.length&&(n=n.trim(),!t.test(n));)if(n[0]===s){const{nodes:a,remainingInput:A}=ja(n);n=A,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:a})}else if(o.test(n)){const a=sp(n),A=a.nodes[0];if(n=a.remainingInput,n[0]===s){const{nodes:l,remainingInput:c}=ja(n);r.push({type:"function",name:A,arguments:l}),n=c}else r.push(A)}else if(e.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:a,remainingInput:A}=n[0]===i?np(n):ip(n);if(a.length===0)break;r.push(a[0]),n=A}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),sp=(()=>{const o=/[^a-z0-9_\-\u0240-\uffff]/i;return e=>{const t=e.match(o),s=t==null?e:e.substr(0,t.index),i=t==null?"":e.substr(t.index);return{nodes:[{type:"ident",value:s}],remainingInput:i}}})(),ip=(()=>{const o=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,e=/^[a-z%]+/i,t=/^(m|mm|cm|rad|deg|[%])$/;return s=>{const i=s.match(o),n=i==null?"0":i[0];s=n==null?s:s.slice(n.length);const r=s.match(e);let a=r!=null&&r[0]!==""?r[0]:null;const A=r==null?s:s.slice(a.length);return a!=null&&!t.test(a)&&(a=null),{nodes:[{type:"number",number:parseFloat(n)||0,unit:a}],remainingInput:A}}})(),np=(()=>{const o=/^[a-f0-9]*/i;return e=>{e=e.slice(1).trim();const t=e.match(o);return{nodes:t==null?[]:[{type:"hex",value:t[0]}],remainingInput:t==null?e:e.slice(t[0].length)}}})(),ja=o=>{const e=[];for(o=o.slice(1).trim();o.length;){const t=Kc(o);if(e.push(t.nodes[0]),o=t.remainingInput.trim(),o[0]===",")o=o.slice(1).trim();else if(o[0]===")"){o=o.slice(1);break}}return{nodes:e,remainingInput:o}},Wa=Symbol("visitedTypes");class rp{constructor(e){this[Wa]=e}walk(e,t){const s=e.slice();for(;s.length;){const i=s.shift();switch(this[Wa].indexOf(i.type)>-1&&t(i),i.type){case"expression":s.unshift(...i.terms);break;case"function":s.unshift(i.name,...i.arguments);break}}}}const Et=Object.freeze({type:"number",number:0,unit:null});/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Sn=(o,e=0)=>{let{number:t,unit:s}=o;if(!isFinite(t))t=e,s="rad";else if(o.unit==="rad"||o.unit==null)return o;return{type:"number",number:(s==="deg"&&t!=null?t:0)*Math.PI/180,unit:"rad"}},Xa=(o,e=0)=>{let{number:t,unit:s}=o;if(!isFinite(t))t=e,s="m";else if(o.unit==="m")return o;let i;switch(s){default:i=1;break;case"cm":i=1/100;break;case"mm":i=1/1e3;break}return{type:"number",number:i*t,unit:"m"}},Pe=(()=>{const o=t=>t,e={rad:o,deg:Sn,m:o,mm:Xa,cm:Xa};return(t,s=Et)=>{isFinite(t.number)||(t.number=s.number,t.unit=s.unit);const{unit:i}=t;if(i==null)return t;const n=e[i];return n==null?s:n(t)}})();/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var zc,Za,eA;const Es=Symbol("evaluate"),Ji=Symbol("lastValue");class W{constructor(){this[zc]=null}static evaluatableFor(e,t=Et){if(e instanceof W)return e;if(e.type==="number")return e.unit==="%"?new op(e,t):e;switch(e.name.value){case"calc":return new lp(e,t);case"env":return new ap(e)}return Et}static evaluate(e){return e instanceof W?e.evaluate():e}static isConstant(e){return e instanceof W?e.isConstant:!0}static applyIntrinsics(e,t){const{basis:s,keywords:i}=t,{auto:n}=i;return s.map((r,a)=>{const A=n[a]==null?r:n[a];let l=e[a]?e[a]:A;if(l.type==="ident"){const c=l.value;c in i&&(l=i[c][a])}return(l==null||l.type==="ident")&&(l=A),l.unit==="%"?he(l.number/100*r.number,r.unit):(l=Pe(l,r),l.unit!==r.unit?r:l)})}get isConstant(){return!1}evaluate(){return(!this.isConstant||this[Ji]==null)&&(this[Ji]=this[Es]()),this[Ji]}}zc=Ji;const tA=Symbol("percentage"),or=Symbol("basis");class op extends W{constructor(e,t){super(),this[tA]=e,this[or]=t}get isConstant(){return!0}[Es](){return he(this[tA].number/100*this[or].number,this[or].unit)}}const Ei=Symbol("identNode");class ap extends W{constructor(e){super(),this[Za]=null;const t=e.arguments.length?e.arguments[0].terms[0]:null;t!=null&&t.type==="ident"&&(this[Ei]=t)}get isConstant(){return!1}[(Za=Ei,Es)](){if(this[Ei]!=null)switch(this[Ei].value){case"window-scroll-y":const e=window.pageYOffset,t=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight);return{type:"number",number:e/(t-window.innerHeight)||0,unit:null}}return Et}}const Ap=/[\*\/]/,Ht=Symbol("evaluator");class lp extends W{constructor(e,t=Et){if(super(),this[eA]=null,e.arguments.length!==1)return;const s=e.arguments[0].terms.slice(),i=[];for(;s.length;){const n=s.shift();if(i.length>0){const r=i[i.length-1];if(r.type==="operator"&&Ap.test(r.value)){const a=i.pop(),A=i.pop();if(A==null)return;i.push(new iA(a,W.evaluatableFor(A,t),W.evaluatableFor(n,t)));continue}}i.push(n.type==="operator"?n:W.evaluatableFor(n,t))}for(;i.length>2;){const[n,r,a]=i.splice(0,3);if(r.type!=="operator")return;i.unshift(new iA(r,W.evaluatableFor(n,t),W.evaluatableFor(a,t)))}i.length===1&&(this[Ht]=i[0])}get isConstant(){return this[Ht]==null||W.isConstant(this[Ht])}[(eA=Ht,Es)](){return this[Ht]!=null?W.evaluate(this[Ht]):Et}}const sA=Symbol("operator"),ar=Symbol("left"),Ar=Symbol("right");class iA extends W{constructor(e,t,s){super(),this[sA]=e,this[ar]=t,this[Ar]=s}get isConstant(){return W.isConstant(this[ar])&&W.isConstant(this[Ar])}[Es](){const e=Pe(W.evaluate(this[ar])),t=Pe(W.evaluate(this[Ar])),{number:s,unit:i}=e,{number:n,unit:r}=t;if(r!=null&&i!=null&&r!=i)return Et;const a=i||r;let A;switch(this[sA].value){case"+":A=s+n;break;case"-":A=s-n;break;case"/":A=s/n;break;case"*":A=s*n;break;default:return Et}return{type:"number",number:A,unit:a}}}const lr=Symbol("evaluatables"),nA=Symbol("intrinsics");class Yc extends W{constructor(e,t){super(),this[nA]=t;const s=e[0],i=s!=null?s.terms:[];this[lr]=t.basis.map((n,r)=>{const a=i[r];return a==null?{type:"ident",value:"auto"}:a.type==="ident"?a:W.evaluatableFor(a,n)})}get isConstant(){for(const e of this[lr])if(!W.isConstant(e))return!1;return!0}[Es](){const e=this[lr].map(t=>W.evaluate(t));return W.applyIntrinsics(e,this[nA]).map(t=>t.number)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Jc,jc,Wc,Xc;const $t=Symbol("instances"),rA=Symbol("activateListener"),oA=Symbol("deactivateListener"),cr=Symbol("notifyInstances"),aA=Symbol("notify"),AA=Symbol("callback");class Ne{constructor(e){this[AA]=e}static[cr](){for(const e of Ne[$t])e[aA]()}static[(Jc=$t,rA)](){window.addEventListener("scroll",this[cr],{passive:!0})}static[oA](){window.removeEventListener("scroll",this[cr])}observe(){Ne[$t].size===0&&Ne[rA](),Ne[$t].add(this)}disconnect(){Ne[$t].delete(this),Ne[$t].size===0&&Ne[oA]()}[aA](){this[AA]()}}Ne[Jc]=new Set;const lA=Symbol("computeStyleCallback"),Zc=Symbol("astWalker"),Ks=Symbol("dependencies"),eh=Symbol("onScroll");class cp{constructor(e){this[jc]={},this[Wc]=new rp(["function"]),this[Xc]=()=>{this[lA]({relatedState:"window-scroll"})},this[lA]=e}observeEffectsFor(e){const t={},s=this[Ks];this[Zc].walk(e,i=>{const{name:n}=i,a=i.arguments[0].terms[0];if(!(n.value!=="env"||a==null||a.type!=="ident"))switch(a.value){case"window-scroll-y":if(t["window-scroll"]==null){const A="window-scroll"in s?s["window-scroll"]:new Ne(this[eh]);A.observe(),delete s["window-scroll"],t["window-scroll"]=A}break}});for(const i in s)s[i].disconnect();this[Ks]=t}dispose(){for(const e in this[Ks])this[Ks][e].disconnect()}}jc=Ks,Wc=Zc,Xc=eh;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const At=o=>{const e=o.observeEffects||!1,t=o.intrinsics instanceof Function?o.intrinsics:()=>o.intrinsics;return(s,i)=>{const n=s.updated,r=s.connectedCallback,a=s.disconnectedCallback,A=Symbol(`${i}StyleEffector`),l=Symbol(`${i}StyleEvaluator`),c=Symbol(`${i}UpdateEvaluator`),h=Symbol(`${i}EvaluateAndSync`);Object.defineProperties(s,{[A]:{value:null,writable:!0},[l]:{value:null,writable:!0},[c]:{value:function(){const d=tt(this[i]);this[l]=new Yc(d,t(this)),this[A]==null&&e&&(this[A]=new cp(()=>this[h]())),this[A]!=null&&this[A].observeEffectsFor(d)}},[h]:{value:function(){if(this[l]==null)return;const d=this[l].evaluate();this[o.updateHandler](d)}},updated:{value:function(d){d.has(i)&&(this[c](),this[h]()),n.call(this,d)}},connectedCallback:{value:function(){r.call(this),this.requestUpdate(i,this[i])}},disconnectedCallback:{value:function(){a.call(this),this[A]!=null&&(this[A].dispose(),this[A]=null)}}})}};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const th=o=>o<.5?2*o*o:-1+(4-2*o)*o,hp=(o,e,t=th)=>s=>o+(e-o)*t(s),up=(o,e)=>{const t=i=>n=>i+=n,s=e.map(t(0));return i=>{i=ke(i,0,1),i*=s[s.length-1];const n=s.findIndex(A=>A>=i),r=n<1?0:s[n-1],a=s[n];return o[n]((i-r)/(a-r))}},rs=o=>{const e=[],t=[];let s=o.initialValue;for(let i=0;i<o.keyframes.length;++i){const n=o.keyframes[i],{value:r,frames:a}=n,A=n.ease||th,l=hp(s,r,A);e.push(l),t.push(a),s=r}return up(e,t)};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var te=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const dp=5e3,gp=rs({initialValue:0,keyframes:[{frames:5,value:-1},{frames:1,value:-1},{frames:8,value:1},{frames:1,value:1},{frames:5,value:0},{frames:18,value:0}]}),pp=rs({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),fp=30,mp=12,sh="0deg 75deg 105%",Ip="auto auto auto",Ep="auto",Cp=2.2,Bp=["front","right","back","left"],yp=["upper-","","lower-"],wp=3e3,Qp=". Use mouse, touch or arrow keys to move.",Ci={AUTO:"auto",NONE:"none"},hr={BASIC:"basic",WIGGLE:"wiggle"},vp={PAN_Y:"pan-y",PAN_X:"pan-x",NONE:"none"},cA=()=>({basis:[Sn(he(fp,"deg"))],keywords:{auto:[null]}}),Sp=()=>({basis:[Sn(he(mp,"deg"))],keywords:{auto:[null]}}),ih=(()=>{const o=tt(sh)[0].terms,e=Pe(o[0]),t=Pe(o[1]);return s=>{const i=s[v].idealCameraDistance();return{basis:[e,t,he(i,"m")],keywords:{auto:[null,null,he(105,"%")]}}}})(),xp=o=>{const e=Cp*o[v].boundingSphere.radius;return{basis:[he(-1/0,"rad"),he(Math.PI/8,"rad"),he(e,"m")],keywords:{auto:[null,null,null]}}},bp=o=>{const e=ih(o),s=new Yc([],e).evaluate()[2];return{basis:[he(1/0,"rad"),he(Math.PI-Math.PI/8,"rad"),he(s,"m")],keywords:{auto:[null,null,null]}}},Tp=o=>{const e=o[v].boundingBox.getCenter(new N);return{basis:[he(e.x,"m"),he(e.y,"m"),he(e.z,"m")],keywords:{auto:[null,null,null]}}},nh=Math.PI/2,Mp=Math.PI/3,Rp=nh/2,Dp=2*Math.PI,K=Symbol("controls"),ji=Symbol("panElement"),ur=Symbol("promptElement"),Bi=Symbol("promptAnimatedContainer"),dr=Symbol("fingerAnimatedContainers"),yi=Symbol("deferInteractionPrompt"),hA=Symbol("updateAria"),uA=Symbol("updateCameraForRadius"),Vt=Symbol("cancelPrompts"),gr=Symbol("onChange"),Ss=Symbol("onPointerChange"),Qt=Symbol("waitingToPromptUser"),wi=Symbol("userHasInteracted"),qt=Symbol("promptElementVisibleTime"),xs=Symbol("lastPromptOffset"),Qi=Symbol("cancellationSource"),pr=Symbol("lastSpherical"),bs=Symbol("jumpCamera"),fr=Symbol("initialized"),Ts=Symbol("maintainThetaPhi"),dA=Symbol("syncCameraOrbit"),gA=Symbol("syncFieldOfView"),pA=Symbol("syncCameraTarget"),fA=Symbol("syncMinCameraOrbit"),mA=Symbol("syncMaxCameraOrbit"),IA=Symbol("syncMinFieldOfView"),EA=Symbol("syncMaxFieldOfView"),_p=o=>{var e,t,s,i,n,r,a,A,l,c,h,d,u,g,p,f,I;class C extends o{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=sh,this.cameraTarget=Ip,this.fieldOfView=Ep,this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=wp,this.interactionPrompt=Ci.AUTO,this.interactionPromptStyle=hr.WIGGLE,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=vp.NONE,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=Vc,this[e]=this.shadowRoot.querySelector(".interaction-prompt"),this[t]=this.shadowRoot.querySelector("#prompt"),this[s]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[i]=this.shadowRoot.querySelector(".pan-target"),this[n]=0,this[r]=1/0,this[a]=!1,this[A]=!1,this[l]=X.AUTOMATIC,this[c]=new kp(this[v].camera,this[He],this[v]),this[h]=new Vi,this[d]=!1,this[u]=!1,this[g]=!1,this[p]=()=>{const m=this[K].changeSource;this[Qi]=m,m===X.USER_INTERACTION&&(this[wi]=!0,this[yi]())},this[f]=()=>{this[hA](),this[ce]();const m=this[K].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:m}}))},this[I]=m=>{this[tn].classList.toggle("pointer-tumbling",m.type==="pointer-change-start")}}get inputSensitivity(){return this[K].inputSensitivity}set inputSensitivity(m){this[K].inputSensitivity=m}getCameraOrbit(){const{theta:m,phi:E,radius:B}=this[pr];return{theta:m,phi:E,radius:B,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return dt(this[V].isPresenting?this[V].arRenderer.target:this[v].getTarget())}getFieldOfView(){return this[K].getFieldOfView()}getMinimumFieldOfView(){return this[K].options.minimumFieldOfView}getMaximumFieldOfView(){return this[K].options.maximumFieldOfView}getIdealAspect(){return this[v].idealAspect}jumpCameraToGoal(){this[bs]=!0,this.requestUpdate(bs,!1)}resetInteractionPrompt(){this[xs]=0,this[qt]=1/0,this[wi]=!1,this[Qt]=this.interactionPrompt===Ci.AUTO&&this.cameraControls}zoom(m){const E=new WheelEvent("wheel",{deltaY:-30*m});this[He].dispatchEvent(E)}connectedCallback(){super.connectedCallback(),this[K].addEventListener("user-interaction",this[Vt]),this[K].addEventListener("pointer-change-start",this[Ss]),this[K].addEventListener("pointer-change-end",this[Ss])}disconnectedCallback(){super.disconnectedCallback(),this[K].removeEventListener("user-interaction",this[Vt]),this[K].removeEventListener("pointer-change-start",this[Ss]),this[K].removeEventListener("pointer-change-end",this[Ss])}updated(m){super.updated(m);const E=this[K],B=this[v];if(m.has("cameraControls")&&(this.cameraControls?(E.enableInteraction(),this.interactionPrompt===Ci.AUTO&&(this[Qt]=!0)):(E.disableInteraction(),this[yi]()),this[He].setAttribute("aria-label",this[Xs])),m.has("disableZoom")&&(E.disableZoom=this.disableZoom),m.has("disablePan")&&(E.enablePan=!this.disablePan),m.has("disableTap")&&(E.enableTap=!this.disableTap),(m.has("interactionPrompt")||m.has("cameraControls")||m.has("src"))&&(this.interactionPrompt===Ci.AUTO&&this.cameraControls&&!this[wi]?this[Qt]=!0:this[yi]()),m.has("interactionPromptStyle")&&(this[Bi].style.opacity=this.interactionPromptStyle==hr.BASIC?"1":"0"),m.has("touchAction")){const Q=this.touchAction;E.applyOptions({touchAction:Q}),E.updateTouchActionStyle()}m.has("orbitSensitivity")&&(E.orbitSensitivity=this.orbitSensitivity),m.has("zoomSensitivity")&&(E.zoomSensitivity=this.zoomSensitivity),m.has("panSensitivity")&&(E.panSensitivity=this.panSensitivity),m.has("interpolationDecay")&&(E.setDamperDecayTime(this.interpolationDecay),B.setTargetDamperDecayTime(this.interpolationDecay)),this[bs]===!0&&Promise.resolve().then(()=>{E.jumpToGoal(),B.jumpToGoal(),this[gr](),this[bs]=!1})}async updateFraming(){const m=this[v],E=m.adjustedFoV(m.framedFoVDeg);await m.updateFraming();const B=m.adjustedFoV(m.framedFoVDeg),Q=this[K].getFieldOfView()/E;this[K].setFieldOfView(B*Q),this[Ts]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(m,E,B){const Q=this[He],y=this[dr];if(y[0].style.opacity==="1"){console.warn("interact() failed because an existing interaction is running.");return}const S=new Array;S.push({x:rs(E.x),y:rs(E.y)});const x=[{x:S[0].x(0),y:S[0].y(0)}];B!=null&&(S.push({x:rs(B.x),y:rs(B.y)}),x.push({x:S[1].x(0),y:S[1].y(0)}));let R=performance.now();const{width:_,height:U}=this[v],T=this.getBoundingClientRect(),M=O=>{for(const[z,$]of x.entries()){const{style:Y}=y[z];Y.transform=`translateX(${_*$.x}px) translateY(${U*$.y}px)`,O==="pointerdown"?Y.opacity="1":O==="pointerup"&&(Y.opacity="0");const Z={pointerId:z-5678,pointerType:"touch",target:Q,clientX:_*$.x+T.x,clientY:U*$.y+T.y,altKey:!0};Q.dispatchEvent(new PointerEvent(O,Z))}},k=()=>{const O=this[Qi];if(O!==X.AUTOMATIC||!Q.isConnected){for(const $ of this[dr])$.style.opacity="0";M("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:O}})),document.removeEventListener("visibilitychange",D);return}const z=Math.min(1,(performance.now()-R)/m);for(const[$,Y]of x.entries())Y.x=S[$].x(z),Y.y=S[$].y(z);M("pointermove"),z<1?requestAnimationFrame(k):(M("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:X.AUTOMATIC}})),document.removeEventListener("visibilitychange",D))},D=()=>{let O=0;document.visibilityState==="hidden"?O=performance.now()-R:R=performance.now()-O};document.addEventListener("visibilitychange",D),M("pointerdown"),this[Qi]=X.AUTOMATIC,requestAnimationFrame(k)}[(e=ur,t=Bi,s=dr,i=ji,n=xs,r=qt,a=wi,A=Qt,l=Qi,c=K,h=pr,d=bs,u=fr,g=Ts,gA)](m){const E=this[K],B=this[v];B.framedFoVDeg=m[0]*180/Math.PI,E.changeSource=X.NONE,E.setFieldOfView(B.adjustedFoV(B.framedFoVDeg)),this[Vt]()}[dA](m){const E=this[K];if(this[Ts]){const{theta:B,phi:Q}=this.getCameraOrbit();m[0]=B,m[1]=Q,this[Ts]=!1}E.changeSource=X.NONE,E.setOrbit(m[0],m[1],m[2]),this[Vt]()}[fA](m){this[K].applyOptions({minimumAzimuthalAngle:m[0],minimumPolarAngle:m[1],minimumRadius:m[2]}),this.jumpCameraToGoal()}[mA](m){this[K].applyOptions({maximumAzimuthalAngle:m[0],maximumPolarAngle:m[1],maximumRadius:m[2]}),this[uA](m[2]),this.jumpCameraToGoal()}[IA](m){this[K].applyOptions({minimumFieldOfView:m[0]*180/Math.PI}),this.jumpCameraToGoal()}[EA](m){const E=this[v].adjustedFoV(m[0]*180/Math.PI);this[K].applyOptions({maximumFieldOfView:E}),this.jumpCameraToGoal()}[pA](m){const[E,B,Q]=m;this[V].arRenderer.isPresenting||this[v].setTarget(E,B,Q),this[K].changeSource=X.NONE,this[V].arRenderer.updateTarget(),this[Vt]()}[qe](m,E){if(super[qe](m,E),this[V].isPresenting||!this[Ut]())return;const B=this[K],Q=this[v],y=performance.now();if(this[Qt]&&this.loaded&&y>this[Js]+this.interactionPromptThreshold&&(this[Qt]=!1,this[qt]=y,this[ur].classList.add("visible")),isFinite(this[qt])&&this.interactionPromptStyle===hr.WIGGLE){const R=(y-this[qt])/dp%1,_=gp(R),U=pp(R);if(this[Bi].style.opacity=`${U}`,_!==this[xs]){const T=_*Q.width*.05,M=(_-this[xs])*Math.PI/16;this[Bi].style.transform=`translateX(${T}px)`,B.changeSource=X.AUTOMATIC,B.adjustOrbit(M,0,0),this[xs]=_}}const S=B.update(m,E),x=Q.updateTarget(E);(S||x)&&this[gr]()}[yi](){this[Qt]=!1,this[ur].classList.remove("visible"),this[qt]=1/0}[uA](m){const E=Math.max(this[v].farRadius(),m),B=0,Q=Math.abs(2*E);this[K].updateNearFar(B,Q)}[hA](){const{theta:m,phi:E}=this[K].getCameraSpherical(this[pr]),B=(4+Math.floor((m%Dp+Rp)/nh))%4,Q=Math.floor(E/Mp),y=Bp[B],S=yp[Q];this[Co](`View from stage ${S}${y}`)}get[Xs](){return super[Xs].replace(/\.$/,"")+(this.cameraControls?Qp:"")}async[ai](m){const E=this[K],B=this[v],Q=B.adjustedFoV(B.framedFoVDeg);super[ai](m);const y=B.adjustedFoV(B.framedFoVDeg)/Q,S=E.getFieldOfView()*(isFinite(y)?y:1);E.updateAspect(this[v].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[K].setFieldOfView(S),this.jumpCameraToGoal()}[Ct](){super[Ct](),this[fr]?this[Ts]=!0:this[fr]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}}return p=Vt,f=gr,I=Ss,te([F({type:Boolean,attribute:"camera-controls"})],C.prototype,"cameraControls",void 0),te([At({intrinsics:ih,observeEffects:!0,updateHandler:dA}),F({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],C.prototype,"cameraOrbit",void 0),te([At({intrinsics:Tp,observeEffects:!0,updateHandler:pA}),F({type:String,attribute:"camera-target",hasChanged:()=>!0})],C.prototype,"cameraTarget",void 0),te([At({intrinsics:cA,observeEffects:!0,updateHandler:gA}),F({type:String,attribute:"field-of-view",hasChanged:()=>!0})],C.prototype,"fieldOfView",void 0),te([At({intrinsics:xp,updateHandler:fA}),F({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],C.prototype,"minCameraOrbit",void 0),te([At({intrinsics:bp,updateHandler:mA}),F({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],C.prototype,"maxCameraOrbit",void 0),te([At({intrinsics:Sp,updateHandler:IA}),F({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],C.prototype,"minFieldOfView",void 0),te([At({intrinsics:cA,updateHandler:EA}),F({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],C.prototype,"maxFieldOfView",void 0),te([F({type:Number,attribute:"interaction-prompt-threshold"})],C.prototype,"interactionPromptThreshold",void 0),te([F({type:String,attribute:"interaction-prompt"})],C.prototype,"interactionPrompt",void 0),te([F({type:String,attribute:"interaction-prompt-style"})],C.prototype,"interactionPromptStyle",void 0),te([F({type:Number,attribute:"orbit-sensitivity"})],C.prototype,"orbitSensitivity",void 0),te([F({type:Number,attribute:"zoom-sensitivity"})],C.prototype,"zoomSensitivity",void 0),te([F({type:Number,attribute:"pan-sensitivity"})],C.prototype,"panSensitivity",void 0),te([F({type:String,attribute:"touch-action"})],C.prototype,"touchAction",void 0),te([F({type:Boolean,attribute:"disable-zoom"})],C.prototype,"disableZoom",void 0),te([F({type:Boolean,attribute:"disable-pan"})],C.prototype,"disablePan",void 0),te([F({type:Boolean,attribute:"disable-tap"})],C.prototype,"disableTap",void 0),te([F({type:Number,attribute:"interpolation-decay"})],C.prototype,"interpolationDecay",void 0),C};/* @license
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Lp=.018,CA=2,Fp=300,Np=new De,BA=new N,yA=Object.freeze({minimumRadius:0,maximumRadius:1/0,minimumPolarAngle:Math.PI/8,maximumPolarAngle:Math.PI-Math.PI/8,minimumAzimuthalAngle:-1/0,maximumAzimuthalAngle:1/0,minimumFieldOfView:10,maximumFieldOfView:45,touchAction:"none"}),vi=Math.PI/8,Si=.04,xi=10,X={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class kp extends wn{constructor(e,t,s){super(),this.camera=e,this.element=t,this.scene=s,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.inputSensitivity=1,this.changeSource=X.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new _o,this.panPerPixel=0,this.spherical=new Vi,this.goalSpherical=new Vi,this.thetaDamper=new ye,this.phiDamper=new ye,this.radiusDamper=new ye,this.logFov=Math.log(yA.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new ye,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=i=>{if(this.enablePan)i.preventDefault();else for(const n of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:n.id})))},this.touchModeZoom=(i,n)=>{if(!this._disableZoom){const r=this.twoTouchDistance(this.pointers[0],this.pointers[1]),a=Si*this.zoomSensitivity*(this.lastSeparation-r)*50/this.scene.height;this.lastSeparation=r,this.userAdjustOrbit(0,0,a)}this.panPerPixel>0&&this.movePan(i,n)},this.disableScroll=i=>{i.preventDefault()},this.touchModeRotate=(i,n)=>{const{touchAction:r}=this._options;if(!this.touchDecided&&r!=="none"){this.touchDecided=!0;const a=Math.abs(i),A=Math.abs(n);if(this.changeSource===X.USER_INTERACTION&&(r==="pan-y"&&A>a||r==="pan-x"&&a>A)){this.touchMode=null;return}else this.element.addEventListener("touchmove",this.disableScroll,{passive:!1})}this.handleSinglePointerMove(i,n)},this.onPointerDown=i=>{if(this.pointers.length>2)return;const{element:n}=this;this.pointers.length===0&&(n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=i.clientX,this.startPointerPosition.clientY=i.clientY,this.startTime=performance.now());try{n.setPointerCapture(i.pointerId)}catch{}this.pointers.push({clientX:i.clientX,clientY:i.clientY,id:i.pointerId}),this.isUserPointing=!1,i.pointerType==="touch"?(this.changeSource=i.altKey?X.AUTOMATIC:X.USER_INTERACTION,this.onTouchChange(i)):(this.changeSource=X.USER_INTERACTION,this.onMouseDown(i)),this.changeSource===X.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=i=>{const n=this.pointers.find(l=>l.id===i.pointerId);if(n==null)return;if(i.pointerType==="mouse"&&i.buttons===0){this.onPointerUp(i);return}const r=this.pointers.length,a=(i.clientX-n.clientX)/r,A=(i.clientY-n.clientY)/r;a===0&&A===0||(n.clientX=i.clientX,n.clientY=i.clientY,i.pointerType==="touch"?(this.changeSource=i.altKey?X.AUTOMATIC:X.USER_INTERACTION,this.touchMode!==null&&this.touchMode(a,A)):(this.changeSource=X.USER_INTERACTION,this.panPerPixel>0?this.movePan(a,A):this.handleSinglePointerMove(a,A)))},this.onPointerUp=i=>{const{element:n}=this,r=this.pointers.findIndex(a=>a.id===i.pointerId);r!==-1&&this.pointers.splice(r,1),this.panPerPixel>0&&!i.altKey&&this.resetRadius(),this.pointers.length===0?(n.removeEventListener("pointermove",this.onPointerMove),n.removeEventListener("pointerup",this.onPointerUp),n.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(i)):this.touchMode!==null&&this.onTouchChange(i),this.scene.element[ji].style.opacity=0,n.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=i=>{this.changeSource=X.USER_INTERACTION;const n=i.deltaY*(i.deltaMode==1?18:1)*Si*this.zoomSensitivity/30;this.userAdjustOrbit(0,0,n),i.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=i=>{const{changeSource:n}=this;this.changeSource=X.USER_INTERACTION,(i.shiftKey&&this.enablePan?this.panKeyCodeHandler(i):this.orbitZoomKeyCodeHandler(i))?(i.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=n},this._options=Object.assign({},yA),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(this._interactionEnabled===!1){const{element:e}=this;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||e.addEventListener("wheel",this.onWheel),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("touchmove",()=>{},{passive:!1}),e.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(this._interactionEnabled===!0){const{element:e}=this;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("pointercancel",this.onPointerUp),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("contextmenu",this.onContext),e.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(e){this._disableZoom!=e&&(this._disableZoom=e,e===!0?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(e=new Vi){return e.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(e){Object.assign(this._options,e),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(e,t){this.camera.far=t===0?2:t,this.camera.near=Math.max(e,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}setOrbit(e=this.goalSpherical.theta,t=this.goalSpherical.phi,s=this.goalSpherical.radius){const{minimumAzimuthalAngle:i,maximumAzimuthalAngle:n,minimumPolarAngle:r,maximumPolarAngle:a,minimumRadius:A,maximumRadius:l}=this._options,{theta:c,phi:h,radius:d}=this.goalSpherical,u=ke(e,i,n);!isFinite(i)&&!isFinite(n)&&(this.spherical.theta=this.wrapAngle(this.spherical.theta-u)+u);const g=ke(t,r,a),p=ke(s,A,l);return u===c&&g===h&&p===d||!isFinite(u)||!isFinite(g)||!isFinite(p)?!1:(this.goalSpherical.theta=u,this.goalSpherical.phi=g,this.goalSpherical.radius=p,this.goalSpherical.makeSafe(),!0)}setRadius(e){this.goalSpherical.radius=e,this.setOrbit()}setFieldOfView(e){const{minimumFieldOfView:t,maximumFieldOfView:s}=this._options;e=ke(e,t,s),this.goalLogFov=Math.log(e)}setDamperDecayTime(e){this.thetaDamper.setDecayTime(e),this.phiDamper.setDecayTime(e),this.radiusDamper.setDecayTime(e),this.fovDamper.setDecayTime(e)}adjustOrbit(e,t,s){const{theta:i,phi:n,radius:r}=this.goalSpherical,{minimumRadius:a,maximumRadius:A,minimumFieldOfView:l,maximumFieldOfView:c}=this._options,h=this.spherical.theta-i,d=Math.PI-.001,u=i-ke(e,-d-h,d-h),g=n-t,p=s===0?0:((s>0?A:a)-r)/(Math.log(s>0?c:l)-this.goalLogFov),f=r+s*(isFinite(p)?p:(A-a)*2);if(this.setOrbit(u,g,f),s!==0){const I=this.goalLogFov+s;this.setFieldOfView(Math.exp(I))}}jumpToGoal(){this.update(0,$c)}update(e,t){if(this.isStationary())return!1;const{maximumPolarAngle:s,maximumRadius:i}=this._options,n=this.spherical.theta-this.goalSpherical.theta;return Math.abs(n)>Math.PI&&!isFinite(this._options.minimumAzimuthalAngle)&&!isFinite(this._options.maximumAzimuthalAngle)&&(this.spherical.theta-=Math.sign(n)*2*Math.PI),this.spherical.theta=this.thetaDamper.update(this.spherical.theta,this.goalSpherical.theta,t,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,t,s),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,t,i),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,t,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:e}=this.element;if(this._interactionEnabled){const{touchAction:t}=this._options;this._disableZoom&&t!=="none"?e.touchAction="manipulation":e.touchAction=t}else e.touchAction=""}isStationary(){return this.goalSpherical.theta===this.spherical.theta&&this.goalSpherical.phi===this.spherical.phi&&this.goalSpherical.radius===this.spherical.radius&&this.goalLogFov===this.logFov}moveCamera(){this.spherical.makeSafe(),this.camera.position.setFromSpherical(this.spherical),this.camera.setRotationFromEuler(new oc(this.spherical.phi-Math.PI/2,this.spherical.theta,0,"YXZ")),this.camera.fov!==Math.exp(this.logFov)&&(this.camera.fov=Math.exp(this.logFov),this.camera.updateProjectionMatrix())}userAdjustOrbit(e,t,s){this.adjustOrbit(e*this.orbitSensitivity*this.inputSensitivity,t*this.orbitSensitivity*this.inputSensitivity,s*this.inputSensitivity)}wrapAngle(e){const t=(e+Math.PI)/(2*Math.PI);return(t-Math.floor(t))*2*Math.PI-Math.PI}pixelLengthToSphericalAngle(e){return 2*Math.PI*e/this.scene.height}twoTouchDistance(e,t){const{clientX:s,clientY:i}=e,{clientX:n,clientY:r}=t,a=n-s,A=r-i;return Math.sqrt(a*a+A*A)}handleSinglePointerMove(e,t){const s=this.pixelLengthToSphericalAngle(e),i=this.pixelLengthToSphericalAngle(t);this.isUserPointing===!1&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(s,i,0)}initializePan(){const{theta:e,phi:t}=this.spherical,s=e-this.scene.yaw;this.panPerPixel=Lp*this.panSensitivity/this.scene.height,this.panProjection.set(-Math.cos(s),-Math.cos(t)*Math.sin(s),0,0,Math.sin(t),0,Math.sin(s),-Math.cos(t)*Math.cos(s),0)}movePan(e,t){const{scene:s}=this,i=BA.set(e,t,0).multiplyScalar(this.inputSensitivity),n=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;i.multiplyScalar(n);const r=s.getTarget();r.add(i.applyMatrix3(this.panProjection)),s.boundingSphere.clampPoint(r,r),s.setTarget(r.x,r.y,r.z)}recenter(e){if(performance.now()>this.startTime+Fp||Math.abs(e.clientX-this.startPointerPosition.clientX)>CA||Math.abs(e.clientY-this.startPointerPosition.clientY)>CA)return;const{scene:t}=this,s=t.positionAndNormalFromPoint(t.getNDC(e.clientX,e.clientY));if(s==null){const{cameraTarget:i}=t.element;t.element.cameraTarget="",t.element.cameraTarget=i,this.userAdjustOrbit(0,0,1)}else t.target.worldToLocal(s.position),t.setTarget(s.position.x,s.position.y,s.position.z)}resetRadius(){const{scene:e}=this,t=e.positionAndNormalFromPoint(Np.set(0,0));if(t==null)return;e.target.worldToLocal(t.position);const s=e.getTarget(),{theta:i,phi:n}=this.spherical,r=i-e.yaw,a=BA.set(Math.sin(n)*Math.sin(r),Math.cos(n),Math.sin(n)*Math.cos(r)),A=a.dot(t.position.sub(s));s.add(a.multiplyScalar(A)),e.setTarget(s.x,s.y,s.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-A)}onTouchChange(e){if(this.pointers.length===1)this.touchMode=this.touchModeRotate;else{if(this._disableZoom){this.touchMode=null,this.element.removeEventListener("touchmove",this.disableScroll);return}this.touchMode=this.touchDecided&&this.touchMode===null?null:this.touchModeZoom,this.touchDecided=!0,this.element.addEventListener("touchmove",this.disableScroll,{passive:!1}),this.lastSeparation=this.twoTouchDistance(this.pointers[0],this.pointers[1]),this.enablePan&&this.touchMode!=null&&(this.initializePan(),e.altKey||(this.scene.element[ji].style.opacity=1))}}onMouseDown(e){this.panPerPixel=0,this.enablePan&&(e.button===2||e.ctrlKey||e.metaKey||e.shiftKey)&&(this.initializePan(),this.scene.element[ji].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(e){let t=!0;switch(e.key){case"PageUp":this.userAdjustOrbit(0,0,Si*this.zoomSensitivity);break;case"PageDown":this.userAdjustOrbit(0,0,-1*Si*this.zoomSensitivity);break;case"ArrowUp":this.userAdjustOrbit(0,-vi,0);break;case"ArrowDown":this.userAdjustOrbit(0,vi,0);break;case"ArrowLeft":this.userAdjustOrbit(-vi,0,0);break;case"ArrowRight":this.userAdjustOrbit(vi,0,0);break;default:t=!1;break}return t}panKeyCodeHandler(e){this.initializePan();let t=!0;switch(e.key){case"ArrowUp":this.movePan(0,-1*xi);break;case"ArrowDown":this.movePan(0,xi);break;case"ArrowLeft":this.movePan(-1*xi,0);break;case"ArrowRight":this.movePan(xi,0);break;default:t=!1;break}return t}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Up=30,Gp=.8,wA=1.5,Op=20,rh=1.3,Pp=1/rh,Hp=.25,$p=10,ut={NOT_PRESENTING:"not-presenting",SESSION_STARTED:"session-started",OBJECT_PLACED:"object-placed",FAILED:"failed"},go={TRACKING:"tracking",NOT_TRACKING:"not-tracking"},bi=new N,Vp=new Ve,qp=new N,Kp=new ti(45,1,.1,100);class zp extends wn{constructor(e){super(),this.renderer=e,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new N,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new N,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new N,this.goalYaw=0,this.goalScale=1,this.xDamper=new ye,this.yDamper=new ye,this.zDamper=new ye,this.yawDamper=new ye,this.scaleDamper=new ye,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{this.placementBox!=null&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new Ja(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=t=>{const s=this.transientHitTestSource;if(s==null)return;const i=this.frame.getHitTestResultsForTransientInput(s),n=this.presentedScene,r=this.placementBox;if(i.length===1){this.inputSource=t.inputSource;const{axes:a}=this.inputSource.gamepad,A=r.getHit(this.presentedScene,a[0],a[1]);r.show=!0,A!=null?(this.isTranslating=!0,this.lastDragPosition.copy(A)):this.placeOnWall===!1&&(this.isRotating=!0,this.lastAngle=a[0]*wA)}else if(i.length===2){r.show=!0,this.isTwoFingering=!0;const{separation:a}=this.fingerPolar(i);this.firstRatio=a/n.scale.x}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.threeRenderer=e.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){Ia();const e=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(e),this.threeRenderer.xr.cameraAutoUpdate=!1,e}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return Ia(),await navigator.xr.isSessionSupported("immersive-ar")}catch(e){return console.warn("Request to present in WebXR denied:"),console.warn(e),console.warn("Falling back to next ar-mode"),!1}}async present(e,t=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let s=new Promise((l,c)=>{requestAnimationFrame(()=>l())});e.setHotspotsVisibility(!1),e.queueRender(),await s,this._presentedScene=e,this.overlay=e.element.shadowRoot.querySelector("div.default"),t===!0&&(this.xrLight=new Xg(this.threeRenderer),this.xrLight.addEventListener("estimationstart",()=>{if(!this.isPresenting||this.xrLight==null)return;const l=this.presentedScene;l.add(this.xrLight),l.environment=this.xrLight.environment}));const i=await this.resolveARSession();i.addEventListener("end",()=>{this.postSessionCleanup()},{once:!0});const n=e.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");n.classList.add("enabled"),n.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=n;const r=await i.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=e.yaw,this.goalYaw=e.yaw,this.goalScale=1,e.setBackground(null),this.oldShadowIntensity=e.shadowIntensity,e.setShadowIntensity(.01),this.oldTarget.copy(e.getTarget()),e.element.addEventListener("load",this.onUpdateScene);const a=Op*Math.PI/180,A=this.placeOnWall===!0?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(a),z:-Math.cos(a)});i.requestHitTestSource({space:r,offsetRay:A}).then(l=>{this.initialHitSource=l}),this.currentSession=i,this.placementBox=new Ja(e,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:ut.SESSION_STARTED})}async stopPresenting(){if(!this.isPresenting)return;const e=new Promise(t=>{this.resolveCleanup=t});try{await this.currentSession.end(),await e}catch(t){console.warn("Error while trying to end WebXR AR session"),console.warn(t),this.postSessionCleanup()}}get isPresenting(){return this.presentedScene!=null}get target(){return this.oldTarget}updateTarget(){const e=this.presentedScene;if(e!=null){const t=e.getTarget();this.oldTarget.copy(t),this.placeOnWall?t.z=e.boundingBox.min.z:t.y=e.boundingBox.min.y,e.setTarget(t.x,t.y,t.z)}}postSessionCleanup(){const e=this.currentSession;e!=null&&(e.removeEventListener("selectstart",this.onSelectStart),e.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const t=this.presentedScene;if(this._presentedScene=null,t!=null){const{element:r}=t;this.xrLight!=null&&(t.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),t.position.set(0,0,0),t.scale.set(1,1,1),t.setShadowOffset(0);const a=this.turntableRotation;a!=null&&(t.yaw=a);const A=this.oldShadowIntensity;A!=null&&t.setShadowIntensity(A),t.setEnvironmentAndSkybox(r[$s],r[Vs]);const l=this.oldTarget;t.setTarget(l.x,l.y,l.z),t.xrCamera=null,t.element.removeEventListener("load",this.onUpdateScene),t.orientHotspots(0),r.requestUpdate("cameraTarget"),r.requestUpdate("maxCameraOrbit"),r[ai](r.getBoundingClientRect()),requestAnimationFrame(()=>{t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:X.NONE}}))})}this.renderer.height=0;const s=this.exitWebXRButtonContainer;s!=null&&(s.classList.remove("enabled"),s.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const i=this.transientHitTestSource;i!=null&&(i.cancel(),this.transientHitTestSource=null);const n=this.initialHitSource;n!=null&&(n.cancel(),this.initialHitSource=null),this.placementBox!=null&&(this.placementBox.dispose(),this.placementBox=null),this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,this.overlay=null,this.resolveCleanup!=null&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:ut.NOT_PRESENTING})}updateView(e){const t=this.presentedScene,s=this.threeRenderer.xr;s.updateCamera(Kp),t.xrCamera=s.getCamera();const{elements:i}=t.getCamera().matrixWorld;if(t.orientHotspots(Math.atan2(i[1],i[5])),this.initialized||(this.placeInitially(),this.initialized=!0),e.requestViewportScale&&e.recommendedViewportScale){const r=e.recommendedViewportScale;e.requestViewportScale(Math.max(r,Hp))}const n=s.getBaseLayer();if(n!=null){const r=n instanceof XRWebGLLayer?n.getViewport(e):s.getBinding().getViewSubImage(n,e).viewport;this.threeRenderer.setViewport(r.x,r.y,r.width,r.height)}}placeInitially(){const e=this.presentedScene,{position:t,element:s}=e,i=e.getCamera(),{width:n,height:r}=this.overlay.getBoundingClientRect();e.setSize(n,r),i.projectionMatrixInverse.copy(i.projectionMatrix).invert();const{theta:a,radius:A}=s.getCameraOrbit(),l=i.getWorldDirection(bi);e.yaw=Math.atan2(-l.x,-l.z)-a,this.goalYaw=e.yaw,t.copy(i.position).add(l.multiplyScalar(A)),this.updateTarget();const c=e.getTarget();t.add(c).sub(this.oldTarget),this.goalPosition.copy(t),e.setHotspotsVisibility(!0);const{session:h}=this.frame;h.addEventListener("selectstart",this.onSelectStart),h.addEventListener("selectend",this.onSelectEnd),h.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then(d=>{this.transientHitTestSource=d})}getTouchLocation(){const{axes:e}=this.inputSource.gamepad;let t=this.placementBox.getExpandedHit(this.presentedScene,e[0],e[1]);return t!=null&&(bi.copy(t).sub(this.presentedScene.getCamera().position),bi.length()>$p)?null:t}getHitPoint(e){const t=this.threeRenderer.xr.getReferenceSpace(),s=e.getPose(t);if(s==null)return null;const i=Vp.fromArray(s.transform.matrix);return this.placeOnWall===!0&&(this.goalYaw=Math.atan2(i.elements[4],i.elements[6])),i.elements[5]>.75!==this.placeOnWall?qp.setFromMatrixPosition(i):null}moveToFloor(e){const t=this.initialHitSource;if(t==null)return;const s=e.getHitTestResults(t);if(s.length==0)return;const i=s[0],n=this.getHitPoint(i);n!=null&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(n):this.goalPosition.y=n.y),t.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:ut.OBJECT_PLACED}))}fingerPolar(e){const t=e[0].inputSource.gamepad.axes,s=e[1].inputSource.gamepad.axes,i=s[0]-t[0],n=s[1]-t[1],r=Math.atan2(n,i);let a=this.lastAngle-r;return a>Math.PI?a-=2*Math.PI:a<-Math.PI&&(a+=2*Math.PI),this.lastAngle=r,{separation:Math.sqrt(i*i+n*n),deltaYaw:a}}processInput(e){const t=this.transientHitTestSource;if(t==null||!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const s=e.getHitTestResultsForTransientInput(t),i=this.presentedScene,n=i.scale.x;if(this.isTwoFingering){if(s.length<2)this.isTwoFingering=!1;else{const{separation:r,deltaYaw:a}=this.fingerPolar(s);if(this.placeOnWall===!1&&(this.goalYaw+=a),i.canScale){const A=r/this.firstRatio;this.goalScale=A<rh&&A>Pp?1:A}}return}else if(s.length===2){this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:r}=this.fingerPolar(s);this.firstRatio=r/n;return}if(this.isRotating){const r=this.inputSource.gamepad.axes[0]*wA;this.goalYaw+=r-this.lastAngle,this.lastAngle=r}else this.isTranslating&&s.forEach(r=>{if(r.inputSource!==this.inputSource)return;let a=null;if(r.results.length>0&&(a=this.getHitPoint(r.results[0])),a==null&&(a=this.getTouchLocation()),a!=null){if(this.goalPosition.sub(this.lastDragPosition),this.placeOnWall===!1){const A=a.y-this.lastDragPosition.y;if(A<0){this.placementBox.offsetHeight=A/n,this.presentedScene.setShadowOffset(A);const l=bi.copy(i.getCamera().position),c=-A/(l.y-a.y);l.multiplyScalar(c),a.multiplyScalar(1-c).add(l)}}this.goalPosition.add(a),this.lastDragPosition.copy(a)}})}moveScene(e){const t=this.presentedScene,{position:s,yaw:i}=t,n=t.boundingSphere.radius,r=this.goalPosition,a=t.scale.x,A=this.placementBox;let l=X.NONE;if(!r.equals(s)||this.goalScale!==a){l=X.USER_INTERACTION;let{x:c,y:h,z:d}=s;c=this.xDamper.update(c,r.x,e,n),h=this.yDamper.update(h,r.y,e,n),d=this.zDamper.update(d,r.z,e,n),s.set(c,h,d);const u=this.scaleDamper.update(a,this.goalScale,e,1);if(t.scale.set(u,u,u),!this.isTranslating){const g=r.y-h;this.placementComplete&&this.placeOnWall===!1?(A.offsetHeight=g/u,t.setShadowOffset(g)):g===0&&(this.placementComplete=!0,A.show=!1,t.setShadowIntensity(Gp))}}A.updateOpacity(e),t.updateTarget(e),t.yaw=this.yawDamper.update(i,this.goalYaw,e,Math.PI),t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:l}}))}onWebXRFrame(e,t){this.frame=t,++this.frames;const s=this.threeRenderer.xr.getReferenceSpace(),i=t.getViewerPose(s);i==null&&this.tracking===!0&&this.frames>Up&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:go.NOT_TRACKING}));const n=this.presentedScene;if(i==null||n==null||!n.element.loaded){this.threeRenderer.clear();return}this.tracking===!1&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:go.TRACKING}));let r=!0;for(const a of i.views){if(this.updateView(a),r){this.moveToFloor(t),this.processInput(t);const A=e-this.lastTick;this.moveScene(A),this.renderer.preRender(n,e,A),this.lastTick=e,n.renderShadow(this.threeRenderer)}this.threeRenderer.render(n,n.getCamera()),r=!1}}}function Yp(o){const e=new Map,t=new Map,s=o.clone();return oh(o,s,function(i,n){e.set(n,i),t.set(i,n)}),s.traverse(function(i){if(!i.isSkinnedMesh)return;const n=i,r=e.get(i),a=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=a.map(function(A){return t.get(A)}),n.bind(n.skeleton,n.bindMatrix)}),s}function oh(o,e,t){t(o,e);for(let s=0;s<o.children.length;s++)oh(o.children[s],e.children[s],t)}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const QA=Symbol("prepared"),hn=Symbol("prepare"),Fe=Symbol("preparedGLTF"),un=Symbol("clone");class Jp{constructor(e){this[Fe]=e}static prepare(e){if(e.scene==null)throw new Error("Model does not have a scene");if(e[QA])return e;const t=this[hn](e);return t[QA]=!0,t}static[hn](e){const{scene:t}=e,s=[t];return Object.assign(Object.assign({},e),{scene:t,scenes:s})}get parser(){return this[Fe].parser}get animations(){return this[Fe].animations}get scene(){return this[Fe].scene}get scenes(){return this[Fe].scenes}get cameras(){return this[Fe].cameras}get asset(){return this[Fe].asset}get userData(){return this[Fe].userData}clone(){const e=this.constructor,t=this[un]();return new e(t)}dispose(){this.scenes.forEach(e=>{e.traverse(t=>{const s=t;if(!s.material)return;(Array.isArray(s.material)?s.material:[s.material]).forEach(n=>{for(const r in n){const a=n[r];if(a instanceof Ge){const A=a.source.data;A.close!=null&&A.close(),a.dispose()}}n.dispose()}),s.geometry.dispose()})})}[un](){const e=this[Fe],t=Yp(this.scene);jp(t,this.scene);const s=[t],i=e.userData?Object.assign({},e.userData):{};return Object.assign(Object.assign({},e),{scene:t,scenes:s,userData:i})}}const jp=(o,e)=>{ah(o,e,(t,s)=>{s.userData.variantMaterials!==void 0&&(t.userData.variantMaterials=new Map(s.userData.variantMaterials)),s.userData.variantData!==void 0&&(t.userData.variantData=s.userData.variantData),s.userData.originalMaterial!==void 0&&(t.userData.originalMaterial=s.userData.originalMaterial)})},ah=(o,e,t)=>{t(o,e);for(let s=0;s<o.children.length;s++)ah(o.children[s],e.children[s],t)},vA=Symbol("threeGLTF"),SA=Symbol("gltf"),xA=Symbol("gltfElementMap"),bA=Symbol("threeObjectMap"),TA=Symbol("parallelTraverseThreeScene"),MA=Symbol("correlateOriginalThreeGLTF"),RA=Symbol("correlateCloneThreeGLTF");class oi{constructor(e,t,s,i){this[vA]=e,this[SA]=t,this[xA]=i,this[bA]=s}static from(e,t){return t!=null?this[RA](e,t):this[MA](e)}static[MA](e){const t=e.parser.json,s=e.parser.associations,i=new Map,n={name:"Default"},r={type:"materials",index:-1};for(const a of s.keys())a instanceof Hi&&s.get(a)==null&&(r.index<0&&(t.materials==null&&(t.materials=[]),r.index=t.materials.length,t.materials.push(n)),a.name=n.name,s.set(a,{materials:r.index}));for(const[a,A]of s){A&&(a.userData=a.userData||{},a.userData.associations=A);for(const l in A)if(l!=null&&l!=="primitives"){const c=l,d=(t[c]||[])[A[c]];if(d==null)continue;let u=i.get(d);u==null&&(u=new Set,i.set(d,u)),u.add(a)}}return new oi(e,t,s,i)}static[RA](e,t){const s=t.threeGLTF,i=t.gltf,n=JSON.parse(JSON.stringify(i)),r=new Map,a=new Map;for(let A=0;A<s.scenes.length;A++)this[TA](s.scenes[A],e.scenes[A],(l,c)=>{const h=t.threeObjectMap.get(l);if(h!=null){for(const d in h)if(d!=null&&d!=="primitives"){const u=d,g=h[u],p=n[u][g],f=r.get(c)||{};f[u]=g,r.set(c,f);const I=a.get(p)||new Set;I.add(c),a.set(p,I)}}});return new oi(e,n,r,a)}static[TA](e,t,s){const i=(n,r)=>{if(s(n,r),n.isObject3D){const a=n,A=r;if(a.material)if(Array.isArray(a.material))for(let l=0;l<a.material.length;++l)s(a.material[l],A.material[l]);else s(a.material,A.material);for(let l=0;l<n.children.length;++l)i(n.children[l],r.children[l])}};i(e,t)}get threeGLTF(){return this[vA]}get gltf(){return this[SA]}get gltfElementMap(){return this[xA]}get threeObjectMap(){return this[bA]}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ms=Symbol("correlatedSceneGraph");class Wp extends Jp{static[hn](e){const t=super[hn](e);t[Ms]==null&&(t[Ms]=oi.from(t));const{scene:s}=t,i=new Ro(void 0,1/0);return s.traverse(n=>{n.renderOrder=1e3,n.frustumCulled=!1,n.name||(n.name=n.uuid);const r=n;if(r.material){const{geometry:a}=r;r.castShadow=!0,r.isSkinnedMesh&&(a.boundingSphere=i,a.boundingBox=null);const A=r.material;if(A.isMeshBasicMaterial===!0&&(A.toneMapped=!1),A.shadowSide=Mo,A.aoMap){const{gltf:l,threeObjectMap:c}=t[Ms],h=c.get(A);if(l.materials!=null&&h!=null&&h.materials!=null){const d=l.materials[h.materials];d.occlusionTexture&&d.occlusionTexture.texCoord===0&&a.attributes.uv!=null&&a.setAttribute("uv2",a.attributes.uv)}}}}),t}get correlatedSceneGraph(){return this[Fe][Ms]}[un](){const e=super[un](),t=new Map;return e.scene.traverse(s=>{const i=s;if(i.material){const r=i.material;if(r!=null){if(t.has(r.uuid)){i.material=t.get(r.uuid);return}i.material=r.clone(),t.set(r.uuid,i.material)}}const n=s;n.target!==void 0&&n.add(n.target)}),e[Ms]=oi.from(e,this.correlatedSceneGraph),e}}const Ah=(o,e,t)=>{let s;switch(o){case Ie:s=new Uint8ClampedArray(e*t*4);break;case Qe:s=new Uint16Array(e*t*4);break;case Mu:s=new Uint32Array(e*t*4);break;case Tu:s=new Int8Array(e*t*4);break;case bu:s=new Int16Array(e*t*4);break;case xu:s=new Int32Array(e*t*4);break;case $e:s=new Float32Array(e*t*4);break;default:throw new Error("Unsupported data type")}return s};let Ti;const Xp=(o,e,t,s)=>{if(Ti!==void 0)return Ti;const i=new si(1,1,s);e.setRenderTarget(i);const n=new pe(new Is,new Ue({color:16777215}));e.render(n,t),e.setRenderTarget(null);const r=Ah(o,i.width,i.height);return e.readRenderTargetPixels(i,0,0,i.width,i.height,r),i.dispose(),n.geometry.dispose(),n.material.dispose(),Ti=r[0]!==0,Ti};class ko{constructor(e){var t,s,i,n,r,a,A,l,c,h,d,u,g,p,f,I;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(w){throw this._renderer.setRenderTarget(null),w}this._renderer.setRenderTarget(null)},this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const C={format:we,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:((t=e.renderTargetOptions)===null||t===void 0?void 0:t.anisotropy)!==void 0?(s=e.renderTargetOptions)===null||s===void 0?void 0:s.anisotropy:1,generateMipmaps:((i=e.renderTargetOptions)===null||i===void 0?void 0:i.generateMipmaps)!==void 0?(n=e.renderTargetOptions)===null||n===void 0?void 0:n.generateMipmaps:!1,magFilter:((r=e.renderTargetOptions)===null||r===void 0?void 0:r.magFilter)!==void 0?(a=e.renderTargetOptions)===null||a===void 0?void 0:a.magFilter:ae,minFilter:((A=e.renderTargetOptions)===null||A===void 0?void 0:A.minFilter)!==void 0?(l=e.renderTargetOptions)===null||l===void 0?void 0:l.minFilter:ae,samples:((c=e.renderTargetOptions)===null||c===void 0?void 0:c.samples)!==void 0?(h=e.renderTargetOptions)===null||h===void 0?void 0:h.samples:void 0,wrapS:((d=e.renderTargetOptions)===null||d===void 0?void 0:d.wrapS)!==void 0?(u=e.renderTargetOptions)===null||u===void 0?void 0:u.wrapS:Me,wrapT:((g=e.renderTargetOptions)===null||g===void 0?void 0:g.wrapT)!==void 0?(p=e.renderTargetOptions)===null||p===void 0?void 0:p.wrapT:Me};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=ko.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new It,this._camera=new mn,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!Xp(this._type,this._renderer,this._camera,C)){let w;switch(this._type){case Qe:w=this._renderer.extensions.has("EXT_color_buffer_float")?$e:void 0;break}w!==void 0?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${$e}`),this._type=w):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new pe(new Is,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new si(this.width,this.height,C),this._renderTarget.texture.mapping=((f=e.renderTargetOptions)===null||f===void 0?void 0:f.mapping)!==void 0?(I=e.renderTargetOptions)===null||I===void 0?void 0:I.mapping:an}static instantiateRenderer(){const e=new Do;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=Ah(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new ic(this.toArray(),this.width,this.height,we,this._type,(e==null?void 0:e.mapping)||an,(e==null?void 0:e.wrapS)||Me,(e==null?void 0:e.wrapT)||Me,(e==null?void 0:e.magFilter)||ae,(e==null?void 0:e.minFilter)||ae,(e==null?void 0:e.anisotropy)||1,ee);return t.generateMipmaps=(e==null?void 0:e.generateMipmaps)!==void 0?e==null?void 0:e.generateMipmaps:!1,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof cs&&Object.values(this.material.uniforms).forEach(t=>{t.value instanceof Ge&&t.value.dispose()}),Object.values(this.material).forEach(t=>{t instanceof Ge&&t.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}const Zp=`
varying vec2 vUv;

void main() {
  vUv = uv;
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,ef=`
// min half float value
#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )
// max half float value
#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )

uniform sampler2D sdr;
uniform sampler2D gainMap;
uniform vec3 gamma;
uniform vec3 offsetHdr;
uniform vec3 offsetSdr;
uniform vec3 gainMapMin;
uniform vec3 gainMapMax;
uniform float weightFactor;

varying vec2 vUv;

void main() {
  vec3 rgb = texture2D( sdr, vUv ).rgb;
  vec3 recovery = texture2D( gainMap, vUv ).rgb;
  vec3 logRecovery = pow( recovery, gamma );
  vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;
  vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;
  vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
  gl_FragColor = vec4( clampedHdrColor , 1.0 );
}
`;class tf extends cs{constructor({gamma:e,offsetHdr:t,offsetSdr:s,gainMapMin:i,gainMapMax:n,maxDisplayBoost:r,hdrCapacityMin:a,hdrCapacityMax:A,sdr:l,gainMap:c}){super({name:"GainMapDecoderMaterial",vertexShader:Zp,fragmentShader:ef,uniforms:{sdr:{value:l},gainMap:{value:c},gamma:{value:new N(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:new N().fromArray(t)},offsetSdr:{value:new N().fromArray(s)},gainMapMin:{value:new N().fromArray(i)},gainMapMax:{value:new N().fromArray(n)},weightFactor:{value:(Math.log2(r)-a)/(A-a)}},blending:ac,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=r,this._hdrCapacityMin=a,this._hdrCapacityMax=A,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}class lh extends Error{}class ch extends Error{}const Rs=(o,e,t)=>{var s;let i;const n=(s=o.attributes.getNamedItem(e))===null||s===void 0?void 0:s.nodeValue;if(n)i=n;else{const r=o.getElementsByTagName(e)[0];if(r){const a=r.getElementsByTagName("rdf:li");if(a.length===3)i=Array.from(a).map(A=>A.innerHTML);else throw new Error(`Gainmap metadata contains an array of items for ${e} but its length is not 3`)}else{if(t)return t;throw new Error(`Can't find ${e} in gainmap metadata`)}}return i},sf=o=>{var e,t;let s;typeof TextDecoder<"u"?s=new TextDecoder().decode(o):s=o.toString();let i=s.indexOf("<x:xmpmeta");const n=new DOMParser;for(;i!==-1;){const r=s.indexOf("x:xmpmeta>",i);s.slice(i,r+10);const a=s.slice(i,r+10);try{const l=n.parseFromString(a,"text/xml").getElementsByTagName("rdf:Description")[0],c=Rs(l,"hdrgm:GainMapMin","0"),h=Rs(l,"hdrgm:GainMapMax"),d=Rs(l,"hdrgm:Gamma","1"),u=Rs(l,"hdrgm:OffsetSDR","0.015625"),g=Rs(l,"hdrgm:OffsetHDR","0.015625");let p=(e=l.attributes.getNamedItem("hdrgm:HDRCapacityMin"))===null||e===void 0?void 0:e.nodeValue;p||(p="0");const f=(t=l.attributes.getNamedItem("hdrgm:HDRCapacityMax"))===null||t===void 0?void 0:t.nodeValue;if(!f)throw new Error("Incomplete gainmap metadata");return{gainMapMin:Array.isArray(c)?c.map(I=>parseFloat(I)):[parseFloat(c),parseFloat(c),parseFloat(c)],gainMapMax:Array.isArray(h)?h.map(I=>parseFloat(I)):[parseFloat(h),parseFloat(h),parseFloat(h)],gamma:Array.isArray(d)?d.map(I=>parseFloat(I)):[parseFloat(d),parseFloat(d),parseFloat(d)],offsetSdr:Array.isArray(u)?u.map(I=>parseFloat(I)):[parseFloat(u),parseFloat(u),parseFloat(u)],offsetHdr:Array.isArray(g)?g.map(I=>parseFloat(I)):[parseFloat(g),parseFloat(g),parseFloat(g)],hdrCapacityMin:parseFloat(p),hdrCapacityMax:parseFloat(f)}}catch{}i=s.indexOf("<x:xmpmeta",r)}};class nf{constructor(e){this.options={debug:e&&e.debug!==void 0?e.debug:!1,extractFII:e&&e.extractFII!==void 0?e.extractFII:!0,extractNonFII:e&&e.extractNonFII!==void 0?e.extractNonFII:!0}}extract(e){return new Promise((t,s)=>{const i=this.options.debug,n=new DataView(e.buffer);if(n.getUint16(0)!==65496){s(new Error("Not a valid jpeg"));return}const r=n.byteLength;let a=2,A=0,l;for(;a<r;){if(++A>250){s(new Error(`Found no marker after ${A} loops 😵`));return}if(n.getUint8(a)!==255){s(new Error(`Not a valid marker at offset 0x${a.toString(16)}, found: 0x${n.getUint8(a).toString(16)}`));return}if(l=n.getUint8(a+1),i&&console.log(`Marker: ${l.toString(16)}`),l===226){i&&console.log("Found APP2 marker (0xffe2)");const c=a+4;if(n.getUint32(c)===1297106432){const h=c+4;let d;if(n.getUint16(h)===18761)d=!1;else if(n.getUint16(h)===19789)d=!0;else{s(new Error("No valid endianness marker found in TIFF header"));return}if(n.getUint16(h+2,!d)!==42){s(new Error("Not valid TIFF data! (no 0x002A marker)"));return}const u=n.getUint32(h+4,!d);if(u<8){s(new Error("Not valid TIFF data! (First offset less than 8)"));return}const g=h+u,p=n.getUint16(g,!d),f=g+2;let I=0;for(let E=f;E<f+12*p;E+=12)n.getUint16(E,!d)===45057&&(I=n.getUint32(E+8,!d));const w=g+2+p*12+4,m=[];for(let E=w;E<w+I*16;E+=16){const B={MPType:n.getUint32(E,!d),size:n.getUint32(E+4,!d),dataOffset:n.getUint32(E+8,!d),dependantImages:n.getUint32(E+12,!d),start:-1,end:-1,isFII:!1};B.dataOffset?(B.start=h+B.dataOffset,B.isFII=!1):(B.start=0,B.isFII=!0),B.end=B.start+B.size,m.push(B)}if(this.options.extractNonFII&&m.length){const E=new Blob([n]),B=[];for(const Q of m){if(Q.isFII&&!this.options.extractFII)continue;const y=E.slice(Q.start,Q.end+1,"image/jpeg");B.push(y)}t(B)}}}a+=2+n.getUint16(a+2)}})}}const rf=async o=>{const e=sf(o);if(!e)throw new ch("Gain map XMP metadata not found");const s=await new nf({extractFII:!0,extractNonFII:!0}).extract(o);if(s.length!==2)throw new lh("Gain map recovery image not found");return{sdr:new Uint8Array(await s[0].arrayBuffer()),gainMap:new Uint8Array(await s[1].arrayBuffer()),metadata:e}},DA=o=>new Promise((e,t)=>{const s=document.createElement("img");s.onload=()=>{e(s)},s.onerror=i=>{t(i)},s.src=URL.createObjectURL(o)});class of extends fn{constructor(e,t){super(t),this._renderer=e,this._internalLoadingManager=new Ru}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){const e=new tf({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new Ge,sdr:new Ge});return new ko({width:16,height:16,type:Qe,colorSpace:ee,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(e,t,s,i){const n=i?new Blob([i],{type:"image/jpeg"}):void 0,r=new Blob([s],{type:"image/jpeg"});let a,A,l=!1;if(typeof createImageBitmap>"u"){const d=await Promise.all([n?DA(n):Promise.resolve(void 0),DA(r)]);A=d[0],a=d[1],l=!0}else{const d=await Promise.all([n?createImageBitmap(n,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(r,{imageOrientation:"flipY"})]);A=d[0],a=d[1]}const c=new Ge(A||new ImageData(2,2),an,Me,Me,ae,sa,we,Ie,1,ee);c.flipY=l,c.needsUpdate=!0;const h=new Ge(a,an,Me,Me,ae,sa,we,Ie,1,Ee);h.flipY=l,h.needsUpdate=!0,e.width=a.width,e.height=a.height,e.material.gainMap=c,e.material.sdr=h,e.material.gainMapMin=t.gainMapMin,e.material.gainMapMax=t.gainMapMax,e.material.offsetHdr=t.offsetHdr,e.material.offsetSdr=t.offsetSdr,e.material.gamma=t.gamma,e.material.hdrCapacityMin=t.hdrCapacityMin,e.material.hdrCapacityMax=t.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,t.hdrCapacityMax),e.material.needsUpdate=!0,e.render()}}class af extends of{load(e,t,s,i){const n=this.prepareQuadRenderer(),r=new pt(this._internalLoadingManager);return r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),this.manager.itemStart(e),r.load(e,async a=>{if(typeof a=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const A=new Uint8Array(a);let l,c,h;try{const d=await rf(A);l=d.sdr,c=d.gainMap,h=d.metadata}catch(d){if(d instanceof ch||d instanceof lh)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),h={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},l=A;else throw d}try{await this.render(n,h,l,c)}catch(d){this.manager.itemError(e),typeof i=="function"&&i(d),n.disposeOnDemandRenderer();return}typeof t=="function"&&t(n),this.manager.itemEnd(e),n.disposeOnDemandRenderer()},s,a=>{this.manager.itemError(e),typeof i=="function"&&i(a)}),n}}class Af extends Du{constructor(e){super(e),this.type=Qe}parse(e){const r=function(y,S){switch(y){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(S||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(S||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(S||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(S||""))}},c=`
`,h=function(y,S,x){S=S||1024;let _=y.pos,U=-1,T=0,M="",k=String.fromCharCode.apply(null,new Uint16Array(y.subarray(_,_+128)));for(;0>(U=k.indexOf(c))&&T<S&&_<y.byteLength;)M+=k,T+=k.length,_+=128,k+=String.fromCharCode.apply(null,new Uint16Array(y.subarray(_,_+128)));return-1<U?(x!==!1&&(y.pos+=T+U+1),M+k.slice(0,U)):!1},d=function(y){const S=/^#\?(\S+)/,x=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,R=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,U=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,T={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let M,k;for((y.pos>=y.byteLength||!(M=h(y)))&&r(1,"no header found"),(k=M.match(S))||r(3,"bad initial token"),T.valid|=1,T.programtype=k[1],T.string+=M+`
`;M=h(y),M!==!1;){if(T.string+=M+`
`,M.charAt(0)==="#"){T.comments+=M+`
`;continue}if((k=M.match(x))&&(T.gamma=parseFloat(k[1])),(k=M.match(R))&&(T.exposure=parseFloat(k[1])),(k=M.match(_))&&(T.valid|=2,T.format=k[1]),(k=M.match(U))&&(T.valid|=4,T.height=parseInt(k[1],10),T.width=parseInt(k[2],10)),T.valid&2&&T.valid&4)break}return T.valid&2||r(3,"missing format specifier"),T.valid&4||r(3,"missing image size specifier"),T},u=function(y,S,x){const R=S;if(R<8||R>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);R!==(y[2]<<8|y[3])&&r(3,"wrong scanline width");const _=new Uint8Array(4*S*x);_.length||r(4,"unable to allocate buffer space");let U=0,T=0;const M=4*R,k=new Uint8Array(4),D=new Uint8Array(M);let O=x;for(;O>0&&T<y.byteLength;){T+4>y.byteLength&&r(1),k[0]=y[T++],k[1]=y[T++],k[2]=y[T++],k[3]=y[T++],(k[0]!=2||k[1]!=2||(k[2]<<8|k[3])!=R)&&r(3,"bad rgbe scanline format");let z=0,$;for(;z<M&&T<y.byteLength;){$=y[T++];const Z=$>128;if(Z&&($-=128),($===0||z+$>M)&&r(3,"bad scanline data"),Z){const re=y[T++];for(let Ce=0;Ce<$;Ce++)D[z++]=re}else D.set(y.subarray(T,T+$),z),z+=$,T+=$}const Y=R;for(let Z=0;Z<Y;Z++){let re=0;_[U]=D[Z+re],re+=R,_[U+1]=D[Z+re],re+=R,_[U+2]=D[Z+re],re+=R,_[U+3]=D[Z+re],U+=4}O--}return _},g=function(y,S,x,R){const _=y[S+3],U=Math.pow(2,_-128)/255;x[R+0]=y[S+0]*U,x[R+1]=y[S+1]*U,x[R+2]=y[S+2]*U,x[R+3]=1},p=function(y,S,x,R){const _=y[S+3],U=Math.pow(2,_-128)/255;x[R+0]=di.toHalfFloat(Math.min(y[S+0]*U,65504)),x[R+1]=di.toHalfFloat(Math.min(y[S+1]*U,65504)),x[R+2]=di.toHalfFloat(Math.min(y[S+2]*U,65504)),x[R+3]=di.toHalfFloat(1)},f=new Uint8Array(e);f.pos=0;const I=d(f),C=I.width,w=I.height,m=u(f.subarray(f.pos),C,w);let E,B,Q;switch(this.type){case $e:Q=m.length/4;const y=new Float32Array(Q*4);for(let x=0;x<Q;x++)g(m,x*4,y,x*4);E=y,B=$e;break;case Qe:Q=m.length/4;const S=new Uint16Array(Q*4);for(let x=0;x<Q;x++)p(m,x*4,S,x*4);E=S,B=Qe;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:C,height:w,data:E,header:I.string,gamma:I.gamma,exposure:I.exposure,type:B}}setDataType(e){return this.type=e,this}load(e,t,s,i){function n(r,a){switch(r.type){case $e:case Qe:r.colorSpace=ee,r.minFilter=ae,r.magFilter=ae,r.generateMipmaps=!1,r.flipY=!0;break}t&&t(r,a)}return super.load(e,n,s,i)}}/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const lf={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]},cf={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,10,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,14,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,12,0],scale:[.1,5,5]},{intensity:16,position:[0,9,14],scale:[5,5,.1]},{intensity:80,position:[7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,16,-14],scale:[2.5,2.5,.1]},{intensity:1,position:[0,20,0],scale:[.1,.1,.1]}]};class _A extends It{constructor(e){super(),this.position.y=-3.5;const t=new Ac;t.deleteAttribute("uv");const s=new nn({metalness:0,side:Lo}),i=new nn({metalness:0}),n=e=="legacy"?lf:cf,r=new Zl(16777215,n.topLight.intensity,28,2);r.position.set(...n.topLight.position),this.add(r);const a=new pe(t,s);a.position.set(...n.room.position),a.scale.set(...n.room.scale),this.add(a);for(const A of n.boxes){const l=new pe(t,i);l.position.set(...A.position),l.rotation.set(0,A.rotation,0),l.scale.set(...A.scale),this.add(l)}for(const A of n.lights){const l=new pe(t,this.createAreaLightMaterial(A.intensity));l.position.set(...A.position),l.scale.set(...A.scale),this.add(l)}}createAreaLightMaterial(e){const t=new Ue;return t.color.setScalar(e),t}}const hf=.04,Kt=20,uf=/\.hdr(\.js)?$/;class LA{constructor(e){this.threeRenderer=e,this.lottieLoaderUrl="",this.withCredentials=!1,this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}get ldrLoader(){return this._ldrLoader==null&&(this._ldrLoader=new tc),this._ldrLoader.setWithCredentials(this.withCredentials),this._ldrLoader}get imageLoader(){return this._imageLoader==null&&(this._imageLoader=new af(this.threeRenderer)),this._imageLoader.setWithCredentials(this.withCredentials),this._imageLoader}get hdrLoader(){return this._hdrLoader==null&&(this._hdrLoader=new Af,this._hdrLoader.setDataType(Qe)),this._hdrLoader.setWithCredentials(this.withCredentials),this._hdrLoader}async getLottieLoader(){if(this._lottieLoader==null){const{LottieLoader:e}=await Lh(()=>import(this.lottieLoaderUrl),__vite__mapDeps([]),import.meta.url);this._lottieLoader=new e}return this._lottieLoader.setWithCredentials(this.withCredentials),this._lottieLoader}async loadImage(e){const t=await new Promise((s,i)=>this.ldrLoader.load(e,s,()=>{},i));return t.name=e,t.flipY=!1,t}async loadLottie(e,t){const s=await this.getLottieLoader();s.setQuality(t);const i=await new Promise((n,r)=>s.load(e,n,()=>{},r));return i.name=e,i}async loadEquirect(e,t=()=>{}){try{const s=uf.test(e),i=s?this.hdrLoader:this.imageLoader,n=await new Promise((r,a)=>i.load(e,A=>{const{renderTarget:l}=A;if(l!=null){const{texture:c}=l;A.dispose(!1),r(c)}else r(A)},A=>{t(A.loaded/A.total*.9)},a));return t(1),n.name=e,n.mapping=_u,s||(n.colorSpace=Ee),n}finally{t&&t(1)}}async generateEnvironmentMapAndSkybox(e=null,t=null,s=()=>{}){const i=t!=="legacy";(t==="legacy"||t==="neutral")&&(t=null),t=yc(t);let n=Promise.resolve(null),r;e&&(n=this.loadEquirectFromUrl(e,s)),t?r=this.loadEquirectFromUrl(t,s):e?r=this.loadEquirectFromUrl(e,s):r=i?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[a,A]=await Promise.all([r,n]);if(a==null)throw new Error("Failed to load environment map.");return{environmentMap:a,skybox:A}}async loadEquirectFromUrl(e,t){if(!this.skyboxCache.has(e)){const s=this.loadEquirect(e,t);this.skyboxCache.set(e,s)}return this.skyboxCache.get(e)}async GenerateEnvironmentMap(e,t){await gd();const s=this.threeRenderer,i=new rc(256,{generateMipmaps:!1,type:Qe,format:we,colorSpace:ee,depthBuffer:!0}),n=new ia(.1,100,i),r=n.renderTarget.texture;r.name=t;const a=s.outputColorSpace,A=s.toneMapping;return s.toneMapping=Lu,s.outputColorSpace=ee,n.update(s,e),this.blurCubemap(i,hf),s.toneMapping=A,s.outputColorSpace=a,r}async loadGeneratedEnvironmentMap(){return this.generatedEnvironmentMap==null&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new _A("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return this.generatedEnvironmentMapAlt==null&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new _A("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(e,t){if(this.blurMaterial==null){this.blurMaterial=this.getBlurShader(Kt);const i=new Ac,n=new pe(i,this.blurMaterial);this.blurScene=new It,this.blurScene.add(n)}const s=e.clone();this.halfblur(e,s,t,"latitudinal"),this.halfblur(s,e,t,"longitudinal")}halfblur(e,t,s,i){const r=e.width,a=isFinite(s)?Math.PI/(2*r):2*Math.PI/(2*Kt-1),A=s/a,l=isFinite(s)?1+Math.floor(3*A):Kt;l>Kt&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${l} samples when the maximum is set to ${Kt}`);const c=[];let h=0;for(let g=0;g<Kt;++g){const p=g/A,f=Math.exp(-p*p/2);c.push(f),g==0?h+=f:g<l&&(h+=2*f)}for(let g=0;g<c.length;g++)c[g]=c[g]/h;const d=this.blurMaterial.uniforms;d.envMap.value=e.texture,d.samples.value=l,d.weights.value=c,d.latitudinal.value=i==="latitudinal",d.dTheta.value=a,new ia(.1,100,t).update(this.threeRenderer,this.blurScene)}getBlurShader(e){const t=new Float32Array(e),s=new N(0,1,0);return new cs({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:s}},vertexShader:`
      
      varying vec3 vOutputDirection;
  
      void main() {
  
        vOutputDirection = vec3( position );
        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  
      }
    `,fragmentShader:`
        varying vec3 vOutputDirection;
  
        uniform samplerCube envMap;
        uniform int samples;
        uniform float weights[ n ];
        uniform bool latitudinal;
        uniform float dTheta;
        uniform vec3 poleAxis;
  
        vec3 getSample( float theta, vec3 axis ) {
  
          float cosTheta = cos( theta );
          // Rodrigues' axis-angle rotation
          vec3 sampleDirection = vOutputDirection * cosTheta
            + cross( axis, vOutputDirection ) * sin( theta )
            + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  
          return vec3( textureCube( envMap, sampleDirection ) );
  
        }
  
        void main() {
  
          vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  
          if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  
            axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  
          }
  
          axis = normalize( axis );
  
          gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
          gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  
          for ( int i = 1; i < n; i++ ) {
  
            if ( i >= samples ) {
  
              break;
  
            }
  
            float theta = dTheta * float( i );
            gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
            gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  
          }
        }
      `,blending:ac,depthTest:!1,depthWrite:!1,side:Lo})}async dispose(){for(const[,e]of this.skyboxCache)(await e).dispose();this.generatedEnvironmentMap!=null&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),this.generatedEnvironmentMapAlt!=null&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),this.blurMaterial!=null&&this.blurMaterial.dispose()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const df=.2,mr=40,Ir=60,FA=5,zt=[1,.79,.62,.5,.4,.31,.25],gf=3,hh="high-performance",pf=1.3;class Re extends wn{constructor(e){super(),this.loader=new se(Wp),this.width=0,this.height=0,this.dpr=1,this.scenes=new Set,this.multipleScenesVisible=!1,this.lastTick=performance.now(),this.renderedLastFrame=!1,this.scaleStep=0,this.lastStep=gf,this.avgFrameDuration=(Ir+mr)/2,this.onWebGLContextLost=t=>{this.dispatchEvent({type:"contextlost",sourceEvent:t})},this.onWebGLContextRestored=()=>{var t;(t=this.textureUtils)===null||t===void 0||t.dispose(),this.textureUtils=new LA(this.threeRenderer);for(const s of this.scenes)s.element[cn]()},this.dpr=lo(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show"),na.tonemapping_pars_fragment=na.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }",`
      float startCompression = 0.8 - 0.04;
      float desaturation = 0.15;
      vec3 CustomToneMapping( vec3 color ) {
        color *= toneMappingExposure;

        float x = min(color.r, min(color.g, color.b));
        float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
        color -= offset;

        float peak = max(color.r, max(color.g, color.b));
        if (peak < startCompression) return color;

        float d = 1. - startCompression;
        float newPeak = 1. - d * d / (peak + d - startCompression);
        color *= newPeak / peak;

        float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
        return mix(color, vec3(1, 1, 1), g);
      }`);try{this.threeRenderer=new Do({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:e.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!e.debug,onShaderError:null},this.threeRenderer.toneMapping=xo}catch(t){console.warn(t)}this.arRenderer=new zp(this),this.textureUtils=this.canRender?new LA(this.threeRenderer):null,se.initializeKTX2Loader(this.threeRenderer),this.canvas3D.addEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.addEventListener("webglcontextrestored",this.onWebGLContextRestored),this.updateRendererSize()}static get singleton(){return this._singleton}static resetSingleton(){const e=this._singleton.dispose();for(const t of e)t.disconnectedCallback();this._singleton=new Re({powerPreference:(self.ModelViewerElement||{}).powerPreference||hh,debug:wc()});for(const t of e)t.connectedCallback()}get canRender(){return this.threeRenderer!=null}get scaleFactor(){return zt[this.scaleStep]}set minScale(e){let t=1;for(;t<zt.length&&!(zt[t]<e);)++t;this.lastStep=t-1}registerScene(e){this.scenes.add(e),e.forceRescale();const t=new De;this.threeRenderer.getSize(t),e.canvas.width=t.x,e.canvas.height=t.y,this.canRender&&this.scenes.size>0&&this.threeRenderer.setAnimationLoop((s,i)=>this.render(s,i))}unregisterScene(e){this.scenes.delete(e),this.canvas3D.parentElement===e.canvas.parentElement&&e.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&this.scenes.size===0&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(e){return this.multipleScenesVisible?e.element[Bo]:this.canvas3D}countVisibleScenes(){const{canvas3D:e}=this;let t=0,s=null;for(const n of this.scenes){const{element:r}=n;r.modelIsVisible&&n.externalRenderer==null&&++t,e.parentElement===n.canvas.parentElement&&(s=n)}const i=t>1;if(s!=null){const n=i&&!this.multipleScenesVisible,r=!s.element.modelIsVisible;if(n||r){const{width:a,height:A}=this.sceneSize(s);this.copyPixels(s,a,A),e.parentElement.removeChild(e)}}this.multipleScenesVisible=i}updateRendererSize(){var e;const t=lo();if(t!==this.dpr)for(const n of this.scenes){const{element:r}=n;r[is](r.getBoundingClientRect())}let s=0,i=0;for(const n of this.scenes)s=Math.max(s,n.width),i=Math.max(i,n.height);if(!(s===this.width&&i===this.height&&t===this.dpr)){this.width=s,this.height=i,this.dpr=t,s=Math.ceil(s*t),i=Math.ceil(i*t),this.canRender&&this.threeRenderer.setSize(s,i,!1);for(const n of this.scenes){const{canvas:r}=n;r.width=s,r.height=i,n.forceRescale(),(e=n.effectRenderer)===null||e===void 0||e.setSize(s,i)}}}updateRendererScale(e){const t=this.scaleStep;this.avgFrameDuration+=ke(df*(e-this.avgFrameDuration),-FA,FA),this.avgFrameDuration>Ir?++this.scaleStep:this.avgFrameDuration<mr&&this.scaleStep>0&&--this.scaleStep,this.scaleStep=Math.min(this.scaleStep,this.lastStep),t!==this.scaleStep&&(this.avgFrameDuration=(Ir+mr)/2)}shouldRender(e){if(e.shouldRender())e.scaleStep!=this.scaleStep&&(e.scaleStep=this.scaleStep,this.rescaleCanvas(e));else if(e.scaleStep!=0)e.scaleStep=0,this.rescaleCanvas(e);else return!1;return!0}rescaleCanvas(e){const t=zt[e.scaleStep],s=Math.ceil(this.width/t),i=Math.ceil(this.height/t),{style:n}=e.canvas;n.width=`${s}px`,n.height=`${i}px`,this.canvas3D.style.width=`${s}px`,this.canvas3D.style.height=`${i}px`;const r=this.dpr*t,a=t<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";e.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:r,minimumDpr:this.dpr*zt[this.lastStep],pixelWidth:Math.ceil(e.width*r),pixelHeight:Math.ceil(e.height*r),reason:a}}))}sceneSize(e){const{dpr:t}=this,s=zt[e.scaleStep],i=Math.min(Math.ceil(e.width*s*t),this.canvas3D.width),n=Math.min(Math.ceil(e.height*s*t),this.canvas3D.height);return{width:i,height:n}}copyPixels(e,t,s){const i=e.context;if(i==null){console.log("could not acquire 2d context");return}i.clearRect(0,0,t,s),i.drawImage(this.canvas3D,0,0,t,s,0,0,t,s),e.canvas.classList.add("show")}orderedScenes(){const e=[];for(const t of[!1,!0])for(const s of this.scenes)s.element.modelIsVisible===t&&e.push(s);return e}get isPresenting(){return this.arRenderer.isPresenting}preRender(e,t,s){const{element:i,exposure:n,toneMapping:r}=e;i[qe](t,s);const a=typeof n=="number"&&!Number.isNaN(n),A=i.environmentImage,l=i.skyboxImage,c=r===Wl&&(A==="neutral"||A==="legacy"||!A&&!l);this.threeRenderer.toneMappingExposure=(a?n:1)*(c?pf:1)}render(e,t){if(t!=null){this.arRenderer.onWebXRFrame(e,t);return}const s=e-this.lastTick;if(this.lastTick=e,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(s),this.renderedLastFrame=!1);const{canvas3D:i}=this;for(const n of this.orderedScenes()){const{element:r}=n;if(!r.loaded||!r.modelIsVisible&&n.renderCount>0||(this.preRender(n,e,s),!this.shouldRender(n)))continue;if(n.externalRenderer!=null){const l=n.getCamera();l.updateMatrix();const{matrix:c,projectionMatrix:h}=l,d=c.elements.slice(),u=n.getTarget();d[12]+=u.x,d[13]+=u.y,d[14]+=u.z,n.externalRenderer.render({viewMatrix:d,projectionMatrix:h.elements});continue}if(!r.modelIsVisible&&!this.multipleScenesVisible)for(const l of this.scenes)l.element.modelIsVisible&&l.queueRender();const{width:a,height:A}=this.sceneSize(n);n.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-A,a,A),n.effectRenderer!=null?n.effectRenderer.render(s):(this.threeRenderer.autoClear=!0,this.threeRenderer.toneMapping=n.toneMapping,this.threeRenderer.render(n,n.camera)),this.multipleScenesVisible||!n.element.modelIsVisible&&n.renderCount===0?this.copyPixels(n,a,A):i.parentElement!==n.canvas.parentElement&&(n.canvas.parentElement.appendChild(i),n.canvas.classList.remove("show")),n.hasRendered(),++n.renderCount,this.renderedLastFrame=!0}}dispose(){this.textureUtils!=null&&this.textureUtils.dispose(),this.threeRenderer!=null&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const e=[];for(const t of this.scenes)e.push(t.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),e}}Re._singleton=new Re({powerPreference:(self.ModelViewerElement||{}).powerPreference||hh,debug:wc()});/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const G=Symbol("correlatedObjects"),q=Symbol("onUpdate");class ci{constructor(e,t=null){this[q]=e,this[G]=t}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const NA=new Ue,ff=new Is(2,2);let mf=0;const de=Symbol("threeTexture"),kA=Symbol("threeTextures");let If=class extends ci{get[de](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get[kA](){return this[G]}constructor(e,t){super(e,new Set(t?[t]:[])),this[de].image.src||(this[de].image.src=t.name?t.name:"adhoc_image"+mf++),this[de].image.name||(this[de].image.name=t&&t.image&&t.image.src?t.image.src.split("/").pop():"adhoc_image")}get name(){return this[de].image.name||""}get uri(){return this[de].image.src}get bufferView(){return this[de].image.bufferView}get element(){const e=this[de];if(e&&(e.isCanvasTexture||e.isVideoTexture))return e.image}get animation(){const e=this[de];if(e&&e.isCanvasTexture&&e.animation)return e.animation}get type(){return this.uri!=null?"external":"embedded"}set name(e){for(const t of this[kA])t.image.name=e}update(){const e=this[de];e&&e.isCanvasTexture&&!e.animation&&(this[de].needsUpdate=!0,this[q]())}async createThumbnail(e,t){const s=new It;NA.map=this[de];const i=new pe(ff,NA);s.add(i);const n=new mn(-1,1,1,-1,0,1),{threeRenderer:r}=Re.singleton,a=new si(e,t);r.setRenderTarget(a),r.render(s,n),r.setRenderTarget(null);const A=new Uint8Array(e*t*4);r.readRenderTargetPixels(a,0,0,e,t,A),gt.width=e,gt.height=t;const l=gt.getContext("2d"),c=l.createImageData(e,t);return c.data.set(A),l.putImageData(c,0,0),new Promise(async(h,d)=>{gt.toBlob(u=>{if(!u)return d("Failed to capture thumbnail.");h(URL.createObjectURL(u))},"image/png")})}};var ne;(function(o){o[o.Nearest=9728]="Nearest",o[o.Linear=9729]="Linear",o[o.NearestMipmapNearest=9984]="NearestMipmapNearest",o[o.LinearMipmapNearest=9985]="LinearMipmapNearest",o[o.NearestMipmapLinear=9986]="NearestMipmapLinear",o[o.LinearMipmapLinear=9987]="LinearMipmapLinear"})(ne||(ne={}));var ft;(function(o){o[o.ClampToEdge=33071]="ClampToEdge",o[o.MirroredRepeat=33648]="MirroredRepeat",o[o.Repeat=10497]="Repeat"})(ft||(ft={}));/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const UA=new Map([[ft.Repeat,mt],[ft.ClampToEdge,Me],[ft.MirroredRepeat,yn]]),po=new Map([[mt,ft.Repeat],[Me,ft.ClampToEdge],[yn,ft.MirroredRepeat]]),Ef=new Map([[ne.Nearest,ms],[ne.Linear,ae],[ne.NearestMipmapNearest,En],[ne.LinearMipmapNearest,Cn],[ne.NearestMipmapLinear,Bn],[ne.LinearMipmapLinear,fs]]),uh=new Map([[ms,ne.Nearest],[ae,ne.Linear],[En,ne.NearestMipmapNearest],[Cn,ne.LinearMipmapNearest],[Bn,ne.NearestMipmapLinear],[fs,ne.LinearMipmapLinear]]),Cf=new Map([[ne.Nearest,ms],[ne.Linear,ae]]),dh=new Map([[ms,ne.Nearest],[ae,ne.Linear]]),Bf=o=>uh.has(o),yf=o=>dh.has(o),wf=o=>po.has(o),Qf=(o,e)=>{switch(o){case"minFilter":return Bf(e);case"magFilter":return yf(e);case"wrapS":case"wrapT":return wf(e);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${o}" on Sampler`)}},Je=Symbol("threeTexture"),GA=Symbol("threeTextures"),ot=Symbol("setProperty");class vf extends ci{get[Je](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get[GA](){return this[G]}constructor(e,t){super(e,new Set(t?[t]:[]))}get name(){return this[Je].name||""}get minFilter(){return uh.get(this[Je].minFilter)}get magFilter(){return dh.get(this[Je].magFilter)}get wrapS(){return po.get(this[Je].wrapS)}get wrapT(){return po.get(this[Je].wrapT)}get rotation(){return this[Je].rotation}get scale(){return yo(this[Je].repeat)}get offset(){return yo(this[Je].offset)}setMinFilter(e){this[ot]("minFilter",Ef.get(e))}setMagFilter(e){this[ot]("magFilter",Cf.get(e))}setWrapS(e){this[ot]("wrapS",UA.get(e))}setWrapT(e){this[ot]("wrapT",UA.get(e))}setRotation(e){e==null&&(e=0),this[ot]("rotation",e)}setScale(e){e==null&&(e={u:1,v:1}),this[ot]("repeat",new De(e.u,e.v))}setOffset(e){e==null&&(e={u:0,v:0}),this[ot]("offset",new De(e.u,e.v))}[ot](e,t){if(Qf(e,t))for(const s of this[GA])s[e]=t,s.needsUpdate=!0;this[q]()}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const OA=Symbol("image"),PA=Symbol("sampler"),HA=Symbol("threeTexture");class gh extends ci{constructor(e,t){super(e,new Set(t?[t]:[])),this[PA]=new vf(e,t),this[OA]=new If(e,t)}get[HA](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get name(){return this[HA].name||""}set name(e){for(const t of this[G])t.name=e}get sampler(){return this[PA]}get source(){return this[OA]}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var ph,fh,mh;const bt=Symbol("texture"),Tt=Symbol("transform"),Er=Symbol("materials"),$A=Symbol("usage"),Yt=Symbol("onUpdate"),zs=Symbol("activeVideo");var L;(function(o){o[o.Base=0]="Base",o[o.MetallicRoughness=1]="MetallicRoughness",o[o.Normal=2]="Normal",o[o.Occlusion=3]="Occlusion",o[o.Emissive=4]="Emissive",o[o.Clearcoat=5]="Clearcoat",o[o.ClearcoatRoughness=6]="ClearcoatRoughness",o[o.ClearcoatNormal=7]="ClearcoatNormal",o[o.SheenColor=8]="SheenColor",o[o.SheenRoughness=9]="SheenRoughness",o[o.Transmission=10]="Transmission",o[o.Thickness=11]="Thickness",o[o.Specular=12]="Specular",o[o.SpecularColor=13]="SpecularColor",o[o.Iridescence=14]="Iridescence",o[o.IridescenceThickness=15]="IridescenceThickness",o[o.Anisotropy=16]="Anisotropy"})(L||(L={}));class os{constructor(e,t,s,i){this[ph]=null,this[fh]={rotation:0,scale:new De(1,1),offset:new De(0,0)},this[mh]=!1,s&&(this[Tt].rotation=s.rotation,this[Tt].scale.copy(s.repeat),this[Tt].offset.copy(s.offset),this[bt]=new gh(e,s)),this[Yt]=e,this[Er]=i,this[$A]=t}get texture(){return this[bt]}setTexture(e){var t,s;const i=e!=null?e.source[de]:null,n=(t=this[bt])===null||t===void 0?void 0:t.source[de];if(n!=null&&n.isVideoTexture?this[zs]=!1:!((s=this[bt])===null||s===void 0)&&s.source.animation&&this[bt].source.animation.removeEventListener("enterFrame",this[Yt]),this[bt]=e,i!=null&&i.isVideoTexture){const a=i.image;if(this[zs]=!0,a.requestVideoFrameCallback!=null){const A=()=>{this[zs]&&(this[Yt](),a.requestVideoFrameCallback(A))};a.requestVideoFrameCallback(A)}else{const A=()=>{this[zs]&&(this[Yt](),requestAnimationFrame(A))};requestAnimationFrame(A)}}else(e==null?void 0:e.source.animation)!=null&&e.source.animation.addEventListener("enterFrame",this[Yt]);let r=Ee;if(this[Er])for(const a of this[Er]){switch(this[$A]){case L.Base:a.map=i;break;case L.MetallicRoughness:r=ee,a.metalnessMap=i,a.roughnessMap=i;break;case L.Normal:r=ee,a.normalMap=i;break;case L.Occlusion:r=ee,a.aoMap=i;break;case L.Emissive:a.emissiveMap=i;break;case L.Clearcoat:a.clearcoatMap=i;break;case L.ClearcoatRoughness:a.clearcoatRoughnessMap=i;break;case L.ClearcoatNormal:a.clearcoatNormalMap=i;break;case L.SheenColor:a.sheenColorMap=i;break;case L.SheenRoughness:a.sheenRoughnessMap=i;break;case L.Transmission:a.transmissionMap=i;break;case L.Thickness:a.thicknessMap=i;break;case L.Specular:a.specularIntensityMap=i;break;case L.SpecularColor:a.specularColorMap=i;break;case L.Iridescence:a.iridescenceMap=i;break;case L.IridescenceThickness:a.iridescenceThicknessMap=i;break;case L.Anisotropy:a.anisotropyMap=i;break}a.needsUpdate=!0}i&&(i.colorSpace=r,i.rotation=this[Tt].rotation,i.repeat=this[Tt].scale,i.offset=this[Tt].offset),this[Yt]()}}ph=bt,fh=Tt,mh=zs;/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ds=Symbol("threeMaterial"),Mi=Symbol("threeMaterials"),VA=Symbol("baseColorTexture"),qA=Symbol("metallicRoughnessTexture");class Sf extends ci{constructor(e,t){super(e,t);const{map:s,metalnessMap:i}=t.values().next().value;this[VA]=new os(e,L.Base,s,t),this[qA]=new os(e,L.MetallicRoughness,i,t)}get[Mi](){return this[G]}get[Ds](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get baseColorFactor(){const e=[0,0,0,this[Ds].opacity];return this[Ds].color.toArray(e),e}get metallicFactor(){return this[Ds].metalness}get roughnessFactor(){return this[Ds].roughness}get baseColorTexture(){return this[VA]}get metallicRoughnessTexture(){return this[qA]}setBaseColorFactor(e){const t=new Le;e instanceof Array?t.fromArray(e):t.set(e);for(const s of this[Mi])s.color.set(t),e instanceof Array?s.opacity=e[3]:(e=[0,0,0,s.opacity],t.toArray(e));this[q]()}setMetallicFactor(e){for(const t of this[Mi])t.metalness=e;this[q]()}setRoughnessFactor(e){for(const t of this[Mi])t.roughness=e;this[q]()}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var KA,zA;const YA=Symbol("pbrMetallicRoughness"),JA=Symbol("normalTexture"),jA=Symbol("occlusionTexture"),WA=Symbol("emissiveTexture"),J=Symbol("backingThreeMaterial"),XA=Symbol("applyAlphaCutoff"),Cr=Symbol("getAlphaMode"),Jt=Symbol("lazyLoadGLTFInfo"),Br=Symbol("initialize"),fo=Symbol("getLoadedMaterial"),b=Symbol("ensureMaterialIsLoaded"),ZA=Symbol("gltfIndex"),Ys=Symbol("setActive"),Wi=Symbol("variantIndices"),yr=Symbol("isActive"),Xi=Symbol("variantSet"),el=Symbol("modelVariants"),wr=Symbol("name"),me=Symbol("pbrTextures");class Qr extends ci{constructor(e,t,s,i,n,r,a=void 0){super(e,n),this[KA]=new Set,this[zA]=new Map,this[ZA]=t,this[yr]=s,this[el]=i,this[wr]=r,a==null?this[Br]():this[Jt]=a}get[(KA=Xi,zA=me,J)](){return this[G].values().next().value}[Br](){const e=this[q],t=this[G];this[YA]=new Sf(e,t);const{normalMap:s,aoMap:i,emissiveMap:n}=t.values().next().value;this[JA]=new os(e,L.Normal,s,t),this[jA]=new os(e,L.Occlusion,i,t),this[WA]=new os(e,L.Emissive,n,t);const r=a=>{this[me].set(a,new os(e,a,null,t))};r(L.Clearcoat),r(L.ClearcoatRoughness),r(L.ClearcoatNormal),r(L.SheenColor),r(L.SheenRoughness),r(L.Transmission),r(L.Thickness),r(L.Specular),r(L.SpecularColor),r(L.Iridescence),r(L.IridescenceThickness),r(L.Anisotropy)}async[fo](){if(this[Jt]!=null){const{set:e,material:t}=await this[Jt].doLazyLoad();return this[G]=e,this[Br](),this[Jt]=void 0,this.ensureLoaded=async()=>{},t}return this[G].values().next().value}colorFromRgb(e){const t=new Le;return e instanceof Array?t.fromArray(e):t.set(e),t}[b](){if(this[Jt]!=null)throw new Error(`Material "${this.name}" has not been loaded, call 'await
    myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[fo]()}get isLoaded(){return this[Jt]==null}get isActive(){return this[yr]}[Ys](e){this[yr]=e}get name(){return this[wr]||""}set name(e){if(this[wr]=e,this[G]!=null)for(const t of this[G])t.name=e}get pbrMetallicRoughness(){return this[b](),this[YA]}get normalTexture(){return this[b](),this[JA]}get occlusionTexture(){return this[b](),this[jA]}get emissiveTexture(){return this[b](),this[WA]}get emissiveFactor(){return this[b](),this[J].emissive.toArray()}get index(){return this[ZA]}[Wi](){return this[Xi]}hasVariant(e){const t=this[el].get(e);return t!=null&&this[Xi].has(t.index)}setEmissiveFactor(e){this[b]();const t=this.colorFromRgb(e);for(const s of this[G])s.emissive.set(t);this[q]()}[Cr](){return this[J].transparent?"BLEND":this[J].alphaTest>0?"MASK":"OPAQUE"}[XA](){this[b]();for(const e of this[G])this[Cr]()==="MASK"?e.alphaTest==null&&(e.alphaTest=.5):e.alphaTest=void 0,e.needsUpdate=!0}setAlphaCutoff(e){this[b]();for(const t of this[G])t.alphaTest=e,t.needsUpdate=!0;this[XA](),this[q]()}getAlphaCutoff(){return this[b](),this[J].alphaTest}setDoubleSided(e){this[b]();for(const t of this[G])t.side=e?Ft:Mo,t.needsUpdate=!0;this[q]()}getDoubleSided(){return this[b](),this[J].side==Ft}setAlphaMode(e){this[b]();const t=(s,i)=>{s.transparent=i,s.depthWrite=!i};for(const s of this[G])t(s,e==="BLEND"),e==="MASK"?s.alphaTest=.5:s.alphaTest=void 0,s.needsUpdate=!0;this[q]()}getAlphaMode(){return this[b](),this[Cr]()}get emissiveStrength(){return this[b](),this[J].emissiveIntensity}setEmissiveStrength(e){this[b]();for(const t of this[G])t.emissiveIntensity=e;this[q]()}get clearcoatFactor(){return this[b](),this[J].clearcoat}get clearcoatRoughnessFactor(){return this[b](),this[J].clearcoatRoughness}get clearcoatTexture(){return this[b](),this[me].get(L.Clearcoat)}get clearcoatRoughnessTexture(){return this[b](),this[me].get(L.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[b](),this[me].get(L.ClearcoatNormal)}get clearcoatNormalScale(){return this[b](),this[J].clearcoatNormalScale.x}setClearcoatFactor(e){this[b]();for(const t of this[G])t.clearcoat=e;this[q]()}setClearcoatRoughnessFactor(e){this[b]();for(const t of this[G])t.clearcoatRoughness=e;this[q]()}setClearcoatNormalScale(e){this[b]();for(const t of this[G])t.clearcoatNormalScale=new De(e,e);this[q]()}get ior(){return this[b](),this[J].ior}setIor(e){this[b]();for(const t of this[G])t.ior=e;this[q]()}get sheenColorFactor(){return this[b](),this[J].sheenColor.toArray()}get sheenColorTexture(){return this[b](),this[me].get(L.SheenColor)}get sheenRoughnessFactor(){return this[b](),this[J].sheenRoughness}get sheenRoughnessTexture(){return this[b](),this[me].get(L.SheenRoughness)}setSheenColorFactor(e){this[b]();const t=this.colorFromRgb(e);for(const s of this[G])s.sheenColor.set(t),s.sheen=1;this[q]()}setSheenRoughnessFactor(e){this[b]();for(const t of this[G])t.sheenRoughness=e,t.sheen=1;this[q]()}get transmissionFactor(){return this[b](),this[J].transmission}get transmissionTexture(){return this[b](),this[me].get(L.Transmission)}setTransmissionFactor(e){this[b]();for(const t of this[G])t.transmission=e;this[q]()}get thicknessFactor(){return this[b](),this[J].thickness}get thicknessTexture(){return this[b](),this[me].get(L.Thickness)}get attenuationDistance(){return this[b](),this[J].attenuationDistance}get attenuationColor(){return this[b](),this[J].attenuationColor.toArray()}setThicknessFactor(e){this[b]();for(const t of this[G])t.thickness=e;this[q]()}setAttenuationDistance(e){this[b]();for(const t of this[G])t.attenuationDistance=e;this[q]()}setAttenuationColor(e){this[b]();const t=this.colorFromRgb(e);for(const s of this[G])s.attenuationColor.set(t);this[q]()}get specularFactor(){return this[b](),this[J].specularIntensity}get specularTexture(){return this[b](),this[me].get(L.Specular)}get specularColorFactor(){return this[b](),this[J].specularColor.toArray()}get specularColorTexture(){return this[b](),this[me].get(L.SheenColor)}setSpecularFactor(e){this[b]();for(const t of this[G])t.specularIntensity=e;this[q]()}setSpecularColorFactor(e){this[b]();const t=this.colorFromRgb(e);for(const s of this[G])s.specularColor.set(t);this[q]()}get iridescenceFactor(){return this[b](),this[J].iridescence}get iridescenceTexture(){return this[b](),this[me].get(L.Iridescence)}get iridescenceIor(){return this[b](),this[J].iridescenceIOR}get iridescenceThicknessMinimum(){return this[b](),this[J].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[b](),this[J].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[b](),this[me].get(L.IridescenceThickness)}setIridescenceFactor(e){this[b]();for(const t of this[G])t.iridescence=e;this[q]()}setIridescenceIor(e){this[b]();for(const t of this[G])t.iridescenceIOR=e;this[q]()}setIridescenceThicknessMinimum(e){this[b]();for(const t of this[G])t.iridescenceThicknessRange[0]=e;this[q]()}setIridescenceThicknessMaximum(e){this[b]();for(const t of this[G])t.iridescenceThicknessRange[1]=e;this[q]()}get anisotropyStrength(){return this[b](),this[J].anisotropy}get anisotropyRotation(){return this[b](),this[J].anisotropyRotation}get anisotropyTexture(){return this[b](),this[me].get(L.Anisotropy)}setAnisotropyStrength(e){this[b]();for(const t of this[G])t.anisotropy=e;this[q]()}setAnisotropyRotation(e){this[b]();for(const t of this[G])t.anisotropyRotation=e;this[q]()}}let Ih=class{constructor(e){this.name="",this.children=new Array,this.name=e}};class vr extends Ih{constructor(e,t,s,i){super(e.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=e;const{gltf:n,threeGLTF:r,threeObjectMap:a}=i;this.parser=r.parser,this.modelVariants=s,this.mesh.userData.variantData=s;const A=a.get(e.material);A.materials!=null?this.initialMaterialIdx=this.activeMaterialIdx=A.materials:console.error(`Primitive (${e.name}) missing initial material reference.`);const l=e.userData.associations||{};if(l.meshes==null){console.error("Mesh is missing primitive index association");return}const d=((n.meshes||[])[l.meshes].primitives||[])[l.primitives];if(d==null){console.error("Mesh primitive definition is missing.");return}if(d.material!=null)this.materials.set(d.material,t[d.material]);else{const u=t.findIndex(g=>g.name==="Default");u>=0?this.materials.set(u,t[u]):console.warn("gltfPrimitive has no material!")}if(d.extensions&&d.extensions.KHR_materials_variants){const u=d.extensions.KHR_materials_variants,p=r.parser.json.extensions.KHR_materials_variants.variants;for(const f of u.mappings){const I=t[f.material];this.materials.set(f.material,I);for(const C of f.variants){const{name:w}=p[C];this.variantToMaterialMap.set(C,I),I[Wi]().add(C),s.has(w)||s.set(w,{name:w,index:C})}}}}async setActiveMaterial(e){const t=this.materials.get(e);if(t!=null&&e!==this.activeMaterialIdx){this.mesh.material=await t[fo]();const{normalScale:s}=this.mesh.material;s!=null&&s.y*s.x<0!=(this.mesh.geometry.attributes.tangent==null)&&this.parser.assignFinalMaterial(this.mesh),this.activeMaterialIdx=e}return this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(e){return this.materials.get(e)}async enableVariant(e){if(e==null)return this.setActiveMaterial(this.initialMaterialIdx);if(this.variantToMaterialMap!=null&&this.modelVariants.has(e)){const t=this.modelVariants.get(e);return this.enableVariantHelper(t.index)}return null}async enableVariantHelper(e){if(this.variantToMaterialMap!=null&&e!=null){const t=this.variantToMaterialMap.get(e);if(t!=null)return this.setActiveMaterial(t.index)}return null}async instantiateVariants(){if(this.variantToMaterialMap!=null)for(const e of this.variantToMaterialMap.keys()){const t=this.mesh.userData.variantMaterials.get(e);if(t.material!=null)continue;const s=await this.enableVariantHelper(e);s!=null&&(t.material=s)}}get variantInfo(){return this.variantToMaterialMap}addVariant(e,t){if(!this.ensureVariantIsUnused(t))return!1;this.modelVariants.has(t)||this.modelVariants.set(t,{name:t,index:this.modelVariants.size});const i=this.modelVariants.get(t).index;return e[Wi]().add(i),this.variantToMaterialMap.set(i,e),this.materials.set(e.index,e),this.updateVariantUserData(i,e),!0}deleteVariant(e){if(this.variantInfo.has(e)){this.variantInfo.delete(e);const t=this.mesh.userData.variantMaterials;t!=null&&t.delete(e)}}updateVariantUserData(e,t){t[Wi]().add(e),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map,this.mesh.userData.variantMaterials.set(e,{material:t[G].values().next().value,gltfMaterialIndex:t.index})}ensureVariantIsUnused(e){const t=this.modelVariants.get(e);return t!=null&&this.variantInfo.has(t.index)?(console.warn(`Primitive cannot add variant '${e}' for this material, it already exists.`),!1):!0}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var tl,sl,il,nl,rl,ol;const vt=Symbol("materials"),Ri=Symbol("hierarchy"),al=Symbol("roots"),je=Symbol("primitives"),Eh=Symbol("prepareVariantsForExport"),Ch=Symbol("switchVariant"),Bh=Symbol("materialFromPoint"),mo=Symbol("nodeFromPoint"),yh=Symbol("nodeFromIndex"),Ae=Symbol("variantData"),Io=Symbol("availableVariants"),Sr=Symbol("modelOnUpdate"),Al=Symbol("cloneMaterial");class xf{constructor(e,t,s,i){this.gltf=e,this.gltfElementMap=t,this.mapKey=s,this.doLazyLoad=i}}class bf{constructor(e,t=()=>{}){this[tl]=new Array,this[sl]=new Array,this[il]=new Array,this[nl]=new Array,this[rl]=()=>{},this[ol]=new Map,this[Sr]=t;const{gltf:s,threeGLTF:i,gltfElementMap:n}=e;for(const[A,l]of s.materials.entries()){const c=n.get(l);if(c!=null)this[vt].push(new Qr(t,A,!0,this[Ae],c,l.name));else{const d=(s.materials||[])[A],u=A,g=async()=>{const p=await i.parser.getDependency("material",u),f=new Set;return n.set(d,f),f.add(p),{set:f,material:p}};this[vt].push(new Qr(t,A,!1,this[Ae],c,l.name,new xf(s,n,d,g)))}}const r=new Map,a=new Array;for(const A of i.scene.children)a.push(A);for(;a.length>0;){const A=a.pop();let l=null;A instanceof pe?(l=new vr(A,this.materials,this[Ae],e),this[je].push(l)):l=new Ih(A.name);const c=r.get(A);c!=null?c.children.push(l):this[al].push(l),this[Ri].push(l);for(const h of A.children)a.push(h),r.set(A,l)}}get materials(){return this[vt]}[(tl=vt,sl=Ri,il=al,nl=je,rl=Sr,ol=Ae,Io)](){const e=Array.from(this[Ae].values());return e.sort((t,s)=>t.index-s.index),e.map(t=>t.name)}getMaterialByName(e){const t=this[vt].filter(s=>s.name===e);return t.length>0?t[0]:null}[yh](e,t){const s=this[Ri].find(i=>{if(i instanceof vr){const{meshes:n,primitives:r}=i.mesh.userData.associations;if(n==e&&r==t)return!0}return!1});return s??null}[mo](e){return this[Ri].find(t=>t instanceof vr&&t.mesh===e.object)}[Bh](e){return this[mo](e).getActiveMaterial()}async[Ch](e){for(const t of this[je])await t.enableVariant(e);for(const t of this.materials)t[Ys](!1);for(const t of this[je])this.materials[t.getActiveMaterial().index][Ys](!0)}async[Eh](){const e=new Array;for(const t of this[je])e.push(t.instantiateVariants());await Promise.all(e)}[Al](e,t){const s=this.materials[e];s.isLoaded||console.error(`Cloning an unloaded material,
           call 'material.ensureLoaded() before cloning the material.`);const i=s[G],n=new Set;for(const[a,A]of i.entries()){const l=A.clone();l.name=t+(i.size>1?"_inst"+a:""),n.add(l)}const r=new Qr(this[Sr],this[vt].length,!1,this[Ae],n,t);return this[vt].push(r),r}createMaterialInstanceForVariant(e,t,s,i=!0){let n=null;for(const r of this[je]){const a=this[Ae].get(s);a!=null&&r.variantInfo.has(a.index)||r.getMaterial(e)!=null&&(this.hasVariant(s)||this.createVariant(s),n==null&&(n=this[Al](e,t)),r.addVariant(n,s))}if(i&&n!=null){n[Ys](!0),this.materials[e][Ys](!1);for(const r of this[je])r.enableVariant(s)}return n}createVariant(e){this[Ae].has(e)?console.warn(`Variant '${e}'' already exists`):this[Ae].set(e,{name:e,index:this[Ae].size})}hasVariant(e){return this[Ae].has(e)}setMaterialToVariant(e,t){if(this[Io]().find(s=>s===t)==null){console.warn(`Can't add material to '${t}', the variant does not exist.'`);return}if(e<0||e>=this.materials.length){console.error("setMaterialToVariant(): materialIndex is out of bounds.");return}for(const s of this[je]){const i=s.getMaterial(e);i!=null&&s.addVariant(i,t)}}updateVariantName(e,t){const s=this[Ae].get(e);s!=null&&(s.name=t,this[Ae].set(t,s),this[Ae].delete(e))}deleteVariant(e){const t=this[Ae].get(e);if(t!=null){for(const s of this.materials)s.hasVariant(e)&&s[Xi].delete(t.index);for(const s of this[je])s.deleteVariant(t.index);this[Ae].delete(e)}}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var xr=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const Zi=Symbol("currentGLTF"),en=Symbol("originalGltfJson"),Mt=Symbol("model"),br=Symbol("getOnUpdateMethod"),_s=Symbol("buildTexture"),Tf=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this[e]=void 0,this[t]=null,this[s]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[Mt]}get availableVariants(){return this.model?this.model[Io]():[]}get originalGltfJson(){return this[en]}[(e=Mt,t=Zi,s=en,br)](){return()=>{this[ce]()}}[_s](r){return r.colorSpace=Ee,r.wrapS=mt,r.wrapT=mt,new gh(this[br](),r)}async createTexture(r,a="image/png"){const{textureUtils:A}=this[V],l=await A.loadImage(r);return l.userData.mimeType=a,this[_s](l)}async createLottieTexture(r,a=1){const{textureUtils:A}=this[V],l=await A.loadLottie(r,a);return this[_s](l)}createVideoTexture(r){const a=document.createElement("video");a.crossOrigin=this.withCredentials?"use-credentials":"anonymous",a.src=r,a.muted=!0,a.playsInline=!0,a.loop=!0,a.play();const A=new Fu(a);return this[_s](A)}createCanvasTexture(){const r=document.createElement("canvas"),a=new nc(r);return this[_s](a)}async updated(r){if(super.updated(r),r.has("variantName")){const a=this[kt].beginActivity("variant-update");a(.1);const A=this[Mt],{variantName:l}=this;A!=null&&(await A[Ch](l),this[ce](),this.dispatchEvent(new CustomEvent("variant-applied"))),a(1)}if(r.has("orientation")||r.has("scale")){if(!this.loaded)return;const a=this[v];a.applyTransform(),a.updateBoundingBox(),a.updateShadow(),this[V].arRenderer.onUpdateScene(),this[ce]()}}[Ct](){super[Ct]();const{currentGLTF:r}=this[v];if(r!=null){const{correlatedSceneGraph:a}=r;a!=null&&r!==this[Zi]&&(this[Mt]=new bf(a,this[br]()),this[en]=JSON.parse(JSON.stringify(a.gltf))),"variants"in r.userData&&this.requestUpdate("variantName")}this[Zi]=r}async exportScene(r){const a=this[v];return new Promise(async(A,l)=>{const c={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(c,r),c.animations=a.animations,c.truncateDrawRange=!0;const h=a.shadow;let d=!1;h!=null&&(d=h.visible,h.visible=!1),await this[Mt][Eh](),new No().register(g=>new jg(g)).parse(a.model,g=>A(new Blob([c.binary?g:JSON.stringify(g)],{type:c.binary?"application/octet-stream":"application/json"})),()=>l("glTF export failed"),c),h!=null&&(h.visible=d)})}materialFromPoint(r,a){const A=this[Mt];if(A==null)return null;const l=this[v],c=l.getNDC(r,a),h=l.hitFromPoint(c);return h==null||h.face==null?null:A[Bh](h)}}return xr([F({type:String,attribute:"variant-name"})],i.prototype,"variantName",void 0),xr([F({type:String,attribute:"orientation"})],i.prototype,"orientation",void 0),xr([F({type:String,attribute:"scale"})],i.prototype,"scale",void 0),i};/* @license
 * Copyright 2023 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Mf extends pe{constructor(){super(void 0,new Ue({depthWrite:!1})),this.height=0,this.radius=0,this.resolution=0,this.userData.noHit=!0}get map(){return this.material.map}set map(e){this.material.map=e}isUsable(){return this.height>0&&this.radius>0&&this.geometry!=null&&this.map!=null}updateGeometry(e=this.height,t=this.radius,s=128){(e!=this.height||t!=this.radius||s!=this.resolution)&&(this.height=e,this.radius=t,this.resolution=s,e>0&&t>0&&(this.geometry.dispose(),this.geometry=Rf(e,t,s)))}}function Rf(o,e,t){const s=new Nu(e,2*t,t);s.scale(1,1,-1);const i=s.getAttribute("position"),n=new N;for(let r=0;r<i.count;++r)if(n.fromBufferAttribute(i,r),n.y<0){const a=-o*3/2,A=n.y<a?-o/n.y:1-n.y*n.y/(3*a*a);n.multiplyScalar(A),n.toArray(i.array,3*r)}return i.needsUpdate=!0,s}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Di=new N,Tr=new N,Mr=new N,_i=new _o,ll=new lc,cl=new In;class as extends Sg{constructor(e){super(document.createElement("div")),this.normal=new N(0,1,0),this.initialized=!1,this.referenceCount=1,this.pivot=document.createElement("div"),this.slot=document.createElement("slot"),this.element.classList.add("annotation-wrapper"),this.slot.name=e.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(e.position),this.updateNormal(e.normal),this.surface=e.surface}get facingCamera(){return!this.element.classList.contains("hide")}show(){(!this.facingCamera||!this.initialized)&&this.updateVisibility(!0)}hide(){(this.facingCamera||!this.initialized)&&this.updateVisibility(!1)}increment(){this.referenceCount++}decrement(){return this.referenceCount>0&&--this.referenceCount,this.referenceCount===0}updatePosition(e){if(e==null)return;const t=tt(e)[0].terms;for(let s=0;s<3;++s)this.position.setComponent(s,Pe(t[s]).number);this.updateMatrixWorld()}updateNormal(e){if(e==null)return;const t=tt(e)[0].terms;for(let s=0;s<3;++s)this.normal.setComponent(s,t[s].number)}updateSurface(e){if(!e&&this.initialized)return;const{mesh:t,tri:s,bary:i}=this;if(t==null||s==null||i==null)return;t.getVertexPosition(s.x,Di),t.getVertexPosition(s.y,Tr),t.getVertexPosition(s.z,Mr),Di.toArray(_i.elements,0),Tr.toArray(_i.elements,3),Mr.toArray(_i.elements,6),this.position.copy(i).applyMatrix3(_i);const n=this.parent;n.worldToLocal(t.localToWorld(this.position)),ll.set(Di,Tr,Mr),ll.getNormal(this.normal).transformDirection(t.matrixWorld);const r=n.parent;cl.setFromAxisAngle(Di.set(0,1,0),-r.yaw),this.normal.applyQuaternion(cl)}orient(e){this.pivot.style.transform=`rotate(${e}rad)`}updateVisibility(e){this.element.classList.toggle("hide",!e),this.slot.assignedNodes().forEach(t=>{if(t.nodeType!==Node.ELEMENT_NODE)return;const s=t,i=s.dataset.visibilityAttribute;if(i!=null){const n=`data-${i}`;s.toggleAttribute(n,e)}s.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e}}))}),this.initialized=!0}}const Df={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;
		uniform float h;

		varying vec2 vUv;

		void main() {

			vec4 sum = vec4( 0.0 );

			sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;
			sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
			sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;

			gl_FragColor = sum;

		}`},_f={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;
		uniform float v;

		varying vec2 vUv;

		void main() {

			vec4 sum = vec4( 0.0 );

			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;

			gl_FragColor = sum;

		}`};/* @license
 * Copyright 2022 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const hl=9,Lf=6,Rr=2,Ff=.3;class Nf extends Ai{constructor(e,t,s){super(),this.camera=new mn,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new ku,this.horizontalBlurMaterial=new cs(Df),this.verticalBlurMaterial=new cs(_f),this.intensity=0,this.softness=1,this.boundingBox=new Dt,this.size=new N,this.maxDimension=0,this.isAnimated=!1,this.needsUpdate=!1;const{camera:i}=this;i.rotation.x=Math.PI/2,i.left=-.5,i.right=.5,i.bottom=-.5,i.top=.5,this.add(i);const n=new Is,r=new Ue({opacity:1,transparent:!0,side:Lo});this.floor=new pe(n,r),this.floor.userData.noHit=!0,i.add(this.floor),this.blurPlane=new pe(n),this.blurPlane.visible=!1,i.add(this.blurPlane),e.target.add(this),this.depthMaterial.onBeforeCompile=function(a){a.fragmentShader=a.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * opacity );")},this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial.depthTest=!1,this.setScene(e,t,s)}setScene(e,t,s){const{boundingBox:i,size:n,rotation:r,position:a}=this;if(this.isAnimated=e.animationNames.length>0,this.boundingBox.copy(e.boundingBox),this.size.copy(e.size),this.maxDimension=Math.max(n.x,n.y,n.z)*(this.isAnimated?Rr:1),this.boundingBox.getCenter(a),s==="back"){const{min:A,max:l}=i;[A.y,A.z]=[A.z,A.y],[l.y,l.z]=[l.z,l.y],[n.y,n.z]=[n.z,n.y],r.x=Math.PI/2,r.y=Math.PI}else r.x=0,r.y=0;if(this.isAnimated){const A=i.min.y,l=i.max.y;n.y=this.maxDimension,i.expandByVector(n.subScalar(this.maxDimension).multiplyScalar(-.5)),i.min.y=A,i.max.y=l,n.set(this.maxDimension,l-A,this.maxDimension)}s==="bottom"?a.y=i.min.y:a.z=i.min.y,this.setSoftness(t)}setSoftness(e){this.softness=e;const{size:t,camera:s}=this,i=this.isAnimated?Rr:1,n=i*Math.pow(2,hl-e*(hl-Lf));this.setMapSize(n);const r=t.y/2,a=t.y*i;s.near=0,s.far=qo(a,r,e),this.depthMaterial.opacity=1/e,s.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(e){const{size:t}=this;this.isAnimated&&(e*=Rr);const s=Math.floor(t.x>t.z?e:e*t.x/t.z),i=Math.floor(t.x>t.z?e*t.z/t.x:e),n=10,r=n+s,a=n+i;if(this.renderTarget!=null&&(this.renderTarget.width!==r||this.renderTarget.height!==a)&&(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),this.renderTarget==null){const A={format:we};this.renderTarget=new si(r,a,A),this.renderTargetBlur=new si(r,a,A),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(t.x*(1+n/s),t.z*(1+n/i),1),this.needsUpdate=!0}setIntensity(e){this.intensity=e,e>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=e*qo(Ff,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(e){this.floor.position.z=-e+this.gap()}gap(){return .001*this.maxDimension}render(e,t){t.overrideMaterial=this.depthMaterial;const s=e.getClearAlpha();e.setClearAlpha(0),this.floor.visible=!1;const i=e.xr.enabled;e.xr.enabled=!1;const n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.render(t,this.camera),t.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(e),e.xr.enabled=i,e.setRenderTarget(n),e.setClearAlpha(s)}blurShadow(e){const{camera:t,horizontalBlurMaterial:s,verticalBlurMaterial:i,renderTarget:n,renderTargetBlur:r,blurPlane:a}=this;a.visible=!0,a.material=s,s.uniforms.h.value=1/this.renderTarget.width,s.uniforms.tDiffuse.value=this.renderTarget.texture,e.setRenderTarget(r),e.render(a,t),a.material=i,i.uniforms.v.value=1/this.renderTarget.height,i.uniforms.tDiffuse.value=this.renderTargetBlur.texture,e.setRenderTarget(n),e.render(a,t),a.visible=!1}dispose(){this.renderTarget!=null&&this.renderTarget.dispose(),this.renderTargetBlur!=null&&this.renderTargetBlur.dispose(),this.depthMaterial.dispose(),this.horizontalBlurMaterial.dispose(),this.verticalBlurMaterial.dispose(),this.floor.material.dispose(),this.floor.geometry.dispose(),this.blurPlane.geometry.dispose(),this.removeFromParent()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const ul=10,Dr=100,_r=new N,dl=new N,gl=new N,Lr=new Uu,kf=new N,Ls=new De;class Uf extends It{constructor({canvas:e,element:t,width:s,height:i}){super(),this.annotationRenderer=new xg,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.camera=new ti(45,1,.1,100),this.xrCamera=null,this.url=null,this.target=new Ai,this.animationNames=[],this.boundingBox=new Dt,this.boundingSphere=new Ro,this.size=new N,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=xo,this.canScale=!0,this.isDirty=!1,this.goalTarget=new N,this.targetDamperX=new ye,this.targetDamperY=new ye,this.targetDamperZ=new ye,this._currentGLTF=null,this._model=null,this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationAction=null,this.groundedSkybox=new Mf,this.name="ModelScene",this.element=t,this.canvas=e,this.camera=new ti(45,1,.1,100),this.camera.name="MainCamera",this.add(this.target),this.setSize(s,i),this.target.name="Target",this.mixer=new Gu(this.target);const{domElement:n}=this.annotationRenderer,{style:r}=n;r.display="none",r.pointerEvents="none",r.position="absolute",r.top="0",this.element.shadowRoot.querySelector(".default").appendChild(n),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return this.xrCamera!=null?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(e){this.reset(),this._model=e,this.target.add(e),await this.setupScene()}async setSource(e,t=()=>{}){if(!e||e===this.url){t(1);return}if(this.reset(),this.url=e,this.externalRenderer!=null){const a=await this.externalRenderer.load(t);this.boundingSphere.radius=a.framedRadius,this.idealAspect=a.fieldOfViewAspect;return}this.cancelPendingSourceChange!=null&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);let s;try{s=await new Promise(async(a,A)=>{this.cancelPendingSourceChange=()=>A();try{const l=await this.element[V].loader.load(e,this.element,t);a(l)}catch(l){A(l)}})}catch(a){if(a==null)return;throw a}this.cancelPendingSourceChange=null,this.reset(),this.url=e,this._currentGLTF=s,s!=null&&(this._model=s.scene,this.target.add(s.scene));const{animations:i}=s,n=new Map,r=[];for(const a of i)n.set(a.name,a),r.push(a.name);this.animations=i,this.animationsByName=n,this.animationNames=r,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}reset(){this.url=null,this.renderCount=0,this.queueRender(),this.shadow!=null&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_model:e}=this;e!=null&&(e.removeFromParent(),this._model=null);const t=this._currentGLTF;t!=null&&(t.dispose(),this._currentGLTF=null),this.currentAnimationAction!=null&&(this.currentAnimationAction.stop(),this.currentAnimationAction=null),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this)}dispose(){this.reset(),this.shadow!=null&&(this.shadow.dispose(),this.shadow=null),this.element[Zi]=null,this.element[en]=null,this.element[Mt]=null}get currentGLTF(){return this._currentGLTF}setSize(e,t){if(!(this.width===e&&this.height===t)){if(this.width=Math.max(e,1),this.height=Math.max(t,1),this.annotationRenderer.setSize(e,t),this.aspect=this.width/this.height,this.externalRenderer!=null){const s=lo();this.externalRenderer.resize(e*s,t*s)}this.queueRender()}}markBakedShadow(e){e.userData.noHit=!0,this.bakedShadows.add(e)}unmarkBakedShadow(e){e.userData.noHit=!1,e.visible=!0,this.bakedShadows.delete(e),this.boundingBox.expandByObject(e)}findBakedShadows(e){const t=new Dt;e.traverse(s=>{const i=s;if(!i.material||!i.material.transparent)return;t.setFromObject(i);const r=t.getSize(kf),a=Math.min(r.x,r.y,r.z);Math.max(r.x,r.y,r.z)<Dr*a||this.markBakedShadow(i)})}checkBakedShadows(){const{min:e,max:t}=this.boundingBox,s=new Dt;this.boundingBox.getSize(this.size);for(const i of this.bakedShadows)s.setFromObject(i),!(s.min.y<e.y+this.size.y/Dr&&s.min.x<=e.x&&s.max.x>=t.x&&s.min.z<=e.z&&s.max.z>=t.z)&&(s.min.z<e.z+this.size.z/Dr&&s.min.x<=e.x&&s.max.x>=t.x&&s.min.y<=e.y&&s.max.y>=t.y||this.unmarkBakedShadow(i))}applyTransform(){const{model:e}=this;if(e==null)return;const t=tt(this.element.orientation)[0].terms,s=Pe(t[0]).number,i=Pe(t[1]).number,n=Pe(t[2]).number;e.quaternion.setFromEuler(new oc(i,n,s,"YXZ"));const r=tt(this.element.scale)[0].terms;e.scale.set(r[0].number,r[1].number,r[2].number)}updateBoundingBox(){const{model:e}=this;if(e==null)return;this.target.remove(e),this.findBakedShadows(e);const t=(s,i)=>s.expandByPoint(i);this.setBakedShadowVisibility(!1),this.boundingBox=fi(e,t,new Dt),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach(s=>this.unmarkBakedShadow(s)),this.boundingBox=fi(e,t,new Dt)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(e)}async updateFraming(){const{model:e}=this;if(e==null)return;this.target.remove(e),this.setBakedShadowVisibility(!1);const{center:t}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,t.copy(this.getTarget());const s=(n,r)=>Math.max(n,t.distanceToSquared(r));this.boundingSphere.radius=Math.sqrt(fi(e,s,0));const i=(n,r)=>{r.sub(t);const a=Math.sqrt(r.x*r.x+r.z*r.z);return Math.max(n,a/(this.idealCameraDistance()-Math.abs(r.y)))};this.idealAspect=fi(e,i,0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(e)}setBakedShadowVisibility(e=this.shadowIntensity<=0){for(const t of this.bakedShadows)t.visible=e}idealCameraDistance(){const e=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(e)}adjustedFoV(e){const t=Math.tan(e/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(t)*180/Math.PI}getNDC(e,t){if(this.xrCamera!=null)Ls.set(e/window.screen.width,t/window.screen.height);else{const s=this.element.getBoundingClientRect();Ls.set((e-s.x)/this.width,(t-s.y)/this.height)}return Ls.multiplyScalar(2).subScalar(1),Ls.y*=-1,Ls}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(e,t){this.element[V].arRenderer.presentedScene!==this&&(this.environment=e,this.setBackground(t),this.queueRender())}setBackground(e){this.groundedSkybox.map=e,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=e)}farRadius(){return this.boundingSphere.radius*(this.groundedSkybox.parent!=null?ul:1)}setGroundedSkybox(){const e=tt(this.element.skyboxHeight)[0].terms[0],t=Pe(e).number,s=ul*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(t,s),this.groundedSkybox.position.y=t-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(e,t,s){this.goalTarget.set(-e,-t,-s)}setTargetDamperDecayTime(e){this.targetDamperX.setDecayTime(e),this.targetDamperY.setDecayTime(e),this.targetDamperZ.setDecayTime(e)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget($c)}updateTarget(e){const t=this.goalTarget,s=this.target.position;if(t.equals(s))return!1;{const i=this.boundingSphere.radius/10;let{x:n,y:r,z:a}=s;return n=this.targetDamperX.update(n,t.x,e,i),r=this.targetDamperY.update(r,t.y,e,i),a=this.targetDamperZ.update(a,t.z,e,i),this.target.position.set(n,r,a),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(e,t){const{x:s,z:i}=this.position;this.yaw=Math.atan2(e-s,t-i)}get model(){return this._model}set yaw(e){this.rotation.y=e,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(e){this.mixer.setTime(e),this.queueShadowRender()}get animationTime(){if(this.currentAnimationAction!=null){const e=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop===cc&&(e&1)===1?this.duration-this.currentAnimationAction.time:this.currentAnimationAction.time}return 0}set animationTimeScale(e){this.mixer.timeScale=e}get animationTimeScale(){return this.mixer.timeScale}get duration(){return this.currentAnimationAction!=null&&this.currentAnimationAction.getClip()?this.currentAnimationAction.getClip().duration:0}get hasActiveAnimation(){return this.currentAnimationAction!=null}playAnimation(e=null,t=0,s=hc,i=1/0){if(this._currentGLTF==null)return;const{animations:n}=this;if(n==null||n.length===0)return;let r=null;if(e!=null&&(r=this.animationsByName.get(e),r==null)){const a=parseInt(e);!isNaN(a)&&a>=0&&a<n.length&&(r=n[a])}r==null&&(r=n[0]);try{const{currentAnimationAction:a}=this,A=this.mixer.clipAction(r,this);this.currentAnimationAction=A,this.element.paused?this.mixer.stopAllAction():(A.paused=!1,a!=null&&A!==a?A.crossFadeFrom(a,t,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),A.setLoop(s,i),A.enabled=!0,A.clampWhenFinished=!0,A.play()}catch(a){console.error(a)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(e){this.mixer.update(e),this.queueShadowRender()}subscribeMixerEvent(e,t){this.mixer.addEventListener(e,t)}updateShadow(){const e=this.shadow;if(e!=null){const t=this.element.arPlacement==="wall"?"back":"bottom";e.setScene(this,this.shadowSoftness,t),e.needsUpdate=!0}}renderShadow(e){const t=this.shadow;t!=null&&t.needsUpdate==!0&&(t.render(e,this),t.needsUpdate=!1)}queueShadowRender(){this.shadow!=null&&(this.shadow.needsUpdate=!0)}setShadowIntensity(e){if(this.shadowIntensity=e,this._currentGLTF!=null&&(this.setBakedShadowVisibility(),!(e<=0&&this.shadow==null))){if(this.shadow==null){const t=this.element.arPlacement==="wall"?"back":"bottom";this.shadow=new Nf(this,this.shadowSoftness,t)}this.shadow.setIntensity(e)}}setShadowSoftness(e){this.shadowSoftness=e;const t=this.shadow;t!=null&&t.setSoftness(e)}setShadowOffset(e){const t=this.shadow;t!=null&&t.setOffset(e)}hitFromPoint(e,t=this){return Lr.setFromCamera(e,this.getCamera()),Lr.intersectObject(t,!0).find(i=>i.object.visible&&!i.object.userData.noHit)}positionAndNormalFromPoint(e,t=this){var s;const i=this.hitFromPoint(e,t);if(i==null)return null;const n=i.point,r=i.face!=null?i.face.normal.clone().applyNormalMatrix(new _o().getNormalMatrix(i.object.matrixWorld)):Lr.ray.direction.clone().multiplyScalar(-1),a=(s=i.uv)!==null&&s!==void 0?s:null;return{position:n,normal:r,uv:a}}surfaceFromPoint(e,t=this){const s=this.element.model;if(s==null)return null;const i=this.hitFromPoint(e,t);if(i==null||i.face==null)return null;const n=s[mo](i),{meshes:r,primitives:a}=n.mesh.userData.associations,A=new N,l=new N,c=new N,{a:h,b:d,c:u}=i.face,g=i.object;g.getVertexPosition(h,A),g.getVertexPosition(d,l),g.getVertexPosition(u,c);const p=new lc(A,l,c),f=new N;return p.getBarycoord(g.worldToLocal(i.point),f),`${r} ${a} ${h} ${d} ${u} ${f.x.toFixed(3)} ${f.y.toFixed(3)} ${f.z.toFixed(3)}`}addHotspot(e){this.target.add(e),this.annotationRenderer.domElement.appendChild(e.element)}removeHotspot(e){this.target.remove(e)}forHotspots(e){const{children:t}=this.target;for(let s=0,i=t.length;s<i;s++){const n=t[s];n instanceof as&&e(n)}}initializeSurface(e){if(e.surface!=null&&e.mesh==null){const t=tt(e.surface)[0].terms;if(t.length!=8){console.warn(e.surface+" does not have exactly 8 numbers.");return}const s=this.element.model[yh](t[0].number,t[1].number),i=new N(t[2].number,t[3].number,t[4].number);if(s==null){console.warn(e.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");return}const n=s.mesh.geometry.attributes.position.count;if(i.x>=n||i.y>=n||i.z>=n){console.warn(e.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");return}const r=new N(t[5].number,t[6].number,t[7].number);e.mesh=s.mesh,e.tri=i,e.bary=r}}updateSurfaceHotspots(){const e=!this.element.paused;this.forHotspots(t=>{this.initializeSurface(t),t.updateSurface(e)})}updateHotspotsVisibility(e){this.forHotspots(t=>{_r.copy(e),dl.setFromMatrixPosition(t.matrixWorld),_r.sub(dl),gl.copy(t.normal).transformDirection(this.target.matrixWorld),_r.dot(gl)<0?t.hide():t.show()})}orientHotspots(e){this.forHotspots(t=>{t.orient(e)})}setHotspotsVisibility(e){this.forHotspots(t=>{t.visible=e})}updateSchema(e){var t;const{schemaElement:s,element:i}=this,{alt:n,poster:r,iosSrc:a}=i;if(e!=null){const A=[{"@type":"MediaObject",contentUrl:e,encodingFormat:((t=e.split(".").pop())===null||t===void 0?void 0:t.toLowerCase())==="gltf"?"model/gltf+json":"model/gltf-binary"}];a&&A.push({"@type":"MediaObject",contentUrl:a,encodingFormat:"model/vnd.usdz+zip"});const l={"@context":"http://schema.org/","@type":"3DModel",image:r??void 0,name:n??void 0,encoding:A};s.textContent=JSON.stringify(l),document.head.appendChild(s)}else s.parentElement!=null&&s.parentElement.removeChild(s)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Gf extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(e){const t={progress:0,completed:!1};return this.ongoingActivities.add(t),this.ongoingActivityCount===1&&this.announceTotalProgress(t,0,e),s=>{let i;return i=Math.max(ke(s,0,1),t.progress),i!==t.progress&&this.announceTotalProgress(t,i,e),t.progress}}announceTotalProgress(e,t,s){let i=0,n=0;t==1&&(e.completed=!0);for(const A of this.ongoingActivities){const{progress:l}=A;i+=1-l,A.completed&&n++}const r=e.progress;e.progress=t,this.totalProgress+=(t-r)*(1-this.totalProgress)/i;const a=n===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:a,reason:s}})),n===this.ongoingActivityCount&&(this.totalProgress=0,this.ongoingActivities.clear())}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var xn=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},pl,fl,ml,Il,El,Cl,Bl,yl,wl,Ql,vl,Sl,xl;const Of=10,Pf=50,Hf=0,$f=300,Vf=150,gt=document.createElement("canvas"),Fr=Symbol("fallbackResizeHandler"),bl=Symbol("defaultAriaLabel"),Li=Symbol("resizeObserver"),jt=Symbol("clearModelTimeout"),Nr=Symbol("onContextLost"),Wt=Symbol("loaded"),kr=Symbol("status"),Ur=Symbol("onFocus"),Gr=Symbol("onBlur"),is=Symbol("updateSize"),Fi=Symbol("intersectionObserver"),Rt=Symbol("isElementInViewport"),dn=Symbol("announceModelVisibility"),Xs=Symbol("ariaLabel"),Eo=Symbol("altDefaulted"),Fs=Symbol("statusElement"),Co=Symbol("updateStatus"),Js=Symbol("loadedTime"),ls=Symbol("updateSource"),Tl=Symbol("markLoaded"),tn=Symbol("container"),He=Symbol("input"),Bo=Symbol("canvas"),v=Symbol("scene"),ce=Symbol("needsRender"),qe=Symbol("tick"),Ct=Symbol("onModelLoad"),ai=Symbol("onResize"),V=Symbol("renderer"),kt=Symbol("progressTracker"),Ml=Symbol("getLoaded"),Ut=Symbol("getModelIsVisible"),gs=Symbol("shouldAttemptPreload"),dt=o=>({x:o.x,y:o.y,z:o.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),yo=o=>({u:o.x,v:o.y,toString(){return`${this.u} ${this.v}`}});class hi extends _t{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[pl]=!1,this[fl]=!1,this[ml]=0,this[Il]="",this[El]=null,this[Cl]=Ea(()=>{const i=this.getBoundingClientRect();this[is](i)},Pf),this[Bl]=Ea(i=>{const n=this.modelIsVisible;n!==i&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:n}}))},Hf),this[yl]=null,this[wl]=null,this[Ql]=new Gf,this[vl]=()=>{this[Fs].textContent=this[kr]},this[Sl]=()=>{this[Fs].textContent=""},this[xl]=i=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:i.sourceEvent}}))},this.attachShadow({mode:"open"});const e=this.shadowRoot;vd(e),this[tn]=e.querySelector(".container"),this[He]=e.querySelector(".userInput"),this[Bo]=e.querySelector("canvas"),this[Fs]=e.querySelector("#status"),this[bl]=this[He].getAttribute("aria-label");let t,s;if(this.isConnected){const i=this.getBoundingClientRect();t=i.width,s=i.height}else t=$f,s=Vf;this[v]=new Uf({canvas:this[Bo],element:this,width:t,height:s}),Promise.resolve().then(()=>{this[is](this.getBoundingClientRect())}),Gn&&(this[Li]=new ResizeObserver(i=>{if(!this[V].isPresenting)for(let n of i)n.target===this&&this[is](n.contentRect)})),On?this[Fi]=new IntersectionObserver(i=>{for(let n of i)if(n.target===this){const r=this.modelIsVisible;this[Rt]=n.isIntersecting,this[dn](r),this[Rt]&&!this.loaded&&this[ls]()}},{root:null,rootMargin:"0px",threshold:1e-5}):this[Rt]=!0}static get is(){return"model-viewer"}static set modelCacheSize(e){se[ct].evictionThreshold=e}static get modelCacheSize(){return se[ct].evictionThreshold}static set minimumRenderScale(e){e>1&&console.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),e<=0&&console.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),Re.singleton.minScale=e}static get minimumRenderScale(){return Re.singleton.minScale}get loaded(){return this[Ml]()}get[(pl=Rt,fl=Wt,ml=Js,Il=kr,El=jt,Cl=Fr,Bl=dn,yl=Li,wl=Fi,Ql=kt,V)](){return Re.singleton}get modelIsVisible(){return this[Ut]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Gn?this[Li].observe(this):self.addEventListener("resize",this[Fr]),On&&this[Fi].observe(this),this.addEventListener("focus",this[Ur]),this.addEventListener("blur",this[Gr]);const e=this[V];e.addEventListener("contextlost",this[Nr]),e.registerScene(this[v]),this[jt]!=null&&(self.clearTimeout(this[jt]),this[jt]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Gn?this[Li].unobserve(this):self.removeEventListener("resize",this[Fr]),On&&this[Fi].unobserve(this),this.removeEventListener("focus",this[Ur]),this.removeEventListener("blur",this[Gr]);const e=this[V];e.removeEventListener("contextlost",this[Nr]),e.unregisterScene(this[v]),this[jt]=self.setTimeout(()=>{this[v].dispose(),this[jt]=null},Of)}updated(e){super.updated(e),e.has("src")&&(this.src==null?(this[Wt]=!1,this[Js]=0,this[v].reset()):this.src!==this[v].url&&(this[Wt]=!1,this[Js]=0,this[ls]())),e.has("alt")&&this[He].setAttribute("aria-label",this[Xs]),e.has("withCredentials")&&(se.withCredentials=this.withCredentials,this[V].textureUtils.withCredentials=this.withCredentials),e.has("generateSchema")&&(this.generateSchema?this[v].updateSchema(this.src):this[v].updateSchema(null))}toDataURL(e,t){return this[V].displayCanvas(this[v]).toDataURL(e,t)}async toBlob(e){const t=e?e.mimeType:void 0,s=e?e.qualityArgument:void 0,i=e?e.idealAspect:void 0,{width:n,height:r,idealAspect:a,aspect:A}=this[v],{dpr:l,scaleFactor:c}=this[V];let h=n*c*l,d=r*c*l,u=0,g=0;if(i===!0)if(a>A){const p=d;d=Math.round(h/a),g=(p-d)/2}else{const p=h;h=Math.round(d*a),u=(p-h)/2}gt.width=h,gt.height=d;try{return new Promise(async(p,f)=>{gt.getContext("2d").drawImage(this[V].displayCanvas(this[v]),u,g,h,d,0,0,h,d),gt.toBlob(I=>{if(!I)return f(new Error("Unable to retrieve canvas blob"));p(I)},t,s)})}finally{this[is]({width:n,height:r})}}registerEffectComposer(e){e.setRenderer(this[V].threeRenderer),e.setMainCamera(this[v].getCamera()),e.setMainScene(this[v]),this[v].effectRenderer=e}unregisterEffectComposer(){this[v].effectRenderer=null}registerRenderer(e){this[v].externalRenderer=e}unregisterRenderer(){this[v].externalRenderer=null}get[Xs](){return this[Eo]}get[Eo](){return this.alt==null||this.alt==="null"?this[bl]:this.alt}[Ml](){return this[Wt]}[Ut](){return this.loaded&&this[Rt]}[gs](){return!!this.src&&this[Rt]}[is]({width:e,height:t}){e===0||t===0||(this[tn].style.width=`${e}px`,this[tn].style.height=`${t}px`,this[ai]({width:e,height:t}))}[qe](e,t){var s;(s=this[v].effectRenderer)===null||s===void 0||s.beforeRender(e,t)}[Tl](){this[Wt]||(this[Wt]=!0,this[Js]=performance.now())}[ce](){this[v].queueRender()}[Ct](){}[Co](e){this[kr]=e;const t=this.getRootNode();t!=null&&t.activeElement===this&&this[Fs].textContent!=e&&(this[Fs].textContent=e)}[(vl=Ur,Sl=Gr,ai)](e){this[v].setSize(e.width,e.height)}async[(xl=Nr,ls)](){const e=this[v];if(this.loaded||!this[gs]()||this.src===e.url)return;this.generateSchema&&e.updateSchema(this.src),this[Co]("Loading"),e.stopAnimation();const t=this[kt].beginActivity("model-load"),s=this.src;try{const i=e.setSource(s,r=>t(ke(r,0,1)*.95)),n=this[cn]();await Promise.all([i,n]),this[Tl](),this[Ct](),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("before-render"))}),await new Promise(r=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:s}})),r()})})})}catch(i){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:i}}))}finally{t(1)}}}xn([F({type:String})],hi.prototype,"alt",void 0);xn([F({type:String})],hi.prototype,"src",void 0);xn([F({type:Boolean,attribute:"with-credentials"})],hi.prototype,"withCredentials",void 0);xn([F({type:Boolean,attribute:"generate-schema"})],hi.prototype,"generateSchema",void 0);/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Or=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const Rl=1e3,Ni=Symbol("changeAnimation"),We=Symbol("paused"),qf={repetitions:1/0,pingpong:!1},Kf=o=>{var e;class t extends o{constructor(...i){super(i),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[e]=!0,this[v].subscribeMixerEvent("loop",n=>{const r=n.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:r}}))}),this[v].subscribeMixerEvent("finished",()=>{this[We]=!0,this.dispatchEvent(new CustomEvent("finished"))})}get availableAnimations(){return this.loaded?this[v].animationNames:[]}get duration(){return this[v].duration}get paused(){return this[We]}get currentTime(){return this[v].animationTime}set currentTime(i){this[v].animationTime=i,this[ce]()}get timeScale(){return this[v].animationTimeScale}set timeScale(i){this[v].animationTimeScale=i}pause(){this[We]||(this[We]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(i){this.availableAnimations.length>0&&(this[We]=!1,this[Ni](i),this.dispatchEvent(new CustomEvent("play")))}[(e=We,Ct)](){super[Ct](),this[We]=!0,this.animationName!=null&&this[Ni](),this.autoplay&&this.play()}[qe](i,n){super[qe](i,n),!(this[We]||!this[Ut]()&&!this[V].isPresenting)&&(this[v].updateAnimation(n/Rl),this[ce]())}updated(i){super.updated(i),i.has("autoplay")&&this.autoplay&&this.play(),i.has("animationName")&&this[Ni]()}[Ni](i=qf){var n;const r=(n=i.repetitions)!==null&&n!==void 0?n:1/0,a=i.pingpong?cc:r===1?Ou:hc;this[v].playAnimation(this.animationName,this.animationCrossfadeDuration/Rl,a,r),this[We]&&(this[v].updateAnimation(0),this[ce]())}}return Or([F({type:Boolean})],t.prototype,"autoplay",void 0),Or([F({type:String,attribute:"animation-name"})],t.prototype,"animationName",void 0),Or([F({type:Number,attribute:"animation-crossfade-duration"})],t.prototype,"animationCrossfadeDuration",void 0),t};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const St=Symbol("hotspotMap"),Pr=Symbol("mutationCallback"),Ns=Symbol("observer"),Hr=Symbol("addHotspot"),Dl=Symbol("removeHotspot"),$r=new Ve,zf=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this[e]=new Map,this[t]=r=>{r.forEach(a=>{(!(a instanceof MutationRecord)||a.type==="childList")&&(a.addedNodes.forEach(A=>{this[Hr](A)}),a.removedNodes.forEach(A=>{this[Dl](A)}),this[ce]())})},this[s]=new MutationObserver(this[Pr])}connectedCallback(){super.connectedCallback();for(let a=0;a<this.children.length;++a)this[Hr](this.children[a]);const{ShadyDOM:r}=self;r==null?this[Ns].observe(this,{childList:!0}):this[Ns]=r.observeChildren(this,this[Pr])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:r}=self;r==null?this[Ns].disconnect():r.unobserveChildren(this[Ns])}[(e=St,t=Pr,s=Ns,qe)](r,a){super[qe](r,a);const A=this[v],{annotationRenderer:l}=A,c=A.getCamera();A.shouldRender()&&(A.updateSurfaceHotspots(),A.updateHotspotsVisibility(c.position),l.domElement.style.display="",l.render(A,c))}updateHotspot(r){const a=this[St].get(r.name);a!=null&&(a.updatePosition(r.position),a.updateNormal(r.normal),a.surface=r.surface,this[ce]())}queryHotspot(r){const a=this[St].get(r);if(a==null)return null;const A=dt(a.position),l=dt(a.normal),c=a.facingCamera,h=this[v],d=h.getCamera(),u=new N;u.setFromMatrixPosition(a.matrixWorld),u.project(d);const g=h.width/2,p=h.height/2;u.x=u.x*g+g,u.y=-(u.y*p)+p;const f=dt(new N(u.x,u.y,u.z));return!Number.isFinite(f.x)||!Number.isFinite(f.y)?null:{position:A,normal:l,canvasPosition:f,facingCamera:c}}positionAndNormalFromPoint(r,a){const A=this[v],l=A.getNDC(r,a),c=A.positionAndNormalFromPoint(l);if(c==null)return null;$r.copy(A.target.matrixWorld).invert();const h=dt(c.position.applyMatrix4($r)),d=dt(c.normal.transformDirection($r));let u=null;return c.uv!=null&&(u=yo(c.uv)),{position:h,normal:d,uv:u}}surfaceFromPoint(r,a){const A=this[v],l=A.getNDC(r,a);return A.surfaceFromPoint(l)}[Hr](r){if(!(r instanceof HTMLElement&&r.slot.indexOf("hotspot")===0))return;let a=this[St].get(r.slot);a!=null?a.increment():(a=new as({name:r.slot,position:r.dataset.position,normal:r.dataset.normal,surface:r.dataset.surface}),this[St].set(r.slot,a),this[v].addHotspot(a)),this[v].queueRender()}[Dl](r){if(!(r instanceof HTMLElement))return;const a=this[St].get(r.slot);a&&(a.decrement()&&(this[v].removeHotspot(a),this[St].delete(r.slot)),this[v].queueRender())}}return i};/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.6.9
*/var _l=function(o){return URL.createObjectURL(new Blob([o],{type:"text/javascript"}))};try{URL.revokeObjectURL(_l(""))}catch{_l=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var fe=Uint8Array,ge=Uint16Array,ps=Uint32Array,Uo=new fe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Go=new fe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ll=new fe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wh=function(o,e){for(var t=new ge(31),s=0;s<31;++s)t[s]=e+=1<<o[s-1];for(var i=new ps(t[30]),s=1;s<30;++s)for(var n=t[s];n<t[s+1];++n)i[n]=n-t[s]<<5|s;return[t,i]},Qh=wh(Uo,2),Yf=Qh[0],wo=Qh[1];Yf[28]=258,wo[258]=28;var Jf=wh(Go,0),Fl=Jf[1],Qo=new ge(32768);for(var j=0;j<32768;++j){var at=(j&43690)>>>1|(j&21845)<<1;at=(at&52428)>>>2|(at&13107)<<2,at=(at&61680)>>>4|(at&3855)<<4,Qo[j]=((at&65280)>>>8|(at&255)<<8)>>>1}var Zs=function(o,e,t){for(var s=o.length,i=0,n=new ge(e);i<s;++i)++n[o[i]-1];var r=new ge(e);for(i=0;i<e;++i)r[i]=r[i-1]+n[i-1]<<1;var a;if(t){a=new ge(1<<e);var A=15-e;for(i=0;i<s;++i)if(o[i])for(var l=i<<4|o[i],c=e-o[i],h=r[o[i]-1]++<<c,d=h|(1<<c)-1;h<=d;++h)a[Qo[h]>>>A]=l}else for(a=new ge(s),i=0;i<s;++i)o[i]&&(a[i]=Qo[r[o[i]-1]++]>>>15-o[i]);return a},Gt=new fe(288);for(var j=0;j<144;++j)Gt[j]=8;for(var j=144;j<256;++j)Gt[j]=9;for(var j=256;j<280;++j)Gt[j]=7;for(var j=280;j<288;++j)Gt[j]=8;var gn=new fe(32);for(var j=0;j<32;++j)gn[j]=5;var jf=Zs(Gt,9,0),Wf=Zs(gn,5,0),vh=function(o){return(o/8|0)+(o&7&&1)},Sh=function(o,e,t){(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length);var s=new(o instanceof ge?ge:o instanceof ps?ps:fe)(t-e);return s.set(o.subarray(e,t)),s},Xe=function(o,e,t){t<<=e&7;var s=e/8|0;o[s]|=t,o[s+1]|=t>>>8},ks=function(o,e,t){t<<=e&7;var s=e/8|0;o[s]|=t,o[s+1]|=t>>>8,o[s+2]|=t>>>16},Vr=function(o,e){for(var t=[],s=0;s<o.length;++s)o[s]&&t.push({s,f:o[s]});var i=t.length,n=t.slice();if(!i)return[Oo,0];if(i==1){var r=new fe(t[0].s+1);return r[t[0].s]=1,[r,1]}t.sort(function(E,B){return E.f-B.f}),t.push({s:-1,f:25001});var a=t[0],A=t[1],l=0,c=1,h=2;for(t[0]={s:-1,f:a.f+A.f,l:a,r:A};c!=i-1;)a=t[t[l].f<t[h].f?l++:h++],A=t[l!=c&&t[l].f<t[h].f?l++:h++],t[c++]={s:-1,f:a.f+A.f,l:a,r:A};for(var d=n[0].s,s=1;s<i;++s)n[s].s>d&&(d=n[s].s);var u=new ge(d+1),g=vo(t[c-1],u,0);if(g>e){var s=0,p=0,f=g-e,I=1<<f;for(n.sort(function(B,Q){return u[Q.s]-u[B.s]||B.f-Q.f});s<i;++s){var C=n[s].s;if(u[C]>e)p+=I-(1<<g-u[C]),u[C]=e;else break}for(p>>>=f;p>0;){var w=n[s].s;u[w]<e?p-=1<<e-u[w]++-1:++s}for(;s>=0&&p;--s){var m=n[s].s;u[m]==e&&(--u[m],++p)}g=e}return[new fe(u),g]},vo=function(o,e,t){return o.s==-1?Math.max(vo(o.l,e,t+1),vo(o.r,e,t+1)):e[o.s]=t},Nl=function(o){for(var e=o.length;e&&!o[--e];);for(var t=new ge(++e),s=0,i=o[0],n=1,r=function(A){t[s++]=A},a=1;a<=e;++a)if(o[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)r(32754);n>2&&(r(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(r(i),--n;n>6;n-=6)r(8304);n>2&&(r(n-3<<5|8208),n=0)}for(;n--;)r(i);n=1,i=o[a]}return[t.subarray(0,s),e]},Us=function(o,e){for(var t=0,s=0;s<e.length;++s)t+=o[s]*e[s];return t},sn=function(o,e,t){var s=t.length,i=vh(e+2);o[i]=s&255,o[i+1]=s>>>8,o[i+2]=o[i]^255,o[i+3]=o[i+1]^255;for(var n=0;n<s;++n)o[i+n+4]=t[n];return(i+4+s)*8},kl=function(o,e,t,s,i,n,r,a,A,l,c){Xe(e,c++,t),++i[256];for(var h=Vr(i,15),d=h[0],u=h[1],g=Vr(n,15),p=g[0],f=g[1],I=Nl(d),C=I[0],w=I[1],m=Nl(p),E=m[0],B=m[1],Q=new ge(19),y=0;y<C.length;++y)Q[C[y]&31]++;for(var y=0;y<E.length;++y)Q[E[y]&31]++;for(var S=Vr(Q,7),x=S[0],R=S[1],_=19;_>4&&!x[Ll[_-1]];--_);var U=l+5<<3,T=Us(i,Gt)+Us(n,gn)+r,M=Us(i,d)+Us(n,p)+r+14+3*_+Us(Q,x)+(2*Q[16]+3*Q[17]+7*Q[18]);if(U<=T&&U<=M)return sn(e,c,o.subarray(A,A+l));var k,D,O,z;if(Xe(e,c,1+(M<T)),c+=2,M<T){k=Zs(d,u,0),D=d,O=Zs(p,f,0),z=p;var $=Zs(x,R,0);Xe(e,c,w-257),Xe(e,c+5,B-1),Xe(e,c+10,_-4),c+=14;for(var y=0;y<_;++y)Xe(e,c+3*y,x[Ll[y]]);c+=3*_;for(var Y=[C,E],Z=0;Z<2;++Z)for(var re=Y[Z],y=0;y<re.length;++y){var Ce=re[y]&31;Xe(e,c,$[Ce]),c+=x[Ce],Ce>15&&(Xe(e,c,re[y]>>>5&127),c+=re[y]>>>12)}}else k=jf,D=Gt,O=Wf,z=gn;for(var y=0;y<a;++y)if(s[y]>255){var Ce=s[y]>>>18&31;ks(e,c,k[Ce+257]),c+=D[Ce+257],Ce>7&&(Xe(e,c,s[y]>>>23&31),c+=Uo[Ce]);var Be=s[y]&31;ks(e,c,O[Be]),c+=z[Be],Be>3&&(ks(e,c,s[y]>>>5&8191),c+=Go[Be])}else ks(e,c,k[s[y]]),c+=D[s[y]];return ks(e,c,k[256]),c+D[256]},Xf=new ps([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Oo=new fe(0),Zf=function(o,e,t,s,i,n){var r=o.length,a=new fe(s+r+5*(1+Math.ceil(r/7e3))+i),A=a.subarray(s,a.length-i),l=0;if(!e||r<8)for(var c=0;c<=r;c+=65535){var h=c+65535;h<r?l=sn(A,l,o.subarray(c,h)):(A[c]=n,l=sn(A,l,o.subarray(c,r)))}else{for(var d=Xf[e-1],u=d>>>13,g=d&8191,p=(1<<t)-1,f=new ge(32768),I=new ge(p+1),C=Math.ceil(t/3),w=2*C,m=function(Tn){return(o[Tn]^o[Tn+1]<<C^o[Tn+2]<<w)&p},E=new ps(25e3),B=new ge(288),Q=new ge(32),y=0,S=0,c=0,x=0,R=0,_=0;c<r;++c){var U=m(c),T=c&32767,M=I[U];if(f[T]=M,I[U]=T,R<=c){var k=r-c;if((y>7e3||x>24576)&&k>423){l=kl(o,A,0,E,B,Q,S,x,_,c-_,l),x=y=S=0,_=c;for(var D=0;D<286;++D)B[D]=0;for(var D=0;D<30;++D)Q[D]=0}var O=2,z=0,$=g,Y=T-M&32767;if(k>2&&U==m(c-Y))for(var Z=Math.min(u,k)-1,re=Math.min(32767,c),Ce=Math.min(258,k);Y<=re&&--$&&T!=M;){if(o[c+O]==o[c+O-Y]){for(var Be=0;Be<Ce&&o[c+Be]==o[c+Be-Y];++Be);if(Be>O){if(O=Be,z=Y,Be>Z)break;for(var Dh=Math.min(Y,Be-2),Po=0,D=0;D<Dh;++D){var bn=c-Y+D+32768&32767,_h=f[bn],Ho=bn-_h+32768&32767;Ho>Po&&(Po=Ho,M=bn)}}}T=M,M=f[T],Y+=T-M+32768&32767}if(z){E[x++]=268435456|wo[O]<<18|Fl[z];var $o=wo[O]&31,Vo=Fl[z]&31;S+=Uo[$o]+Go[Vo],++B[257+$o],++Q[Vo],R=c+O,++y}else E[x++]=o[c],++B[o[c]]}}l=kl(o,A,n,E,B,Q,S,x,_,c-_,l),!n&&l&7&&(l=sn(A,l+1,Oo))}return Sh(a,0,s+vh(l)+i)},em=function(){for(var o=new ps(256),e=0;e<256;++e){for(var t=e,s=9;--s;)t=(t&1&&3988292384)^t>>>1;o[e]=t}return o}(),tm=function(){var o=-1;return{p:function(e){for(var t=o,s=0;s<e.length;++s)t=em[t&255^e[s]]^t>>>8;o=t},d:function(){return~o}}},sm=function(o,e,t,s,i){return Zf(o,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(o.length)))*1.5):12+e.mem,t,s,!i)},xh=function(o,e){var t={};for(var s in o)t[s]=o[s];for(var s in e)t[s]=e[s];return t},oe=function(o,e,t){for(;t;++e)o[e]=t,t>>>=8};function im(o,e){return sm(o,e||{},0,0)}var bh=function(o,e,t,s){for(var i in o){var n=o[i],r=e+i;n instanceof fe?t[r]=[n,s]:Array.isArray(n)?t[r]=[n[0],xh(s,n[1])]:bh(n,r+"/",t,s)}},Ul=typeof TextEncoder<"u"&&new TextEncoder,nm=typeof TextDecoder<"u"&&new TextDecoder,rm=0;try{nm.decode(Oo,{stream:!0}),rm=1}catch{}function pn(o,e){if(e){for(var t=new fe(o.length),s=0;s<o.length;++s)t[s]=o.charCodeAt(s);return t}if(Ul)return Ul.encode(o);for(var i=o.length,n=new fe(o.length+(o.length>>1)),r=0,a=function(c){n[r++]=c},s=0;s<i;++s){if(r+5>n.length){var A=new fe(r+8+(i-s<<1));A.set(n),n=A}var l=o.charCodeAt(s);l<128||e?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|o.charCodeAt(++s)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return Sh(n,0,r)}var So=function(o){var e=0;if(o)for(var t in o){var s=o[t].length;if(s>65535)throw"extra field too long";e+=s+4}return e},Gl=function(o,e,t,s,i,n,r,a){var A=s.length,l=t.extra,c=a&&a.length,h=So(l);oe(o,e,r!=null?33639248:67324752),e+=4,r!=null&&(o[e++]=20,o[e++]=t.os),o[e]=20,e+=2,o[e++]=t.flag<<1|(n==null&&8),o[e++]=i&&8,o[e++]=t.compression&255,o[e++]=t.compression>>8;var d=new Date(t.mtime==null?Date.now():t.mtime),u=d.getFullYear()-1980;if(u<0||u>119)throw"date not in range 1980-2099";if(oe(o,e,u<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,n!=null&&(oe(o,e,t.crc),oe(o,e+4,n),oe(o,e+8,t.size)),oe(o,e+12,A),oe(o,e+14,h),e+=16,r!=null&&(oe(o,e,c),oe(o,e+6,t.attrs),oe(o,e+10,r),e+=14),o.set(s,e),e+=A,h)for(var g in l){var p=l[g],f=p.length;oe(o,e,+g),oe(o,e+2,f),o.set(p,e+4),e+=4+f}return c&&(o.set(a,e),e+=c),e},om=function(o,e,t,s,i){oe(o,e,101010256),oe(o,e+8,t),oe(o,e+10,t),oe(o,e+12,s),oe(o,e+16,i)};function am(o,e){e||(e={});var t={},s=[];bh(o,"",t,e);var i=0,n=0;for(var r in t){var a=t[r],A=a[0],l=a[1],c=l.level==0?0:8,h=pn(r),d=h.length,u=l.comment,g=u&&pn(u),p=g&&g.length,f=So(l.extra);if(d>65535)throw"filename too long";var I=c?im(A,l):A,C=I.length,w=tm();w.p(A),s.push(xh(l,{size:A.length,crc:w.d(),c:I,f:h,m:g,u:d!=r.length||g&&u.length!=p,o:i,compression:c})),i+=30+d+f+C,n+=76+2*(d+f)+(p||0)+C}for(var m=new fe(n+22),E=i,B=n-i,Q=0;Q<s.length;++Q){var h=s[Q];Gl(m,h.o,h,h.f,h.u,h.c.length);var y=30+h.f.length+So(h.extra);m.set(h.c,h.o+y),Gl(m,i,h,h.f,h.u,h.c.length,h.o,h.m),i+=16+y+(h.m?h.m.length:0)}return om(m,i,s.length,B,E),m}class Am{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1},t);const s={},i="model.usda";s[i]=null;let n=Th();n+=cm(t);const r={},a={};e.traverseVisible(l=>{if(l.isMesh){const c=l.geometry,h=l.material;if(h.isMeshStandardMaterial){const d="geometries/Geometry_"+c.id+".usda";if(!(d in s)){const u=gm(c);s[d]=um(u)}h.uuid in r||(r[h.uuid]=h),n+=dm(l,c,h)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",l)}else l.isCamera&&(n+=wm(l))}),n+=hm(),n+=Cm(r,a,t.quickLookCompatible),s[i]=pn(n),n=null;for(const l in a){let c=a[l];c.isCompressedTexture===!0&&(c=zi(c));const h=lm(c.image,c.flipY),d=await new Promise(u=>h.toBlob(u,"image/png",1));s[`textures/Texture_${l}.png`]=new Uint8Array(await d.arrayBuffer())}let A=0;for(const l in s){const c=s[l],h=34+l.length;A+=h;const d=A&63;if(d!==4){const u=64-d,g=new Uint8Array(u);s[l]=[c,{extra:{12345:g}}]}A=c.length}return am(s,{level:0})}}function lm(o,e){if(typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&o instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&o instanceof ImageBitmap){const t=1024/Math.max(o.width,o.height),s=document.createElement("canvas");s.width=o.width*Math.min(1,t),s.height=o.height*Math.min(1,t);const i=s.getContext("2d");return e===!0&&(i.translate(0,s.height),i.scale(1,-1)),i.drawImage(o,0,0,s.width,s.height),s}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const le=7;function Th(){return`#usda 1.0
(
	customLayerData = {
		string creator = "Three.js USDZExporter"
	}
	defaultPrim = "Root"
	metersPerUnit = 1
	upAxis = "Y"
)

`}function cm(o){return`def Xform "Root"
{
	def Scope "Scenes" (
		kind = "sceneLibrary"
	)
	{
		def Xform "Scene" (
			customData = {
				bool preliminary_collidesWithEnvironment = 0
				string sceneName = "Scene"
			}
			sceneName = "Scene"
		)
		{
		token preliminary:anchoring:type = "${o.ar.anchoring.type}"
		token preliminary:planeAnchoring:alignment = "${o.ar.planeAnchoring.alignment}"

`}function hm(){return`
		}
	}
}

`}function um(o){let e=Th();return e+=o,pn(e)}function dm(o,e,t){const s="Object_"+o.id,i=Mh(o.matrixWorld);return o.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",o),`def Xform "${s}" (
	prepend references = @./geometries/Geometry_${e.id}.usda@</Geometry>
	prepend apiSchemas = ["MaterialBindingAPI"]
)
{
	matrix4d xformOp:transform = ${i}
	uniform token[] xformOpOrder = ["xformOp:transform"]

	rel material:binding = </Materials/Material_${t.id}>
}

`}function Mh(o){const e=o.elements;return`( ${ki(e,0)}, ${ki(e,4)}, ${ki(e,8)}, ${ki(e,12)} )`}function ki(o,e){return`(${o[e+0]}, ${o[e+1]}, ${o[e+2]}, ${o[e+3]})`}function gm(o){return`
def "Geometry"
{
${pm(o)}
}
`}function pm(o){const e="Geometry",t=o.attributes,s=t.position.count;return`
	def Mesh "${e}"
	{
		int[] faceVertexCounts = [${fm(o)}]
		int[] faceVertexIndices = [${mm(o)}]
		normal3f[] normals = [${Ol(t.normal,s)}] (
			interpolation = "vertex"
		)
		point3f[] points = [${Ol(t.position,s)}]
${Em(t)}
		uniform token subdivisionScheme = "none"
	}
`}function fm(o){const e=o.index!==null?o.index.count:o.attributes.position.count;return Array(e/3).fill(3).join(", ")}function mm(o){const e=o.index,t=[];if(e!==null)for(let s=0;s<e.count;s++)t.push(e.getX(s));else{const s=o.attributes.position.count;for(let i=0;i<s;i++)t.push(i)}return t.join(", ")}function Ol(o,e){if(o===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const t=[];for(let s=0;s<o.count;s++){const i=o.getX(s),n=o.getY(s),r=o.getZ(s);t.push(`(${i.toPrecision(le)}, ${n.toPrecision(le)}, ${r.toPrecision(le)})`)}return t.join(", ")}function Im(o){const e=[];for(let t=0;t<o.count;t++){const s=o.getX(t),i=o.getY(t);e.push(`(${s.toPrecision(le)}, ${1-i.toPrecision(le)})`)}return e.join(", ")}function Em(o){let e="";for(let t=0;t<4;t++){const s=t>0?t:"",i=o["uv"+s];i!==void 0&&(e+=`
		texCoord2f[] primvars:st${s} = [${Im(i)}] (
			interpolation = "vertex"
		)`)}return e}function Cm(o,e,t=!1){const s=[];for(const i in o){const n=o[i];s.push(Bm(n,e,t))}return`def "Materials"
{
${s.join("")}
}

`}function Bm(o,e,t=!1){const s="			",i=[],n=[];function r(a,A,l){const c=a.source.id+"_"+a.flipY;e[c]=a;const h=a.channel>0?"st"+a.channel:"st",d={1e3:"repeat",1001:"clamp",1002:"mirror"},u=a.repeat.clone(),g=a.offset.clone(),p=a.rotation,f=Math.sin(p),I=Math.cos(p);return g.y=1-g.y-u.y,t?(g.x=g.x/u.x,g.y=g.y/u.y,g.x+=f/u.x,g.y+=I-1):(g.x+=f*u.x,g.y+=(1-I)*u.y),`
		def Shader "PrimvarReader_${A}"
		{
			uniform token info:id = "UsdPrimvarReader_float2"
			float2 inputs:fallback = (0.0, 0.0)
			token inputs:varname = "${h}"
			float2 outputs:result
		}

		def Shader "Transform2d_${A}"
		{
			uniform token info:id = "UsdTransform2d"
			token inputs:in.connect = </Materials/Material_${o.id}/PrimvarReader_${A}.outputs:result>
			float inputs:rotation = ${(p*(180/Math.PI)).toFixed(le)}
			float2 inputs:scale = ${Hl(u)}
			float2 inputs:translation = ${Hl(g)}
			float2 outputs:result
		}

		def Shader "Texture_${a.id}_${A}"
		{
			uniform token info:id = "UsdUVTexture"
			asset inputs:file = @textures/Texture_${c}.png@
			float2 inputs:st.connect = </Materials/Material_${o.id}/Transform2d_${A}.outputs:result>
			${l!==void 0?"float4 inputs:scale = "+ym(l):""}
			token inputs:sourceColorSpace = "${a.colorSpace===on?"raw":"sRGB"}"
			token inputs:wrapS = "${d[a.wrapS]}"
			token inputs:wrapT = "${d[a.wrapT]}"
			float outputs:r
			float outputs:g
			float outputs:b
			float3 outputs:rgb
			${o.transparent||o.alphaTest>0?"float outputs:a":""}
		}`}return o.side===Ft&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",o),o.map!==null?(i.push(`${s}color3f inputs:diffuseColor.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:rgb>`),o.transparent?i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:a>`):o.alphaTest>0&&(i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:a>`),i.push(`${s}float inputs:opacityThreshold = ${o.alphaTest}`)),n.push(r(o.map,"diffuse",o.color))):i.push(`${s}color3f inputs:diffuseColor = ${Pl(o.color)}`),o.emissiveMap!==null?(i.push(`${s}color3f inputs:emissiveColor.connect = </Materials/Material_${o.id}/Texture_${o.emissiveMap.id}_emissive.outputs:rgb>`),n.push(r(o.emissiveMap,"emissive"))):o.emissive.getHex()>0&&i.push(`${s}color3f inputs:emissiveColor = ${Pl(o.emissive)}`),o.normalMap!==null&&(i.push(`${s}normal3f inputs:normal.connect = </Materials/Material_${o.id}/Texture_${o.normalMap.id}_normal.outputs:rgb>`),n.push(r(o.normalMap,"normal"))),o.aoMap!==null&&(i.push(`${s}float inputs:occlusion.connect = </Materials/Material_${o.id}/Texture_${o.aoMap.id}_occlusion.outputs:r>`),n.push(r(o.aoMap,"occlusion"))),o.roughnessMap!==null&&o.roughness===1?(i.push(`${s}float inputs:roughness.connect = </Materials/Material_${o.id}/Texture_${o.roughnessMap.id}_roughness.outputs:g>`),n.push(r(o.roughnessMap,"roughness"))):i.push(`${s}float inputs:roughness = ${o.roughness}`),o.metalnessMap!==null&&o.metalness===1?(i.push(`${s}float inputs:metallic.connect = </Materials/Material_${o.id}/Texture_${o.metalnessMap.id}_metallic.outputs:b>`),n.push(r(o.metalnessMap,"metallic"))):i.push(`${s}float inputs:metallic = ${o.metalness}`),o.alphaMap!==null?(i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.alphaMap.id}_opacity.outputs:r>`),i.push(`${s}float inputs:opacityThreshold = 0.0001`),n.push(r(o.alphaMap,"opacity"))):i.push(`${s}float inputs:opacity = ${o.opacity}`),o.isMeshPhysicalMaterial&&(i.push(`${s}float inputs:clearcoat = ${o.clearcoat}`),i.push(`${s}float inputs:clearcoatRoughness = ${o.clearcoatRoughness}`),i.push(`${s}float inputs:ior = ${o.ior}`)),`
	def Material "Material_${o.id}"
	{
		def Shader "PreviewSurface"
		{
			uniform token info:id = "UsdPreviewSurface"
${i.join(`
`)}
			int inputs:useSpecularWorkflow = 0
			token outputs:surface
		}

		token outputs:surface.connect = </Materials/Material_${o.id}/PreviewSurface.outputs:surface>

${n.join(`
`)}

	}
`}function Pl(o){return`(${o.r}, ${o.g}, ${o.b})`}function ym(o){return`(${o.r}, ${o.g}, ${o.b}, 1.0)`}function Hl(o){return`(${o.x}, ${o.y})`}function wm(o){const e=o.name?o.name:"Camera_"+o.id,t=Mh(o.matrixWorld);return o.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",o),o.isOrthographicCamera?`def Camera "${e}"
		{
			matrix4d xformOp:transform = ${t}
			uniform token[] xformOpOrder = ["xformOp:transform"]

			float2 clippingRange = (${o.near.toPrecision(le)}, ${o.far.toPrecision(le)})
			float horizontalAperture = ${((Math.abs(o.left)+Math.abs(o.right))*10).toPrecision(le)}
			float verticalAperture = ${((Math.abs(o.top)+Math.abs(o.bottom))*10).toPrecision(le)}
			token projection = "orthographic"
		}
	
	`:`def Camera "${e}"
		{
			matrix4d xformOp:transform = ${t}
			uniform token[] xformOpOrder = ["xformOp:transform"]

			float2 clippingRange = (${o.near.toPrecision(le)}, ${o.far.toPrecision(le)})
			float focalLength = ${o.getFocalLength().toPrecision(le)}
			float focusDistance = ${o.focus.toPrecision(le)}
			float horizontalAperture = ${o.getFilmWidth().toPrecision(le)}
			token projection = "perspective"
			float verticalAperture = ${o.getFilmHeight().toPrecision(le)}
		}
	
	`}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Qm=o=>e=>{try{const t=tt(e),s=(t.length?t[0].terms:[]).filter(i=>i&&i.type==="ident").map(i=>i.value).filter(i=>o.indexOf(i)>-1);return new Set(s)}catch{}return new Set};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Xt=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};let $l=!1,Vl=!1;const ql="#model-viewer-no-ar-fallback",vm=Qm(["quick-look","scene-viewer","webxr","none"]),Sm="webxr scene-viewer quick-look",xe={QUICK_LOOK:"quick-look",SCENE_VIEWER:"scene-viewer",WEBXR:"webxr",NONE:"none"},Ze=Symbol("arButtonContainer"),Kl=Symbol("enterARWithWebXR"),zl=Symbol("openSceneViewer"),Yl=Symbol("openIOSARQuickLook"),xm=Symbol("canActivateAR"),Ui=Symbol("arMode"),qr=Symbol("arModes"),Zt=Symbol("arAnchor"),Gi=Symbol("preload"),Oi=Symbol("onARButtonContainerClick"),Kr=Symbol("onARStatus"),zr=Symbol("onARTracking"),Yr=Symbol("onARTap"),Gs=Symbol("selectARMode"),Jr=Symbol("triggerLoad"),bm=o=>{var e,t,s,i,n,r,a,A,l,c;class h extends o{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arPlacement="floor",this.arModes=Sm,this.iosSrc=null,this.xrEnvironment=!1,this[e]=!1,this[t]=this.shadowRoot.querySelector(".ar-button"),this[s]=document.createElement("a"),this[i]=new Set,this[n]=xe.NONE,this[r]=!1,this[a]=u=>{u.preventDefault(),this.activateAR()},this[A]=({status:u})=>{(u===ut.NOT_PRESENTING||this[V].arRenderer.presentedScene===this[v])&&(this.setAttribute("ar-status",u),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:u}})),u===ut.NOT_PRESENTING?this.removeAttribute("ar-tracking"):u===ut.SESSION_STARTED&&this.setAttribute("ar-tracking",go.TRACKING))},this[l]=({status:u})=>{this.setAttribute("ar-tracking",u),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:u}}))},this[c]=u=>{u.data=="_apple_ar_quicklook_button_tapped"&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[Ui]!==xe.NONE}connectedCallback(){super.connectedCallback(),this[V].arRenderer.addEventListener("status",this[Kr]),this.setAttribute("ar-status",ut.NOT_PRESENTING),this[V].arRenderer.addEventListener("tracking",this[zr]),this[Zt].addEventListener("message",this[Yr])}disconnectedCallback(){super.disconnectedCallback(),this[V].arRenderer.removeEventListener("status",this[Kr]),this[V].arRenderer.removeEventListener("tracking",this[zr]),this[Zt].removeEventListener("message",this[Yr])}update(u){super.update(u),u.has("arScale")&&(this[v].canScale=this.arScale!=="fixed"),u.has("arPlacement")&&(this[v].updateShadow(),this[ce]()),u.has("arModes")&&(this[qr]=vm(this.arModes)),(u.has("ar")||u.has("arModes")||u.has("src")||u.has("iosSrc"))&&this[Gs]()}async activateAR(){switch(this[Ui]){case xe.QUICK_LOOK:await this[Yl]();break;case xe.WEBXR:await this[Kl]();break;case xe.SCENE_VIEWER:this[zl]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities");break}}async[(e=xm,t=Ze,s=Zt,i=qr,n=Ui,r=Gi,a=Oi,A=Kr,l=zr,c=Yr,Gs)](){let u=xe.NONE;if(this.ar){if(this.src!=null)for(const g of this[qr]){if(g==="webxr"&&Bc&&!$l&&await this[V].arRenderer.supportsPresentation()){u=xe.WEBXR;break}if(g==="scene-viewer"&&ld&&!Vl){u=xe.SCENE_VIEWER;break}if(g==="quick-look"&&ma){u=xe.QUICK_LOOK;break}}u===xe.NONE&&this.iosSrc!=null&&ma&&(u=xe.QUICK_LOOK)}if(u!==xe.NONE)this[Ze].classList.add("enabled"),this[Ze].addEventListener("click",this[Oi]);else if(this[Ze].classList.contains("enabled")){this[Ze].removeEventListener("click",this[Oi]),this[Ze].classList.remove("enabled");const g=ut.FAILED;this.setAttribute("ar-status",g),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:g}}))}this[Ui]=u}async[Kl](){console.log("Attempting to present in AR with WebXR..."),await this[Jr]();try{this[Ze].removeEventListener("click",this[Oi]);const{arRenderer:u}=this[V];u.placeOnWall=this.arPlacement==="wall",await u.present(this[v],this.xrEnvironment)}catch(u){console.warn("Error while trying to present in AR with WebXR"),console.error(u),await this[V].arRenderer.stopPresenting(),$l=!0,console.warn("Falling back to next ar-mode"),await this[Gs](),this.activateAR()}finally{this[Gs]()}}async[Jr](){this.loaded||(this[Gi]=!0,this[ls](),await pd(this,"load"),this[Gi]=!1)}[gs](){return super[gs]()||this[Gi]}[zl](){const u=self.location.toString(),g=new URL(u),p=new URL(this.src,u);p.hash&&(p.hash="");const f=new URLSearchParams(p.search);if(g.hash=ql,f.set("mode","ar_preferred"),f.has("disable_occlusion")||f.set("disable_occlusion","true"),this.arScale==="fixed"&&f.set("resizable","false"),this.arPlacement==="wall"&&f.set("enable_vertical_placement","true"),f.has("sound")){const w=new URL(f.get("sound"),u);f.set("sound",w.toString())}if(f.has("link")){const w=new URL(f.get("link"),u);f.set("link",w.toString())}const I=`intent://arvr.google.com/scene-viewer/1.0?${f.toString()+"&file="+encodeURIComponent(p.toString())}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(g.toString())};end;`,C=()=>{self.location.hash===ql&&(Vl=!0,self.history.back(),console.warn("Error while trying to present in AR with Scene Viewer"),console.warn("Falling back to next ar-mode"),this[Gs]())};self.addEventListener("hashchange",C,{once:!0}),this[Zt].setAttribute("href",I),console.log("Attempting to present in AR with Scene Viewer..."),this[Zt].click()}async[Yl](){const u=!this.iosSrc;this[Ze].classList.remove("enabled");const g=u?await this.prepareUSDZ():this.iosSrc,p=new URL(g,self.location.toString());if(u){const C=self.location.toString(),w=new URL(C),m=new URL(this.src,w);m.hash&&(p.hash=m.hash)}this.arScale==="fixed"&&(p.hash&&(p.hash+="&"),p.hash+="allowsContentScaling=0");const f=this[Zt];f.setAttribute("rel","ar");const I=document.createElement("img");f.appendChild(I),f.setAttribute("href",p.toString()),u&&f.setAttribute("download","model.usdz"),f.style.display="none",f.isConnected||this.shadowRoot.appendChild(f),console.log("Attempting to present in AR with Quick Look..."),f.click(),f.removeChild(I),u&&URL.revokeObjectURL(g),this[Ze].classList.add("enabled")}async prepareUSDZ(){const u=this[kt].beginActivity("usdz-conversion");await this[Jr]();const{model:g,shadow:p}=this[v];if(g==null)return"";let f=!1;p!=null&&(f=p.visible,p.visible=!1),u(.2);const C=await new Am().parse(g),w=new Blob([C],{type:"model/vnd.usdz+zip"}),m=URL.createObjectURL(w);return u(1),p!=null&&(p.visible=f),m}}return Xt([F({type:Boolean,attribute:"ar"})],h.prototype,"ar",void 0),Xt([F({type:String,attribute:"ar-scale"})],h.prototype,"arScale",void 0),Xt([F({type:String,attribute:"ar-placement"})],h.prototype,"arPlacement",void 0),Xt([F({type:String,attribute:"ar-modes"})],h.prototype,"arModes",void 0),Xt([F({type:String,attribute:"ios-src"})],h.prototype,"iosSrc",void 0),Xt([F({type:Boolean,attribute:"xr-environment"})],h.prototype,"xrEnvironment",void 0),h};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var jr=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const Tm=100,Mm="https://www.gstatic.com/draco/versioned/decoders/1.5.6/",Rm="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/",Dm="https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js",Wr={AUTO:"auto",MANUAL:"manual"},Jl={AUTO:"auto",LAZY:"lazy",EAGER:"eager"},es=Symbol("defaultProgressBarElement"),Xr=Symbol("posterContainerElement"),ts=Symbol("defaultPosterElement"),Os=Symbol("shouldDismissPoster"),Zr=Symbol("hidePoster"),Pi=Symbol("modelIsRevealed"),eo=Symbol("updateProgressBar"),_m=Symbol("ariaLabelCallToAction"),to=Symbol("onProgress"),Lm=o=>{var e,t,s,i,n,r,a,A;class l extends o{constructor(...h){super(...h),this.poster=null,this.reveal=Wr.AUTO,this.loading=Jl.AUTO,this[e]=!1,this[t]=!1,this[s]=this.shadowRoot.querySelector(".slot.poster"),this[i]=this.shadowRoot.querySelector("#default-poster"),this[n]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[r]=this[ts].getAttribute("aria-label"),this[a]=ud(f=>{const I=this[es].parentNode;requestAnimationFrame(()=>{this[es].style.transform=`scaleX(${f})`,f===0&&(I.removeChild(this[es]),I.appendChild(this[es])),this[es].classList.toggle("hide",f===1)})},Tm),this[A]=f=>{const I=f.detail.totalProgress;I===1&&(this[eo].flush(),this.loaded&&(this[Os]||this.reveal===Wr.AUTO)&&this[Zr]()),this[eo](I),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:I}}))};const d=self.ModelViewerElement||{},u=d.dracoDecoderLocation||Mm;se.setDRACODecoderLocation(u);const g=d.ktx2TranscoderLocation||Rm;se.setKTX2TranscoderLocation(g),d.meshoptDecoderLocation&&se.setMeshoptDecoderLocation(d.meshoptDecoderLocation);const p=d.lottieLoaderLocation||Dm;Re.singleton.textureUtils.lottieLoaderUrl=p}static set dracoDecoderLocation(h){se.setDRACODecoderLocation(h)}static get dracoDecoderLocation(){return se.getDRACODecoderLocation()}static set ktx2TranscoderLocation(h){se.setKTX2TranscoderLocation(h)}static get ktx2TranscoderLocation(){return se.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(h){se.setMeshoptDecoderLocation(h)}static get meshoptDecoderLocation(){return se.getMeshoptDecoderLocation()}static set lottieLoaderLocation(h){Re.singleton.textureUtils.lottieLoaderUrl=h}static get lottieLoaderLocation(){return Re.singleton.textureUtils.lottieLoaderUrl}static mapURLs(h){Re.singleton.loader[xt].manager.setURLModifier(h)}dismissPoster(){this.loaded?this[Zr]():(this[Os]=!0,this[ls]())}showPoster(){const h=this[Xr];if(h.classList.contains("show"))return;h.classList.add("show"),this[He].classList.remove("show");const d=this[ts];d.removeAttribute("tabindex"),d.removeAttribute("aria-hidden");const u=this.modelIsVisible;this[Pi]=!1,this[dn](u)}getDimensions(){return dt(this[v].size)}getBoundingBoxCenter(){return dt(this[v].boundingBox.getCenter(new N))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[kt].addEventListener("progress",this[to])}disconnectedCallback(){super.disconnectedCallback(),this[kt].removeEventListener("progress",this[to])}async updated(h){super.updated(h),h.has("poster")&&this.poster!=null&&(this[ts].style.backgroundImage=`url(${this.poster})`),h.has("alt")&&this[ts].setAttribute("aria-label",this[Eo]),(h.has("reveal")||h.has("loading"))&&this[ls]()}[(e=Pi,t=Os,s=Xr,i=ts,n=es,r=_m,a=eo,A=to,gs)](){return!!this.src&&(this[Os]||this.loading===Jl.EAGER||this.reveal===Wr.AUTO&&this[Rt])}[Zr](){this[Os]=!1;const h=this[Xr];if(!h.classList.contains("show"))return;h.classList.remove("show"),this[He].classList.add("show");const d=this.modelIsVisible;this[Pi]=!0,this[dn](d);const u=this.getRootNode();u&&u.activeElement===this&&this[He].focus();const g=this[ts];g.setAttribute("aria-hidden","true"),g.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[Ut](){return super[Ut]()&&this[Pi]}}return jr([F({type:String})],l.prototype,"poster",void 0),jr([F({type:String})],l.prototype,"reveal",void 0),jr([F({type:String})],l.prototype,"loading",void 0),l};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var so=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const Fm=Math.PI/32,Nm=3e3,km={basis:[Sn(he(Fm,"rad"))],keywords:{auto:[null]}},ss=Symbol("autoRotateStartTime"),io=Symbol("radiansPerSecond"),jl=Symbol("syncRotationRate"),no=Symbol("onCameraChange"),Um=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=Nm,this.rotationPerSecond="auto",this[e]=performance.now(),this[t]=0,this[s]=r=>{this.autoRotate&&r.detail.source==="user-interaction"&&(this[ss]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[no]),this[ss]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[no]),this[ss]=performance.now()}updated(r){super.updated(r),r.has("autoRotate")&&(this[ss]=performance.now())}[(e=ss,t=io,jl)](r){this[io]=r[0]}[qe](r,a){if(super[qe](r,a),!this.autoRotate||!this[Ut]()||this[V].isPresenting)return;const A=Math.min(a,r-this[ss]-this.autoRotateDelay);A>0&&(this[v].yaw=this.turntableRotation+this[io]*A*.001)}get turntableRotation(){return this[v].yaw}resetTurntableRotation(r=0){this[v].yaw=r}}return s=no,so([F({type:Boolean,attribute:"auto-rotate"})],i.prototype,"autoRotate",void 0),so([F({type:Number,attribute:"auto-rotate-delay"})],i.prototype,"autoRotateDelay",void 0),so([At({intrinsics:km,updateHandler:jl}),F({type:String,attribute:"rotation-per-second"})],i.prototype,"rotationPerSecond",void 0),i};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Rh=zf(Tf(Um(Cd(_p(bm(Lm(Kf(hi))))))));customElements.define("model-viewer",Rh);const Gm=["src","disable-tap","exposure","shadow-intensity","autoplay","ar","ar-modes","skybox-image","environment-image"],Om={class:"annotation initial-load-banner"},Pm={class:"overlay-svg-wrapper"},Hm=["x1","y1","x2","y2"],$m={key:0},Vm=["x","y","width","height"],qm=["x","y"],Km=Fh({__name:"ModelViewerWrapper",props:{src:{}},emits:["load"],setup(o,{expose:e,emit:t}){Rh.modelCacheSize=0;const s=t,i=o,n=Cs(null),r=Cs(null),a=Cs(null);Nh(()=>{n.value&&(n.value.addEventListener("load",async()=>{if(!n.value)return;let w=n.value.querySelector(".initial-load-banner");w&&w.remove(),r.value=n.value[v],a.value=n.value[V],s("load")}),n.value.addEventListener("camera-change",u))});let A=1,l=Cs({});function c(w){return w.x+" "+w.y+" "+w.z}function h(w,m,E,B={"stroke-width":"2",stroke:"red"}){var x;if(!r.value||!((x=n.value)!=null&&x.shadowRoot))return null;let Q=A++,y="line"+Q+"_start",S="line"+Q+"_end";return r.value.addHotspot(new as({name:y,position:c(w)})),r.value.addHotspot(new as({name:S,position:c(m)})),l.value[Q]={startHotspot:n.value.shadowRoot.querySelector('slot[name="'+y+'"]').parentElement,endHotspot:n.value.shadowRoot.querySelector('slot[name="'+S+'"]').parentElement,start2D:[-1e3,-1e3],end2D:[-1e3,-1e3],centerText:E,centerTextSize:[0,0],lineAttrs:B},r.value.queueRender(),requestIdleCallback(()=>p(Q),{timeout:100}),Q}function d(w){var m,E;return!r.value||!(w in l.value)?!1:(r.value.removeHotspot(new as({name:"line"+w+"_start"})),(m=l.value[w].startHotspot.parentElement)==null||m.remove(),r.value.removeHotspot(new as({name:"line"+w+"_end"})),(E=l.value[w].endHotspot.parentElement)==null||E.remove(),delete l.value[w],r.value.queueRender(),!0)}function u(){for(let w in l.value)p(w)}let g=Cs(null);function p(w){if(!(w in l.value)||!n.value)return;let{x:m,y:E}=n.value.getBoundingClientRect(),{x:B,y:Q}=l.value[w].startHotspot.getBoundingClientRect();l.value[w].start2D=[B-m,Q-E];let{x:y,y:S}=l.value[w].endHotspot.getBoundingClientRect();if(l.value[w].end2D=[y-m,S-E],g.value&&l.value[w].centerText&&l.value[w].centerTextSize[0]===0){let x=g.value.getElementsByClassName("line"+w+"_text")[0];if(x){let R=x.getBBox();l.value[w].centerTextSize=[R.width,R.height]}}}function f(w){n.value?w(n.value):Ko(()=>n.value,m=>{m&&w(m)})}function I(w){return Object.entries(w)}e({elem:n,onElemReady:f,scene:r,renderer:a,addLine3D:h,removeLine3D:d});let{disableTap:C}=kh("disableTap");return Ko(C,w=>{var m,E;w?(m=n.value)==null||m.setAttribute("disable-tap",""):(E=n.value)==null||E.removeAttribute("disable-tap")}),(w,m)=>(Ke(),it(Mn,null,[ui("model-viewer",{ref_key:"elem",ref:n,style:{width:"100%",height:"100%"},src:i.src,alt:"The 3D model(s)","camera-controls":"","camera-orbit":"30deg 75deg auto","max-camera-orbit":"Infinity 180deg auto","min-camera-orbit":"-Infinity 0deg 5%","disable-tap":Se(C),exposure:Se(nt).exposure,"shadow-intensity":Se(nt).shadowIntensity,"interaction-prompt":"none",autoplay:Se(nt).autoplay,ar:Se(nt).arModes.length>0,"ar-modes":Se(nt).arModes,"skybox-image":Se(nt).background,"environment-image":Se(nt).background},[Uh(w.$slots,"default",{},void 0,!0),ui("div",Om,[zo(" Trying to load models from... "),(Ke(!0),it(Mn,null,Yo(Se(nt).preload,E=>(Ke(),Gh(Se(Hu),{key:E},{default:Jo(()=>[Oh(Se(Pu),null,{default:Jo(()=>[zo(jo(E),1)]),_:2},1024)]),_:2},1024))),128))])],8,Gm),ui("div",Pm,[(Ke(),it("svg",{ref_key:"svg",ref:g,class:"overlay-svg",width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg"},[(Ke(!0),it(Mn,null,Yo(I(Se(l)),([E,B])=>(Ke(),it("g",{key:E},[ui("line",Ph({x1:B.start2D[0],y1:B.start2D[1],x2:B.end2D[0],y2:B.end2D[1]},B.lineAttrs),null,16,Hm),B.centerText!==void 0?(Ke(),it("g",$m,[B.centerText?(Ke(),it("rect",{key:0,x:(B.start2D[0]+B.end2D[0])/2-B.centerTextSize[0]/2-4,y:(B.start2D[1]+B.end2D[1])/2-B.centerTextSize[1]/2-2,width:B.centerTextSize[0]+8,height:B.centerTextSize[1]+4,fill:"gray","fill-opacity":"0.75",rx:"4",ry:"4",stroke:"black"},null,8,Vm)):Rn("",!0),B.centerText?(Ke(),it("text",{key:1,x:(B.start2D[0]+B.end2D[0])/2,y:(B.start2D[1]+B.end2D[1])/2,"text-anchor":"middle","dominant-baseline":"middle","font-size":"16",fill:"black",class:Hh("line"+E+"_text")},jo(B.centerText),11,qm)):Rn("",!0)])):Rn("",!0)]))),128))],512))])],64))}}),hI=$h(Km,[["__scopeId","data-v-c8987e41"]]);export{hI as default};
