shop-components 0.4.14 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var sn=Object.create;var wi=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var on=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var ln=(o,e,t)=>e in o?wi(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var cn=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of nn(e))!an.call(o,s)&&s!==t&&wi(o,s,{get:()=>e[s],enumerable:!(i=rn(e,s))||i.enumerable});return o};var un=(o,e,t)=>(t=o!=null?sn(on(o)):{},cn(e||!o||!o.__esModule?wi(t,"default",{value:o,enumerable:!0}):t,o));var P=(o,e,t)=>(ln(o,typeof e!="symbol"?e+"":e,t),t),Ss=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var V=(o,e,t)=>(Ss(o,e,"read from private field"),t?t.call(o):e.get(o)),Me=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},me=(o,e,t,i)=>(Ss(o,e,"write to private field"),i?i.call(o,t):e.set(o,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three"),Ms=require("three/examples/jsm/loaders/HDRLoader.js"),hn=require("three/examples/jsm/controls/OrbitControls"),ve=require("three/examples/jsm/renderers/CSS2DRenderer"),fn=require("three/examples/jsm/loaders/FontLoader"),us=require("three/examples/jsm/loaders/GLTFLoader.js"),dn=require("three/examples/jsm/libs/meshopt_decoder.module.js"),pn=require("three/examples/jsm/loaders/DRACOLoader.js"),mn=require("three/examples/jsm/loaders/GLTFLoader"),gn=require("three/examples/jsm/loaders/DRACOLoader"),vn=require("three/examples/jsm/exporters/DRACOExporter"),_n=require("three/examples/jsm/exporters/GLTFExporter"),yn=require("three/examples/jsm/utils/SkeletonUtils.js"),xn=require("three/examples/jsm/lines/Line2.js"),wn=require("three/examples/jsm/lines/LineMaterial.js"),Cs=require("three/examples/jsm/lines/LineGeometry.js"),bn=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const Vt=require("three/examples/jsm/postprocessing/Pass"),Le=require("three-mesh-bvh"),dt=require("three/examples/jsm/postprocessing/Pass.js");var pt=typeof document<"u"?document.currentScript:null;function wr(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const k=wr(d),bi=wr(yn);function br(o,e,t=0){if(o.isInterleavedBufferAttribute){const i=o.itemSize;for(let s=0,a=o.count;s<a;s++){const n=s+t;e.setX(n,o.getX(s)),i>=2&&e.setY(n,o.getY(s)),i>=3&&e.setZ(n,o.getZ(s)),i>=4&&e.setW(n,o.getW(s))}}else{const i=e.array,s=i.constructor,a=i.BYTES_PER_ELEMENT*o.itemSize*t;new s(i.buffer,a,o.array.length).set(o.array)}}function Dt(o,e=null){const t=o.array.constructor,i=o.normalized,s=o.itemSize,a=e===null?o.count:e;return new d.BufferAttribute(new t(s*a),s,i)}function ot(o,e){if(!o&&!e)return!0;if(!!o!=!!e)return!1;const t=o.count===e.count,i=o.normalized===e.normalized,s=o.array.constructor===e.array.constructor,a=o.itemSize===e.itemSize;return!(!t||!i||!s||!a)}function An(o){const e=o[0].index!==null,t=new Set(Object.keys(o[0].attributes));if(!o[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<o.length;++i){const s=o[i];let a=0;if(e!==(s.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const n in s.attributes){if(!t.has(n))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+n+'" attribute exists among all geometries, or in none of them.');a++}if(a!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function Tn(o){let e=0;for(let t=0,i=o.length;t<i;t++)e+=o[t].getIndex().count;return e}function Sn(o){let e=0;for(let t=0,i=o.length;t<i;t++)e+=o[t].getAttribute("position").count;return e}function Mn(o,e,t){o.index&&o.index.count!==e&&o.setIndex(null);const i=o.attributes;for(const s in i)i[s].count!==t&&o.deleteAttribute(s)}function Cn(o,e={},t=new d.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:a=[],overwriteIndex:n=!0}=e;An(o);const c=o[0].index!==null,u=c?Tn(o):-1,f=Sn(o);if(Mn(t,u,f),i){let r=0;for(let l=0,h=o.length;l<h;l++){const g=o[l];let _;c?_=g.getIndex().count:_=g.getAttribute("position").count,t.addGroup(r,_,l),r+=_}}if(c){let r=!1;if(t.index||(t.setIndex(new d.BufferAttribute(new Uint32Array(u),1,!1)),r=!0),r||n){let l=0,h=0;const g=t.getIndex();for(let _=0,m=o.length;_<m;_++){const v=o[_],y=v.getIndex();if(!(!s&&!r&&a[_]))for(let w=0;w<y.count;++w)g.setX(l+w,y.getX(w)+h);l+=y.count,h+=v.getAttribute("position").count}}}const p=Object.keys(o[0].attributes);for(let r=0,l=p.length;r<l;r++){let h=!1;const g=p[r];if(!t.getAttribute(g)){const v=o[0].getAttribute(g);t.setAttribute(g,Dt(v,f)),h=!0}let _=0;const m=t.getAttribute(g);for(let v=0,y=o.length;v<y;v++){const x=o[v],w=!s&&!h&&a[v],b=x.getAttribute(g);w||br(b,m,_),_+=b.count}}}function Rn(o,e,t){const i=o.index,a=o.attributes.position.count,n=i?i.count:a;let c=o.groups;c.length===0&&(c=[{count:n,start:0,materialIndex:0}]);let u=o.getAttribute("materialIndex");if(!u||u.count!==a){let p;t.length<=255?p=new Uint8Array(a):p=new Uint16Array(a),u=new d.BufferAttribute(p,1,!1),o.deleteAttribute("materialIndex"),o.setAttribute("materialIndex",u)}const f=u.array;for(let p=0;p<c.length;p++){const r=c[p],l=r.start,h=r.count,g=Math.min(h,n-l),_=Array.isArray(e)?e[r.materialIndex]:e,m=t.indexOf(_);for(let v=0;v<g;v++){let y=l+v;i&&(y=i.getX(y)),f[y]=m}}}function In(o,e){if(!o.index){const t=o.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;o.setIndex(i)}if(!o.attributes.normal&&e&&e.includes("normal")&&o.computeVertexNormals(),!o.attributes.uv&&e&&e.includes("uv")){const t=o.attributes.position.count;o.setAttribute("uv",new d.BufferAttribute(new Float32Array(t*2),2,!1))}if(!o.attributes.uv2&&e&&e.includes("uv2")){const t=o.attributes.position.count;o.setAttribute("uv2",new d.BufferAttribute(new Float32Array(t*2),2,!1))}if(!o.attributes.tangent&&e&&e.includes("tangent"))if(o.attributes.uv&&o.attributes.normal)o.computeTangents();else{const t=o.attributes.position.count;o.setAttribute("tangent",new d.BufferAttribute(new Float32Array(t*4),4,!1))}if(!o.attributes.color&&e&&e.includes("color")){const t=o.attributes.position.count,i=new Float32Array(t*4);i.fill(1),o.setAttribute("color",new d.BufferAttribute(i,4))}}function hs(o){let e=0;if(o.byteLength!==0){const t=new Uint8Array(o);for(let i=0;i<o.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function Rs(o){let e=o.uuid;const t=Object.values(o.attributes);o.index&&(t.push(o.index),e+=`index|${o.index.version}`);const i=Object.keys(t).sort();for(const s of i){const a=t[s];e+=`${s}_${a.version}|`}return e}function Is(o){const e=o.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${hs(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Dn{constructor(e=null){this.matrixWorld=new d.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=Rs(t),this.primitiveCount=i,this.skeletonHash=Is(e)}didChange(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===Rs(t)&&this.skeletonHash===Is(e)&&this.primitiveCount===i)}}const Be=new d.Vector3,Oe=new d.Vector3,ze=new d.Vector3,Ds=new d.Vector4,Ut=new d.Vector3,Ai=new d.Vector3,Ls=new d.Vector4,Ps=new d.Vector4,Wt=new d.Matrix4,Fs=new d.Matrix4;function Es(o,e,t){const i=o.skeleton,s=o.geometry,a=i.bones,n=i.boneInverses;Ls.fromBufferAttribute(s.attributes.skinIndex,e),Ps.fromBufferAttribute(s.attributes.skinWeight,e),Wt.elements.fill(0);for(let c=0;c<4;c++){const u=Ps.getComponent(c);if(u!==0){const f=Ls.getComponent(c);Fs.multiplyMatrices(a[f].matrixWorld,n[f]),Ln(Wt,Fs,u)}}return Wt.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse),t.transformDirection(Wt),t}function Ti(o,e,t,i,s){Ut.set(0,0,0);for(let a=0,n=o.length;a<n;a++){const c=e[a],u=o[a];c!==0&&(Ai.fromBufferAttribute(u,i),t?Ut.addScaledVector(Ai,c):Ut.addScaledVector(Ai.sub(s),c))}s.add(Ut)}function Ln(o,e,t){const i=o.elements,s=e.elements;for(let a=0,n=s.length;a<n;a++)i[a]+=s[a]*t}function Pn(o){const{index:e,attributes:t}=o;if(e)for(let i=0,s=e.count;i<s;i+=3){const a=e.getX(i),n=e.getX(i+2);e.setX(i,n),e.setX(i+2,a)}else for(const i in t){const s=t[i],a=s.itemSize;for(let n=0,c=s.count;n<c;n+=3)for(let u=0;u<a;u++){const f=s.getComponent(n,u),p=s.getComponent(n+2,u);s.setComponent(n,u,p),s.setComponent(n+2,u,f)}}return o}function Fn(o,e={},t=new d.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=o.geometry,s=e.applyWorldTransforms,a=e.attributes.includes("normal"),n=e.attributes.includes("tangent"),c=i.attributes,u=t.attributes;for(const y in t.attributes)(!e.attributes.includes(y)||!(y in i.attributes))&&t.deleteAttribute(y);!t.index&&i.index&&(t.index=i.index.clone()),u.position||t.setAttribute("position",Dt(c.position)),a&&!u.normal&&c.normal&&t.setAttribute("normal",Dt(c.normal)),n&&!u.tangent&&c.tangent&&t.setAttribute("tangent",Dt(c.tangent)),ot(i.index,t.index),ot(c.position,u.position),a&&ot(c.normal,u.normal),n&&ot(c.tangent,u.tangent);const f=c.position,p=a?c.normal:null,r=n?c.tangent:null,l=i.morphAttributes.position,h=i.morphAttributes.normal,g=i.morphAttributes.tangent,_=i.morphTargetsRelative,m=o.morphTargetInfluences,v=new d.Matrix3;v.getNormalMatrix(o.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,x=c.position.count;y<x;y++)Be.fromBufferAttribute(f,y),p&&Oe.fromBufferAttribute(p,y),r&&(Ds.fromBufferAttribute(r,y),ze.fromBufferAttribute(r,y)),m&&(l&&Ti(l,m,_,y,Be),h&&Ti(h,m,_,y,Oe),g&&Ti(g,m,_,y,ze)),o.isSkinnedMesh&&(o.applyBoneTransform(y,Be),p&&Es(o,y,Oe),r&&Es(o,y,ze)),s&&Be.applyMatrix4(o.matrixWorld),u.position.setXYZ(y,Be.x,Be.y,Be.z),p&&(s&&Oe.applyNormalMatrix(v),u.normal.setXYZ(y,Oe.x,Oe.y,Oe.z)),r&&(s&&ze.transformDirection(o.matrixWorld),u.tangent.setXYZW(y,ze.x,ze.y,ze.z,Ds.w));for(const y in e.attributes){const x=e.attributes[y];x==="position"||x==="tangent"||x==="normal"||!(x in c)||(u[x]||t.setAttribute(x,Dt(c[x])),ot(c[x],u[x]),br(c[x],u[x]))}return o.matrixWorld.determinant()<0&&Pn(t),t}class En extends d.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Dn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const a=t[s],n=i.attributes[a],c=this.attributes[a];if(n&&!ot(n,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(Fn(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const Ni=0,Ar=1,Tr=2;function kn(o,e){for(let t=0,i=o.length;t<i;t++)o[t].traverseVisible(a=>{a.isMesh&&e(a)})}function Bn(o){const e=[];for(let t=0,i=o.length;t<i;t++){const s=o[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function On(o,e,t){if(o.length===0){e.setIndex(null);const i=e.attributes;for(const s in i)e.deleteAttribute(s);for(const s in t.attributes)e.setAttribute(t.attributes[s],new d.BufferAttribute(new Float32Array(0),4,!1))}else Cn(o,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class zn{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new d.MeshBasicMaterial,t=new d.BufferGeometry;t.setAttribute("position",new d.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new d.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return kn(this.objects,t=>{e.push(t)}),e.sort((t,i)=>t.uuid>i.uuid?1:t.uuid<i.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,t=this._getMeshes(),i=new Set(e.keys()),s={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let a=0,n=t.length;a<n;a++){const c=t[a],u=c.uuid;i.delete(u);let f=e.get(u);(!f||!f.isCompatible(c,this.attributes))&&(f&&f.dispose(),f=new En,e.set(u,f)),f.updateFrom(c,s)&&this.generateMissingAttributes&&In(f,this.attributes)}i.forEach(a=>{e.delete(a)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new d.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:a}=this,n=this._getMeshes(),c=[],u=[],f=a.get(e)||[];this._updateIntermediateGeometries();let p=!1;n.length!==f.length&&(p=!0);for(let l=0,h=n.length;l<h;l++){const g=n[l],_=s.get(g.uuid);u.push(_);const m=f[l];!m||m.uuid!==_.uuid?(c.push(!1),p=!0):m.version!==_.version?c.push(!1):c.push(!0)}On(u,e,{useGroups:t,forceUpdate:p,skipAssigningAttributes:c,overwriteIndex:i}),p&&e.dispose(),a.set(e,u.map(l=>({version:l.version,uuid:l.uuid})));let r=Ni;return p?r=Tr:c.includes(!1)&&(r=Ar),{changeType:r,materials:Bn(n),geometry:e}}}function Vn(o){const e=new Set;for(let t=0,i=o.length;t<i;t++){const s=o[t];for(const a in s){const n=s[a];n&&n.isTexture&&e.add(n)}}return Array.from(e)}function Un(o){const e=[],t=new Set;for(let s=0,a=o.length;s<a;s++)o[s].traverse(n=>{n.visible&&(n.isRectAreaLight||n.isSpotLight||n.isPointLight||n.isDirectionalLight)&&(e.push(n),n.iesMap&&t.add(n.iesMap))});const i=Array.from(t).sort((s,a)=>s.uuid<a.uuid?1:s.uuid>a.uuid?-1:0);return{lights:e,iesTextures:i}}class Wn{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new d.BufferGeometry,this.staticGeometryGenerator=new zn(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(e=null){const{staticGeometryGenerator:t,geometry:i,attributes:s}=this,a=t.objects;t.attributes=s,a.forEach(r=>{r.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const n=t.generate(i),c=n.materials,u=Vn(c),{lights:f,iesTextures:p}=Un(a);if(n.changeType!==Ni&&Rn(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(n.changeType===Tr){const r={strategy:Le.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,r):this.bvh=new Le.MeshBVH(i,r)}else n.changeType===Ar&&this.bvh.refit()}return{bvhChanged:n.changeType!==Ni,bvh:this.bvh,lights:f,iesTextures:p,geometry:i,materials:c,textures:u,objects:a}}}class fs extends d.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const t in this.uniforms)Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(i){this.uniforms[t].value=i}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}}class Hn extends fs{constructor(e){super({blending:d.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
1
+ "use strict";var Jr=Object.create;var vi=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty;var rn=(o,e,t)=>e in o?vi(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var nn=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of en(e))!sn.call(o,s)&&s!==t&&vi(o,s,{get:()=>e[s],enumerable:!(i=$r(e,s))||i.enumerable});return o};var on=(o,e,t)=>(t=o!=null?Jr(tn(o)):{},nn(e||!o||!o.__esModule?vi(t,"default",{value:o,enumerable:!0}):t,o));var P=(o,e,t)=>(rn(o,typeof e!="symbol"?e+"":e,t),t),ys=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var V=(o,e,t)=>(ys(o,e,"read from private field"),t?t.call(o):e.get(o)),Te=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},de=(o,e,t,i)=>(ys(o,e,"write to private field"),i?i.call(o,t):e.set(o,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),xs=require("three/examples/jsm/loaders/HDRLoader.js"),an=require("three/examples/jsm/controls/OrbitControls"),me=require("three/examples/jsm/renderers/CSS2DRenderer"),ln=require("three/examples/jsm/loaders/FontLoader"),ns=require("three/examples/jsm/loaders/GLTFLoader.js");require("three/examples/jsm/libs/meshopt_decoder.module.js");require("three/examples/jsm/loaders/DRACOLoader.js");const cn=require("three/examples/jsm/loaders/GLTFLoader"),un=require("three/examples/jsm/loaders/DRACOLoader"),hn=require("three/examples/jsm/exporters/DRACOExporter"),fn=require("three/examples/jsm/exporters/GLTFExporter"),dn=require("three/examples/jsm/utils/SkeletonUtils.js"),pn=require("three/examples/jsm/lines/Line2.js"),mn=require("three/examples/jsm/lines/LineMaterial.js"),ws=require("three/examples/jsm/lines/LineGeometry.js"),gn=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const Ot=require("three/examples/jsm/postprocessing/Pass"),Ie=require("three-mesh-bvh"),ht=require("three/examples/jsm/postprocessing/Pass.js");var ft=typeof document<"u"?document.currentScript:null;function mr(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const B=mr(f),_i=mr(dn);function gr(o,e,t=0){if(o.isInterleavedBufferAttribute){const i=o.itemSize;for(let s=0,a=o.count;s<a;s++){const n=s+t;e.setX(n,o.getX(s)),i>=2&&e.setY(n,o.getY(s)),i>=3&&e.setZ(n,o.getZ(s)),i>=4&&e.setW(n,o.getW(s))}}else{const i=e.array,s=i.constructor,a=i.BYTES_PER_ELEMENT*o.itemSize*t;new s(i.buffer,a,o.array.length).set(o.array)}}function Rt(o,e=null){const t=o.array.constructor,i=o.normalized,s=o.itemSize,a=e===null?o.count:e;return new f.BufferAttribute(new t(s*a),s,i)}function rt(o,e){if(!o&&!e)return!0;if(!!o!=!!e)return!1;const t=o.count===e.count,i=o.normalized===e.normalized,s=o.array.constructor===e.array.constructor,a=o.itemSize===e.itemSize;return!(!t||!i||!s||!a)}function vn(o){const e=o[0].index!==null,t=new Set(Object.keys(o[0].attributes));if(!o[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<o.length;++i){const s=o[i];let a=0;if(e!==(s.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const n in s.attributes){if(!t.has(n))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+n+'" attribute exists among all geometries, or in none of them.');a++}if(a!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function _n(o){let e=0;for(let t=0,i=o.length;t<i;t++)e+=o[t].getIndex().count;return e}function yn(o){let e=0;for(let t=0,i=o.length;t<i;t++)e+=o[t].getAttribute("position").count;return e}function xn(o,e,t){o.index&&o.index.count!==e&&o.setIndex(null);const i=o.attributes;for(const s in i)i[s].count!==t&&o.deleteAttribute(s)}function wn(o,e={},t=new f.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:a=[],overwriteIndex:n=!0}=e;vn(o);const c=o[0].index!==null,u=c?_n(o):-1,d=yn(o);if(xn(t,u,d),i){let r=0;for(let l=0,h=o.length;l<h;l++){const g=o[l];let _;c?_=g.getIndex().count:_=g.getAttribute("position").count,t.addGroup(r,_,l),r+=_}}if(c){let r=!1;if(t.index||(t.setIndex(new f.BufferAttribute(new Uint32Array(u),1,!1)),r=!0),r||n){let l=0,h=0;const g=t.getIndex();for(let _=0,m=o.length;_<m;_++){const v=o[_],y=v.getIndex();if(!(!s&&!r&&a[_]))for(let w=0;w<y.count;++w)g.setX(l+w,y.getX(w)+h);l+=y.count,h+=v.getAttribute("position").count}}}const p=Object.keys(o[0].attributes);for(let r=0,l=p.length;r<l;r++){let h=!1;const g=p[r];if(!t.getAttribute(g)){const v=o[0].getAttribute(g);t.setAttribute(g,Rt(v,d)),h=!0}let _=0;const m=t.getAttribute(g);for(let v=0,y=o.length;v<y;v++){const x=o[v],w=!s&&!h&&a[v],b=x.getAttribute(g);w||gr(b,m,_),_+=b.count}}}function bn(o,e,t){const i=o.index,a=o.attributes.position.count,n=i?i.count:a;let c=o.groups;c.length===0&&(c=[{count:n,start:0,materialIndex:0}]);let u=o.getAttribute("materialIndex");if(!u||u.count!==a){let p;t.length<=255?p=new Uint8Array(a):p=new Uint16Array(a),u=new f.BufferAttribute(p,1,!1),o.deleteAttribute("materialIndex"),o.setAttribute("materialIndex",u)}const d=u.array;for(let p=0;p<c.length;p++){const r=c[p],l=r.start,h=r.count,g=Math.min(h,n-l),_=Array.isArray(e)?e[r.materialIndex]:e,m=t.indexOf(_);for(let v=0;v<g;v++){let y=l+v;i&&(y=i.getX(y)),d[y]=m}}}function An(o,e){if(!o.index){const t=o.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;o.setIndex(i)}if(!o.attributes.normal&&e&&e.includes("normal")&&o.computeVertexNormals(),!o.attributes.uv&&e&&e.includes("uv")){const t=o.attributes.position.count;o.setAttribute("uv",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!o.attributes.uv2&&e&&e.includes("uv2")){const t=o.attributes.position.count;o.setAttribute("uv2",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!o.attributes.tangent&&e&&e.includes("tangent"))if(o.attributes.uv&&o.attributes.normal)o.computeTangents();else{const t=o.attributes.position.count;o.setAttribute("tangent",new f.BufferAttribute(new Float32Array(t*4),4,!1))}if(!o.attributes.color&&e&&e.includes("color")){const t=o.attributes.position.count,i=new Float32Array(t*4);i.fill(1),o.setAttribute("color",new f.BufferAttribute(i,4))}}function os(o){let e=0;if(o.byteLength!==0){const t=new Uint8Array(o);for(let i=0;i<o.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function bs(o){let e=o.uuid;const t=Object.values(o.attributes);o.index&&(t.push(o.index),e+=`index|${o.index.version}`);const i=Object.keys(t).sort();for(const s of i){const a=t[s];e+=`${s}_${a.version}|`}return e}function As(o){const e=o.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${os(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Tn{constructor(e=null){this.matrixWorld=new f.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=bs(t),this.primitiveCount=i,this.skeletonHash=As(e)}didChange(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===bs(t)&&this.skeletonHash===As(e)&&this.primitiveCount===i)}}const Ee=new f.Vector3,Be=new f.Vector3,ke=new f.Vector3,Ts=new f.Vector4,zt=new f.Vector3,yi=new f.Vector3,Ss=new f.Vector4,Ms=new f.Vector4,Vt=new f.Matrix4,Cs=new f.Matrix4;function Rs(o,e,t){const i=o.skeleton,s=o.geometry,a=i.bones,n=i.boneInverses;Ss.fromBufferAttribute(s.attributes.skinIndex,e),Ms.fromBufferAttribute(s.attributes.skinWeight,e),Vt.elements.fill(0);for(let c=0;c<4;c++){const u=Ms.getComponent(c);if(u!==0){const d=Ss.getComponent(c);Cs.multiplyMatrices(a[d].matrixWorld,n[d]),Sn(Vt,Cs,u)}}return Vt.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse),t.transformDirection(Vt),t}function xi(o,e,t,i,s){zt.set(0,0,0);for(let a=0,n=o.length;a<n;a++){const c=e[a],u=o[a];c!==0&&(yi.fromBufferAttribute(u,i),t?zt.addScaledVector(yi,c):zt.addScaledVector(yi.sub(s),c))}s.add(zt)}function Sn(o,e,t){const i=o.elements,s=e.elements;for(let a=0,n=s.length;a<n;a++)i[a]+=s[a]*t}function Mn(o){const{index:e,attributes:t}=o;if(e)for(let i=0,s=e.count;i<s;i+=3){const a=e.getX(i),n=e.getX(i+2);e.setX(i,n),e.setX(i+2,a)}else for(const i in t){const s=t[i],a=s.itemSize;for(let n=0,c=s.count;n<c;n+=3)for(let u=0;u<a;u++){const d=s.getComponent(n,u),p=s.getComponent(n+2,u);s.setComponent(n,u,p),s.setComponent(n+2,u,d)}}return o}function Cn(o,e={},t=new f.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=o.geometry,s=e.applyWorldTransforms,a=e.attributes.includes("normal"),n=e.attributes.includes("tangent"),c=i.attributes,u=t.attributes;for(const y in t.attributes)(!e.attributes.includes(y)||!(y in i.attributes))&&t.deleteAttribute(y);!t.index&&i.index&&(t.index=i.index.clone()),u.position||t.setAttribute("position",Rt(c.position)),a&&!u.normal&&c.normal&&t.setAttribute("normal",Rt(c.normal)),n&&!u.tangent&&c.tangent&&t.setAttribute("tangent",Rt(c.tangent)),rt(i.index,t.index),rt(c.position,u.position),a&&rt(c.normal,u.normal),n&&rt(c.tangent,u.tangent);const d=c.position,p=a?c.normal:null,r=n?c.tangent:null,l=i.morphAttributes.position,h=i.morphAttributes.normal,g=i.morphAttributes.tangent,_=i.morphTargetsRelative,m=o.morphTargetInfluences,v=new f.Matrix3;v.getNormalMatrix(o.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,x=c.position.count;y<x;y++)Ee.fromBufferAttribute(d,y),p&&Be.fromBufferAttribute(p,y),r&&(Ts.fromBufferAttribute(r,y),ke.fromBufferAttribute(r,y)),m&&(l&&xi(l,m,_,y,Ee),h&&xi(h,m,_,y,Be),g&&xi(g,m,_,y,ke)),o.isSkinnedMesh&&(o.applyBoneTransform(y,Ee),p&&Rs(o,y,Be),r&&Rs(o,y,ke)),s&&Ee.applyMatrix4(o.matrixWorld),u.position.setXYZ(y,Ee.x,Ee.y,Ee.z),p&&(s&&Be.applyNormalMatrix(v),u.normal.setXYZ(y,Be.x,Be.y,Be.z)),r&&(s&&ke.transformDirection(o.matrixWorld),u.tangent.setXYZW(y,ke.x,ke.y,ke.z,Ts.w));for(const y in e.attributes){const x=e.attributes[y];x==="position"||x==="tangent"||x==="normal"||!(x in c)||(u[x]||t.setAttribute(x,Rt(c[x])),rt(c[x],u[x]),gr(c[x],u[x]))}return o.matrixWorld.determinant()<0&&Mn(t),t}class Rn extends f.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Tn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const a=t[s],n=i.attributes[a],c=this.attributes[a];if(n&&!rt(n,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(Cn(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const Vi=0,vr=1,_r=2;function In(o,e){for(let t=0,i=o.length;t<i;t++)o[t].traverseVisible(a=>{a.isMesh&&e(a)})}function Dn(o){const e=[];for(let t=0,i=o.length;t<i;t++){const s=o[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function Ln(o,e,t){if(o.length===0){e.setIndex(null);const i=e.attributes;for(const s in i)e.deleteAttribute(s);for(const s in t.attributes)e.setAttribute(t.attributes[s],new f.BufferAttribute(new Float32Array(0),4,!1))}else wn(o,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class Pn{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new f.MeshBasicMaterial,t=new f.BufferGeometry;t.setAttribute("position",new f.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new f.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return In(this.objects,t=>{e.push(t)}),e.sort((t,i)=>t.uuid>i.uuid?1:t.uuid<i.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,t=this._getMeshes(),i=new Set(e.keys()),s={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let a=0,n=t.length;a<n;a++){const c=t[a],u=c.uuid;i.delete(u);let d=e.get(u);(!d||!d.isCompatible(c,this.attributes))&&(d&&d.dispose(),d=new Rn,e.set(u,d)),d.updateFrom(c,s)&&this.generateMissingAttributes&&An(d,this.attributes)}i.forEach(a=>{e.delete(a)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new f.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:a}=this,n=this._getMeshes(),c=[],u=[],d=a.get(e)||[];this._updateIntermediateGeometries();let p=!1;n.length!==d.length&&(p=!0);for(let l=0,h=n.length;l<h;l++){const g=n[l],_=s.get(g.uuid);u.push(_);const m=d[l];!m||m.uuid!==_.uuid?(c.push(!1),p=!0):m.version!==_.version?c.push(!1):c.push(!0)}Ln(u,e,{useGroups:t,forceUpdate:p,skipAssigningAttributes:c,overwriteIndex:i}),p&&e.dispose(),a.set(e,u.map(l=>({version:l.version,uuid:l.uuid})));let r=Vi;return p?r=_r:c.includes(!1)&&(r=vr),{changeType:r,materials:Dn(n),geometry:e}}}function Fn(o){const e=new Set;for(let t=0,i=o.length;t<i;t++){const s=o[t];for(const a in s){const n=s[a];n&&n.isTexture&&e.add(n)}}return Array.from(e)}function En(o){const e=[],t=new Set;for(let s=0,a=o.length;s<a;s++)o[s].traverse(n=>{n.visible&&(n.isRectAreaLight||n.isSpotLight||n.isPointLight||n.isDirectionalLight)&&(e.push(n),n.iesMap&&t.add(n.iesMap))});const i=Array.from(t).sort((s,a)=>s.uuid<a.uuid?1:s.uuid>a.uuid?-1:0);return{lights:e,iesTextures:i}}class Bn{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new f.BufferGeometry,this.staticGeometryGenerator=new Pn(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(e=null){const{staticGeometryGenerator:t,geometry:i,attributes:s}=this,a=t.objects;t.attributes=s,a.forEach(r=>{r.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const n=t.generate(i),c=n.materials,u=Fn(c),{lights:d,iesTextures:p}=En(a);if(n.changeType!==Vi&&bn(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(n.changeType===_r){const r={strategy:Ie.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,r):this.bvh=new Ie.MeshBVH(i,r)}else n.changeType===vr&&this.bvh.refit()}return{bvhChanged:n.changeType!==Vi,bvh:this.bvh,lights:d,iesTextures:p,geometry:i,materials:c,textures:u,objects:a}}}class as extends f.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const t in this.uniforms)Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(i){this.uniforms[t].value=i}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}}class kn extends as{constructor(e){super({blending:f.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
2
2
 
3
3
  varying vec2 vUv;
4
4
 
@@ -35,7 +35,7 @@
35
35
 
36
36
  }
37
37
 
38
- }`}),this.setValues(e)}}function Ht(o=1){let e="uint";return o>1&&(e="uvec"+o),`
38
+ }`}),this.setValues(e)}}function Ut(o=1){let e="uint";return o>1&&(e="uvec"+o),`
39
39
  ${e} sobolReverseBits( ${e} x ) {
40
40
 
41
41
  x = ( ( ( x & 0xaaaaaaaau ) >> 1 ) | ( ( x & 0x55555555u ) << 1 ) );
@@ -70,7 +70,7 @@
70
70
  return x;
71
71
 
72
72
  }
73
- `}function Nt(o=1){let e="uint",t="float",i="",s=".r",a="1u";return o>1&&(e="uvec"+o,t="vec"+o,i=o+"",o===2?(s=".rg",a="uvec2( 1u, 2u )"):o===3?(s=".rgb",a="uvec3( 1u, 2u, 3u )"):(s="",a="uvec4( 1u, 2u, 3u, 4u )")),`
73
+ `}function Wt(o=1){let e="uint",t="float",i="",s=".r",a="1u";return o>1&&(e="uvec"+o,t="vec"+o,i=o+"",o===2?(s=".rg",a="uvec2( 1u, 2u )"):o===3?(s=".rgb",a="uvec3( 1u, 2u, 3u )"):(s="",a="uvec4( 1u, 2u, 3u, 4u )")),`
74
74
 
75
75
  ${t} sobol${i}( int effect ) {
76
76
 
@@ -88,16 +88,16 @@
88
88
  return SOBOL_FACTOR * ${t}( result >> 8 );
89
89
 
90
90
  }
91
- `}const Sr=`
91
+ `}const yr=`
92
92
 
93
93
  // Utils
94
94
  const float SOBOL_FACTOR = 1.0 / 16777216.0;
95
95
  const uint SOBOL_MAX_POINTS = 256u * 256u;
96
96
 
97
- ${Ht(1)}
98
- ${Ht(2)}
99
- ${Ht(3)}
100
- ${Ht(4)}
97
+ ${Ut(1)}
98
+ ${Ut(2)}
99
+ ${Ut(3)}
100
+ ${Ut(4)}
101
101
 
102
102
  uint sobolHash( uint x ) {
103
103
 
@@ -111,7 +111,7 @@
111
111
 
112
112
  }
113
113
 
114
- `,Nn=`
114
+ `,On=`
115
115
 
116
116
  const uint SOBOL_DIRECTIONS_1[ 32 ] = uint[ 32 ](
117
117
  0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,
@@ -189,7 +189,7 @@
189
189
 
190
190
  }
191
191
 
192
- `,Gn=`
192
+ `,zn=`
193
193
 
194
194
  // Seeds
195
195
  uniform sampler2D sobolTexture;
@@ -227,12 +227,12 @@
227
227
 
228
228
  }
229
229
 
230
- ${Nt(1)}
231
- ${Nt(2)}
232
- ${Nt(3)}
233
- ${Nt(4)}
230
+ ${Wt(1)}
231
+ ${Wt(2)}
232
+ ${Wt(3)}
233
+ ${Wt(4)}
234
234
 
235
- `;class qn extends fs{constructor(){super({blending:d.NoBlending,uniforms:{resolution:{value:new d.Vector2}},vertexShader:`
235
+ `;class Vn extends as{constructor(){super({blending:f.NoBlending,uniforms:{resolution:{value:new f.Vector2}},vertexShader:`
236
236
 
237
237
  varying vec2 vUv;
238
238
  void main() {
@@ -243,8 +243,8 @@
243
243
  }
244
244
  `,fragmentShader:`
245
245
 
246
- ${Sr}
247
- ${Nn}
246
+ ${yr}
247
+ ${On}
248
248
 
249
249
  varying vec2 vUv;
250
250
  uniform vec2 resolution;
@@ -254,7 +254,7 @@
254
254
  gl_FragColor = generateSobolPoint( index );
255
255
 
256
256
  }
257
- `})}}class jn{generate(e,t=256){const i=new d.WebGLRenderTarget(t,t,{type:d.FloatType,format:d.RGBAFormat,minFilter:d.NearestFilter,magFilter:d.NearestFilter,generateMipmaps:!1}),s=e.getRenderTarget();e.setRenderTarget(i);const a=new dt.FullScreenQuad(new qn);return a.material.resolution.set(t,t),a.render(e),e.setRenderTarget(s),a.dispose(),i}}class Qn extends d.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,t){return super.copy(e,t),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}}class Yn{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof Qn?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function Si(o){const e=new Uint16Array(o.length);for(let t=0,i=o.length;t<i;++t)e[t]=d.DataUtils.toHalfFloat(o[t]);return e}function ks(o,e,t=0,i=o.length){let s=t,a=t+i-1;for(;s<a;){const n=s+a>>1;o[n]<e?s=n+1:a=n}return s-t}function Zn(o,e,t){return .2126*o+.7152*e+.0722*t}function Kn(o,e=d.HalfFloatType){const t=o.clone();t.source=new d.Source({...t.image});const{width:i,height:s,data:a}=t.image;let n=a;if(t.type!==e){e===d.HalfFloatType?n=new Uint16Array(a.length):n=new Float32Array(a.length);let c;a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array?c=2**(8*a.BYTES_PER_ELEMENT-1)-1:c=2**(8*a.BYTES_PER_ELEMENT)-1;for(let u=0,f=a.length;u<f;u++){let p=a[u];t.type===d.HalfFloatType&&(p=d.DataUtils.fromHalfFloat(a[u])),t.type!==d.FloatType&&t.type!==d.HalfFloatType&&(p/=c),e===d.HalfFloatType&&(n[u]=d.DataUtils.toHalfFloat(p))}t.image.data=n,t.type=e}if(t.flipY){const c=n;n=n.slice();for(let u=0;u<s;u++)for(let f=0;f<i;f++){const p=s-u-1,r=4*(u*i+f),l=4*(p*i+f);n[l+0]=c[r+0],n[l+1]=c[r+1],n[l+2]=c[r+2],n[l+3]=c[r+3]}t.flipY=!1,t.image.data=n}return t}class Xn{constructor(){const e=new d.DataTexture(Si(new Float32Array([0,0,0,0])),1,1);e.type=d.HalfFloatType,e.format=d.RGBAFormat,e.minFilter=d.LinearFilter,e.magFilter=d.LinearFilter,e.wrapS=d.RepeatWrapping,e.wrapT=d.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const t=new d.DataTexture(Si(new Float32Array([0,1])),1,2);t.type=d.HalfFloatType,t.format=d.RedFormat,t.minFilter=d.LinearFilter,t.magFilter=d.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0;const i=new d.DataTexture(Si(new Float32Array([0,0,1,1])),2,2);i.type=d.HalfFloatType,i.format=d.RedFormat,i.minFilter=d.LinearFilter,i.magFilter=d.LinearFilter,i.generateMipmaps=!1,i.needsUpdate=!0,this.map=e,this.marginalWeights=t,this.conditionalWeights=i,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const t=Kn(e);t.wrapS=d.RepeatWrapping,t.wrapT=d.ClampToEdgeWrapping;const{width:i,height:s,data:a}=t.image,n=new Float32Array(i*s),c=new Float32Array(i*s),u=new Float32Array(s),f=new Float32Array(s);let p=0,r=0;for(let m=0;m<s;m++){let v=0;for(let y=0;y<i;y++){const x=m*i+y,w=d.DataUtils.fromHalfFloat(a[4*x+0]),b=d.DataUtils.fromHalfFloat(a[4*x+1]),A=d.DataUtils.fromHalfFloat(a[4*x+2]),S=Zn(w,b,A);v+=S,p+=S,n[x]=S,c[x]=v}if(v!==0)for(let y=m*i,x=m*i+i;y<x;y++)n[y]/=v,c[y]/=v;r+=v,u[m]=v,f[m]=r}if(r!==0)for(let m=0,v=u.length;m<v;m++)u[m]/=r,f[m]/=r;const l=new Uint16Array(s),h=new Uint16Array(i*s);for(let m=0;m<s;m++){const v=(m+1)/s,y=ks(f,v);l[m]=d.DataUtils.toHalfFloat((y+.5)/s)}for(let m=0;m<s;m++)for(let v=0;v<i;v++){const y=m*i+v,x=(v+1)/i,w=ks(c,x,m*i,i);h[y]=d.DataUtils.toHalfFloat((w+.5)/i)}this.dispose();const{marginalWeights:g,conditionalWeights:_}=this;g.image={width:s,height:1,data:l},g.needsUpdate=!0,_.image={width:i,height:s,data:h},_.needsUpdate=!0,this.totalSum=p,this.map=t}}const Mi=6,Jn=0,$n=1,eo=2,to=3,io=4,ue=new d.Vector3,J=new d.Vector3,Bs=new d.Matrix4,je=new d.Quaternion,Os=new d.Vector3,Qe=new d.Vector3,so=new d.Vector3(0,1,0);class ro{constructor(){const e=new d.DataTexture(new Float32Array(4),1,1);e.format=d.RGBAFormat,e.type=d.FloatType,e.wrapS=d.ClampToEdgeWrapping,e.wrapT=d.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=d.NearestFilter,e.magFilter=d.NearestFilter,this.tex=e,this.count=0}updateFrom(e,t=[]){const i=this.tex,s=Math.max(e.length*Mi,1),a=Math.ceil(Math.sqrt(s));i.image.width!==a&&(i.dispose(),i.image.data=new Float32Array(a*a*4),i.image.width=a,i.image.height=a);const n=i.image.data;for(let u=0,f=e.length;u<f;u++){const p=e[u],r=u*Mi*4;let l=0;for(let g=0;g<Mi*4;g++)n[r+g]=0;p.getWorldPosition(J),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z;let h=Jn;if(p.isRectAreaLight&&p.isCircular?h=$n:p.isSpotLight?h=eo:p.isDirectionalLight?h=to:p.isPointLight&&(h=io),n[r+l++]=h,n[r+l++]=p.color.r,n[r+l++]=p.color.g,n[r+l++]=p.color.b,n[r+l++]=p.intensity,p.getWorldQuaternion(je),p.isRectAreaLight)ue.set(p.width,0,0).applyQuaternion(je),n[r+l++]=ue.x,n[r+l++]=ue.y,n[r+l++]=ue.z,l++,J.set(0,p.height,0).applyQuaternion(je),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z,n[r+l++]=ue.cross(J).length()*(p.isCircular?Math.PI/4:1);else if(p.isSpotLight){const g=p.radius||0;Os.setFromMatrixPosition(p.matrixWorld),Qe.setFromMatrixPosition(p.target.matrixWorld),Bs.lookAt(Os,Qe,so),je.setFromRotationMatrix(Bs),ue.set(1,0,0).applyQuaternion(je),n[r+l++]=ue.x,n[r+l++]=ue.y,n[r+l++]=ue.z,l++,J.set(0,1,0).applyQuaternion(je),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z,n[r+l++]=Math.PI*g*g,n[r+l++]=g,n[r+l++]=p.decay,n[r+l++]=p.distance,n[r+l++]=Math.cos(p.angle),n[r+l++]=Math.cos(p.angle*(1-p.penumbra)),n[r+l++]=p.iesMap?t.indexOf(p.iesMap):-1}else if(p.isPointLight){const g=ue.setFromMatrixPosition(p.matrixWorld);n[r+l++]=g.x,n[r+l++]=g.y,n[r+l++]=g.z,l++,l+=4,l+=1,n[r+l++]=p.decay,n[r+l++]=p.distance}else if(p.isDirectionalLight){const g=ue.setFromMatrixPosition(p.matrixWorld),_=J.setFromMatrixPosition(p.target.matrixWorld);Qe.subVectors(g,_).normalize(),n[r+l++]=Qe.x,n[r+l++]=Qe.y,n[r+l++]=Qe.z}}this.count=e.length;const c=hs(n.buffer);return this.hash!==c?(this.hash=c,i.needsUpdate=!0,!0):!1}}function zs(o,e,t,i,s){if(e>i)throw new Error;const a=o.length/e,n=o.constructor.BYTES_PER_ELEMENT*8;let c=1;switch(o.constructor){case Uint8Array:case Uint16Array:case Uint32Array:c=2**n-1;break;case Int8Array:case Int16Array:case Int32Array:c=2**(n-1)-1;break}for(let u=0;u<a;u++){const f=4*u,p=e*u;for(let r=0;r<i;r++)t[s+f+r]=e>=r+1?o[p+r]/c:0}}class no extends d.DataArrayTexture{constructor(){super(),this._textures=[],this.type=d.FloatType,this.format=d.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,t){const i=this._textures[e];i.updateFrom(t);const s=i.image,a=this.image;if(s.width!==a.width||s.height!==a.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:n,height:c,data:u}=a,p=n*c*4*e;let r=t.itemSize;r===3&&(r=4),zs(i.image.data,r,u,4,p),this.dispose(),this.needsUpdate=!0}setAttributes(e){const t=e[0].count,i=e.length;for(let r=0,l=i;r<l;r++)if(e[r].count!==t)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const s=this._textures;for(;s.length<i;){const r=new Le.FloatVertexAttributeTexture;s.push(r)}for(;s.length>i;)s.pop();for(let r=0,l=i;r<l;r++)s[r].updateFrom(e[r]);const n=s[0].image,c=this.image;(n.width!==c.width||n.height!==c.height||n.depth!==i)&&(c.width=n.width,c.height=n.height,c.depth=i,c.data=new Float32Array(c.width*c.height*c.depth*4));const{data:u,width:f,height:p}=c;for(let r=0,l=i;r<l;r++){const h=s[r],_=f*p*4*r;let m=e[r].itemSize;m===3&&(m=4),zs(h.image.data,m,u,4,_)}this.dispose(),this.needsUpdate=!0}}class oo extends no{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,t,i,s){this.setAttributes([e,t,i,s])}}function ds(o,e){return o.uuid<e.uuid?1:o.uuid>e.uuid?-1:0}function Gi(o){return`${o.source.uuid}:${o.colorSpace}`}function ao(o){const e=new Set,t=[];for(let i=0,s=o.length;i<s;i++){const a=o[i],n=Gi(a);e.has(n)||(e.add(n),t.push(a))}return t}function lo(o){const e=o.map(i=>i.iesMap||null).filter(i=>i),t=new Set(e);return Array.from(t).sort(ds)}function co(o){const e=new Set;for(let i=0,s=o.length;i<s;i++){const a=o[i];for(const n in a){const c=a[n];c&&c.isTexture&&e.add(c)}}const t=Array.from(e);return ao(t).sort(ds)}function uo(o){const e=[];return o.traverse(t=>{t.visible&&(t.isRectAreaLight||t.isSpotLight||t.isPointLight||t.isDirectionalLight)&&e.push(t)}),e.sort(ds)}const Mr=45,Vs=Mr*4;class ho{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,t=!0){t===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class fo extends d.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=d.RGBAFormat,this.type=d.FloatType,this.wrapS=d.ClampToEdgeWrapping,this.wrapT=d.ClampToEdgeWrapping,this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.generateMipmaps=!1,this.features=new ho}updateFrom(e,t){function i(g,_,m=-1){if(_ in g&&g[_]){const v=Gi(g[_]);return r[v]}else return m}function s(g,_,m){return _ in g?g[_]:m}function a(g,_,m,v){const y=g[_]&&g[_].isTexture?g[_]:null;if(y){y.matrixAutoUpdate&&y.updateMatrix();const x=y.matrix.elements;let w=0;m[v+w++]=x[0],m[v+w++]=x[3],m[v+w++]=x[6],w++,m[v+w++]=x[1],m[v+w++]=x[4],m[v+w++]=x[7],w++}return 8}let n=0;const c=e.length*Mr,u=Math.ceil(Math.sqrt(c))||1,{image:f,features:p}=this,r={};for(let g=0,_=t.length;g<_;g++)r[Gi(t[g])]=g;f.width!==u&&(this.dispose(),f.data=new Float32Array(u*u*4),f.width=u,f.height=u);const l=f.data;p.reset();for(let g=0,_=e.length;g<_;g++){const m=e[g];if(m.isFogVolumeMaterial){p.setUsed("FOG");for(let x=0;x<Vs;x++)l[n+x]=0;l[n+0*4+0]=m.color.r,l[n+0*4+1]=m.color.g,l[n+0*4+2]=m.color.b,l[n+2*4+3]=s(m,"emissiveIntensity",0),l[n+3*4+0]=m.emissive.r,l[n+3*4+1]=m.emissive.g,l[n+3*4+2]=m.emissive.b,l[n+13*4+1]=m.density,l[n+13*4+3]=0,l[n+14*4+2]=4,n+=Vs;continue}l[n++]=m.color.r,l[n++]=m.color.g,l[n++]=m.color.b,l[n++]=i(m,"map"),l[n++]=s(m,"metalness",0),l[n++]=i(m,"metalnessMap"),l[n++]=s(m,"roughness",0),l[n++]=i(m,"roughnessMap"),l[n++]=s(m,"ior",1.5),l[n++]=s(m,"transmission",0),l[n++]=i(m,"transmissionMap"),l[n++]=s(m,"emissiveIntensity",0),"emissive"in m?(l[n++]=m.emissive.r,l[n++]=m.emissive.g,l[n++]=m.emissive.b):(l[n++]=0,l[n++]=0,l[n++]=0),l[n++]=i(m,"emissiveMap"),l[n++]=i(m,"normalMap"),"normalScale"in m?(l[n++]=m.normalScale.x,l[n++]=m.normalScale.y):(l[n++]=1,l[n++]=1),l[n++]=s(m,"clearcoat",0),l[n++]=i(m,"clearcoatMap"),l[n++]=s(m,"clearcoatRoughness",0),l[n++]=i(m,"clearcoatRoughnessMap"),l[n++]=i(m,"clearcoatNormalMap"),"clearcoatNormalScale"in m?(l[n++]=m.clearcoatNormalScale.x,l[n++]=m.clearcoatNormalScale.y):(l[n++]=1,l[n++]=1),n++,l[n++]=s(m,"sheen",0),"sheenColor"in m?(l[n++]=m.sheenColor.r,l[n++]=m.sheenColor.g,l[n++]=m.sheenColor.b):(l[n++]=0,l[n++]=0,l[n++]=0),l[n++]=i(m,"sheenColorMap"),l[n++]=s(m,"sheenRoughness",0),l[n++]=i(m,"sheenRoughnessMap"),l[n++]=i(m,"iridescenceMap"),l[n++]=i(m,"iridescenceThicknessMap"),l[n++]=s(m,"iridescence",0),l[n++]=s(m,"iridescenceIOR",1.3);const v=s(m,"iridescenceThicknessRange",[100,400]);l[n++]=v[0],l[n++]=v[1],"specularColor"in m?(l[n++]=m.specularColor.r,l[n++]=m.specularColor.g,l[n++]=m.specularColor.b):(l[n++]=1,l[n++]=1,l[n++]=1),l[n++]=i(m,"specularColorMap"),l[n++]=s(m,"specularIntensity",1),l[n++]=i(m,"specularIntensityMap");const y=s(m,"thickness",0)===0&&s(m,"attenuationDistance",1/0)===1/0;if(l[n++]=Number(y),n++,"attenuationColor"in m?(l[n++]=m.attenuationColor.r,l[n++]=m.attenuationColor.g,l[n++]=m.attenuationColor.b):(l[n++]=1,l[n++]=1,l[n++]=1),l[n++]=s(m,"attenuationDistance",1/0),l[n++]=i(m,"alphaMap"),l[n++]=m.opacity,l[n++]=m.alphaTest,!y&&m.transmission>0)l[n++]=0;else switch(m.side){case d.FrontSide:l[n++]=1;break;case d.BackSide:l[n++]=-1;break;case d.DoubleSide:l[n++]=0;break}l[n++]=Number(s(m,"matte",!1)),l[n++]=Number(s(m,"castShadow",!0)),l[n++]=Number(m.vertexColors)|Number(m.flatShading)<<1,l[n++]=Number(m.transparent),n+=a(m,"map",l,n),n+=a(m,"metalnessMap",l,n),n+=a(m,"roughnessMap",l,n),n+=a(m,"transmissionMap",l,n),n+=a(m,"emissiveMap",l,n),n+=a(m,"normalMap",l,n),n+=a(m,"clearcoatMap",l,n),n+=a(m,"clearcoatNormalMap",l,n),n+=a(m,"clearcoatRoughnessMap",l,n),n+=a(m,"sheenColorMap",l,n),n+=a(m,"sheenRoughnessMap",l,n),n+=a(m,"iridescenceMap",l,n),n+=a(m,"iridescenceThicknessMap",l,n),n+=a(m,"specularColorMap",l,n),n+=a(m,"specularIntensityMap",l,n)}const h=hs(l.buffer);return this.hash!==h?(this.hash=h,this.needsUpdate=!0,!0):!1}}const Us=new d.Color;function po(o){return o?`${o.uuid}:${o.version}`:null}function mo(o,e){for(const t in e)t in o&&(o[t]=e[t])}class Ws extends d.WebGLArrayRenderTarget{constructor(e,t,i){const s={format:d.RGBAFormat,type:d.UnsignedByteType,minFilter:d.LinearFilter,magFilter:d.LinearFilter,wrapS:d.RepeatWrapping,wrapT:d.RepeatWrapping,generateMipmaps:!1,...i};super(e,t,1,s),mo(this.texture,s),this.texture.setTextures=(...n)=>{this.setTextures(...n)},this.hashes=[null];const a=new dt.FullScreenQuad(new go);this.fsQuad=a}setTextures(e,t,i=this.width,s=this.height){const a=e.getRenderTarget(),n=e.toneMapping,c=e.getClearAlpha();e.getClearColor(Us);const u=t.length||1;(i!==this.width||s!==this.height||this.depth!==u)&&(this.setSize(i,s,u),this.hashes=new Array(u).fill(null)),e.setClearColor(0,0),e.toneMapping=d.NoToneMapping;const f=this.fsQuad,p=this.hashes;let r=!1;for(let l=0,h=u;l<h;l++){const g=t[l],_=po(g);g&&(p[l]!==_||g.isWebGLRenderTarget)&&(g.matrixAutoUpdate=!1,g.matrix.identity(),f.material.map=g,e.setRenderTarget(this,l),f.render(e),g.updateMatrix(),g.matrixAutoUpdate=!0,p[l]=_,r=!0)}return f.material.map=null,e.setClearColor(Us,c),e.setRenderTarget(a),e.toneMapping=n,r}dispose(){super.dispose(),this.fsQuad.dispose()}}class go extends d.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
257
+ `})}}class Un{generate(e,t=256){const i=new f.WebGLRenderTarget(t,t,{type:f.FloatType,format:f.RGBAFormat,minFilter:f.NearestFilter,magFilter:f.NearestFilter,generateMipmaps:!1}),s=e.getRenderTarget();e.setRenderTarget(i);const a=new ht.FullScreenQuad(new Vn);return a.material.resolution.set(t,t),a.render(e),e.setRenderTarget(s),a.dispose(),i}}class Wn extends f.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,t){return super.copy(e,t),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}}class Hn{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof Wn?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function wi(o){const e=new Uint16Array(o.length);for(let t=0,i=o.length;t<i;++t)e[t]=f.DataUtils.toHalfFloat(o[t]);return e}function Is(o,e,t=0,i=o.length){let s=t,a=t+i-1;for(;s<a;){const n=s+a>>1;o[n]<e?s=n+1:a=n}return s-t}function Nn(o,e,t){return .2126*o+.7152*e+.0722*t}function Gn(o,e=f.HalfFloatType){const t=o.clone();t.source=new f.Source({...t.image});const{width:i,height:s,data:a}=t.image;let n=a;if(t.type!==e){e===f.HalfFloatType?n=new Uint16Array(a.length):n=new Float32Array(a.length);let c;a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array?c=2**(8*a.BYTES_PER_ELEMENT-1)-1:c=2**(8*a.BYTES_PER_ELEMENT)-1;for(let u=0,d=a.length;u<d;u++){let p=a[u];t.type===f.HalfFloatType&&(p=f.DataUtils.fromHalfFloat(a[u])),t.type!==f.FloatType&&t.type!==f.HalfFloatType&&(p/=c),e===f.HalfFloatType&&(n[u]=f.DataUtils.toHalfFloat(p))}t.image.data=n,t.type=e}if(t.flipY){const c=n;n=n.slice();for(let u=0;u<s;u++)for(let d=0;d<i;d++){const p=s-u-1,r=4*(u*i+d),l=4*(p*i+d);n[l+0]=c[r+0],n[l+1]=c[r+1],n[l+2]=c[r+2],n[l+3]=c[r+3]}t.flipY=!1,t.image.data=n}return t}class qn{constructor(){const e=new f.DataTexture(wi(new Float32Array([0,0,0,0])),1,1);e.type=f.HalfFloatType,e.format=f.RGBAFormat,e.minFilter=f.LinearFilter,e.magFilter=f.LinearFilter,e.wrapS=f.RepeatWrapping,e.wrapT=f.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const t=new f.DataTexture(wi(new Float32Array([0,1])),1,2);t.type=f.HalfFloatType,t.format=f.RedFormat,t.minFilter=f.LinearFilter,t.magFilter=f.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0;const i=new f.DataTexture(wi(new Float32Array([0,0,1,1])),2,2);i.type=f.HalfFloatType,i.format=f.RedFormat,i.minFilter=f.LinearFilter,i.magFilter=f.LinearFilter,i.generateMipmaps=!1,i.needsUpdate=!0,this.map=e,this.marginalWeights=t,this.conditionalWeights=i,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const t=Gn(e);t.wrapS=f.RepeatWrapping,t.wrapT=f.ClampToEdgeWrapping;const{width:i,height:s,data:a}=t.image,n=new Float32Array(i*s),c=new Float32Array(i*s),u=new Float32Array(s),d=new Float32Array(s);let p=0,r=0;for(let m=0;m<s;m++){let v=0;for(let y=0;y<i;y++){const x=m*i+y,w=f.DataUtils.fromHalfFloat(a[4*x+0]),b=f.DataUtils.fromHalfFloat(a[4*x+1]),A=f.DataUtils.fromHalfFloat(a[4*x+2]),S=Nn(w,b,A);v+=S,p+=S,n[x]=S,c[x]=v}if(v!==0)for(let y=m*i,x=m*i+i;y<x;y++)n[y]/=v,c[y]/=v;r+=v,u[m]=v,d[m]=r}if(r!==0)for(let m=0,v=u.length;m<v;m++)u[m]/=r,d[m]/=r;const l=new Uint16Array(s),h=new Uint16Array(i*s);for(let m=0;m<s;m++){const v=(m+1)/s,y=Is(d,v);l[m]=f.DataUtils.toHalfFloat((y+.5)/s)}for(let m=0;m<s;m++)for(let v=0;v<i;v++){const y=m*i+v,x=(v+1)/i,w=Is(c,x,m*i,i);h[y]=f.DataUtils.toHalfFloat((w+.5)/i)}this.dispose();const{marginalWeights:g,conditionalWeights:_}=this;g.image={width:s,height:1,data:l},g.needsUpdate=!0,_.image={width:i,height:s,data:h},_.needsUpdate=!0,this.totalSum=p,this.map=t}}const bi=6,jn=0,Qn=1,Yn=2,Zn=3,Kn=4,ce=new f.Vector3,J=new f.Vector3,Ds=new f.Matrix4,Ge=new f.Quaternion,Ls=new f.Vector3,qe=new f.Vector3,Xn=new f.Vector3(0,1,0);class Jn{constructor(){const e=new f.DataTexture(new Float32Array(4),1,1);e.format=f.RGBAFormat,e.type=f.FloatType,e.wrapS=f.ClampToEdgeWrapping,e.wrapT=f.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=f.NearestFilter,e.magFilter=f.NearestFilter,this.tex=e,this.count=0}updateFrom(e,t=[]){const i=this.tex,s=Math.max(e.length*bi,1),a=Math.ceil(Math.sqrt(s));i.image.width!==a&&(i.dispose(),i.image.data=new Float32Array(a*a*4),i.image.width=a,i.image.height=a);const n=i.image.data;for(let u=0,d=e.length;u<d;u++){const p=e[u],r=u*bi*4;let l=0;for(let g=0;g<bi*4;g++)n[r+g]=0;p.getWorldPosition(J),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z;let h=jn;if(p.isRectAreaLight&&p.isCircular?h=Qn:p.isSpotLight?h=Yn:p.isDirectionalLight?h=Zn:p.isPointLight&&(h=Kn),n[r+l++]=h,n[r+l++]=p.color.r,n[r+l++]=p.color.g,n[r+l++]=p.color.b,n[r+l++]=p.intensity,p.getWorldQuaternion(Ge),p.isRectAreaLight)ce.set(p.width,0,0).applyQuaternion(Ge),n[r+l++]=ce.x,n[r+l++]=ce.y,n[r+l++]=ce.z,l++,J.set(0,p.height,0).applyQuaternion(Ge),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z,n[r+l++]=ce.cross(J).length()*(p.isCircular?Math.PI/4:1);else if(p.isSpotLight){const g=p.radius||0;Ls.setFromMatrixPosition(p.matrixWorld),qe.setFromMatrixPosition(p.target.matrixWorld),Ds.lookAt(Ls,qe,Xn),Ge.setFromRotationMatrix(Ds),ce.set(1,0,0).applyQuaternion(Ge),n[r+l++]=ce.x,n[r+l++]=ce.y,n[r+l++]=ce.z,l++,J.set(0,1,0).applyQuaternion(Ge),n[r+l++]=J.x,n[r+l++]=J.y,n[r+l++]=J.z,n[r+l++]=Math.PI*g*g,n[r+l++]=g,n[r+l++]=p.decay,n[r+l++]=p.distance,n[r+l++]=Math.cos(p.angle),n[r+l++]=Math.cos(p.angle*(1-p.penumbra)),n[r+l++]=p.iesMap?t.indexOf(p.iesMap):-1}else if(p.isPointLight){const g=ce.setFromMatrixPosition(p.matrixWorld);n[r+l++]=g.x,n[r+l++]=g.y,n[r+l++]=g.z,l++,l+=4,l+=1,n[r+l++]=p.decay,n[r+l++]=p.distance}else if(p.isDirectionalLight){const g=ce.setFromMatrixPosition(p.matrixWorld),_=J.setFromMatrixPosition(p.target.matrixWorld);qe.subVectors(g,_).normalize(),n[r+l++]=qe.x,n[r+l++]=qe.y,n[r+l++]=qe.z}}this.count=e.length;const c=os(n.buffer);return this.hash!==c?(this.hash=c,i.needsUpdate=!0,!0):!1}}function Ps(o,e,t,i,s){if(e>i)throw new Error;const a=o.length/e,n=o.constructor.BYTES_PER_ELEMENT*8;let c=1;switch(o.constructor){case Uint8Array:case Uint16Array:case Uint32Array:c=2**n-1;break;case Int8Array:case Int16Array:case Int32Array:c=2**(n-1)-1;break}for(let u=0;u<a;u++){const d=4*u,p=e*u;for(let r=0;r<i;r++)t[s+d+r]=e>=r+1?o[p+r]/c:0}}class $n extends f.DataArrayTexture{constructor(){super(),this._textures=[],this.type=f.FloatType,this.format=f.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,t){const i=this._textures[e];i.updateFrom(t);const s=i.image,a=this.image;if(s.width!==a.width||s.height!==a.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:n,height:c,data:u}=a,p=n*c*4*e;let r=t.itemSize;r===3&&(r=4),Ps(i.image.data,r,u,4,p),this.dispose(),this.needsUpdate=!0}setAttributes(e){const t=e[0].count,i=e.length;for(let r=0,l=i;r<l;r++)if(e[r].count!==t)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const s=this._textures;for(;s.length<i;){const r=new Ie.FloatVertexAttributeTexture;s.push(r)}for(;s.length>i;)s.pop();for(let r=0,l=i;r<l;r++)s[r].updateFrom(e[r]);const n=s[0].image,c=this.image;(n.width!==c.width||n.height!==c.height||n.depth!==i)&&(c.width=n.width,c.height=n.height,c.depth=i,c.data=new Float32Array(c.width*c.height*c.depth*4));const{data:u,width:d,height:p}=c;for(let r=0,l=i;r<l;r++){const h=s[r],_=d*p*4*r;let m=e[r].itemSize;m===3&&(m=4),Ps(h.image.data,m,u,4,_)}this.dispose(),this.needsUpdate=!0}}class eo extends $n{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,t,i,s){this.setAttributes([e,t,i,s])}}function ls(o,e){return o.uuid<e.uuid?1:o.uuid>e.uuid?-1:0}function Ui(o){return`${o.source.uuid}:${o.colorSpace}`}function to(o){const e=new Set,t=[];for(let i=0,s=o.length;i<s;i++){const a=o[i],n=Ui(a);e.has(n)||(e.add(n),t.push(a))}return t}function io(o){const e=o.map(i=>i.iesMap||null).filter(i=>i),t=new Set(e);return Array.from(t).sort(ls)}function so(o){const e=new Set;for(let i=0,s=o.length;i<s;i++){const a=o[i];for(const n in a){const c=a[n];c&&c.isTexture&&e.add(c)}}const t=Array.from(e);return to(t).sort(ls)}function ro(o){const e=[];return o.traverse(t=>{t.visible&&(t.isRectAreaLight||t.isSpotLight||t.isPointLight||t.isDirectionalLight)&&e.push(t)}),e.sort(ls)}const xr=45,Fs=xr*4;class no{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,t=!0){t===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class oo extends f.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=f.RGBAFormat,this.type=f.FloatType,this.wrapS=f.ClampToEdgeWrapping,this.wrapT=f.ClampToEdgeWrapping,this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.generateMipmaps=!1,this.features=new no}updateFrom(e,t){function i(g,_,m=-1){if(_ in g&&g[_]){const v=Ui(g[_]);return r[v]}else return m}function s(g,_,m){return _ in g?g[_]:m}function a(g,_,m,v){const y=g[_]&&g[_].isTexture?g[_]:null;if(y){y.matrixAutoUpdate&&y.updateMatrix();const x=y.matrix.elements;let w=0;m[v+w++]=x[0],m[v+w++]=x[3],m[v+w++]=x[6],w++,m[v+w++]=x[1],m[v+w++]=x[4],m[v+w++]=x[7],w++}return 8}let n=0;const c=e.length*xr,u=Math.ceil(Math.sqrt(c))||1,{image:d,features:p}=this,r={};for(let g=0,_=t.length;g<_;g++)r[Ui(t[g])]=g;d.width!==u&&(this.dispose(),d.data=new Float32Array(u*u*4),d.width=u,d.height=u);const l=d.data;p.reset();for(let g=0,_=e.length;g<_;g++){const m=e[g];if(m.isFogVolumeMaterial){p.setUsed("FOG");for(let x=0;x<Fs;x++)l[n+x]=0;l[n+0*4+0]=m.color.r,l[n+0*4+1]=m.color.g,l[n+0*4+2]=m.color.b,l[n+2*4+3]=s(m,"emissiveIntensity",0),l[n+3*4+0]=m.emissive.r,l[n+3*4+1]=m.emissive.g,l[n+3*4+2]=m.emissive.b,l[n+13*4+1]=m.density,l[n+13*4+3]=0,l[n+14*4+2]=4,n+=Fs;continue}l[n++]=m.color.r,l[n++]=m.color.g,l[n++]=m.color.b,l[n++]=i(m,"map"),l[n++]=s(m,"metalness",0),l[n++]=i(m,"metalnessMap"),l[n++]=s(m,"roughness",0),l[n++]=i(m,"roughnessMap"),l[n++]=s(m,"ior",1.5),l[n++]=s(m,"transmission",0),l[n++]=i(m,"transmissionMap"),l[n++]=s(m,"emissiveIntensity",0),"emissive"in m?(l[n++]=m.emissive.r,l[n++]=m.emissive.g,l[n++]=m.emissive.b):(l[n++]=0,l[n++]=0,l[n++]=0),l[n++]=i(m,"emissiveMap"),l[n++]=i(m,"normalMap"),"normalScale"in m?(l[n++]=m.normalScale.x,l[n++]=m.normalScale.y):(l[n++]=1,l[n++]=1),l[n++]=s(m,"clearcoat",0),l[n++]=i(m,"clearcoatMap"),l[n++]=s(m,"clearcoatRoughness",0),l[n++]=i(m,"clearcoatRoughnessMap"),l[n++]=i(m,"clearcoatNormalMap"),"clearcoatNormalScale"in m?(l[n++]=m.clearcoatNormalScale.x,l[n++]=m.clearcoatNormalScale.y):(l[n++]=1,l[n++]=1),n++,l[n++]=s(m,"sheen",0),"sheenColor"in m?(l[n++]=m.sheenColor.r,l[n++]=m.sheenColor.g,l[n++]=m.sheenColor.b):(l[n++]=0,l[n++]=0,l[n++]=0),l[n++]=i(m,"sheenColorMap"),l[n++]=s(m,"sheenRoughness",0),l[n++]=i(m,"sheenRoughnessMap"),l[n++]=i(m,"iridescenceMap"),l[n++]=i(m,"iridescenceThicknessMap"),l[n++]=s(m,"iridescence",0),l[n++]=s(m,"iridescenceIOR",1.3);const v=s(m,"iridescenceThicknessRange",[100,400]);l[n++]=v[0],l[n++]=v[1],"specularColor"in m?(l[n++]=m.specularColor.r,l[n++]=m.specularColor.g,l[n++]=m.specularColor.b):(l[n++]=1,l[n++]=1,l[n++]=1),l[n++]=i(m,"specularColorMap"),l[n++]=s(m,"specularIntensity",1),l[n++]=i(m,"specularIntensityMap");const y=s(m,"thickness",0)===0&&s(m,"attenuationDistance",1/0)===1/0;if(l[n++]=Number(y),n++,"attenuationColor"in m?(l[n++]=m.attenuationColor.r,l[n++]=m.attenuationColor.g,l[n++]=m.attenuationColor.b):(l[n++]=1,l[n++]=1,l[n++]=1),l[n++]=s(m,"attenuationDistance",1/0),l[n++]=i(m,"alphaMap"),l[n++]=m.opacity,l[n++]=m.alphaTest,!y&&m.transmission>0)l[n++]=0;else switch(m.side){case f.FrontSide:l[n++]=1;break;case f.BackSide:l[n++]=-1;break;case f.DoubleSide:l[n++]=0;break}l[n++]=Number(s(m,"matte",!1)),l[n++]=Number(s(m,"castShadow",!0)),l[n++]=Number(m.vertexColors)|Number(m.flatShading)<<1,l[n++]=Number(m.transparent),n+=a(m,"map",l,n),n+=a(m,"metalnessMap",l,n),n+=a(m,"roughnessMap",l,n),n+=a(m,"transmissionMap",l,n),n+=a(m,"emissiveMap",l,n),n+=a(m,"normalMap",l,n),n+=a(m,"clearcoatMap",l,n),n+=a(m,"clearcoatNormalMap",l,n),n+=a(m,"clearcoatRoughnessMap",l,n),n+=a(m,"sheenColorMap",l,n),n+=a(m,"sheenRoughnessMap",l,n),n+=a(m,"iridescenceMap",l,n),n+=a(m,"iridescenceThicknessMap",l,n),n+=a(m,"specularColorMap",l,n),n+=a(m,"specularIntensityMap",l,n)}const h=os(l.buffer);return this.hash!==h?(this.hash=h,this.needsUpdate=!0,!0):!1}}const Es=new f.Color;function ao(o){return o?`${o.uuid}:${o.version}`:null}function lo(o,e){for(const t in e)t in o&&(o[t]=e[t])}class Bs extends f.WebGLArrayRenderTarget{constructor(e,t,i){const s={format:f.RGBAFormat,type:f.UnsignedByteType,minFilter:f.LinearFilter,magFilter:f.LinearFilter,wrapS:f.RepeatWrapping,wrapT:f.RepeatWrapping,generateMipmaps:!1,...i};super(e,t,1,s),lo(this.texture,s),this.texture.setTextures=(...n)=>{this.setTextures(...n)},this.hashes=[null];const a=new ht.FullScreenQuad(new co);this.fsQuad=a}setTextures(e,t,i=this.width,s=this.height){const a=e.getRenderTarget(),n=e.toneMapping,c=e.getClearAlpha();e.getClearColor(Es);const u=t.length||1;(i!==this.width||s!==this.height||this.depth!==u)&&(this.setSize(i,s,u),this.hashes=new Array(u).fill(null)),e.setClearColor(0,0),e.toneMapping=f.NoToneMapping;const d=this.fsQuad,p=this.hashes;let r=!1;for(let l=0,h=u;l<h;l++){const g=t[l],_=ao(g);g&&(p[l]!==_||g.isWebGLRenderTarget)&&(g.matrixAutoUpdate=!1,g.matrix.identity(),d.material.map=g,e.setRenderTarget(this,l),d.render(e),g.updateMatrix(),g.matrixAutoUpdate=!0,p[l]=_,r=!0)}return d.material.map=null,e.setClearColor(Es,c),e.setRenderTarget(a),e.toneMapping=n,r}dispose(){super.dispose(),this.fsQuad.dispose()}}class co extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
258
258
  varying vec2 vUv;
259
259
  void main() {
260
260
 
@@ -270,7 +270,7 @@
270
270
  gl_FragColor = texture2D( map, vUv );
271
271
 
272
272
  }
273
- `})}}function vo(o,e=Math.random()){for(let t=o.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=o[t];o[t]=o[i],o[i]=s}return o}class _o{constructor(e,t,i=Math.random){const s=e**t,a=new Uint16Array(s);let n=s;for(let c=0;c<s;c++)a[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)a[c]=c;n=0},this.reshuffle=function(){n=0},this.next=function(){const{samples:c}=this;n>=a.length&&(vo(a,i),this.reshuffle());let u=a[n++];for(let f=0;f<t;f++)c[f]=(u%e+i())/e,u=Math.floor(u/e);return c}}}class yo{constructor(e,t,i=Math.random){let s=0;for(const u of t)s+=u;const a=new Float32Array(s),n=[];let c=0;for(const u of t){const f=new _o(e,u,i);f.samples=new Float32Array(a.buffer,c,f.samples.length),c+=f.samples.length*4,n.push(f)}this.samples=a,this.strataCount=e,this.next=function(){for(const u of n)u.next();return a},this.reshuffle=function(){for(const u of n)u.reshuffle()},this.reset=function(){for(const u of n)u.reset()}}}class xo{constructor(e=0){this.m=2147483648,this.a=1103515245,this.c=12345,this.seed=e}nextInt(){return this.seed=(this.a*this.seed+this.c)%this.m,this.seed}nextFloat(){return this.nextInt()/(this.m-1)}}class wo extends d.DataTexture{constructor(e=1,t=1,i=8){super(new Float32Array(1),1,1,d.RGBAFormat,d.FloatType),this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.strata=i,this.sampler=null,this.generator=new xo,this.stableNoise=!1,this.random=()=>this.stableNoise?this.generator.nextFloat():Math.random(),this.init(e,t,i)}init(e=this.image.height,t=this.image.width,i=this.strata){const{image:s}=this;if(s.width===t&&s.height===e&&this.sampler!==null)return;const a=new Array(e*t).fill(4),n=new yo(i,a,this.random);s.width=t,s.height=e,s.data=n.samples,this.sampler=n,this.dispose(),this.next()}next(){this.sampler.next(),this.needsUpdate=!0}reset(){this.sampler.reset(),this.generator.seed=0}}function bo(o,e=Math.random){for(let t=o.length-1;t>0;t--){const i=~~((e()-1e-6)*t),s=o[t];o[t]=o[i],o[i]=s}}function Ao(o,e){o.fill(0);for(let t=0;t<e;t++)o[t]=1}class Hs{constructor(e){this.count=0,this.size=-1,this.sigma=-1,this.radius=-1,this.lookupTable=null,this.score=null,this.binaryPattern=null,this.resize(e),this.setSigma(1.5)}findVoid(){const{score:e,binaryPattern:t}=this;let i=1/0,s=-1;for(let a=0,n=t.length;a<n;a++){if(t[a]!==0)continue;const c=e[a];c<i&&(i=c,s=a)}return s}findCluster(){const{score:e,binaryPattern:t}=this;let i=-1/0,s=-1;for(let a=0,n=t.length;a<n;a++){if(t[a]!==1)continue;const c=e[a];c>i&&(i=c,s=a)}return s}setSigma(e){if(e===this.sigma)return;const t=~~(Math.sqrt(10*2*e**2)+1),i=2*t+1,s=new Float32Array(i*i),a=e*e;for(let n=-t;n<=t;n++)for(let c=-t;c<=t;c++){const u=(t+c)*i+n+t,f=n*n+c*c;s[u]=Math.E**(-f/(2*a))}this.lookupTable=s,this.sigma=e,this.radius=t}resize(e){this.size!==e&&(this.size=e,this.score=new Float32Array(e*e),this.binaryPattern=new Uint8Array(e*e))}invert(){const{binaryPattern:e,score:t,size:i}=this;t.fill(0);for(let s=0,a=e.length;s<a;s++)if(e[s]===0){const n=~~(s/i),c=s-n*i;this.updateScore(c,n,1),e[s]=1}else e[s]=0}updateScore(e,t,i){const{size:s,score:a,lookupTable:n}=this,c=this.radius,u=2*c+1;for(let f=-c;f<=c;f++)for(let p=-c;p<=c;p++){const r=(c+p)*u+f+c,l=n[r];let h=e+f;h=h<0?s+h:h%s;let g=t+p;g=g<0?s+g:g%s;const _=g*s+h;a[_]+=i*l}}addPointIndex(e){this.binaryPattern[e]=1;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,1),this.count++}removePointIndex(e){this.binaryPattern[e]=0;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,-1),this.count--}copy(e){this.resize(e.size),this.score.set(e.score),this.binaryPattern.set(e.binaryPattern),this.setSigma(e.sigma),this.count=e.count}}class To{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new Hs(1),this.savedSamples=new Hs(1)}generate(){const{samples:e,savedSamples:t,sigma:i,majorityPointsRatio:s,size:a}=this;e.resize(a),e.setSigma(i);const n=Math.floor(a*a*s),c=e.binaryPattern;Ao(c,n),bo(c,this.random);for(let r=0,l=c.length;r<l;r++)c[r]===1&&e.addPointIndex(r);for(;;){const r=e.findCluster();e.removePointIndex(r);const l=e.findVoid();if(r===l){e.addPointIndex(r);break}e.addPointIndex(l)}const u=new Uint32Array(a*a);t.copy(e);let f;for(f=e.count-1;f>=0;){const r=e.findCluster();e.removePointIndex(r),u[r]=f,f--}const p=a*a;for(f=t.count;f<p/2;){const r=t.findVoid();t.addPointIndex(r),u[r]=f,f++}for(t.invert();f<p;){const r=t.findCluster();t.removePointIndex(r),u[r]=f,f++}return{data:u,maxValue:p}}}function So(o){return o>=3?4:o}function Mo(o){switch(o){case 1:return d.RedFormat;case 2:return d.RGFormat;default:return d.RGBAFormat}}class Co extends d.DataTexture{constructor(e=64,t=1){super(new Float32Array(4),1,1,d.RGBAFormat,d.FloatType),this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.size=e,this.channels=t,this.update()}update(){const e=this.channels,t=this.size,i=new To;i.channels=e,i.size=t;const s=So(e),a=Mo(s);(this.image.width!==t||a!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*s),this.format=a,this.dispose());const n=this.image.data;for(let c=0,u=e;c<u;c++){const f=i.generate(),p=f.data,r=f.maxValue;for(let l=0,h=p.length;l<h;l++){const g=p[l]/r;n[l*s+c]=g}}this.needsUpdate=!0}}const Ro=`
273
+ `})}}function uo(o,e=Math.random()){for(let t=o.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=o[t];o[t]=o[i],o[i]=s}return o}class ho{constructor(e,t,i=Math.random){const s=e**t,a=new Uint16Array(s);let n=s;for(let c=0;c<s;c++)a[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)a[c]=c;n=0},this.reshuffle=function(){n=0},this.next=function(){const{samples:c}=this;n>=a.length&&(uo(a,i),this.reshuffle());let u=a[n++];for(let d=0;d<t;d++)c[d]=(u%e+i())/e,u=Math.floor(u/e);return c}}}class fo{constructor(e,t,i=Math.random){let s=0;for(const u of t)s+=u;const a=new Float32Array(s),n=[];let c=0;for(const u of t){const d=new ho(e,u,i);d.samples=new Float32Array(a.buffer,c,d.samples.length),c+=d.samples.length*4,n.push(d)}this.samples=a,this.strataCount=e,this.next=function(){for(const u of n)u.next();return a},this.reshuffle=function(){for(const u of n)u.reshuffle()},this.reset=function(){for(const u of n)u.reset()}}}class po{constructor(e=0){this.m=2147483648,this.a=1103515245,this.c=12345,this.seed=e}nextInt(){return this.seed=(this.a*this.seed+this.c)%this.m,this.seed}nextFloat(){return this.nextInt()/(this.m-1)}}class mo extends f.DataTexture{constructor(e=1,t=1,i=8){super(new Float32Array(1),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.strata=i,this.sampler=null,this.generator=new po,this.stableNoise=!1,this.random=()=>this.stableNoise?this.generator.nextFloat():Math.random(),this.init(e,t,i)}init(e=this.image.height,t=this.image.width,i=this.strata){const{image:s}=this;if(s.width===t&&s.height===e&&this.sampler!==null)return;const a=new Array(e*t).fill(4),n=new fo(i,a,this.random);s.width=t,s.height=e,s.data=n.samples,this.sampler=n,this.dispose(),this.next()}next(){this.sampler.next(),this.needsUpdate=!0}reset(){this.sampler.reset(),this.generator.seed=0}}function go(o,e=Math.random){for(let t=o.length-1;t>0;t--){const i=~~((e()-1e-6)*t),s=o[t];o[t]=o[i],o[i]=s}}function vo(o,e){o.fill(0);for(let t=0;t<e;t++)o[t]=1}class ks{constructor(e){this.count=0,this.size=-1,this.sigma=-1,this.radius=-1,this.lookupTable=null,this.score=null,this.binaryPattern=null,this.resize(e),this.setSigma(1.5)}findVoid(){const{score:e,binaryPattern:t}=this;let i=1/0,s=-1;for(let a=0,n=t.length;a<n;a++){if(t[a]!==0)continue;const c=e[a];c<i&&(i=c,s=a)}return s}findCluster(){const{score:e,binaryPattern:t}=this;let i=-1/0,s=-1;for(let a=0,n=t.length;a<n;a++){if(t[a]!==1)continue;const c=e[a];c>i&&(i=c,s=a)}return s}setSigma(e){if(e===this.sigma)return;const t=~~(Math.sqrt(10*2*e**2)+1),i=2*t+1,s=new Float32Array(i*i),a=e*e;for(let n=-t;n<=t;n++)for(let c=-t;c<=t;c++){const u=(t+c)*i+n+t,d=n*n+c*c;s[u]=Math.E**(-d/(2*a))}this.lookupTable=s,this.sigma=e,this.radius=t}resize(e){this.size!==e&&(this.size=e,this.score=new Float32Array(e*e),this.binaryPattern=new Uint8Array(e*e))}invert(){const{binaryPattern:e,score:t,size:i}=this;t.fill(0);for(let s=0,a=e.length;s<a;s++)if(e[s]===0){const n=~~(s/i),c=s-n*i;this.updateScore(c,n,1),e[s]=1}else e[s]=0}updateScore(e,t,i){const{size:s,score:a,lookupTable:n}=this,c=this.radius,u=2*c+1;for(let d=-c;d<=c;d++)for(let p=-c;p<=c;p++){const r=(c+p)*u+d+c,l=n[r];let h=e+d;h=h<0?s+h:h%s;let g=t+p;g=g<0?s+g:g%s;const _=g*s+h;a[_]+=i*l}}addPointIndex(e){this.binaryPattern[e]=1;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,1),this.count++}removePointIndex(e){this.binaryPattern[e]=0;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,-1),this.count--}copy(e){this.resize(e.size),this.score.set(e.score),this.binaryPattern.set(e.binaryPattern),this.setSigma(e.sigma),this.count=e.count}}class _o{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new ks(1),this.savedSamples=new ks(1)}generate(){const{samples:e,savedSamples:t,sigma:i,majorityPointsRatio:s,size:a}=this;e.resize(a),e.setSigma(i);const n=Math.floor(a*a*s),c=e.binaryPattern;vo(c,n),go(c,this.random);for(let r=0,l=c.length;r<l;r++)c[r]===1&&e.addPointIndex(r);for(;;){const r=e.findCluster();e.removePointIndex(r);const l=e.findVoid();if(r===l){e.addPointIndex(r);break}e.addPointIndex(l)}const u=new Uint32Array(a*a);t.copy(e);let d;for(d=e.count-1;d>=0;){const r=e.findCluster();e.removePointIndex(r),u[r]=d,d--}const p=a*a;for(d=t.count;d<p/2;){const r=t.findVoid();t.addPointIndex(r),u[r]=d,d++}for(t.invert();d<p;){const r=t.findCluster();t.removePointIndex(r),u[r]=d,d++}return{data:u,maxValue:p}}}function yo(o){return o>=3?4:o}function xo(o){switch(o){case 1:return f.RedFormat;case 2:return f.RGFormat;default:return f.RGBAFormat}}class wo extends f.DataTexture{constructor(e=64,t=1){super(new Float32Array(4),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.size=e,this.channels=t,this.update()}update(){const e=this.channels,t=this.size,i=new _o;i.channels=e,i.size=t;const s=yo(e),a=xo(s);(this.image.width!==t||a!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*s),this.format=a,this.dispose());const n=this.image.data;for(let c=0,u=e;c<u;c++){const d=i.generate(),p=d.data,r=d.maxValue;for(let l=0,h=p.length;l<h;l++){const g=p[l]/r;n[l*s+c]=g}}this.needsUpdate=!0}}const bo=`
274
274
 
275
275
  struct PhysicalCamera {
276
276
 
@@ -282,7 +282,7 @@
282
282
 
283
283
  };
284
284
 
285
- `,Io=`
285
+ `,Ao=`
286
286
 
287
287
  struct EquirectHdrInfo {
288
288
 
@@ -294,7 +294,7 @@
294
294
 
295
295
  };
296
296
 
297
- `,Do=`
297
+ `,To=`
298
298
 
299
299
  #define RECT_AREA_LIGHT_TYPE 0
300
300
  #define CIRC_AREA_LIGHT_TYPE 1
@@ -380,7 +380,7 @@
380
380
 
381
381
  }
382
382
 
383
- `,Lo=`
383
+ `,So=`
384
384
 
385
385
  struct Material {
386
386
 
@@ -587,7 +587,7 @@
587
587
 
588
588
  }
589
589
 
590
- `,Po=`
590
+ `,Mo=`
591
591
 
592
592
  struct SurfaceRecord {
593
593
 
@@ -649,7 +649,7 @@
649
649
  vec3 color;
650
650
  };
651
651
 
652
- `,Fo=`
652
+ `,Co=`
653
653
 
654
654
  // samples the the given environment map in the given direction
655
655
  vec3 sampleEquirectColor( sampler2D envMap, vec3 direction ) {
@@ -716,7 +716,7 @@
716
716
  return float( resolution.x * resolution.y ) * pdf * equirectDirectionPdf( direction );
717
717
 
718
718
  }
719
- `,Eo=`
719
+ `,Ro=`
720
720
 
721
721
  float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
722
722
 
@@ -931,7 +931,7 @@
931
931
 
932
932
  }
933
933
 
934
- `,ko=`
934
+ `,Io=`
935
935
 
936
936
  vec3 sampleHemisphere( vec3 n, vec2 uv ) {
937
937
 
@@ -1016,7 +1016,7 @@
1016
1016
  }
1017
1017
 
1018
1018
 
1019
- `,Bo=`
1019
+ `,Do=`
1020
1020
 
1021
1021
  bool totalInternalReflection( float cosTheta, float eta ) {
1022
1022
 
@@ -1119,7 +1119,7 @@
1119
1119
 
1120
1120
  }
1121
1121
 
1122
- `,Oo=`
1122
+ `,Lo=`
1123
1123
 
1124
1124
  // Fast arccos approximation used to remove banding artifacts caused by numerical errors in acos.
1125
1125
  // This is a cubic Lagrange interpolating polynomial for x = [-1, -1/2, 0, 1/2, 1].
@@ -1199,7 +1199,7 @@
1199
1199
 
1200
1200
  }
1201
1201
 
1202
- `,zo=`
1202
+ `,Po=`
1203
1203
 
1204
1204
  // Finds the point where the ray intersects the plane defined by u and v and checks if this point
1205
1205
  // falls in the bounds of the rectangle on that same plane.
@@ -1260,7 +1260,7 @@
1260
1260
 
1261
1261
  }
1262
1262
 
1263
- `,Vo=`
1263
+ `,Fo=`
1264
1264
 
1265
1265
  // add texel fetch functions for texture arrays
1266
1266
  vec4 texelFetch1D( sampler2DArray tex, int layer, uint index ) {
@@ -1283,7 +1283,7 @@
1283
1283
 
1284
1284
  }
1285
1285
 
1286
- `,Cr=`
1286
+ `,wr=`
1287
1287
 
1288
1288
  // TODO: possibly this should be renamed something related to material or path tracing logic
1289
1289
 
@@ -1398,7 +1398,7 @@
1398
1398
  return x < 0.5 ? sqrt( 2.0 * x ) - 1.0 : 1.0 - sqrt( 2.0 - ( 2.0 * x ) );
1399
1399
 
1400
1400
  }
1401
- `,Ns=`
1401
+ `,Os=`
1402
1402
 
1403
1403
  // https://www.shadertoy.com/view/wltcRS
1404
1404
  uvec4 WHITE_NOISE_SEED;
@@ -1454,7 +1454,7 @@
1454
1454
  return vec4( WHITE_NOISE_SEED ) / float( 0xffffffffu );
1455
1455
 
1456
1456
  }
1457
- `,Uo=`
1457
+ `,Eo=`
1458
1458
 
1459
1459
  uniform sampler2D stratifiedTexture;
1460
1460
  uniform sampler2D stratifiedOffsetTexture;
@@ -1503,7 +1503,7 @@
1503
1503
 
1504
1504
  }
1505
1505
 
1506
- `,Wo=`
1506
+ `,Bo=`
1507
1507
 
1508
1508
  // diffuse
1509
1509
  float diffuseEval( vec3 wo, vec3 wi, vec3 wh, SurfaceRecord surf, inout vec3 color ) {
@@ -1941,7 +1941,7 @@
1941
1941
 
1942
1942
  }
1943
1943
 
1944
- `,Ho=`
1944
+ `,ko=`
1945
1945
 
1946
1946
  // returns the hit distance given the material density
1947
1947
  float intersectFogVolume( Material material, float u ) {
@@ -1962,7 +1962,7 @@
1962
1962
 
1963
1963
  }
1964
1964
 
1965
- `,No=`
1965
+ `,Oo=`
1966
1966
 
1967
1967
  // The GGX functions provide sampling and distribution information for normals as output so
1968
1968
  // in order to get probability of scatter direction the half vector must be computed and provided.
@@ -2063,7 +2063,7 @@
2063
2063
 
2064
2064
  }
2065
2065
 
2066
- `,Go=`
2066
+ `,zo=`
2067
2067
 
2068
2068
  // XYZ to sRGB color space
2069
2069
  const mat3 XYZ_TO_REC709 = mat3(
@@ -2197,7 +2197,7 @@
2197
2197
 
2198
2198
  }
2199
2199
 
2200
- `,qo=`
2200
+ `,Vo=`
2201
2201
 
2202
2202
  // See equation (2) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
2203
2203
  float velvetD( float cosThetaH, float roughness ) {
@@ -2294,7 +2294,7 @@
2294
2294
 
2295
2295
  }
2296
2296
 
2297
- `,jo=`
2297
+ `,Uo=`
2298
2298
 
2299
2299
  #ifndef FOG_CHECK_ITERATIONS
2300
2300
  #define FOG_CHECK_ITERATIONS 30
@@ -2355,7 +2355,7 @@ bool bvhIntersectFogVolumeHit(
2355
2355
 
2356
2356
  }
2357
2357
 
2358
- `,Qo=`
2358
+ `,Wo=`
2359
2359
 
2360
2360
  // step through multiple surface hits and accumulate color attenuation based on transmissive surfaces
2361
2361
  // returns true if a solid surface was hit
@@ -2532,7 +2532,7 @@ bool bvhIntersectFogVolumeHit(
2532
2532
 
2533
2533
  }
2534
2534
 
2535
- `,Yo=`
2535
+ `,Ho=`
2536
2536
 
2537
2537
  vec3 ndcToRayOrigin( vec2 coord ) {
2538
2538
 
@@ -2615,7 +2615,7 @@ bool bvhIntersectFogVolumeHit(
2615
2615
 
2616
2616
  }
2617
2617
 
2618
- `,Zo=`
2618
+ `,No=`
2619
2619
 
2620
2620
  vec3 directLightContribution( vec3 worldWo, SurfaceRecord surf, RenderState state, vec3 rayOrigin ) {
2621
2621
 
@@ -2711,7 +2711,7 @@ bool bvhIntersectFogVolumeHit(
2711
2711
 
2712
2712
  }
2713
2713
 
2714
- `,Ko=`
2714
+ `,Go=`
2715
2715
 
2716
2716
  #define SKIP_SURFACE 0
2717
2717
  #define HIT_SURFACE 1
@@ -3033,7 +3033,7 @@ bool bvhIntersectFogVolumeHit(
3033
3033
  return HIT_SURFACE;
3034
3034
 
3035
3035
  }
3036
- `,Xo=`
3036
+ `,qo=`
3037
3037
 
3038
3038
  struct Ray {
3039
3039
 
@@ -3082,7 +3082,7 @@ bool bvhIntersectFogVolumeHit(
3082
3082
 
3083
3083
  }
3084
3084
 
3085
- `,Jo=`
3085
+ `,jo=`
3086
3086
 
3087
3087
  #define NO_HIT 0
3088
3088
  #define SURFACE_HIT 1
@@ -3129,7 +3129,7 @@ bool bvhIntersectFogVolumeHit(
3129
3129
 
3130
3130
  }
3131
3131
 
3132
- `;class $o extends fs{onBeforeRender(){this.setDefine("FEATURE_DOF",this.physicalCamera.bokehSize===0?0:1),this.setDefine("FEATURE_BACKGROUND_MAP",this.backgroundMap?1:0),this.setDefine("FEATURE_FOG",this.materials.features.isUsed("FOG")?1:0)}constructor(e){super({transparent:!0,depthWrite:!1,defines:{FEATURE_MIS:1,FEATURE_RUSSIAN_ROULETTE:1,FEATURE_DOF:1,FEATURE_BACKGROUND_MAP:0,FEATURE_FOG:1,RANDOM_TYPE:2,CAMERA_TYPE:0,DEBUG_MODE:0,ATTR_NORMAL:0,ATTR_TANGENT:1,ATTR_UV:2,ATTR_COLOR:3},uniforms:{resolution:{value:new d.Vector2},opacity:{value:1},bounces:{value:10},transmissiveBounces:{value:10},filterGlossyFactor:{value:0},physicalCamera:{value:new Yn},cameraWorldMatrix:{value:new d.Matrix4},invProjectionMatrix:{value:new d.Matrix4},bvh:{value:new Le.MeshBVHUniformStruct},attributesArray:{value:new oo},materialIndexAttribute:{value:new Le.UIntVertexAttributeTexture},materials:{value:new fo},textures:{value:new Ws().texture},lights:{value:new ro},iesProfiles:{value:new Ws(360,180,{type:d.HalfFloatType,wrapS:d.ClampToEdgeWrapping,wrapT:d.ClampToEdgeWrapping}).texture},environmentIntensity:{value:1},environmentRotation:{value:new d.Matrix4},envMapInfo:{value:new Xn},backgroundBlur:{value:0},backgroundMap:{value:null},backgroundAlpha:{value:1},backgroundIntensity:{value:1},backgroundRotation:{value:new d.Matrix4},seed:{value:0},sobolTexture:{value:null},stratifiedTexture:{value:new wo},stratifiedOffsetTexture:{value:new Co(64,1)}},vertexShader:`
3132
+ `;class Qo extends as{onBeforeRender(){this.setDefine("FEATURE_DOF",this.physicalCamera.bokehSize===0?0:1),this.setDefine("FEATURE_BACKGROUND_MAP",this.backgroundMap?1:0),this.setDefine("FEATURE_FOG",this.materials.features.isUsed("FOG")?1:0)}constructor(e){super({transparent:!0,depthWrite:!1,defines:{FEATURE_MIS:1,FEATURE_RUSSIAN_ROULETTE:1,FEATURE_DOF:1,FEATURE_BACKGROUND_MAP:0,FEATURE_FOG:1,RANDOM_TYPE:2,CAMERA_TYPE:0,DEBUG_MODE:0,ATTR_NORMAL:0,ATTR_TANGENT:1,ATTR_UV:2,ATTR_COLOR:3},uniforms:{resolution:{value:new f.Vector2},opacity:{value:1},bounces:{value:10},transmissiveBounces:{value:10},filterGlossyFactor:{value:0},physicalCamera:{value:new Hn},cameraWorldMatrix:{value:new f.Matrix4},invProjectionMatrix:{value:new f.Matrix4},bvh:{value:new Ie.MeshBVHUniformStruct},attributesArray:{value:new eo},materialIndexAttribute:{value:new Ie.UIntVertexAttributeTexture},materials:{value:new oo},textures:{value:new Bs().texture},lights:{value:new Jn},iesProfiles:{value:new Bs(360,180,{type:f.HalfFloatType,wrapS:f.ClampToEdgeWrapping,wrapT:f.ClampToEdgeWrapping}).texture},environmentIntensity:{value:1},environmentRotation:{value:new f.Matrix4},envMapInfo:{value:new qn},backgroundBlur:{value:0},backgroundMap:{value:null},backgroundAlpha:{value:1},backgroundIntensity:{value:1},backgroundRotation:{value:new f.Matrix4},seed:{value:0},sobolTexture:{value:null},stratifiedTexture:{value:new mo},stratifiedOffsetTexture:{value:new wo(64,1)}},vertexShader:`
3133
3133
 
3134
3134
  varying vec2 vUv;
3135
3135
  void main() {
@@ -3153,27 +3153,27 @@ bool bvhIntersectFogVolumeHit(
3153
3153
  #include <common>
3154
3154
 
3155
3155
  // bvh intersection
3156
- ${Le.BVHShaderGLSL.common_functions}
3157
- ${Le.BVHShaderGLSL.bvh_struct_definitions}
3158
- ${Le.BVHShaderGLSL.bvh_ray_functions}
3156
+ ${Ie.BVHShaderGLSL.common_functions}
3157
+ ${Ie.BVHShaderGLSL.bvh_struct_definitions}
3158
+ ${Ie.BVHShaderGLSL.bvh_ray_functions}
3159
3159
 
3160
3160
  // uniform structs
3161
- ${Ro}
3162
- ${Do}
3163
- ${Io}
3164
- ${Lo}
3165
- ${Po}
3161
+ ${bo}
3162
+ ${To}
3163
+ ${Ao}
3164
+ ${So}
3165
+ ${Mo}
3166
3166
 
3167
3167
  // random
3168
3168
  #if RANDOM_TYPE == 2 // Stratified List
3169
3169
 
3170
- ${Uo}
3170
+ ${Eo}
3171
3171
 
3172
3172
  #elif RANDOM_TYPE == 1 // Sobol
3173
3173
 
3174
- ${Ns}
3175
- ${Sr}
3176
- ${Gn}
3174
+ ${Os}
3175
+ ${yr}
3176
+ ${zn}
3177
3177
 
3178
3178
  #define rand(v) sobol(v)
3179
3179
  #define rand2(v) sobol2(v)
@@ -3182,7 +3182,7 @@ bool bvhIntersectFogVolumeHit(
3182
3182
 
3183
3183
  #else // PCG
3184
3184
 
3185
- ${Ns}
3185
+ ${Os}
3186
3186
 
3187
3187
  // Using the sobol functions seems to break the the compiler on MacOS
3188
3188
  // - specifically the "sobolReverseBits" function.
@@ -3198,11 +3198,11 @@ bool bvhIntersectFogVolumeHit(
3198
3198
  #endif
3199
3199
 
3200
3200
  // common
3201
- ${Vo}
3202
- ${Bo}
3203
- ${Cr}
3204
- ${Oo}
3205
- ${zo}
3201
+ ${Fo}
3202
+ ${Do}
3203
+ ${wr}
3204
+ ${Lo}
3205
+ ${Po}
3206
3206
 
3207
3207
  // environment
3208
3208
  uniform EquirectHdrInfo envMapInfo;
@@ -3258,16 +3258,16 @@ bool bvhIntersectFogVolumeHit(
3258
3258
  float lightsDenom;
3259
3259
 
3260
3260
  // sampling
3261
- ${ko}
3262
- ${Fo}
3263
- ${Eo}
3261
+ ${Io}
3262
+ ${Co}
3263
+ ${Ro}
3264
3264
 
3265
- ${jo}
3266
- ${No}
3267
- ${qo}
3268
- ${Go}
3269
- ${Ho}
3270
- ${Wo}
3265
+ ${Uo}
3266
+ ${Oo}
3267
+ ${Vo}
3268
+ ${zo}
3269
+ ${ko}
3270
+ ${Bo}
3271
3271
 
3272
3272
  float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
3273
3273
 
@@ -3299,12 +3299,12 @@ bool bvhIntersectFogVolumeHit(
3299
3299
 
3300
3300
  }
3301
3301
 
3302
- ${Xo}
3303
- ${Yo}
3304
- ${Jo}
3305
- ${Qo}
3306
- ${Zo}
3307
- ${Ko}
3302
+ ${qo}
3303
+ ${Ho}
3304
+ ${jo}
3305
+ ${Wo}
3306
+ ${No}
3307
+ ${Go}
3308
3308
 
3309
3309
  void main() {
3310
3310
 
@@ -3596,7 +3596,7 @@ bool bvhIntersectFogVolumeHit(
3596
3596
 
3597
3597
  }
3598
3598
 
3599
- `}),this.setValues(e)}}function*ea(){const{_renderer:o,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:a,_subframe:n,alpha:c,material:u}=this,f=new d.Vector4,p=new d.Vector4,r=t.material;let[l,h]=s;for(;;){c?(r.opacity=this._opacityFactor/(this.samples+1),u.blending=d.NoBlending,u.opacity=1):(u.opacity=this._opacityFactor/(this.samples+1),u.blending=d.NormalBlending);const[g,_,m,v]=n,y=i.width,x=i.height;u.resolution.set(y*m,x*v),u.sobolTexture=a.texture,u.stratifiedTexture.init(20,u.bounces+u.transmissiveBounces+5),u.stratifiedTexture.next(),u.seed++;const w=this.tiles.x||1,b=this.tiles.y||1,A=w*b,S=Math.ceil(y*m),C=Math.ceil(x*v),M=Math.floor(g*y),I=Math.floor(_*x),D=Math.ceil(S/w),T=Math.ceil(C/b);for(let R=0;R<b;R++)for(let L=0;L<w;L++){const F=o.getRenderTarget(),E=o.autoClear,z=o.getScissorTest();o.getScissor(f),o.getViewport(p);let N=L,j=R;if(!this.stableTiles){const K=this._currentTile%(w*b);N=K%w,j=~~(K/w),this._currentTile=K+1}const Z=b-j-1;i.scissor.set(M+N*D,I+Z*T,Math.min(D,S-N*D),Math.min(T,C-Z*T)),i.viewport.set(M,I,S,C),o.setRenderTarget(i),o.setScissorTest(!0),o.autoClear=!1,e.render(o),o.setViewport(p),o.setScissor(f),o.setScissorTest(z),o.setRenderTarget(F),o.autoClear=E,c&&(r.target1=l.texture,r.target2=i.texture,o.setRenderTarget(h),t.render(o),o.setRenderTarget(F)),this.samples+=1/A,L===w-1&&R===b-1&&(this.samples=Math.round(this.samples)),yield}[l,h]=[h,l]}}const Gs=new d.Color;class qs{get material(){return this._fsQuad.material}set material(e){this._fsQuad.material.removeEventListener("recompilation",this._compileFunction),e.addEventListener("recompilation",this._compileFunction),this._fsQuad.material=e}get target(){return this._alpha?this._blendTargets[1]:this._primaryTarget}set alpha(e){this._alpha!==e&&(e||(this._blendTargets[0].dispose(),this._blendTargets[1].dispose()),this._alpha=e,this.reset())}get alpha(){return this._alpha}get isCompiling(){return!!this._compilePromise}constructor(e){this.camera=null,this.tiles=new d.Vector2(3,3),this.stableNoise=!1,this.stableTiles=!0,this.samples=0,this._subframe=new d.Vector4(0,0,1,1),this._opacityFactor=1,this._renderer=e,this._alpha=!1,this._fsQuad=new dt.FullScreenQuad(new $o),this._blendQuad=new dt.FullScreenQuad(new Hn),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new jn().generate(e),this._primaryTarget=new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.NearestFilter}),this._blendTargets=[new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.NearestFilter}),new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.NearestFilter})],this._compileFunction=()=>{const t=this.compileMaterial(this._fsQuad._mesh);t.then(()=>{this._compilePromise===t&&(this._compilePromise=null)}),this._compilePromise=t},this.material.addEventListener("recompilation",this._compileFunction)}compileMaterial(){return this._renderer.compileAsync(this._fsQuad._mesh)}setCamera(e){const{material:t}=this;t.cameraWorldMatrix.copy(e.matrixWorld),t.invProjectionMatrix.copy(e.projectionMatrixInverse),t.physicalCamera.updateFrom(e);let i=0;e.projectionMatrix.elements[15]>0&&(i=1),e.isEquirectCamera&&(i=2),t.setDefine("CAMERA_TYPE",i),this.camera=e}setSize(e,t){e=Math.ceil(e),t=Math.ceil(t),!(this._primaryTarget.width===e&&this._primaryTarget.height===t)&&(this._primaryTarget.setSize(e,t),this._blendTargets[0].setSize(e,t),this._blendTargets[1].setSize(e,t),this.reset())}getSize(e){e.x=this._primaryTarget.width,e.y=this._primaryTarget.height}dispose(){this._primaryTarget.dispose(),this._blendTargets[0].dispose(),this._blendTargets[1].dispose(),this._sobolTarget.dispose(),this._fsQuad.dispose(),this._blendQuad.dispose(),this._task=null}reset(){const{_renderer:e,_primaryTarget:t,_blendTargets:i}=this,s=e.getRenderTarget(),a=e.getClearAlpha();e.getClearColor(Gs),e.setRenderTarget(t),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[0]),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[1]),e.setClearColor(0,0),e.clearColor(),e.setClearColor(Gs,a),e.setRenderTarget(s),this.samples=0,this._task=null,this.material.stratifiedTexture.stableNoise=this.stableNoise,this.stableNoise&&(this.material.seed=0,this.material.stratifiedTexture.reset())}update(){this.material.onBeforeRender(),!this.isCompiling&&(this._task||(this._task=ea.call(this)),this._task.next())}}const Ve=new d.Vector2,js=new d.Vector2,Gt=new d.Spherical,qt=new d.Color;class ta extends d.DataTexture{constructor(e=512,t=512){super(new Float32Array(e*t*4),e,t,d.RGBAFormat,d.FloatType,d.EquirectangularReflectionMapping,d.RepeatWrapping,d.ClampToEdgeWrapping,d.LinearFilter,d.LinearFilter),this.generationCallback=null}update(){this.dispose(),this.needsUpdate=!0;const{data:e,width:t,height:i}=this.image;for(let s=0;s<t;s++)for(let a=0;a<i;a++){js.set(t,i),Ve.set(s/t,a/i),Ve.x-=.5,Ve.y=1-Ve.y,Gt.theta=Ve.x*2*Math.PI,Gt.phi=Ve.y*Math.PI,Gt.radius=1,this.generationCallback(Gt,Ve,js,qt);const c=4*(a*t+s);e[c+0]=qt.r,e[c+1]=qt.g,e[c+2]=qt.b,e[c+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const Qs=new d.Vector3;class ia extends ta{constructor(e=512){super(e,e),this.topColor=new d.Color().set(16777215),this.bottomColor=new d.Color().set(0),this.exponent=2,this.generationCallback=(t,i,s,a)=>{Qs.setFromSpherical(t);const n=Qs.y*.5+.5;a.lerpColors(this.bottomColor,this.topColor,n**this.exponent)}}copy(e){return super.copy(e),this.topColor.copy(e.topColor),this.bottomColor.copy(e.bottomColor),this}}class sa extends d.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}constructor(e){super({uniforms:{map:{value:null},opacity:{value:1}},vertexShader:`
3599
+ `}),this.setValues(e)}}function*Yo(){const{_renderer:o,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:a,_subframe:n,alpha:c,material:u}=this,d=new f.Vector4,p=new f.Vector4,r=t.material;let[l,h]=s;for(;;){c?(r.opacity=this._opacityFactor/(this.samples+1),u.blending=f.NoBlending,u.opacity=1):(u.opacity=this._opacityFactor/(this.samples+1),u.blending=f.NormalBlending);const[g,_,m,v]=n,y=i.width,x=i.height;u.resolution.set(y*m,x*v),u.sobolTexture=a.texture,u.stratifiedTexture.init(20,u.bounces+u.transmissiveBounces+5),u.stratifiedTexture.next(),u.seed++;const w=this.tiles.x||1,b=this.tiles.y||1,A=w*b,S=Math.ceil(y*m),C=Math.ceil(x*v),M=Math.floor(g*y),I=Math.floor(_*x),D=Math.ceil(S/w),T=Math.ceil(C/b);for(let R=0;R<b;R++)for(let L=0;L<w;L++){const F=o.getRenderTarget(),E=o.autoClear,z=o.getScissorTest();o.getScissor(d),o.getViewport(p);let N=L,j=R;if(!this.stableTiles){const K=this._currentTile%(w*b);N=K%w,j=~~(K/w),this._currentTile=K+1}const Z=b-j-1;i.scissor.set(M+N*D,I+Z*T,Math.min(D,S-N*D),Math.min(T,C-Z*T)),i.viewport.set(M,I,S,C),o.setRenderTarget(i),o.setScissorTest(!0),o.autoClear=!1,e.render(o),o.setViewport(p),o.setScissor(d),o.setScissorTest(z),o.setRenderTarget(F),o.autoClear=E,c&&(r.target1=l.texture,r.target2=i.texture,o.setRenderTarget(h),t.render(o),o.setRenderTarget(F)),this.samples+=1/A,L===w-1&&R===b-1&&(this.samples=Math.round(this.samples)),yield}[l,h]=[h,l]}}const zs=new f.Color;class Vs{get material(){return this._fsQuad.material}set material(e){this._fsQuad.material.removeEventListener("recompilation",this._compileFunction),e.addEventListener("recompilation",this._compileFunction),this._fsQuad.material=e}get target(){return this._alpha?this._blendTargets[1]:this._primaryTarget}set alpha(e){this._alpha!==e&&(e||(this._blendTargets[0].dispose(),this._blendTargets[1].dispose()),this._alpha=e,this.reset())}get alpha(){return this._alpha}get isCompiling(){return!!this._compilePromise}constructor(e){this.camera=null,this.tiles=new f.Vector2(3,3),this.stableNoise=!1,this.stableTiles=!0,this.samples=0,this._subframe=new f.Vector4(0,0,1,1),this._opacityFactor=1,this._renderer=e,this._alpha=!1,this._fsQuad=new ht.FullScreenQuad(new Qo),this._blendQuad=new ht.FullScreenQuad(new kn),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new Un().generate(e),this._primaryTarget=new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),this._blendTargets=[new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter})],this._compileFunction=()=>{const t=this.compileMaterial(this._fsQuad._mesh);t.then(()=>{this._compilePromise===t&&(this._compilePromise=null)}),this._compilePromise=t},this.material.addEventListener("recompilation",this._compileFunction)}compileMaterial(){return this._renderer.compileAsync(this._fsQuad._mesh)}setCamera(e){const{material:t}=this;t.cameraWorldMatrix.copy(e.matrixWorld),t.invProjectionMatrix.copy(e.projectionMatrixInverse),t.physicalCamera.updateFrom(e);let i=0;e.projectionMatrix.elements[15]>0&&(i=1),e.isEquirectCamera&&(i=2),t.setDefine("CAMERA_TYPE",i),this.camera=e}setSize(e,t){e=Math.ceil(e),t=Math.ceil(t),!(this._primaryTarget.width===e&&this._primaryTarget.height===t)&&(this._primaryTarget.setSize(e,t),this._blendTargets[0].setSize(e,t),this._blendTargets[1].setSize(e,t),this.reset())}getSize(e){e.x=this._primaryTarget.width,e.y=this._primaryTarget.height}dispose(){this._primaryTarget.dispose(),this._blendTargets[0].dispose(),this._blendTargets[1].dispose(),this._sobolTarget.dispose(),this._fsQuad.dispose(),this._blendQuad.dispose(),this._task=null}reset(){const{_renderer:e,_primaryTarget:t,_blendTargets:i}=this,s=e.getRenderTarget(),a=e.getClearAlpha();e.getClearColor(zs),e.setRenderTarget(t),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[0]),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[1]),e.setClearColor(0,0),e.clearColor(),e.setClearColor(zs,a),e.setRenderTarget(s),this.samples=0,this._task=null,this.material.stratifiedTexture.stableNoise=this.stableNoise,this.stableNoise&&(this.material.seed=0,this.material.stratifiedTexture.reset())}update(){this.material.onBeforeRender(),!this.isCompiling&&(this._task||(this._task=Yo.call(this)),this._task.next())}}const Oe=new f.Vector2,Us=new f.Vector2,Ht=new f.Spherical,Nt=new f.Color;class Zo extends f.DataTexture{constructor(e=512,t=512){super(new Float32Array(e*t*4),e,t,f.RGBAFormat,f.FloatType,f.EquirectangularReflectionMapping,f.RepeatWrapping,f.ClampToEdgeWrapping,f.LinearFilter,f.LinearFilter),this.generationCallback=null}update(){this.dispose(),this.needsUpdate=!0;const{data:e,width:t,height:i}=this.image;for(let s=0;s<t;s++)for(let a=0;a<i;a++){Us.set(t,i),Oe.set(s/t,a/i),Oe.x-=.5,Oe.y=1-Oe.y,Ht.theta=Oe.x*2*Math.PI,Ht.phi=Oe.y*Math.PI,Ht.radius=1,this.generationCallback(Ht,Oe,Us,Nt);const c=4*(a*t+s);e[c+0]=Nt.r,e[c+1]=Nt.g,e[c+2]=Nt.b,e[c+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const Ws=new f.Vector3;class Ko extends Zo{constructor(e=512){super(e,e),this.topColor=new f.Color().set(16777215),this.bottomColor=new f.Color().set(0),this.exponent=2,this.generationCallback=(t,i,s,a)=>{Ws.setFromSpherical(t);const n=Ws.y*.5+.5;a.lerpColors(this.bottomColor,this.topColor,n**this.exponent)}}copy(e){return super.copy(e),this.topColor.copy(e.topColor),this.bottomColor.copy(e.bottomColor),this}}class Xo extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}constructor(e){super({uniforms:{map:{value:null},opacity:{value:1}},vertexShader:`
3600
3600
  varying vec2 vUv;
3601
3601
  void main() {
3602
3602
 
@@ -3653,7 +3653,7 @@ bool bvhIntersectFogVolumeHit(
3653
3653
  #include <premultiplied_alpha_fragment>
3654
3654
 
3655
3655
  }
3656
- `}),this.setValues(e)}}class ra extends d.ShaderMaterial{constructor(){super({uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:`
3656
+ `}),this.setValues(e)}}class Jo extends f.ShaderMaterial{constructor(){super({uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:`
3657
3657
  varying vec2 vUv;
3658
3658
  void main() {
3659
3659
 
@@ -3670,7 +3670,7 @@ bool bvhIntersectFogVolumeHit(
3670
3670
  #include <common>
3671
3671
  #include <cube_uv_reflection_fragment>
3672
3672
 
3673
- ${Cr}
3673
+ ${wr}
3674
3674
 
3675
3675
  void main() {
3676
3676
 
@@ -3678,14 +3678,14 @@ bool bvhIntersectFogVolumeHit(
3678
3678
  rayDirection.x *= flipEnvMap;
3679
3679
  gl_FragColor = textureCube( envMap, rayDirection );
3680
3680
 
3681
- }`}),this.depthWrite=!1,this.depthTest=!1}}class Ys{constructor(e){this._renderer=e,this._quad=new dt.FullScreenQuad(new ra)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=this._renderer,n=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new d.WebGLRenderTarget(t,i,{type:d.FloatType,colorSpace:s.colorSpace}),u=s.height,f=Math.log2(u)-2,p=1/u,r=1/(3*Math.max(Math.pow(2,f),7*16));n.material.defines.CUBEUV_MAX_MIP=`${f}.0`,n.material.defines.CUBEUV_TEXEL_WIDTH=r,n.material.defines.CUBEUV_TEXEL_HEIGHT=p,n.material.uniforms.envMap.value=e,n.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,n.material.needsUpdate=!0;const l=a.getRenderTarget(),h=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),n.render(a),a.setRenderTarget(l),a.autoClear=h;const g=new Uint16Array(t*i*4),_=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,_),c.dispose();for(let v=0,y=_.length;v<y;v++)g[v]=d.DataUtils.toHalfFloat(_[v]);const m=new d.DataTexture(g,t,i,d.RGBAFormat,d.HalfFloatType);return m.minFilter=d.LinearMipMapLinearFilter,m.magFilter=d.LinearFilter,m.wrapS=d.RepeatWrapping,m.wrapT=d.RepeatWrapping,m.mapping=d.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function na(o){return o.extensions.get("EXT_float_blend")}const Ye=new d.Vector2;class oa{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Wn,this._pathTracer=new qs(e),this._queueReset=!1,this._clock=new d.Clock,this._compilePromise=null,this._lowResPathTracer=new qs(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new dt.FullScreenQuad(new sa({map:null,transparent:!0,blending:d.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new d.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},this.setScene(new d.Scene,new d.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,a=co(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=uo(e),a=lo(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new ia(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new Ys(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new Ys(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:a,bvh:n,bvhChanged:c}=i;this._materials=s;const f=this._pathTracer.material;return c&&(f.bvh.updateFrom(n),f.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),f.materialIndexAttribute.updateFrom(a.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,s.start());const n=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!na(i),e.alpha=t.alpha,this.renderToCanvas){const u=this._renderer,f=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+n/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<f||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(u),a.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?d.AdditiveBlending:d.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,u,a),a.material.blending=d.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(Ye);const e=Math.floor(this.renderScale*Ye.x),t=Math.floor(this.renderScale*Ye.y);if(this._pathTracer.getSize(Ye),Ye.x!==e||Ye.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const aa="";globalThis.GLTF_PROGRESSIVE_VERSION=aa;console.debug("[gltf-progressive] version -");let de="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",gi="https://cdn.needle.tools/static/three/0.179.1/basis2/";const la=de,ca=gi,Rr=new URL(de+"draco_decoder.js");Rr.searchParams.append("range","true");fetch(Rr,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(o=>{console.debug(`Failed to fetch remote Draco decoder from ${de} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),de===la&&ha("./include/draco/"),gi===ca&&fa("./include/ktx2/")}).finally(()=>{Dr()});const ua=()=>({dracoDecoderPath:de,ktx2TranscoderPath:gi});function ha(o){de=o,se&&se[qi]!=de?(console.debug("Updating Draco decoder path to "+o),se[qi]=de,se.setDecoderPath(de),se.preload()):console.debug("Setting Draco decoder path to "+o)}function fa(o){gi=o}function ps(o){return Dr(),{dracoLoader:se,meshoptDecoder:hi}}function Ir(o){o.dracoLoader||o.setDRACOLoader(se),o.meshoptDecoder||o.setMeshoptDecoder(hi)}const qi=Symbol("dracoDecoderPath");let se,hi;function Dr(){se||(se=new pn.DRACOLoader,se[qi]=de,se.setDecoderPath(de),se.setDecoderConfig({type:"js"}),se.preload()),hi||(hi=dn.MeshoptDecoder)}const ji=new WeakMap;function Lr(o,e){let t=ji.get(o);t?t=Object.assign(t,e):t=e,ji.set(o,t)}const Ci=us.GLTFLoader.prototype.load;function da(...o){const e=ji.get(this);let t=o[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,n=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${n}`:this.requestHeader.Accept=`*/*;usecase=${n}`,t=i.toString()}return o[0]=t,Ci==null?void 0:Ci.call(this,...o)}us.GLTFLoader.prototype.load=da;Ge("debugprogressive");function Ge(o){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(o);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function pa(o,e){if(e===void 0||o===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=o.lastIndexOf("/");if(t>=0){const i=o.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function Pr(){return _t!==void 0||(_t=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),Ge("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",_t)),_t}let _t;function Zs(){if(typeof window>"u")return!1;const o=new URL(window.location.href),e=o.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);return o.hostname==="127.0.0.1"||e}class ma{constructor(e=100,t={}){P(this,"_running",new Map);P(this,"_queue",[]);P(this,"debug",!1);P(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:a=>this.add(i,a)})}}}const ga=typeof window>"u"&&typeof document>"u",Qi=Symbol("needle:raycast-mesh");function Ot(o){return(o==null?void 0:o[Qi])instanceof d.BufferGeometry?o[Qi]:null}function va(o,e){if((o.type==="Mesh"||o.type==="SkinnedMesh")&&!Ot(o)){const i=ya(e);i.userData={isRaycastMesh:!0},o[Qi]=i}}function _a(o=!0){if(o){if(yt)return;const e=yt=d.Mesh.prototype.raycast;d.Mesh.prototype.raycast=function(t,i){const s=this,a=Ot(s);let n;a&&s.isMesh&&(n=s.geometry,s.geometry=a),e.call(this,t,i),n&&(s.geometry=n)}}else{if(!yt)return;d.Mesh.prototype.raycast=yt,yt=null}}let yt=null;function ya(o){const e=new d.BufferGeometry;for(const t in o.attributes)e.setAttribute(t,o.getAttribute(t));return e.setIndex(o.getIndex()),e}const Ie=new Array,O=Ge("debugprogressive");let Pt,Ue=-1;if(O){let o=function(){Ue+=1,Ue>=e&&(Ue=-1),console.log(`Toggle LOD level [${Ue}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&o(),t.key==="w"&&(Pt=!Pt,console.log(`Toggle wireframe [${Pt}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Ue=i,console.log(`Set LOD level to [${Ue}]`))})}function Fr(o){if(O&&Pt!==void 0)if(Array.isArray(o))for(const e of o)Fr(e);else o&&"wireframe"in o&&(o.wireframe=Pt===!0)}const xt=new Array;let xa=0;const wa=Pr()?2:10;function ba(o){if(xt.length<wa){const i=xt.length;O&&console.warn(`[Worker] Creating new worker #${i}`);const s=ms.createWorker(o||{});return xt.push(s),s}const e=xa++%xt.length;return xt[e]}class ms{constructor(e,t){P(this,"_running",[]);P(this,"_webglRenderer",null);P(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const a of this._running)if(a.url===s.result.url){Aa(s.result),a.resolve(s.result);const n=a.url;n.startsWith("blob:")&&URL.revokeObjectURL(n)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-fysOIq2s.js").href:new URL("assets/loader.worker-fysOIq2s.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:pt&&pt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new ms(t,e)}async load(e,t){const i=ua();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:f}=await import("three");return new f})()),s=await this._webglRenderer);const c=ps().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const u={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",u),this.worker.postMessage(u),new Promise(f=>{this._running.push({url:e.toString(),resolve:f})})}}function Aa(o){var e,t,i,s,a,n,c,u,f,p,r,l,h,g,_,m;for(const v of o.geometries){const y=v.geometry,x=new d.BufferGeometry;if(x.name=y.name||"",y.index){const w=y.index;x.setIndex(Ri(w))}for(const w in y.attributes){const b=y.attributes[w],A=Ri(b);x.setAttribute(w,A)}if(y.morphAttributes)for(const w in y.morphAttributes){const A=y.morphAttributes[w].map(S=>Ri(S));x.morphAttributes[w]=A}if(x.morphTargetsRelative=y.morphTargetsRelative??!1,x.boundingBox=new d.Box3,x.boundingBox.min=new d.Vector3((e=y.boundingBox)==null?void 0:e.min.x,(t=y.boundingBox)==null?void 0:t.min.y,(i=y.boundingBox)==null?void 0:i.min.z),x.boundingBox.max=new d.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(a=y.boundingBox)==null?void 0:a.max.y,(n=y.boundingBox)==null?void 0:n.max.z),x.boundingSphere=new d.Sphere(new d.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(u=y.boundingSphere)==null?void 0:u.center.y,(f=y.boundingSphere)==null?void 0:f.center.z),(p=y.boundingSphere)==null?void 0:p.radius),y.groups)for(const w of y.groups)x.addGroup(w.start,w.count,w.materialIndex);y.userData&&(x.userData=y.userData),v.geometry=x}for(const v of o.textures){const y=v.texture;let x=null;if(y.isCompressedTexture){const w=y.mipmaps,b=((r=y.image)==null?void 0:r.width)||((h=(l=y.source)==null?void 0:l.data)==null?void 0:h.width)||-1,A=((g=y.image)==null?void 0:g.height)||((m=(_=y.source)==null?void 0:_.data)==null?void 0:m.height)||-1;x=new d.CompressedTexture(w,b,A,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else x=new d.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),x.mipmaps=y.mipmaps,x.channel=y.channel,x.source.data=y.source.data,x.flipY=y.flipY,x.premultiplyAlpha=y.premultiplyAlpha,x.unpackAlignment=y.unpackAlignment,x.matrix=new d.Matrix3(...y.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return o}function Ri(o){let e=o;if("isInterleavedBufferAttribute"in o&&o.isInterleavedBufferAttribute){const t=o.data,i=t.array,s=new d.InterleavedBuffer(i,t.stride);e=new d.InterleavedBufferAttribute(s,o.itemSize,i.byteOffset,o.normalized),e.offset=o.offset}else"isBufferAttribute"in o&&o.isBufferAttribute&&(e=new d.BufferAttribute(o.array,o.itemSize,o.normalized),e.usage=o.usage,e.gpuType=o.gpuType,e.updateRanges=o.updateRanges);return e}const Ta=Ge("gltf-progressive-worker"),Sa=Ge("gltf-progressive-reduce-mipmaps"),Ii=Symbol("needle-progressive-texture"),we="NEEDLE_progressive",B=class B{constructor(e){P(this,"parser");P(this,"url");P(this,"_isLoadingMesh");P(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[we];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var n;return this._isLoadingMesh=!1,a&&B.registerMesh(this.url,t.guid,a,(n=t.lods)==null?void 0:n.length,0,t),a})):null});const t=e.options.path;O&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return we}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",a=e[s];if(a!=null)return a;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(O==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const u of Object.keys(c.uniforms)){const f=c.uniforms[u].value;(f==null?void 0:f.isTexture)===!0&&n(f,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const u=e[c];(u==null?void 0:u.isTexture)===!0&&n(u,t)}else O&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function n(c,u){const f=i.getAssignedLODInformation(c);if(f){const p=i.lodInfos.get(f.key);if(p&&p.lods){u.min_count=Math.min(u.min_count,p.lods.length),u.max_count=Math.max(u.max_count,p.lods.length);for(let r=0;r<p.lods.length;r++){const l=p.lods[r];l.width&&(u.lods[r]=u.lods[r]||{min_height:1/0,max_height:0},u.lods[r].min_height=Math.min(u.lods[r].min_height,l.height),u.lods[r].max_height=Math.max(u.lods[r].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;if(Array.isArray(e)){for(const n of e)if(this.hasLODLevelAvailable(n,t))return!0;return!1}if(e.isMaterial===!0){for(const n of Object.keys(e)){const c=e[n];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const n of e.children)if(n.isMesh===!0&&this.hasLODLevelAvailable(n,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(a=i==null?void 0:i.userData)!=null&&a.LODS){const n=i.userData.LODS;if(s=this.lodInfos.get(n.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof d.Mesh||e.isMesh===!0){const s=e.geometry,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const n of Ie)(i=n.onBeforeGetLODMesh)==null||i.call(n,e,t);return e["LOD:requested level"]=t,B.getOrLoadLOD(s,t).then(n=>{if(Array.isArray(n)){const c=a.index||0;n=n[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],n&&s!=n&&((n==null?void 0:n.isBufferGeometry)?e.geometry=n:O&&console.error("Invalid LOD geometry",n))),n}).catch(n=>(console.error("Error loading mesh LOD",e,n),null))}else O&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const a of i.material){const n=this.assignTextureLOD(a,t);s.push(n)}return Promise.all(s).then(a=>{const n=new Array;for(const c of a)Array.isArray(c)&&n.push(...c);return n})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const n=i;for(const c of Object.keys(n.uniforms)){const u=n.uniforms[c].value;if((u==null?void 0:u.isTexture)===!0){const f=this.assignTextureLODForSlot(u,t,i,c).then(p=>(p&&n.uniforms[c].value!=p&&(n.uniforms[c].value=p,n.uniformsNeedUpdate=!0),p));s.push(f),a.push(c)}}}else for(const n of Object.keys(i)){const c=i[n];if((c==null?void 0:c.isTexture)===!0){const u=this.assignTextureLODForSlot(c,t,i,n);s.push(u),a.push(n)}}return Promise.all(s).then(n=>{const c=new Array;for(let u=0;u<n.length;u++){const f=n[u],p=a[u];f&&f.isTexture===!0?c.push({material:i,slot:p,texture:f,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof d.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):B.getOrLoadLOD(e,t).then(a=>{var n,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const u=i[s];if(u&&!O){const f=this.getAssignedLODInformation(u);if(f&&(f==null?void 0:f.level)<t)return O==="verbose"&&console.warn("Assigned texture level is already higher: ",f.level,t,i,u,a),null}if(Sa&&a.mipmaps){const f=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),f!==a.mipmaps.length&&O&&console.debug(`Reduced mipmap count from ${f} to ${a.mipmaps.length} for ${a.uuid}: ${(n=a.image)==null?void 0:n.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else O=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return O&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var n;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[we];if(c){if(!c.lods){O&&console.warn("Texture has no LODs",c);return}let u=!1;for(const f of this.parser.associations.keys())if(f.isTexture===!0){const p=this.parser.associations.get(f);(p==null?void 0:p.textures)===a&&(u=!0,B.registerTexture(this.url,f,(n=c.lods)==null?void 0:n.length,a,c))}u||this.parser.getDependency("texture",a).then(f=>{var p;f&&B.registerTexture(this.url,f,(p=c.lods)==null?void 0:p.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const n=s==null?void 0:s.extensions[we];if(n&&n.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const u=this.parser.associations.get(c);(u==null?void 0:u.meshes)===a&&B.registerMesh(this.url,n.guid,c,n.lods.length,u.primitives,n)}}}}),null}static async getOrLoadLOD(e,t){var u,f,p,r;const i=O=="verbose",s=this.getAssignedLODInformation(e);if(!s)return O&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let n;if(e.isTexture===!0){const l=e;l.source&&l.source[Ii]&&(n=l.source[Ii])}if(n||(n=B.lodInfos.get(a)),!n)O&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,B.lodInfos);else{if(t>0){let g=!1;const _=Array.isArray(n.lods);if(_&&t>=n.lods.length?g=!0:_||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(n.lods)?(u=n.lods[t])==null?void 0:u.path:n.lods;if(!l)return O&&!n["missing:uri"]&&(n["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,n)),null;const h=pa(s.url,l);if(h.endsWith(".glb")||h.endsWith(".gltf")){if(!n.guid)return console.warn("missing pointer for glb/gltf texture",n),null;const g=h+"_"+n.guid,_=await this.queue.slot(h),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await m.catch(A=>(console.error(`Error loading LOD ${t} from ${h}
3682
- `,A),null)),b=!1;if(w==null||(w instanceof d.Texture&&e instanceof d.Texture?(f=w.image)!=null&&f.data||(p=w.source)!=null&&p.data?w=this.copySettings(e,w):(b=!0,this.previouslyLoaded.delete(g)):w instanceof d.BufferGeometry&&e instanceof d.BufferGeometry&&((r=w.attributes.position)!=null&&r.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return w}if(!_.use)return O&&console.log(`LOD ${t} was aborted: ${h}`),null;const v=n,y=new Promise(async(w,b)=>{if(Ta){const T=await(await ba({})).load(h);if(T.textures.length>0)for(const R of T.textures){let L=R.texture;return B.assignLODInformation(s.url,L,a,t,void 0),e instanceof d.Texture&&(L=this.copySettings(e,L)),L&&(L.guid=v.guid),w(L)}if(T.geometries.length>0){const R=new Array;for(const L of T.geometries){const F=L.geometry;B.assignLODInformation(s.url,F,a,t,L.primitiveIndex),R.push(F)}return w(R)}return w(null)}const A=new us.GLTFLoader;Ir(A),O&&(await new Promise(D=>setTimeout(D,1e3)),i&&console.warn("Start loading (delayed) "+h,v.guid));let S=h;if(v&&Array.isArray(v.lods)){const D=v.lods[t];D.hash&&(S+="?v="+D.hash)}const C=await A.loadAsync(S).catch(D=>(console.error(`Error loading LOD ${t} from ${h}
3683
- `,D),w(null)));if(!C)return w(null);const M=C.parser;i&&console.log("Loading finished "+h,v.guid);let I=0;if(C.parser.json.textures){let D=!1;for(const T of C.parser.json.textures){if(T!=null&&T.extensions){const R=T==null?void 0:T.extensions[we];if(R!=null&&R.guid&&R.guid===v.guid){D=!0;break}}I++}if(D){let T=await M.getDependency("texture",I);return T&&B.assignLODInformation(s.url,T,a,t,void 0),i&&console.log('change "'+e.name+'" → "'+T.name+'"',h,I,T,g),e instanceof d.Texture&&(T=this.copySettings(e,T)),T&&(T.guid=v.guid),w(T)}else O&&console.warn("Could not find texture with guid",v.guid,C.parser.json)}if(I=0,C.parser.json.meshes){let D=!1;for(const T of C.parser.json.meshes){if(T!=null&&T.extensions){const R=T==null?void 0:T.extensions[we];if(R!=null&&R.guid&&R.guid===v.guid){D=!0;break}}I++}if(D){const T=await M.getDependency("mesh",I);if(i&&console.log(`Loaded Mesh "${T.name}"`,h,I,T,g),T.isMesh===!0){const R=T.geometry;return B.assignLODInformation(s.url,R,a,t,0),w(R)}else{const R=new Array;for(let L=0;L<T.children.length;L++){const F=T.children[L];if(F.isMesh===!0){const E=F.geometry;B.assignLODInformation(s.url,E,a,t,L),R.push(E)}}return w(R)}}else O&&console.warn("Could not find mesh with guid",v.guid,C.parser.json)}return w(null)});return this.previouslyLoaded.set(g,y),_.use(y),await y}else if(e instanceof d.Texture){i&&console.log("Load texture from uri: "+h);const _=await new d.TextureLoader().loadAsync(h);return _?(_.guid=n.guid,_.flipY=!1,_.needsUpdate=!0,_.colorSpace=e.colorSpace,i&&console.log(n,_)):O&&console.warn("failed loading",h),_}}return null}static assignLODInformation(e,t,i,s,a){if(!t)return;t.userData||(t.userData={});const n=new Ma(e,i,s,a);t.userData.LODS=n,"source"in t&&typeof t.source=="object"&&(t.source.LODS=n)}static getAssignedLODInformation(e){var t,i;return e?(t=e.userData)!=null&&t.LODS?e.userData.LODS:"source"in e&&((i=e.source)!=null&&i.LODS)?e.source.LODS:null:null}static copySettings(e,t){return t?(O==="verbose"&&console.debug(`Copy texture settings
3681
+ }`}),this.depthWrite=!1,this.depthTest=!1}}class Hs{constructor(e){this._renderer=e,this._quad=new ht.FullScreenQuad(new Jo)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=this._renderer,n=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new f.WebGLRenderTarget(t,i,{type:f.FloatType,colorSpace:s.colorSpace}),u=s.height,d=Math.log2(u)-2,p=1/u,r=1/(3*Math.max(Math.pow(2,d),7*16));n.material.defines.CUBEUV_MAX_MIP=`${d}.0`,n.material.defines.CUBEUV_TEXEL_WIDTH=r,n.material.defines.CUBEUV_TEXEL_HEIGHT=p,n.material.uniforms.envMap.value=e,n.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,n.material.needsUpdate=!0;const l=a.getRenderTarget(),h=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),n.render(a),a.setRenderTarget(l),a.autoClear=h;const g=new Uint16Array(t*i*4),_=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,_),c.dispose();for(let v=0,y=_.length;v<y;v++)g[v]=f.DataUtils.toHalfFloat(_[v]);const m=new f.DataTexture(g,t,i,f.RGBAFormat,f.HalfFloatType);return m.minFilter=f.LinearMipMapLinearFilter,m.magFilter=f.LinearFilter,m.wrapS=f.RepeatWrapping,m.wrapT=f.RepeatWrapping,m.mapping=f.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function $o(o){return o.extensions.get("EXT_float_blend")}const je=new f.Vector2;class ea{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Bn,this._pathTracer=new Vs(e),this._queueReset=!1,this._clock=new f.Clock,this._compilePromise=null,this._lowResPathTracer=new Vs(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new ht.FullScreenQuad(new Xo({map:null,transparent:!0,blending:f.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new f.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},this.setScene(new f.Scene,new f.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,a=so(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=ro(e),a=io(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new Ko(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new Hs(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new Hs(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:a,bvh:n,bvhChanged:c}=i;this._materials=s;const d=this._pathTracer.material;return c&&(d.bvh.updateFrom(n),d.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),d.materialIndexAttribute.updateFrom(a.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,s.start());const n=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!$o(i),e.alpha=t.alpha,this.renderToCanvas){const u=this._renderer,d=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+n/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<d||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(u),a.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?f.AdditiveBlending:f.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,u,a),a.material.blending=f.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(je);const e=Math.floor(this.renderScale*je.x),t=Math.floor(this.renderScale*je.y);if(this._pathTracer.getSize(je),je.x!==e||je.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const ta="";globalThis.GLTF_PROGRESSIVE_VERSION=ta;console.debug("[gltf-progressive] version -");let br="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",ia="https://cdn.needle.tools/static/three/0.179.1/basis2/";const sa=new URL(br+"draco_decoder.js");sa.searchParams.append("range","true");const ra=()=>({dracoDecoderPath:br,ktx2TranscoderPath:ia});function Ar(o){return{dracoLoader:Sr,meshoptDecoder:Mr}}function Tr(o){o.dracoLoader||o.setDRACOLoader(Sr),o.meshoptDecoder||o.setMeshoptDecoder(Mr)}let Sr,Mr;const Wi=new WeakMap;function Cr(o,e){let t=Wi.get(o);t?t=Object.assign(t,e):t=e,Wi.set(o,t)}const Ai=ns.GLTFLoader.prototype.load;function na(...o){const e=Wi.get(this);let t=o[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,n=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${n}`:this.requestHeader.Accept=`*/*;usecase=${n}`,t=i.toString()}return o[0]=t,Ai==null?void 0:Ai.call(this,...o)}ns.GLTFLoader.prototype.load=na;He("debugprogressive");function He(o){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(o);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function oa(o,e){if(e===void 0||o===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=o.lastIndexOf("/");if(t>=0){const i=o.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function Rr(){return gt!==void 0||(gt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),He("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",gt)),gt}let gt;function Ns(){if(typeof window>"u")return!1;const o=new URL(window.location.href),e=o.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);return o.hostname==="127.0.0.1"||e}class aa{constructor(e=100,t={}){P(this,"_running",new Map);P(this,"_queue",[]);P(this,"debug",!1);P(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:a=>this.add(i,a)})}}}const la=typeof window>"u"&&typeof document>"u",Hi=Symbol("needle:raycast-mesh");function Bt(o){return(o==null?void 0:o[Hi])instanceof f.BufferGeometry?o[Hi]:null}function ca(o,e){if((o.type==="Mesh"||o.type==="SkinnedMesh")&&!Bt(o)){const i=ha(e);i.userData={isRaycastMesh:!0},o[Hi]=i}}function ua(o=!0){if(o){if(vt)return;const e=vt=f.Mesh.prototype.raycast;f.Mesh.prototype.raycast=function(t,i){const s=this,a=Bt(s);let n;a&&s.isMesh&&(n=s.geometry,s.geometry=a),e.call(this,t,i),n&&(s.geometry=n)}}else{if(!vt)return;f.Mesh.prototype.raycast=vt,vt=null}}let vt=null;function ha(o){const e=new f.BufferGeometry;for(const t in o.attributes)e.setAttribute(t,o.getAttribute(t));return e.setIndex(o.getIndex()),e}const Ce=new Array,O=He("debugprogressive");let Dt,ze=-1;if(O){let o=function(){ze+=1,ze>=e&&(ze=-1),console.log(`Toggle LOD level [${ze}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&o(),t.key==="w"&&(Dt=!Dt,console.log(`Toggle wireframe [${Dt}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(ze=i,console.log(`Set LOD level to [${ze}]`))})}function Ir(o){if(O&&Dt!==void 0)if(Array.isArray(o))for(const e of o)Ir(e);else o&&"wireframe"in o&&(o.wireframe=Dt===!0)}const _t=new Array;let fa=0;const da=Rr()?2:10;function pa(o){if(_t.length<da){const i=_t.length;O&&console.warn(`[Worker] Creating new worker #${i}`);const s=cs.createWorker(o||{});return _t.push(s),s}const e=fa++%_t.length;return _t[e]}class cs{constructor(e,t){P(this,"_running",[]);P(this,"_webglRenderer",null);P(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const a of this._running)if(a.url===s.result.url){ma(s.result),a.resolve(s.result);const n=a.url;n.startsWith("blob:")&&URL.revokeObjectURL(n)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-fysOIq2s.js").href:new URL("assets/loader.worker-fysOIq2s.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new cs(t,e)}async load(e,t){const i=ra();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:d}=await import("three");return new d})()),s=await this._webglRenderer);const c=Ar().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const u={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",u),this.worker.postMessage(u),new Promise(d=>{this._running.push({url:e.toString(),resolve:d})})}}function ma(o){var e,t,i,s,a,n,c,u,d,p,r,l,h,g,_,m;for(const v of o.geometries){const y=v.geometry,x=new f.BufferGeometry;if(x.name=y.name||"",y.index){const w=y.index;x.setIndex(Ti(w))}for(const w in y.attributes){const b=y.attributes[w],A=Ti(b);x.setAttribute(w,A)}if(y.morphAttributes)for(const w in y.morphAttributes){const A=y.morphAttributes[w].map(S=>Ti(S));x.morphAttributes[w]=A}if(x.morphTargetsRelative=y.morphTargetsRelative??!1,x.boundingBox=new f.Box3,x.boundingBox.min=new f.Vector3((e=y.boundingBox)==null?void 0:e.min.x,(t=y.boundingBox)==null?void 0:t.min.y,(i=y.boundingBox)==null?void 0:i.min.z),x.boundingBox.max=new f.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(a=y.boundingBox)==null?void 0:a.max.y,(n=y.boundingBox)==null?void 0:n.max.z),x.boundingSphere=new f.Sphere(new f.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(u=y.boundingSphere)==null?void 0:u.center.y,(d=y.boundingSphere)==null?void 0:d.center.z),(p=y.boundingSphere)==null?void 0:p.radius),y.groups)for(const w of y.groups)x.addGroup(w.start,w.count,w.materialIndex);y.userData&&(x.userData=y.userData),v.geometry=x}for(const v of o.textures){const y=v.texture;let x=null;if(y.isCompressedTexture){const w=y.mipmaps,b=((r=y.image)==null?void 0:r.width)||((h=(l=y.source)==null?void 0:l.data)==null?void 0:h.width)||-1,A=((g=y.image)==null?void 0:g.height)||((m=(_=y.source)==null?void 0:_.data)==null?void 0:m.height)||-1;x=new f.CompressedTexture(w,b,A,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else x=new f.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),x.mipmaps=y.mipmaps,x.channel=y.channel,x.source.data=y.source.data,x.flipY=y.flipY,x.premultiplyAlpha=y.premultiplyAlpha,x.unpackAlignment=y.unpackAlignment,x.matrix=new f.Matrix3(...y.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return o}function Ti(o){let e=o;if("isInterleavedBufferAttribute"in o&&o.isInterleavedBufferAttribute){const t=o.data,i=t.array,s=new f.InterleavedBuffer(i,t.stride);e=new f.InterleavedBufferAttribute(s,o.itemSize,i.byteOffset,o.normalized),e.offset=o.offset}else"isBufferAttribute"in o&&o.isBufferAttribute&&(e=new f.BufferAttribute(o.array,o.itemSize,o.normalized),e.usage=o.usage,e.gpuType=o.gpuType,e.updateRanges=o.updateRanges);return e}const ga=He("gltf-progressive-worker"),va=He("gltf-progressive-reduce-mipmaps"),Si=Symbol("needle-progressive-texture"),ye="NEEDLE_progressive",k=class k{constructor(e){P(this,"parser");P(this,"url");P(this,"_isLoadingMesh");P(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[ye];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var n;return this._isLoadingMesh=!1,a&&k.registerMesh(this.url,t.guid,a,(n=t.lods)==null?void 0:n.length,0,t),a})):null});const t=e.options.path;O&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return ye}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",a=e[s];if(a!=null)return a;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(O==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const u of Object.keys(c.uniforms)){const d=c.uniforms[u].value;(d==null?void 0:d.isTexture)===!0&&n(d,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const u=e[c];(u==null?void 0:u.isTexture)===!0&&n(u,t)}else O&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function n(c,u){const d=i.getAssignedLODInformation(c);if(d){const p=i.lodInfos.get(d.key);if(p&&p.lods){u.min_count=Math.min(u.min_count,p.lods.length),u.max_count=Math.max(u.max_count,p.lods.length);for(let r=0;r<p.lods.length;r++){const l=p.lods[r];l.width&&(u.lods[r]=u.lods[r]||{min_height:1/0,max_height:0},u.lods[r].min_height=Math.min(u.lods[r].min_height,l.height),u.lods[r].max_height=Math.max(u.lods[r].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;if(Array.isArray(e)){for(const n of e)if(this.hasLODLevelAvailable(n,t))return!0;return!1}if(e.isMaterial===!0){for(const n of Object.keys(e)){const c=e[n];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const n of e.children)if(n.isMesh===!0&&this.hasLODLevelAvailable(n,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(a=i==null?void 0:i.userData)!=null&&a.LODS){const n=i.userData.LODS;if(s=this.lodInfos.get(n.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof f.Mesh||e.isMesh===!0){const s=e.geometry,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const n of Ce)(i=n.onBeforeGetLODMesh)==null||i.call(n,e,t);return e["LOD:requested level"]=t,k.getOrLoadLOD(s,t).then(n=>{if(Array.isArray(n)){const c=a.index||0;n=n[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],n&&s!=n&&((n==null?void 0:n.isBufferGeometry)?e.geometry=n:O&&console.error("Invalid LOD geometry",n))),n}).catch(n=>(console.error("Error loading mesh LOD",e,n),null))}else O&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const a of i.material){const n=this.assignTextureLOD(a,t);s.push(n)}return Promise.all(s).then(a=>{const n=new Array;for(const c of a)Array.isArray(c)&&n.push(...c);return n})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const n=i;for(const c of Object.keys(n.uniforms)){const u=n.uniforms[c].value;if((u==null?void 0:u.isTexture)===!0){const d=this.assignTextureLODForSlot(u,t,i,c).then(p=>(p&&n.uniforms[c].value!=p&&(n.uniforms[c].value=p,n.uniformsNeedUpdate=!0),p));s.push(d),a.push(c)}}}else for(const n of Object.keys(i)){const c=i[n];if((c==null?void 0:c.isTexture)===!0){const u=this.assignTextureLODForSlot(c,t,i,n);s.push(u),a.push(n)}}return Promise.all(s).then(n=>{const c=new Array;for(let u=0;u<n.length;u++){const d=n[u],p=a[u];d&&d.isTexture===!0?c.push({material:i,slot:p,texture:d,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof f.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):k.getOrLoadLOD(e,t).then(a=>{var n,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const u=i[s];if(u&&!O){const d=this.getAssignedLODInformation(u);if(d&&(d==null?void 0:d.level)<t)return O==="verbose"&&console.warn("Assigned texture level is already higher: ",d.level,t,i,u,a),null}if(va&&a.mipmaps){const d=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),d!==a.mipmaps.length&&O&&console.debug(`Reduced mipmap count from ${d} to ${a.mipmaps.length} for ${a.uuid}: ${(n=a.image)==null?void 0:n.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else O=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return O&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var n;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[ye];if(c){if(!c.lods){O&&console.warn("Texture has no LODs",c);return}let u=!1;for(const d of this.parser.associations.keys())if(d.isTexture===!0){const p=this.parser.associations.get(d);(p==null?void 0:p.textures)===a&&(u=!0,k.registerTexture(this.url,d,(n=c.lods)==null?void 0:n.length,a,c))}u||this.parser.getDependency("texture",a).then(d=>{var p;d&&k.registerTexture(this.url,d,(p=c.lods)==null?void 0:p.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const n=s==null?void 0:s.extensions[ye];if(n&&n.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const u=this.parser.associations.get(c);(u==null?void 0:u.meshes)===a&&k.registerMesh(this.url,n.guid,c,n.lods.length,u.primitives,n)}}}}),null}static async getOrLoadLOD(e,t){var u,d,p,r;const i=O=="verbose",s=this.getAssignedLODInformation(e);if(!s)return O&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let n;if(e.isTexture===!0){const l=e;l.source&&l.source[Si]&&(n=l.source[Si])}if(n||(n=k.lodInfos.get(a)),!n)O&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,k.lodInfos);else{if(t>0){let g=!1;const _=Array.isArray(n.lods);if(_&&t>=n.lods.length?g=!0:_||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(n.lods)?(u=n.lods[t])==null?void 0:u.path:n.lods;if(!l)return O&&!n["missing:uri"]&&(n["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,n)),null;const h=oa(s.url,l);if(h.endsWith(".glb")||h.endsWith(".gltf")){if(!n.guid)return console.warn("missing pointer for glb/gltf texture",n),null;const g=h+"_"+n.guid,_=await this.queue.slot(h),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await m.catch(A=>(console.error(`Error loading LOD ${t} from ${h}
3682
+ `,A),null)),b=!1;if(w==null||(w instanceof f.Texture&&e instanceof f.Texture?(d=w.image)!=null&&d.data||(p=w.source)!=null&&p.data?w=this.copySettings(e,w):(b=!0,this.previouslyLoaded.delete(g)):w instanceof f.BufferGeometry&&e instanceof f.BufferGeometry&&((r=w.attributes.position)!=null&&r.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return w}if(!_.use)return O&&console.log(`LOD ${t} was aborted: ${h}`),null;const v=n,y=new Promise(async(w,b)=>{if(ga){const T=await(await pa({})).load(h);if(T.textures.length>0)for(const R of T.textures){let L=R.texture;return k.assignLODInformation(s.url,L,a,t,void 0),e instanceof f.Texture&&(L=this.copySettings(e,L)),L&&(L.guid=v.guid),w(L)}if(T.geometries.length>0){const R=new Array;for(const L of T.geometries){const F=L.geometry;k.assignLODInformation(s.url,F,a,t,L.primitiveIndex),R.push(F)}return w(R)}return w(null)}const A=new ns.GLTFLoader;Tr(A),O&&(await new Promise(D=>setTimeout(D,1e3)),i&&console.warn("Start loading (delayed) "+h,v.guid));let S=h;if(v&&Array.isArray(v.lods)){const D=v.lods[t];D.hash&&(S+="?v="+D.hash)}const C=await A.loadAsync(S).catch(D=>(console.error(`Error loading LOD ${t} from ${h}
3683
+ `,D),w(null)));if(!C)return w(null);const M=C.parser;i&&console.log("Loading finished "+h,v.guid);let I=0;if(C.parser.json.textures){let D=!1;for(const T of C.parser.json.textures){if(T!=null&&T.extensions){const R=T==null?void 0:T.extensions[ye];if(R!=null&&R.guid&&R.guid===v.guid){D=!0;break}}I++}if(D){let T=await M.getDependency("texture",I);return T&&k.assignLODInformation(s.url,T,a,t,void 0),i&&console.log('change "'+e.name+'" → "'+T.name+'"',h,I,T,g),e instanceof f.Texture&&(T=this.copySettings(e,T)),T&&(T.guid=v.guid),w(T)}else O&&console.warn("Could not find texture with guid",v.guid,C.parser.json)}if(I=0,C.parser.json.meshes){let D=!1;for(const T of C.parser.json.meshes){if(T!=null&&T.extensions){const R=T==null?void 0:T.extensions[ye];if(R!=null&&R.guid&&R.guid===v.guid){D=!0;break}}I++}if(D){const T=await M.getDependency("mesh",I);if(i&&console.log(`Loaded Mesh "${T.name}"`,h,I,T,g),T.isMesh===!0){const R=T.geometry;return k.assignLODInformation(s.url,R,a,t,0),w(R)}else{const R=new Array;for(let L=0;L<T.children.length;L++){const F=T.children[L];if(F.isMesh===!0){const E=F.geometry;k.assignLODInformation(s.url,E,a,t,L),R.push(E)}}return w(R)}}else O&&console.warn("Could not find mesh with guid",v.guid,C.parser.json)}return w(null)});return this.previouslyLoaded.set(g,y),_.use(y),await y}else if(e instanceof f.Texture){i&&console.log("Load texture from uri: "+h);const _=await new f.TextureLoader().loadAsync(h);return _?(_.guid=n.guid,_.flipY=!1,_.needsUpdate=!0,_.colorSpace=e.colorSpace,i&&console.log(n,_)):O&&console.warn("failed loading",h),_}}return null}static assignLODInformation(e,t,i,s,a){if(!t)return;t.userData||(t.userData={});const n=new _a(e,i,s,a);t.userData.LODS=n,"source"in t&&typeof t.source=="object"&&(t.source.LODS=n)}static getAssignedLODInformation(e){var t,i;return e?(t=e.userData)!=null&&t.LODS?e.userData.LODS:"source"in e&&((i=e.source)!=null&&i.LODS)?e.source.LODS:null:null}static copySettings(e,t){return t?(O==="verbose"&&console.debug(`Copy texture settings
3684
3684
  `,e.uuid,`
3685
- `,t.uuid),t=t.clone(),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t.magFilter=e.magFilter,t.minFilter=e.minFilter,t.wrapS=e.wrapS,t.wrapT=e.wrapT,t.flipY=e.flipY,t.anisotropy=e.anisotropy,t.mipmaps||(t.generateMipmaps=e.generateMipmaps),t):e}};P(B,"registerTexture",(e,t,i,s,a)=>{var c,u,f,p,r,l,h,g;if(!t){O&&console.error("!! gltf-progressive: Called register texture without texture");return}if(O){const _=((c=t.image)==null?void 0:c.width)||((f=(u=t.source)==null?void 0:u.data)==null?void 0:f.width)||0,m=((p=t.image)==null?void 0:p.height)||((l=(r=t.source)==null?void 0:r.data)==null?void 0:l.height)||0;console.log(`> gltf-progressive: register texture[${s}] "${t.name||t.uuid}", Current: ${_}x${m}, Max: ${(h=a.lods[0])==null?void 0:h.width}x${(g=a.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,a,t)}t.source&&(t.source[Ii]=a);const n=a.guid;B.assignLODInformation(e,t,n,i,s),B.lodInfos.set(n,a),B.lowresCache.set(n,t)}),P(B,"registerMesh",(e,t,i,s,a,n)=>{var f;const c=i.geometry;if(!c){O&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),O&&console.log("> Progressive: register mesh "+i.name,{index:a,uuid:i.uuid},n,i),B.assignLODInformation(e,c,t,s,a),B.lodInfos.set(t,n);let u=B.lowresCache.get(t);u?u.push(i.geometry):u=[i.geometry],B.lowresCache.set(t,u),s>0&&!Ot(i)&&va(i,c);for(const p of Ie)(f=p.onRegisteredNewMesh)==null||f.call(p,i,n)}),P(B,"lodInfos",new Map),P(B,"previouslyLoaded",new Map),P(B,"lowresCache",new Map),P(B,"workers",[]),P(B,"_workersIndex",0),P(B,"maxConcurrent",50),P(B,"queue",new ma(B.maxConcurrent,{debug:O!=!1}));let ge=B;class Ma{constructor(e,t,i,s){P(this,"url");P(this,"key");P(this,"level");P(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class ai{constructor(e,t){P(this,"ready");P(this,"_resolve");P(this,"_signal");P(this,"_frame_start");P(this,"_frames_to_capture");P(this,"_resolved",!1);P(this,"_addedCount",0);P(this,"_resolvedCount",0);P(this,"_awaiting",[]);P(this,"_maxPromisesPerObject",1);P(this,"_currentFrame",0);P(this,"_seen",new WeakMap);var a;const s=Math.max(t.frames??2,2);this._frame_start=t.waitForFirstCapture?void 0:e,this._frames_to_capture=s,this.ready=new Promise(n=>{this._resolve=n}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(a=this._signal)==null||a.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,this._frame_start===void 0&&this._addedCount>0&&(this._frame_start=e),((t=this._signal)!=null&&t.aborted||this._awaiting.length===0&&this._frame_start!==void 0&&e>this._frame_start+this._frames_to_capture)&&this.resolveNow()}add(e,t,i){if(this._resolved){O&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._frame_start!==void 0&&this._currentFrame>this._frame_start+this._frames_to_capture)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let s=this._seen.get(t);if(s>=this._maxPromisesPerObject){O&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,s+1)}else this._seen.set(t,1);this._awaiting.push(i),this._addedCount++,i.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(i),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}P(ai,"addPromise",(e,t,i,s)=>{s.forEach(a=>{a.add(e,t,i)})});const he=Ge("debugprogressive"),Ca=Ge("noprogressive"),Di=Symbol("Needle:LODSManager"),Li=Symbol("Needle:LODState"),Ce=Symbol("Needle:CurrentLOD"),$={mesh_lod:-1,texture_lod:-1};var ie,be,pi,Pe,ft,mi,Ae;const W=class W{constructor(e,t){P(this,"renderer");P(this,"context");P(this,"projectionScreenMatrix",new d.Matrix4);P(this,"overrideLodLevel");P(this,"targetTriangleDensity",2e5);P(this,"skinnedMeshAutoUpdateBoundsInterval",30);P(this,"updateInterval","auto");Me(this,ie,1);P(this,"pause",!1);P(this,"manual",!1);P(this,"_newPromiseGroups",[]);P(this,"_promiseGroupIds",0);P(this,"_lodchangedlisteners",[]);Me(this,be,void 0);Me(this,pi,new d.Clock);Me(this,Pe,0);Me(this,ft,0);Me(this,mi,0);Me(this,Ae,0);P(this,"_fpsBuffer",[60,60,60,60,60]);P(this,"_sphere",new d.Sphere);P(this,"_tempBox",new d.Box3);P(this,"_tempBox2",new d.Box3);P(this,"tempMatrix",new d.Matrix4);P(this,"_tempWorldPosition",new d.Vector3);P(this,"_tempBoxSize",new d.Vector3);P(this,"_tempBox2Size",new d.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Li]}static addPlugin(e){Ie.push(e)}static removePlugin(e){const t=Ie.indexOf(e);t>=0&&Ie.splice(t,1)}static get(e,t){if(e[Di])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[Di];const i=new W(e,{engine:"unknown",...t});return e[Di]=i,i}get plugins(){return Ie}awaitLoading(e){const t=this._promiseGroupIds++,i=new ai(V(this,Pe),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const a=this._newPromiseGroups.indexOf(i);a>=0&&(this._newPromiseGroups.splice(a,1),Zs()&&performance.measure("LODsManager:awaitLoading",{start:s,detail:{id:t,name:e==null?void 0:e.name,awaited:i.awaitedCount,resolved:i.resolvedCount}}))}),i.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let e=this._newPromiseGroups.length-1;e>=0;e--)this._newPromiseGroups[e].update(V(this,Pe))}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const i=this._lodchangedlisteners.indexOf(t);i>=0&&this._lodchangedlisteners.splice(i,1)}}enable(){if(V(this,be))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;me(this,be,this.renderer.render);const t=this;ps(this.renderer),this.renderer.render=function(i,s){const a=t.renderer.getRenderTarget();(a==null||"isXRRenderTarget"in a&&a.isXRRenderTarget)&&(e=0,me(t,Pe,V(t,Pe)+1),me(t,ft,V(t,pi).getDelta()),me(t,mi,V(t,mi)+V(t,ft)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/V(t,ft)),me(t,Ae,t._fpsBuffer.reduce((c,u)=>c+u)/t._fpsBuffer.length),he&&V(t,Pe)%200===0&&console.log("FPS",Math.round(V(t,Ae)),"Interval:",V(t,ie)));const n=e++;V(t,be).call(this,i,s),t.onAfterRender(i,s,n)}}disable(){V(this,be)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=V(this,be),me(this,be,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const a=this.renderer.renderLists.get(e,0).opaque;let n=!0;if(a.length===1){const c=a[0].material;(c.name==="EffectMaterial"||c.name==="CopyShader")&&(n=!1)}if((t.parent&&t.parent.type==="CubeCamera"||i>=1&&t.type==="OrthographicCamera")&&(n=!1),n){if(Ca||(this.updateInterval==="auto"?V(this,Ae)<40&&V(this,ie)<10?(me(this,ie,V(this,ie)+1),he&&console.warn("↓ Reducing LOD updates",V(this,ie),V(this,Ae).toFixed(0))):V(this,Ae)>=60&&V(this,ie)>1&&(me(this,ie,V(this,ie)-1),he&&console.warn("↑ Increasing LOD updates",V(this,ie),V(this,Ae).toFixed(0))):me(this,ie,this.updateInterval),V(this,ie)>0&&V(this,Pe)%V(this,ie)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var u,f;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const a=this.targetTriangleDensity;for(const p of s){if(p.material&&(((u=p.geometry)==null?void 0:u.type)==="BoxGeometry"||((f=p.geometry)==null?void 0:f.type)==="BufferGeometry")&&(p.material.name==="SphericalGaussianBlur"||p.material.name=="BackgroundCubeMaterial"||p.material.name==="CubemapFromEquirect"||p.material.name==="EquirectangularToCubeUV")){he&&(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",p,p.material.name,p.material.type)));continue}switch(p.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(he==="color"&&p.material&&!p.object.progressive_debug_color){p.object.progressive_debug_color=!0;const l=Math.random()*16777215,h=new d.MeshStandardMaterial({color:l});p.object.material=h}const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const n=i.transparent;for(const p of n){const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const c=i.transmissive;for(const p of c){const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}}updateLODs(e,t,i,s){var c,u;i.userData||(i.userData={});let a=i[Li];if(a||(a=new Ra,i[Li]=a),a.frames++<2)return;for(const f of Ie)(c=f.onBeforeUpdateLOD)==null||c.call(f,this.renderer,e,t,i);const n=this.overrideLodLevel!==void 0?this.overrideLodLevel:Ue;n>=0?($.mesh_lod=n,$.texture_lod=n):(this.calculateLodLevel(t,i,a,s,$),$.mesh_lod=Math.round($.mesh_lod),$.texture_lod=Math.round($.texture_lod)),$.mesh_lod>=0&&this.loadProgressiveMeshes(i,$.mesh_lod),i.material&&$.texture_lod>=0&&this.loadProgressiveTextures(i.material,$.texture_lod,n),O&&i.material&&!i.isGizmo&&Fr(i.material);for(const f of Ie)(u=f.onAfterUpdatedLOD)==null||u.call(f,this.renderer,e,t,i,$);a.lastLodLevel_Mesh=$.mesh_lod,a.lastLodLevel_Texture=$.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const a of e)this.loadProgressiveTextures(a,t);return}let s=!1;if((e[Ce]===void 0||t<e[Ce])&&(s=!0),i!==void 0&&i>=0&&(s=e[Ce]!=i,t=i),s){e[Ce]=t;const a=ge.assignTextureLOD(e,t).then(n=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});ai.addPromise("texture",e,a,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[Ce]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[Ce]!=s,t=s),i){e[Ce]=t;const a=e.geometry,n=ge.assignMeshLOD(e,t).then(c=>(c&&e[Ce]==t&&a!=e.geometry&&this._lodchangedlisteners.forEach(u=>u({type:"mesh",level:t,object:e})),c));return ai.addPromise("mesh",e,n,this._newPromiseGroups),n}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,a=(i.x+s.x)*.5,n=(i.y+s.y)*.5;return this._tempPtInside.set(a,n,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,a){var m,v,y,x;if(!t){a.mesh_lod=-1,a.texture_lod=-1;return}if(!e){a.mesh_lod=-1,a.texture_lod=-1;return}let c=10+1,u=!1;if(he&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const f=(m=ge.getMeshLODExtension(t.geometry))==null?void 0:m.lods,p=ge.getPrimitiveIndex(t.geometry),r=f&&f.length>0,l=ge.getMaterialMinMaxLODsCount(t.material),h=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!r&&!h){a.mesh_lod=0,a.texture_lod=0;return}r||(u=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let _=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const w=t;if(!w.boundingBox)w.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!w[W.$skinnedMeshBoundsOffset]){const A=W.skinnedMeshBoundsFrameOffsetCounter++;w[W.$skinnedMeshBoundsOffset]=A}const b=w[W.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const A=Ot(w),S=w.geometry;A&&(w.geometry=A),w.computeBoundingBox(),w.geometry=S}}_=w.boundingBox}if(_){const w=e;if(t.geometry.attributes.color&&t.geometry.attributes.color.count<100&&t.geometry.boundingSphere){this._sphere.copy(t.geometry.boundingSphere),this._sphere.applyMatrix4(t.matrixWorld);const R=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(R)){a.mesh_lod=0,a.texture_lod=0;return}}if(this._tempBox.copy(_),this._tempBox.applyMatrix4(t.matrixWorld),w.isPerspectiveCamera&&W.isInside(this._tempBox,this.projectionScreenMatrix)){a.mesh_lod=0,a.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&w.isPerspectiveCamera&&w.fov>70){const R=this._tempBox.min,L=this._tempBox.max;let F=R.x,E=R.y,z=L.x,N=L.y;const j=2,Z=1.5,K=(R.x+L.x)*.5,U=(R.y+L.y)*.5;F=(F-K)*j+K,E=(E-U)*j+U,z=(z-K)*j+K,N=(N-U)*j+U;const G=F<0&&z>0?0:Math.min(Math.abs(R.x),Math.abs(L.x)),ne=E<0&&N>0?0:Math.min(Math.abs(R.y),Math.abs(L.y)),te=Math.max(G,ne);i.lastCentrality=(Z-te)*(Z-te)*(Z-te)}else i.lastCentrality=1;const b=this._tempBox.getSize(this._tempBoxSize);b.multiplyScalar(.5),screen.availHeight>0&&g>0&&b.multiplyScalar(g/screen.availHeight),e.isPerspectiveCamera?b.x*=e.aspect:e.isOrthographicCamera;const A=e.matrixWorldInverse,S=this._tempBox2;S.copy(_),S.applyMatrix4(t.matrixWorld),S.applyMatrix4(A);const C=S.getSize(this._tempBox2Size),M=Math.max(C.x,C.y);if(Math.max(b.x,b.y)!=0&&M!=0&&(b.z=C.z/Math.max(C.x,C.y)*Math.max(b.x,b.y)),i.lastScreenCoverage=Math.max(b.x,b.y,b.z),i.lastScreenspaceVolume.copy(b),i.lastScreenCoverage*=i.lastCentrality,he&&W.debugDrawLine){const R=this.tempMatrix.copy(this.projectionScreenMatrix);R.invert();const L=W.corner0,F=W.corner1,E=W.corner2,z=W.corner3;L.copy(this._tempBox.min),F.copy(this._tempBox.max),F.x=L.x,E.copy(this._tempBox.max),E.y=L.y,z.copy(this._tempBox.max);const N=(L.z+z.z)*.5;L.z=F.z=E.z=z.z=N,L.applyMatrix4(R),F.applyMatrix4(R),E.applyMatrix4(R),z.applyMatrix4(R),W.debugDrawLine(L,F,255),W.debugDrawLine(L,E,255),W.debugDrawLine(F,z,255),W.debugDrawLine(E,z,255)}let D=999;if(f&&i.lastScreenCoverage>0)for(let R=0;R<f.length;R++){const L=f[R],E=(((v=L.densities)==null?void 0:v[p])||L.density||1e-5)/i.lastScreenCoverage;if(p>0&&Zs()&&!L.densities&&!globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]&&(window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]=!0,console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")),E<s){D=R;break}}D<c&&(c=D,u=!0)}if(u?a.mesh_lod=c:a.mesh_lod=i.lastLodLevel_Mesh,he&&a.mesh_lod!=i.lastLodLevel_Mesh){const b=f==null?void 0:f[a.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${a.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[p].toFixed(0)}) | ${t.name}`)}if(h){const w="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(a.texture_lod=l.max_count-1,he){const b=l.lods[l.max_count-1];he&&console.log(`First Texture LOD ${a.texture_lod} (${b.max_height}px) - ${t.name}`)}}else{const b=i.lastScreenspaceVolume.x+i.lastScreenspaceVolume.y+i.lastScreenspaceVolume.z;let A=i.lastScreenCoverage*4;((x=this.context)==null?void 0:x.engine)==="model-viewer"&&(A*=1.5);const C=g/window.devicePixelRatio*A;let M=!1;for(let I=l.lods.length-1;I>=0;I--){const D=l.lods[I];if(!(w&&D.max_height>=2048)&&!(Pr()&&D.max_height>4096)&&(D.max_height>C||!M&&I===0)){if(M=!0,a.texture_lod=I,he&&a.texture_lod<i.lastLodLevel_Texture){const T=D.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${a.texture_lod} = ${T}px
3685
+ `,t.uuid),t=t.clone(),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t.magFilter=e.magFilter,t.minFilter=e.minFilter,t.wrapS=e.wrapS,t.wrapT=e.wrapT,t.flipY=e.flipY,t.anisotropy=e.anisotropy,t.mipmaps||(t.generateMipmaps=e.generateMipmaps),t):e}};P(k,"registerTexture",(e,t,i,s,a)=>{var c,u,d,p,r,l,h,g;if(!t){O&&console.error("!! gltf-progressive: Called register texture without texture");return}if(O){const _=((c=t.image)==null?void 0:c.width)||((d=(u=t.source)==null?void 0:u.data)==null?void 0:d.width)||0,m=((p=t.image)==null?void 0:p.height)||((l=(r=t.source)==null?void 0:r.data)==null?void 0:l.height)||0;console.log(`> gltf-progressive: register texture[${s}] "${t.name||t.uuid}", Current: ${_}x${m}, Max: ${(h=a.lods[0])==null?void 0:h.width}x${(g=a.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,a,t)}t.source&&(t.source[Si]=a);const n=a.guid;k.assignLODInformation(e,t,n,i,s),k.lodInfos.set(n,a),k.lowresCache.set(n,t)}),P(k,"registerMesh",(e,t,i,s,a,n)=>{var d;const c=i.geometry;if(!c){O&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),O&&console.log("> Progressive: register mesh "+i.name,{index:a,uuid:i.uuid},n,i),k.assignLODInformation(e,c,t,s,a),k.lodInfos.set(t,n);let u=k.lowresCache.get(t);u?u.push(i.geometry):u=[i.geometry],k.lowresCache.set(t,u),s>0&&!Bt(i)&&ca(i,c);for(const p of Ce)(d=p.onRegisteredNewMesh)==null||d.call(p,i,n)}),P(k,"lodInfos",new Map),P(k,"previouslyLoaded",new Map),P(k,"lowresCache",new Map),P(k,"workers",[]),P(k,"_workersIndex",0),P(k,"maxConcurrent",50),P(k,"queue",new aa(k.maxConcurrent,{debug:O!=!1}));let pe=k;class _a{constructor(e,t,i,s){P(this,"url");P(this,"key");P(this,"level");P(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class ni{constructor(e,t){P(this,"ready");P(this,"_resolve");P(this,"_signal");P(this,"_frame_start");P(this,"_frames_to_capture");P(this,"_resolved",!1);P(this,"_addedCount",0);P(this,"_resolvedCount",0);P(this,"_awaiting",[]);P(this,"_maxPromisesPerObject",1);P(this,"_currentFrame",0);P(this,"_seen",new WeakMap);var a;const s=Math.max(t.frames??2,2);this._frame_start=t.waitForFirstCapture?void 0:e,this._frames_to_capture=s,this.ready=new Promise(n=>{this._resolve=n}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(a=this._signal)==null||a.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,this._frame_start===void 0&&this._addedCount>0&&(this._frame_start=e),((t=this._signal)!=null&&t.aborted||this._awaiting.length===0&&this._frame_start!==void 0&&e>this._frame_start+this._frames_to_capture)&&this.resolveNow()}add(e,t,i){if(this._resolved){O&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._frame_start!==void 0&&this._currentFrame>this._frame_start+this._frames_to_capture)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let s=this._seen.get(t);if(s>=this._maxPromisesPerObject){O&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,s+1)}else this._seen.set(t,1);this._awaiting.push(i),this._addedCount++,i.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(i),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}P(ni,"addPromise",(e,t,i,s)=>{s.forEach(a=>{a.add(e,t,i)})});const ue=He("debugprogressive"),ya=He("noprogressive"),Mi=Symbol("Needle:LODSManager"),Ci=Symbol("Needle:LODState"),Se=Symbol("Needle:CurrentLOD"),$={mesh_lod:-1,texture_lod:-1};var ie,xe,hi,De,ut,fi,we;const W=class W{constructor(e,t){P(this,"renderer");P(this,"context");P(this,"projectionScreenMatrix",new f.Matrix4);P(this,"overrideLodLevel");P(this,"targetTriangleDensity",2e5);P(this,"skinnedMeshAutoUpdateBoundsInterval",30);P(this,"updateInterval","auto");Te(this,ie,1);P(this,"pause",!1);P(this,"manual",!1);P(this,"_newPromiseGroups",[]);P(this,"_promiseGroupIds",0);P(this,"_lodchangedlisteners",[]);Te(this,xe,void 0);Te(this,hi,new f.Clock);Te(this,De,0);Te(this,ut,0);Te(this,fi,0);Te(this,we,0);P(this,"_fpsBuffer",[60,60,60,60,60]);P(this,"_sphere",new f.Sphere);P(this,"_tempBox",new f.Box3);P(this,"_tempBox2",new f.Box3);P(this,"tempMatrix",new f.Matrix4);P(this,"_tempWorldPosition",new f.Vector3);P(this,"_tempBoxSize",new f.Vector3);P(this,"_tempBox2Size",new f.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Ci]}static addPlugin(e){Ce.push(e)}static removePlugin(e){const t=Ce.indexOf(e);t>=0&&Ce.splice(t,1)}static get(e,t){if(e[Mi])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[Mi];const i=new W(e,{engine:"unknown",...t});return e[Mi]=i,i}get plugins(){return Ce}awaitLoading(e){const t=this._promiseGroupIds++,i=new ni(V(this,De),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const a=this._newPromiseGroups.indexOf(i);a>=0&&(this._newPromiseGroups.splice(a,1),Ns()&&performance.measure("LODsManager:awaitLoading",{start:s,detail:{id:t,name:e==null?void 0:e.name,awaited:i.awaitedCount,resolved:i.resolvedCount}}))}),i.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let e=this._newPromiseGroups.length-1;e>=0;e--)this._newPromiseGroups[e].update(V(this,De))}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const i=this._lodchangedlisteners.indexOf(t);i>=0&&this._lodchangedlisteners.splice(i,1)}}enable(){if(V(this,xe))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;de(this,xe,this.renderer.render);const t=this;Ar(this.renderer),this.renderer.render=function(i,s){const a=t.renderer.getRenderTarget();(a==null||"isXRRenderTarget"in a&&a.isXRRenderTarget)&&(e=0,de(t,De,V(t,De)+1),de(t,ut,V(t,hi).getDelta()),de(t,fi,V(t,fi)+V(t,ut)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/V(t,ut)),de(t,we,t._fpsBuffer.reduce((c,u)=>c+u)/t._fpsBuffer.length),ue&&V(t,De)%200===0&&console.log("FPS",Math.round(V(t,we)),"Interval:",V(t,ie)));const n=e++;V(t,xe).call(this,i,s),t.onAfterRender(i,s,n)}}disable(){V(this,xe)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=V(this,xe),de(this,xe,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const a=this.renderer.renderLists.get(e,0).opaque;let n=!0;if(a.length===1){const c=a[0].material;(c.name==="EffectMaterial"||c.name==="CopyShader")&&(n=!1)}if((t.parent&&t.parent.type==="CubeCamera"||i>=1&&t.type==="OrthographicCamera")&&(n=!1),n){if(ya||(this.updateInterval==="auto"?V(this,we)<40&&V(this,ie)<10?(de(this,ie,V(this,ie)+1),ue&&console.warn("↓ Reducing LOD updates",V(this,ie),V(this,we).toFixed(0))):V(this,we)>=60&&V(this,ie)>1&&(de(this,ie,V(this,ie)-1),ue&&console.warn("↑ Increasing LOD updates",V(this,ie),V(this,we).toFixed(0))):de(this,ie,this.updateInterval),V(this,ie)>0&&V(this,De)%V(this,ie)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var u,d;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const a=this.targetTriangleDensity;for(const p of s){if(p.material&&(((u=p.geometry)==null?void 0:u.type)==="BoxGeometry"||((d=p.geometry)==null?void 0:d.type)==="BufferGeometry")&&(p.material.name==="SphericalGaussianBlur"||p.material.name=="BackgroundCubeMaterial"||p.material.name==="CubemapFromEquirect"||p.material.name==="EquirectangularToCubeUV")){ue&&(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",p,p.material.name,p.material.type)));continue}switch(p.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(ue==="color"&&p.material&&!p.object.progressive_debug_color){p.object.progressive_debug_color=!0;const l=Math.random()*16777215,h=new f.MeshStandardMaterial({color:l});p.object.material=h}const r=p.object;(r instanceof f.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const n=i.transparent;for(const p of n){const r=p.object;(r instanceof f.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const c=i.transmissive;for(const p of c){const r=p.object;(r instanceof f.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}}updateLODs(e,t,i,s){var c,u;i.userData||(i.userData={});let a=i[Ci];if(a||(a=new xa,i[Ci]=a),a.frames++<2)return;for(const d of Ce)(c=d.onBeforeUpdateLOD)==null||c.call(d,this.renderer,e,t,i);const n=this.overrideLodLevel!==void 0?this.overrideLodLevel:ze;n>=0?($.mesh_lod=n,$.texture_lod=n):(this.calculateLodLevel(t,i,a,s,$),$.mesh_lod=Math.round($.mesh_lod),$.texture_lod=Math.round($.texture_lod)),$.mesh_lod>=0&&this.loadProgressiveMeshes(i,$.mesh_lod),i.material&&$.texture_lod>=0&&this.loadProgressiveTextures(i.material,$.texture_lod,n),O&&i.material&&!i.isGizmo&&Ir(i.material);for(const d of Ce)(u=d.onAfterUpdatedLOD)==null||u.call(d,this.renderer,e,t,i,$);a.lastLodLevel_Mesh=$.mesh_lod,a.lastLodLevel_Texture=$.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const a of e)this.loadProgressiveTextures(a,t);return}let s=!1;if((e[Se]===void 0||t<e[Se])&&(s=!0),i!==void 0&&i>=0&&(s=e[Se]!=i,t=i),s){e[Se]=t;const a=pe.assignTextureLOD(e,t).then(n=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});ni.addPromise("texture",e,a,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[Se]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[Se]!=s,t=s),i){e[Se]=t;const a=e.geometry,n=pe.assignMeshLOD(e,t).then(c=>(c&&e[Se]==t&&a!=e.geometry&&this._lodchangedlisteners.forEach(u=>u({type:"mesh",level:t,object:e})),c));return ni.addPromise("mesh",e,n,this._newPromiseGroups),n}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,a=(i.x+s.x)*.5,n=(i.y+s.y)*.5;return this._tempPtInside.set(a,n,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,a){var m,v,y,x;if(!t){a.mesh_lod=-1,a.texture_lod=-1;return}if(!e){a.mesh_lod=-1,a.texture_lod=-1;return}let c=10+1,u=!1;if(ue&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const d=(m=pe.getMeshLODExtension(t.geometry))==null?void 0:m.lods,p=pe.getPrimitiveIndex(t.geometry),r=d&&d.length>0,l=pe.getMaterialMinMaxLODsCount(t.material),h=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!r&&!h){a.mesh_lod=0,a.texture_lod=0;return}r||(u=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let _=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const w=t;if(!w.boundingBox)w.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!w[W.$skinnedMeshBoundsOffset]){const A=W.skinnedMeshBoundsFrameOffsetCounter++;w[W.$skinnedMeshBoundsOffset]=A}const b=w[W.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const A=Bt(w),S=w.geometry;A&&(w.geometry=A),w.computeBoundingBox(),w.geometry=S}}_=w.boundingBox}if(_){const w=e;if(t.geometry.attributes.color&&t.geometry.attributes.color.count<100&&t.geometry.boundingSphere){this._sphere.copy(t.geometry.boundingSphere),this._sphere.applyMatrix4(t.matrixWorld);const R=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(R)){a.mesh_lod=0,a.texture_lod=0;return}}if(this._tempBox.copy(_),this._tempBox.applyMatrix4(t.matrixWorld),w.isPerspectiveCamera&&W.isInside(this._tempBox,this.projectionScreenMatrix)){a.mesh_lod=0,a.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&w.isPerspectiveCamera&&w.fov>70){const R=this._tempBox.min,L=this._tempBox.max;let F=R.x,E=R.y,z=L.x,N=L.y;const j=2,Z=1.5,K=(R.x+L.x)*.5,U=(R.y+L.y)*.5;F=(F-K)*j+K,E=(E-U)*j+U,z=(z-K)*j+K,N=(N-U)*j+U;const G=F<0&&z>0?0:Math.min(Math.abs(R.x),Math.abs(L.x)),re=E<0&&N>0?0:Math.min(Math.abs(R.y),Math.abs(L.y)),te=Math.max(G,re);i.lastCentrality=(Z-te)*(Z-te)*(Z-te)}else i.lastCentrality=1;const b=this._tempBox.getSize(this._tempBoxSize);b.multiplyScalar(.5),screen.availHeight>0&&g>0&&b.multiplyScalar(g/screen.availHeight),e.isPerspectiveCamera?b.x*=e.aspect:e.isOrthographicCamera;const A=e.matrixWorldInverse,S=this._tempBox2;S.copy(_),S.applyMatrix4(t.matrixWorld),S.applyMatrix4(A);const C=S.getSize(this._tempBox2Size),M=Math.max(C.x,C.y);if(Math.max(b.x,b.y)!=0&&M!=0&&(b.z=C.z/Math.max(C.x,C.y)*Math.max(b.x,b.y)),i.lastScreenCoverage=Math.max(b.x,b.y,b.z),i.lastScreenspaceVolume.copy(b),i.lastScreenCoverage*=i.lastCentrality,ue&&W.debugDrawLine){const R=this.tempMatrix.copy(this.projectionScreenMatrix);R.invert();const L=W.corner0,F=W.corner1,E=W.corner2,z=W.corner3;L.copy(this._tempBox.min),F.copy(this._tempBox.max),F.x=L.x,E.copy(this._tempBox.max),E.y=L.y,z.copy(this._tempBox.max);const N=(L.z+z.z)*.5;L.z=F.z=E.z=z.z=N,L.applyMatrix4(R),F.applyMatrix4(R),E.applyMatrix4(R),z.applyMatrix4(R),W.debugDrawLine(L,F,255),W.debugDrawLine(L,E,255),W.debugDrawLine(F,z,255),W.debugDrawLine(E,z,255)}let D=999;if(d&&i.lastScreenCoverage>0)for(let R=0;R<d.length;R++){const L=d[R],E=(((v=L.densities)==null?void 0:v[p])||L.density||1e-5)/i.lastScreenCoverage;if(p>0&&Ns()&&!L.densities&&!globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]&&(window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]=!0,console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")),E<s){D=R;break}}D<c&&(c=D,u=!0)}if(u?a.mesh_lod=c:a.mesh_lod=i.lastLodLevel_Mesh,ue&&a.mesh_lod!=i.lastLodLevel_Mesh){const b=d==null?void 0:d[a.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${a.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[p].toFixed(0)}) | ${t.name}`)}if(h){const w="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(a.texture_lod=l.max_count-1,ue){const b=l.lods[l.max_count-1];ue&&console.log(`First Texture LOD ${a.texture_lod} (${b.max_height}px) - ${t.name}`)}}else{const b=i.lastScreenspaceVolume.x+i.lastScreenspaceVolume.y+i.lastScreenspaceVolume.z;let A=i.lastScreenCoverage*4;((x=this.context)==null?void 0:x.engine)==="model-viewer"&&(A*=1.5);const C=g/window.devicePixelRatio*A;let M=!1;for(let I=l.lods.length-1;I>=0;I--){const D=l.lods[I];if(!(w&&D.max_height>=2048)&&!(Rr()&&D.max_height>4096)&&(D.max_height>C||!M&&I===0)){if(M=!0,a.texture_lod=I,ue&&a.texture_lod<i.lastLodLevel_Texture){const T=D.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${a.texture_lod} = ${T}px
3686
3686
  Screensize: ${C.toFixed(0)}px, Coverage: ${(100*i.lastScreenCoverage).toFixed(2)}%, Volume ${b.toFixed(1)}
3687
- ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new WeakMap,Pe=new WeakMap,ft=new WeakMap,mi=new WeakMap,Ae=new WeakMap,P(W,"debugDrawLine"),P(W,"corner0",new d.Vector3),P(W,"corner1",new d.Vector3),P(W,"corner2",new d.Vector3),P(W,"corner3",new d.Vector3),P(W,"_tempPtInside",new d.Vector3),P(W,"skinnedMeshBoundsFrameOffsetCounter",0),P(W,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset"));let mt=W;class Ra{constructor(){P(this,"frames",0);P(this,"lastLodLevel_Mesh",-1);P(this,"lastLodLevel_Texture",-1);P(this,"lastScreenCoverage",0);P(this,"lastScreenspaceVolume",new d.Vector3);P(this,"lastCentrality",0)}}const Ks=Symbol("NEEDLE_mesh_lod"),jt=Symbol("NEEDLE_texture_lod");let wt=null;function Er(){const o=Ia();o&&(o.mapURLs(function(e){return Xs(),e}),Xs(),wt==null||wt.disconnect(),wt=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&i.tagName.toLowerCase()==="model-viewer"&&kr(i)})})}),wt.observe(document,{childList:!0,subtree:!0}))}function Ia(){if(typeof customElements>"u")return null;const o=customElements.get("model-viewer");return o||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Er()}),null)}function Xs(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{kr(e)})}const Js=new WeakSet;let Da=0;function kr(o){if(!o||Js.has(o))return null;Js.add(o),console.debug("[gltf-progressive] found new model-viewer..."+ ++Da+`
3688
- `,o.getAttribute("src"));let e=null,t=null,i=null;for(let s=o;s!=null;s=Object.getPrototypeOf(s)){const a=Object.getOwnPropertySymbols(s),n=a.find(f=>f.toString()=="Symbol(renderer)"),c=a.find(f=>f.toString()=="Symbol(scene)"),u=a.find(f=>f.toString()=="Symbol(needsRender)");!e&&n!=null&&(e=o[n].threeRenderer),!t&&c!=null&&(t=o[c]),!i&&u!=null&&(i=o[u])}if(e&&t){let s=function(){if(i){let n=0,c=setInterval(()=>{if(n++>5){clearInterval(c);return}i==null||i.call(o)},300)}};console.debug("[gltf-progressive] setup model-viewer");const a=mt.get(e,{engine:"model-viewer"});return mt.addPlugin(new La),a.enable(),a.addEventListener("changed",()=>{i==null||i.call(o)}),o.addEventListener("model-visibility",n=>{n.detail.visible&&(i==null||i.call(o))}),o.addEventListener("load",()=>{s()}),()=>{a.disable()}}return null}class La{constructor(){P(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,i,s){this.tryParseMeshLOD(t,s),this.tryParseTextureLOD(t,s)}getUrl(e){if(!e)return null;let t=e.getAttribute("src");return t||(t=e.src),t||(this._didWarnAboutMissingUrl||console.warn("No url found in modelviewer",e),this._didWarnAboutMissingUrl=!0),t}tryGetCurrentGLTF(e){return e._currentGLTF}tryGetCurrentModelViewer(e){return e.element}tryParseTextureLOD(e,t){if(t[jt]==!0)return;t[jt]=!0;const i=this.tryGetCurrentGLTF(e),s=this.tryGetCurrentModelViewer(e),a=this.getUrl(s);if(a&&i&&t.material){let n=function(u){var p,r,l;if(u[jt]==!0)return;u[jt]=!0,u.userData&&(u.userData.LOD=-1);const f=Object.keys(u);for(let h=0;h<f.length;h++){const g=f[h],_=u[g];if((_==null?void 0:_.isTexture)===!0){const m=(r=(p=_.userData)==null?void 0:p.associations)==null?void 0:r.textures;if(m==null)continue;const v=i.parser.json.textures[m];if(!v){console.warn("Texture data not found for texture index "+m);continue}if((l=v==null?void 0:v.extensions)!=null&&l[we]){const y=v.extensions[we];y&&a&&ge.registerTexture(a,_,y.lods.length,m,y)}}}};const c=t.material;if(Array.isArray(c))for(const u of c)n(u);else n(c)}}tryParseMeshLOD(e,t){var n,c;if(t[Ks]==!0)return;t[Ks]=!0;const i=this.tryGetCurrentModelViewer(e),s=this.getUrl(i);if(!s)return;const a=(c=(n=t.userData)==null?void 0:n.gltfExtensions)==null?void 0:c[we];if(a&&s){const u=t.uuid;ge.registerMesh(s,u,t,0,a.lods.length,a)}}}function Br(...o){let e,t,i,s;switch(o.length){case 2:[i,t]=o,s={};break;case 3:[i,t,s]=o;break;case 4:[e,t,i,s]=o;break;default:throw new Error("Invalid arguments")}ps(),Ir(i),Lr(i,{progressive:!0,...s==null?void 0:s.hints}),i.register(n=>new ge(n));const a=mt.get(t);return(s==null?void 0:s.enableLODsManager)!==!1&&a.enable(),a}Er();if(!ga){const o={gltfProgressive:{useNeedleProgressive:Br,LODsManager:mt,configureLoader:Lr,getRaycastMesh:Ot,useRaycastMeshes:_a}};if(!globalThis.Needle)globalThis.Needle=o;else for(const e in o)globalThis.Needle[e]=o[e]}var ut=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-ut.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?ut.Bounce.In(o*2)*.5:ut.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),lt=function(){return performance.now()},Or=function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=lt()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var a=this._tweens[i[s]],n=!t;a&&a.update(e,n)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},o}(),He={Linear:function(o,e){var t=o.length-1,i=t*e,s=Math.floor(i),a=He.Utils.Linear;return e<0?a(o[0],o[1],i):e>1?a(o[t],o[t-1],t-i):a(o[s],o[s+1>t?t:s+1],i-s)},Bezier:function(o,e){for(var t=0,i=o.length-1,s=Math.pow,a=He.Utils.Bernstein,n=0;n<=i;n++)t+=s(1-e,i-n)*s(e,n)*o[n]*a(i,n);return t},CatmullRom:function(o,e){var t=o.length-1,i=t*e,s=Math.floor(i),a=He.Utils.CatmullRom;return o[0]===o[t]?(e<0&&(s=Math.floor(i=t*(1+e))),a(o[(s-1+t)%t],o[s],o[(s+1)%t],o[(s+2)%t],i-s)):e<0?o[0]-(a(o[0],o[0],o[1],o[1],-i)-o[0]):e>1?o[t]-(a(o[t],o[t],o[t-1],o[t-1],i-t)-o[t]):a(o[s?s-1:0],o[s],o[t<s+1?t:s+1],o[t<s+2?t:s+2],i-s)},Utils:{Linear:function(o,e,t){return(e-o)*t+o},Bernstein:function(o,e){var t=He.Utils.Factorial;return t(o)/t(e)/t(o-e)},Factorial:function(){var o=[1];return function(e){var t=1;if(o[e])return o[e];for(var i=e;i>1;i--)t*=i;return o[e]=t,t}}(),CatmullRom:function(o,e,t,i,s){var a=(t-o)*.5,n=(i-e)*.5,c=s*s,u=s*c;return(2*e-2*t+a+n)*u+(-3*e+3*t-2*a-n)*c+a*s+e}}},gs=function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o}(),Yi=new Or,fi=function(){function o(e,t){t===void 0&&(t=Yi),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ut.Linear.None,this._interpolationFunction=He.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=gs.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=lt()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var a in this._valuesEnd)s[a]=this._valuesEnd[a];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,i,s,a){for(var n in i){var c=e[n],u=Array.isArray(c),f=u?"array":typeof c,p=!u&&Array.isArray(i[n]);if(!(f==="undefined"||f==="function")){if(p){var r=i[n];if(r.length===0)continue;for(var l=[c],h=0,g=r.length;h<g;h+=1){var _=this._handleRelativeValue(c,r[h]);if(isNaN(_)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}l.push(_)}p&&(i[n]=l)}if((f==="object"||u)&&c&&!p){t[n]=u?[]:{};var m=c;for(var v in m)t[n][v]=m[v];s[n]=u?[]:{};var r=i[n];if(!this._isDynamic){var y={};for(var v in r)y[v]=r[v];i[n]=r=y}this._setupProperties(m,t[n],r,s[n],a)}else(typeof t[n]>"u"||a)&&(t[n]=c),u||(t[n]*=1),p?s[n]=i[n].slice().reverse():s[n]=t[n]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=lt()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=lt()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=Yi),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=ut.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=He.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=lt()),t===void 0&&(t=!0),this._isPaused)return!0;var a,n=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>n)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=e-this._startTime,u=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),f=this._duration+this._repeat*u,p=function(){if(i._duration===0||c>f)return 1;var m=Math.trunc(c/u),v=c-m*u,y=Math.min(v/i._duration,1);return y===0&&c===i._duration?1:y},r=p(),l=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),this._duration===0||c>=this._duration)if(this._repeat>0){var h=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=h);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,_=this._chainedTweens.length;g<_;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,i,s){for(var a in i)if(t[a]!==void 0){var n=t[a]||0,c=i[a],u=Array.isArray(e[a]),f=Array.isArray(c),p=!u&&f;p?e[a]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[a],n,c,s):(c=this._handleRelativeValue(n,c),typeof c=="number"&&(e[a]=n+(c-n)*s))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},o}(),Pa="23.1.3",Fa=gs.nextId,ye=Yi,Ea=ye.getAll.bind(ye),ka=ye.removeAll.bind(ye),Ba=ye.add.bind(ye),Oa=ye.remove.bind(ye),za=ye.update.bind(ye),Fe={Easing:ut,Group:Or,Interpolation:He,now:lt,Sequence:gs,nextId:Fa,Tween:fi,VERSION:Pa,getAll:Ea,removeAll:ka,add:Ba,remove:Oa,update:za},bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Va(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var zr={exports:{}};(function(o){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(u,f,p){this.fn=u,this.context=f,this.once=p||!1}function a(u,f,p,r,l){if(typeof p!="function")throw new TypeError("The listener must be a function");var h=new s(p,r||u,l),g=t?t+f:f;return u._events[g]?u._events[g].fn?u._events[g]=[u._events[g],h]:u._events[g].push(h):(u._events[g]=h,u._eventsCount++),u}function n(u,f){--u._eventsCount===0?u._events=new i:delete u._events[f]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],p,r;if(this._eventsCount===0)return f;for(r in p=this._events)e.call(p,r)&&f.push(t?r.slice(1):r);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},c.prototype.listeners=function(f){var p=t?t+f:f,r=this._events[p];if(!r)return[];if(r.fn)return[r.fn];for(var l=0,h=r.length,g=new Array(h);l<h;l++)g[l]=r[l].fn;return g},c.prototype.listenerCount=function(f){var p=t?t+f:f,r=this._events[p];return r?r.fn?1:r.length:0},c.prototype.emit=function(f,p,r,l,h,g){var _=t?t+f:f;if(!this._events[_])return!1;var m=this._events[_],v=arguments.length,y,x;if(m.fn){switch(m.once&&this.removeListener(f,m.fn,void 0,!0),v){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,p),!0;case 3:return m.fn.call(m.context,p,r),!0;case 4:return m.fn.call(m.context,p,r,l),!0;case 5:return m.fn.call(m.context,p,r,l,h),!0;case 6:return m.fn.call(m.context,p,r,l,h,g),!0}for(x=1,y=new Array(v-1);x<v;x++)y[x-1]=arguments[x];m.fn.apply(m.context,y)}else{var w=m.length,b;for(x=0;x<w;x++)switch(m[x].once&&this.removeListener(f,m[x].fn,void 0,!0),v){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,p);break;case 3:m[x].fn.call(m[x].context,p,r);break;case 4:m[x].fn.call(m[x].context,p,r,l);break;default:if(!y)for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];m[x].fn.apply(m[x].context,y)}}return!0},c.prototype.on=function(f,p,r){return a(this,f,p,r,!1)},c.prototype.once=function(f,p,r){return a(this,f,p,r,!0)},c.prototype.removeListener=function(f,p,r,l){var h=t?t+f:f;if(!this._events[h])return this;if(!p)return n(this,h),this;var g=this._events[h];if(g.fn)g.fn===p&&(!l||g.once)&&(!r||g.context===r)&&n(this,h);else{for(var _=0,m=[],v=g.length;_<v;_++)(g[_].fn!==p||l&&!g[_].once||r&&g[_].context!==r)&&m.push(g[_]);m.length?this._events[h]=m.length===1?m[0]:m:n(this,h)}return this},c.prototype.removeAllListeners=function(f){var p;return f?(p=t?t+f:f,this._events[p]&&n(this,p)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=t,c.EventEmitter=c,o.exports=c})(zr);var Ua=zr.exports;const gt=Va(Ua);var Ft=function(){var o=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(r){r.preventDefault(),i(++o%e.children.length)},!1);function t(r){return e.appendChild(r.dom),r}function i(r){for(var l=0;l<e.children.length;l++)e.children[l].style.display=l===r?"block":"none";o=r}var s=(performance||Date).now(),a=s,n=0,c=t(new Ft.Panel("FPS","#0ff","#002")),u=t(new Ft.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=t(new Ft.Panel("MB","#f08","#201"));i(0);var p=0;return{REVISION:16,dom:e,fps:function(){return p&&parseInt(p.toFixed(0))},addPanel:t,showPanel:i,begin:function(){s=(performance||Date).now()},end:function(){n++;var r=(performance||Date).now();if(u.update(r-s,200),r>=a+1e3&&(p=n*1e3/(r-a),c.update(p,100),a=r,n=0,f)){var l=performance.memory;f.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return r},update:function(){s=this.end()},domElement:e,setMode:i}};Ft.Panel=function(o,e,t){var i=1/0,s=0,a=Math.round,n=a(window.devicePixelRatio||1),c=80*n,u=48*n,f=3*n,p=2*n,r=3*n,l=15*n,h=74*n,g=30*n,_=document.createElement("canvas");_.width=c,_.height=u,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*n+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,u),m.fillStyle=e,m.fillText(o,f,p),m.fillRect(r,l,h,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r,l,h,g),{dom:_,update:function(v,y){i=Math.min(i,v),s=Math.max(s,v),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,l),m.fillStyle=e,m.fillText(a(v)+" "+o+" ("+a(i)+"-"+a(s)+")",f,p),m.drawImage(_,r+n,l,h-n,g,r,l,h-n,g),m.fillRect(r+h-n,l,n,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r+h-n,l,n,a((1-v/y)*g))}}};function Wa(o,e){const t=URL.createObjectURL(o),i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function Vr(o){return o.length===0?0:o.reduce((t,i)=>t+i,0)/o.length}function Zi(o,e){const t=new Blob([o],{type:e});return URL.createObjectURL(t)}function Ur(){return/Mac|iPod|iPhone|iPad/.test(navigator==null?void 0:navigator.platform)||/Mac OS|iOS/.test(navigator==null?void 0:navigator.userAgent)}function Ki(o){let e=document.createElement("canvas");const t=e.getContext("2d");return e.width=o.width,e.height=o.height,t?(t.drawImage(o,0,0),e.toDataURL("image/png",.75)):void 0}function Ha(o,e=43){const t=o*Math.PI/180;return e/(2*Math.tan(t/2))}var Wr={};/*!
3687
+ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,xe=new WeakMap,hi=new WeakMap,De=new WeakMap,ut=new WeakMap,fi=new WeakMap,we=new WeakMap,P(W,"debugDrawLine"),P(W,"corner0",new f.Vector3),P(W,"corner1",new f.Vector3),P(W,"corner2",new f.Vector3),P(W,"corner3",new f.Vector3),P(W,"_tempPtInside",new f.Vector3),P(W,"skinnedMeshBoundsFrameOffsetCounter",0),P(W,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset"));let dt=W;class xa{constructor(){P(this,"frames",0);P(this,"lastLodLevel_Mesh",-1);P(this,"lastLodLevel_Texture",-1);P(this,"lastScreenCoverage",0);P(this,"lastScreenspaceVolume",new f.Vector3);P(this,"lastCentrality",0)}}const Gs=Symbol("NEEDLE_mesh_lod"),Gt=Symbol("NEEDLE_texture_lod");let yt=null;function Dr(){const o=wa();o&&(o.mapURLs(function(e){return qs(),e}),qs(),yt==null||yt.disconnect(),yt=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&i.tagName.toLowerCase()==="model-viewer"&&Lr(i)})})}),yt.observe(document,{childList:!0,subtree:!0}))}function wa(){if(typeof customElements>"u")return null;const o=customElements.get("model-viewer");return o||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Dr()}),null)}function qs(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{Lr(e)})}const js=new WeakSet;let ba=0;function Lr(o){if(!o||js.has(o))return null;js.add(o),console.debug("[gltf-progressive] found new model-viewer..."+ ++ba+`
3688
+ `,o.getAttribute("src"));let e=null,t=null,i=null;for(let s=o;s!=null;s=Object.getPrototypeOf(s)){const a=Object.getOwnPropertySymbols(s),n=a.find(d=>d.toString()=="Symbol(renderer)"),c=a.find(d=>d.toString()=="Symbol(scene)"),u=a.find(d=>d.toString()=="Symbol(needsRender)");!e&&n!=null&&(e=o[n].threeRenderer),!t&&c!=null&&(t=o[c]),!i&&u!=null&&(i=o[u])}if(e&&t){let s=function(){if(i){let n=0,c=setInterval(()=>{if(n++>5){clearInterval(c);return}i==null||i.call(o)},300)}};console.debug("[gltf-progressive] setup model-viewer");const a=dt.get(e,{engine:"model-viewer"});return dt.addPlugin(new Aa),a.enable(),a.addEventListener("changed",()=>{i==null||i.call(o)}),o.addEventListener("model-visibility",n=>{n.detail.visible&&(i==null||i.call(o))}),o.addEventListener("load",()=>{s()}),()=>{a.disable()}}return null}class Aa{constructor(){P(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,i,s){this.tryParseMeshLOD(t,s),this.tryParseTextureLOD(t,s)}getUrl(e){if(!e)return null;let t=e.getAttribute("src");return t||(t=e.src),t||(this._didWarnAboutMissingUrl||console.warn("No url found in modelviewer",e),this._didWarnAboutMissingUrl=!0),t}tryGetCurrentGLTF(e){return e._currentGLTF}tryGetCurrentModelViewer(e){return e.element}tryParseTextureLOD(e,t){if(t[Gt]==!0)return;t[Gt]=!0;const i=this.tryGetCurrentGLTF(e),s=this.tryGetCurrentModelViewer(e),a=this.getUrl(s);if(a&&i&&t.material){let n=function(u){var p,r,l;if(u[Gt]==!0)return;u[Gt]=!0,u.userData&&(u.userData.LOD=-1);const d=Object.keys(u);for(let h=0;h<d.length;h++){const g=d[h],_=u[g];if((_==null?void 0:_.isTexture)===!0){const m=(r=(p=_.userData)==null?void 0:p.associations)==null?void 0:r.textures;if(m==null)continue;const v=i.parser.json.textures[m];if(!v){console.warn("Texture data not found for texture index "+m);continue}if((l=v==null?void 0:v.extensions)!=null&&l[ye]){const y=v.extensions[ye];y&&a&&pe.registerTexture(a,_,y.lods.length,m,y)}}}};const c=t.material;if(Array.isArray(c))for(const u of c)n(u);else n(c)}}tryParseMeshLOD(e,t){var n,c;if(t[Gs]==!0)return;t[Gs]=!0;const i=this.tryGetCurrentModelViewer(e),s=this.getUrl(i);if(!s)return;const a=(c=(n=t.userData)==null?void 0:n.gltfExtensions)==null?void 0:c[ye];if(a&&s){const u=t.uuid;pe.registerMesh(s,u,t,0,a.lods.length,a)}}}function Pr(...o){let e,t,i,s;switch(o.length){case 2:[i,t]=o,s={};break;case 3:[i,t,s]=o;break;case 4:[e,t,i,s]=o;break;default:throw new Error("Invalid arguments")}Tr(i),Cr(i,{progressive:!0,...s==null?void 0:s.hints}),i.register(n=>new pe(n));const a=dt.get(t);return(s==null?void 0:s.enableLODsManager)!==!1&&a.enable(),a}Dr();if(!la){const o={gltfProgressive:{useNeedleProgressive:Pr,LODsManager:dt,configureLoader:Cr,getRaycastMesh:Bt,useRaycastMeshes:ua}};if(!globalThis.Needle)globalThis.Needle=o;else for(const e in o)globalThis.Needle[e]=o[e]}var lt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-lt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?lt.Bounce.In(o*2)*.5:lt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),ot=function(){return performance.now()},Fr=function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=ot()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var a=this._tweens[i[s]],n=!t;a&&a.update(e,n)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},o}(),Ue={Linear:function(o,e){var t=o.length-1,i=t*e,s=Math.floor(i),a=Ue.Utils.Linear;return e<0?a(o[0],o[1],i):e>1?a(o[t],o[t-1],t-i):a(o[s],o[s+1>t?t:s+1],i-s)},Bezier:function(o,e){for(var t=0,i=o.length-1,s=Math.pow,a=Ue.Utils.Bernstein,n=0;n<=i;n++)t+=s(1-e,i-n)*s(e,n)*o[n]*a(i,n);return t},CatmullRom:function(o,e){var t=o.length-1,i=t*e,s=Math.floor(i),a=Ue.Utils.CatmullRom;return o[0]===o[t]?(e<0&&(s=Math.floor(i=t*(1+e))),a(o[(s-1+t)%t],o[s],o[(s+1)%t],o[(s+2)%t],i-s)):e<0?o[0]-(a(o[0],o[0],o[1],o[1],-i)-o[0]):e>1?o[t]-(a(o[t],o[t],o[t-1],o[t-1],i-t)-o[t]):a(o[s?s-1:0],o[s],o[t<s+1?t:s+1],o[t<s+2?t:s+2],i-s)},Utils:{Linear:function(o,e,t){return(e-o)*t+o},Bernstein:function(o,e){var t=Ue.Utils.Factorial;return t(o)/t(e)/t(o-e)},Factorial:function(){var o=[1];return function(e){var t=1;if(o[e])return o[e];for(var i=e;i>1;i--)t*=i;return o[e]=t,t}}(),CatmullRom:function(o,e,t,i,s){var a=(t-o)*.5,n=(i-e)*.5,c=s*s,u=s*c;return(2*e-2*t+a+n)*u+(-3*e+3*t-2*a-n)*c+a*s+e}}},us=function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o}(),Ni=new Fr,ci=function(){function o(e,t){t===void 0&&(t=Ni),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=lt.Linear.None,this._interpolationFunction=Ue.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=us.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=ot()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var a in this._valuesEnd)s[a]=this._valuesEnd[a];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,i,s,a){for(var n in i){var c=e[n],u=Array.isArray(c),d=u?"array":typeof c,p=!u&&Array.isArray(i[n]);if(!(d==="undefined"||d==="function")){if(p){var r=i[n];if(r.length===0)continue;for(var l=[c],h=0,g=r.length;h<g;h+=1){var _=this._handleRelativeValue(c,r[h]);if(isNaN(_)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}l.push(_)}p&&(i[n]=l)}if((d==="object"||u)&&c&&!p){t[n]=u?[]:{};var m=c;for(var v in m)t[n][v]=m[v];s[n]=u?[]:{};var r=i[n];if(!this._isDynamic){var y={};for(var v in r)y[v]=r[v];i[n]=r=y}this._setupProperties(m,t[n],r,s[n],a)}else(typeof t[n]>"u"||a)&&(t[n]=c),u||(t[n]*=1),p?s[n]=i[n].slice().reverse():s[n]=t[n]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=ot()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=ot()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=Ni),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=lt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Ue.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=ot()),t===void 0&&(t=!0),this._isPaused)return!0;var a,n=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>n)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=e-this._startTime,u=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),d=this._duration+this._repeat*u,p=function(){if(i._duration===0||c>d)return 1;var m=Math.trunc(c/u),v=c-m*u,y=Math.min(v/i._duration,1);return y===0&&c===i._duration?1:y},r=p(),l=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),this._duration===0||c>=this._duration)if(this._repeat>0){var h=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=h);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,_=this._chainedTweens.length;g<_;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,i,s){for(var a in i)if(t[a]!==void 0){var n=t[a]||0,c=i[a],u=Array.isArray(e[a]),d=Array.isArray(c),p=!u&&d;p?e[a]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[a],n,c,s):(c=this._handleRelativeValue(n,c),typeof c=="number"&&(e[a]=n+(c-n)*s))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},o}(),Ta="23.1.3",Sa=us.nextId,ve=Ni,Ma=ve.getAll.bind(ve),Ca=ve.removeAll.bind(ve),Ra=ve.add.bind(ve),Ia=ve.remove.bind(ve),Da=ve.update.bind(ve),Le={Easing:lt,Group:Fr,Interpolation:Ue,now:ot,Sequence:us,nextId:Sa,Tween:ci,VERSION:Ta,getAll:Ma,removeAll:Ca,add:Ra,remove:Ia,update:Da},xt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function La(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Er={exports:{}};(function(o){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(u,d,p){this.fn=u,this.context=d,this.once=p||!1}function a(u,d,p,r,l){if(typeof p!="function")throw new TypeError("The listener must be a function");var h=new s(p,r||u,l),g=t?t+d:d;return u._events[g]?u._events[g].fn?u._events[g]=[u._events[g],h]:u._events[g].push(h):(u._events[g]=h,u._eventsCount++),u}function n(u,d){--u._eventsCount===0?u._events=new i:delete u._events[d]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var d=[],p,r;if(this._eventsCount===0)return d;for(r in p=this._events)e.call(p,r)&&d.push(t?r.slice(1):r);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(p)):d},c.prototype.listeners=function(d){var p=t?t+d:d,r=this._events[p];if(!r)return[];if(r.fn)return[r.fn];for(var l=0,h=r.length,g=new Array(h);l<h;l++)g[l]=r[l].fn;return g},c.prototype.listenerCount=function(d){var p=t?t+d:d,r=this._events[p];return r?r.fn?1:r.length:0},c.prototype.emit=function(d,p,r,l,h,g){var _=t?t+d:d;if(!this._events[_])return!1;var m=this._events[_],v=arguments.length,y,x;if(m.fn){switch(m.once&&this.removeListener(d,m.fn,void 0,!0),v){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,p),!0;case 3:return m.fn.call(m.context,p,r),!0;case 4:return m.fn.call(m.context,p,r,l),!0;case 5:return m.fn.call(m.context,p,r,l,h),!0;case 6:return m.fn.call(m.context,p,r,l,h,g),!0}for(x=1,y=new Array(v-1);x<v;x++)y[x-1]=arguments[x];m.fn.apply(m.context,y)}else{var w=m.length,b;for(x=0;x<w;x++)switch(m[x].once&&this.removeListener(d,m[x].fn,void 0,!0),v){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,p);break;case 3:m[x].fn.call(m[x].context,p,r);break;case 4:m[x].fn.call(m[x].context,p,r,l);break;default:if(!y)for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];m[x].fn.apply(m[x].context,y)}}return!0},c.prototype.on=function(d,p,r){return a(this,d,p,r,!1)},c.prototype.once=function(d,p,r){return a(this,d,p,r,!0)},c.prototype.removeListener=function(d,p,r,l){var h=t?t+d:d;if(!this._events[h])return this;if(!p)return n(this,h),this;var g=this._events[h];if(g.fn)g.fn===p&&(!l||g.once)&&(!r||g.context===r)&&n(this,h);else{for(var _=0,m=[],v=g.length;_<v;_++)(g[_].fn!==p||l&&!g[_].once||r&&g[_].context!==r)&&m.push(g[_]);m.length?this._events[h]=m.length===1?m[0]:m:n(this,h)}return this},c.prototype.removeAllListeners=function(d){var p;return d?(p=t?t+d:d,this._events[p]&&n(this,p)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=t,c.EventEmitter=c,o.exports=c})(Er);var Pa=Er.exports;const pt=La(Pa);var Lt=function(){var o=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(r){r.preventDefault(),i(++o%e.children.length)},!1);function t(r){return e.appendChild(r.dom),r}function i(r){for(var l=0;l<e.children.length;l++)e.children[l].style.display=l===r?"block":"none";o=r}var s=(performance||Date).now(),a=s,n=0,c=t(new Lt.Panel("FPS","#0ff","#002")),u=t(new Lt.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=t(new Lt.Panel("MB","#f08","#201"));i(0);var p=0;return{REVISION:16,dom:e,fps:function(){return p&&parseInt(p.toFixed(0))},addPanel:t,showPanel:i,begin:function(){s=(performance||Date).now()},end:function(){n++;var r=(performance||Date).now();if(u.update(r-s,200),r>=a+1e3&&(p=n*1e3/(r-a),c.update(p,100),a=r,n=0,d)){var l=performance.memory;d.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return r},update:function(){s=this.end()},domElement:e,setMode:i}};Lt.Panel=function(o,e,t){var i=1/0,s=0,a=Math.round,n=a(window.devicePixelRatio||1),c=80*n,u=48*n,d=3*n,p=2*n,r=3*n,l=15*n,h=74*n,g=30*n,_=document.createElement("canvas");_.width=c,_.height=u,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*n+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,u),m.fillStyle=e,m.fillText(o,d,p),m.fillRect(r,l,h,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r,l,h,g),{dom:_,update:function(v,y){i=Math.min(i,v),s=Math.max(s,v),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,l),m.fillStyle=e,m.fillText(a(v)+" "+o+" ("+a(i)+"-"+a(s)+")",d,p),m.drawImage(_,r+n,l,h-n,g,r,l,h-n,g),m.fillRect(r+h-n,l,n,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r+h-n,l,n,a((1-v/y)*g))}}};function Fa(o,e){const t=URL.createObjectURL(o),i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function Br(o){return o.length===0?0:o.reduce((t,i)=>t+i,0)/o.length}function Gi(o,e){const t=new Blob([o],{type:e});return URL.createObjectURL(t)}function kr(){return/Mac|iPod|iPhone|iPad/.test(navigator==null?void 0:navigator.platform)||/Mac OS|iOS/.test(navigator==null?void 0:navigator.userAgent)}function qi(o){let e=document.createElement("canvas");const t=e.getContext("2d");return e.width=o.width,e.height=o.height,t?(t.drawImage(o,0,0),e.toDataURL("image/png",.75)):void 0}function Ea(o,e=43){const t=o*Math.PI/180;return e/(2*Math.tan(t/2))}var Or={};/*!
3689
3689
  * howler.js v2.2.4
3690
3690
  * howlerjs.com
3691
3691
  *
@@ -3693,7 +3693,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new
3693
3693
  * goldfirestudios.com
3694
3694
  *
3695
3695
  * MIT License
3696
- */(function(o){(function(){var e=function(){this.init()};e.prototype={init:function(){var r=this||t;return r._counter=1e3,r._html5AudioPool=[],r.html5PoolSize=10,r._codecs={},r._howls=[],r._muted=!1,r._volume=1,r._canPlayEvent="canplaythrough",r._navigator=typeof window<"u"&&window.navigator?window.navigator:null,r.masterGain=null,r.noAudio=!1,r.usingWebAudio=!0,r.autoSuspend=!0,r.ctx=null,r.autoUnlock=!0,r._setup(),r},volume:function(r){var l=this||t;if(r=parseFloat(r),l.ctx||p(),typeof r<"u"&&r>=0&&r<=1){if(l._volume=r,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.volume=m._volume*r)}return l}return l._volume},mute:function(r){var l=this||t;l.ctx||p(),l._muted=r,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r?0:l._volume,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.muted=r?!0:m._muted)}return l},stop:function(){for(var r=this||t,l=0;l<r._howls.length;l++)r._howls[l].stop();return r},unload:function(){for(var r=this||t,l=r._howls.length-1;l>=0;l--)r._howls[l].unload();return r.usingWebAudio&&r.ctx&&typeof r.ctx.close<"u"&&(r.ctx.close(),r.ctx=null,p()),r},codecs:function(r){return(this||t)._codecs[r.replace(/^x-/,"")]},_setup:function(){var r=this||t;if(r.state=r.ctx&&r.ctx.state||"suspended",r._autoSuspend(),!r.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(r._canPlayEvent="canplay")}catch{r.noAudio=!0}else r.noAudio=!0;try{var l=new Audio;l.muted&&(r.noAudio=!0)}catch{}return r.noAudio||r._setupCodecs(),r},_setupCodecs:function(){var r=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return r}if(!l||typeof l.canPlayType!="function")return r;var h=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=r._navigator?r._navigator.userAgent:"",_=g.match(/OPR\/(\d+)/g),m=_&&parseInt(_[0].split("/")[1],10)<33,v=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),x=v&&y&&parseInt(y[1],10)<15;return r._codecs={mp3:!!(!m&&(h||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},r},_unlockAudio:function(){var r=this||t;if(!(r._audioUnlocked||!r.ctx)){r._audioUnlocked=!1,r.autoUnlock=!1,!r._mobileUnloaded&&r.ctx.sampleRate!==44100&&(r._mobileUnloaded=!0,r.unload()),r._scratchBuffer=r.ctx.createBuffer(1,1,22050);var l=function(h){for(;r._html5AudioPool.length<r.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,r._releaseHtml5Audio(g)}catch{r.noAudio=!0;break}for(var _=0;_<r._howls.length;_++)if(!r._howls[_]._webAudio)for(var m=r._howls[_]._getSoundIds(),v=0;v<m.length;v++){var y=r._howls[_]._soundById(m[v]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}r._autoResume();var x=r.ctx.createBufferSource();x.buffer=r._scratchBuffer,x.connect(r.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof r.ctx.resume=="function"&&r.ctx.resume(),x.onended=function(){x.disconnect(0),r._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var w=0;w<r._howls.length;w++)r._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),r}},_obtainHtml5Audio:function(){var r=this||t;if(r._html5AudioPool.length)return r._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(r){var l=this||t;return r._unlocked&&l._html5AudioPool.push(r),l},_autoSuspend:function(){var r=this;if(!(!r.autoSuspend||!r.ctx||typeof r.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<r._howls.length;l++)if(r._howls[l]._webAudio){for(var h=0;h<r._howls[l]._sounds.length;h++)if(!r._howls[l]._sounds[h]._paused)return r}return r._suspendTimer&&clearTimeout(r._suspendTimer),r._suspendTimer=setTimeout(function(){if(r.autoSuspend){r._suspendTimer=null,r.state="suspending";var g=function(){r.state="suspended",r._resumeAfterSuspend&&(delete r._resumeAfterSuspend,r._autoResume())};r.ctx.suspend().then(g,g)}},3e4),r}},_autoResume:function(){var r=this;if(!(!r.ctx||typeof r.ctx.resume>"u"||!t.usingWebAudio))return r.state==="running"&&r.ctx.state!=="interrupted"&&r._suspendTimer?(clearTimeout(r._suspendTimer),r._suspendTimer=null):r.state==="suspended"||r.state==="running"&&r.ctx.state==="interrupted"?(r.ctx.resume().then(function(){r.state="running";for(var l=0;l<r._howls.length;l++)r._howls[l]._emit("resume")}),r._suspendTimer&&(clearTimeout(r._suspendTimer),r._suspendTimer=null)):r.state==="suspending"&&(r._resumeAfterSuspend=!0),r}};var t=new e,i=function(r){var l=this;if(!r.src||r.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(r)};i.prototype={init:function(r){var l=this;return t.ctx||p(),l._autoplay=r.autoplay||!1,l._format=typeof r.format!="string"?r.format:[r.format],l._html5=r.html5||!1,l._muted=r.mute||!1,l._loop=r.loop||!1,l._pool=r.pool||5,l._preload=typeof r.preload=="boolean"||r.preload==="metadata"?r.preload:!0,l._rate=r.rate||1,l._sprite=r.sprite||{},l._src=typeof r.src!="string"?r.src:[r.src],l._volume=r.volume!==void 0?r.volume:1,l._xhr={method:r.xhr&&r.xhr.method?r.xhr.method:"GET",headers:r.xhr&&r.xhr.headers?r.xhr.headers:null,withCredentials:r.xhr&&r.xhr.withCredentials?r.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=r.onend?[{fn:r.onend}]:[],l._onfade=r.onfade?[{fn:r.onfade}]:[],l._onload=r.onload?[{fn:r.onload}]:[],l._onloaderror=r.onloaderror?[{fn:r.onloaderror}]:[],l._onplayerror=r.onplayerror?[{fn:r.onplayerror}]:[],l._onpause=r.onpause?[{fn:r.onpause}]:[],l._onplay=r.onplay?[{fn:r.onplay}]:[],l._onstop=r.onstop?[{fn:r.onstop}]:[],l._onmute=r.onmute?[{fn:r.onmute}]:[],l._onvolume=r.onvolume?[{fn:r.onvolume}]:[],l._onrate=r.onrate?[{fn:r.onrate}]:[],l._onseek=r.onseek?[{fn:r.onseek}]:[],l._onunlock=r.onunlock?[{fn:r.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var r=this,l=null;if(t.noAudio){r._emit("loaderror",null,"No audio support.");return}typeof r._src=="string"&&(r._src=[r._src]);for(var h=0;h<r._src.length;h++){var g,_;if(r._format&&r._format[h])g=r._format[h];else{if(_=r._src[h],typeof _!="string"){r._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(_),g||(g=/\.([^.]+)$/.exec(_.split("?",1)[0])),g&&(g=g[1].toLowerCase())}if(g||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),g&&t.codecs(g)){l=r._src[h];break}}if(!l){r._emit("loaderror",null,"No codec support for selected audio sources.");return}return r._src=l,r._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(r._html5=!0,r._webAudio=!1),new s(r),r._webAudio&&n(r),r},play:function(r,l){var h=this,g=null;if(typeof r=="number")g=r,r=null;else{if(typeof r=="string"&&h._state==="loaded"&&!h._sprite[r])return null;if(typeof r>"u"&&(r="__default",!h._playLock)){for(var _=0,m=0;m<h._sounds.length;m++)h._sounds[m]._paused&&!h._sounds[m]._ended&&(_++,g=h._sounds[m]._id);_===1?r=null:g=null}}var v=g?h._soundById(g):h._inactiveSound();if(!v)return null;if(g&&!r&&(r=v._sprite||"__default"),h._state!=="loaded"){v._sprite=r,v._ended=!1;var y=v._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(g&&!v._paused)return l||h._loadQueue("play"),v._id;h._webAudio&&t._autoResume();var x=Math.max(0,v._seek>0?v._seek:h._sprite[r][0]/1e3),w=Math.max(0,(h._sprite[r][0]+h._sprite[r][1])/1e3-x),b=w*1e3/Math.abs(v._rate),A=h._sprite[r][0]/1e3,S=(h._sprite[r][0]+h._sprite[r][1])/1e3;v._sprite=r,v._ended=!1;var C=function(){v._paused=!1,v._seek=x,v._start=A,v._stop=S,v._loop=!!(v._loop||h._sprite[r][2])};if(x>=S){h._ended(v);return}var M=v._node;if(h._webAudio){var I=function(){h._playLock=!1,C(),h._refreshBuffer(v);var L=v._muted||h._muted?0:v._volume;M.gain.setValueAtTime(L,t.ctx.currentTime),v._playStart=t.ctx.currentTime,typeof M.bufferSource.start>"u"?v._loop?M.bufferSource.noteGrainOn(0,x,86400):M.bufferSource.noteGrainOn(0,x,w):v._loop?M.bufferSource.start(0,x,86400):M.bufferSource.start(0,x,w),b!==1/0&&(h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b)),l||setTimeout(function(){h._emit("play",v._id),h._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?I():(h._playLock=!0,h.once("resume",I),h._clearTimer(v._id))}else{var D=function(){M.currentTime=x,M.muted=v._muted||h._muted||t._muted||M.muted,M.volume=v._volume*t.volume(),M.playbackRate=v._rate;try{var L=M.play();if(L&&typeof Promise<"u"&&(L instanceof Promise||typeof L.then=="function")?(h._playLock=!0,C(),L.then(function(){h._playLock=!1,M._unlocked=!0,l?h._loadQueue():h._emit("play",v._id)}).catch(function(){h._playLock=!1,h._emit("playerror",v._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),v._ended=!0,v._paused=!0})):l||(h._playLock=!1,C(),h._emit("play",v._id)),M.playbackRate=v._rate,M.paused){h._emit("playerror",v._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}r!=="__default"||v._loop?h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b):(h._endTimers[v._id]=function(){h._ended(v),M.removeEventListener("ended",h._endTimers[v._id],!1)},M.addEventListener("ended",h._endTimers[v._id],!1))}catch(F){h._emit("playerror",v._id,F)}};M.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(M.src=h._src,M.load());var T=window&&window.ejecta||!M.readyState&&t._navigator.isCocoonJS;if(M.readyState>=3||T)D();else{h._playLock=!0,h._state="loading";var R=function(){h._state="loaded",D(),M.removeEventListener(t._canPlayEvent,R,!1)};M.addEventListener(t._canPlayEvent,R,!1),h._clearTimer(v._id)}}return v._id},pause:function(r){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(r)}}),l;for(var h=l._getSoundIds(r),g=0;g<h.length;g++){l._clearTimer(h[g]);var _=l._soundById(h[g]);if(_&&!_._paused&&(_._seek=l.seek(h[g]),_._rateSeek=0,_._paused=!0,l._stopFade(h[g]),_._node))if(l._webAudio){if(!_._node.bufferSource)continue;typeof _._node.bufferSource.stop>"u"?_._node.bufferSource.noteOff(0):_._node.bufferSource.stop(0),l._cleanBuffer(_._node)}else(!isNaN(_._node.duration)||_._node.duration===1/0)&&_._node.pause();arguments[1]||l._emit("pause",_?_._id:null)}return l},stop:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(r)}}),h;for(var g=h._getSoundIds(r),_=0;_<g.length;_++){h._clearTimer(g[_]);var m=h._soundById(g[_]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,h._stopFade(g[_]),m._node&&(h._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),h._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&h._clearSound(m._node))),l||h._emit("stop",m._id))}return h},mute:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(r,l)}}),h;if(typeof l>"u")if(typeof r=="boolean")h._muted=r;else return h._muted;for(var g=h._getSoundIds(l),_=0;_<g.length;_++){var m=h._soundById(g[_]);m&&(m._muted=r,m._interval&&h._stopFade(m._id),h._webAudio&&m._node?m._node.gain.setValueAtTime(r?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:r),h._emit("mute",m._id))}return h},volume:function(){var r=this,l=arguments,h,g;if(l.length===0)return r._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length>=2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h<"u"&&h>=0&&h<=1){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,l)}}),r;typeof g>"u"&&(r._volume=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)v=r._soundById(g[y]),v&&(v._volume=h,l[2]||r._stopFade(g[y]),r._webAudio&&v._node&&!v._muted?v._node.gain.setValueAtTime(h,t.ctx.currentTime):v._node&&!v._muted&&(v._node.volume=h*t.volume()),r._emit("volume",v._id))}else return v=g?r._soundById(g):r._sounds[0],v?v._volume:0;return r},fade:function(r,l,h,g){var _=this;if(_._state!=="loaded"||_._playLock)return _._queue.push({event:"fade",action:function(){_.fade(r,l,h,g)}}),_;r=Math.min(Math.max(0,parseFloat(r)),1),l=Math.min(Math.max(0,parseFloat(l)),1),h=parseFloat(h),_.volume(r,g);for(var m=_._getSoundIds(g),v=0;v<m.length;v++){var y=_._soundById(m[v]);if(y){if(g||_._stopFade(m[v]),_._webAudio&&!y._muted){var x=t.ctx.currentTime,w=x+h/1e3;y._volume=r,y._node.gain.setValueAtTime(r,x),y._node.gain.linearRampToValueAtTime(l,w)}_._startFadeInterval(y,r,l,h,m[v],typeof g>"u")}}return _},_startFadeInterval:function(r,l,h,g,_,m){var v=this,y=l,x=h-l,w=Math.abs(x/.01),b=Math.max(4,w>0?g/w:g),A=Date.now();r._fadeTo=h,r._interval=setInterval(function(){var S=(Date.now()-A)/g;A=Date.now(),y+=x*S,y=Math.round(y*100)/100,x<0?y=Math.max(h,y):y=Math.min(h,y),v._webAudio?r._volume=y:v.volume(y,r._id,!0),m&&(v._volume=y),(h<l&&y<=h||h>l&&y>=h)&&(clearInterval(r._interval),r._interval=null,r._fadeTo=null,v.volume(h,r._id),v._emit("fade",r._id))},b)},_stopFade:function(r){var l=this,h=l._soundById(r);return h&&h._interval&&(l._webAudio&&h._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(h._interval),h._interval=null,l.volume(h._fadeTo,r),h._fadeTo=null,l._emit("fade",r)),l},loop:function(){var r=this,l=arguments,h,g,_;if(l.length===0)return r._loop;if(l.length===1)if(typeof l[0]=="boolean")h=l[0],r._loop=h;else return _=r._soundById(parseInt(l[0],10)),_?_._loop:!1;else l.length===2&&(h=l[0],g=parseInt(l[1],10));for(var m=r._getSoundIds(g),v=0;v<m.length;v++)_=r._soundById(m[v]),_&&(_._loop=h,r._webAudio&&_._node&&_._node.bufferSource&&(_._node.bufferSource.loop=h,h&&(_._node.bufferSource.loopStart=_._start||0,_._node.bufferSource.loopEnd=_._stop,r.playing(m[v])&&(r.pause(m[v],!0),r.play(m[v],!0)))));return r},rate:function(){var r=this,l=arguments,h,g;if(l.length===0)g=r._sounds[0]._id;else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h=="number"){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,l)}}),r;typeof g>"u"&&(r._rate=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)if(v=r._soundById(g[y]),v){r.playing(g[y])&&(v._rateSeek=r.seek(g[y]),v._playStart=r._webAudio?t.ctx.currentTime:v._playStart),v._rate=h,r._webAudio&&v._node&&v._node.bufferSource?v._node.bufferSource.playbackRate.setValueAtTime(h,t.ctx.currentTime):v._node&&(v._node.playbackRate=h);var x=r.seek(g[y]),w=(r._sprite[v._sprite][0]+r._sprite[v._sprite][1])/1e3-x,b=w*1e3/Math.abs(v._rate);(r._endTimers[g[y]]||!v._paused)&&(r._clearTimer(g[y]),r._endTimers[g[y]]=setTimeout(r._ended.bind(r,v),b)),r._emit("rate",v._id)}}else return v=r._soundById(g),v?v._rate:r._rate;return r},seek:function(){var r=this,l=arguments,h,g;if(l.length===0)r._sounds.length&&(g=r._sounds[0]._id);else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):r._sounds.length&&(g=r._sounds[0]._id,h=parseFloat(l[0]))}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof h=="number"&&(r._state!=="loaded"||r._playLock))return r._queue.push({event:"seek",action:function(){r.seek.apply(r,l)}}),r;var v=r._soundById(g);if(v)if(typeof h=="number"&&h>=0){var y=r.playing(g);y&&r.pause(g,!0),v._seek=h,v._ended=!1,r._clearTimer(g),!r._webAudio&&v._node&&!isNaN(v._node.duration)&&(v._node.currentTime=h);var x=function(){y&&r.play(g,!0),r._emit("seek",g)};if(y&&!r._webAudio){var w=function(){r._playLock?setTimeout(w,0):x()};setTimeout(w,0)}else x()}else if(r._webAudio){var b=r.playing(g)?t.ctx.currentTime-v._playStart:0,A=v._rateSeek?v._rateSeek-v._seek:0;return v._seek+(A+b*Math.abs(v._rate))}else return v._node.currentTime;return r},playing:function(r){var l=this;if(typeof r=="number"){var h=l._soundById(r);return h?!h._paused:!1}for(var g=0;g<l._sounds.length;g++)if(!l._sounds[g]._paused)return!0;return!1},duration:function(r){var l=this,h=l._duration,g=l._soundById(r);return g&&(h=l._sprite[g._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var r=this,l=r._sounds,h=0;h<l.length;h++)l[h]._paused||r.stop(l[h]._id),r._webAudio||(r._clearSound(l[h]._node),l[h]._node.removeEventListener("error",l[h]._errorFn,!1),l[h]._node.removeEventListener(t._canPlayEvent,l[h]._loadFn,!1),l[h]._node.removeEventListener("ended",l[h]._endFn,!1),t._releaseHtml5Audio(l[h]._node)),delete l[h]._node,r._clearTimer(l[h]._id);var g=t._howls.indexOf(r);g>=0&&t._howls.splice(g,1);var _=!0;for(h=0;h<t._howls.length;h++)if(t._howls[h]._src===r._src||r._src.indexOf(t._howls[h]._src)>=0){_=!1;break}return a&&_&&delete a[r._src],t.noAudio=!1,r._state="unloaded",r._sounds=[],r=null,null},on:function(r,l,h,g){var _=this,m=_["_on"+r];return typeof l=="function"&&m.push(g?{id:h,fn:l,once:g}:{id:h,fn:l}),_},off:function(r,l,h){var g=this,_=g["_on"+r],m=0;if(typeof l=="number"&&(h=l,l=null),l||h)for(m=0;m<_.length;m++){var v=h===_[m].id;if(l===_[m].fn&&v||!l&&v){_.splice(m,1);break}}else if(r)g["_on"+r]=[];else{var y=Object.keys(g);for(m=0;m<y.length;m++)y[m].indexOf("_on")===0&&Array.isArray(g[y[m]])&&(g[y[m]]=[])}return g},once:function(r,l,h){var g=this;return g.on(r,l,h,1),g},_emit:function(r,l,h){for(var g=this,_=g["_on"+r],m=_.length-1;m>=0;m--)(!_[m].id||_[m].id===l||r==="load")&&(setTimeout((function(v){v.call(this,l,h)}).bind(g,_[m].fn),0),_[m].once&&g.off(r,_[m].fn,_[m].id));return g._loadQueue(r),g},_loadQueue:function(r){var l=this;if(l._queue.length>0){var h=l._queue[0];h.event===r&&(l._queue.shift(),l._loadQueue()),r||h.action()}return l},_ended:function(r){var l=this,h=r._sprite;if(!l._webAudio&&r._node&&!r._node.paused&&!r._node.ended&&r._node.currentTime<r._stop)return setTimeout(l._ended.bind(l,r),100),l;var g=!!(r._loop||l._sprite[h][2]);if(l._emit("end",r._id),!l._webAudio&&g&&l.stop(r._id,!0).play(r._id),l._webAudio&&g){l._emit("play",r._id),r._seek=r._start||0,r._rateSeek=0,r._playStart=t.ctx.currentTime;var _=(r._stop-r._start)*1e3/Math.abs(r._rate);l._endTimers[r._id]=setTimeout(l._ended.bind(l,r),_)}return l._webAudio&&!g&&(r._paused=!0,r._ended=!0,r._seek=r._start||0,r._rateSeek=0,l._clearTimer(r._id),l._cleanBuffer(r._node),t._autoSuspend()),!l._webAudio&&!g&&l.stop(r._id,!0),l},_clearTimer:function(r){var l=this;if(l._endTimers[r]){if(typeof l._endTimers[r]!="function")clearTimeout(l._endTimers[r]);else{var h=l._soundById(r);h&&h._node&&h._node.removeEventListener("ended",l._endTimers[r],!1)}delete l._endTimers[r]}return l},_soundById:function(r){for(var l=this,h=0;h<l._sounds.length;h++)if(r===l._sounds[h]._id)return l._sounds[h];return null},_inactiveSound:function(){var r=this;r._drain();for(var l=0;l<r._sounds.length;l++)if(r._sounds[l]._ended)return r._sounds[l].reset();return new s(r)},_drain:function(){var r=this,l=r._pool,h=0,g=0;if(!(r._sounds.length<l)){for(g=0;g<r._sounds.length;g++)r._sounds[g]._ended&&h++;for(g=r._sounds.length-1;g>=0;g--){if(h<=l)return;r._sounds[g]._ended&&(r._webAudio&&r._sounds[g]._node&&r._sounds[g]._node.disconnect(0),r._sounds.splice(g,1),h--)}}},_getSoundIds:function(r){var l=this;if(typeof r>"u"){for(var h=[],g=0;g<l._sounds.length;g++)h.push(l._sounds[g]._id);return h}else return[r]},_refreshBuffer:function(r){var l=this;return r._node.bufferSource=t.ctx.createBufferSource(),r._node.bufferSource.buffer=a[l._src],r._panner?r._node.bufferSource.connect(r._panner):r._node.bufferSource.connect(r._node),r._node.bufferSource.loop=r._loop,r._loop&&(r._node.bufferSource.loopStart=r._start||0,r._node.bufferSource.loopEnd=r._stop||0),r._node.bufferSource.playbackRate.setValueAtTime(r._rate,t.ctx.currentTime),l},_cleanBuffer:function(r){var l=this,h=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!r.bufferSource)return l;if(t._scratchBuffer&&r.bufferSource&&(r.bufferSource.onended=null,r.bufferSource.disconnect(0),h))try{r.bufferSource.buffer=t._scratchBuffer}catch{}return r.bufferSource=null,l},_clearSound:function(r){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(r.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(r){this._parent=r,this.init()};s.prototype={init:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,l._sounds.push(r),r.create(),r},create:function(){var r=this,l=r._parent,h=t._muted||r._muted||r._parent._muted?0:r._volume;return l._webAudio?(r._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),r._node.gain.setValueAtTime(h,t.ctx.currentTime),r._node.paused=!0,r._node.connect(t.masterGain)):t.noAudio||(r._node=t._obtainHtml5Audio(),r._errorFn=r._errorListener.bind(r),r._node.addEventListener("error",r._errorFn,!1),r._loadFn=r._loadListener.bind(r),r._node.addEventListener(t._canPlayEvent,r._loadFn,!1),r._endFn=r._endListener.bind(r),r._node.addEventListener("ended",r._endFn,!1),r._node.src=l._src,r._node.preload=l._preload===!0?"auto":l._preload,r._node.volume=h*t.volume(),r._node.load()),r},reset:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._rateSeek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,r},_errorListener:function(){var r=this;r._parent._emit("loaderror",r._id,r._node.error?r._node.error.code:0),r._node.removeEventListener("error",r._errorFn,!1)},_loadListener:function(){var r=this,l=r._parent;l._duration=Math.ceil(r._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),r._node.removeEventListener(t._canPlayEvent,r._loadFn,!1)},_endListener:function(){var r=this,l=r._parent;l._duration===1/0&&(l._duration=Math.ceil(r._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(r)),r._node.removeEventListener("ended",r._endFn,!1)}};var a={},n=function(r){var l=r._src;if(a[l]){r._duration=a[l].duration,f(r);return}if(/^data:[^;]+;base64,/.test(l)){for(var h=atob(l.split(",")[1]),g=new Uint8Array(h.length),_=0;_<h.length;++_)g[_]=h.charCodeAt(_);u(g.buffer,r)}else{var m=new XMLHttpRequest;m.open(r._xhr.method,l,!0),m.withCredentials=r._xhr.withCredentials,m.responseType="arraybuffer",r._xhr.headers&&Object.keys(r._xhr.headers).forEach(function(v){m.setRequestHeader(v,r._xhr.headers[v])}),m.onload=function(){var v=(m.status+"")[0];if(v!=="0"&&v!=="2"&&v!=="3"){r._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}u(m.response,r)},m.onerror=function(){r._webAudio&&(r._html5=!0,r._webAudio=!1,r._sounds=[],delete a[l],r.load())},c(m)}},c=function(r){try{r.send()}catch{r.onerror()}},u=function(r,l){var h=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(_){_&&l._sounds.length>0?(a[l._src]=_,f(l,_)):h()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(r).then(g).catch(h):t.ctx.decodeAudioData(r,g,h)},f=function(r,l){l&&!r._duration&&(r._duration=l.duration),Object.keys(r._sprite).length===0&&(r._sprite={__default:[0,r._duration*1e3]}),r._state!=="loaded"&&(r._state="loaded",r._emit("load"),r._loadQueue())},p=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var r=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),h=l?parseInt(l[1],10):null;if(r&&h&&h<9){var g=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!g&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};o.Howler=t,o.Howl=i,typeof bt<"u"?(bt.HowlerGlobal=e,bt.Howler=t,bt.Howl=i,bt.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})();/*!
3696
+ */(function(o){(function(){var e=function(){this.init()};e.prototype={init:function(){var r=this||t;return r._counter=1e3,r._html5AudioPool=[],r.html5PoolSize=10,r._codecs={},r._howls=[],r._muted=!1,r._volume=1,r._canPlayEvent="canplaythrough",r._navigator=typeof window<"u"&&window.navigator?window.navigator:null,r.masterGain=null,r.noAudio=!1,r.usingWebAudio=!0,r.autoSuspend=!0,r.ctx=null,r.autoUnlock=!0,r._setup(),r},volume:function(r){var l=this||t;if(r=parseFloat(r),l.ctx||p(),typeof r<"u"&&r>=0&&r<=1){if(l._volume=r,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.volume=m._volume*r)}return l}return l._volume},mute:function(r){var l=this||t;l.ctx||p(),l._muted=r,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r?0:l._volume,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.muted=r?!0:m._muted)}return l},stop:function(){for(var r=this||t,l=0;l<r._howls.length;l++)r._howls[l].stop();return r},unload:function(){for(var r=this||t,l=r._howls.length-1;l>=0;l--)r._howls[l].unload();return r.usingWebAudio&&r.ctx&&typeof r.ctx.close<"u"&&(r.ctx.close(),r.ctx=null,p()),r},codecs:function(r){return(this||t)._codecs[r.replace(/^x-/,"")]},_setup:function(){var r=this||t;if(r.state=r.ctx&&r.ctx.state||"suspended",r._autoSuspend(),!r.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(r._canPlayEvent="canplay")}catch{r.noAudio=!0}else r.noAudio=!0;try{var l=new Audio;l.muted&&(r.noAudio=!0)}catch{}return r.noAudio||r._setupCodecs(),r},_setupCodecs:function(){var r=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return r}if(!l||typeof l.canPlayType!="function")return r;var h=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=r._navigator?r._navigator.userAgent:"",_=g.match(/OPR\/(\d+)/g),m=_&&parseInt(_[0].split("/")[1],10)<33,v=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),x=v&&y&&parseInt(y[1],10)<15;return r._codecs={mp3:!!(!m&&(h||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},r},_unlockAudio:function(){var r=this||t;if(!(r._audioUnlocked||!r.ctx)){r._audioUnlocked=!1,r.autoUnlock=!1,!r._mobileUnloaded&&r.ctx.sampleRate!==44100&&(r._mobileUnloaded=!0,r.unload()),r._scratchBuffer=r.ctx.createBuffer(1,1,22050);var l=function(h){for(;r._html5AudioPool.length<r.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,r._releaseHtml5Audio(g)}catch{r.noAudio=!0;break}for(var _=0;_<r._howls.length;_++)if(!r._howls[_]._webAudio)for(var m=r._howls[_]._getSoundIds(),v=0;v<m.length;v++){var y=r._howls[_]._soundById(m[v]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}r._autoResume();var x=r.ctx.createBufferSource();x.buffer=r._scratchBuffer,x.connect(r.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof r.ctx.resume=="function"&&r.ctx.resume(),x.onended=function(){x.disconnect(0),r._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var w=0;w<r._howls.length;w++)r._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),r}},_obtainHtml5Audio:function(){var r=this||t;if(r._html5AudioPool.length)return r._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(r){var l=this||t;return r._unlocked&&l._html5AudioPool.push(r),l},_autoSuspend:function(){var r=this;if(!(!r.autoSuspend||!r.ctx||typeof r.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<r._howls.length;l++)if(r._howls[l]._webAudio){for(var h=0;h<r._howls[l]._sounds.length;h++)if(!r._howls[l]._sounds[h]._paused)return r}return r._suspendTimer&&clearTimeout(r._suspendTimer),r._suspendTimer=setTimeout(function(){if(r.autoSuspend){r._suspendTimer=null,r.state="suspending";var g=function(){r.state="suspended",r._resumeAfterSuspend&&(delete r._resumeAfterSuspend,r._autoResume())};r.ctx.suspend().then(g,g)}},3e4),r}},_autoResume:function(){var r=this;if(!(!r.ctx||typeof r.ctx.resume>"u"||!t.usingWebAudio))return r.state==="running"&&r.ctx.state!=="interrupted"&&r._suspendTimer?(clearTimeout(r._suspendTimer),r._suspendTimer=null):r.state==="suspended"||r.state==="running"&&r.ctx.state==="interrupted"?(r.ctx.resume().then(function(){r.state="running";for(var l=0;l<r._howls.length;l++)r._howls[l]._emit("resume")}),r._suspendTimer&&(clearTimeout(r._suspendTimer),r._suspendTimer=null)):r.state==="suspending"&&(r._resumeAfterSuspend=!0),r}};var t=new e,i=function(r){var l=this;if(!r.src||r.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(r)};i.prototype={init:function(r){var l=this;return t.ctx||p(),l._autoplay=r.autoplay||!1,l._format=typeof r.format!="string"?r.format:[r.format],l._html5=r.html5||!1,l._muted=r.mute||!1,l._loop=r.loop||!1,l._pool=r.pool||5,l._preload=typeof r.preload=="boolean"||r.preload==="metadata"?r.preload:!0,l._rate=r.rate||1,l._sprite=r.sprite||{},l._src=typeof r.src!="string"?r.src:[r.src],l._volume=r.volume!==void 0?r.volume:1,l._xhr={method:r.xhr&&r.xhr.method?r.xhr.method:"GET",headers:r.xhr&&r.xhr.headers?r.xhr.headers:null,withCredentials:r.xhr&&r.xhr.withCredentials?r.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=r.onend?[{fn:r.onend}]:[],l._onfade=r.onfade?[{fn:r.onfade}]:[],l._onload=r.onload?[{fn:r.onload}]:[],l._onloaderror=r.onloaderror?[{fn:r.onloaderror}]:[],l._onplayerror=r.onplayerror?[{fn:r.onplayerror}]:[],l._onpause=r.onpause?[{fn:r.onpause}]:[],l._onplay=r.onplay?[{fn:r.onplay}]:[],l._onstop=r.onstop?[{fn:r.onstop}]:[],l._onmute=r.onmute?[{fn:r.onmute}]:[],l._onvolume=r.onvolume?[{fn:r.onvolume}]:[],l._onrate=r.onrate?[{fn:r.onrate}]:[],l._onseek=r.onseek?[{fn:r.onseek}]:[],l._onunlock=r.onunlock?[{fn:r.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var r=this,l=null;if(t.noAudio){r._emit("loaderror",null,"No audio support.");return}typeof r._src=="string"&&(r._src=[r._src]);for(var h=0;h<r._src.length;h++){var g,_;if(r._format&&r._format[h])g=r._format[h];else{if(_=r._src[h],typeof _!="string"){r._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(_),g||(g=/\.([^.]+)$/.exec(_.split("?",1)[0])),g&&(g=g[1].toLowerCase())}if(g||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),g&&t.codecs(g)){l=r._src[h];break}}if(!l){r._emit("loaderror",null,"No codec support for selected audio sources.");return}return r._src=l,r._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(r._html5=!0,r._webAudio=!1),new s(r),r._webAudio&&n(r),r},play:function(r,l){var h=this,g=null;if(typeof r=="number")g=r,r=null;else{if(typeof r=="string"&&h._state==="loaded"&&!h._sprite[r])return null;if(typeof r>"u"&&(r="__default",!h._playLock)){for(var _=0,m=0;m<h._sounds.length;m++)h._sounds[m]._paused&&!h._sounds[m]._ended&&(_++,g=h._sounds[m]._id);_===1?r=null:g=null}}var v=g?h._soundById(g):h._inactiveSound();if(!v)return null;if(g&&!r&&(r=v._sprite||"__default"),h._state!=="loaded"){v._sprite=r,v._ended=!1;var y=v._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(g&&!v._paused)return l||h._loadQueue("play"),v._id;h._webAudio&&t._autoResume();var x=Math.max(0,v._seek>0?v._seek:h._sprite[r][0]/1e3),w=Math.max(0,(h._sprite[r][0]+h._sprite[r][1])/1e3-x),b=w*1e3/Math.abs(v._rate),A=h._sprite[r][0]/1e3,S=(h._sprite[r][0]+h._sprite[r][1])/1e3;v._sprite=r,v._ended=!1;var C=function(){v._paused=!1,v._seek=x,v._start=A,v._stop=S,v._loop=!!(v._loop||h._sprite[r][2])};if(x>=S){h._ended(v);return}var M=v._node;if(h._webAudio){var I=function(){h._playLock=!1,C(),h._refreshBuffer(v);var L=v._muted||h._muted?0:v._volume;M.gain.setValueAtTime(L,t.ctx.currentTime),v._playStart=t.ctx.currentTime,typeof M.bufferSource.start>"u"?v._loop?M.bufferSource.noteGrainOn(0,x,86400):M.bufferSource.noteGrainOn(0,x,w):v._loop?M.bufferSource.start(0,x,86400):M.bufferSource.start(0,x,w),b!==1/0&&(h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b)),l||setTimeout(function(){h._emit("play",v._id),h._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?I():(h._playLock=!0,h.once("resume",I),h._clearTimer(v._id))}else{var D=function(){M.currentTime=x,M.muted=v._muted||h._muted||t._muted||M.muted,M.volume=v._volume*t.volume(),M.playbackRate=v._rate;try{var L=M.play();if(L&&typeof Promise<"u"&&(L instanceof Promise||typeof L.then=="function")?(h._playLock=!0,C(),L.then(function(){h._playLock=!1,M._unlocked=!0,l?h._loadQueue():h._emit("play",v._id)}).catch(function(){h._playLock=!1,h._emit("playerror",v._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),v._ended=!0,v._paused=!0})):l||(h._playLock=!1,C(),h._emit("play",v._id)),M.playbackRate=v._rate,M.paused){h._emit("playerror",v._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}r!=="__default"||v._loop?h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b):(h._endTimers[v._id]=function(){h._ended(v),M.removeEventListener("ended",h._endTimers[v._id],!1)},M.addEventListener("ended",h._endTimers[v._id],!1))}catch(F){h._emit("playerror",v._id,F)}};M.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(M.src=h._src,M.load());var T=window&&window.ejecta||!M.readyState&&t._navigator.isCocoonJS;if(M.readyState>=3||T)D();else{h._playLock=!0,h._state="loading";var R=function(){h._state="loaded",D(),M.removeEventListener(t._canPlayEvent,R,!1)};M.addEventListener(t._canPlayEvent,R,!1),h._clearTimer(v._id)}}return v._id},pause:function(r){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(r)}}),l;for(var h=l._getSoundIds(r),g=0;g<h.length;g++){l._clearTimer(h[g]);var _=l._soundById(h[g]);if(_&&!_._paused&&(_._seek=l.seek(h[g]),_._rateSeek=0,_._paused=!0,l._stopFade(h[g]),_._node))if(l._webAudio){if(!_._node.bufferSource)continue;typeof _._node.bufferSource.stop>"u"?_._node.bufferSource.noteOff(0):_._node.bufferSource.stop(0),l._cleanBuffer(_._node)}else(!isNaN(_._node.duration)||_._node.duration===1/0)&&_._node.pause();arguments[1]||l._emit("pause",_?_._id:null)}return l},stop:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(r)}}),h;for(var g=h._getSoundIds(r),_=0;_<g.length;_++){h._clearTimer(g[_]);var m=h._soundById(g[_]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,h._stopFade(g[_]),m._node&&(h._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),h._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&h._clearSound(m._node))),l||h._emit("stop",m._id))}return h},mute:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(r,l)}}),h;if(typeof l>"u")if(typeof r=="boolean")h._muted=r;else return h._muted;for(var g=h._getSoundIds(l),_=0;_<g.length;_++){var m=h._soundById(g[_]);m&&(m._muted=r,m._interval&&h._stopFade(m._id),h._webAudio&&m._node?m._node.gain.setValueAtTime(r?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:r),h._emit("mute",m._id))}return h},volume:function(){var r=this,l=arguments,h,g;if(l.length===0)return r._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length>=2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h<"u"&&h>=0&&h<=1){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,l)}}),r;typeof g>"u"&&(r._volume=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)v=r._soundById(g[y]),v&&(v._volume=h,l[2]||r._stopFade(g[y]),r._webAudio&&v._node&&!v._muted?v._node.gain.setValueAtTime(h,t.ctx.currentTime):v._node&&!v._muted&&(v._node.volume=h*t.volume()),r._emit("volume",v._id))}else return v=g?r._soundById(g):r._sounds[0],v?v._volume:0;return r},fade:function(r,l,h,g){var _=this;if(_._state!=="loaded"||_._playLock)return _._queue.push({event:"fade",action:function(){_.fade(r,l,h,g)}}),_;r=Math.min(Math.max(0,parseFloat(r)),1),l=Math.min(Math.max(0,parseFloat(l)),1),h=parseFloat(h),_.volume(r,g);for(var m=_._getSoundIds(g),v=0;v<m.length;v++){var y=_._soundById(m[v]);if(y){if(g||_._stopFade(m[v]),_._webAudio&&!y._muted){var x=t.ctx.currentTime,w=x+h/1e3;y._volume=r,y._node.gain.setValueAtTime(r,x),y._node.gain.linearRampToValueAtTime(l,w)}_._startFadeInterval(y,r,l,h,m[v],typeof g>"u")}}return _},_startFadeInterval:function(r,l,h,g,_,m){var v=this,y=l,x=h-l,w=Math.abs(x/.01),b=Math.max(4,w>0?g/w:g),A=Date.now();r._fadeTo=h,r._interval=setInterval(function(){var S=(Date.now()-A)/g;A=Date.now(),y+=x*S,y=Math.round(y*100)/100,x<0?y=Math.max(h,y):y=Math.min(h,y),v._webAudio?r._volume=y:v.volume(y,r._id,!0),m&&(v._volume=y),(h<l&&y<=h||h>l&&y>=h)&&(clearInterval(r._interval),r._interval=null,r._fadeTo=null,v.volume(h,r._id),v._emit("fade",r._id))},b)},_stopFade:function(r){var l=this,h=l._soundById(r);return h&&h._interval&&(l._webAudio&&h._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(h._interval),h._interval=null,l.volume(h._fadeTo,r),h._fadeTo=null,l._emit("fade",r)),l},loop:function(){var r=this,l=arguments,h,g,_;if(l.length===0)return r._loop;if(l.length===1)if(typeof l[0]=="boolean")h=l[0],r._loop=h;else return _=r._soundById(parseInt(l[0],10)),_?_._loop:!1;else l.length===2&&(h=l[0],g=parseInt(l[1],10));for(var m=r._getSoundIds(g),v=0;v<m.length;v++)_=r._soundById(m[v]),_&&(_._loop=h,r._webAudio&&_._node&&_._node.bufferSource&&(_._node.bufferSource.loop=h,h&&(_._node.bufferSource.loopStart=_._start||0,_._node.bufferSource.loopEnd=_._stop,r.playing(m[v])&&(r.pause(m[v],!0),r.play(m[v],!0)))));return r},rate:function(){var r=this,l=arguments,h,g;if(l.length===0)g=r._sounds[0]._id;else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h=="number"){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,l)}}),r;typeof g>"u"&&(r._rate=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)if(v=r._soundById(g[y]),v){r.playing(g[y])&&(v._rateSeek=r.seek(g[y]),v._playStart=r._webAudio?t.ctx.currentTime:v._playStart),v._rate=h,r._webAudio&&v._node&&v._node.bufferSource?v._node.bufferSource.playbackRate.setValueAtTime(h,t.ctx.currentTime):v._node&&(v._node.playbackRate=h);var x=r.seek(g[y]),w=(r._sprite[v._sprite][0]+r._sprite[v._sprite][1])/1e3-x,b=w*1e3/Math.abs(v._rate);(r._endTimers[g[y]]||!v._paused)&&(r._clearTimer(g[y]),r._endTimers[g[y]]=setTimeout(r._ended.bind(r,v),b)),r._emit("rate",v._id)}}else return v=r._soundById(g),v?v._rate:r._rate;return r},seek:function(){var r=this,l=arguments,h,g;if(l.length===0)r._sounds.length&&(g=r._sounds[0]._id);else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):r._sounds.length&&(g=r._sounds[0]._id,h=parseFloat(l[0]))}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof h=="number"&&(r._state!=="loaded"||r._playLock))return r._queue.push({event:"seek",action:function(){r.seek.apply(r,l)}}),r;var v=r._soundById(g);if(v)if(typeof h=="number"&&h>=0){var y=r.playing(g);y&&r.pause(g,!0),v._seek=h,v._ended=!1,r._clearTimer(g),!r._webAudio&&v._node&&!isNaN(v._node.duration)&&(v._node.currentTime=h);var x=function(){y&&r.play(g,!0),r._emit("seek",g)};if(y&&!r._webAudio){var w=function(){r._playLock?setTimeout(w,0):x()};setTimeout(w,0)}else x()}else if(r._webAudio){var b=r.playing(g)?t.ctx.currentTime-v._playStart:0,A=v._rateSeek?v._rateSeek-v._seek:0;return v._seek+(A+b*Math.abs(v._rate))}else return v._node.currentTime;return r},playing:function(r){var l=this;if(typeof r=="number"){var h=l._soundById(r);return h?!h._paused:!1}for(var g=0;g<l._sounds.length;g++)if(!l._sounds[g]._paused)return!0;return!1},duration:function(r){var l=this,h=l._duration,g=l._soundById(r);return g&&(h=l._sprite[g._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var r=this,l=r._sounds,h=0;h<l.length;h++)l[h]._paused||r.stop(l[h]._id),r._webAudio||(r._clearSound(l[h]._node),l[h]._node.removeEventListener("error",l[h]._errorFn,!1),l[h]._node.removeEventListener(t._canPlayEvent,l[h]._loadFn,!1),l[h]._node.removeEventListener("ended",l[h]._endFn,!1),t._releaseHtml5Audio(l[h]._node)),delete l[h]._node,r._clearTimer(l[h]._id);var g=t._howls.indexOf(r);g>=0&&t._howls.splice(g,1);var _=!0;for(h=0;h<t._howls.length;h++)if(t._howls[h]._src===r._src||r._src.indexOf(t._howls[h]._src)>=0){_=!1;break}return a&&_&&delete a[r._src],t.noAudio=!1,r._state="unloaded",r._sounds=[],r=null,null},on:function(r,l,h,g){var _=this,m=_["_on"+r];return typeof l=="function"&&m.push(g?{id:h,fn:l,once:g}:{id:h,fn:l}),_},off:function(r,l,h){var g=this,_=g["_on"+r],m=0;if(typeof l=="number"&&(h=l,l=null),l||h)for(m=0;m<_.length;m++){var v=h===_[m].id;if(l===_[m].fn&&v||!l&&v){_.splice(m,1);break}}else if(r)g["_on"+r]=[];else{var y=Object.keys(g);for(m=0;m<y.length;m++)y[m].indexOf("_on")===0&&Array.isArray(g[y[m]])&&(g[y[m]]=[])}return g},once:function(r,l,h){var g=this;return g.on(r,l,h,1),g},_emit:function(r,l,h){for(var g=this,_=g["_on"+r],m=_.length-1;m>=0;m--)(!_[m].id||_[m].id===l||r==="load")&&(setTimeout((function(v){v.call(this,l,h)}).bind(g,_[m].fn),0),_[m].once&&g.off(r,_[m].fn,_[m].id));return g._loadQueue(r),g},_loadQueue:function(r){var l=this;if(l._queue.length>0){var h=l._queue[0];h.event===r&&(l._queue.shift(),l._loadQueue()),r||h.action()}return l},_ended:function(r){var l=this,h=r._sprite;if(!l._webAudio&&r._node&&!r._node.paused&&!r._node.ended&&r._node.currentTime<r._stop)return setTimeout(l._ended.bind(l,r),100),l;var g=!!(r._loop||l._sprite[h][2]);if(l._emit("end",r._id),!l._webAudio&&g&&l.stop(r._id,!0).play(r._id),l._webAudio&&g){l._emit("play",r._id),r._seek=r._start||0,r._rateSeek=0,r._playStart=t.ctx.currentTime;var _=(r._stop-r._start)*1e3/Math.abs(r._rate);l._endTimers[r._id]=setTimeout(l._ended.bind(l,r),_)}return l._webAudio&&!g&&(r._paused=!0,r._ended=!0,r._seek=r._start||0,r._rateSeek=0,l._clearTimer(r._id),l._cleanBuffer(r._node),t._autoSuspend()),!l._webAudio&&!g&&l.stop(r._id,!0),l},_clearTimer:function(r){var l=this;if(l._endTimers[r]){if(typeof l._endTimers[r]!="function")clearTimeout(l._endTimers[r]);else{var h=l._soundById(r);h&&h._node&&h._node.removeEventListener("ended",l._endTimers[r],!1)}delete l._endTimers[r]}return l},_soundById:function(r){for(var l=this,h=0;h<l._sounds.length;h++)if(r===l._sounds[h]._id)return l._sounds[h];return null},_inactiveSound:function(){var r=this;r._drain();for(var l=0;l<r._sounds.length;l++)if(r._sounds[l]._ended)return r._sounds[l].reset();return new s(r)},_drain:function(){var r=this,l=r._pool,h=0,g=0;if(!(r._sounds.length<l)){for(g=0;g<r._sounds.length;g++)r._sounds[g]._ended&&h++;for(g=r._sounds.length-1;g>=0;g--){if(h<=l)return;r._sounds[g]._ended&&(r._webAudio&&r._sounds[g]._node&&r._sounds[g]._node.disconnect(0),r._sounds.splice(g,1),h--)}}},_getSoundIds:function(r){var l=this;if(typeof r>"u"){for(var h=[],g=0;g<l._sounds.length;g++)h.push(l._sounds[g]._id);return h}else return[r]},_refreshBuffer:function(r){var l=this;return r._node.bufferSource=t.ctx.createBufferSource(),r._node.bufferSource.buffer=a[l._src],r._panner?r._node.bufferSource.connect(r._panner):r._node.bufferSource.connect(r._node),r._node.bufferSource.loop=r._loop,r._loop&&(r._node.bufferSource.loopStart=r._start||0,r._node.bufferSource.loopEnd=r._stop||0),r._node.bufferSource.playbackRate.setValueAtTime(r._rate,t.ctx.currentTime),l},_cleanBuffer:function(r){var l=this,h=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!r.bufferSource)return l;if(t._scratchBuffer&&r.bufferSource&&(r.bufferSource.onended=null,r.bufferSource.disconnect(0),h))try{r.bufferSource.buffer=t._scratchBuffer}catch{}return r.bufferSource=null,l},_clearSound:function(r){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(r.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(r){this._parent=r,this.init()};s.prototype={init:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,l._sounds.push(r),r.create(),r},create:function(){var r=this,l=r._parent,h=t._muted||r._muted||r._parent._muted?0:r._volume;return l._webAudio?(r._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),r._node.gain.setValueAtTime(h,t.ctx.currentTime),r._node.paused=!0,r._node.connect(t.masterGain)):t.noAudio||(r._node=t._obtainHtml5Audio(),r._errorFn=r._errorListener.bind(r),r._node.addEventListener("error",r._errorFn,!1),r._loadFn=r._loadListener.bind(r),r._node.addEventListener(t._canPlayEvent,r._loadFn,!1),r._endFn=r._endListener.bind(r),r._node.addEventListener("ended",r._endFn,!1),r._node.src=l._src,r._node.preload=l._preload===!0?"auto":l._preload,r._node.volume=h*t.volume(),r._node.load()),r},reset:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._rateSeek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,r},_errorListener:function(){var r=this;r._parent._emit("loaderror",r._id,r._node.error?r._node.error.code:0),r._node.removeEventListener("error",r._errorFn,!1)},_loadListener:function(){var r=this,l=r._parent;l._duration=Math.ceil(r._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),r._node.removeEventListener(t._canPlayEvent,r._loadFn,!1)},_endListener:function(){var r=this,l=r._parent;l._duration===1/0&&(l._duration=Math.ceil(r._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(r)),r._node.removeEventListener("ended",r._endFn,!1)}};var a={},n=function(r){var l=r._src;if(a[l]){r._duration=a[l].duration,d(r);return}if(/^data:[^;]+;base64,/.test(l)){for(var h=atob(l.split(",")[1]),g=new Uint8Array(h.length),_=0;_<h.length;++_)g[_]=h.charCodeAt(_);u(g.buffer,r)}else{var m=new XMLHttpRequest;m.open(r._xhr.method,l,!0),m.withCredentials=r._xhr.withCredentials,m.responseType="arraybuffer",r._xhr.headers&&Object.keys(r._xhr.headers).forEach(function(v){m.setRequestHeader(v,r._xhr.headers[v])}),m.onload=function(){var v=(m.status+"")[0];if(v!=="0"&&v!=="2"&&v!=="3"){r._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}u(m.response,r)},m.onerror=function(){r._webAudio&&(r._html5=!0,r._webAudio=!1,r._sounds=[],delete a[l],r.load())},c(m)}},c=function(r){try{r.send()}catch{r.onerror()}},u=function(r,l){var h=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(_){_&&l._sounds.length>0?(a[l._src]=_,d(l,_)):h()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(r).then(g).catch(h):t.ctx.decodeAudioData(r,g,h)},d=function(r,l){l&&!r._duration&&(r._duration=l.duration),Object.keys(r._sprite).length===0&&(r._sprite={__default:[0,r._duration*1e3]}),r._state!=="loaded"&&(r._state="loaded",r._emit("load"),r._loadQueue())},p=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var r=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),h=l?parseInt(l[1],10):null;if(r&&h&&h<9){var g=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!g&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};o.Howler=t,o.Howl=i,typeof xt<"u"?(xt.HowlerGlobal=e,xt.Howler=t,xt.Howl=i,xt.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})();/*!
3697
3697
  * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
3698
3698
  *
3699
3699
  * howler.js v2.2.4
@@ -3703,23 +3703,23 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new
3703
3703
  * goldfirestudios.com
3704
3704
  *
3705
3705
  * MIT License
3706
- */(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,n,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var f=u._orientation;if(i=typeof i!="number"?f[1]:i,s=typeof s!="number"?f[2]:s,a=typeof a!="number"?f[3]:a,n=typeof n!="number"?f[4]:n,c=typeof c!="number"?f[5]:c,typeof t=="number")u._orientation=[t,i,s,a,n,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(n,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,n,c);else return f;return u},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var a=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var n=s._getSoundIds(i),c=0;c<n.length;c++){var u=s._soundById(n[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"pos",action:function(){n.pos(t,i,s,a)}}),n;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")n._pos=[t,i,s];else return n._pos;for(var c=n._getSoundIds(a),u=0;u<c.length;u++){var f=n._soundById(c[u]);if(f)if(typeof t=="number")f._pos=[t,i,s],f._node&&((!f._panner||f._panner.pan)&&e(f,"spatial"),typeof f._panner.positionX<"u"?(f._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setPosition(t,i,s)),n._emit("pos",f._id);else return f._pos}return n},Howl.prototype.orientation=function(t,i,s,a){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"orientation",action:function(){n.orientation(t,i,s,a)}}),n;if(i=typeof i!="number"?n._orientation[1]:i,s=typeof s!="number"?n._orientation[2]:s,typeof a>"u")if(typeof t=="number")n._orientation=[t,i,s];else return n._orientation;for(var c=n._getSoundIds(a),u=0;u<c.length;u++){var f=n._soundById(c[u]);if(f)if(typeof t=="number")f._orientation=[t,i,s],f._node&&(f._panner||(f._pos||(f._pos=n._pos||[0,0,-.5]),e(f,"spatial")),typeof f._panner.orientationX<"u"?(f._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setOrientation(t,i,s)),n._emit("orientation",f._id);else return f._orientation}return n},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,n;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof a>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return n=t._soundById(parseInt(i[0],10)),n?n._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(n=t._soundById(c[u]),n){var f=n._pannerAttr;f={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:f.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:f.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:f.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:f.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:f.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:f.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:f.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:f.panningModel};var p=n._panner;p||(n._pos||(n._pos=t._pos||[0,0,-.5]),e(n,"spatial"),p=n._panner),p.coneInnerAngle=f.coneInnerAngle,p.coneOuterAngle=f.coneOuterAngle,p.coneOuterGain=f.coneOuterGain,p.distanceModel=f.distanceModel,p.maxDistance=f.maxDistance,p.refDistance=f.refDistance,p.rolloffFactor=f.rolloffFactor,p.panningModel=f.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(Wr);const Na="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAExhdmM1OC43NQAAAAAAAAAAAAAAACQCwAAAAAAAAAjgTZykiAAAAAAAAAAAAAAAAAD/80DEABJhFmQCwwYUIDsKrsHAWBMRyeJYliQJBg5RYsWU/W3z/8OLc/3AAAQiIAIjv+7vUCJXd4jucQABAE3lwffiDBD+JC58oCH8H/1h/WH//1HPwTUMFrULH9ELKxULyTodFKYbO//zQsQRFFkScKDSRhyGWpIFpG91I7Fi/F6D2RWwN6TN/t9CiVSG5wMw74ogYcHoEwTFyMmTf4KkxEwmRfjXIYv1tpIOZRv/3O9ibtjR6gYmbGCgQ+Fk0mfSmybOX1cf78g7D6nP6qxCgf/zQMQbF+EacktaSABfy+3JKszHdMgcwwcl/kNFIuAo0I0DD1fWVs/crTSTTRInof3cmIwyLBwGQqCSLq7hyvtRPBB4aFyyXHov9X///7UXKqoIIcgcHict89/0y+n+nf/C0DIjB/+P//NCxBYZU9q0AYpoAHNyXSLn/+EjEbJclC4eJT//8e5aMAWeE4////wvAyAvYjZLjAD0Lg9D0kCU/////zwwBdJcYAehKBIwtYyx6FyXC4XP//////x7l83NDpfqd6gAcA/+wu9A2FGg//NAxAwXCnsq/5M4AhQKAOwmRvQRhjhOe5S8UkAmVHpU8IVU3lwejjIcayXOOceGwjf+D05I8oAu2x382o1ZHHV//31NU4441lmqcv///+RNGrUJKImnTf//iVYK1UZquoZESSy3egH/80LEChchBtMfyzAAk191v20qimbuNqavb211BthJKSJAG2aucbdLeVFVmRjZEVvzOggIwuUFDgvEZA7UeuUqNMLOraDQ5CVCk5m9BsmT3kbNrBdolcFSsqXGwQTWyYUX2wEDEgKkvZb/80DECRYRUpWsikYY1HXLbDZksYxtCHBShdHt/DgYCOM6r8AmUSpfGZYzH7ARMBCj1JtmY/hmwoGio0XBUShoklC5GsNeDR38RQ6d01DyrENtqp6mCJ5GJUckmpUBaIgYK6C0fPjmUf/zQsQLFil+cajTBhydxPRO4mLMWWSGQF2qa1f3PPlHQDJdzCxnwgkzB1SQohrpNRYRgtobv07tBLUFc27jQdWoQY0JNpiMJy654enBVoqnQR571uq/i9rpL1oAqAupJATLLk5L+QT3Kf/zQMQOE9D2bWFaGACZyWQZdt1rd3OVY8s/y2dBlg0m12PFzdFSlYrboY6gMOE1hJp7iFqmDcopF8F2OKEPnktdThRLoy9iuyj//0vD4+qf///++38OsIIFFhpEFZMC4s+gZmilJz1X//NCxBkaW8allZI4AWPWKBoLFWrwfuYvukbk4Rt9tBuJYOBoWpfzfjQaNMp//+OGEzzzDIif3+n/4PBIEt5hjDc9zxv/////nseeNDHGg0MQwxBEFn//////4TpB9d/s9thcHddpssFg//NAxAsVCT8GX5BAAigUAPBBdOBaKEIpaajR1VyCNH/gAwAfjRX8G7B4zfx0HANA8BpjQ6FhfqKxRBQURleGbrufzJywVGVfRdOzp5///ERCxhb//8wqijBAwUYMBCjVWZsv26uwYU3/80LEERRTIuTLwxABmdQgEBGKFNo9amfRWcpnayOUsKJ/UpWo/qyL////sj1b+pc3oarStSWpf/VP+hlotDN/0MVjKMKDAZGL/Ar8QWpCR0msAoVgrMoeT3xHIZd3qARkQge7hzlejQD/80DEGxPQ5sryeYYUBCI58AEvohe5nAMDcPxAbUxN6VCB4xCid97iaTyonF0l4upInmIpD//V0f/OllFls0vEBipVlYYRWhuzlHgpEiJSRmYJQaiptezfqvKm1PBRJKiq7M3s1yoqKv/zQsQmFBEGuojBkAQdCzTSpHY0FSwdboEQKi7pZN986g7UVOkf5ZR6VdbbQwZ+79PW6VoWdwZqA4VT2QGoxuuO0VZgbATjSNkSqqresUZ4lDGM5tfbuZzGHYfri5YKg0eDjgQjhm0Wpf/zQMQxE1jyoqhoxFD16D4jzQUUULEB1QXZhRIdIbHFtSlSvX5anFh11QTHaABkiBXOXoXxGW9galRr4fRiew3yOag/4HjxOydOM9ZyyokPlRKdFBa0CjY1luBiKXXwLw6oeMWEhjoS//NCxD4TUNKKIJpMJNTRh7nf/3kekmjdSWypy9UZXQgZMDh3pnAWB4O2M6nAaelR4r1OmVPFSwoksiWRUE1zc+f1lPc0ZudtdFDr4LLpoSwwGkpVO+oD6Tlb3HsYL7d+R1//td2LQMNF//NAxEwTaP5xYqJMCFlqIwAbEoCJNDEp9/3itYVbV6Yx/v0nuLdzyy50qHQw3cafmKlb6zBo0yXeRMnQG5J4jE7j4PFAkTSpQ9pexojMMsL0PIqP/Z1Xp/TpnVZZ27eWtNWRSSSyWyz/80LEWRSo1nDhWhgAlsstlkskgADyNOHqG5rlhLnSyI0a5oClU7uw0JnJQq2kTMBUYADEskGQ9wdHohh2xMKnCubKTIdyRgT83NEIrcfJpJOL3fV7l9cyXXJwJRDGpJLTZJF1+3OPUX3/80DEYiVyorJfmlgDRVRdYm21rHJXTVH0+ajd35ouiSF1tVcmLGnFummxbrhsXfHNzcf/2qgd/7XhppiSaYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let Ga=class{constructor(){this.sound=new Wr.Howl({src:[Na]})}play(){this.sound.play()}};const _e=o=>{var e,t;if(typeof o.destroy=="function"){o.destroy();return}for(;o.children.length>0;)_e(o.children[0]),(e=o.children[0])==null||e.removeFromParent();if(o instanceof d.Mesh)try{(t=o.geometry)==null||t.dispose()}catch{}};function qa(o){return new d.Vector3(o[0],o[1],o[2])}function ja(){let o=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(o=4,e=1/window.devicePixelRatio),{tiles:o,renderScale:e}}function Qa(o){let e=!1,t=!1,i=!1,s=1/0,a=1/0,n=1/0,c=-1/0,u=-1/0,f=-1/0,p=0,r=0;return o.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const m=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),A=_.getZ(x);r=Math.max(b,r),m&&v&&m.forEach((C,M)=>{const I=v&&v[M]||0;w+=C.getX(x)*I,b+=C.getY(x)*I,A+=C.getZ(x)*I}),w<s&&(s=w),b<a&&(a=b),A<n&&(n=A),w>c&&(c=w),b>u&&(u=b),A>f&&(f=A);const S=Math.sqrt(w*w+b*b);S>p&&(p=S)}}}),{box:new d.Box3(new d.Vector3(s,a,n),new d.Vector3(c,u,f)),maxRadius:p,height:r,hasWidth:t,hasLength:e,hasHeight:i}}function Ya(o,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){o.apply(s,a)},e)}}class Za{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const $s=o=>{var i;let e=0,t=0;if(o.geometry){o.geometry.computeBoundingBox();const s=new d.Vector3;(i=o.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function vs(){var e;if(typeof navigator>"u")return!1;if(Ka())return!0;const o=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(o)}function Ka(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const Hr=new _n.GLTFExporter,Ne=new mn.GLTFLoader,vi=new gn.DRACOLoader;let ht="./draco/";try{ht=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:pt&&pt.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{ht="./draco/"}typeof window<"u"&&window.dracoPath&&(ht=window.dracoPath);vi.setDecoderConfig({type:"wasm"});vi.setDecoderPath(ht.endsWith("/")?ht:`${ht}/`);vi.preload();Ne.setDRACOLoader(vi);const Xa=new vn.DRACOExporter,er=[115,103,108,98];function Ja(o,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=new Uint8Array([115,103,108,98]),n=new Uint8Array(2);n[0]=t>>8,n[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const u=new Uint8Array(o),f=a.length+n.length+c.length+s.length+u.length,p=new Uint8Array(f);let r=0;return p.set(a,r),r+=a.length,p.set(n,r),r+=n.length,p.set(c,r),r+=c.length,p.set(s,r),r+=s.length,p.set(u,r),p.buffer}function $a(o){const e=new Uint8Array(o.slice(0,4));let t=!0;for(let r=0;r<er.length;r++)if(e[r]!==er[r]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(o,4,2).getUint16(0,!1),n=new DataView(o,6,4).getUint32(0,!1),c=new Uint8Array(o.slice(10,10+n)),u=new TextDecoder().decode(c),f=JSON.parse(u),p=o.slice(10+n);return{version:s,jsonDescription:f,glbContent:p}}class Bt{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const a=this;fetch(e).then(n=>{if(!n.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+n.statusText}));return}return n.arrayBuffer()}).then(async n=>{n||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=a.parse(n);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=Zi(c.glbContent,"model/gltf-binary"),f=await Ne.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=f.scene,c.scene=f.scene,c.animations=f.animations,n=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(n=>{s==null||s(new ErrorEvent("Error",{message:n.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const a=Zi(s.glbContent,"model/gltf-binary");console.log(a);const n=await Ne.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=n.scene,s.scene=n.scene,s.animations=n.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return $a(e)}clear(){[...this.cache.values()]}}const el=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,tl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",tr={name:"",isMobile:!1},il={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function At(o){return o==null?"":String(o).replace(/[&<>"']/g,e=>il[e])}function ir(...o){return o.filter(Boolean).join(" ")}class Nr extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...tr,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...tr,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=ir("slot-item-container",this._props.isMobile&&"is-mobile"),t=ir("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(r=>{const l=At(r);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(r=>!this._functions.includes(r)),a=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",n=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
3706
+ */(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,n,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var d=u._orientation;if(i=typeof i!="number"?d[1]:i,s=typeof s!="number"?d[2]:s,a=typeof a!="number"?d[3]:a,n=typeof n!="number"?d[4]:n,c=typeof c!="number"?d[5]:c,typeof t=="number")u._orientation=[t,i,s,a,n,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(n,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,n,c);else return d;return u},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var a=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var n=s._getSoundIds(i),c=0;c<n.length;c++){var u=s._soundById(n[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"pos",action:function(){n.pos(t,i,s,a)}}),n;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")n._pos=[t,i,s];else return n._pos;for(var c=n._getSoundIds(a),u=0;u<c.length;u++){var d=n._soundById(c[u]);if(d)if(typeof t=="number")d._pos=[t,i,s],d._node&&((!d._panner||d._panner.pan)&&e(d,"spatial"),typeof d._panner.positionX<"u"?(d._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),d._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),d._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):d._panner.setPosition(t,i,s)),n._emit("pos",d._id);else return d._pos}return n},Howl.prototype.orientation=function(t,i,s,a){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"orientation",action:function(){n.orientation(t,i,s,a)}}),n;if(i=typeof i!="number"?n._orientation[1]:i,s=typeof s!="number"?n._orientation[2]:s,typeof a>"u")if(typeof t=="number")n._orientation=[t,i,s];else return n._orientation;for(var c=n._getSoundIds(a),u=0;u<c.length;u++){var d=n._soundById(c[u]);if(d)if(typeof t=="number")d._orientation=[t,i,s],d._node&&(d._panner||(d._pos||(d._pos=n._pos||[0,0,-.5]),e(d,"spatial")),typeof d._panner.orientationX<"u"?(d._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),d._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),d._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):d._panner.setOrientation(t,i,s)),n._emit("orientation",d._id);else return d._orientation}return n},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,n;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof a>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return n=t._soundById(parseInt(i[0],10)),n?n._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(n=t._soundById(c[u]),n){var d=n._pannerAttr;d={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:d.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:d.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:d.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:d.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:d.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:d.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:d.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:d.panningModel};var p=n._panner;p||(n._pos||(n._pos=t._pos||[0,0,-.5]),e(n,"spatial"),p=n._panner),p.coneInnerAngle=d.coneInnerAngle,p.coneOuterAngle=d.coneOuterAngle,p.coneOuterGain=d.coneOuterGain,p.distanceModel=d.distanceModel,p.maxDistance=d.maxDistance,p.refDistance=d.refDistance,p.rolloffFactor=d.rolloffFactor,p.panningModel=d.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(Or);const Ba="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAExhdmM1OC43NQAAAAAAAAAAAAAAACQCwAAAAAAAAAjgTZykiAAAAAAAAAAAAAAAAAD/80DEABJhFmQCwwYUIDsKrsHAWBMRyeJYliQJBg5RYsWU/W3z/8OLc/3AAAQiIAIjv+7vUCJXd4jucQABAE3lwffiDBD+JC58oCH8H/1h/WH//1HPwTUMFrULH9ELKxULyTodFKYbO//zQsQRFFkScKDSRhyGWpIFpG91I7Fi/F6D2RWwN6TN/t9CiVSG5wMw74ogYcHoEwTFyMmTf4KkxEwmRfjXIYv1tpIOZRv/3O9ibtjR6gYmbGCgQ+Fk0mfSmybOX1cf78g7D6nP6qxCgf/zQMQbF+EacktaSABfy+3JKszHdMgcwwcl/kNFIuAo0I0DD1fWVs/crTSTTRInof3cmIwyLBwGQqCSLq7hyvtRPBB4aFyyXHov9X///7UXKqoIIcgcHict89/0y+n+nf/C0DIjB/+P//NCxBYZU9q0AYpoAHNyXSLn/+EjEbJclC4eJT//8e5aMAWeE4////wvAyAvYjZLjAD0Lg9D0kCU/////zwwBdJcYAehKBIwtYyx6FyXC4XP//////x7l83NDpfqd6gAcA/+wu9A2FGg//NAxAwXCnsq/5M4AhQKAOwmRvQRhjhOe5S8UkAmVHpU8IVU3lwejjIcayXOOceGwjf+D05I8oAu2x382o1ZHHV//31NU4441lmqcv///+RNGrUJKImnTf//iVYK1UZquoZESSy3egH/80LEChchBtMfyzAAk191v20qimbuNqavb211BthJKSJAG2aucbdLeVFVmRjZEVvzOggIwuUFDgvEZA7UeuUqNMLOraDQ5CVCk5m9BsmT3kbNrBdolcFSsqXGwQTWyYUX2wEDEgKkvZb/80DECRYRUpWsikYY1HXLbDZksYxtCHBShdHt/DgYCOM6r8AmUSpfGZYzH7ARMBCj1JtmY/hmwoGio0XBUShoklC5GsNeDR38RQ6d01DyrENtqp6mCJ5GJUckmpUBaIgYK6C0fPjmUf/zQsQLFil+cajTBhydxPRO4mLMWWSGQF2qa1f3PPlHQDJdzCxnwgkzB1SQohrpNRYRgtobv07tBLUFc27jQdWoQY0JNpiMJy654enBVoqnQR571uq/i9rpL1oAqAupJATLLk5L+QT3Kf/zQMQOE9D2bWFaGACZyWQZdt1rd3OVY8s/y2dBlg0m12PFzdFSlYrboY6gMOE1hJp7iFqmDcopF8F2OKEPnktdThRLoy9iuyj//0vD4+qf///++38OsIIFFhpEFZMC4s+gZmilJz1X//NCxBkaW8allZI4AWPWKBoLFWrwfuYvukbk4Rt9tBuJYOBoWpfzfjQaNMp//+OGEzzzDIif3+n/4PBIEt5hjDc9zxv/////nseeNDHGg0MQwxBEFn//////4TpB9d/s9thcHddpssFg//NAxAsVCT8GX5BAAigUAPBBdOBaKEIpaajR1VyCNH/gAwAfjRX8G7B4zfx0HANA8BpjQ6FhfqKxRBQURleGbrufzJywVGVfRdOzp5///ERCxhb//8wqijBAwUYMBCjVWZsv26uwYU3/80LEERRTIuTLwxABmdQgEBGKFNo9amfRWcpnayOUsKJ/UpWo/qyL////sj1b+pc3oarStSWpf/VP+hlotDN/0MVjKMKDAZGL/Ar8QWpCR0msAoVgrMoeT3xHIZd3qARkQge7hzlejQD/80DEGxPQ5sryeYYUBCI58AEvohe5nAMDcPxAbUxN6VCB4xCid97iaTyonF0l4upInmIpD//V0f/OllFls0vEBipVlYYRWhuzlHgpEiJSRmYJQaiptezfqvKm1PBRJKiq7M3s1yoqKv/zQsQmFBEGuojBkAQdCzTSpHY0FSwdboEQKi7pZN986g7UVOkf5ZR6VdbbQwZ+79PW6VoWdwZqA4VT2QGoxuuO0VZgbATjSNkSqqresUZ4lDGM5tfbuZzGHYfri5YKg0eDjgQjhm0Wpf/zQMQxE1jyoqhoxFD16D4jzQUUULEB1QXZhRIdIbHFtSlSvX5anFh11QTHaABkiBXOXoXxGW9galRr4fRiew3yOag/4HjxOydOM9ZyyokPlRKdFBa0CjY1luBiKXXwLw6oeMWEhjoS//NCxD4TUNKKIJpMJNTRh7nf/3kekmjdSWypy9UZXQgZMDh3pnAWB4O2M6nAaelR4r1OmVPFSwoksiWRUE1zc+f1lPc0ZudtdFDr4LLpoSwwGkpVO+oD6Tlb3HsYL7d+R1//td2LQMNF//NAxEwTaP5xYqJMCFlqIwAbEoCJNDEp9/3itYVbV6Yx/v0nuLdzyy50qHQw3cafmKlb6zBo0yXeRMnQG5J4jE7j4PFAkTSpQ9pexojMMsL0PIqP/Z1Xp/TpnVZZ27eWtNWRSSSyWyz/80LEWRSo1nDhWhgAlsstlkskgADyNOHqG5rlhLnSyI0a5oClU7uw0JnJQq2kTMBUYADEskGQ9wdHohh2xMKnCubKTIdyRgT83NEIrcfJpJOL3fV7l9cyXXJwJRDGpJLTZJF1+3OPUX3/80DEYiVyorJfmlgDRVRdYm21rHJXTVH0+ajd35ouiSF1tVcmLGnFummxbrhsXfHNzcf/2qgd/7XhppiSaYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let ka=class{constructor(){this.sound=new Or.Howl({src:[Ba]})}play(){this.sound.play()}};const ge=o=>{var e,t;if(typeof o.destroy=="function"){o.destroy();return}for(;o.children.length>0;)ge(o.children[0]),(e=o.children[0])==null||e.removeFromParent();if(o instanceof f.Mesh)try{(t=o.geometry)==null||t.dispose()}catch{}};function Oa(o){return new f.Vector3(o[0],o[1],o[2])}function za(){let o=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(o=4,e=1/window.devicePixelRatio),{tiles:o,renderScale:e}}function Va(o){let e=!1,t=!1,i=!1,s=1/0,a=1/0,n=1/0,c=-1/0,u=-1/0,d=-1/0,p=0,r=0;return o.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const m=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),A=_.getZ(x);r=Math.max(b,r),m&&v&&m.forEach((C,M)=>{const I=v&&v[M]||0;w+=C.getX(x)*I,b+=C.getY(x)*I,A+=C.getZ(x)*I}),w<s&&(s=w),b<a&&(a=b),A<n&&(n=A),w>c&&(c=w),b>u&&(u=b),A>d&&(d=A);const S=Math.sqrt(w*w+b*b);S>p&&(p=S)}}}),{box:new f.Box3(new f.Vector3(s,a,n),new f.Vector3(c,u,d)),maxRadius:p,height:r,hasWidth:t,hasLength:e,hasHeight:i}}function Ua(o,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){o.apply(s,a)},e)}}class Wa{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const Qs=o=>{var i;let e=0,t=0;if(o.geometry){o.geometry.computeBoundingBox();const s=new f.Vector3;(i=o.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function hs(){var e;if(typeof navigator>"u")return!1;if(Ha())return!0;const o=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(o)}function Ha(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const zr=new fn.GLTFExporter,We=new cn.GLTFLoader,di=new un.DRACOLoader;let ct="./draco/";try{ct=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{ct="./draco/"}typeof window<"u"&&window.dracoPath&&(ct=window.dracoPath);di.setDecoderConfig({type:"wasm"});di.setDecoderPath(ct.endsWith("/")?ct:`${ct}/`);di.preload();We.setDRACOLoader(di);const Na=new hn.DRACOExporter,Ys=[115,103,108,98];function Ga(o,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=new Uint8Array([115,103,108,98]),n=new Uint8Array(2);n[0]=t>>8,n[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const u=new Uint8Array(o),d=a.length+n.length+c.length+s.length+u.length,p=new Uint8Array(d);let r=0;return p.set(a,r),r+=a.length,p.set(n,r),r+=n.length,p.set(c,r),r+=c.length,p.set(s,r),r+=s.length,p.set(u,r),p.buffer}function qa(o){const e=new Uint8Array(o.slice(0,4));let t=!0;for(let r=0;r<Ys.length;r++)if(e[r]!==Ys[r]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(o,4,2).getUint16(0,!1),n=new DataView(o,6,4).getUint32(0,!1),c=new Uint8Array(o.slice(10,10+n)),u=new TextDecoder().decode(c),d=JSON.parse(u),p=o.slice(10+n);return{version:s,jsonDescription:d,glbContent:p}}class Et{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const a=this;fetch(e).then(n=>{if(!n.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+n.statusText}));return}return n.arrayBuffer()}).then(async n=>{n||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=a.parse(n);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=Gi(c.glbContent,"model/gltf-binary"),d=await We.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=d.scene,c.scene=d.scene,c.animations=d.animations,n=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(n=>{s==null||s(new ErrorEvent("Error",{message:n.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const a=Gi(s.glbContent,"model/gltf-binary");console.log(a);const n=await We.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=n.scene,s.scene=n.scene,s.animations=n.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return qa(e)}clear(){[...this.cache.values()]}}const ja=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,Qa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",Zs={name:"",isMobile:!1},Ya={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function wt(o){return o==null?"":String(o).replace(/[&<>"']/g,e=>Ya[e])}function Ks(...o){return o.filter(Boolean).join(" ")}class Vr extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...Zs,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...Zs,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=Ks("slot-item-container",this._props.isMobile&&"is-mobile"),t=Ks("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(r=>{const l=wt(r);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(r=>!this._functions.includes(r)),a=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",n=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
3707
3707
  <label>添加功能<i class="btn btn-close" data-action="toggle-dialog"></i></label>
3708
3708
  <div class="functions">
3709
- ${s.map(r=>{const l=At(r);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
3709
+ ${s.map(r=>{const l=wt(r);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
3710
3710
  </div>
3711
- </div>`:"",c=this._deviceLogo?`<img class="device-logo" src="${At(this._deviceLogo)}" alt="device logo">`:"",u=At(((p=this._slot)==null?void 0:p.name)??this._props.name??""),f=At(this._deviceName||"待安装");this.shadowRoot.innerHTML=`
3712
- <style>${el}</style>
3711
+ </div>`:"",c=this._deviceLogo?`<img class="device-logo" src="${wt(this._deviceLogo)}" alt="device logo">`:"",u=wt(((p=this._slot)==null?void 0:p.name)??this._props.name??""),d=wt(this._deviceName||"待安装");this.shadowRoot.innerHTML=`
3712
+ <style>${ja}</style>
3713
3713
  <div class="${e}">
3714
3714
  <div class="${t}" style="width:${this._size}px;height:${this._size}px"></div>
3715
3715
  <div class="info">
3716
- <img alt="" src="${tl}">
3716
+ <img alt="" src="${Qa}">
3717
3717
  <div class="name">
3718
3718
  <div class="name-wrapper">${u}</div>
3719
3719
  <div class="functions-wrapper">
3720
3720
  <div class="device-name ${this._deviceName?"":"empty"}">
3721
3721
  ${c}
3722
- <span>${f}</span>
3722
+ <span>${d}</span>
3723
3723
  <i class="btn btn-close" data-action="remove-device"></i>
3724
3724
  </div>
3725
3725
  ${a}
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new
3728
3728
  </div>
3729
3729
  </div>
3730
3730
  </div>
3731
- `,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Nr);const Y={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class Xi extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new gt,this._slotContainer=new d.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new d.Vector3,this._wrapper=new d.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Nr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_DELETED)}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(Y.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const n=JSON.parse(s);try{await this.install(n),this._emitter.emit(Y.ON_DROP,this)}catch(c){this._emitter.emit(Y.ON_DROP_ERROR,c)}}else this._emitter.emit(Y.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const a=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*a}}}async loadGlb(e){const i=await new Bt({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Bt({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_REPLACED),s.traverse(a=>{a.name.startsWith("Slot")&&this._bracketSlots.push(a),a.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(a=>{a.add(i)})}else this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_REPLACED),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),_e(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(Y.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(Y.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(Y.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(Y.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),_e(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(n=34,c=60,u=60),a<u){let f=(u-a)*1+n;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(n)}clone(e){return new d.Group}}class sl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=vs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const a="6px",n=document.createElement("div");n.style.pointerEvents="none",Object.assign(n.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(n);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class li extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new sl(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.Vector3().subVectors(t,e).normalize();let n;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?n=new d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0)),n.normalize();const c=new d.Vector3().addVectors(e,n.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*1e3).toFixed(0)} mm`;const l=new d.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>_e(e)),this.removeFromParent()}}class Gr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new rl(""),this._line=new li(void 0,!1,!1),this._box=new d.Mesh,this._arc=new xn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new Cs.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new wn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new d.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let n=.006*this.radius;n<.003&&(n=.003),n>.006&&(n=.006);const c=this._createArcGeometry(s,a,this.radius+n);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],a=t-e,n=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/n;for(let f=0;f<=n;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new Cs.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class rl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=vs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",sr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAdzSURBVHic7Z3hlZs6EIUvW4E7CB3EHcQdxB08OngugVTg8yrwSQVOKnBSwW4qsFOB3cF9PxhZQsYYjEAS1neOD7ssCwPXMxoNIGWIDJJLAAsASwCfAOTyey6bLOQDABf5qJ9P8vkry48sy05j2+ySzLcBjyC5QiXOV1kuWv+hPxcAvwD8BvCBSsRL6394JDjBSC4ArFEJtG7Y5ILqwp4A/JHlxfyoC04yN/4vh/bEz9Dim9uY+/8O4EfI4nmFZEFyz1veSe5Iri0BXB13Icfekjxaxz6TPMixXXt2fJDM5WLZF+og63MPNi1IbsQGW7zyJYUToXZyEUxP8iLSPUS80hLvdYQTobbWN3fHKvMLGpKrBq/bzla4htC3C8mbutIg3JnkxrddzhCvil4omwbhDqy6IPEisV5xJFn4tsk1rDJI8wtZ+rapN+JV73PzqnuwSk7MtvkQzflabdUxGsMdIGFSnfuZZFPHPxysELjnXDOoFsTbzAJA6dumRiyxSt/2+Ma6Hlvf9lyRb9QumjAwIZKQqOLAznvEEbFUcvFS7VVXWO/WvHsTLYnVnSBEM8JgEqsDlmi7qQ++TWL1xxKtnOqgKvs5J7H6I6KdJxFNsh5FygafxLqOxVgHme6b8QIYkWqcZoW6Mr13vvMXhboi8u56x+a34eXKTWMhXSO3SQirgqZi5WSniSvS1ChyFztUoTCcetjMoNGnHbqjTQqF42P1z4pnd7IwssKUwo8Mq/uIz2eN1NWMg3vzxoUWvu3pihEa+zU/4l3RJhoRC/ZcAkKdxkfnXUC8ggE1L+tWILbartW45o1D5IIpL+tWq43du4C4BQNqXlY82jB67wJmIdhSTG/vl1FXkaP1LiB+wQCA+m5+Ya5/s7b7V5a/J7Eq0cZ/svza+FcrHEZd1ZiJh5kp/q0e1D3tqMMhMA/BgFodt1DrzJD4jyx/TmpVoo3vsqyHxTmFQ2BWHpY3ngP1Pa9h5f1AmItgQC1bXAE6JKpXVn94sSrRxocsl4AW7Iss/0xuTuIRKqfQ7dic2i9gdiHxWlu0V8yi/QLmJRhQc6jlG3T7lYboCRfVji3eoMda+mjeNhEAJ1ku31ANYQekhCNklDafTA87eTEl0YWTLHNTsNSGhYvSZvEGPWDkyY8t1xt2ua/jd0Uyah/jYinBcvt+2OTIBTgAOHi6GJ3wbKeOfkaOn09sRNM4VGcXF8N1P0wiwNmyMx+63x7HV48dnuHqpJ40ZMNbBovmUrAGsRSTjuB2PRefgokhZcPFGCSaK8FaxCqf3ecAW66Cea8juhbNhWCBiaXridRtSD61IZZRzkQbKlhIYok9ut5rCOY9Q3Ml2hDBQhNLbKoJdpBfVr4MMnEh2rOChSiW2KWeCHg3X4wO5h2woaI9I1ioYolt6gHf/RuMOpU/k+pkWVYC+GatXmCkTit1p9hOvL6JLb7JZXky+0LTjn/UgWc9rY+HhexZCuqXIzZmfAzyAdJnROsqWAxiAbUnp9bmmxJn34bdo69oXQSLRSwAt10veqwndqVFtKJh21bBWD2WHotYuo5orDzIymAyxSbuiEZbtDbBqN8hCF4soGbv3lwZbOJh00W0e4LFJhZQG81hY67UHbMIeCRak2AxigXU2q+V/QdF7sWynrSJ1nFdDGJd2y/axXnqikfhx7z+tIjWhdK3/Y+gbqpuu1yM9IU+Nt8EfUQU00ex4YU+84/m6Df55NYNgPdDXhOFb3u7wLZwaGwUXVhUdBSt8G1nV9hlvBTjpKPIFm0eiFb4tq8P7No3ZkA3NJ/hjmiFb7v6QN3Nuh8OjY3VCQffib6HJVrh256+GN5Vdtk4ZwS1xUeIaIVvO/rSy7uMf9rF7mWx0su7jH9SD31E7WWxwfoI5v0eO6QuOiYvmwgOGcGcLkZ6TnSG+kGb7m1Xw05UtnVMoXE8WJ8hYljZjL4mKXsh6HIE85SAjAvHmCqFabKcUeAYk+UYO1ePWqXpqBxBXWx3f0vLyhpL5wd4MYyoNd7bnKzX6IJ+wipkOOXUlJN8M2YMfUxNaSUh+SQHnQFWszLtfGxME2/3whJr+j4t09T2nbHE8jO1vRiSRHtAMGIZBi2M8HhO2aNGskGVYOy8i2VCXQ+bLvsJGNYfci1929OIZeQ+qG/UREjE2QcvlsIKA0cGMjrBFFjt1ZGx3EcUww/Gt2w7Z2+T890Z5/seZQJmhcjjHBMSVuW6o3GepW+bBsHqfo/pbYc5hMkGrzpG6VX3YPWWyTl24e4IVfi2axRYZVBm+h+NcKxGHdhZtm9n5VX3EOHKBo8rGVByIt5UUFdzKDbvXkIomzvCKfE2PsQzRDpYNh1lfT61TcEhwq3lItniHSX0FGMIKAKtxWveecueAbVRmW8DbESUNaopHpe4HbDrhGqU6Q9UMyao309qgyzLTsa+7E8O4LMsm/YPVPOo/QTwI8uyoMbzD04wE7ngS/l8AbBC8wUeghL/J4CPLMt+Od6/U4IWrAlpQ5aoPOSTLHNoIRfGzxfoMd9P0J74F5VIlyzLopok6H/tVqA8kSYfTwAAAABJRU5ErkJggg==",al="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYwAAACsCAYAAABo4pvIAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAzYSURBVHic7d3hcdtIEobhD05gmYGRgbkRLDKwMjiGoBCUgeoi0F0Evo1AdASiIxAcgbkR9P1Aj9mESIm2QMwAeJ8qlihKomeXwHzsHgCsBBTOzGpJK7+pd7/2r3+ceCw69Vh8nkvt/fbW4/H7vaR//H4bfqeNX6uqij8DilPlHgCWxcxW6ibvNFmn+x/DY/Fn0mHyPXVLE7F0ejKOf3/SpRO1B9c55wJNOg6rfrD1/5v7/31pbN97j7WS9lVVnf3vAoZGYGAwPqHW6ia+tbrJce0/Tj+Lk176+k/4/ui2tAnRA/VUaNbqQjXdr8PvtDoOku/xeyoXDIXAwMXMbK1DGHzUcTikiatVN1l9Uy8YmLiG1wuY2r9+0vHrUuvwOux0/PrseF1wKQIDR06EQvw+TTatunexrXgXOwmh+ku31AJc6xAoMUxaESboITAWyoOhVjdhfAr307vQnbpQ2KlrDe2yDBSj8EBJ20S/Qml12B7S/XZp7UIQGLMX3lk2Og6Gnbqd/1u4zySAI+EghRQmH9VtS7W6bWYrKpLFIDBmJFQNf6nbwdOCc6oYvqqrFrY5xof56AXJJ53e3r5J2hIi80FgTFRoIcRwaP32Vb7TUjFgTCdaW426thYhMgMExgT4u7m1Dm2lxn+UqoatCAcUyrffRodqpPEfbcWbm0khMAoUdrBUPTTyUFC3g7UsQmPKvBJpdNzOiq3TLQFSHgKjAKGM/6xDOb+T9Le6d17bXGMDxmJmjY73g1aHRfX/ESD5ERgZhBbTZx2OOCEggOCVAEn7CQEyMgJjJL2Nv9Hxhr/NNS5gKnr7UK0uQNiHMH1mtjKzGzN7MLNnvz34Rg/gHXz/aszs3vetH75/bbyCB8pmZrVvsI/WeTSzWz8/AsCV+L536/vcj7Dv1bnHBvxkZmt/l/MUqogb3uUAefSqjx++X95R3SOLEBK0moDCER4Y3YmQuKfVBEyLh8dd2I8JDwzD+6J3hAQwP2fCo849LkyI9z/TwnVqNxESwIyF8IgL5qxD4jTfYB786KYvZnaTe0wAxudzQTraivVJdE60nDaUpACkn92GuxAed1QdCxSqCY5wAvCm3pFWj8wZM2eHk+p+VhO5xwRgWrzqSCcIPrHWMTMeFGltgmoCwCB6ax33tLMnzM+biG2nOveYAMxPWAulXTU1vUNiuRAZgFGERfJngqNwrE8AKEVoVz0xHxWEoABQqhAczE85ERQApiIEB62qMREUAKaK4BiJH4nwRFAAmDqC40rCeRQEBYBZ8Y5JumZVnXs8k9U7RO0u93gA4Br6cx2nAvyisE5B6gJYBA+OB684uFr2W3rtpzr3eABgbL31jTr3eIoUTq2/yz0WAMjNugsbPpvZbe6xFMOrimfSFACO+fyYzhhvco8nq1BVkKAAcIZXGz/M7D73WEYXqgoWtQHgAr1qo849nlGEvtwm91gAYGoWsbbBEVAAMIxw5YvH2Z23EVpQy+u/AcAV+Hkb9z63rnOPZxBhsWa+5RMAZDKbFlVIvzr3WABgrsbq4ny4xpOm/pqklaQ/q6pqr/HvAAAkn2P/lLSa1FFUIenuco8FAJYmXMiwzj2WVxEWAJBfCI0yF8PN7MYXtze5xwIASxeu+t3kHsuRMLAy0wwAFsjM1kW9kQ9hUeceCwDgWFgq2OQeSPp4wTrrQAAAZ3lo5Ks0QljQhgKAwmVrT1n3iVCEBQBMSAiNcebuUNrwmbMAMDF+ROv11539Ylf5F08AAL8tXH+qvuY/8sgVZwFg+vzkvqdrPfm9mT1e5ckBAKPz604NWwSM1vMCAIxm8HM0wiI3R0QBwMz4kVPDFAS+bjHtD+YAAJzli+DvW3IY5EkAAMV715XGaUUBwHKEOb/+nT/+wudaAMBy+KG2D7/6R42XJ6srjQsAUCCf+y+/kocvdDfXGxIAoETpIysu/eWGhW4AWK6Lz83w6oILCwLAQl1UZaS1i5HGBAAo1JtrGV5dbMYbEgCgRF5lnF6e8EuX/xh5TACAQvUvGfIh/OxW0n/GHhAAoFhbSS/bUp4kzdijAQCU6eS6dvqM7kxjAgAUKhYTqSW1Fu0oAMBLW3UZ0eHMbgDAKUcnc6ejo7huFACgzzPCpK4lVUvaV1W1zzoqAEBxPBt2ZtZ8UNeb2uYdEgCgYK2k9QdJnyR9yzsWAEDBvkr6mFpSbdahAABKtpNXGGtJrF8AAF6zSudhtDlHAQAo2l4hMAAAOGcvaaV0fC0AAOeYmVFhAAAu8kHSPl7vHACAyDOi/aDUmwIA4BUEBgDgLbV0CAwAAM5ZSdp9kJ/Bl3kwAIBy1fI1jO+S/so7FgBAwT5J+pYqjDrvWAAABWvUZUV3QgYfoAQA6IsfspdO3NuKdQwAwEtrSbuqqvYpMP6W9K+MAwIAlOmzuozo+Id8P+cbDwCgRN6OavoPPr94EACwWP1iIl588N+iLQUAOPgs6b8vHjWzmrYUACBJR0el739WGFVVtZJaM9tkGBcAoCCeBbuqqk5fPsrMbqgyAAAXrWv7L21GGREAoDhePDxe8osbqgwAWC4ze7z4qFmqDABYJj+U9u3qIvwBaxkAsDB+3ahfPyfPzB7M7O4qowIAFMfM7szsy+/8Ye3H4NbDDwsAUBIzW79rzve0oTUFADPnC923+Z8EAFAsM7v9pYXuV56o9kUQPi8DAGbm3a2oE0+48dAY5gkBANmFguBm6Ce+N7OnQZ8UAJCNLzncX+vJnzjUFgCmz4uA969bvPIPpPKFRXAAmKiwzLB6+7ff9w9dp+cFALg6v5LHeOfYhVV1jpwCgIkIc3cz9j+8ITQAYBpCWGxyDWAzamkDAPhl4VJPm9wD4RwNAChUWHfe5B6LJNpTAFAib0OVExaJf+hGeQMDgAUKb+TLPKI1pNld7rEAwFKlK40Xv1QQ+mV3uccCAEszmbBIPDSe/FP7rnsmIQAgfbzqg8+9de7x/DK/Vsl0kg4AJih0dq5zIcGx+AdzcP0pALgCn2N/zGaODYvh97SoAGAYs+3ieH/tcbL9NQAoRGhBPcx6PqVFBQC/L1xdYxlzaDiK6nHW6QgAA/F582GWLahLeP9tPos1AHAFYWH7LvdYsvJLilBtAECPVxWPi60qzmFtAwAO/IxtqopzQpo+2tifCAUABVjMEVBDscNnznJpEQCL0FvU3uQez6T4eRvpIlp3BAeAuWKuG0hI3fwfLwgAAwrnVNB+GpIfTcX6BoDJC0HBlS+uieAAMFUhKFinGBPBAWAqCIpChBeC4ABQFIKiUP7CPBEcAHIjKCYitKo4RA3AaPxUgNjx2OQeEy4UguOHB0ede0wA5qd3wt2Dma1zjwm/yV/MdFVc2lUABuFvSh+sw3kUc+Ll4m1Y57ilXQXgV/XXJwiKmeu1q+6pOgC8JlQTqe3U5B4TRmaH61WldhWL5AAk/Wxnx2qCtVB0wjsI1jqABbPuatlfwtpEk3tMKFRY64hHWDW5xwXgesxsHVpOj15Z0G3A5bwkTZcdfiY8gPnwkLin5YTBecuK8AAm7ERI3HPeBK6qFx4caQUUrHeEEyGBfM6FB/1PIA9fh7wJIfFESKA4vuYRF8wf/fs699iAOfNWU9r3LCxc17nHBrzJDhciS4fqplKY6gMYwIlW04NXFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class rr extends ve.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new gt,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=vs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${sr}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const n=document.createElement("div");if(n.style.position="absolute",n.style.left="0",n.style.transform="translateX(-50%)",a.style.bottom=n.style.top="8px",n.style.width=n.style.height=a.style.width,n.style.background=`url(${sr}) center no-repeat`,n.style.backgroundSize="100% auto",n.style.transition="all .2s",n.setAttribute("data-direction","down"),Array.from([a,n]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${al}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${ol}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${nl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=f/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new fi(l.rotation).to({z:v}).duration(u).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,n),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof ve.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof ve.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class ll extends bn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new gt,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.bottom="0",t.append(n),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",n.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",n.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",n.style[this._sizeFlag]=a*100+"px",n.style.textAlign="center",this._sizeFlag==="height"?(n.style.borderLeft="0.1px dashed #fff",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):n.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class cl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new li("长:"),this._line12=new li("宽:"),this._line13=new li("高:"),this._outline=new Gr(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof ve.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof ve.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:a,hasHeight:n,hasWidth:c}=Qa(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=n,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class We extends d.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var e,t;this.clear(),(e=this.lineSegments)==null||e.geometry.dispose(),this._lineMaterial.dispose(),(t=this.lineSegments)==null||t.removeFromParent()}clearAll(){this.dispose()}clone(e){const t=new We(this._currentLength,this._currentWidth,this._currentHeight);return t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale),t.visible=this.visible,t.castShadow=this.castShadow,t.receiveShadow=this.receiveShadow,e&&this.children.forEach(i=>{if(i!==this.lineSegments){const s=i.clone(!0);t.add(s)}}),t}_generate(e,t,i){_e(this),this.clear(),this.geometry.dispose(),this.geometry=new d.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new d.EdgesGeometry(this.geometry);this.lineSegments=new d.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Ji{constructor(e){this._props=e,this.name="",this.transparentTexture=_s.load(ul),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;let n=window.devicePixelRatio*2;this._offscreen.width=a.width+n,this._offscreen.height=a.height+n;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,n/2,n/2,a.width,a.height),s=new d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function nr(o){return o.type?o.type==="Mesh":o.isMesh}const _s=new d.TextureLoader;_s.crossOrigin="anonymous";class qr extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new gt,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new cl,this._goodsSize=new Za(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new d.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new d.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta()},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Xi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i+.14-.54;this.setShapeKey("boxLength",s);const a=i+.14;if(this.setShapeKey("topWidth",a),this.isTopInvert){const n=i-.257;this.setShapeKey("length",n)}else this.setShapeKey("width",a);this._generateRollers()}if(t==="goodsWidth"){const s=i+.193;this.setShapeKey("boxWidth",s);const a=i+.219;if(this.setShapeKey("topLength",a),this.isTopInvert){const n=i+.62;this.setShapeKey("width",n)}else this.setShapeKey("length",a)}})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const u=await Ne.loadAsync(e);i=u.animations||[],s=u.scene}else if(t==="sglb"||e.endsWith(".sglb")){const f=await new Bt({useCache:!0}).loadAsync(e);i=f.animations||[],s=f.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const a=this._findFirstSkinnedMesh(s),n=this._findFirstSkinnedMesh(this._modelRoot);(!a||!n)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new d.AnimationMixer(this._modelRoot));const c=typeof bi.retargetClip=="function";i.forEach(u=>{let f=u;if(c&&a&&n)try{f=bi.retargetClip(n,a,u)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",u.name,r)}this._clips=this._clips.filter(r=>r.name!==f.name),this._clips.push(f);const p=this._mixer.clipAction(f);this._actionsMap.set(f.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let n=await Ne.loadAsync(e);i=n.scene,s=n.animations||[]}else{const c=await new Bt({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=bi.clone(i);this._generateAmr(a,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new d.Vector2(t.scaleX,t.scaleY),new d.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(a=>{var u;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(u=a.morphTargetDictionary)==null?void 0:u[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new d.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(i=>{if(i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),i.userData.isRollerLevel&&this._rollerLevel.set(i.userData.level||0,i),i.userData.isCenterModel&&(i.visible=this.useCenterModel),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&(this._liftBrackets.push(i),i.visible=this._useLift),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!this._useLift),i.userData.isRoller&&(this._roller=i,this._roller.visible=!1,this._generateRollers()),i.userData.isRollerLevelBox){this._rollerGoodsBox=i;const s=new We(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);this.goods.push(s)}Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a);const n=this._shapeKeyTargets.get(s);n?n.push(i):this._shapeKeyTargets.set(s,[i])})}),e.traverse(i=>{if(i instanceof d.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(n=>n.name===a.userData.name)||this.skins.push(new ls({name:a.userData.name,target:a})))});else{if(i.material.userData.isVideo&&i.material.userData.video){const a=i.material.userData.video;let n=this._videoCache.get(a);n||(n=document.createElement("video"),n.src=a,n.crossOrigin="anonymous",n.loop=!0,n.muted=!0,n.playsInline=!0,n.autoplay=!0,n.preload="auto",this._videoCache.set(a,n)),n.play().catch(()=>{}),i.material.map&&i.material.map.dispose(),i.material.emissiveMap&&i.material.emissiveMap.dispose();const c=new d.VideoTexture(n);c.colorSpace=d.SRGBColorSpace,i.material.map=c,i.material.emissiveMap=c,i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=1,i.material.needsUpdate=!0}if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Fe.Tween(i.material).to({emissiveIntensity:.2}).easing(Fe.Easing.Quintic.InOut).duration(a),c=new Fe.Tween(i.material).to({emissiveIntensity:2}).easing(Fe.Easing.Quintic.InOut).duration(a);n.onComplete(()=>c.start()),c.onComplete(()=>n.start()),n.start(),this._breathLights.push(n,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new ls({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(n=>{if(n.userData.isLOGO){i.material.transparent=!0;let c;const u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Ki(i.material.map.image)),i.material.needsUpdate=!0;const f=new Ji({name:n.userData.name,target:i,size:$s(i),imageSize:u,imageUrl:c});this._logos.push(f)}n.userData.isTransparent&&(n.transparent=!0),this._materialsCache.set(n.uuid,{opacity:n.opacity,transparent:n.transparent,roughness:n.roughness,metalness:n.metalness,color:n.color,mat:n})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let n;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,n=Ki(i.material.map.image));const u=new Ji({name:a.userData.name,target:i,size:$s(i),imageSize:c,imageUrl:n});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(n=>{if(n.startsWith("follow_")){const c=n.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[n])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof We&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this.goodsSize.length))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}setColumns(e){this._columnCount=e,this._rollerLevel.forEach(t=>{const i=t.children.find(f=>f.userData.isRollerLevelBox&&!f.userData.cloned);if(!i)return;console.log(i);const s=new d.Box3().setFromObject(i),a=new d.Vector3;s.getSize(a);const n=.03,c=a.x;console.log(a);const u=c*e+n*(e-1)-c;for(let f=1;f<e;f++){const p=i.clone(!0);p.userData.cloned=!0,p.position.x+=(n+c)/2,t.add(p)}i.position.x-=u/2})}get levels(){return this._levelCount}setLevels(e){var a;if(!e)return;this._levelCount=e;const t=this._rollerLevel.size;let i=e-t;const s=this._rollerLevel.get(0);if(i>0&&s)for(let n=t;n<e;n++){const c=s.clone(!0);c.visible=!0,c.position.z+=.2,this._rollerLevel.set(n,c),(a=s.parent)==null||a.add(c),this.regenerateShapeKeyNode(c),c.traverse(u=>{u instanceof We&&this.goods.push(u)}),this.setGoodsSize({length:this.goodsSize.length,width:this.goodsSize.width,height:this.goodsSize.height})}else for(let n=0;n<t;n++){const c=this._rollerLevel.get(n);c&&(c.visible=n<e)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{nr(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);t.userData.cloned=!0,s&&s.push(t)})})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=[];this._rollerLevel.forEach(p=>{p.traverse(r=>{r.userData.isCloned&&e.push(r)})}),e.forEach(p=>{_e(p),p.removeFromParent()}),e=[];let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s,c=i+s;let u=Math.floor(n/c);const f=n%c;if(u>0){u>1&&(s+=f/(u+2));const p=i+s,r=-t/2+s+i/2;for(let l=0;l<u;l++)this._rollerLevel.forEach(h=>{let g;h.traverse(m=>{m.userData.isRollerLevelBox&&(g=m)});const _=this._roller.clone(!0);_.visible=!0,_.userData.isCloned=!0,_.position.y=r+p*l,g==null||g.add(_),this.regenerateShapeKeyNode(_)})}}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-9)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{_e(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{nr(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const n=this._shelf.clone(!0);n.position.z+=t*a,this._shelves.set(a,n),(s=this._shelf.parent)==null||s.add(n);let c;if(n.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)+this._goodsSize.length/2)),c){const u=new We(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new We(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Gr(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(u=>{u.name===i&&(n=u)}),!n)return;const c=new rr({name:"",target:i,default:0,min:s,max:a},n);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(u=>{u.name===i&&(n=u)}),!n)return;const c=new rr({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},n);e.add(c),this.controllers.push(c),(n.userData.isFork||n.userData.isLift||n.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=qa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new d.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new d.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new d.Vector3(0,0,e.userData.start-e.position.z),c=n.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new ll({start:n,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,n=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Xi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(Y.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(Y.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(Y.ON_ERROR_STATE_CHANGE,h=>{var _;if(!this._app)return;const g=(_=this._app)==null?void 0:_._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),h){if(l.device){if(g.selectedObjects.find(v=>{var y;return v.parent===((y=l.device)==null?void 0:y.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var v;return m.parent!==((v=l.device)==null?void 0:v.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),_e(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const a=this._currentAction,n=a===s,c=n?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,u=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const f=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(f?d.LoopRepeat:d.LoopOnce,f?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!f,s.play();const p=(t==null?void 0:t.timeScale)??1;return u?(a.stopFading(),a.enabled=!0,a.setEffectiveWeight(1),a.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(r=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=h=>{var g;h.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,r())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}}const jr=0,hl=1,fl=2,or=2,Pi=1.25,ar=1,Et=6*4+4+4,_i=65535,dl=Math.pow(2,-24),Fi=Symbol("SKIP_GENERATION");function pl(o){return o.index?o.index.count:o.attributes.position.count}function vt(o){return pl(o)/3}function ml(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function gl(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=ml(t,i);o.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Qr(o){const e=vt(o),t=o.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),n=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(n)}]}function Yr(o){if(!o.groups||!o.groups.length)return Qr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of o.groups){const u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const n=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<n.length-1;c++){const u=n[c],f=n[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function vl(o){if(o.groups.length===0)return!1;const e=vt(o),t=Yr(o).sort((a,n)=>a.offset-n.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Ei(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=o[v+0],w=o[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],C=o[v+3],M=S-C,I=S+C;M<n&&(n=M),I>f&&(f=I),S<l&&(l=S),S>_&&(_=S);const D=o[v+4],T=o[v+5],R=D-T,L=D+T;R<c&&(c=R),L>p&&(p=L),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=n,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function _l(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=vt(o),c=s.normalized;let u;e===null?(u=new Float32Array(n*6*4),t=0,i=n):(u=e,t=t||0,i=i||n);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let S=w;b<S&&(S=b),A<S&&(S=A);let C=w;b>C&&(C=b),A>C&&(C=A);const M=(C-S)/2,I=x*2;u[_+I+0]=S+M,u[_+I+1]=M+(Math.abs(S)+M)*dl}}return u}function q(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function lr(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function cr(o,e){e.set(o)}function ur(o,e,t){let i,s;for(let a=0;a<3;a++){const n=a+3;i=o[a],s=e[a],t[a]=i<s?i:s,i=o[n],s=e[n],t[n]=i>s?i:s}}function Qt(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],a=e[o+2*i+1],n=s-a,c=s+a;n<t[i]&&(t[i]=n),c>t[i+3]&&(t[i+3]=c)}}function Tt(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}const xe=32,yl=(o,e)=>o.candidate-e.candidate,Re=new Array(xe).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Yt=new Float32Array(6);function xl(o,e,t,i,s,a){let n=-1,c=0;if(a===jr)n=lr(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===hl)n=lr(o),n!==-1&&(c=wl(t,i,s,n));else if(a===fl){const u=Tt(o);let f=Pi*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/xe;if(s<xe/4){const v=[...Re];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:S,rightCacheBounds:C}=b;for(let M=0;M<3;M++)C[M]=1/0,C[M+3]=-1/0,S[M]=1/0,S[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;Qt(w,t,A)}v.sort(yl);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let A=0;A<x;A++){const S=v[A];b>=S.candidate?Qt(w,t,S.rightCacheBounds):(Qt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,S=s-b.count,C=b.leftCacheBounds,M=b.rightCacheBounds;let I=0;A!==0&&(I=Tt(C)/u);let D=0;S!==0&&(D=Tt(M)/u);const T=ar+Pi*(I*A+D*S);T<f&&(n=l,f=T,c=b.candidate)}}else{for(let x=0;x<xe;x++){const w=Re[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=xe&&(A=xe-1);const S=Re[A];S.count++,Qt(x,t,S.bounds)}const v=Re[xe-1];cr(v.bounds,v.rightCacheBounds);for(let x=xe-2;x>=0;x--){const w=Re[x],b=Re[x+1];ur(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<xe-1;x++){const w=Re[x],b=w.count,A=w.bounds,C=Re[x+1].rightCacheBounds;b!==0&&(y===0?cr(A,Yt):ur(A,Yt,Yt)),y+=b;let M=0,I=0;y!==0&&(M=Tt(Yt)/u);const D=s-y;D!==0&&(I=Tt(C)/u);const T=ar+Pi*(M*y+I*D);T<f&&(n=l,f=T,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function wl(o,e,t,i){let s=0;for(let a=e,n=e+t;a<n;a++)s+=o[a*6+i*2];return s/t}class ki{constructor(){this.boundingData=new Float32Array(6)}}function bl(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)c--;if(n<c){for(let p=0;p<3;p++){let r=e[n*3+p];e[n*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[n*6+p];t[n*6+p]=t[c*6+p],t[c*6+p]=r}n++,c--}else return n}}function Al(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)c--;if(n<c){let p=o[n];o[n]=o[c],o[c]=p;for(let r=0;r<6;r++){let l=t[n*6+r];t[n*6+r]=t[c*6+r],t[c*6+r]=l}n++,c--}else return n}}function ee(o,e){return e[o+15]===65535}function re(o,e){return e[o+6]}function oe(o,e){return e[o+14]}function ae(o){return o+8}function le(o,e){return e[o+6]}function Zr(o,e){return e[o+7]}let Kr,Lt,ci,Xr;const Tl=Math.pow(2,32);function $i(o){return"count"in o?1:1+$i(o.left)+$i(o.right)}function Sl(o,e,t){return Kr=new Float32Array(t),Lt=new Uint32Array(t),ci=new Uint16Array(t),Xr=new Uint8Array(t),es(o,e)}function es(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)Kr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Xr.set(new Uint8Array(n),o);for(let c=o,u=o+n.byteLength;c<u;c+=Et){const f=c/2;ee(f,ci)||(Lt[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return Lt[t+6]=n,ci[i+14]=c,ci[i+15]=_i,o+Et}else{const n=e.left,c=e.right,u=e.splitAxis;let f;if(f=es(o+Et,n),f/4>Tl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Lt[t+6]=f/4,f=es(f,c),Lt[t+7]=u,f}}function Ml(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),n=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=n.length;c<u;c++)n[c]=c;return n}function Cl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,h=l.index?l.index.array:null,g=p?Al:bl,_=vt(l),m=new Float32Array(6);let v=!1;const y=new ki;return Ei(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,S,C=null,M=0){if(!v&&M>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||M>=a)return x(A+S),b.offset=A,b.count=S,b;const I=xl(b.boundingData,C,e,A,S,u);if(I.axis===-1)return x(A+S),b.offset=A,b.count=S,b;const D=g(r,h,e,A,S,I);if(D===A||D===A+S)x(A+S),b.offset=A,b.count=S;else{b.splitAxis=I.axis;const T=new ki,R=A,L=D-A;b.left=T,Ei(e,R,L,T.boundingData,m),w(T,R,L,m,M+1);const F=new ki,E=D,z=S-L;b.right=F,Ei(e,E,z,F.boundingData,m),w(F,E,z,m,M+1)}return b}}function Rl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=Ml(t,e.useSharedArrayBuffer),vl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),o._indirectBuffer||gl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=_l(t),a=e.indirect?Qr(t):Yr(t);o._roots=a.map(n=>{const c=Cl(o,s,n.offset,n.count,e),u=$i(c),f=new i(Et*u);return Sl(0,c,f),f})}class Te{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,n=e.length;a<n;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,n=t.length;a<n;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Te.prototype.setFromBox=function(){const o=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){o.x=s.x*u+a.x*(1-u),o.y=s.y*f+a.y*(1-f),o.z=s.z*p+a.z*(1-p);const r=t.dot(o);n=Math.min(r,n),c=Math.max(r,c)}this.min=n,this.max=c}}();const Il=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,n){const c=s.start,u=o,f=a.start,p=e;t.subVectors(c,f),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,n.x=v,n.y=y}}(),ys=function(){const o=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,n,c){Il(s,a,o);let u=o.x,f=o.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,n),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(f>=0&&f<=1){u<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(h);return}}}}(),Dl=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,n){const{radius:c,center:u}=a,{a:f,b:p,c:r}=n;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c))return!0;const _=n.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(n.containsPoint(v))return!0}return!1}}(),Ll=1e-15;function Bi(o){return Math.abs(o)<Ll}class pe extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new Te),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Dl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,n=this.satBounds,c=a[0],u=n[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=n[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=n[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}pe.prototype.closestPointToSegment=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,n=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),ys(t,s,o,e),p=o.distanceToSquared(e),p<r&&(r=p,a&&a.copy(o),n&&n.copy(e))}return this.closestPointToPoint(c,o),p=c.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(c)),this.closestPointToPoint(u,o),p=u.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(u)),Math.sqrt(r)}}();pe.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Array(3),i=new Te,s=new Te,a=new d.Vector3,n=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:S}=p;A.copy(y[b]),S.copy(y[(b+1)%3]),p.delta(n);const C=Bi(m.distanceToPoint(A));if(Bi(m.normal.dot(n))&&C){v.copy(p),x=2;break}const M=m.intersectLine(p,h);if(!M&&C&&h.copy(A),(M||C)&&!Bi(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),C&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(o.copy(m),o.update(),m=o);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let M=0;M<4;M++){const I=b[M],D=A[M];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const S=m.satBounds,C=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let M=0;M<4;M++){const I=S[M],D=C[M];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let M=0;M<4;M++){const I=A[M];for(let D=0;D<4;D++){const T=C[D];if(a.crossVectors(I,T),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let R=l.start;l.start=l.end,l.end=R}const S=r.start.dot(c),C=r.end.dot(c),M=l.start.dot(c),I=l.end.dot(c),D=C<M,T=S<I;return S!==I&&M!==C&&D===T?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();pe.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();pe.prototype.distanceToTriangle=function(){const o=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(n,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(n,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=n[h];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),u&&u.copy(g));const _=this[h];n.closestPointToPoint(_,o),l=_.distanceToSquared(o),l<p&&(p=l,c&&c.copy(_),u&&u.copy(o))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(n[_],n[m]),ys(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),u&&u.copy(e))}}return Math.sqrt(p)}}();class X{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new Te),this.alignedSatBounds=new Array(3).fill().map(()=>new Te),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}X.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=n[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();X.prototype.intersectsBox=function(){const o=new Te;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,n=this.satAxes,c=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,c[0].isSeparated(o)||(o.min=i.y,o.max=s.y,c[1].isSeparated(o))||(o.min=i.z,o.max=s.z,c[2].isSeparated(o)))return!1;for(let u=0;u<3;u++){const f=n[u],p=a[u];if(o.setFromBox(f,t),p.isSeparated(o))return!1}return!0}}();X.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Te,i=new Te,s=new d.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(o.copy(n),o.update(),n=o);const c=this.satBounds,u=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();X.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();X.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();X.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(n,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(u||f)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=n.min,l=n.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,S=h[b],C=h[A];e[_].set(S,C);const I=o[m],D=o[x],T=o[w],R=t[_],L=R.start,F=R.end;L[I]=r[I],L[D]=v?r[D]:l[D],L[T]=y?r[T]:l[D],F[I]=l[I],F[D]=v?r[D]:l[D],F[T]=y?r[T]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];ys(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class xs{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Pl extends xs{constructor(){super(()=>new pe)}}const ce=new Pl;class Fl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const H=new Fl;let Ee,ct;const Ze=[],Zt=new xs(()=>new d.Box3);function El(o,e,t,i,s,a){Ee=Zt.getPrimitive(),ct=Zt.getPrimitive(),Ze.push(Ee,ct),H.setBuffer(o._roots[e]);const n=ts(0,o.geometry,t,i,s,a);H.clearBuffer(),Zt.releasePrimitive(Ee),Zt.releasePrimitive(ct),Ze.pop(),Ze.pop();const c=Ze.length;return c>0&&(ct=Ze[c-1],Ee=Ze[c-2]),n}function ts(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:u,uint32Array:f}=H;let p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);return q(o,c,Ee),i(l,h,!1,n,a+o,Ee)}else{let I=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=ae(T),F=T*2;return re(T,L)},D=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=le(T,L),F=T*2;return re(T,L)+oe(F,R)};const l=ae(o),h=le(o,f);let g=l,_=h,m,v,y,x;if(s&&(y=Ee,x=ct,q(g,c,y),q(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const T=m;m=v,v=T,y=x}y||(y=Ee,q(g,c,y));const w=ee(g*2,u),b=t(y,w,m,n+1,a+g);let A;if(b===or){const T=I(g),L=D(g)-T;A=i(T,L,!0,n+1,a+g,y)}else A=b&&ts(g,e,t,i,s,a,n+1);if(A)return!0;x=ct,q(_,c,x);const S=ee(_*2,u),C=t(x,S,v,n+1,a+_);let M;if(C===or){const T=I(_),L=D(_)-T;M=i(T,L,!0,n+1,a+_,x)}else M=C&&ts(_,e,t,i,s,a,n+1);return!!M}}const St=new d.Vector3,Oi=new d.Vector3;function kl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,u=null;if(o.shapecast({boundsTraverseOrder:p=>(St.copy(e).clamp(p.min,p.max),St.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,St);const l=e.distanceToSquared(St);return l<c&&(Oi.copy(St),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Oi):t.point=Oi.clone(),t.distance=f,t.faceIndex=u,t}const Ke=new d.Vector3,Xe=new d.Vector3,Je=new d.Vector3,Kt=new d.Vector2,Xt=new d.Vector2,Jt=new d.Vector2,hr=new d.Vector3,fr=new d.Vector3,dr=new d.Vector3,$t=new d.Vector3;function Bl(o,e,t,i,s,a,n,c){let u;if(a===d.BackSide?u=o.intersectTriangle(i,t,e,!0,s):u=o.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=o.origin.distanceTo(s);return f<n||f>c?null:{distance:f,point:s.clone()}}function Ol(o,e,t,i,s,a,n,c,u,f,p){Ke.fromBufferAttribute(e,a),Xe.fromBufferAttribute(e,n),Je.fromBufferAttribute(e,c);const r=Bl(o,Ke,Xe,Je,$t,u,f,p);if(r){i&&(Kt.fromBufferAttribute(i,a),Xt.fromBufferAttribute(i,n),Jt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation($t,Ke,Xe,Je,Kt,Xt,Jt,new d.Vector2)),s&&(Kt.fromBufferAttribute(s,a),Xt.fromBufferAttribute(s,n),Jt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation($t,Ke,Xe,Je,Kt,Xt,Jt,new d.Vector2)),t&&(hr.fromBufferAttribute(t,a),fr.fromBufferAttribute(t,n),dr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation($t,Ke,Xe,Je,hr,fr,dr,new d.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ke,Xe,Je,l.normal),r.face=l,r.faceIndex=a}return r}function yi(o,e,t,i,s,a,n){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=o.index;o.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=o.attributes,m=Ol(t,l,h,g,_,u,f,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Q(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),n.x=i.getX(f),n.y=i.getY(f),n.z=i.getZ(f)}function zl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++)yi(u,e,t,p,a,n,c)}function Vl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=yi(c,e,t,r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Wl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===_i){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=3*v,I=3*(v+y);M<I;M++){let D=i[M];const T=s.getX(D),R=s.getY(D),L=s.getZ(D);T<x&&(x=T),T>A&&(A=T),R<w&&(w=R),R>S&&(S=R),L<b&&(b=L),L>C&&(C=L)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function ke(o,e,t,i,s){let a,n,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[o],y=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],A=e[o+3+2];return r>=0?(a=(v-g)*r,n=(y-g)*r):(a=(y-g)*r,n=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>n||((c>a||isNaN(a))&&(a=c),(u<n||isNaN(n))&&(n=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>n)?!1:((f>a||a!==a)&&(a=f),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function Hl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;yi(u,e,t,l,a,n,c)}}function Nl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=yi(c,e,t,u?u[r]:r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Gl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function ql(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),is(0,o,t,i,s,a,n),H.clearBuffer()}function is(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);zl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&is(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&is(h,e,t,i,s,a,n)}}const jl=["x","y","z"];function Ql(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=ss(0,o,t,i,s,a);return H.clearBuffer(),n}function ss(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=jl[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?ss(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?ss(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ei=new d.Box3,$e=new pe,et=new pe,Mt=new d.Matrix4,pr=new X,ti=new X;function Yl(o,e,t,i){H.setBuffer(o._roots[e]);const s=rs(0,o,t,i);return H.clearBuffer(),s}function rs(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),pr.set(t.boundingBox.min,t.boundingBox.max,i),s=pr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(Mt.copy(i).invert(),t.boundsTree)return q(o,a,ti),ti.matrix.copy(Mt),ti.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ti.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(Q(et,x,r,l),et.needsUpdate=!0,y.intersectsTriangle(et))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){Q($e,v,r,l),$e.a.applyMatrix4(Mt),$e.b.applyMatrix4(Mt),$e.c.applyMatrix4(Mt),$e.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(Q(et,x,h,g),et.needsUpdate=!0,$e.intersectsTriangle(et))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,ei),!!(s.intersectsBox(ei)&&rs(p,e,t,i,s)||(q(r,a,ei),s.intersectsBox(ei)&&rs(r,e,t,i,s)))}}const ii=new d.Matrix4,zi=new X,Ct=new X,Zl=new d.Vector3,Kl=new d.Vector3,Xl=new d.Vector3,Jl=new d.Vector3;function $l(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),zi.set(e.boundingBox.min,e.boundingBox.max,t),zi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=Zl,_=Kl,m=null,v=null;s&&(m=Xl,v=Jl);let y=1/0,x=null,w=null;return ii.copy(t).invert(),Ct.matrix.copy(ii),o.shapecast({boundsTraverseOrder:b=>zi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Ct.min.copy(b.min),Ct.max.copy(b.max),Ct.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:C=>Ct.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){Q(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let T=b,R=b+A;T<R;T++){Q(l,3*T,f,u),l.needsUpdate=!0;const L=l.distanceToTriangle(h,g,m);if(L<y&&(_.copy(g),v&&v.copy(m),y=L,x=T,w=I),L<a)return!0}}}});{const S=vt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){Q(l,3*I,f,u),l.needsUpdate=!0;const T=l.distanceToTriangle(h,g,m);if(T<y&&(_.copy(g),v&&v.copy(m),y=T,x=I,w=C),T<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ii),_.applyMatrix4(ii),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function ec(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===_i){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=v,I=v+y;M<I;M++){const D=3*o.resolveTriangleIndex(M);for(let T=0;T<3;T++){let R=D+T;R=i?i[R]:R;const L=s.getX(R),F=s.getY(R),E=s.getZ(R);L<x&&(x=L),L>A&&(A=L),F<w&&(w=F),F>S&&(S=F),E<b&&(b=E),E>C&&(C=E)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function tc(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),ns(0,o,t,i,s,a,n),H.clearBuffer()}function ns(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);Hl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&ns(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&ns(h,e,t,i,s,a,n)}}const ic=["x","y","z"];function sc(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=os(0,o,t,i,s,a);return H.clearBuffer(),n}function os(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Nl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=ic[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?os(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?os(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const si=new d.Box3,it=new pe,st=new pe,Rt=new d.Matrix4,mr=new X,ri=new X;function rc(o,e,t,i){H.setBuffer(o._roots[e]);const s=as(0,o,t,i);return H.clearBuffer(),s}function as(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),mr.set(t.boundingBox.min,t.boundingBox.max,i),s=mr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(Rt.copy(i).invert(),t.boundsTree)return q(o,a,ri),ri.matrix.copy(Rt),ri.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ri.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(Q(st,3*e.resolveTriangleIndex(x),r,l),st.needsUpdate=!0,y.intersectsTriangle(st))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);Q(it,3*x,r,l),it.a.applyMatrix4(Rt),it.b.applyMatrix4(Rt),it.c.applyMatrix4(Rt),it.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(Q(st,w,h,g),st.needsUpdate=!0,it.intersectsTriangle(st))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,si),!!(s.intersectsBox(si)&&as(p,e,t,i,s)||(q(r,a,si),s.intersectsBox(si)&&as(r,e,t,i,s)))}}const ni=new d.Matrix4,Vi=new X,It=new X,nc=new d.Vector3,oc=new d.Vector3,ac=new d.Vector3,lc=new d.Vector3;function cc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Vi.set(e.boundingBox.min,e.boundingBox.max,t),Vi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=nc,_=oc,m=null,v=null;s&&(m=ac,v=lc);let y=1/0,x=null,w=null;return ni.copy(t).invert(),It.matrix.copy(ni),o.shapecast({boundsTraverseOrder:b=>Vi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(It.min.copy(b.min),It.max.copy(b.max),It.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:C=>It.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){const T=S.resolveTriangleIndex(I);Q(h,3*T,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,L=b+A;R<L;R++){const F=o.resolveTriangleIndex(R);Q(l,3*F,f,u),l.needsUpdate=!0;const E=l.distanceToTriangle(h,g,m);if(E<y&&(_.copy(g),v&&v.copy(m),y=E,x=R,w=I),E<a)return!0}}}})}else{const S=vt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){const T=o.resolveTriangleIndex(I);Q(l,3*T,f,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=I,w=C),R<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ni),_.applyMatrix4(ni),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function uc(){return typeof SharedArrayBuffer<"u"}const kt=new H.constructor,di=new H.constructor,De=new xs(()=>new d.Box3),rt=new d.Box3,nt=new d.Box3,Ui=new d.Box3,Wi=new d.Box3;let Hi=!1;function hc(o,e,t,i){if(Hi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Hi=!0;const s=o._roots,a=e._roots;let n,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){kt.setBuffer(s[p]),u=0;const l=De.getPrimitive();q(0,kt.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(di.setBuffer(a[p]),n=fe(0,0,t,f,i,c,u,0,0,l),di.clearBuffer(),u+=a[h].length,!n);h++);if(De.releasePrimitive(l),kt.clearBuffer(),c+=s[p].length,n)break}return Hi=!1,n}function fe(o,e,t,i,s,a=0,n=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=di,l=kt):(r=kt,l=di);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=o*2,w=e*2,b=ee(x,_),A=ee(w,y);let S=!1;if(A&&b)p?S=s(re(e,v),oe(e*2,y),re(o,g),oe(o*2,_),u,n+e,c,a+o):S=s(re(o,g),oe(o*2,_),re(e,v),oe(e*2,y),c,a+o,u,n+e);else if(A){const C=De.getPrimitive();q(e,m,C),C.applyMatrix4(t);const M=ae(o),I=le(o,g);q(M,h,rt),q(I,h,nt);const D=C.intersectsBox(rt),T=C.intersectsBox(nt);S=D&&fe(e,M,i,t,s,n,a,u,c+1,C,!p)||T&&fe(e,I,i,t,s,n,a,u,c+1,C,!p),De.releasePrimitive(C)}else{const C=ae(e),M=le(e,v);q(C,m,Ui),q(M,m,Wi);const I=f.intersectsBox(Ui),D=f.intersectsBox(Wi);if(I&&D)S=fe(o,C,t,i,s,a,n,c,u+1,f,p)||fe(o,M,t,i,s,a,n,c,u+1,f,p);else if(I)if(b)S=fe(o,C,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Ui).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,rt),q(L,h,nt);const F=T.intersectsBox(rt),E=T.intersectsBox(nt);S=F&&fe(C,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(C,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}else if(D)if(b)S=fe(o,M,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Wi).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,rt),q(L,h,nt);const F=T.intersectsBox(rt),E=T.intersectsBox(nt);S=F&&fe(M,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(M,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}}return S}const oi=new X,gr=new d.Box3,fc={strategy:jr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ws{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,n=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:n?n.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:n?n.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:n}=e,c=new ws(t,{...i,[Fi]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...fc,[Fi]:!1},t),t.useSharedArrayBuffer&&!uc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Fi]||(Rl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?ec:Wl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,u=0){const f=c*2,p=a[f+15]===_i;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Et/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(n(r,u+1),n(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=n.groups,r=u?t.side:t,l=this.indirect?tc:ql;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=n.groups,r=c?t.side:t,l=this.indirect?sc:Ql;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?rc:Yl;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=ce.getPrimitive(),i=this.indirect?Gl:Ul;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else n||(c?n=(r,l,h,g)=>i(r,l,this,c,h,g,t):n=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=El(this,r,a,n,s,f),u)break;f+=h.byteLength}return ce.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=ce.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);Q(n,_*3,c,u)}:g=>{Q(n,g*3,c,u)},p=ce.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);Q(p,_*3,r,l)}:g=>{Q(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let S=v,C=v+y;S<C;S++){h(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let M=_,I=_+m;M<I;M++)if(f(M),n.needsUpdate=!0,a(n,p,M,S,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,S){return _(m,v,y,x,w,b,A,S)?!0:g(m,v,y,x,w,b,A,S)}}else s=g}return hc(this,e,t,s)}intersectsBox(e,t){return oi.set(e.min,e.max,t),oi.needsUpdate=!0,this.shapecast({intersectsBounds:i=>oi.intersectsBox(i),intersectsTriangle:i=>oi.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,n=1/0){return(this.indirect?cc:$l)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return kl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{q(0,new Float32Array(i),gr),e.union(gr)}),e}}class dc{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class pc extends dc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:pt&&pt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=ws.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];n&&u.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class mc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new gt,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,a)=>s.position.z>a.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const a=this.domElement.width/this.domElement.clientWidth,n=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*n,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const n=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(n),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+n):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-n):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){this._animator=window.requestAnimationFrame(r);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),r()},this.drawCircle=(s,a=10,n="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=n,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,n=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=n,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(a=>{const n=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,n?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),n=s.size;s.position.set(a.x*(this.center.x-n/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-n/2-this.options.padding),a.z)};const i={offset:new d.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new d.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
3731
+ `,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Vr);const Y={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class ji extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new pt,this._slotContainer=new f.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new f.Vector3,this._wrapper=new f.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Vr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_DELETED)}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(Y.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const n=JSON.parse(s);try{await this.install(n),this._emitter.emit(Y.ON_DROP,this)}catch(c){this._emitter.emit(Y.ON_DROP_ERROR,c)}}else this._emitter.emit(Y.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const a=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*a}}}async loadGlb(e){const i=await new Et({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Et({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_REPLACED),s.traverse(a=>{a.name.startsWith("Slot")&&this._bracketSlots.push(a),a.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(a=>{a.add(i)})}else this.clearSlot(),this._emitter.emit(Y.ON_DEVICE_REPLACED),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),ge(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(Y.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(Y.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(Y.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(Y.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),ge(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new f.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(n=34,c=60,u=60),a<u){let d=(u-a)*1+n;a<20&&(d=c),d>c&&(d=c),this._slotUI.setSize(d)}else this._slotUI.setSize(n)}clone(e){return new f.Group}}class Za extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=hs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const a="6px",n=document.createElement("div");n.style.pointerEvents="none",Object.assign(n.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(n);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class oi extends f.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new Za(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e,t;(e=this._line.geometry)==null||e.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line.computeLineDistances(),(t=this._line2.geometry)==null||t.dispose(),this._line2.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line2.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new f.Vector3().subVectors(t,e).normalize();let n;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?n=new f.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0)),n.normalize();const c=new f.Vector3().addVectors(e,n.clone().multiplyScalar(s)),u=new f.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),d=new f.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,u,d,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*1e3).toFixed(0)} mm`;const l=new f.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>ge(e)),this.removeFromParent()}}class Ur extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new Ka(""),this._line=new oi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new pn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new f.RingGeometry(e,e+.003,128),this._box.material=new f.MeshBasicMaterial({color:"#666",side:f.DoubleSide}),this._arc.geometry=new ws.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new mn.LineMaterial({color:"#eee",linewidth:2,resolution:new f.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new f.RingGeometry(e,e+.003,128),this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new f.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let n=.006*this.radius;n<.003&&(n=.003),n>.006&&(n=.006);const c=this._createArcGeometry(s,a,this.radius+n);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],a=t-e,n=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/n;for(let d=0;d<=n;d++){const p=e+d*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new ws.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class Ka extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=hs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",Ja="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",Xs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAdzSURBVHic7Z3hlZs6EIUvW4E7CB3EHcQdxB08OngugVTg8yrwSQVOKnBSwW4qsFOB3cF9PxhZQsYYjEAS1neOD7ssCwPXMxoNIGWIDJJLAAsASwCfAOTyey6bLOQDABf5qJ9P8vkry48sy05j2+ySzLcBjyC5QiXOV1kuWv+hPxcAvwD8BvCBSsRL6394JDjBSC4ArFEJtG7Y5ILqwp4A/JHlxfyoC04yN/4vh/bEz9Dim9uY+/8O4EfI4nmFZEFyz1veSe5Iri0BXB13Icfekjxaxz6TPMixXXt2fJDM5WLZF+og63MPNi1IbsQGW7zyJYUToXZyEUxP8iLSPUS80hLvdYQTobbWN3fHKvMLGpKrBq/bzla4htC3C8mbutIg3JnkxrddzhCvil4omwbhDqy6IPEisV5xJFn4tsk1rDJI8wtZ+rapN+JV73PzqnuwSk7MtvkQzflabdUxGsMdIGFSnfuZZFPHPxysELjnXDOoFsTbzAJA6dumRiyxSt/2+Ma6Hlvf9lyRb9QumjAwIZKQqOLAznvEEbFUcvFS7VVXWO/WvHsTLYnVnSBEM8JgEqsDlmi7qQ++TWL1xxKtnOqgKvs5J7H6I6KdJxFNsh5FygafxLqOxVgHme6b8QIYkWqcZoW6Mr13vvMXhboi8u56x+a34eXKTWMhXSO3SQirgqZi5WSniSvS1ChyFztUoTCcetjMoNGnHbqjTQqF42P1z4pnd7IwssKUwo8Mq/uIz2eN1NWMg3vzxoUWvu3pihEa+zU/4l3RJhoRC/ZcAkKdxkfnXUC8ggE1L+tWILbartW45o1D5IIpL+tWq43du4C4BQNqXlY82jB67wJmIdhSTG/vl1FXkaP1LiB+wQCA+m5+Ya5/s7b7V5a/J7Eq0cZ/svza+FcrHEZd1ZiJh5kp/q0e1D3tqMMhMA/BgFodt1DrzJD4jyx/TmpVoo3vsqyHxTmFQ2BWHpY3ngP1Pa9h5f1AmItgQC1bXAE6JKpXVn94sSrRxocsl4AW7Iss/0xuTuIRKqfQ7dic2i9gdiHxWlu0V8yi/QLmJRhQc6jlG3T7lYboCRfVji3eoMda+mjeNhEAJ1ku31ANYQekhCNklDafTA87eTEl0YWTLHNTsNSGhYvSZvEGPWDkyY8t1xt2ua/jd0Uyah/jYinBcvt+2OTIBTgAOHi6GJ3wbKeOfkaOn09sRNM4VGcXF8N1P0wiwNmyMx+63x7HV48dnuHqpJ40ZMNbBovmUrAGsRSTjuB2PRefgokhZcPFGCSaK8FaxCqf3ecAW66Cea8juhbNhWCBiaXridRtSD61IZZRzkQbKlhIYok9ut5rCOY9Q3Ml2hDBQhNLbKoJdpBfVr4MMnEh2rOChSiW2KWeCHg3X4wO5h2woaI9I1ioYolt6gHf/RuMOpU/k+pkWVYC+GatXmCkTit1p9hOvL6JLb7JZXky+0LTjn/UgWc9rY+HhexZCuqXIzZmfAzyAdJnROsqWAxiAbUnp9bmmxJn34bdo69oXQSLRSwAt10veqwndqVFtKJh21bBWD2WHotYuo5orDzIymAyxSbuiEZbtDbBqN8hCF4soGbv3lwZbOJh00W0e4LFJhZQG81hY67UHbMIeCRak2AxigXU2q+V/QdF7sWynrSJ1nFdDGJd2y/axXnqikfhx7z+tIjWhdK3/Y+gbqpuu1yM9IU+Nt8EfUQU00ex4YU+84/m6Df55NYNgPdDXhOFb3u7wLZwaGwUXVhUdBSt8G1nV9hlvBTjpKPIFm0eiFb4tq8P7No3ZkA3NJ/hjmiFb7v6QN3Nuh8OjY3VCQffib6HJVrh256+GN5Vdtk4ZwS1xUeIaIVvO/rSy7uMf9rF7mWx0su7jH9SD31E7WWxwfoI5v0eO6QuOiYvmwgOGcGcLkZ6TnSG+kGb7m1Xw05UtnVMoXE8WJ8hYljZjL4mKXsh6HIE85SAjAvHmCqFabKcUeAYk+UYO1ePWqXpqBxBXWx3f0vLyhpL5wd4MYyoNd7bnKzX6IJ+wipkOOXUlJN8M2YMfUxNaSUh+SQHnQFWszLtfGxME2/3whJr+j4t09T2nbHE8jO1vRiSRHtAMGIZBi2M8HhO2aNGskGVYOy8i2VCXQ+bLvsJGNYfci1929OIZeQ+qG/UREjE2QcvlsIKA0cGMjrBFFjt1ZGx3EcUww/Gt2w7Z2+T890Z5/seZQJmhcjjHBMSVuW6o3GepW+bBsHqfo/pbYc5hMkGrzpG6VX3YPWWyTl24e4IVfi2axRYZVBm+h+NcKxGHdhZtm9n5VX3EOHKBo8rGVByIt5UUFdzKDbvXkIomzvCKfE2PsQzRDpYNh1lfT61TcEhwq3lItniHSX0FGMIKAKtxWveecueAbVRmW8DbESUNaopHpe4HbDrhGqU6Q9UMyao309qgyzLTsa+7E8O4LMsm/YPVPOo/QTwI8uyoMbzD04wE7ngS/l8AbBC8wUeghL/J4CPLMt+Od6/U4IWrAlpQ5aoPOSTLHNoIRfGzxfoMd9P0J74F5VIlyzLopok6H/tVqA8kSYfTwAAAABJRU5ErkJggg==",$a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYwAAACsCAYAAABo4pvIAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAzYSURBVHic7d3hcdtIEobhD05gmYGRgbkRLDKwMjiGoBCUgeoi0F0Evo1AdASiIxAcgbkR9P1Aj9mESIm2QMwAeJ8qlihKomeXwHzsHgCsBBTOzGpJK7+pd7/2r3+ceCw69Vh8nkvt/fbW4/H7vaR//H4bfqeNX6uqij8DilPlHgCWxcxW6ibvNFmn+x/DY/Fn0mHyPXVLE7F0ejKOf3/SpRO1B9c55wJNOg6rfrD1/5v7/31pbN97j7WS9lVVnf3vAoZGYGAwPqHW6ia+tbrJce0/Tj+Lk176+k/4/ui2tAnRA/VUaNbqQjXdr8PvtDoOku/xeyoXDIXAwMXMbK1DGHzUcTikiatVN1l9Uy8YmLiG1wuY2r9+0vHrUuvwOux0/PrseF1wKQIDR06EQvw+TTatunexrXgXOwmh+ku31AJc6xAoMUxaESboITAWyoOhVjdhfAr307vQnbpQ2KlrDe2yDBSj8EBJ20S/Qml12B7S/XZp7UIQGLMX3lk2Og6Gnbqd/1u4zySAI+EghRQmH9VtS7W6bWYrKpLFIDBmJFQNf6nbwdOCc6oYvqqrFrY5xof56AXJJ53e3r5J2hIi80FgTFRoIcRwaP32Vb7TUjFgTCdaW426thYhMgMExgT4u7m1Dm2lxn+UqoatCAcUyrffRodqpPEfbcWbm0khMAoUdrBUPTTyUFC3g7UsQmPKvBJpdNzOiq3TLQFSHgKjAKGM/6xDOb+T9Le6d17bXGMDxmJmjY73g1aHRfX/ESD5ERgZhBbTZx2OOCEggOCVAEn7CQEyMgJjJL2Nv9Hxhr/NNS5gKnr7UK0uQNiHMH1mtjKzGzN7MLNnvz34Rg/gHXz/aszs3vetH75/bbyCB8pmZrVvsI/WeTSzWz8/AsCV+L536/vcj7Dv1bnHBvxkZmt/l/MUqogb3uUAefSqjx++X95R3SOLEBK0moDCER4Y3YmQuKfVBEyLh8dd2I8JDwzD+6J3hAQwP2fCo849LkyI9z/TwnVqNxESwIyF8IgL5qxD4jTfYB786KYvZnaTe0wAxudzQTraivVJdE60nDaUpACkn92GuxAed1QdCxSqCY5wAvCm3pFWj8wZM2eHk+p+VhO5xwRgWrzqSCcIPrHWMTMeFGltgmoCwCB6ax33tLMnzM+biG2nOveYAMxPWAulXTU1vUNiuRAZgFGERfJngqNwrE8AKEVoVz0xHxWEoABQqhAczE85ERQApiIEB62qMREUAKaK4BiJH4nwRFAAmDqC40rCeRQEBYBZ8Y5JumZVnXs8k9U7RO0u93gA4Br6cx2nAvyisE5B6gJYBA+OB684uFr2W3rtpzr3eABgbL31jTr3eIoUTq2/yz0WAMjNugsbPpvZbe6xFMOrimfSFACO+fyYzhhvco8nq1BVkKAAcIZXGz/M7D73WEYXqgoWtQHgAr1qo849nlGEvtwm91gAYGoWsbbBEVAAMIxw5YvH2Z23EVpQy+u/AcAV+Hkb9z63rnOPZxBhsWa+5RMAZDKbFlVIvzr3WABgrsbq4ny4xpOm/pqklaQ/q6pqr/HvAAAkn2P/lLSa1FFUIenuco8FAJYmXMiwzj2WVxEWAJBfCI0yF8PN7MYXtze5xwIASxeu+t3kHsuRMLAy0wwAFsjM1kW9kQ9hUeceCwDgWFgq2OQeSPp4wTrrQAAAZ3lo5Ks0QljQhgKAwmVrT1n3iVCEBQBMSAiNcebuUNrwmbMAMDF+ROv11539Ylf5F08AAL8tXH+qvuY/8sgVZwFg+vzkvqdrPfm9mT1e5ckBAKPz604NWwSM1vMCAIxm8HM0wiI3R0QBwMz4kVPDFAS+bjHtD+YAAJzli+DvW3IY5EkAAMV715XGaUUBwHKEOb/+nT/+wudaAMBy+KG2D7/6R42XJ6srjQsAUCCf+y+/kocvdDfXGxIAoETpIysu/eWGhW4AWK6Lz83w6oILCwLAQl1UZaS1i5HGBAAo1JtrGV5dbMYbEgCgRF5lnF6e8EuX/xh5TACAQvUvGfIh/OxW0n/GHhAAoFhbSS/bUp4kzdijAQCU6eS6dvqM7kxjAgAUKhYTqSW1Fu0oAMBLW3UZ0eHMbgDAKUcnc6ejo7huFACgzzPCpK4lVUvaV1W1zzoqAEBxPBt2ZtZ8UNeb2uYdEgCgYK2k9QdJnyR9yzsWAEDBvkr6mFpSbdahAABKtpNXGGtJrF8AAF6zSudhtDlHAQAo2l4hMAAAOGcvaaV0fC0AAOeYmVFhAAAu8kHSPl7vHACAyDOi/aDUmwIA4BUEBgDgLbV0CAwAAM5ZSdp9kJ/Bl3kwAIBy1fI1jO+S/so7FgBAwT5J+pYqjDrvWAAABWvUZUV3QgYfoAQA6IsfspdO3NuKdQwAwEtrSbuqqvYpMP6W9K+MAwIAlOmzuozo+Id8P+cbDwCgRN6OavoPPr94EACwWP1iIl588N+iLQUAOPgs6b8vHjWzmrYUACBJR0el739WGFVVtZJaM9tkGBcAoCCeBbuqqk5fPsrMbqgyAAAXrWv7L21GGREAoDhePDxe8osbqgwAWC4ze7z4qFmqDABYJj+U9u3qIvwBaxkAsDB+3ahfPyfPzB7M7O4qowIAFMfM7szsy+/8Ye3H4NbDDwsAUBIzW79rzve0oTUFADPnC923+Z8EAFAsM7v9pYXuV56o9kUQPi8DAGbm3a2oE0+48dAY5gkBANmFguBm6Ce+N7OnQZ8UAJCNLzncX+vJnzjUFgCmz4uA969bvPIPpPKFRXAAmKiwzLB6+7ff9w9dp+cFALg6v5LHeOfYhVV1jpwCgIkIc3cz9j+8ITQAYBpCWGxyDWAzamkDAPhl4VJPm9wD4RwNAChUWHfe5B6LJNpTAFAib0OVExaJf+hGeQMDgAUKb+TLPKI1pNld7rEAwFKlK40Xv1QQ+mV3uccCAEszmbBIPDSe/FP7rnsmIQAgfbzqg8+9de7x/DK/Vsl0kg4AJih0dq5zIcGx+AdzcP0pALgCn2N/zGaODYvh97SoAGAYs+3ieH/tcbL9NQAoRGhBPcx6PqVFBQC/L1xdYxlzaDiK6nHW6QgAA/F582GWLahLeP9tPos1AHAFYWH7LvdYsvJLilBtAECPVxWPi60qzmFtAwAO/IxtqopzQpo+2tifCAUABVjMEVBDscNnznJpEQCL0FvU3uQez6T4eRvpIlp3BAeAuWKuG0hI3fwfLwgAAwrnVNB+GpIfTcX6BoDJC0HBlS+uieAAMFUhKFinGBPBAWAqCIpChBeC4ABQFIKiUP7CPBEcAHIjKCYitKo4RA3AaPxUgNjx2OQeEy4UguOHB0ede0wA5qd3wt2Dma1zjwm/yV/MdFVc2lUABuFvSh+sw3kUc+Ll4m1Y57ilXQXgV/XXJwiKmeu1q+6pOgC8JlQTqe3U5B4TRmaH61WldhWL5AAk/Wxnx2qCtVB0wjsI1jqABbPuatlfwtpEk3tMKFRY64hHWDW5xwXgesxsHVpOj15Z0G3A5bwkTZcdfiY8gPnwkLin5YTBecuK8AAm7ERI3HPeBK6qFx4caQUUrHeEEyGBfM6FB/1PIA9fh7wJIfFESKA4vuYRF8wf/fs699iAOfNWU9r3LCxc17nHBrzJDhciS4fqplKY6gMYwIlW04NXFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class Js extends me.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new pt,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=hs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Xs}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const n=document.createElement("div");if(n.style.position="absolute",n.style.left="0",n.style.transform="translateX(-50%)",a.style.bottom=n.style.top="8px",n.style.width=n.style.height=a.style.width,n.style.background=`url(${Xs}) center no-repeat`,n.style.backgroundSize="100% auto",n.style.transition="all .2s",n.setAttribute("data-direction","down"),Array.from([a,n]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:d,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${$a}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${Ja}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${Xa}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=d/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new ci(l.rotation).to({z:v}).duration(u).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,n),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof me.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof me.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class el extends gn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new pt,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new f.Vector2,this._targetSize=new f.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:d,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(d,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:d,pageY:p}=u;let r=d-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.bottom="0",t.append(n),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",n.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",n.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",n.style[this._sizeFlag]=a*100+"px",n.style.textAlign="center",this._sizeFlag==="height"?(n.style.borderLeft="0.1px dashed #fff",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):n.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class tl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new oi("长:"),this._line12=new oi("宽:"),this._line13=new oi("高:"),this._outline=new Ur(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof me.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof me.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:a,hasHeight:n,hasWidth:c}=Va(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=n,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const u=this._box3.min.x,d=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new f.Vector3(u,h,0),m=new f.Vector3(d,h,0);this._line11.update(_.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const v=new f.Vector3(d,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),v.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(u,h,p),x=new f.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Ve extends f.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var e,t;this.clear(),(e=this.lineSegments)==null||e.geometry.dispose(),this._lineMaterial.dispose(),(t=this.lineSegments)==null||t.removeFromParent()}clearAll(){this.dispose()}clone(e){const t=new Ve(this._currentLength,this._currentWidth,this._currentHeight);return t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale),t.visible=this.visible,t.castShadow=this.castShadow,t.receiveShadow=this.receiveShadow,e&&this.children.forEach(i=>{if(i!==this.lineSegments){const s=i.clone(!0);t.add(s)}}),t}_generate(e,t,i){ge(this),this.clear(),this.geometry.dispose(),this.geometry=new f.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new f.EdgesGeometry(this.geometry);this.lineSegments=new f.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const il="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Qi{constructor(e){this._props=e,this.name="",this.transparentTexture=fs.load(il),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new f.Vector2(1,1),i=new f.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var d;let n=window.devicePixelRatio*2;this._offscreen.width=a.width+n,this._offscreen.height=a.height+n;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,n/2,n/2,a.width,a.height),s=new f.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=f.SRGBColorSpace,s.wrapS=s.wrapT=f.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((d=u.material.map)==null||d.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function $s(o){return o.type?o.type==="Mesh":o.isMesh}const fs=new f.TextureLoader;fs.crossOrigin="anonymous";class Wr extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new pt,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new f.Clock,this.sizeBox=new tl,this._goodsSize=new Wa(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new f.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new f.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta()},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof f.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof ji&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new f.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i+.14-.54;this.setShapeKey("boxLength",s);const a=i+.14;if(this.setShapeKey("topWidth",a),this.isTopInvert){const n=i-.257;this.setShapeKey("length",n)}else this.setShapeKey("width",a);this._generateRollers()}if(t==="goodsWidth"){const s=i+.193;this.setShapeKey("boxWidth",s);const a=i+.219;if(this.setShapeKey("topLength",a),this.isTopInvert){const n=i+.62;this.setShapeKey("width",n)}else this.setShapeKey("length",a)}})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const u=await We.loadAsync(e);i=u.animations||[],s=u.scene}else if(t==="sglb"||e.endsWith(".sglb")){const d=await new Et({useCache:!0}).loadAsync(e);i=d.animations||[],s=d.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const a=this._findFirstSkinnedMesh(s),n=this._findFirstSkinnedMesh(this._modelRoot);(!a||!n)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof _i.retargetClip=="function";i.forEach(u=>{let d=u;if(c&&a&&n)try{d=_i.retargetClip(n,a,u)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",u.name,r)}this._clips=this._clips.filter(r=>r.name!==d.name),this._clips.push(d);const p=this._mixer.clipAction(d);this._actionsMap.set(d.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let n=await We.loadAsync(e);i=n.scene,s=n.animations||[]}else{const c=await new Et({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=_i.clone(i);this._generateAmr(a,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new f.Vector2(t.scaleX,t.scaleY),new f.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(a=>{var u;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(u=a.morphTargetDictionary)==null?void 0:u[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof f.Mesh&&a.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(i=>{if(i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),i.userData.isRollerLevel&&this._rollerLevel.set(i.userData.level||0,i),i.userData.isCenterModel&&(i.visible=this.useCenterModel),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&(this._liftBrackets.push(i),i.visible=this._useLift),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!this._useLift),i.userData.isRoller&&(this._roller=i,this._roller.visible=!1,this._generateRollers()),i.userData.isRollerLevelBox){this._rollerGoodsBox=i;const s=new Ve(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);this.goods.push(s)}Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a);const n=this._shapeKeyTargets.get(s);n?n.push(i):this._shapeKeyTargets.set(s,[i])})}),e.traverse(i=>{if(i instanceof f.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(n=>n.name===a.userData.name)||this.skins.push(new ss({name:a.userData.name,target:a})))});else{if(i.material.userData.isVideo&&i.material.userData.video){const a=i.material.userData.video;let n=this._videoCache.get(a);n||(n=document.createElement("video"),n.src=a,n.crossOrigin="anonymous",n.loop=!0,n.muted=!0,n.playsInline=!0,n.autoplay=!0,n.preload="auto",this._videoCache.set(a,n)),n.play().catch(()=>{}),i.material.map&&i.material.map.dispose(),i.material.emissiveMap&&i.material.emissiveMap.dispose();const c=new f.VideoTexture(n);c.colorSpace=f.SRGBColorSpace,i.material.map=c,i.material.emissiveMap=c,i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=1,i.material.needsUpdate=!0}if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Le.Tween(i.material).to({emissiveIntensity:.2}).easing(Le.Easing.Quintic.InOut).duration(a),c=new Le.Tween(i.material).to({emissiveIntensity:2}).easing(Le.Easing.Quintic.InOut).duration(a);n.onComplete(()=>c.start()),c.onComplete(()=>n.start()),n.start(),this._breathLights.push(n,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new ss({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(n=>{if(n.userData.isLOGO){i.material.transparent=!0;let c;const u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=qi(i.material.map.image)),i.material.needsUpdate=!0;const d=new Qi({name:n.userData.name,target:i,size:Qs(i),imageSize:u,imageUrl:c});this._logos.push(d)}n.userData.isTransparent&&(n.transparent=!0),this._materialsCache.set(n.uuid,{opacity:n.opacity,transparent:n.transparent,roughness:n.roughness,metalness:n.metalness,color:n.color,mat:n})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let n;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,n=qi(i.material.map.image));const u=new Qi({name:a.userData.name,target:i,size:Qs(i),imageSize:c,imageUrl:n});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(n=>{if(n.startsWith("follow_")){const c=n.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[n])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof Ve&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this.goodsSize.length))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}setColumns(e){this._columnCount=e,this._rollerLevel.forEach(t=>{const i=t.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned);if(!i)return;console.log(i);const s=new f.Box3().setFromObject(i),a=new f.Vector3;s.getSize(a);const n=.03,c=a.x;console.log(a);const u=c*e+n*(e-1)-c;for(let d=1;d<e;d++){const p=i.clone(!0);p.userData.cloned=!0,p.position.x+=(n+c)/2,t.add(p)}i.position.x-=u/2})}get levels(){return this._levelCount}setLevels(e){var a;if(!e)return;this._levelCount=e;const t=this._rollerLevel.size;let i=e-t;const s=this._rollerLevel.get(0);if(i>0&&s)for(let n=t;n<e;n++){const c=s.clone(!0);c.visible=!0,c.position.z+=.2,this._rollerLevel.set(n,c),(a=s.parent)==null||a.add(c),this.regenerateShapeKeyNode(c),c.traverse(u=>{u instanceof Ve&&this.goods.push(u)}),this.setGoodsSize({length:this.goodsSize.length,width:this.goodsSize.width,height:this.goodsSize.height})}else for(let n=0;n<t;n++){const c=this._rollerLevel.get(n);c&&(c.visible=n<e)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{$s(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);t.userData.cloned=!0,s&&s.push(t)})})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=[];this._rollerLevel.forEach(p=>{p.traverse(r=>{r.userData.isCloned&&e.push(r)})}),e.forEach(p=>{ge(p),p.removeFromParent()}),e=[];let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s,c=i+s;let u=Math.floor(n/c);const d=n%c;if(u>0){u>1&&(s+=d/(u+2));const p=i+s,r=-t/2+s+i/2;for(let l=0;l<u;l++)this._rollerLevel.forEach(h=>{let g;h.traverse(m=>{m.userData.isRollerLevelBox&&(g=m)});const _=this._roller.clone(!0);_.visible=!0,_.userData.isCloned=!0,_.position.y=r+p*l,g==null||g.add(_),this.regenerateShapeKeyNode(_)})}}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-9)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{ge(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{$s(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const n=this._shelf.clone(!0);n.position.z+=t*a,this._shelves.set(a,n),(s=this._shelf.parent)==null||s.add(n);let c;if(n.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)+this._goodsSize.length/2)),c){const u=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const d=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);d.position.z-=t,c.add(d),this.goods.push(d)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Ur(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(u=>{u.name===i&&(n=u)}),!n)return;const c=new Js({name:"",target:i,default:0,min:s,max:a},n);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(u=>{u.name===i&&(n=u)}),!n)return;const c=new Js({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},n);e.add(c),this.controllers.push(c),(n.userData.isFork||n.userData.isLift||n.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=Oa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new f.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new f.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new f.Vector3(0,0,e.userData.start-e.position.z),c=n.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new el({start:n,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,n=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let d;u&&t.traverse(h=>{h.name===u&&(d=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new ji({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=d,l.addEventListener(Y.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(Y.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(Y.ON_ERROR_STATE_CHANGE,h=>{var _;if(!this._app)return;const g=(_=this._app)==null?void 0:_._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),h){if(l.device){if(g.selectedObjects.find(v=>{var y;return v.parent===((y=l.device)==null?void 0:y.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var v;return m.parent!==((v=l.device)==null?void 0:v.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),ge(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const a=this._currentAction,n=a===s,c=n?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,u=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const d=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(d?f.LoopRepeat:f.LoopOnce,d?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!d,s.play();const p=(t==null?void 0:t.timeScale)??1;return u?(a.stopFading(),a.enabled=!0,a.setEffectiveWeight(1),a.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(r=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=h=>{var g;h.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,r())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}}const Hr=0,sl=1,rl=2,er=2,Ri=1.25,tr=1,Pt=6*4+4+4,pi=65535,nl=Math.pow(2,-24),Ii=Symbol("SKIP_GENERATION");function ol(o){return o.index?o.index.count:o.attributes.position.count}function mt(o){return ol(o)/3}function al(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function ll(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=al(t,i);o.setIndex(new f.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Nr(o){const e=mt(o),t=o.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),n=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(n)}]}function Gr(o){if(!o.groups||!o.groups.length)return Nr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of o.groups){const u=c.start/3,d=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,d))}const n=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<n.length-1;c++){const u=n[c],d=n[c+1];e.push({offset:Math.floor(u),count:Math.floor(d-u)})}return e}function cl(o){if(o.groups.length===0)return!1;const e=mt(o),t=Gr(o).sort((a,n)=>a.offset-n.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Di(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,u=-1/0,d=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=o[v+0],w=o[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],C=o[v+3],M=S-C,I=S+C;M<n&&(n=M),I>d&&(d=I),S<l&&(l=S),S>_&&(_=S);const D=o[v+4],T=o[v+5],R=D-T,L=D+T;R<c&&(c=R),L>p&&(p=L),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=n,i[2]=c,i[3]=u,i[4]=d,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function ul(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=mt(o),c=s.normalized;let u;e===null?(u=new Float32Array(n*6*4),t=0,i=n):(u=e,t=t||0,i=i||n);const d=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=d[m+x],b=d[v+x],A=d[y+x]);let S=w;b<S&&(S=b),A<S&&(S=A);let C=w;b>C&&(C=b),A>C&&(C=A);const M=(C-S)/2,I=x*2;u[_+I+0]=S+M,u[_+I+1]=M+(Math.abs(S)+M)*nl}}return u}function q(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function ir(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function sr(o,e){e.set(o)}function rr(o,e,t){let i,s;for(let a=0;a<3;a++){const n=a+3;i=o[a],s=e[a],t[a]=i<s?i:s,i=o[n],s=e[n],t[n]=i>s?i:s}}function qt(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],a=e[o+2*i+1],n=s-a,c=s+a;n<t[i]&&(t[i]=n),c>t[i+3]&&(t[i+3]=c)}}function bt(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}const _e=32,hl=(o,e)=>o.candidate-e.candidate,Me=new Array(_e).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),jt=new Float32Array(6);function fl(o,e,t,i,s,a){let n=-1,c=0;if(a===Hr)n=ir(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===sl)n=ir(o),n!==-1&&(c=dl(t,i,s,n));else if(a===rl){const u=bt(o);let d=Ri*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/_e;if(s<_e/4){const v=[...Me];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:S,rightCacheBounds:C}=b;for(let M=0;M<3;M++)C[M]=1/0,C[M+3]=-1/0,S[M]=1/0,S[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;qt(w,t,A)}v.sort(hl);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let A=0;A<x;A++){const S=v[A];b>=S.candidate?qt(w,t,S.rightCacheBounds):(qt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,S=s-b.count,C=b.leftCacheBounds,M=b.rightCacheBounds;let I=0;A!==0&&(I=bt(C)/u);let D=0;S!==0&&(D=bt(M)/u);const T=tr+Ri*(I*A+D*S);T<d&&(n=l,d=T,c=b.candidate)}}else{for(let x=0;x<_e;x++){const w=Me[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=_e&&(A=_e-1);const S=Me[A];S.count++,qt(x,t,S.bounds)}const v=Me[_e-1];sr(v.bounds,v.rightCacheBounds);for(let x=_e-2;x>=0;x--){const w=Me[x],b=Me[x+1];rr(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<_e-1;x++){const w=Me[x],b=w.count,A=w.bounds,C=Me[x+1].rightCacheBounds;b!==0&&(y===0?sr(A,jt):rr(A,jt,jt)),y+=b;let M=0,I=0;y!==0&&(M=bt(jt)/u);const D=s-y;D!==0&&(I=bt(C)/u);const T=tr+Ri*(M*y+I*D);T<d&&(n=l,d=T,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function dl(o,e,t,i){let s=0;for(let a=e,n=e+t;a<n;a++)s+=o[a*6+i*2];return s/t}class Li{constructor(){this.boundingData=new Float32Array(6)}}function pl(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<u;)n++;for(;n<=c&&t[c*6+d]>=u;)c--;if(n<c){for(let p=0;p<3;p++){let r=e[n*3+p];e[n*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[n*6+p];t[n*6+p]=t[c*6+p],t[c*6+p]=r}n++,c--}else return n}}function ml(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<u;)n++;for(;n<=c&&t[c*6+d]>=u;)c--;if(n<c){let p=o[n];o[n]=o[c],o[c]=p;for(let r=0;r<6;r++){let l=t[n*6+r];t[n*6+r]=t[c*6+r],t[c*6+r]=l}n++,c--}else return n}}function ee(o,e){return e[o+15]===65535}function se(o,e){return e[o+6]}function ne(o,e){return e[o+14]}function oe(o){return o+8}function ae(o,e){return e[o+6]}function qr(o,e){return e[o+7]}let jr,It,ai,Qr;const gl=Math.pow(2,32);function Yi(o){return"count"in o?1:1+Yi(o.left)+Yi(o.right)}function vl(o,e,t){return jr=new Float32Array(t),It=new Uint32Array(t),ai=new Uint16Array(t),Qr=new Uint8Array(t),Zi(o,e)}function Zi(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)jr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Qr.set(new Uint8Array(n),o);for(let c=o,u=o+n.byteLength;c<u;c+=Pt){const d=c/2;ee(d,ai)||(It[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return It[t+6]=n,ai[i+14]=c,ai[i+15]=pi,o+Pt}else{const n=e.left,c=e.right,u=e.splitAxis;let d;if(d=Zi(o+Pt,n),d/4>gl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return It[t+6]=d/4,d=Zi(d,c),It[t+7]=u,d}}function _l(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),n=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=n.length;c<u;c++)n[c]=c;return n}function yl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:u,onProgress:d,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,h=l.index?l.index.array:null,g=p?ml:pl,_=mt(l),m=new Float32Array(6);let v=!1;const y=new Li;return Di(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){d&&d(b/_)}function w(b,A,S,C=null,M=0){if(!v&&M>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||M>=a)return x(A+S),b.offset=A,b.count=S,b;const I=fl(b.boundingData,C,e,A,S,u);if(I.axis===-1)return x(A+S),b.offset=A,b.count=S,b;const D=g(r,h,e,A,S,I);if(D===A||D===A+S)x(A+S),b.offset=A,b.count=S;else{b.splitAxis=I.axis;const T=new Li,R=A,L=D-A;b.left=T,Di(e,R,L,T.boundingData,m),w(T,R,L,m,M+1);const F=new Li,E=D,z=S-L;b.right=F,Di(e,E,z,F.boundingData,m),w(F,E,z,m,M+1)}return b}}function xl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=_l(t,e.useSharedArrayBuffer),cl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),o._indirectBuffer||ll(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=ul(t),a=e.indirect?Nr(t):Gr(t);o._roots=a.map(n=>{const c=yl(o,s,n.offset,n.count,e),u=Yi(c),d=new i(Pt*u);return vl(0,c,d),d})}class be{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,n=e.length;a<n;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,n=t.length;a<n;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}be.prototype.setFromBox=function(){const o=new f.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let d=0;d<=1;d++)for(let p=0;p<=1;p++){o.x=s.x*u+a.x*(1-u),o.y=s.y*d+a.y*(1-d),o.z=s.z*p+a.z*(1-p);const r=t.dot(o);n=Math.min(r,n),c=Math.max(r,c)}this.min=n,this.max=c}}();const wl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,a,n){const c=s.start,u=o,d=a.start,p=e;t.subVectors(c,d),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,n.x=v,n.y=y}}(),ds=function(){const o=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,a,n,c){wl(s,a,o);let u=o.x,d=o.y;if(u>=0&&u<=1&&d>=0&&d<=1){s.at(u,n),a.at(d,c);return}else if(u>=0&&u<=1){d<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(d>=0&&d<=1){u<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;d<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(h);return}}}}(),bl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(a,n){const{radius:c,center:u}=a,{a:d,b:p,c:r}=n;if(i.start=d,i.end=p,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c||(i.start=d,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c))return!0;const _=n.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(n.containsPoint(v))return!0}return!1}}(),Al=1e-15;function Pi(o){return Math.abs(o)<Al}class fe extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new be),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return bl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,n=this.satBounds,c=a[0],u=n[0];this.getNormal(c),u.setFromPoints(c,s);const d=a[1],p=n[1];d.subVectors(e,t),p.setFromPoints(d,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=n[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}fe.prototype.closestPointToSegment=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,a=null,n=null){const{start:c,end:u}=s,d=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(d[l]),t.end.copy(d[h]),ds(t,s,o,e),p=o.distanceToSquared(e),p<r&&(r=p,a&&a.copy(o),n&&n.copy(e))}return this.closestPointToPoint(c,o),p=c.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(c)),this.closestPointToPoint(u,o),p=u.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(u)),Math.sqrt(r)}}();fe.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new Array(3),i=new be,s=new be,a=new f.Vector3,n=new f.Vector3,c=new f.Vector3,u=new f.Vector3,d=new f.Vector3,p=new f.Line3,r=new f.Line3,l=new f.Line3,h=new f.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:S}=p;A.copy(y[b]),S.copy(y[(b+1)%3]),p.delta(n);const C=Pi(m.distanceToPoint(A));if(Pi(m.normal.dot(n))&&C){v.copy(p),x=2;break}const M=m.intersectLine(p,h);if(!M&&C&&h.copy(A),(M||C)&&!Pi(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),C&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(o.copy(m),o.update(),m=o);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let M=0;M<4;M++){const I=b[M],D=A[M];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const S=m.satBounds,C=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let M=0;M<4;M++){const I=S[M],D=C[M];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let M=0;M<4;M++){const I=A[M];for(let D=0;D<4;D++){const T=C[D];if(a.crossVectors(I,T),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let R=l.start;l.start=l.end,l.end=R}const S=r.start.dot(c),C=r.end.dot(c),M=l.start.dot(c),I=l.end.dot(c),D=C<M,T=S<I;return S!==I&&M!==C&&D===T?!1:(v&&(d.subVectors(r.start,l.start),d.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),d.subVectors(r.end,l.end),d.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();fe.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();fe.prototype.distanceToTriangle=function(){const o=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(n,c=null,u=null){const d=c||u?i:null;if(this.intersectsTriangle(n,d))return(c||u)&&(c&&d.getCenter(c),u&&d.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=n[h];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),u&&u.copy(g));const _=this[h];n.closestPointToPoint(_,o),l=_.distanceToSquared(o),l<p&&(p=l,c&&c.copy(_),u&&u.copy(o))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(n[_],n[m]),ds(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),u&&u.copy(e))}}return Math.sqrt(p)}}();class X{constructor(e,t,i){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new be),this.alignedSatBounds=new Array(3).fill().map(()=>new be),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}X.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let d=0;d<=1;d++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*d|2*p|4*r,h=s[l];h.x=d?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let d=0;d<3;d++){const p=n[d],r=a[d],l=1<<d,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();X.prototype.intersectsBox=function(){const o=new be;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,n=this.satAxes,c=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,c[0].isSeparated(o)||(o.min=i.y,o.max=s.y,c[1].isSeparated(o))||(o.min=i.z,o.max=s.z,c[2].isSeparated(o)))return!1;for(let u=0;u<3;u++){const d=n[u],p=a[u];if(o.setFromBox(d,t),p.isSeparated(o))return!1}return!0}}();X.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new be,i=new be,s=new f.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(o.copy(n),o.update(),n=o);const c=this.satBounds,u=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const d=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const h=d[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();X.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();X.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();X.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),i=new f.Vector3,s=new f.Vector3;return function(n,c=0,u=null,d=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(u||d)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),u&&u.copy(i),d&&d.copy(s)),0;const p=c*c,r=n.min,l=n.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),d&&d.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,S=h[b],C=h[A];e[_].set(S,C);const I=o[m],D=o[x],T=o[w],R=t[_],L=R.start,F=R.end;L[I]=r[I],L[D]=v?r[D]:l[D],L[T]=y?r[T]:l[D],F[I]=l[I],F[D]=v?r[D]:l[D],F[T]=y?r[T]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),d&&d.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];ds(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),d&&d.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Tl extends ps{constructor(){super(()=>new fe)}}const le=new Tl;class Sl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const H=new Sl;let Pe,at;const Qe=[],Qt=new ps(()=>new f.Box3);function Ml(o,e,t,i,s,a){Pe=Qt.getPrimitive(),at=Qt.getPrimitive(),Qe.push(Pe,at),H.setBuffer(o._roots[e]);const n=Ki(0,o.geometry,t,i,s,a);H.clearBuffer(),Qt.releasePrimitive(Pe),Qt.releasePrimitive(at),Qe.pop(),Qe.pop();const c=Qe.length;return c>0&&(at=Qe[c-1],Pe=Qe[c-2]),n}function Ki(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:u,uint32Array:d}=H;let p=o*2;if(ee(p,u)){const l=se(o,d),h=ne(p,u);return q(o,c,Pe),i(l,h,!1,n,a+o,Pe)}else{let I=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=oe(T),F=T*2;return se(T,L)},D=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=ae(T,L),F=T*2;return se(T,L)+ne(F,R)};const l=oe(o),h=ae(o,d);let g=l,_=h,m,v,y,x;if(s&&(y=Pe,x=at,q(g,c,y),q(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const T=m;m=v,v=T,y=x}y||(y=Pe,q(g,c,y));const w=ee(g*2,u),b=t(y,w,m,n+1,a+g);let A;if(b===er){const T=I(g),L=D(g)-T;A=i(T,L,!0,n+1,a+g,y)}else A=b&&Ki(g,e,t,i,s,a,n+1);if(A)return!0;x=at,q(_,c,x);const S=ee(_*2,u),C=t(x,S,v,n+1,a+_);let M;if(C===er){const T=I(_),L=D(_)-T;M=i(T,L,!0,n+1,a+_,x)}else M=C&&Ki(_,e,t,i,s,a,n+1);return!!M}}const At=new f.Vector3,Fi=new f.Vector3;function Cl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,u=null;if(o.shapecast({boundsTraverseOrder:p=>(At.copy(e).clamp(p.min,p.max),At.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,At);const l=e.distanceToSquared(At);return l<c&&(Fi.copy(At),c=l,u=r),l<a}}),c===1/0)return null;const d=Math.sqrt(c);return t.point?t.point.copy(Fi):t.point=Fi.clone(),t.distance=d,t.faceIndex=u,t}const Ye=new f.Vector3,Ze=new f.Vector3,Ke=new f.Vector3,Yt=new f.Vector2,Zt=new f.Vector2,Kt=new f.Vector2,nr=new f.Vector3,or=new f.Vector3,ar=new f.Vector3,Xt=new f.Vector3;function Rl(o,e,t,i,s,a,n,c){let u;if(a===f.BackSide?u=o.intersectTriangle(i,t,e,!0,s):u=o.intersectTriangle(e,t,i,a!==f.DoubleSide,s),u===null)return null;const d=o.origin.distanceTo(s);return d<n||d>c?null:{distance:d,point:s.clone()}}function Il(o,e,t,i,s,a,n,c,u,d,p){Ye.fromBufferAttribute(e,a),Ze.fromBufferAttribute(e,n),Ke.fromBufferAttribute(e,c);const r=Rl(o,Ye,Ze,Ke,Xt,u,d,p);if(r){i&&(Yt.fromBufferAttribute(i,a),Zt.fromBufferAttribute(i,n),Kt.fromBufferAttribute(i,c),r.uv=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),s&&(Yt.fromBufferAttribute(s,a),Zt.fromBufferAttribute(s,n),Kt.fromBufferAttribute(s,c),r.uv1=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),t&&(nr.fromBufferAttribute(t,a),or.fromBufferAttribute(t,n),ar.fromBufferAttribute(t,c),r.normal=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,nr,or,ar,new f.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(Ye,Ze,Ke,l.normal),r.face=l,r.faceIndex=a}return r}function mi(o,e,t,i,s,a,n){const c=i*3;let u=c+0,d=c+1,p=c+2;const r=o.index;o.index&&(u=r.getX(u),d=r.getX(d),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=o.attributes,m=Il(t,l,h,g,_,u,d,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Q(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,u=e+1,d=e+2;t&&(c=t.getX(c),u=t.getX(u),d=t.getX(d)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),n.x=i.getX(d),n.y=i.getY(d),n.z=i.getZ(d)}function Dl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++)mi(u,e,t,p,a,n,c)}function Ll(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=mi(c,e,t,r,null,a,n),h&&h.distance<d&&(p=h,d=h.distance)}return p}function Pl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Q(n,l*3,u,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Fl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,u,d=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===pi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=3*v,I=3*(v+y);M<I;M++){let D=i[M];const T=s.getX(D),R=s.getY(D),L=s.getZ(D);T<x&&(x=T),T>A&&(A=T),R<w&&(w=R),R>S&&(S=R),L<b&&(b=L),L>C&&(C=L)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function Fe(o,e,t,i,s){let a,n,c,u,d,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[o],y=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],A=e[o+3+2];return r>=0?(a=(v-g)*r,n=(y-g)*r):(a=(y-g)*r,n=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>n||((c>a||isNaN(a))&&(a=c),(u<n||isNaN(n))&&(n=u),h>=0?(d=(b-m)*h,p=(A-m)*h):(d=(A-m)*h,p=(b-m)*h),a>p||d>n)?!1:((d>a||a!==a)&&(a=d),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function El(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++){let l=d?d[p]:p;mi(u,e,t,l,a,n,c)}}function Bl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=mi(c,e,t,u?u[r]:r,null,a,n),h&&h.distance<d&&(p=h,d=h.distance)}return p}function kl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Q(n,l*3,u,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Ol(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),Xi(0,o,t,i,s,a,n),H.clearBuffer()}function Xi(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:d}=H,p=o*2;if(ee(p,u)){const l=se(o,d),h=ne(p,u);Dl(e,t,i,l,h,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&Xi(l,e,t,i,s,a,n);const h=ae(o,d);Fe(h,c,i,a,n)&&Xi(h,e,t,i,s,a,n)}}const zl=["x","y","z"];function Vl(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=Ji(0,o,t,i,s,a);return H.clearBuffer(),n}function Ji(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let d=o*2;if(ee(d,c)){const r=se(o,u),l=ne(d,c);return Ll(e,t,i,r,l,s,a)}else{const r=qr(o,u),l=zl[r],g=i.direction[l]>=0;let _,m;g?(_=oe(o),m=ae(o,u)):(_=ae(o,u),m=oe(o));const y=Fe(_,n,i,s,a)?Ji(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=Fe(m,n,i,s,a)?Ji(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Jt=new f.Box3,Xe=new fe,Je=new fe,Tt=new f.Matrix4,lr=new X,$t=new X;function Ul(o,e,t,i){H.setBuffer(o._roots[e]);const s=$i(0,o,t,i);return H.clearBuffer(),s}function $i(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),lr.set(t.boundingBox.min,t.boundingBox.max,i),s=lr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=se(o,c),m=ne(u,n);if(Tt.copy(i).invert(),t.boundsTree)return q(o,a,$t),$t.matrix.copy(Tt),$t.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>$t.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(Q(Je,x,r,l),Je.needsUpdate=!0,y.intersectsTriangle(Je))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){Q(Xe,v,r,l),Xe.a.applyMatrix4(Tt),Xe.b.applyMatrix4(Tt),Xe.c.applyMatrix4(Tt),Xe.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(Q(Je,x,h,g),Je.needsUpdate=!0,Xe.intersectsTriangle(Je))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,Jt),!!(s.intersectsBox(Jt)&&$i(p,e,t,i,s)||(q(r,a,Jt),s.intersectsBox(Jt)&&$i(r,e,t,i,s)))}}const ei=new f.Matrix4,Ei=new X,St=new X,Wl=new f.Vector3,Hl=new f.Vector3,Nl=new f.Vector3,Gl=new f.Vector3;function ql(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Ei.set(e.boundingBox.min,e.boundingBox.max,t),Ei.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),h=le.getPrimitive();let g=Wl,_=Hl,m=null,v=null;s&&(m=Nl,v=Gl);let y=1/0,x=null,w=null;return ei.copy(t).invert(),St.matrix.copy(ei),o.shapecast({boundsTraverseOrder:b=>Ei.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(St.min.copy(b.min),St.max.copy(b.max),St.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:C=>St.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){Q(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let T=b,R=b+A;T<R;T++){Q(l,3*T,d,u),l.needsUpdate=!0;const L=l.distanceToTriangle(h,g,m);if(L<y&&(_.copy(g),v&&v.copy(m),y=L,x=T,w=I),L<a)return!0}}}});{const S=mt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){Q(l,3*I,d,u),l.needsUpdate=!0;const T=l.distanceToTriangle(h,g,m);if(T<y&&(_.copy(g),v&&v.copy(m),y=T,x=I,w=C),T<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ei),_.applyMatrix4(ei),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function jl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,u,d=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===pi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=v,I=v+y;M<I;M++){const D=3*o.resolveTriangleIndex(M);for(let T=0;T<3;T++){let R=D+T;R=i?i[R]:R;const L=s.getX(R),F=s.getY(R),E=s.getZ(R);L<x&&(x=L),L>A&&(A=L),F<w&&(w=F),F>S&&(S=F),E<b&&(b=E),E>C&&(C=E)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function Ql(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),es(0,o,t,i,s,a,n),H.clearBuffer()}function es(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:d}=H,p=o*2;if(ee(p,u)){const l=se(o,d),h=ne(p,u);El(e,t,i,l,h,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&es(l,e,t,i,s,a,n);const h=ae(o,d);Fe(h,c,i,a,n)&&es(h,e,t,i,s,a,n)}}const Yl=["x","y","z"];function Zl(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=ts(0,o,t,i,s,a);return H.clearBuffer(),n}function ts(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let d=o*2;if(ee(d,c)){const r=se(o,u),l=ne(d,c);return Bl(e,t,i,r,l,s,a)}else{const r=qr(o,u),l=Yl[r],g=i.direction[l]>=0;let _,m;g?(_=oe(o),m=ae(o,u)):(_=ae(o,u),m=oe(o));const y=Fe(_,n,i,s,a)?ts(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=Fe(m,n,i,s,a)?ts(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ti=new f.Box3,$e=new fe,et=new fe,Mt=new f.Matrix4,cr=new X,ii=new X;function Kl(o,e,t,i){H.setBuffer(o._roots[e]);const s=is(0,o,t,i);return H.clearBuffer(),s}function is(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),cr.set(t.boundingBox.min,t.boundingBox.max,i),s=cr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=se(o,c),m=ne(u,n);if(Mt.copy(i).invert(),t.boundsTree)return q(o,a,ii),ii.matrix.copy(Mt),ii.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ii.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(Q(et,3*e.resolveTriangleIndex(x),r,l),et.needsUpdate=!0,y.intersectsTriangle(et))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);Q($e,3*x,r,l),$e.a.applyMatrix4(Mt),$e.b.applyMatrix4(Mt),$e.c.applyMatrix4(Mt),$e.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(Q(et,w,h,g),et.needsUpdate=!0,$e.intersectsTriangle(et))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,ti),!!(s.intersectsBox(ti)&&is(p,e,t,i,s)||(q(r,a,ti),s.intersectsBox(ti)&&is(r,e,t,i,s)))}}const si=new f.Matrix4,Bi=new X,Ct=new X,Xl=new f.Vector3,Jl=new f.Vector3,$l=new f.Vector3,ec=new f.Vector3;function tc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Bi.set(e.boundingBox.min,e.boundingBox.max,t),Bi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),h=le.getPrimitive();let g=Xl,_=Jl,m=null,v=null;s&&(m=$l,v=ec);let y=1/0,x=null,w=null;return si.copy(t).invert(),Ct.matrix.copy(si),o.shapecast({boundsTraverseOrder:b=>Bi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Ct.min.copy(b.min),Ct.max.copy(b.max),Ct.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:C=>Ct.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){const T=S.resolveTriangleIndex(I);Q(h,3*T,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,L=b+A;R<L;R++){const F=o.resolveTriangleIndex(R);Q(l,3*F,d,u),l.needsUpdate=!0;const E=l.distanceToTriangle(h,g,m);if(E<y&&(_.copy(g),v&&v.copy(m),y=E,x=R,w=I),E<a)return!0}}}})}else{const S=mt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){const T=o.resolveTriangleIndex(I);Q(l,3*T,d,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=I,w=C),R<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(si),_.applyMatrix4(si),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function ic(){return typeof SharedArrayBuffer<"u"}const Ft=new H.constructor,ui=new H.constructor,Re=new ps(()=>new f.Box3),it=new f.Box3,st=new f.Box3,ki=new f.Box3,Oi=new f.Box3;let zi=!1;function sc(o,e,t,i){if(zi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");zi=!0;const s=o._roots,a=e._roots;let n,c=0,u=0;const d=new f.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Ft.setBuffer(s[p]),u=0;const l=Re.getPrimitive();q(0,Ft.float32Array,l),l.applyMatrix4(d);for(let h=0,g=a.length;h<g&&(ui.setBuffer(a[p]),n=he(0,0,t,d,i,c,u,0,0,l),ui.clearBuffer(),u+=a[h].length,!n);h++);if(Re.releasePrimitive(l),Ft.clearBuffer(),c+=s[p].length,n)break}return zi=!1,n}function he(o,e,t,i,s,a=0,n=0,c=0,u=0,d=null,p=!1){let r,l;p?(r=ui,l=Ft):(r=Ft,l=ui);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=o*2,w=e*2,b=ee(x,_),A=ee(w,y);let S=!1;if(A&&b)p?S=s(se(e,v),ne(e*2,y),se(o,g),ne(o*2,_),u,n+e,c,a+o):S=s(se(o,g),ne(o*2,_),se(e,v),ne(e*2,y),c,a+o,u,n+e);else if(A){const C=Re.getPrimitive();q(e,m,C),C.applyMatrix4(t);const M=oe(o),I=ae(o,g);q(M,h,it),q(I,h,st);const D=C.intersectsBox(it),T=C.intersectsBox(st);S=D&&he(e,M,i,t,s,n,a,u,c+1,C,!p)||T&&he(e,I,i,t,s,n,a,u,c+1,C,!p),Re.releasePrimitive(C)}else{const C=oe(e),M=ae(e,v);q(C,m,ki),q(M,m,Oi);const I=d.intersectsBox(ki),D=d.intersectsBox(Oi);if(I&&D)S=he(o,C,t,i,s,a,n,c,u+1,d,p)||he(o,M,t,i,s,a,n,c,u+1,d,p);else if(I)if(b)S=he(o,C,t,i,s,a,n,c,u+1,d,p);else{const T=Re.getPrimitive();T.copy(ki).applyMatrix4(t);const R=oe(o),L=ae(o,g);q(R,h,it),q(L,h,st);const F=T.intersectsBox(it),E=T.intersectsBox(st);S=F&&he(C,R,i,t,s,n,a,u,c+1,T,!p)||E&&he(C,L,i,t,s,n,a,u,c+1,T,!p),Re.releasePrimitive(T)}else if(D)if(b)S=he(o,M,t,i,s,a,n,c,u+1,d,p);else{const T=Re.getPrimitive();T.copy(Oi).applyMatrix4(t);const R=oe(o),L=ae(o,g);q(R,h,it),q(L,h,st);const F=T.intersectsBox(it),E=T.intersectsBox(st);S=F&&he(M,R,i,t,s,n,a,u,c+1,T,!p)||E&&he(M,L,i,t,s,n,a,u,c+1,T,!p),Re.releasePrimitive(T)}}return S}const ri=new X,ur=new f.Box3,rc={strategy:Hr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,n=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:n?n.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:n?n.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:n}=e,c=new ms(t,{...i,[Ii]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const u=t.getIndex();if(u===null){const d=new f.BufferAttribute(e.index,1,!1);t.setIndex(d)}else u.array!==s&&(u.array.set(s),u.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...rc,[Ii]:!1},t),t.useSharedArrayBuffer&&!ic())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ii]||(xl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?jl:Fl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,u=0){const d=c*2,p=a[d+15]===pi;if(p){const r=s[c+6],l=a[d+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(n(r,u+1),n(l,u+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],u=t.isMaterial,d=Array.isArray(t),p=n.groups,r=u?t.side:t,l=this.indirect?Ql:Ol;for(let h=0,g=a.length;h<g;h++){const _=d?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),d){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,u=Array.isArray(t);let d=null;const p=n.groups,r=c?t.side:t,l=this.indirect?Zl:Vl;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(d==null||m.distance<d.distance)&&(d=m,u&&(m.face.materialIndex=p[h].materialIndex))}return d}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?Kl:Ul;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=le.getPrimitive(),i=this.indirect?kl:Pl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else n||(c?n=(r,l,h,g)=>i(r,l,this,c,h,g,t):n=(r,l,h)=>h);let u=!1,d=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=Ml(this,r,a,n,s,d),u)break;d+=h.byteLength}return le.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=le.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,d=this.indirect?g=>{const _=this.resolveTriangleIndex(g);Q(n,_*3,c,u)}:g=>{Q(n,g*3,c,u)},p=le.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);Q(p,_*3,r,l)}:g=>{Q(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let S=v,C=v+y;S<C;S++){h(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let M=_,I=_+m;M<I;M++)if(d(M),n.needsUpdate=!0,a(n,p,M,S,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,S){return _(m,v,y,x,w,b,A,S)?!0:g(m,v,y,x,w,b,A,S)}}else s=g}return sc(this,e,t,s)}intersectsBox(e,t){return ri.set(e.min,e.max,t),ri.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ri.intersectsBox(i),intersectsTriangle:i=>ri.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,n=1/0){return(this.indirect?tc:ql)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return Cl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{q(0,new Float32Array(i),ur),e.union(ur)}),e}}class nc{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class oc extends nc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=d=>{a(new Error(`GenerateMeshBVHWorker: ${d.message}`))},e.onmessage=d=>{const{data:p}=d;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=ms.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const _=new f.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];n&&u.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(d=>d.buffer).filter(d=>typeof SharedArrayBuffer>"u"||!(d instanceof SharedArrayBuffer)))})}}class ac{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new f.Matrix4,this.mouse=new f.Vector3,this.rotateStart=new f.Vector2,this.rotateEnd=new f.Vector2,this.rotateDelta=new f.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new pt,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,a)=>s.position.z>a.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const a=this.domElement.width/this.domElement.clientWidth,n=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*n,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const n=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(n),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+n):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-n):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),d=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,d);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==d){this._animator=window.requestAnimationFrame(r);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),r()},this.drawCircle=(s,a=10,n="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=n,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,n=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=n,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(a=>{const n=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,n?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),n=s.size;s.position.set(a.x*(this.center.x-n/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-n/2-this.options.padding),a.z)};const i={offset:new f.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new f.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
3732
3732
  transition: all 0.8s ease-in-out;
3733
3733
  color: rgb(68, 78, 105);
3734
3734
  position: absolute;
@@ -3739,7 +3739,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new
3739
3739
  margin-right: ${-this.options.size/4}px;
3740
3740
  font-size: 12px;
3741
3741
  text-align:center;
3742
- `}appendTo(e){e.append(this.domElement),e.append(this._text)}createAxes(){const{colors:e,lineWidth:t,bubbleSizePrimary:i,bubbleSizeSecondary:s}=this.options;return[{axis:"x",direction:new d.Vector3(1,0,0),size:i,color:e.x,line:t,label:"前",position:new d.Vector3},{axis:"y",direction:new d.Vector3(0,1,0),size:i,color:e.y,line:t,label:"左",position:new d.Vector3},{axis:"z",direction:new d.Vector3(0,0,1),size:i,color:e.z,line:t,label:"上",position:new d.Vector3},{axis:"-x",direction:new d.Vector3(-1,0,0),size:s,color:e.x,label:"后",position:new d.Vector3},{axis:"-y",direction:new d.Vector3(0,-1,0),size:s,color:e.y,position:new d.Vector3,label:"右"},{axis:"-z",direction:new d.Vector3(0,0,-1),size:i,color:e.z,label:"下",position:new d.Vector3}]}createCanvas(e){const t=document.createElement("canvas");return t.width=e.size,t.height=e.size,t.classList.add(e.className),t.style.cssText=`
3742
+ `}appendTo(e){e.append(this.domElement),e.append(this._text)}createAxes(){const{colors:e,lineWidth:t,bubbleSizePrimary:i,bubbleSizeSecondary:s}=this.options;return[{axis:"x",direction:new f.Vector3(1,0,0),size:i,color:e.x,line:t,label:"前",position:new f.Vector3},{axis:"y",direction:new f.Vector3(0,1,0),size:i,color:e.y,line:t,label:"左",position:new f.Vector3},{axis:"z",direction:new f.Vector3(0,0,1),size:i,color:e.z,line:t,label:"上",position:new f.Vector3},{axis:"-x",direction:new f.Vector3(-1,0,0),size:s,color:e.x,label:"后",position:new f.Vector3},{axis:"-y",direction:new f.Vector3(0,-1,0),size:s,color:e.y,position:new f.Vector3,label:"右"},{axis:"-z",direction:new f.Vector3(0,0,-1),size:i,color:e.z,label:"下",position:new f.Vector3}]}createCanvas(e){const t=document.createElement("canvas");return t.width=e.size,t.height=e.size,t.classList.add(e.className),t.style.cssText=`
3743
3743
  position: absolute;
3744
3744
  left: auto;
3745
3745
  top: ${this.options.offset.y}px;
@@ -3751,14 +3751,14 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,pi=new
3751
3751
  border-radius: 100%;
3752
3752
  transition: background-color .15s linear;
3753
3753
  cursor: pointer;
3754
- `,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class gc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=512,shadowBias:a=.001,lightCount:n=8,size:c=4,frames:u=40,lightRadius:f=2,ambientWeight:p=.5,alphaTest:r=.98,paused:l=!1}={}){this.params={enabled:!0,frames:u,lightRadius:f,ambientWeight:p,alphaTest:r,debugHelpers:!1,size:c,paused:l},this.scene=t,this.renderer=e,this.buffer1Active=!1,this.dirLights=[],this.dirLightsHelpers=[],this.clearColor=new d.Color,this.clearAlpha=0,this.progress=0,this.discardMaterial=new _c,this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.isZUp=d.Object3D.DEFAULT_UP.z===1,this.progShadowGrp=new d.Group,this.progShadowGrp.name="progressive_shadow_assets",this.scene.add(this.progShadowGrp),this.lightOrigin=new d.Group,this.lightOrigin.name="light_origin",this.isZUp?this.lightOrigin.position.set(c,c,c*1.5):this.lightOrigin.position.set(c,c,c),this.progShadowGrp.add(this.lightOrigin),this.lightGroup=new d.Group,this.lightGroup.name="all_dir_lights",this.progShadowGrp.add(this.lightGroup);const h=Math.PI;for(let m=0;m<n;m++){const v=new d.DirectionalLight(16777215,h/n);v.name="dir_light_"+m,v.castShadow=!0,v.shadow.bias=a,v.shadow.camera.near=.1,v.shadow.camera.far=50,v.shadow.camera.right=c/2,v.shadow.camera.left=-c/2,v.shadow.camera.top=c/2,v.shadow.camera.bottom=-c/2,v.shadow.mapSize.width=s,v.shadow.mapSize.height=s,this.dirLights.push(v),this.lightGroup.add(v)}const g=/(Android|iPad|iPhone|iPod)/g.test(navigator==null?void 0:navigator.userAgent)?d.HalfFloatType:d.FloatType;this.progressiveLightMap1=new d.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap2=new d.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap1.texture.colorSpace=d.NoColorSpace,this.progressiveLightMap2.texture.colorSpace=d.NoColorSpace,this.shadowCatcherMaterial=new vc({map:this.progressiveLightMap2.texture,transparent:!0,opacity:1});const _=new d.PlaneGeometry(c,c);this.isZUp||_.rotateX(-Math.PI/2),this.shadowCatcherMesh=new d.Mesh(_,this.shadowCatcherMaterial),this.isZUp?this.shadowCatcherMesh.position.z=.001:this.shadowCatcherMesh.position.y=.001,this.shadowCatcherMesh.name="shadowCatcherMesh",this.shadowCatcherMesh.receiveShadow=!0,this.progShadowGrp.add(this.shadowCatcherMesh),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.rebuildObjectsToShowAncestors(),this.debugHelpersGroup=new d.Group,this.targetMat=new d.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:u},this.targetMat.onBeforeCompile=m=>{m.vertexShader=`varying vec2 vUv;
3754
+ `,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class lc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=512,shadowBias:a=.001,lightCount:n=8,size:c=4,frames:u=40,lightRadius:d=2,ambientWeight:p=.5,alphaTest:r=.98,paused:l=!1}={}){this.params={enabled:!0,frames:u,lightRadius:d,ambientWeight:p,alphaTest:r,debugHelpers:!1,size:c,paused:l},this.scene=t,this.renderer=e,this.buffer1Active=!1,this.dirLights=[],this.dirLightsHelpers=[],this.clearColor=new f.Color,this.clearAlpha=0,this.progress=0,this.discardMaterial=new uc,this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.isZUp=f.Object3D.DEFAULT_UP.z===1,this.progShadowGrp=new f.Group,this.progShadowGrp.name="progressive_shadow_assets",this.scene.add(this.progShadowGrp),this.lightOrigin=new f.Group,this.lightOrigin.name="light_origin",this.isZUp?this.lightOrigin.position.set(c,c,c*1.5):this.lightOrigin.position.set(c,c,c),this.progShadowGrp.add(this.lightOrigin),this.lightGroup=new f.Group,this.lightGroup.name="all_dir_lights",this.progShadowGrp.add(this.lightGroup);const h=Math.PI;for(let m=0;m<n;m++){const v=new f.DirectionalLight(16777215,h/n);v.name="dir_light_"+m,v.castShadow=!0,v.shadow.bias=a,v.shadow.camera.near=.1,v.shadow.camera.far=50,v.shadow.camera.right=c/2,v.shadow.camera.left=-c/2,v.shadow.camera.top=c/2,v.shadow.camera.bottom=-c/2,v.shadow.mapSize.width=s,v.shadow.mapSize.height=s,this.dirLights.push(v),this.lightGroup.add(v)}const g=/(Android|iPad|iPhone|iPod)/g.test(navigator==null?void 0:navigator.userAgent)?f.HalfFloatType:f.FloatType;this.progressiveLightMap1=new f.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap2=new f.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap1.texture.colorSpace=f.NoColorSpace,this.progressiveLightMap2.texture.colorSpace=f.NoColorSpace,this.shadowCatcherMaterial=new cc({map:this.progressiveLightMap2.texture,transparent:!0,opacity:1});const _=new f.PlaneGeometry(c,c);this.isZUp||_.rotateX(-Math.PI/2),this.shadowCatcherMesh=new f.Mesh(_,this.shadowCatcherMaterial),this.isZUp?this.shadowCatcherMesh.position.z=.001:this.shadowCatcherMesh.position.y=.001,this.shadowCatcherMesh.name="shadowCatcherMesh",this.shadowCatcherMesh.receiveShadow=!0,this.progShadowGrp.add(this.shadowCatcherMesh),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.rebuildObjectsToShowAncestors(),this.debugHelpersGroup=new f.Group,this.targetMat=new f.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:u},this.targetMat.onBeforeCompile=m=>{m.vertexShader=`varying vec2 vUv;
3755
3755
  `+m.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const v=m.fragmentShader.indexOf("void main() {");m.fragmentShader=`varying vec2 vUv;
3756
3756
  `+m.fragmentShader.slice(0,v)+`uniform sampler2D previousShadowMap;
3757
3757
  uniform float averagingWindow;
3758
3758
  `+m.fragmentShader.slice(v-1,-1)+`
3759
3759
  vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3760
3760
  gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);
3761
- }`,m.uniforms.previousShadowMap=this.previousShadowMap,m.uniforms.averagingWindow=this.averagingWindow}}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=this.params.frames;const t=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,i=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1;this.renderer.setRenderTarget(t),this.previousShadowMap.value=i.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.finish(),this.renderer.setRenderTarget(null)}showDebugHelpers(e){if(!this.debugHelpersGroup.children.length){const t=new d.Mesh(new d.PlaneGeometry(2,2),new d.MeshBasicMaterial({map:this.progressiveLightMap1.texture,side:d.DoubleSide}));this.isZUp?t.position.z=this.params.size/2:t.position.y=this.params.size/2;for(const a of this.dirLights){const n=new d.DirectionalLightHelper(a);this.dirLightsHelpers.push(n)}const i=this.isZUp?new d.Vector3(0,0,1):new d.Vector3(0,1,0),s=new d.PlaneHelper(new d.Plane(i,.001),this.params.size,16776960);this.debugHelpersGroup.add(t,s,...this.dirLightsHelpers)}e?(this.progShadowGrp.add(this.debugHelpersGroup),this.dirLightsHelpers.forEach(t=>{t.update()})):this.progShadowGrp.remove(this.debugHelpersGroup)}randomiseLights(){const e=this.lightOrigin.position.length();for(let t=0;t<this.dirLights.length;t++){if(Math.random()>this.params.ambientWeight)this.dirLights[t].position.set(this.lightOrigin.position.x+d.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.y+d.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.z+d.MathUtils.randFloatSpread(this.params.lightRadius));else{const i=Math.acos(2*Math.random()-1)-1.570795,s=2*3.14159*Math.random();this.isZUp?this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.cos(i)*Math.sin(s)*e,Math.abs(Math.sin(i)*e)):this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.abs(Math.cos(i)*Math.sin(s)*e),Math.sin(i)*e)}this.params.debugHelpers&&this.dirLightsHelpers[t].update()}}async recalculate(){this.params.enabled&&(this.clear(),this.framesDone=0,this.fixedCamera=null,this.isRendering=!1)}prepare(){this.lights.forEach(t=>{t.object.intensity=0}),this.meshes.forEach(t=>{t.object.material=this.discardMaterial}),this.autoHiddenObjects.length=0;const e=t=>this.objectsToShowAncestors.has(t);this.scene.traverse(t=>{t!==this.scene&&(this.isExcludedObject(t)||e(t)||t.isLight||t.isCamera||t.visible&&(this.autoHiddenObjects.push({object:t,visible:t.visible}),t.visible=!1))}),this.lightGroup.visible=!0,this.shadowCatcherMesh.material=this.targetMat,this.params.debugHelpers&&this.showDebugHelpers(!1)}finish(){this.lights.forEach(e=>{e.object.intensity=e.intensity}),this.meshes.forEach(e=>{e.object.material=e.material}),this.autoHiddenObjects.forEach(e=>{e.object.visible=e.visible}),this.autoHiddenObjects.length=0,this.lightGroup.visible=!1,this.shadowCatcherMesh.material=this.shadowCatcherMaterial,this.params.debugHelpers&&this.showDebugHelpers(!0)}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.shadowCatcherMesh.material.alphaTest=0,this.updateShadowObjectsList()}updateShadowObjectsList(){this.lights.length=0,this.meshes.length=0,this.objectsToShow.length=0,this.objectsToShowSet.clear(),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.scene.traverse(e=>{if(e!==this.scene){if(this.isExcludedObject(e)){this.addObjectToShow(e);return}if(e===this.progShadowGrp||e===this.lightGroup||e===this.lightOrigin){this.addObjectToShow(e);return}if(e===this.shadowCatcherMesh){this.addObjectToShow(e);return}if(e.isLight&&e.parent!==this.lightGroup){this.lights.push({object:e,intensity:e.intensity});return}e.isGoods||e.isTransformControls||e.geometry&&e!==this.shadowCatcherMesh&&e.castShadow&&(this.meshes.push({object:e,material:e.material}),this.addObjectToShow(e))}}),this.rebuildObjectsToShowAncestors()}addObjectToShow(e){e&&(this.objectsToShowSet.has(e)||(this.objectsToShow.push({object:e,visible:e.visible}),this.objectsToShowSet.add(e)))}rebuildObjectsToShowAncestors(){this.objectsToShowAncestors.clear();const e=t=>{let i=t;for(;i&&!this.objectsToShowAncestors.has(i);)this.objectsToShowAncestors.add(i),i=i.parent};this.objectsToShow.forEach(({object:t})=>{e(t)})}isExcludedObject(e){const t=e;return!!(t.isCSS2DObject||t.isCSS3DObject||t.isHelper||typeof e.type=="string"&&e.type.endsWith("Helper")||typeof e.name=="string"&&e.name.toLowerCase().includes("helper"))}update(e){!this.params||!this.shadowCatcherMesh||!this.progressiveLightMap1||!this.progressiveLightMap2||!this.params.enabled||this.framesDone>=this.params.frames||this.params.paused||!this.shadowCatcherMesh.visible||!this.progShadowGrp.visible||(this.framesDone===0&&(this.fixedCamera=e.clone(),this.isRendering=!0),this.shadowCatcherMesh.material.alphaTest=d.MathUtils.clamp(d.MathUtils.mapLinear(this.framesDone,2,this.params.frames-1,0,this.params.alphaTest),0,1),this.renderOnRenderTargets(this.fixedCamera||e),this.randomiseLights(),this.progress=d.MathUtils.mapLinear(this.framesDone,0,this.params.frames-1,0,100),this.framesDone++,this.framesDone>=this.params.frames&&(this.fixedCamera=null,this.isRendering=!1))}destroy(){this.scene&&this.progShadowGrp&&this.scene.remove(this.progShadowGrp),this.progressiveLightMap1&&(this.progressiveLightMap1.dispose(),this.progressiveLightMap1=null),this.progressiveLightMap2&&(this.progressiveLightMap2.dispose(),this.progressiveLightMap2=null),this.shadowCatcherMaterial&&(this.shadowCatcherMaterial.dispose(),this.shadowCatcherMaterial=null),this.targetMat&&(this.targetMat.dispose(),this.targetMat=null),this.discardMaterial&&(this.discardMaterial.dispose(),this.discardMaterial=null),this.shadowCatcherMesh&&(this.shadowCatcherMesh.geometry&&this.shadowCatcherMesh.geometry.dispose(),this.shadowCatcherMesh=null),this.dirLights.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLights=[],this.dirLightsHelpers.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLightsHelpers=[],this.debugHelpersGroup&&(this.debugHelpersGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this.debugHelpersGroup.clear(),this.debugHelpersGroup=null),this.progShadowGrp&&(this.progShadowGrp.clear(),this.progShadowGrp=null),this.lightGroup&&(this.lightGroup.clear(),this.lightGroup=null),this.lightOrigin&&(this.lightOrigin.clear(),this.lightOrigin=null),this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function Jr(o={},e,t,i=s=>{}){const s=class extends d.ShaderMaterial{constructor(a={}){const n=Object.entries(o);super({uniforms:n.reduce((c,[u,f])=>{const p=d.UniformsUtils.clone({[u]:{value:f}});return{...c,...p}},{}),vertexShader:e,fragmentShader:t}),n.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:u=>this.uniforms[c].value=u})),Object.assign(this,a),i&&i(this)}};return s.key=d.MathUtils.generateUUID(),s}const vc=Jr({transparent:!0,color:new d.Color(0,0,0),alphaTest:0,opacity:1,map:null,depthWrite:!1,toneMapped:!1,blend:2},`varying vec2 vUv;
3761
+ }`,m.uniforms.previousShadowMap=this.previousShadowMap,m.uniforms.averagingWindow=this.averagingWindow}}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=this.params.frames;const t=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,i=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1;this.renderer.setRenderTarget(t),this.previousShadowMap.value=i.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.finish(),this.renderer.setRenderTarget(null)}showDebugHelpers(e){if(!this.debugHelpersGroup.children.length){const t=new f.Mesh(new f.PlaneGeometry(2,2),new f.MeshBasicMaterial({map:this.progressiveLightMap1.texture,side:f.DoubleSide}));this.isZUp?t.position.z=this.params.size/2:t.position.y=this.params.size/2;for(const a of this.dirLights){const n=new f.DirectionalLightHelper(a);this.dirLightsHelpers.push(n)}const i=this.isZUp?new f.Vector3(0,0,1):new f.Vector3(0,1,0),s=new f.PlaneHelper(new f.Plane(i,.001),this.params.size,16776960);this.debugHelpersGroup.add(t,s,...this.dirLightsHelpers)}e?(this.progShadowGrp.add(this.debugHelpersGroup),this.dirLightsHelpers.forEach(t=>{t.update()})):this.progShadowGrp.remove(this.debugHelpersGroup)}randomiseLights(){const e=this.lightOrigin.position.length();for(let t=0;t<this.dirLights.length;t++){if(Math.random()>this.params.ambientWeight)this.dirLights[t].position.set(this.lightOrigin.position.x+f.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.y+f.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.z+f.MathUtils.randFloatSpread(this.params.lightRadius));else{const i=Math.acos(2*Math.random()-1)-1.570795,s=2*3.14159*Math.random();this.isZUp?this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.cos(i)*Math.sin(s)*e,Math.abs(Math.sin(i)*e)):this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.abs(Math.cos(i)*Math.sin(s)*e),Math.sin(i)*e)}this.params.debugHelpers&&this.dirLightsHelpers[t].update()}}async recalculate(){this.params.enabled&&(this.clear(),this.framesDone=0,this.fixedCamera=null,this.isRendering=!1)}prepare(){this.lights.forEach(t=>{t.object.intensity=0}),this.meshes.forEach(t=>{t.object.material=this.discardMaterial}),this.autoHiddenObjects.length=0;const e=t=>this.objectsToShowAncestors.has(t);this.scene.traverse(t=>{t!==this.scene&&(this.isExcludedObject(t)||e(t)||t.isLight||t.isCamera||t.visible&&(this.autoHiddenObjects.push({object:t,visible:t.visible}),t.visible=!1))}),this.lightGroup.visible=!0,this.shadowCatcherMesh.material=this.targetMat,this.params.debugHelpers&&this.showDebugHelpers(!1)}finish(){this.lights.forEach(e=>{e.object.intensity=e.intensity}),this.meshes.forEach(e=>{e.object.material=e.material}),this.autoHiddenObjects.forEach(e=>{e.object.visible=e.visible}),this.autoHiddenObjects.length=0,this.lightGroup.visible=!1,this.shadowCatcherMesh.material=this.shadowCatcherMaterial,this.params.debugHelpers&&this.showDebugHelpers(!0)}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.shadowCatcherMesh.material.alphaTest=0,this.updateShadowObjectsList()}updateShadowObjectsList(){this.lights.length=0,this.meshes.length=0,this.objectsToShow.length=0,this.objectsToShowSet.clear(),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.scene.traverse(e=>{if(e!==this.scene){if(this.isExcludedObject(e)){this.addObjectToShow(e);return}if(e===this.progShadowGrp||e===this.lightGroup||e===this.lightOrigin){this.addObjectToShow(e);return}if(e===this.shadowCatcherMesh){this.addObjectToShow(e);return}if(e.isLight&&e.parent!==this.lightGroup){this.lights.push({object:e,intensity:e.intensity});return}e.isGoods||e.isTransformControls||e.geometry&&e!==this.shadowCatcherMesh&&e.castShadow&&(this.meshes.push({object:e,material:e.material}),this.addObjectToShow(e))}}),this.rebuildObjectsToShowAncestors()}addObjectToShow(e){e&&(this.objectsToShowSet.has(e)||(this.objectsToShow.push({object:e,visible:e.visible}),this.objectsToShowSet.add(e)))}rebuildObjectsToShowAncestors(){this.objectsToShowAncestors.clear();const e=t=>{let i=t;for(;i&&!this.objectsToShowAncestors.has(i);)this.objectsToShowAncestors.add(i),i=i.parent};this.objectsToShow.forEach(({object:t})=>{e(t)})}isExcludedObject(e){const t=e;return!!(t.isCSS2DObject||t.isCSS3DObject||t.isHelper||typeof e.type=="string"&&e.type.endsWith("Helper")||typeof e.name=="string"&&e.name.toLowerCase().includes("helper"))}update(e){!this.params||!this.shadowCatcherMesh||!this.progressiveLightMap1||!this.progressiveLightMap2||!this.params.enabled||this.framesDone>=this.params.frames||this.params.paused||!this.shadowCatcherMesh.visible||!this.progShadowGrp.visible||(this.framesDone===0&&(this.fixedCamera=e.clone(),this.isRendering=!0),this.shadowCatcherMesh.material.alphaTest=f.MathUtils.clamp(f.MathUtils.mapLinear(this.framesDone,2,this.params.frames-1,0,this.params.alphaTest),0,1),this.renderOnRenderTargets(this.fixedCamera||e),this.randomiseLights(),this.progress=f.MathUtils.mapLinear(this.framesDone,0,this.params.frames-1,0,100),this.framesDone++,this.framesDone>=this.params.frames&&(this.fixedCamera=null,this.isRendering=!1))}destroy(){this.scene&&this.progShadowGrp&&this.scene.remove(this.progShadowGrp),this.progressiveLightMap1&&(this.progressiveLightMap1.dispose(),this.progressiveLightMap1=null),this.progressiveLightMap2&&(this.progressiveLightMap2.dispose(),this.progressiveLightMap2=null),this.shadowCatcherMaterial&&(this.shadowCatcherMaterial.dispose(),this.shadowCatcherMaterial=null),this.targetMat&&(this.targetMat.dispose(),this.targetMat=null),this.discardMaterial&&(this.discardMaterial.dispose(),this.discardMaterial=null),this.shadowCatcherMesh&&(this.shadowCatcherMesh.geometry&&this.shadowCatcherMesh.geometry.dispose(),this.shadowCatcherMesh=null),this.dirLights.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLights=[],this.dirLightsHelpers.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLightsHelpers=[],this.debugHelpersGroup&&(this.debugHelpersGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this.debugHelpersGroup.clear(),this.debugHelpersGroup=null),this.progShadowGrp&&(this.progShadowGrp.clear(),this.progShadowGrp=null),this.lightGroup&&(this.lightGroup.clear(),this.lightGroup=null),this.lightOrigin&&(this.lightOrigin.clear(),this.lightOrigin=null),this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function Yr(o={},e,t,i=s=>{}){const s=class extends f.ShaderMaterial{constructor(a={}){const n=Object.entries(o);super({uniforms:n.reduce((c,[u,d])=>{const p=f.UniformsUtils.clone({[u]:{value:d}});return{...c,...p}},{}),vertexShader:e,fragmentShader:t}),n.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:u=>this.uniforms[c].value=u})),Object.assign(this,a),i&&i(this)}};return s.key=f.MathUtils.generateUUID(),s}const cc=Yr({transparent:!0,color:new f.Color(0,0,0),alphaTest:0,opacity:1,map:null,depthWrite:!1,toneMapped:!1,blend:2},`varying vec2 vUv;
3762
3762
  void main() {
3763
3763
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
3764
3764
  vUv = uv;
@@ -3773,7 +3773,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3773
3773
  gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);
3774
3774
  #include <tonemapping_fragment>
3775
3775
  #include <colorspace_fragment>
3776
- }`),_c=Jr({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class yc extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._controls=e}}class xc extends k.ShaderMaterial{get source(){return this.uniforms.source.value}set source(e){this.uniforms.source.value=e}constructor(){super({uniforms:{source:{value:null}},vertexShader:`
3776
+ }`),uc=Yr({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class hc extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._controls=e}}class fc extends B.ShaderMaterial{get source(){return this.uniforms.source.value}set source(e){this.uniforms.source.value=e}constructor(){super({uniforms:{source:{value:null}},vertexShader:`
3777
3777
  void main() {
3778
3778
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3779
3779
  }
@@ -3795,7 +3795,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3795
3795
  }
3796
3796
  gl_FragColor = vec4( 0.0 );
3797
3797
  }
3798
- `})}}class vr extends k.ShaderMaterial{get negative(){return this.uniforms.negative.value===-1}set negative(e){this.uniforms.negative.value=e?-1:1}constructor(){super({uniforms:{negative:{value:1}},vertexShader:`
3798
+ `})}}class hr extends B.ShaderMaterial{get negative(){return this.uniforms.negative.value===-1}set negative(e){this.uniforms.negative.value=e?-1:1}constructor(){super({uniforms:{negative:{value:1}},vertexShader:`
3799
3799
  #include <morphtarget_pars_vertex>
3800
3800
  void main() {
3801
3801
  vec3 transformed = position;
@@ -3807,7 +3807,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3807
3807
  void main() {
3808
3808
  gl_FragColor = vec4( gl_FragCoord.xy, 1e4 * float( negative ), 1 );
3809
3809
  }
3810
- `}),this.morphTargets=!0}}class wc extends k.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get mask(){return this.uniforms.mask.value}set mask(e){this.uniforms.mask.value=e}get thickness(){return this.uniforms.thickness.value}set thickness(e){this.uniforms.thickness.value=e}get inside(){return this.uniforms.inside.value===-1}set inside(e){this.uniforms.inside.value=e?-1:1}get color(){return this.uniforms.color.value}constructor(){super({transparent:!0,uniforms:{map:{value:null},mask:{value:null},color:{value:new k.Color},thickness:{value:5},inside:{value:1}},vertexShader:`
3810
+ `}),this.morphTargets=!0}}class dc extends B.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get mask(){return this.uniforms.mask.value}set mask(e){this.uniforms.mask.value=e}get thickness(){return this.uniforms.thickness.value}set thickness(e){this.uniforms.thickness.value=e}get inside(){return this.uniforms.inside.value===-1}set inside(e){this.uniforms.inside.value=e?-1:1}get color(){return this.uniforms.color.value}constructor(){super({transparent:!0,uniforms:{map:{value:null},mask:{value:null},color:{value:new B.Color},thickness:{value:5},inside:{value:1}},vertexShader:`
3811
3811
  varying vec2 vUv;
3812
3812
  void main() {
3813
3813
  vUv = uv;
@@ -3841,7 +3841,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3841
3841
  }
3842
3842
  #include <colorspace_fragment>
3843
3843
  }
3844
- `})}}class bc extends k.ShaderMaterial{get source(){return this.uniforms.source.value}set source(e){this.uniforms.source.value=e}get mask(){return this.uniforms.mask.value}set mask(e){this.uniforms.mask.value=e}get step(){return this.uniforms.step.value}set step(e){this.uniforms.step.value=e}constructor(){super({uniforms:{source:{value:null},mask:{value:null},step:{value:0}},vertexShader:`
3844
+ `})}}class pc extends B.ShaderMaterial{get source(){return this.uniforms.source.value}set source(e){this.uniforms.source.value=e}get mask(){return this.uniforms.mask.value}set mask(e){this.uniforms.mask.value=e}get step(){return this.uniforms.step.value}set step(e){this.uniforms.step.value=e}constructor(){super({uniforms:{source:{value:null},mask:{value:null},step:{value:0}},vertexShader:`
3845
3845
  varying vec2 vUv;
3846
3846
  void main() {
3847
3847
  vUv = uv;
@@ -3890,7 +3890,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3890
3890
  `}).join("")}
3891
3891
  gl_FragColor = vec4( result, 1.0 );
3892
3892
  }
3893
- `})}}class Ac{constructor(e,t,i,s){this.params={inside:!1,thickness:30,color:new k.Color("#e91e63")},this._selectionLayer=31,this._box=new k.Box3,this._sphere=new k.Sphere,this.renderer=e,this.scene=t,this.camera=i,(s==null?void 0:s.inside)!==void 0&&(this.params.inside=s.inside),(s==null?void 0:s.thickness)!==void 0&&(this.params.thickness=s.thickness),(s==null?void 0:s.color)!==void 0&&(this.params.color=new k.Color(s.color)),this.seedMaterial=new vr,this.seedMaterial.side=k.DoubleSide,this.seedModelMaterial=new vr,this.seedModelMaterial.side=k.DoubleSide,this.maskMaterial=new k.MeshBasicMaterial({color:16777215,side:k.DoubleSide}),this.maskMaterial.morphTargets=!0,this.targets=[new k.WebGLRenderTarget(1,1,{format:k.RGBAFormat,type:k.FloatType,minFilter:k.NearestFilter,magFilter:k.NearestFilter}),new k.WebGLRenderTarget(1,1,{format:k.RGBAFormat,type:k.FloatType,minFilter:k.NearestFilter,magFilter:k.NearestFilter})],this.masks=[new k.WebGLRenderTarget(1,1,{format:k.RedFormat,type:k.UnsignedByteType,minFilter:k.LinearFilter,magFilter:k.LinearFilter,wrapS:k.ClampToEdgeWrapping,wrapT:k.ClampToEdgeWrapping}),new k.WebGLRenderTarget(1,1,{format:k.RedFormat,type:k.UnsignedByteType,minFilter:k.LinearFilter,magFilter:k.LinearFilter,wrapS:k.ClampToEdgeWrapping,wrapT:k.ClampToEdgeWrapping})],this.effectQuad=new Vt.FullScreenQuad(new wc),this.jfaQuad=new Vt.FullScreenQuad(new bc),this.seedQuad=new Vt.FullScreenQuad(this.seedMaterial),this.expandQuad=new Vt.FullScreenQuad(new xc),this.setSize(window.innerWidth,window.innerHeight)}setSize(e,t){const i=this.renderer.getPixelRatio(),s=Math.floor(e*i),a=Math.floor(t*i);this.targets[0].setSize(s,a),this.targets[1].setSize(s,a)}render(e){const t=this.renderer,i=this.scene,s=this.camera,a=this.params;let n=!1;const c=s.layers.mask;if(e){const C=Array.isArray(e)?e:[e];C.length>0&&(n=!0,this._box.makeEmpty(),C.forEach(M=>{if(M)try{this._box.expandByObject(M),M.traverse(I=>{I.layers.enable(this._selectionLayer)})}catch(I){console.log("eee",I)}}),this._box.getBoundingSphere(this._sphere),s.layers.set(this._selectionLayer))}else this._box.setFromObject(i).getBoundingSphere(this._sphere);this.masks[0].setSize(this.targets[0].width,this.targets[0].height),this.masks[1].setSize(this.masks[0].width,this.masks[0].height),i.overrideMaterial=this.maskMaterial,t.setClearColor(0,0),t.setRenderTarget(this.masks[0]),t.clear(),t.render(i,s),i.overrideMaterial=null,t.setRenderTarget(null);for(let C=0;C<4;C++)this.expandQuad.material.source=this.masks[0].texture,t.setRenderTarget(this.masks[1]),this.expandQuad.render(t),t.setRenderTarget(null),this.masks.reverse();this.masks.reverse(),s.updateMatrixWorld();const u=this._sphere.center.clone();u.applyMatrix4(s.matrixWorldInverse);const f=u.z>-this._sphere.radius-s.near;u.x+=this._sphere.radius,u.y+=this._sphere.radius,u.applyMatrix4(s.projectionMatrix);const p=this._sphere.center.clone();p.project(s).multiplyScalar(.5),p.x+=.5,p.y+=.5,p.z=0,u.multiplyScalar(.5),u.x+=.5,u.y+=.5,u.z=0;let{width:r,height:l}=this.targets[0];r/=t.getPixelRatio(),l/=t.getPixelRatio();const h=a.thickness+20,g=Math.max(Math.abs(p.x-u.x)*r,Math.abs(p.y-u.y)*l)*1.5+h;p.x*=r,p.y*=l;const _=p.x-g,m=p.y-g,v=g*2,y=g*2;f||v>=r||y>=l?t.setScissorTest(!1):(t.setScissorTest(!0),t.setScissor(_,m,v,y)),t.setRenderTarget(this.targets[0]),this.seedQuad.material.depthWrite=!1,this.seedQuad.render(t),i.overrideMaterial=this.seedModelMaterial,this.seedModelMaterial.negative=!0,t.autoClear=!1,t.render(i,s),t.autoClear=!0,i.overrideMaterial=null,t.setRenderTarget(null);let x=Math.min(Math.max(this.targets[0].width,this.targets[0].height),a.thickness);for(;this.jfaQuad.material.step=x,this.jfaQuad.material.source=this.targets[0].texture,this.jfaQuad.material.mask=this.masks[1].texture,t.setRenderTarget(this.targets[1]),this.jfaQuad.render(t),t.setRenderTarget(null),this.targets.reverse(),!(x<=1);)x=Math.ceil(x*.5);const w=t.autoClear;t.autoClear=!1;const b=this.effectQuad.material;b.map=this.targets[0].texture;const A=this.targets[0].texture.minFilter,S=this.targets[0].texture.magFilter;this.targets[0].texture.minFilter=k.LinearFilter,this.targets[0].texture.magFilter=k.LinearFilter,this.targets[0].texture.needsUpdate=!0,b.mask=this.masks[1].texture,b.thickness=a.thickness,b.inside=a.inside,b.color.set(a.color),b.transparent=!0,b.blending=k.NormalBlending,b.depthTest=!1,b.depthWrite=!1,this.effectQuad.render(t),this.targets[0].texture.minFilter=A,this.targets[0].texture.magFilter=S,this.targets[0].texture.needsUpdate=!0,t.autoClear=w,t.setScissorTest(!1),n&&e&&((Array.isArray(e)?e:[e]).forEach(M=>{M&&M.traverse(I=>{I.layers.disable(this._selectionLayer)})}),s.layers.mask=c)}}class Tc extends d.Mesh{constructor(e=200,t=20,i=.8){const s=new d.PlaneGeometry(e,e),a=new d.ShaderMaterial({side:d.DoubleSide,transparent:!0,depthWrite:!1,uniforms:{uColor:{value:new d.Color(13619165)},uSize:{value:1},uDistance:{value:e/2},uOpacity:{value:i}},vertexShader:`
3893
+ `})}}class mc{constructor(e,t,i,s){this.params={inside:!1,thickness:30,color:new B.Color("#e91e63")},this._selectionLayer=31,this._box=new B.Box3,this._sphere=new B.Sphere,this.renderer=e,this.scene=t,this.camera=i,(s==null?void 0:s.inside)!==void 0&&(this.params.inside=s.inside),(s==null?void 0:s.thickness)!==void 0&&(this.params.thickness=s.thickness),(s==null?void 0:s.color)!==void 0&&(this.params.color=new B.Color(s.color)),this.seedMaterial=new hr,this.seedMaterial.side=B.DoubleSide,this.seedModelMaterial=new hr,this.seedModelMaterial.side=B.DoubleSide,this.maskMaterial=new B.MeshBasicMaterial({color:16777215,side:B.DoubleSide}),this.maskMaterial.morphTargets=!0,this.targets=[new B.WebGLRenderTarget(1,1,{format:B.RGBAFormat,type:B.FloatType,minFilter:B.NearestFilter,magFilter:B.NearestFilter}),new B.WebGLRenderTarget(1,1,{format:B.RGBAFormat,type:B.FloatType,minFilter:B.NearestFilter,magFilter:B.NearestFilter})],this.masks=[new B.WebGLRenderTarget(1,1,{format:B.RedFormat,type:B.UnsignedByteType,minFilter:B.LinearFilter,magFilter:B.LinearFilter,wrapS:B.ClampToEdgeWrapping,wrapT:B.ClampToEdgeWrapping}),new B.WebGLRenderTarget(1,1,{format:B.RedFormat,type:B.UnsignedByteType,minFilter:B.LinearFilter,magFilter:B.LinearFilter,wrapS:B.ClampToEdgeWrapping,wrapT:B.ClampToEdgeWrapping})],this.effectQuad=new Ot.FullScreenQuad(new dc),this.jfaQuad=new Ot.FullScreenQuad(new pc),this.seedQuad=new Ot.FullScreenQuad(this.seedMaterial),this.expandQuad=new Ot.FullScreenQuad(new fc),this.setSize(window.innerWidth,window.innerHeight)}setSize(e,t){const i=this.renderer.getPixelRatio(),s=Math.floor(e*i),a=Math.floor(t*i);this.targets[0].setSize(s,a),this.targets[1].setSize(s,a)}render(e){const t=this.renderer,i=this.scene,s=this.camera,a=this.params;let n=!1;const c=s.layers.mask;if(e){const C=Array.isArray(e)?e:[e];C.length>0&&(n=!0,this._box.makeEmpty(),C.forEach(M=>{if(M)try{this._box.expandByObject(M),M.traverse(I=>{I.layers.enable(this._selectionLayer)})}catch(I){console.log("eee",I)}}),this._box.getBoundingSphere(this._sphere),s.layers.set(this._selectionLayer))}else this._box.setFromObject(i).getBoundingSphere(this._sphere);this.masks[0].setSize(this.targets[0].width,this.targets[0].height),this.masks[1].setSize(this.masks[0].width,this.masks[0].height),i.overrideMaterial=this.maskMaterial,t.setClearColor(0,0),t.setRenderTarget(this.masks[0]),t.clear(),t.render(i,s),i.overrideMaterial=null,t.setRenderTarget(null);for(let C=0;C<4;C++)this.expandQuad.material.source=this.masks[0].texture,t.setRenderTarget(this.masks[1]),this.expandQuad.render(t),t.setRenderTarget(null),this.masks.reverse();this.masks.reverse(),s.updateMatrixWorld();const u=this._sphere.center.clone();u.applyMatrix4(s.matrixWorldInverse);const d=u.z>-this._sphere.radius-s.near;u.x+=this._sphere.radius,u.y+=this._sphere.radius,u.applyMatrix4(s.projectionMatrix);const p=this._sphere.center.clone();p.project(s).multiplyScalar(.5),p.x+=.5,p.y+=.5,p.z=0,u.multiplyScalar(.5),u.x+=.5,u.y+=.5,u.z=0;let{width:r,height:l}=this.targets[0];r/=t.getPixelRatio(),l/=t.getPixelRatio();const h=a.thickness+20,g=Math.max(Math.abs(p.x-u.x)*r,Math.abs(p.y-u.y)*l)*1.5+h;p.x*=r,p.y*=l;const _=p.x-g,m=p.y-g,v=g*2,y=g*2;d||v>=r||y>=l?t.setScissorTest(!1):(t.setScissorTest(!0),t.setScissor(_,m,v,y)),t.setRenderTarget(this.targets[0]),this.seedQuad.material.depthWrite=!1,this.seedQuad.render(t),i.overrideMaterial=this.seedModelMaterial,this.seedModelMaterial.negative=!0,t.autoClear=!1,t.render(i,s),t.autoClear=!0,i.overrideMaterial=null,t.setRenderTarget(null);let x=Math.min(Math.max(this.targets[0].width,this.targets[0].height),a.thickness);for(;this.jfaQuad.material.step=x,this.jfaQuad.material.source=this.targets[0].texture,this.jfaQuad.material.mask=this.masks[1].texture,t.setRenderTarget(this.targets[1]),this.jfaQuad.render(t),t.setRenderTarget(null),this.targets.reverse(),!(x<=1);)x=Math.ceil(x*.5);const w=t.autoClear;t.autoClear=!1;const b=this.effectQuad.material;b.map=this.targets[0].texture;const A=this.targets[0].texture.minFilter,S=this.targets[0].texture.magFilter;this.targets[0].texture.minFilter=B.LinearFilter,this.targets[0].texture.magFilter=B.LinearFilter,this.targets[0].texture.needsUpdate=!0,b.mask=this.masks[1].texture,b.thickness=a.thickness,b.inside=a.inside,b.color.set(a.color),b.transparent=!0,b.blending=B.NormalBlending,b.depthTest=!1,b.depthWrite=!1,this.effectQuad.render(t),this.targets[0].texture.minFilter=A,this.targets[0].texture.magFilter=S,this.targets[0].texture.needsUpdate=!0,t.autoClear=w,t.setScissorTest(!1),n&&e&&((Array.isArray(e)?e:[e]).forEach(M=>{M&&M.traverse(I=>{I.layers.disable(this._selectionLayer)})}),s.layers.mask=c)}}class gc extends f.Mesh{constructor(e=200,t=20,i=.8){const s=new f.PlaneGeometry(e,e),a=new f.ShaderMaterial({side:f.DoubleSide,transparent:!0,depthWrite:!1,uniforms:{uColor:{value:new f.Color(13619165)},uSize:{value:1},uDistance:{value:e/2},uOpacity:{value:i}},vertexShader:`
3894
3894
  varying vec3 vPos;
3895
3895
  void main() {
3896
3896
  vPos = position;
@@ -3924,9 +3924,9 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3924
3924
  // Combine
3925
3925
  gl_FragColor = vec4(uColor, alpha * fade * uOpacity);
3926
3926
  }
3927
- `});super(s,a),this.position.z=-.02}}const Sc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Mc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Cc="https://cdn2.seer-group.com/libs/fonts.type.json",Rc=new fn.Font(Cc);class ls{constructor(e){var t;this._props=e,this.name="",this._defaults={color:""},this.color="",this.name=this._props.name,this.color=this._defaults.color="#"+((t=e.target.color)==null?void 0:t.getHexString())}change(e){var t;this.color=e,(t=this._props.target.color)==null||t.set(e)}reset(){this.change(this._defaults.color)}}var $r=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))($r||{});const _r=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let at,ui=0,cs=0;const Ic=()=>{at=void 0,ui=0,cs=0},Dc=new d.MeshBasicMaterial({colorWrite:!1});class Lc{constructor(e){this.props=e,this.stats=new Ft,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new ve.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new qr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new d.Group,this._raycaster=new d.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new gt,this.sound=new Ga,this._rafId=null,this._destroyed=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Tc(18,40),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:u,left:f}=this.renderer.domElement.getBoundingClientRect();this.offset.set(f,u),this.mousePos.set(c.clientX-f,c.clientY-u),this.mouseCoord.set((c.clientX-f)/this.size.x*2-1,-((c.clientY-u)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const u=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(u,200)},this._detectTrackpad=()=>{at||typeof at<"u"||(ui===0&&(cs=performance.now()),ui++,performance.now()-cs>66&&(ui>5?at=!0:at=!1,at?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Ic,2e3)))},this.debounceForkHeightChange=Ya(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,u)=>{var K;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(K=this._fitAnimation)==null||K.stop();const f=new d.Box3,p=new d.Box3,r=new d.Vector3,l=new d.Vector3,h=new d.Vector3,g=new d.Vector3,_=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||f.union(p))},m=U=>{var As,Ts;const G=U.geometry,ne=(As=G==null?void 0:G.attributes)==null?void 0:As.position;if(!ne){_(U);return}const te=((Ts=G.morphAttributes)==null?void 0:Ts.position)||[],bs=U.morphTargetInfluences||[],tn=te.length>0&&bs.length>0;for(let Se=0;Se<ne.count;Se++){if(r.set(ne.getX(Se),ne.getY(Se),ne.getZ(Se)),tn){l.set(0,0,0);let xi=0;for(let qe=0;qe<te.length;qe++){const zt=bs[qe]||0;zt&&(xi+=zt,h.set(te[qe].getX(Se),te[qe].getY(Se),te[qe].getZ(Se)),G.morphTargetsRelative,l.addScaledVector(h,zt))}G.morphTargetsRelative?r.add(l):xi>0&&(r.multiplyScalar(1-xi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),f.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(G=>{if(G.visible){if(G instanceof d.Mesh){m(G);return}(G.isPoint||G.isLine)&&_(G)}})}),f.isEmpty())return;const v=new d.Vector3;f.getCenter(v);const y=new d.Vector3;f.getSize(y);const x=v.clone();this._lastTarget.copy(x);let w;u?w=u.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),A=[new d.Vector3(b.x,b.y,b.z),new d.Vector3(b.x,b.y,-b.z),new d.Vector3(b.x,-b.y,b.z),new d.Vector3(b.x,-b.y,-b.z),new d.Vector3(-b.x,b.y,b.z),new d.Vector3(-b.x,b.y,-b.z),new d.Vector3(-b.x,-b.y,b.z),new d.Vector3(-b.x,-b.y,-b.z)],S=new d.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const C=new d.Vector3().crossVectors(w,S).normalize(),M=new d.Vector3().crossVectors(C,w).normalize();let I=0;A.forEach(U=>{const G=U.dot(C),ne=U.dot(M),te=Math.sqrt(G*G+ne*ne);I=Math.max(I,te)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,T=2*Math.atan(Math.tan(D/2)*this.camera.aspect),R=I/Math.tan(T/2),L=I/Math.tan(D/2),F=Math.max(R,L),E=v.clone().add(w.multiplyScalar(F)),z=this.camera.position.clone(),N=this.controls.target.clone();let j=500;const Z=z.distanceTo(E)+N.distanceTo(x);Z>.001&&(j=Math.min(1e3,Math.max(450,Z*45))),this._animateCamera(z,E,N,x,j)},this.focusSlots=c=>{var M,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const T=this.camera.position.clone(),R=this.controls.target.clone(),L=D.position.clone(),F=D.target.clone();let E=500;const z=T.distanceTo(L)+R.distanceTo(F);z>.001&&(E=Math.min(1e3,Math.max(450,z*45))),this._animateCamera(T,L,R,F,E,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(M=this._fitAnimation)!=null&&M.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const u=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const T=new d.Vector3;return D.parent.getWorldPosition(T),[T]});if(!u.length)return;const f=u.reduce((D,T)=>D.add(T),new d.Vector3).multiplyScalar(1/u.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of u){const T=D.clone().sub(f),R=T.dot(r),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>l&&(l=L)}l=l+.4;const h=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(h/2)*this.camera.aspect),_=l/Math.tan(g/2),m=l/Math.tan(h/2),v=Math.max(_,m),y=f.clone(),x=f.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),A={t:0};let S=500;const C=w.distanceTo(x)+b.distanceTo(y);C>.001&&(S=Math.min(1e3,Math.max(450,C*45))),this._lastTarget=y.clone(),this._fitAnimation=new fi(A).to({t:1},S).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=A.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new d.Box3().setFromObject(this._container);const u=this.amr.sizeBox.size.getSize(new d.Vector3),f=u.clone().multiplyScalar(.5),p=new d.Vector3(0,0,f.z);this._lastTarget.copy(p);let r=f.clone().sub(p);r.lengthSq()<1e-6&&(r=new d.Vector3(1,0,0));const l=r.clone().normalize(),h=u.clone().multiplyScalar(.5),g=[new d.Vector3(h.x,h.y,h.z),new d.Vector3(h.x,h.y,-h.z),new d.Vector3(h.x,-h.y,h.z),new d.Vector3(h.x,-h.y,-h.z),new d.Vector3(-h.x,h.y,h.z),new d.Vector3(-h.x,h.y,-h.z),new d.Vector3(-h.x,-h.y,h.z),new d.Vector3(-h.x,-h.y,-h.z)];let _=0;for(const T of g){const R=T.dot(l),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>_&&(_=L)}_=_*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=_/Math.tan(v/2),x=_/Math.tan(m/2),w=Math.max(y,x),b=f.clone();let A=u.z/3;u.z<u.x&&u.z<u.y&&(A=u.x*.8),u.z>u.x&&u.z>u.y&&(A=0),b.z+=A;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(u.x*2,5);const C=this.camera.position.clone(),M=this.controls.target.clone();let I=600;const D=C.distanceTo(S)+M.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(C,S,M,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const u=c.clientWidth,f=c.clientHeight;this.size.set(u,f),this.camera.aspect=u/f,this.camera.updateProjectionMatrix(),this._amrRender.setSize(u,f),this._updateCamera(),this.css2dRenderer.setSize(u,f),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(u,f),(r=this._jumpFlood)==null||r.setSize(u,f)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const u=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Dc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=u}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Fe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Br(Ne,this.renderer),this._ground.visible=!1,this.controls=new hn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=_r,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:Ur()?.2:1,this._cameraPositionUI=new yc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=ja();this.pathTracer=new oa(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new pc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,u=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=u};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new gc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),this._progressShadow.lightOrigin.position.set(3,2.5,6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Ac(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new mc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new d.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new Ms.HDRLoader().load(Mc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:_r,this.sampleCount=0}get fpsAverage(){return Vr(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof d.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new Ms.HDRLoader().load(Sc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new d.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let f=0;f<t;f++){const p=((i-u-1)*t+f)*4,r=(u*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new en({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){_e(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await Hr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,a,n){var u;const c={t:0};(u=this._fitAnimation)==null||u.stop(),this._fitAnimation=new fi(c).to({t:1},a).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const f=c.t;this.controls.target.lerpVectors(i,s,f);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),h=r.length(),g=l.length(),_=h+(g-h)*f;let m;if(h>.001&&g>.001){const v=r.clone().normalize(),y=l.clone().normalize(),x=v.angleTo(y);if(x>.001){const w=new d.Vector3().crossVectors(v,y);if(w.lengthSq()>.001){w.normalize();const b=new d.Quaternion().setFromAxisAngle(w,x*f),A=v.clone().applyQuaternion(b);m=p.clone().add(A.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=e.clone().lerp(t,f);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
3927
+ `});super(s,a),this.position.z=-.02}}const vc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",_c="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",yc="https://cdn2.seer-group.com/libs/fonts.type.json",xc=new ln.Font(yc);class ss{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof f.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof f.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof f.MeshStandardMaterial);if(this._props.target.material instanceof f.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var Zr=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))(Zr||{});const fr=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let nt,li=0,rs=0;const wc=()=>{nt=void 0,li=0,rs=0},bc=new f.MeshBasicMaterial({colorWrite:!1});class Ac{constructor(e){this.props=e,this.stats=new Lt,this.scene=new f.Scene,this.overlayScene=new f.Scene,this.renderer=new f.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new me.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new Wr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new f.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new f.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new f.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new f.Group,this._raycaster=new f.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new pt,this.sound=new ka,this._rafId=null,this._destroyed=!1,this._ground=new f.Mesh(new f.PlaneGeometry(100,100),new f.MeshPhysicalMaterial({color:new f.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new gc(18,40),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._lastTarget=new f.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:u,left:d}=this.renderer.domElement.getBoundingClientRect();this.offset.set(d,u),this.mousePos.set(c.clientX-d,c.clientY-u),this.mouseCoord.set((c.clientX-d)/this.size.x*2-1,-((c.clientY-u)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const u=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(u,200)},this._detectTrackpad=()=>{nt||typeof nt<"u"||(li===0&&(rs=performance.now()),li++,performance.now()-rs>66&&(li>5?nt=!0:nt=!1,nt?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(wc,2e3)))},this.debounceForkHeightChange=Ua(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,u)=>{var K;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(K=this._fitAnimation)==null||K.stop();const d=new f.Box3,p=new f.Box3,r=new f.Vector3,l=new f.Vector3,h=new f.Vector3,g=new f.Vector3,_=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||d.union(p))},m=U=>{var vs,_s;const G=U.geometry,re=(vs=G==null?void 0:G.attributes)==null?void 0:vs.position;if(!re){_(U);return}const te=((_s=G.morphAttributes)==null?void 0:_s.position)||[],gs=U.morphTargetInfluences||[],Xr=te.length>0&&gs.length>0;for(let Ae=0;Ae<re.count;Ae++){if(r.set(re.getX(Ae),re.getY(Ae),re.getZ(Ae)),Xr){l.set(0,0,0);let gi=0;for(let Ne=0;Ne<te.length;Ne++){const kt=gs[Ne]||0;kt&&(gi+=kt,h.set(te[Ne].getX(Ae),te[Ne].getY(Ae),te[Ne].getZ(Ae)),G.morphTargetsRelative,l.addScaledVector(h,kt))}G.morphTargetsRelative?r.add(l):gi>0&&(r.multiplyScalar(1-gi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),d.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(G=>{if(G.visible){if(G instanceof f.Mesh){m(G);return}(G.isPoint||G.isLine)&&_(G)}})}),d.isEmpty())return;const v=new f.Vector3;d.getCenter(v);const y=new f.Vector3;d.getSize(y);const x=v.clone();this._lastTarget.copy(x);let w;u?w=u.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),A=[new f.Vector3(b.x,b.y,b.z),new f.Vector3(b.x,b.y,-b.z),new f.Vector3(b.x,-b.y,b.z),new f.Vector3(b.x,-b.y,-b.z),new f.Vector3(-b.x,b.y,b.z),new f.Vector3(-b.x,b.y,-b.z),new f.Vector3(-b.x,-b.y,b.z),new f.Vector3(-b.x,-b.y,-b.z)],S=new f.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const C=new f.Vector3().crossVectors(w,S).normalize(),M=new f.Vector3().crossVectors(C,w).normalize();let I=0;A.forEach(U=>{const G=U.dot(C),re=U.dot(M),te=Math.sqrt(G*G+re*re);I=Math.max(I,te)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,T=2*Math.atan(Math.tan(D/2)*this.camera.aspect),R=I/Math.tan(T/2),L=I/Math.tan(D/2),F=Math.max(R,L),E=v.clone().add(w.multiplyScalar(F)),z=this.camera.position.clone(),N=this.controls.target.clone();let j=500;const Z=z.distanceTo(E)+N.distanceTo(x);Z>.001&&(j=Math.min(1e3,Math.max(450,Z*45))),this._animateCamera(z,E,N,x,j)},this.focusSlots=c=>{var M,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const T=this.camera.position.clone(),R=this.controls.target.clone(),L=D.position.clone(),F=D.target.clone();let E=500;const z=T.distanceTo(L)+R.distanceTo(F);z>.001&&(E=Math.min(1e3,Math.max(450,z*45))),this._animateCamera(T,L,R,F,E,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(M=this._fitAnimation)!=null&&M.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new f.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const u=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const T=new f.Vector3;return D.parent.getWorldPosition(T),[T]});if(!u.length)return;const d=u.reduce((D,T)=>D.add(T),new f.Vector3).multiplyScalar(1/u.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of u){const T=D.clone().sub(d),R=T.dot(r),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>l&&(l=L)}l=l+.4;const h=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(h/2)*this.camera.aspect),_=l/Math.tan(g/2),m=l/Math.tan(h/2),v=Math.max(_,m),y=d.clone(),x=d.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),A={t:0};let S=500;const C=w.distanceTo(x)+b.distanceTo(y);C>.001&&(S=Math.min(1e3,Math.max(450,C*45))),this._lastTarget=y.clone(),this._fitAnimation=new ci(A).to({t:1},S).easing(Le.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=A.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new f.Box3().setFromObject(this._container);const u=this.amr.sizeBox.size.getSize(new f.Vector3),d=u.clone().multiplyScalar(.5),p=new f.Vector3(0,0,d.z);this._lastTarget.copy(p);let r=d.clone().sub(p);r.lengthSq()<1e-6&&(r=new f.Vector3(1,0,0));const l=r.clone().normalize(),h=u.clone().multiplyScalar(.5),g=[new f.Vector3(h.x,h.y,h.z),new f.Vector3(h.x,h.y,-h.z),new f.Vector3(h.x,-h.y,h.z),new f.Vector3(h.x,-h.y,-h.z),new f.Vector3(-h.x,h.y,h.z),new f.Vector3(-h.x,h.y,-h.z),new f.Vector3(-h.x,-h.y,h.z),new f.Vector3(-h.x,-h.y,-h.z)];let _=0;for(const T of g){const R=T.dot(l),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>_&&(_=L)}_=_*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=_/Math.tan(v/2),x=_/Math.tan(m/2),w=Math.max(y,x),b=d.clone();let A=u.z/3;u.z<u.x&&u.z<u.y&&(A=u.x*.8),u.z>u.x&&u.z>u.y&&(A=0),b.z+=A;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(u.x*2,5);const C=this.camera.position.clone(),M=this.controls.target.clone();let I=600;const D=C.distanceTo(S)+M.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(C,S,M,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const u=c.clientWidth,d=c.clientHeight;this.size.set(u,d),this.camera.aspect=u/d,this.camera.updateProjectionMatrix(),this._amrRender.setSize(u,d),this._updateCamera(),this.css2dRenderer.setSize(u,d),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(u,d),(r=this._jumpFlood)==null||r.setSize(u,d)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const u=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=bc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=u}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const d=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(d)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Le.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Pr(We,this.renderer),this._ground.visible=!1,this.controls=new an.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=fr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:kr()?.2:1,this._cameraPositionUI=new hc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=f.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=f.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=za();this.pathTracer=new ea(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new oc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,u=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=u};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new lc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),this._progressShadow.lightOrigin.position.set(3,2.5,6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new mc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new ac(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new f.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new f.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new xs.HDRLoader().load(_c,t=>{t.mapping=f.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:fr,this.sampleCount=0}get fpsAverage(){return Br(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof f.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new xs.HDRLoader().load(vc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new f.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new f.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let d=0;d<t;d++){const p=((i-u-1)*t+d)*4,r=(u*t+d)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new Kr({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){ge(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await zr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof f.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,a,n){var u;const c={t:0};(u=this._fitAnimation)==null||u.stop(),this._fitAnimation=new ci(c).to({t:1},a).easing(Le.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const d=c.t;this.controls.target.lerpVectors(i,s,d);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),h=r.length(),g=l.length(),_=h+(g-h)*d;let m;if(h>.001&&g>.001){const v=r.clone().normalize(),y=l.clone().normalize(),x=v.angleTo(y);if(x>.001){const w=new f.Vector3().crossVectors(v,y);if(w.lengthSq()>.001){w.normalize();const b=new f.Quaternion().setFromAxisAngle(w,x*d),A=v.clone().applyQuaternion(b);m=p.clone().add(A.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=e.clone().lerp(t,d);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
3928
3928
  -webkit-user-select: none;
3929
3929
  user-select: none;
3930
3930
  touch-action: none;
3931
3931
  -webkit-touch-callout: none;
3932
- `):e.style.background="radial-gradient(326% 141% at 50% 103%, #E0E0E0 0%, #D9D9D9 38%, #C2C2C2 47%, #C2C2C2 52%, #F0F0F0 100%)",this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,a,n,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(a=this._sciFiGrid.material)==null||a.dispose(),Fe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),_e(this.scene),this.scene.clear()}}class en{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,n,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const A=this.configureCamera(w,b,f,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const S=this.readPixels(t,r,a,n);h[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,n=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),S=Math.max(Math.tan(A/2),1e-4),C=Math.max(S*(i||1),1e-4),M=this.getPerspectiveDirection(t,e.size).normalize(),I=new d.Vector3().crossVectors(M,u).normalize();I.lengthSq()<1e-6&&I.set(1,0,0);const D=new d.Vector3().crossVectors(I,M).normalize(),T=Math.max(e.size.x*.5,1e-4),R=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),F=[new d.Vector3(-T,-R,-L),new d.Vector3(-T,-R,L),new d.Vector3(-T,R,-L),new d.Vector3(-T,R,L),new d.Vector3(T,-R,-L),new d.Vector3(T,-R,L),new d.Vector3(T,R,-L),new d.Vector3(T,R,L)];let E=0,z=-1/0;for(const Z of F){const K=I.dot(Z),U=D.dot(Z),G=M.dot(Z);z=Math.max(z,G);const ne=G+Math.abs(K)/C,te=G+Math.abs(U)/S;E=Math.max(E,ne,te)}E=Math.max(E,z+.1);const N=E*(1+s);let j=1/0;for(const Z of F){const K=M.dot(Z),U=N-K;U>.001&&(j=Math.min(j,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(j)?j*.5:N*.1),w.far=Math.max(w.near+1,N+e.sphere.radius*3),w.position.copy(e.center).add(M.clone().multiplyScalar(N)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const y=_*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new d.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(n,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,0,0),n.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Pc="shop-components",Fc="0.4.14",Ec="Shop components",kc="dist/shop-components.umd.js",Bc="dist/shop-components.mjs",Oc="dist/main.d.ts",zc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build",v:"auto-changelog -p && git add CHANGELOG.md"},Vc=["dist","package.json"],Uc=[],Wc="machengda<machengda@seer-group.com>",Hc="ISC",Nc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Gc={"string-width":"4.2.3"},qc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"^0.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},jc={name:Pc,version:Fc,description:Ec,main:kc,module:Bc,types:Oc,scripts:zc,files:Vc,keywords:Uc,author:Wc,license:Hc,devDependencies:Nc,resolutions:Gc,dependencies:qc};function yr(){const o="Nebula Engin",e=jc.version,t=`%c ${o} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const xr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[xr]||(o[xr]=!0,yr())}catch{yr()}exports.Amr=qr;exports.Logo=Ji;exports.SGLBLoader=Bt;exports.SLOT_EVENTS=Y;exports.Scene3D=Lc;exports.Skin=ls;exports.Slot=Xi;exports.SlotState=$r;exports.TriViewCapture=en;exports.arrayBufferToUrl=Zi;exports.calculateArrayAverage=Vr;exports.calculateFocalLength=Ha;exports.createSGLBFile=Ja;exports.downloadBlob=Wa;exports.dracoExporter=Xa;exports.font=Rc;exports.gltfExporter=Hr;exports.gltfLoader=Ne;exports.imageBitmapToUrl=Ki;exports.isAppleDevice=Ur;exports.textureLoader=_s;
3932
+ `):e.style.background="radial-gradient(326% 141% at 50% 103%, #E0E0E0 0%, #D9D9D9 38%, #C2C2C2 47%, #C2C2C2 52%, #F0F0F0 100%)",this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,a,n,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(a=this._sciFiGrid.material)==null||a.dispose(),Le.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),ge(this.scene),this.scene.clear()}}class Kr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new f.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new f.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new f.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,d=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new f.WebGLRenderTarget(a,n,{format:f.RGBAFormat,type:f.UnsignedByteType});r.texture.colorSpace=f.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const A=this.configureCamera(w,b,d,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const S=this.readPixels(t,r,a,n);h[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new f.Vector3(0,0,1),up:new f.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new f.Vector3(0,-1,0),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new f.Vector3(1,0,0),up:new f.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new f.Vector3(1,1,1),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new f.Box3,i=new f.Box3,s=new f.Vector3,a=new f.Vector3,n=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const d=c.geometry;if(!d)return;d.boundingBox||d.computeBoundingBox();const p=d.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=f.MathUtils.degToRad(b),S=Math.max(Math.tan(A/2),1e-4),C=Math.max(S*(i||1),1e-4),M=this.getPerspectiveDirection(t,e.size).normalize(),I=new f.Vector3().crossVectors(M,u).normalize();I.lengthSq()<1e-6&&I.set(1,0,0);const D=new f.Vector3().crossVectors(I,M).normalize(),T=Math.max(e.size.x*.5,1e-4),R=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),F=[new f.Vector3(-T,-R,-L),new f.Vector3(-T,-R,L),new f.Vector3(-T,R,-L),new f.Vector3(-T,R,L),new f.Vector3(T,-R,-L),new f.Vector3(T,-R,L),new f.Vector3(T,R,-L),new f.Vector3(T,R,L)];let E=0,z=-1/0;for(const Z of F){const K=I.dot(Z),U=D.dot(Z),G=M.dot(Z);z=Math.max(z,G);const re=G+Math.abs(K)/C,te=G+Math.abs(U)/S;E=Math.max(E,re,te)}E=Math.max(E,z+.1);const N=E*(1+s);let j=1/0;for(const Z of F){const K=M.dot(Z),U=N-K;U>.001&&(j=Math.min(j,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(j)?j*.5:N*.1),w.far=Math.max(w.near+1,N+e.sphere.radius*3),w.position.copy(e.center).add(M.clone().multiplyScalar(N)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const y=_*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new f.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new f.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),d=Math.max(t.z,.001),p=Math.max(n,s.z),r=d*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new f.Vector2;e.getSize(t);const i=new f.Vector4;e.getViewport(i);const s=new f.Vector4;e.getScissor(s);const a=e.getClearColor(new f.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new f.Color);e.setClearColor(a,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const a=e.getClearColor(new f.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const u=c.createImageData(i,s),d=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;d.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,0,0),n.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Tc="shop-components",Sc="0.4.15",Mc="Shop components",Cc="dist/shop-components.umd.js",Rc="dist/shop-components.mjs",Ic="dist/main.d.ts",Dc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build","build:web":"BUILD_WEB=1 vite build --outDir dist/web --emptyOutDir",v:"auto-changelog -p && git add CHANGELOG.md"},Lc=["dist","package.json"],Pc=[],Fc="machengda<machengda@seer-group.com>",Ec="ISC",Bc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},kc={"string-width":"4.2.3"},Oc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"^0.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},zc={name:Tc,version:Sc,description:Mc,main:Cc,module:Rc,types:Ic,scripts:Dc,files:Lc,keywords:Pc,author:Fc,license:Ec,devDependencies:Bc,resolutions:kc,dependencies:Oc};function dr(){const o="Nebula Engin",e=zc.version,t=`%c ${o} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const pr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[pr]||(o[pr]=!0,dr())}catch{dr()}exports.Amr=Wr;exports.Logo=Qi;exports.SGLBLoader=Et;exports.SLOT_EVENTS=Y;exports.Scene3D=Ac;exports.Skin=ss;exports.Slot=ji;exports.SlotState=Zr;exports.TriViewCapture=Kr;exports.arrayBufferToUrl=Gi;exports.calculateArrayAverage=Br;exports.calculateFocalLength=Ea;exports.createSGLBFile=Ga;exports.downloadBlob=Fa;exports.dracoExporter=Na;exports.font=xc;exports.gltfExporter=zr;exports.gltfLoader=We;exports.imageBitmapToUrl=qi;exports.isAppleDevice=kr;exports.textureLoader=fs;