@needle-tools/engine 2.56.0-pre → 2.56.2-pre

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.
@@ -6709,7 +6709,7 @@ void main() {
6709
6709
  See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`);break}})();return t.renderOrder=1/0,t.onBeforeRender=function(){e.updateClippingPlanes&&e.updateClippingPlanes()},t}getGlyphDimensions(e){switch(e.textType){case"MSDF":return cU.getGlyphDimensions(e);default:console.warn(`'${e.textType}' is not a supported text type.
6710
6710
  See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`);break}}getGlyphPairKerning(e,t,i){switch(e){case"MSDF":return cU.getGlyphPairKerning(t,i);default:console.warn(`'${e}' is not a supported text type.
6711
6711
  See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`);break}}}}function dT(I){I.children.forEach(A=>{A.children.length>0&&dT(A),I.remove(A),es.disposeOf(A),A.material&&A.material.dispose(),A.geometry&&A.geometry.dispose()}),I.children=[]}var d8=dT,wu=class extends _c.withBase(Te.Object3D)(hT,h8,NU,Oy){constructor(A){super(A),this.isText=!0,this.set(A)}parseParams(){this.calculateInlines(this._fitFontSize||this.getFontSize())}updateLayout(){d8(this),this.inlines&&(this.textContent=this.createText(),this.updateTextMaterial(),this.add(this.textContent)),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.textContent&&this.updateTextMaterial()}calculateInlines(A){let e=this.content,t=this.getFontFamily(),i=this.getBreakOn(),g=this.getTextType(),o=this.getWhiteSpace();if(!t||typeof t=="string"){Du.getFontOf(this)||console.warn("no font was found");return}if(!this.content){this.inlines=null;return}if(!g){console.error(`You must provide a 'textType' attribute so three-mesh-ui knows how to render your text.
6712
- See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`);return}let n=IT(e,o),C=Array.from?Array.from(n):String(n).split(""),s=A/t.info.size,r=t.common.lineHeight*s,a=t.common.base*s,B=C.map(Q=>{let l=this.getGlyphDimensions({textType:g,glyph:Q,font:t,fontSize:A}),E=null;return o!==Oc&&(i.includes(Q)||Q.match(/\s/g))&&(E="possible"),Q.match(/\n/g)&&(E=oT(o)),{height:l.height,width:l.width,anchor:l.anchor,xadvance:l.xadvance,xoffset:l.xoffset,lineBreak:E,glyph:Q,fontSize:A,lineHeight:r,lineBase:a}});if(this.getFontKerning()!=="none")for(let Q=1;Q<B.length;Q++){let l=B[Q],E=B[Q-1].glyph+B[Q].glyph,c=this.getGlyphPairKerning(g,t,E);l.kerning=c*(A/t.info.size)}this.inlines=B}},yu=class extends _c.withBase(Te.Object3D)(hT,kU,cT,NU,Oy){constructor(A){super(A),this.isInlineBlock=!0,this.size=new Te.Vector2(1,1),this.frame=new Jy(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(A)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){let A=this.getWidth(),e=this.getHeight();if(this.inlines){let t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(A,e),this.frame.scale.set(A,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}},Nr={fr:[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],eng:[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],ru:[[[{width:1/12,chars:[{lowerCase:"\u0439",upperCase:"\u0419"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"\u0446",upperCase:"\u0426"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"\u0443",upperCase:"\u0423"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"\u043A",upperCase:"\u041A"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"\u0435",upperCase:"\u0415"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"\u043D",upperCase:"\u041D"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"\u0433",upperCase:"\u0413"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"\u0448",upperCase:"\u0428"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"\u0449",upperCase:"\u0429"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"\u0437",upperCase:"\u0417"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"\u0445",upperCase:"\u0425"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"\u044A",upperCase:"\u042A"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"\u0444",upperCase:"\u0424"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"\u044B",upperCase:"\u042B"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"\u0432",upperCase:"\u0412"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"\u0430",upperCase:"\u0410"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"\u043F",upperCase:"\u041F"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"\u0440",upperCase:"\u0420"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"\u043E",upperCase:"\u041E"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"\u043B",upperCase:"\u041B"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"\u0434",upperCase:"\u0414"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"\u0436",upperCase:"\u0416"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"\u044D",upperCase:"\u042D"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"\u0451",upperCase:"\u0401"},{lowerCase:"|",upperCase:"\\"}]}],[{width:1.5/12,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"\u044F",upperCase:"\u042F"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"\u0447",upperCase:"\u0427"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"\u0441",upperCase:"\u0421"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"\u043C",upperCase:"\u041C"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"\u0438",upperCase:"\u0418"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"\u0442",upperCase:"\u0422"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"\u044C",upperCase:"\u042C"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"\u0431",upperCase:"\u0411"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"\u044E",upperCase:"\u042E"},{lowerCase:".",upperCase:""}]},{width:1.5/12,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"\u0410\u0411\u0412"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],de:[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"\xFC",upperCase:"\xDC"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"\xF6",upperCase:"\xD6"}]},{width:1/11,chars:[{lowerCase:"\xE4",upperCase:"\xC4"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],es:[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"\xF1",upperCase:"\xD1"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],el:[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"\u03C2",upperCase:"\u03C2"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"\u03B5",upperCase:"\u0395"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"\u03C1",upperCase:"\u03A1"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"\u03C4",upperCase:"\u03A4"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"\u03C5",upperCase:"\u03A5"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"\u03B8",upperCase:"\u0398"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"\u03B9",upperCase:"\u0399"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"\u03BF",upperCase:"\u039F"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"\u03C0",upperCase:"\u03A0"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"\u03B1",upperCase:"\u0391"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"\u03C3",upperCase:"\u03A3"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"\u03B4",upperCase:"\u0394"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"\u03C6",upperCase:"\u03A6"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"\u03B3",upperCase:"\u0393"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"\u03B7",upperCase:"\u0397"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"\u03BE",upperCase:"\u039E"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"\u03BA",upperCase:"\u039A"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"\u03BB",upperCase:"\u039B"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"\u03B6",upperCase:"\u0396"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"\u03C7",upperCase:"\u03A7"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"\u03C8",upperCase:"\u03A8"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"\u03C9",upperCase:"\u03A9"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"\u03B2",upperCase:"\u0392"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"\u03BD",upperCase:"\u039D"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"\u03BC",upperCase:"\u039C"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],nord:[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"\xE5",upperCase:"\xC5"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"\xE6",upperCase:"\xC6"}]},{width:1/11,chars:[{lowerCase:"\xF8",upperCase:"\xD8"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]]},u8=new Te.TextureLoader,qy=class extends _c.withBase(Te.Object3D)(kU,Oy){constructor(A){A||(A={}),A.width||(A.width=1),A.height||(A.height=.4),A.margin||(A.margin=.003),A.padding||(A.padding=.01),super(A),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1;let e;if(A.language||navigator.language)switch(A.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Nr.fr;break;case"ru":this.charsetCount=2,e=Nr.ru;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Nr.de;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Nr.es;break;case"el":this.charsetCount=2,e=Nr.el;break;case"nord":e=Nr.nord;break;default:e=Nr.eng;break}else e=Nr.eng;this.keys=[],this.panels=e.map(t=>{let i=A.height/t.length-A.margin*2,g=new bB({width:A.width+A.padding*2,height:A.height+A.padding*2,offset:0,padding:A.padding,fontFamily:A.fontFamily,fontTexture:A.fontTexture,backgroundColor:A.backgroundColor,backgroundOpacity:A.backgroundOpacity});return g.charset=0,g.add(...t.map(o=>{let n=new bB({width:A.width,height:i,margin:A.margin,contentDirection:"row",justifyContent:"center"});n.frame.visible=!1;let C=[];return o.forEach(s=>{let r=new bB({width:A.width*s.width-A.margin*2,height:i,margin:A.margin,justifyContent:"center",offset:0}),a=s.chars[g.charset].lowerCase||s.chars[g.charset].icon||"undif";if(a==="enter"&&A.enterTexture||a==="shift"&&A.shiftTexture||a==="backspace"&&A.backspaceTexture){let B=(()=>{switch(a){case"backspace":return A.backspaceTexture;case"enter":return A.enterTexture;case"shift":return A.shiftTexture;default:console.warn("There is no icon image for this key")}})();u8.load(B,Q=>{r.add(new yu({width:r.width*.65,height:r.height*.65,backgroundSize:"contain",backgroundTexture:Q}))})}else r.add(new wu({content:a,offset:0}));r.type="Key",r.info=s,r.info.input=a,r.panel=g,C.push(r),this.keys.push(r)}),n.add(...C),n})),g}),this.add(this.panels[0]),this.set(A)}setNextPanel(){this.panels.forEach(A=>{this.remove(A)}),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach(A=>{if(!this.panels[this.currentPanel].getObjectById(A.id))return;let t=A.info.chars[A.panel.charset]||A.info.chars[0],i=this.isLowerCase||!t.upperCase?t.lowerCase:t.upperCase;if(!A.childrenTexts.length)return;let g=A.childrenTexts[0];A.info.input=i,g.set({content:i}),g.update(!0,!0,!0)})}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach(A=>{let e=A.info.chars[A.panel.charset]||A.info.chars[0],t=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!A.childrenTexts.length)return;let i=A.childrenTexts[0];A.info.input=t,i.set({content:t}),i.update(!0,!0,!0)})}parseParams(){}updateLayout(){}updateInner(){}},uT=()=>es.update(),pT={Block:bB,Text:wu,InlineBlock:yu,Keyboard:qy,FontLibrary:Du,update:uT,TextAlign:Ty,Whitespace:vy,JustifyContent:Ly,AlignItems:xy,ContentDirection:by};typeof global<"u"&&(global.ThreeMeshUI=pT);var p8=pT,f8=KI.g1,mu=KI.gO,D8=KI.km,w8=KI.zV,y8=KI.ol,S8=KI.uM,KU=KI.N1,JU=KI.xv,m8=KI.PH,M8=KI.UH,G8=KI.ZP,qU=KI.Vx;var Py=class{static createButton(A,e={}){let t=document.createElement("button"),i=!1;function g(){if(e.domOverlay===void 0){var s=document.createElement("div");s.style.display="none",document.body.appendChild(s);var r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width",38),r.setAttribute("height",38),r.style.position="absolute",r.style.right="20px",r.style.top="20px",r.addEventListener("click",function(){B.end()}),s.appendChild(r);var a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),a.setAttribute("stroke","#fff"),a.setAttribute("stroke-width",2),r.appendChild(a),e.optionalFeatures===void 0&&(e.optionalFeatures=[]),e.optionalFeatures.push("dom-overlay"),e.domOverlay={root:s},i=!0}e.optionalFeatures===void 0&&(e.optionalFeatures=[]),e.optionalFeatures.push("local-floor"),e.optionalFeatures.push("hand-tracking"),e.optionalFeatures.push("layers");let B=null,Q=null;async function l(c){if(/WebXRViewer\//i.test(navigator.userAgent))if(e.domOverlay?.root){let p=e.domOverlay.root;Q=p.parentElement,Q&&(console.log("Reparent DOM Overlay to body",p,p.style.display),p.style.display="",p.style.visibility="",document.body.appendChild(p))}else console.warn("WebXRViewer: No DOM Overlay found");c.addEventListener("end",E),await A.xr.setSession(c),t.textContent="STOP AR",i&&(e.domOverlay.root.style.display=""),B=c}function E(){B.removeEventListener("end",E),t.textContent="START AR",Q&&Q.appendChild(e.domOverlay.root),i&&(e.domOverlay.root.style.display="none"),B=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="START AR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){B===null?navigator.xr.requestSession("immersive-ar",e).then(l):B.end()}}function o(){t.disabled=!0,t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function n(){o(),t.textContent="AR NOT SUPPORTED"}function C(s){s.style.position="absolute",s.style.bottom="20px",s.style.padding="12px 6px",s.style.border="1px solid #fff",s.style.borderRadius="4px",s.style.background="rgba(0,0,0,0.1)",s.style.color="#fff",s.style.font="normal 13px sans-serif",s.style.textAlign="center",s.style.opacity="0.5",s.style.outline="none",s.style.zIndex="999"}if("xr"in navigator)return t.id="ARButton",t.style.display="none",C(t),navigator.xr.isSessionSupported("immersive-ar").then(function(s){s?g():n()}).catch(n),t;{let s=document.createElement("a");return window.isSecureContext===!1?(s.href=document.location.href.replace(/^http:/,"https:"),s.innerHTML="WEBXR NEEDS HTTPS"):(s.href="https://immersiveweb.dev/",s.innerHTML="WEBXR NOT AVAILABLE"),s.style.left="calc(50% - 90px)",s.style.width="180px",s.style.textDecoration="none",C(s),s}}};var Wy=class{static createButton(A,e){e&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');let t=document.createElement("button");function i(){let C=null;async function s(a){a.addEventListener("end",r),await A.xr.setSession(a),t.textContent="EXIT VR",C=a}function r(){C.removeEventListener("end",r),t.textContent="ENTER VR",C=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(C===null){let a={optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};navigator.xr.requestSession("immersive-vr",a).then(s)}else C.end()}}function g(){t.disabled=!0,t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function o(){g(),t.textContent="VR NOT SUPPORTED"}function n(C){C.style.position="absolute",C.style.bottom="20px",C.style.padding="12px 6px",C.style.border="1px solid #fff",C.style.borderRadius="4px",C.style.background="rgba(0,0,0,0.1)",C.style.color="#fff",C.style.font="normal 13px sans-serif",C.style.textAlign="center",C.style.opacity="0.5",C.style.outline="none",C.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",n(t),navigator.xr.isSessionSupported("immersive-vr").then(function(C){C?i():o(),Wy.xrSessionIsGranted&&(console.log("XR session is granted - will enter immersive web now"),t.click())}),t;{let C=document.createElement("a");return window.isSecureContext===!1?(C.href=document.location.href.replace(/^http:/,"https:"),C.innerHTML="WEBXR NEEDS HTTPS"):(C.href="https://immersiveweb.dev/",C.innerHTML="WEBXR NOT AVAILABLE"),C.style.left="calc(50% - 90px)",C.style.width="180px",C.style.textDecoration="none",n(C),C}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Wy.xrSessionIsGranted=!0})}}},Vc=Wy;uA(Vc,"xrSessionIsGranted",!1);Vc.registerSessionGrantedListener();var fT=Ma(jw(),1);var zc="noVoip",CI=sA("debugvoip"),k8=sA("voip");var bU=class{id;constructor(A){this.id=A}};var xU=class{peer;voip;userId;peerId;call=null;callErrorListener=null;stream=null;constructor(A,e,t,i){this.voip=A,this.peer=e,this.userId=t,this.peerId=i}close(){CI&&console.log("close voip call"),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.open&&this.call.close(),this.stream?.getTracks().forEach(function(A){A.stop()})}updateMute(A){if(!this.stream)return;let e=this.stream?.getAudioTracks();for(let t of e)t.enabled=!A}async startVoipCall(){if(!await Zg.HasMicrophonePermissions()){console.warn("no permission to use microphone, can not start call");return}CI&&console.log("start voip call"),this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.updateMute(this.voip.muteOutput),CI&&console.log(this.stream),this.call=this.peer.call(this.peerId,this.stream,{metadata:{userId:this.userId}}),this.call.on("error",e=>{console.error(e)}),this.call.on("stream",e=>{CI&&console.log("received stream from remote again",e)}),this.peer.on("close",this.onCallClose.bind(this)),this.callErrorListener=e=>{e.message.includes(this.peerId)?(console.log("Could not connect to "+this.peerId),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.close(),this.stream?.getTracks().forEach(function(t){t.stop()}),this.stream=null):console.error(e)},this.peer.on("error",this.callErrorListener)}onCallClose(A){CI&&console.log("call closed",A)}},LU=class{get currentStream(){return this.stream}get currentAudio(){return this.audio}get currentAnalyzer(){return this.analyzer}voip;call;audio=null;stream=null;obj;analyzer=null;waitingForStart=!1;closed=!1;audioElement=null;constructor(A,e,t){this.voip=A,this.obj=e,this.call=t}openAudioStream(A){let e=A.getAudioTracks();for(let t of e)if(t.kind==="audio"&&t.readyState==="live"){this.open(t);return}console.warn("failed finding valid audio stream to begin call")}open(A){console.assert(A.kind==="audio","invalid track kind, expected audio but received "+A.kind),!this.waitingForStart&&(this.waitingForStart=!0,ct.userInteractionRegistered||CI&&console.log("Incoming call, waiting for user interaction before opening audio"),ct.registerWaitForAllowAudio(async()=>{if(this.call.open&&!this.closed){CI&&console.log("Setup audio and begin listening"),this.stream=new MediaStream([A]);let e=new AB;this.audio=new ar(e),this.audio.setVolume(this.voip.muteInput?0:1),this.audio.setMediaStreamSource(this.stream);let t=document.createElement("audio");this.audioElement=t,t.style.display="none",document.body.appendChild(t),t.srcObject=this.stream,t.sinkId!==void 0&&navigator.mediaDevices.enumerateDevices().then(i=>{if(!!t){console.log(i);for(let g of i)if(g.label==="Speakerphone"){t.sinkId=g.deviceId;break}}}),CI&&console.log("call is setup, you should hear something now"),this.analyzer=new pd(this.audio,32)}}))}close(){this.closed=!0,this.call?.open&&this.call.close(),this.audio?.disconnect(),this.stream?.getTracks().forEach(A=>{A.stop()}),this.stream=null,this.audioElement&&this.audioElement.remove()}},Zg=class extends EA{requireParam=!1;set muteInput(A){if(A===this._inputMuted||(this._inputMuted=A,!this.currentIncomingCalls))return;let e=this._inputMuted?0:1;for(let t in this.currentIncomingCalls)this.currentIncomingCalls[t]?.currentAudio?.setVolume(e)}get muteInput(){return this._inputMuted}set muteOutput(A){if(A!==this._outputMuted&&(this._outputMuted=A,!!this.connections))for(let e in this.connections)this.connections[e]?.updateMute(A)}get muteOutput(){return this._outputMuted}getFrequency(A){if(A===null){for(let t in this.currentIncomingCalls){let i=this.currentIncomingCalls[t];if(i&&i.currentAnalyzer)return i.currentAnalyzer.getAverageFrequency()}return null}let e=this.currentIncomingCalls[A];return e&&e.currentAnalyzer?e.currentAnalyzer.getAverageFrequency():null}peer=null;model=null;connections={};currentIncomingCalls={};_inputMuted=!1;_outputMuted=!1;awake(){if(sA(zc)){console.log("VOIP is disabled by url parameter: "+zc);return}if(this.requireParam&&!k8){console.debug("VOIP must be enabled explicitly by url parameter");return}if(VQ()&&Zp()){console.log("VOIP is currently not supported on Safari iOS");return}this.peer=new fT.default,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,this.context.connection.beginListen("joined-room",A=>{navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}),this.context.connection.beginListen("peer-update-id",A=>{if(A.id!==this.context.connection.connectionId){let e=this.connections[A.id];if(e&&e.close(),this.peer&&this.context.connection.connectionId){let t=new xU(this,this.peer,this.context.connection.connectionId,A.peerId);this.connections[A.id]=t,t.startVoipCall()}}}),this.context.connection.beginListen("user-left-room",A=>{let{userId:e}=A,t=this.connections[e];this.connections[e]=null,t&&t.close();let i=this.currentIncomingCalls[e];CI&&console.log("UserLeftRoom",A,e,i),i&&(i.close(),this.currentIncomingCalls[e]=null)}),this.peer.on("open",this.onOpenPeerConnection.bind(this))}onEnable(){}onDisable(){console.log("TODO: close all");for(let A in this.currentIncomingCalls)try{this.currentIncomingCalls[A]?.close(),this.connections[A]?.close()}catch(e){console.error(e)}}async onOpenPeerConnection(A){CI&&console.log("Peer connection established and received id"),this.model=new bU(A),this.context.connection.send("peer-update-id",this.model,1),this.peer&&(this.peer.on("call",this.onReceiveCall.bind(this)),this.peer.on("connection",function(e){CI&&console.log("CONNECTION",e),e.on("data",function(t){CI&&console.log("Received",t)})}))}async onReceiveCall(A){let{metadata:e}=A;console.assert(e.userId);let{userId:t}=e,{peer:i}=A,g=this.currentIncomingCalls[t];if(g&&g.close(),CI&&console.log("received call"),await Zg.HasMicrophonePermissions()){let o=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});A.answer(o)}else A.answer(null);this.currentIncomingCalls[t]=new LU(this,this.gameObject,A),A.on("stream",o=>{CI&&console.log("receive caller stream, will setup audio now"),this.currentIncomingCalls[t]?.openAudioStream(o)}),A.on("error",console.error)}static async HasMicrophonePermissions(){return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}};var sI=class extends EA{webAR=null;get rig(){return this.webAR?.webxr.Rig}invertForward=!1;get arScale(){return this._arScale}set arScale(A){A!==this._arScale&&(this._arScale=A,this.setScale(A))}_initalMatrix=new zA;_selectStartFn=this.onSelectStart.bind(this);_selectEndFn=this.onSelectEnd.bind(this);start(){let A=IA.findObjectOfType(pe);A&&(A.Rig.updateMatrix(),this._initalMatrix.copy(A.Rig.matrix))}_arScale=5;_rig=null;_startPose=null;_placementPose=null;_isTouching=!1;_rigStartPose=null;onBegin(A){this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose=this.gameObject.matrix.clone(),this._rigStartPose=this.rig?.matrix.clone(),A.addEventListener("selectstart",this._selectStartFn),A.addEventListener("selectend",this._selectEndFn),this.gameObject.visible=!1,this.rig&&(this.rig.matrixAutoUpdate=!0,this._initalMatrix.decompose(this.rig.position,this.rig.quaternion,this.rig.scale))}onUpdate(A,e,t){return t&&!this._placementPose&&this._isTouching?(this.webAR&&this.webAR.setReticleActive(!1),this.placeAt(A,new zA().fromArray(t.transform.matrix).invert()),!0):!1}placeAt(A,e){this._placementPose||(this._placementPose=new zA),this._placementPose.copy(e);let t=this.gameObject.matrixWorld.clone().invert();if(this._placementPose.premultiply(t),A){if(this.invertForward){let i=new zA().makeRotationY(Math.PI);this._placementPose.premultiply(i)}this._rig=A,this.setScale(this.arScale)}else this._rig=null;this.gameObject.visible=!0}onEnd(A,e){this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose&&this.gameObject.matrix.copy(this._startPose),A&&(A.matrixAutoUpdate=!0,this._rigStartPose&&this._rigStartPose.decompose(A.position,A.quaternion,A.scale)),Et.markDirty(this.gameObject,!0),setTimeout(()=>{this.gameObject.matrixAutoUpdate=!0,this.gameObject.visible=!0},100)}onSelectStart(){this._isTouching=!0}onSelectEnd(){this._isTouching=!1}setScale(A){let e=this._rig;!e||!this._placementPose||(this._rigStartPose||(this._rigStartPose=e.matrix.clone()),e.matrixAutoUpdate=!1,e.matrix.multiplyMatrices(new zA().makeScale(A,A,A),this._placementPose),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(),console.log("Place",e.position))}};U([F()],sI.prototype,"invertForward",2),U([F()],sI.prototype,"arScale",1);var on=class extends EA{objectBounds=!1;color;isGizmo=!0;_gizmoObject=null;_boxHelper=null;onEnable(){this.isGizmo&&!Nn||(this._gizmoObject||(this.objectBounds&&this.gameObject.isMesh===!0?this._gizmoObject=new LC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=Lw(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),3)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(;this._boxHelper;)this._boxHelper?.update(),yield}};U([F()],on.prototype,"objectBounds",2),U([F(W)],on.prototype,"color",2),U([F()],on.prototype,"isGizmo",2);var R8=sA("debugrig"),Kr=class extends EA{awake(){if(R8){let A=new vA;A.position.y+=.5,this.gameObject.add(A);let e=A.addNewComponent(on);e&&(e.isGizmo=!1)}}};var zn=class{bb=null;bb_pos=0;__init(A,e){return this.bb_pos=A,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}w(){return this.bb.readFloat32(this.bb_pos+12)}static sizeOf(){return 16}static createVec4(A,e,t,i,g){return A.prep(4,16),A.writeFloat32(g),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}};var pi=class{bb=null;bb_pos=0;__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsVrUserStateBuffer(A,e){return(e||new pi).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsVrUserStateBuffer(A,e){return A.setPosition(A.position()+4),(e||new pi).__init(A.readInt32(A.position())+A.position(),A)}guid(A){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}time(){let A=this.bb.__offset(this.bb_pos,6);return A?this.bb.readInt64(this.bb_pos+A):this.bb.createLong(0,0)}avatarId(A){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,A):null}position(A){let e=this.bb.__offset(this.bb_pos,10);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}rotation(A){let e=this.bb.__offset(this.bb_pos,12);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}scale(){let A=this.bb.__offset(this.bb_pos,14);return A?this.bb.readFloat32(this.bb_pos+A):0}posLeftHand(A){let e=this.bb.__offset(this.bb_pos,16);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}posRightHand(A){let e=this.bb.__offset(this.bb_pos,18);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}rotLeftHand(A){let e=this.bb.__offset(this.bb_pos,20);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}rotRightHand(A){let e=this.bb.__offset(this.bb_pos,22);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}static startVrUserStateBuffer(A){A.startObject(10)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addTime(A,e){A.addFieldInt64(1,e,A.createLong(0,0))}static addAvatarId(A,e){A.addFieldOffset(2,e,0)}static addPosition(A,e){A.addFieldStruct(3,e,0)}static addRotation(A,e){A.addFieldStruct(4,e,0)}static addScale(A,e){A.addFieldFloat32(5,e,0)}static addPosLeftHand(A,e){A.addFieldStruct(6,e,0)}static addPosRightHand(A,e){A.addFieldStruct(7,e,0)}static addRotLeftHand(A,e){A.addFieldStruct(8,e,0)}static addRotRightHand(A,e){A.addFieldStruct(9,e,0)}static endVrUserStateBuffer(A){return A.endObject()}static finishVrUserStateBufferBuffer(A,e){A.finish(e)}static finishSizePrefixedVrUserStateBufferBuffer(A,e){A.finish(e,void 0,!0)}};var DT=sA("debugxr"),Mu=sA("debugavatar");var TU="VRUS";kc(TU,pi.getRootAsVrUserStateBuffer);function vU(){return new Date().getTime()}function U8(I){let A=I&4294967295,e=I/Math.pow(2,32)&1048575;return pg.create(A,e)}var Gu=class{guid;time;avatarId;position=new k;rotation=new Ae;scale=1;posLeftHand=new k;posRightHand=new k;rotLeftHand=new KA;rotRightHand=new KA;constructor(A){this.guid=A}update(A,e,t,i,g){this.time=vU(),this.avatarId=g,this.position.set(e.x,e.y,e.z),A&&this.position.applyMatrix4(A.matrixWorld);let o=Gu.quat0,n=Gu.quat1;o.set(t.x,t.y,t.z,t.w),o=o.multiplyQuaternions(o,Gu.invertRotation),A&&(A.getWorldQuaternion(n),o.multiplyQuaternions(n,o)),this.rotation.set(o.x,o.y,o.z,o.w),this.scale=A.scale.x;let C=i.LeftController?.controllerGrip;C&&(C.getWorldPosition(this.posLeftHand),C.getWorldQuaternion(this.rotLeftHand));let s=i.RightController?.controllerGrip;if(s&&(s.getWorldPosition(this.posRightHand),s.getWorldQuaternion(this.rotRightHand)),i.LeftController?.hand?.visible){let r=i.LeftController.wrist;r&&(r.getWorldPosition(this.posLeftHand),r.getWorldQuaternion(this.rotLeftHand))}if(i.RightController?.hand?.visible){let r=i.RightController.wrist;r&&(r.getWorldPosition(this.posRightHand),r.getWorldQuaternion(this.rotRightHand))}}sendAsBuffer(A,e){A.clear();let t=A.createString(this.guid),i=A.createString(this.avatarId);pi.startVrUserStateBuffer(A),pi.addGuid(A,t),pi.addTime(A,U8(this.time)),pi.addAvatarId(A,i),pi.addPosition(A,oi.createVec3(A,this.position.x,this.position.y,this.position.z)),pi.addRotation(A,zn.createVec4(A,this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)),pi.addScale(A,this.scale),pi.addPosLeftHand(A,oi.createVec3(A,this.posLeftHand.x,this.posLeftHand.y,this.posLeftHand.z)),pi.addPosRightHand(A,oi.createVec3(A,this.posRightHand.x,this.posRightHand.y,this.posRightHand.z)),pi.addRotLeftHand(A,zn.createVec4(A,this.rotLeftHand.x,this.rotLeftHand.y,this.rotLeftHand.z,this.rotLeftHand.w)),pi.addRotRightHand(A,zn.createVec4(A,this.rotRightHand.x,this.rotRightHand.y,this.rotRightHand.z,this.rotRightHand.w));let g=pi.endVrUserStateBuffer(A);A.finish(g,TU);let o=A.asUint8Array();e.sendBinary(o)}setFromBuffer(A,e){if(!A)return;this.guid=A,this.time=e.time().toFloat64();let t=e.avatarId();t&&(this.avatarId=t);let i=e.position();i&&this.position.set(i.x(),i.y(),i.z());let g=e.rotation();g&&this.rotation.set(g.x(),g.y(),g.z(),g.w());let o=e.posLeftHand();o&&this.posLeftHand.set(o.x(),o.y(),o.z());let n=e.posRightHand();n&&this.posRightHand.set(n.x(),n.y(),n.z());let C=e.rotLeftHand();C&&this.rotLeftHand.set(C.x(),C.y(),C.z(),C.w());let s=e.rotRightHand();s&&this.rotRightHand.set(s.x(),s.y(),s.z(),s.w()),this.scale=e.scale()}},Eo=Gu;uA(Eo,"invertRotation",new KA().setFromAxisAngle(new k(0,1,0),Math.PI)),uA(Eo,"quat0",new KA),uA(Eo,"quat1",new KA);var ts=class extends EA{webXR=null;debugAvatarUser=null;voip=null;async awake(){if(this.webXR||(this.webXR=IA.getComponent(this.gameObject,pe)),this.webXR||(this.webXR=IA.findObjectOfType(pe,this.context)),!this.webXR&&(console.log("Missing webxr component"),this.webXR=IA.findObjectOfType(pe,this.context),!this.webXR)){console.error("Could not find webxr component");return}if(this.voip||(this.voip=IA.findObjectOfType(Zg,this.context)),Mu){let A="debug-avatar-"+Mu,e=new ro(this.context,A,this.webXR);if(this.debugAvatarUser=e,typeof Mu=="string"&&Mu.length>0)if(await e.setAvatarOverride(Mu)){let t=new Eo(A);t.position.y+=1;let i=.5;t.posLeftHand.y+=i,t.posLeftHand.x+=i,t.posRightHand.y+=i,t.posRightHand.x-=i,e.tryUpdate(t,0)}else e.destroy()}}onEnable(){if(!this.webXR&&(this.webXR=IA.getComponent(this.gameObject,pe),!this.webXR)){console.warn("Missing webxr component on "+this.gameObject.name);return}this.eventSub_WebXRStartEvent=this.onXRSessionStart.bind(this),pe.addEventListener("xrStarted",this.eventSub_WebXRStartEvent),this.eventSub_WebXRUpdateEvent=this.onXRSessionUpdate.bind(this),pe.addEventListener("xrUpdate",this.eventSub_WebXRUpdateEvent),this.eventSub_WebXREndEvent=this.onXRSessionEnded.bind(this),pe.addEventListener("xrStopped",this.eventSub_WebXREndEvent),this.eventSub_ConnectionEvent=this.onConnected.bind(this),this.context.connection.beginListen("joined-room",this.eventSub_ConnectionEvent),this.context.connection.beginListen("webxr-user-joined",A=>{console.log("webxr user joined evt")}),this.context.connection.beginListen("webxr-user-left",A=>{let e=A.id!==null&&A.id!==void 0;!e||(console.log("webxr user left evt"),e&&(this.avatars[A.id]?.destroy(),this.avatars[A.id]=void 0))}),this.context.connection.beginListenBinrary(TU,A=>{let e=A.guid();if(!e)return;let t=A.time().toFloat64(),i=this.tempState;i.setFromBuffer(e,A),this.onTryGetAvatar(e,t)?.tryUpdate(i,t)}),this.context.connection.beginListen("vr-session-update",A=>{let e=A.guid,t=A.time;this.onTryGetAvatar(e,t)?.tryUpdate(A,t)})}tempState=new Eo("");onTryGetAvatar(A,e){if(A===this.context.connection.connectionId)return null;let t=new Date().getTime()-e;if(t>5e3)return DT&&console.log("old data",t,A),null;let i=this.avatars[A];if(i===void 0)try{console.log("create new avatar");let g=new ro(this.context,A,this.webXR);i=g,this.avatars[A]=g}catch(g){this.avatars[A]=null,console.error(g)}return i}onDisable(){this.eventSub_ConnectionEvent&&this.context.connection.stopListening("joined-room",this.eventSub_ConnectionEvent),pe.removeEventListener("xrStarted",this.eventSub_WebXRStartEvent),pe.removeEventListener("xrUpdate",this.eventSub_WebXRUpdateEvent),pe.removeEventListener("xrStopped",this.eventSub_WebXREndEvent)}update(){let A=vU();this.debugAvatarUser&&(this.debugAvatarUser.lastUpdate=A),this.detectPotentiallyDisconnectedAvatarsAndRemove();for(let e in this.avatars){let t=this.avatars[e];!t||t.update()}}_removeAvatarsList=[];detectPotentiallyDisconnectedAvatarsAndRemove(){let A=vU();for(let e in this.avatars){let t=this.avatars[e];if(!t){this._removeAvatarsList.push(e);continue}A-t.lastUpdate>1e4&&(console.log("avatar timed out (didnt receive any updates in a while) - destroying it now"),t.destroy(),this.avatars[e]=void 0)}for(let e of this._removeAvatarsList)delete this.avatars[e];this._removeAvatarsList.length=0}buildLocalAvatar(){if(this.localAvatar)return;let A=this.context.connection?.connectionId??this.k_LocalAvatarNoNetworkingGuid;this.localAvatar=new ro(this.context,A,this.webXR),this.localAvatar.isLocalAvatar=!0,this.localAvatar.setAvatarOverride(this.getAvatarId()),this.avatars[this.localAvatar.guid]=this.localAvatar}eventSub_ConnectionEvent=null;eventSub_WebXRStartEvent=null;eventSub_WebXREndEvent=null;eventSub_WebXRUpdateEvent=null;avatars={};localAvatar=null;k_LocalAvatarNoNetworkingGuid="local";onConnected(){DT&&console.log("Hey you are connected as "+this.context.connection.connectionId),this.localAvatar?.guid===this.k_LocalAvatarNoNetworkingGuid&&(this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0),this.localAvatar=null,this.xrState=null,this.ownership?.freeOwnership(),this.ownership=null)}onXRSessionStart(A){if(console.log("XR session started"),this.context.connection.send("webxr-user-joined",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null),this.xrState=null,this.ownership?.freeOwnership(),this.ownership=null,this.avatars)for(let e in this.avatars)this.avatars[e]?.updateFlags()}onXRSessionEnded(A){console.log("XR session ended"),this.context.connection.send("webxr-user-left",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null)}ownership=null;xrState=null;builder=new kI(1024);onXRSessionUpdate(A){this.xrState??=new Eo(this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid),this.ownership??=new wr(this.context.connection,this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid),this.ownership.guid=this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid,this.buildLocalAvatar();let{frame:e,xr:t,rig:i}=A,g=e.getViewerPose(t.getReferenceSpace());if(!g)return;let o=g?.transform,n=o.position,C=o.orientation;this.xrState.update(i,n,C,this.webXR,this.getAvatarId()),this.localAvatar&&(this.context.connection.connectionId&&(this.localAvatar.guid=this.context.connection.connectionId),this.localAvatar.tryUpdate(this.xrState,0)),!(this.ownership&&!this.ownership.hasOwnership&&this.context.connection.isConnected&&(this.context.time.frameCount%120===0&&this.ownership.requestOwnership(),!this.ownership.hasOwnership))&&(!this.context.connection.isConnected||!this.context.connection.connectionId||this.xrState.sendAsBuffer(this.builder,this.context.connection))}getAvatarId(){return sA("avatar")??null}};async function F8(){return jp()?!0:"xr"in navigator?await navigator.xr.isSessionSupported("immersive-ar")===!0:!1}async function N8(){return"xr"in navigator?await navigator.xr.isSessionSupported("immersive-vr")===!0:!1}var HU=!1,YU=!1;F8().then(I=>HU=I);N8().then(I=>YU=I);var Ki=class extends EA{enableVR=!0;enableAR=!0;defaultAvatar;handModelPath="";createVRButton=!0;createARButton=!0;static get IsInWebXR(){return this._isInXr}static get XRSupported(){return"xr"in navigator&&(HU||YU)}static get IsARSupported(){return HU}static get IsVRSupported(){return YU}static addEventListener(A,e){return this.events.addEventListener(A,e),e}static removeEventListener(A,e){return this.events.removeEventListener(A,e),e}static createVRButton(A,e){Ki.XRSupported?A.__internalAwake():console.warn("WebXR is not supported on this device");let t=Vc.createButton(A.context.renderer);return t.classList.add("webxr-ar-button"),t.classList.add("webxr-button"),this.resetButtonStyles(t),(e?.registerClick??!0)&&t.addEventListener("click",A.onClickedVRButton.bind(A)),t}static createARButton(A,e){A.__internalAwake();let t=A.webAR?.getAROverlayContainer(),i={};t?(i.domOverlay={root:t},i.optionalFeatures=["hit-test","dom-overlay"]):console.warn("No dom overlay root found, HTML overlays on top of screen-based AR will not work."),i.optionalFeatures.push("plane-detection"),i.optionalFeatures.push("anchors");let g=Py.createButton(A.context.renderer,i);return g.classList.add("webxr-ar-button"),g.classList.add("webxr-button"),Ki.resetButtonStyles(g),(e?.registerClick??!0)&&g.addEventListener("click",A.onClickedARButton.bind(A)),g}static resetButtonStyles(A){!A||(A.style.position="",A.style.bottom="",A.style.left="")}endSession(){let A=this.context.renderer.xr.getSession();A&&A.end()}get Rig(){return this.rig||this.ensureRig(),this.rig}controllers=[];get Controllers(){return this.controllers}get LeftController(){return this.controllers.length>0&&this.controllers[0].input?.handedness==="left"?this.controllers[0]:this.controllers.length>1&&this.controllers[1].input?.handedness==="left"?this.controllers[1]:null}get RightController(){return this.controllers.length>0&&this.controllers[0].input?.handedness==="right"?this.controllers[0]:this.controllers.length>1&&this.controllers[1].input?.handedness==="right"?this.controllers[1]:null}get ARButton(){return this._arButton}get VRButton(){return this._vrButton}get IsInVR(){return this._isInVR}get IsInAR(){return this._isInAR}rig;isInit=!1;_requestedAR=!1;_requestedVR=!1;_isInAR=!1;_isInVR=!1;_arButton;_vrButton;webAR=null;awake(){if(this.defaultAvatar&&typeof this.defaultAvatar=="string"&&(this.defaultAvatar=jg.getOrCreate(this.sourceId??"/",this.defaultAvatar,this.context)),!IA.findObjectOfType(ts,this.context)){let A=IA.addNewComponent(this.gameObject,ts,!1);A.webXR=this}this.webAR=new Jr(this)}onEnable(){if(this.isInit||!this.enableAR&&!this.enableVR)return;this.isInit=!0,this.context.renderer.xr.enabled=!0;let A=Ki.XRSupported,e,t,i=document.createElement("div");i.classList.add("webxr-buttons"),this.context.domElement.append(i),this.enableAR&&this.createARButton&&(e=Ki.createARButton(this),this._arButton=e,i.appendChild(e)),this.createVRButton&&this.enableVR&&(t=Ki.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Ki.resetButtonStyles(t),Ki.resetButtonStyles(e)},1e3)}_transformOrientation=new KA;get TransformOrientation(){return this._transformOrientation}_currentHeadPose=null;get HeadPose(){return this._currentHeadPose}onBeforeRender(A){if(!A)return;let e=this.context.renderer.xr.getSession();if(e){let t=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!t)return;this._currentHeadPose=t;let i=t?.transform;i&&this._transformOrientation.set(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w),Ki._isInXr===!1&&e&&this.onEnterXR(e,A);for(let g of this.controllers)g.onUpdate(e);this._isInAR&&this.webAR?.onUpdate(e,A)}Ki.events.dispatchEvent({type:"xrUpdate",frame:A,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let A=0;A<2;A++)it.Create(this,A,this.gameObject,0);Ki.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ge(this.context.mainCamera)),this._originalCameraRotation.copy(bt(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){let A=IA.findObjectOfType(Kr,this.context);A?this.rig=A.gameObject:(this.rig=new xo,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}_originalCameraParent=null;_originalCameraPosition=new k;_originalCameraRotation=new KA;_originalXRRigParent=null;_originalXRRigPosition=new k;_originalXRRigRotation=new KA;onEnterXR(A,e){console.log("[XR] session begin",A),Ki._isInXr=!0,this.ensureRig();let t=this.context.renderer.xr.getReferenceSpace();if(t&&this.rig){let n=e.getViewerPose(t)?.transform.orientation;if(n){let C=new KA(n.x,n.y,n.z,n.w),s=new $e().setFromQuaternion(C);this.rig.rotateY(s.y)}}let i=this.context.renderer.xr;if(this.context.mainCamera){let o=i.getCamera(this.context.mainCamera);for(let n of o.cameras)n.layers.enableAll();this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}let g=this._requestedAR?2:4;switch(FI.Global.Set(g),g){case 2:this.context.xrSessionMode="immersive-ar",this._isInAR=!0,this.webAR?.onBegin(A);break;case 4:this.context.xrSessionMode="immersive-vr",this._isInVR=!0,this.onEnterVR(A);break}A.addEventListener("end",()=>{console.log("[XR] session end"),Ki._isInXr=!1,this.onExitXR(A)}),this.onEnterXR_HandleMirrorWindow(A),Ki.events.dispatchEvent({type:"xrStarted",session:A})}onExitXR(A){let e=this._isInAR;this._isInAR&&A&&this.webAR?.onEnd(A),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&(this._originalCameraParent?.add(this.context.mainCamera),at(this.context.mainCamera,this._originalCameraPosition),Og(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),e&&(this._originalXRRigParent?.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),FI.Global.Set(17),Ki.events.dispatchEvent({type:"xrStopped",session:A})}onEnterVR(A){}destroyControllers(){for(let A=this.controllers.length-1;A>=0;A-=1)this.controllers[A]?.destroy();this.controllers.length=0}xrMirrorWindow=null;onEnterXR_HandleMirrorWindow(A){!sA("mirror")||setTimeout(()=>{if(!Ki.IsInWebXR)return;let e=new URL(window.location.href);OQ(e.searchParams,zc,1),OQ(e.searchParams,"isMirror",1);let t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Ki.IsInWebXR&&A.end()})})},1e3)}},pe=Ki;uA(pe,"_isInXr",!1),uA(pe,"events",new _i),U([F()],pe.prototype,"enableVR",2),U([F()],pe.prototype,"enableAR",2),U([F(jg)],pe.prototype,"defaultAvatar",2),U([F()],pe.prototype,"handModelPath",2),U([F()],pe.prototype,"createVRButton",2),U([F()],pe.prototype,"createARButton",2);var jc=class{get webxr(){return this._webxr}_webxr;reticle=null;reticleParent=null;hitTestSource=null;reticleActive=!0;previousBackground=null;previousEnvironment=null;sessionRoot=null;_previousParent=null;get context(){return this.webxr.context}constructor(A){this._webxr=A}arDomOverlay=null;arOverlayElement=null;noHitTestAvailable=!1;didPlaceARSessionRoot=!1;getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;let A=this.arDomOverlay;return A.getAROverlayContainer?this.arOverlayElement=A.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(A){this.reticleActive=A}async onBegin(A){let e=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();let t=navigator.userAgent?.includes("OculusBrowser")?0:1,i=t===1?4:2;for(let o=0;o<i;o++)it.Create(this.webxr,o,this.webxr.gameObject,t);(!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=IA.findObjectOfType(sI,e)),this.previousBackground=e.scene.background,this.previousEnvironment=e.scene.environment,e.scene.background=null,A.requestReferenceSpace("viewer").then(o=>{A.requestHitTestSource?.call(A,{space:o})?.then(n=>{this.hitTestSource=n}).catch(n=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",n)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new we(new Gn(.07,.09,32).rotateX(-Math.PI/2),new yt),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new vA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,jc.tempWebXRObject||(jc.tempWebXRObject=new vA),this.context.scene.add(jc.tempWebXRObject),IA.addComponent(jc.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,this.sessionRoot?.onBegin(A)):console.warn("No WebARSessionRoot found in scene");let g=this.context.domElement;g?.onEnterAR?.call(g,A,this.arOverlayElement),this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera()}onEnd(A){this._previousParent&&(IA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;let e=this.webxr.context;e.scene.background=this.previousBackground,e.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,A);let t=this.context.domElement;t.onExitAR?.call(t,A),this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera()}onUpdate(A,e){if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;let i=this.webxr.Rig,g=K8.clone();this.sessionRoot?.placeAt(i,g)}return}if(!this.hitTestSource)return;let t=e.getHitTestResults(this.hitTestSource);if(t.length){let i=t[0],g=this.webxr.context.renderer.xr.getReferenceSpace();if(g){let o=i.getPose(g);if(this.sessionRoot){let n=this.sessionRoot.onUpdate(this.webxr.Rig,A,o);this.didPlaceARSessionRoot=n}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&o)){let n=o.transform.matrix;this.reticle.matrix.fromArray(n),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else this.sessionRoot?.onUpdate(this.webxr.Rig,A,null),this.reticle&&(this.reticle.visible=!1)}},Jr=jc;uA(Jr,"tempWebXRObject");var K8=new zA().identity().makeTranslation(0,0,0);var nn=class{used=!1;Use(){this.used=!0}StopPropagation(){this.event?.stopImmediatePropagation()}inputSource;object;isDown;isUp;isPressed;isClicked;event;constructor(A){this.event=A}};var q8=sA("debugeventsystem"),jn=class extends EA{static createIfNoneExists(A){this.didSearchEventSystem||(this.didSearchEventSystem=!0,jn.systems.length<=0&&jn.systems.push(...IA.findObjectsOfType(jn,A)));for(let t of jn.systems)if(t.context===A)return;let e=new vA;IA.addNewComponent(e,jn),A.scene.add(e)}static get systems(){let A=Ee.Current;return this._eventSystemMap.has(A)||this._eventSystemMap.set(A,[]),this._eventSystemMap.get(A)}static ensureUpdateMeshUI(A,e){Cn.update(A,e)}static markUIDirty(A){Cn.markDirty()}static get instance(){return this.systems[0]}orbitControl=null;orbitControlWasEnabled=!1;raycaster=[];constructor(){super(),jn.systems.push(this)}onDestroy(){jn.systems.splice(jn.systems.indexOf(this),1)}start(){}register(A){A&&this.raycaster&&!this.raycaster.includes(A)&&this.raycaster?.push(A)}unregister(A){let e=this.raycaster?.indexOf(A);e!==void 0&&e!==-1&&this.raycaster?.splice(e,1)}_selectStartFn;_selectEndFn;_selectUpdateFn;onEnable(){let A=new Map;this._selectStartFn??=(t,i)=>{if(!i.grab)return;Cn.resetLastSelected();let g=new nn;g.inputSource=t,g.isDown=t.selectionDown,g.isUp=t.selectionUp,g.isPressed=t.selectionPressed,g.isClicked=!1,A.set(t,i.grab),i.grab&&!this.handleEvents(i.grab,g)&&(i.grab=null)},this._selectEndFn??=(t,i)=>{if(!i.grab)return;let g=new nn;g.inputSource=t,g.isDown=t.selectionDown,g.isUp=t.selectionUp,g.isPressed=t.selectionPressed,g.isClicked=t.selectionClick,this.handleEvents(i.grab,g);let o=A.get(t);if(A.set(t,null),o)for(let n=0;n<this.raisedPointerDownEvents.length;n++){let C=this.raisedPointerDownEvents[n];this.raisedPointerDownObjects[n]===o&&C&&(C.onPointerUp?.call(C,g),this.raisedPointerDownEvents.splice(n,1),this.raisedPointerDownObjects.splice(n,1),n--)}};let e=new vt;this._selectUpdateFn??=t=>{e.ray=t.getRay();let i=this.performRaycast(e);if(!i)return;let g=new nn;g.inputSource=t,this.handleIntersections(i,g)},it.addEventListener("select-start",this._selectStartFn),it.addEventListener("select-end",this._selectEndFn),it.addEventListener("update",this._selectUpdateFn),this.context.pre_update_callbacks.push(this.onBeforeUpdate.bind(this)),this.context.input.addEventListener("pointerdown",this.onPointerDown.bind(this))}onDisable(){it.removeEventListener("select-start",this._selectStartFn),it.removeEventListener("select-end",this._selectEndFn),it.removeEventListener("update",this._selectUpdateFn)}onPointerDown(){this.onBeforeUpdate()}lastPointerEvent=null;objectsHoveredThisFrame=[];objectsHoveredLastFrame=[];raisedPointerDownEvents=[];raisedPointerDownObjects=[];_didMove=!1;onBeforeUpdate(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),pe.IsInWebXR||this.context.input.isKeyPressed("Alt"))return;if(!this._didMove){let g=this.context.input.getPointerPositionRC(0);if(g&&g.x===0&&g.y===0)return;this._didMove=!0}let A=this.performRaycast(null),e=new nn(this.context.input.getPointerEvent(0));if(e.inputSource=this.context.input,e.isClicked=this.context.input.mouseClick,e.isDown=this.context.input.mouseDown,e.isUp=this.context.input.mouseUp,e.isPressed=this.context.input.mousePressed,this.lastPointerEvent=e,!A)return;let t=null,i=null;this.context.input.mouseDown&&this.currentActiveMeshUIComponents.length>0&&this.context.mainCameraComponent&&(t=IA.getComponent(this.context.mainCameraComponent.gameObject,Xi)??null,t&&(i=t.enabled,t.enabled=!1)),this.handleIntersections(A,e),t&&(this.orbitControl=t,this.orbitControl?.enabled?(this.orbitControlWasEnabled=this.orbitControl.enabled,this.orbitControl.enabled=!1):this.orbitControl&&!this.context.input.mousePressed&&(this.orbitControl.enabled=this.orbitControlWasEnabled,this.orbitControl=null))}_tempComponentsArray=[];onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(let e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(let e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;let t=IA.getComponentsInParent(e,EA,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let i=0;i<t.length;i++){let g=t[i];if(!g.gameObject||g.destroyed)continue;let o=g;o.onPointerExit&&o.onPointerExit(this.lastPointerEvent)}}let A=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=A}_sortedHits=[];performRaycast(A){if(!this.raycaster)return null;this._sortedHits.length=0;for(let e of this.raycaster){if(!e.activeAndEnabled)continue;let t=e.performRaycast(A);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(A,e){if(!A||A.length<=0)return!1;A=this.sortCandidates(A);for(let t of A){let{object:i}=t;if(this.handleEvents(i,e))return!0}return!1}_sortingBuffer=[];_noDepthTestingResults=[];sortCandidates(A){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<A.length;e++){let t=A[e],i=t.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(let e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventsArray=[];out={};handleEvents(A,e){if(!this.testIsVisible(A))return e.isClicked&&q8&&console.log("not allowed",A),!1;let t=A;e.object=A,this.lastPointerEvent=e;let i=A.parent,g=!1,o=e.isClicked??!1,n=null;if(i&&i.isUI){let C=(e.isPressed||e.isClicked)??!1;if(i[rI]){let s=i[rI].gameObject;if(s){if(!sn.isInteractable(s,this.out))return this.out.canvasGroup?.interactable??!1;n=this.out.canvasGroup??null;let a=this.handleMeshUIIntersection(A,C);A=s,g=!0}}if(!g&&this.handleMeshUiObjectWithoutShadowDom(i,C))return!0}if(this.objectsHoveredThisFrame.push(A),n===null||n.interactable){let C=this.objectsHoveredLastFrame.indexOf(A)>=0;this.handleEventsArray.length=0;let s=IA.getComponentsInParent(A,EA,this.handleEventsArray);for(let r=0;r<s.length;r++){if(e.used)return!0;if(s[r].destroyed)continue;let a=s[r];a.interactable!==!1&&(a.onPointerEnter&&(C||a.onPointerEnter(e)),e.isDown&&a.onPointerDown&&!this.raisedPointerDownEvents.includes(a)&&(a.onPointerDown(e),this.raisedPointerDownEvents.push(a),this.raisedPointerDownObjects.push(t)),e.isUp&&a.onPointerUp&&a.onPointerUp(e),e.isClicked&&a.onPointerClick&&a.onPointerClick(e))}}return!0}handleMeshUiObjectWithoutShadowDom(A,e){return!A||!A.isUI?!0:this.handleMeshUIIntersection(A,e)}currentActiveMeshUIComponents=[];handleMeshUIIntersection(A,e){let t=Cn.updateState(A,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Cn.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let A=0;A<this.currentActiveMeshUIComponents.length;A++){let e=this.currentActiveMeshUIComponents[A];Cn.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(A){return A?IA.isActiveSelf(A)?this.testIsVisible(A.parent):!1:!0}},wg=jn;uA(wg,"_eventSystemMap",new Map),uA(wg,"didSearchEventSystem",!1);var Cn=class{static markDirty(){this.needsUpdate=!0}static update(A,e){for(let t of this.lastUpdateFrame)if(t.context===e){if(e.time.frameCount===t.frame)return;t.frame=e.time.frameCount,(this.needsUpdate||e.time.frameCount<30)&&(this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:e.time.frameCount}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;e?(this.lastSelected=t,t.states.pressed&&t.setState("pressed")):t.states.hovered&&t.setState("hovered"),this.needsUpdate=!0}return t}static resetLastSelected(){let A=this.lastSelected;!A||(this.lastSelected=null,this.resetState(A))}static resetState(A){if(!A)return;A.interactable===!1?A.states.disabled&&A.setState("disabled"):A===this.lastSelected&&A.states.selected?A.setState("selected"):A.setState("normal"),this.needsUpdate=!0}static findBlockInParent(A){return A?A.isBlock&&Object.keys(A.states).length>0?A:this.findBlockInParent(A.parent):null}};uA(Cn,"lastSelected",null),uA(Cn,"lastUpdateFrame",[]),uA(Cn,"needsUpdate",!1);var Zc="./include";mu.prototype.interactable={get(){return this.interactive},set(I){this.interactable=I}};var rI=Symbol("shadowDomOwner"),tg=class extends EA{isRoot(){return this.Root?.gameObject===this.gameObject}markDirty(){wg.markUIDirty(this.context)}shadowComponent=null;_controlsChildLayout=!0;get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(A){this._controlsChildLayout=A,this.shadowComponent&&(this.shadowComponent.autoLayout=A)}_root=void 0;get Root(){return this._root===void 0&&(this._root=IA.getComponentInParent(this.gameObject,is)),this._root}_parentComponent=void 0;onEnable(){super.onEnable()}addShadowComponent(A,e){this.removeShadowComponent();let t=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=IA.getComponentInParent(t,tg),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have a UI element outside a Canvas?`,this);return}A.name=this.name+" ("+(this.constructor.name??"UI")+")",A.autoLayout=this._parentComponent.controlsChildLayout,A[rI]=this,A.traverse(g=>{g[rI]===void 0&&(g[rI]=this)});let i=!1;if(this.Root?.gameObject===this.gameObject)this.gameObject.add(A);else{let g=this._parentComponent.shadowComponent;g&&(g?.add(A),i=!0)}this.shadowComponent=A,e&&e.shadowComponent&&this.shadowComponent&&e.shadowComponent.add(this.shadowComponent),Nn&&A.add(new yI(.5)),this.onAfterAddedToScene(),i&&qU()}set(A){}traverseOwnedShadowComponents(A,e,t){if(!!A&&A[rI]===e){t(A);for(let i of A.children)this.traverseOwnedShadowComponents(i,e,t)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(A){this.shadowComponent&&(this.shadowComponent.interactable=A)}},is=class extends tg{awake(){super.awake()}};var sn=class{static getObject(A){let e=A[rI];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;let t=this.tryFindCanvasGroup(A);if(t?.isCanvasGroup===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;let i=Oo(A,g=>{if(g.isGraphic===!0)return g},!1);return e&&i?.isGraphic===!0&&(e.graphic=i),i?.raycastTarget!==!1}static tryFindCanvasGroup(A){if(!A)return null;let e=Oo(A,t=>{let i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}};var ku=sA("debugwebxrcontroller");var xB=class extends EA{},Ji=class extends EA{static CreateRaycastLine(){let A=new hg(this.geometry),e=A.material;return e.color=this.raycastColor,A.layers.set(2),A.name="line",A.scale.z=1,A}static CreateRaycastHitPoint(){let A=new Tg(.5,22,22),e=new yt({color:this.raycastColor}),t=new we(A,e);return t.visible=!1,t.layers.set(2),t}static Create(A,e,t,i){let g=t?IA.addNewComponent(t,Ji,!1):new Ji;g.webXR=A,g.index=e,g.type=i;let o=A.context;g.controller=o.renderer.xr.getController(e),g.controllerGrip=o.renderer.xr.getControllerGrip(e),g.controllerModel=this.Factory.createControllerModel(g.controller),g.controllerGrip.add(g.controllerModel),g.hand=o.renderer.xr.getHand(e);let n=new v8;VC(n,o),g.webXR.handModelPath&&g.webXR.handModelPath!==""?n.setPath(Sn(A.sourceId,g.webXR.handModelPath)):n.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/");let C=new b8(g.hand,n);return g.hand.add(C),g.hand.traverse(s=>s.layers.set(2)),g.handPointerModel=new x8(g.hand,g.controller),g.controller.addEventListener("connected",s=>{g.setControllerLayers(g.controllerModel,2),g.setControllerLayers(g.controllerGrip,2),g.setControllerLayers(g.hand,2),setTimeout(()=>{g.setControllerLayers(g.controllerModel,2),g.setControllerLayers(g.controllerGrip,2),g.setControllerLayers(g.hand,2)},1e3)}),g.hand.addEventListener("connected",s=>{if(s.data.hand){A.Rig&&A.Rig.add(g.hand),g.type=0,g.handPointerModel.traverse(B=>B.layers.set(2)),g.handPointerModel.pointerObject?.traverse(B=>B.layers.set(2));let a=g.hand.joints;if(a)for(let B of Object.keys(a)){let Q=a[B];Q.parent||g.hand.add(Q)}}}),g}static addEventListener(A,e){let t=this.eventSubs[A]??[];t.push(e),this.eventSubs[A]=t}static removeEventListener(A,e){if(!e)return;let t=this.eventSubs[A]??[],i=t.indexOf(e);i>=0&&t.splice(i,1),this.eventSubs[A]=t}webXR;index=-1;controllerModel;controller;controllerGrip;hand;handPointerModel;grabbed=null;input=null;type=0;showRaycastLine=!0;get isUsingHands(){let A=this.input?.hand;return A!=null}get wrist(){if(!this.hand)return null;let A=this.hand.joints;return A?A.wrist:null}_wristQuaternion=null;getWristQuaternion(){let A=this.wrist;return A?(this._wristQuaternion||(this._wristQuaternion=new KA),bt(A).multiply(this._wristQuaternion.setFromEuler(new $e(-Math.PI/4,0,0)))):null}movementVector=new k;worldRot=new KA;joystick=new SA;didRotate=!1;didTeleport=!1;didChangeScale=!1;lastHit=null;raycastLine=null;_raycastHitPoint=null;_connnectedCallback=null;_disconnectedCallback=null;_selectStartEvt=null;_selectEndEvt=null;get selectionDown(){return this._selectionPressed&&!this._selectionPressedLastFrame}get selectionUp(){return!this._selectionPressed&&this._selectionPressedLastFrame}get selectionPressed(){return this._selectionPressed}get selectionClick(){return this._selectionEndTime-this._selectionStartTime<.3}get raycastHitPoint(){return this._raycastHitPoint}_selectionPressed=!1;_selectionPressedLastFrame=!1;_selectionStartTime=0;_selectionEndTime=0;get useSmoothing(){return this._useSmoothing}_useSmoothing=!0;awake(){if(!this.controller){console.warn("Missing Controller!!!",this);return}this._connnectedCallback=this.onSourceConnected.bind(this),this._disconnectedCallback=this.onSourceDisconnected.bind(this),this._selectStartEvt=this.onSelectStart.bind(this),this._selectEndEvt=this.onSelectEnd.bind(this),this.type===1&&(this.controllerGrip.addEventListener("connected",this._connnectedCallback),this.controllerGrip.addEventListener("disconnected",this._disconnectedCallback),this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt))}onDestroy(){this.type===1&&(this.controllerGrip.removeEventListener("connected",this._connnectedCallback),this.controllerGrip.removeEventListener("disconnected",this._disconnectedCallback),this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.hand?.clear(),this.controllerGrip?.clear(),this.controller?.clear()}onEnable(){this.hand&&(this.hand.name="Hand"),this.controllerGrip&&(this.controllerGrip.name="ControllerGrip"),this.controller&&(this.controller.name="Controller"),this.raycastLine&&(this.raycastLine.name="RaycastLine;"),this.webXR.Controllers.indexOf(this)<0&&this.webXR.Controllers.push(this),this.raycastLine||(this.raycastLine=Ji.CreateRaycastLine()),this._raycastHitPoint||(this._raycastHitPoint=Ji.CreateRaycastHitPoint()),this.webXR.Rig?.add(this.hand),this.webXR.Rig?.add(this.controllerGrip),this.webXR.Rig?.add(this.controller),this.webXR.Rig?.add(this.raycastLine),this.raycastLine?.add(this._raycastHitPoint),this._raycastHitPoint.visible=!1,this.hand.add(this.handPointerModel),ku&&console.log("ADDED TO RIG",this.webXR.Rig)}onDisable(){this.hand?.removeFromParent(),this.controllerGrip?.removeFromParent(),this.controller?.removeFromParent(),this.raycastLine?.removeFromParent(),this._raycastHitPoint?.removeFromParent();let A=this.webXR.Controllers.indexOf(this);A>=0&&this.webXR.Controllers.splice(A,1)}_isConnected=!1;onSourceConnected(A){if(this._isConnected){console.warn("Received connected event for controller that is already connected",this.index,A);return}this._isConnected=!0,this.input=A.data,this.type===1&&(this.onSelectStart(),this.createPointerEvent("down"))}onSourceDisconnected(A){if(!this._isConnected){console.warn("Received discnnected event for controller that is not connected",A);return}this._isConnected=!1,this.type===1&&(this.onSelectEnd(),this.createPointerEvent("up")),this.input=null}createPointerEvent(A){switch(A){case"down":this.context.input.createPointerDown({clientX:0,clientY:0,button:this.index,pointerType:"touch"});break;case"move":break;case"up":this.context.input.createPointerUp({clientX:0,clientY:0,button:this.index,pointerType:"touch"});break}}rayRotation=new KA;update(){this.context.time.frameCount%60===0&&(this.setControllerLayers(this.controller,2),this.setControllerLayers(this.controllerGrip,2),this.setControllerLayers(this.hand,2));let A=Ji.eventSubs["update"];if(A&&A.length>0)for(let i of A)i(this);let e=1;this.type===0?e=this.context.time.deltaTime/.1:this.isUsingHands&&this.handPointerModel.pinched&&(e=this.context.time.deltaTime/.3),this.rayRotation.slerp(bt(this.controller),this.useSmoothing?e:1);let t=ge(this.controller);if(this.isUsingHands&&this.handPointerModel.cursorObject&&(this.handPointerModel.cursorObject.visible=!1),this.raycastLine){let i=this.showRaycastLine&&this.type!==1;if(this.type===1)this.raycastLine.visible=!1;else if(this.isUsingHands){this.raycastLine.visible=!this.grabbed&&i,at(this.raycastLine,t);let g=this.hand.joints;if(g&&g.wrist&&this.grabbed&&this.grabbed.isCloseGrab){let n=this.getWristQuaternion();n&&this.rayRotation.copy(n)}Og(this.raycastLine,this.rayRotation)}else this.raycastLine.visible=i,Og(this.raycastLine,this.rayRotation),at(this.raycastLine,t)}this.lastHit=this.updateLastHit(),this.grabbed&&this.grabbed.update(),this._selectionPressedLastFrame=this._selectionPressed,this.selectStartCallback&&this.selectStartCallback()}_pinchStartTime=void 0;onUpdate(A){if(this.lastHit=null,!A||A.inputSources.length<=this.index){this.input=null;return}if(this.type===0&&(this.input=A.inputSources[this.index]),!this.input)return;let e=this.webXR.Rig;if(!e)return;this._didNotEndSelection&&!this.handPointerModel.pinched&&(this._didNotEndSelection=!1,this.onSelectEnd()),this.updateStick(this.input);let t=this.input?.gamepad?.buttons;switch(this.input.handedness){case"left":let i=3*Ji.MovementSpeedFactor,g=2,o=VA.clamp01(this.joystick.length()*2),n=this.joystick.x>0?1:-1,C=Math.pow(this.joystick.x,g);C*=n,C*=o;let s=this.joystick.y>0?1:-1,r=Math.pow(this.joystick.y,g);r*=s,C*=o,e.getWorldQuaternion(this.worldRot),this.movementVector.set(C,0,r),this.movementVector.applyQuaternion(this.webXR.TransformOrientation),this.movementVector.y=0,this.movementVector.applyQuaternion(this.worldRot),this.movementVector.multiplyScalar(i*this.context.time.deltaTime),e.position.add(this.movementVector),this.isUsingHands&&this.runTeleport(e,t);break;case"right":let a=this.joystick.x,B=Math.abs(a);if(B<.4)this.didRotate=!1;else if(B>.5&&!this.didRotate){let Q=a>0?-1:1;e.rotateY(VA.toRadians(30*Q)),this.didRotate=!0}this.runTeleport(e,t);break}}runTeleport(A,e){let t=-this.joystick.y;if(this.hand?.visible&&!this.grabbed){let n=this.handPointerModel.isPinched();n&&this._pinchStartTime===void 0&&(this._pinchStartTime=this.context.time.time),n&&this._pinchStartTime&&this.context.time.time-this._pinchStartTime>.8&&(t=this.handPointerModel.isPinched()?1:0),n||(this._pinchStartTime=void 0)}else this._pinchStartTime=void 0;let i=t>.5&&this.webXR.IsInVR,g=this.webXR.Rig?this.webXR.Rig?.scale?.x<.999:!1,o=null;if(e&&this.input&&!this.input.hand)for(let n=0;n<e.length;n++){let C=e[n];if(n===4)if(C.pressed&&!this.didChangeScale&&this.webXR.IsInVR){this.didChangeScale=!0;let s=this.webXR.Rig;if(s)if(g){g=!1,s.scale.set(1,1,1),o=1,Ji.MovementSpeedFactor=1;let r=this.context.mainCamera;Ji.PreviousCameraFarDistance&&(r.far=Ji.PreviousCameraFarDistance)}else{g=!0,i=!0,o=.1,Ji.MovementSpeedFactor=o*2;let r=this.context.mainCamera;Ji.PreviousCameraFarDistance=r.far,r.far/=o}}else C.pressed||(this.didChangeScale=!1)}if(i){if(!this.didTeleport){let n=this.raycast();if(this.didTeleport=!0,n&&n.length>0){let C=n[0];if(g||this.isValidTeleportTarget(C.object)){let s=C.point;at(A,s)}}}}else t<.1&&(this.didTeleport=!1);o!==null&&(A.scale.set(o,o,o),A.updateMatrixWorld())}isValidTeleportTarget(A){return IA.getComponentInParent(A,xB)!=null}updateStick(A){!A||!A.gamepad||A.gamepad.axes?.length<4||(this.joystick.x=A.gamepad.axes[2],this.joystick.y=A.gamepad.axes[3])}updateLastHit(){let A=this.raycast(),e=A?A[0]:null;this.lastHit=e;let t=1;if(this.webXR.Rig&&(t/=this.webXR.Rig.scale.x),this.raycastLine){this.raycastLine.scale.z=t*(this.lastHit?.distance??9999);let i=this.raycastLine.material;e!=null?i.color=Ji.raycastColor:i.color=Ji.raycastNoHitColor}if(this._raycastHitPoint){if(this.lastHit!=null){this._raycastHitPoint.position.z=-1;let i=VA.clamp(this.lastHit.distance*.01*t,.015,.1);this._raycastHitPoint.scale.set(i,i,i)}this._raycastHitPoint.visible=this.lastHit!==null&&this.lastHit!==void 0}return e}onSelectStart(){!this.context.connection.allowEditing||(this.selectStartCallback=()=>this.onHandleSelectStart())}selectStartCallback=null;lastSelectStartObject=null;onHandleSelectStart(){this.selectStartCallback=null,this._selectionPressed=!0,this._selectionStartTime=this.context.time.time,this._selectionEndTime=1e3;let A=null,e=!1;if(this.isUsingHands?(A=this.overlap(),A.length<=0?(A=this.raycast(),e=!1):e=!0):A=this.raycast(),ku&&console.log("onHandleSelectStart","close grab? "+e,"intersections",A),A&&A.length>0)for(let t of A){let i=t.object;this.lastSelectStartObject=i;let g={selected:i,grab:i},o=Ji.eventSubs["select-start"];if(o&&o.length>0)for(let n of o)n(this,g);g.grab!==i&&ku&&console.log("Grabbed object changed","original",i,"new",g.grab),g.grab&&(this.grabbed=aI.TryTake(this,g.grab,t,e));break}else{let t=Ji.eventSubs["select-start"],i={selected:null,grab:null};if(t&&t.length>0)for(let g of t)g(this,i)}}_didNotEndSelection=!1;onSelectEnd(){if(this.isUsingHands&&this.handPointerModel.pinched){this._didNotEndSelection=!0;return}if(!this._selectionPressed)return;this.selectStartCallback=null,this._selectionPressed=!1,this._selectionEndTime=this.context.time.time;let A={grab:this.grabbed?.selected??this.lastSelectStartObject},e=Ji.eventSubs["select-end"];if(e&&e.length>0)for(let t of e)t(this,A);this.grabbed&&(this.grabbed.free(),this.grabbed=null)}testIsVisible(A){return!(!A||IA.isActiveInHierarchy(A)===!1||sn.isInteractable(A)===!1)}setControllerLayers(A,e){if(!!A&&(A.layers.set(e),A.children))for(let t of A.children)this.grabbed?.selected===t||this.grabbed?.selectedMesh===t||this.setControllerLayers(t,e)}getRay(){let A=new Lg;return A.origin.copy(ge(this.controller)),A.direction.set(0,0,-1).applyQuaternion(this.rayRotation),A}closeGrabBoundingBoxHelper;overlap(){let A=this.isUsingHands&&this.handPointerModel?this.handPointerModel.pointerObject:this.controllerGrip;if(ku&&(!this.closeGrabBoundingBoxHelper&&A&&(this.closeGrabBoundingBoxHelper=new LC(A,16776960),this.scene.add(this.closeGrabBoundingBoxHelper)),this.closeGrabBoundingBoxHelper&&A&&this.closeGrabBoundingBoxHelper.setFromObject(A)),!A)return new Array;let e=ge(A).clone();return this.context.physics.sphereOverlap(e,.02)}raycast(){let A=new vt;A.layerMask=new vg,A.layerMask.set(0),A.layerMask.disable(2),A.ray=this.getRay();let e=this.context.physics.raycast(A);for(let t=0;t<e.length;t++){let i=e[t],g=i.object;if(!this.testIsVisible(g)){e.splice(t,1),t--;continue}i.object=sn.getObject(g);break}return e}},it=Ji;uA(it,"Factory",new L8),uA(it,"raycastColor",new W(.9,.3,.3)),uA(it,"raycastNoHitColor",new W(.6,.6,.6)),uA(it,"geometry",new le().setFromPoints([new k(0,0,0),new k(0,0,-1)])),uA(it,"handModels",{}),uA(it,"eventSubs",{}),uA(it,"PreviousCameraFarDistance"),uA(it,"MovementSpeedFactor",1);var Xg=class{static AddEventListener(A,e){return Xg.Events[A]||(Xg.Events[A]=[]),Xg.Events[A].push(e),e}static RemoveEventListener(A,e){if(!e||!Xg.Events[A])return;let t=Xg.Events[A].indexOf(e);t>=0&&Xg.Events[A].splice(t,1)}static Register(A){this.Current.find(e=>e===A)||this.Current.push(A)}static Remove(A){let e=this.Current.indexOf(A);e>=0&&this.Current.splice(e,1)}static TryTake(A,e,t,i){let g=IA.getComponentInParent(e,ao);if(g)e=g.gameObject;else return ku&&console.warn("Prevented taking object that is not interactable",e),null;let o=e,n=IA.getComponentInParent(e,NI);n&&(n.requestOwnership(),o=n.gameObject);for(let s of this.Current)if(s.selected===o)return s.controller===A||(s.free(),s.Take(A,o,e,n,g,t,i)),s;let C=new Xg;return C.Take(A,o,e,n,g,t,i),C}sync=null;selected=null;selectedParent=null;selectedMesh=null;controller=null;grabTime=0;grabUUID="";isCloseGrab=!1;originalMaterial=null;usageMarker=null;rigidbodies=null;didReparent=!1;grabDistance=0;interactable=null;positionSource=null;Take(A,e,t,i,g,o,n){if(console.assert(e!==null,"Expected object to be taken but was",e),A.isUsingHands?this.positionSource=n?A.wrist:A.controller:this.positionSource=A.controller,!this.positionSource)return console.warn("No position source"),this;let C={controller:A,take:e,hit:t,sync:i,interactable:g};Xg.Events.WillTake?.forEach(Q=>Q(this,C));let s=t;s?.material&&(this.originalMaterial=s.material,Array.isArray(s.material)||(s.material=s.material.clone(),s.material&&s.material.emissive&&(s.material.emissive.b=.2))),this.selected=e,this.selectedParent||(this.selectedParent=e.parent),this.selectedMesh=s,this.controller=A,this.interactable=g,this.isCloseGrab=n,this.didReparent=!1,this.sync=i,this.grabTime=A.context.time.time,this.grabUUID=Date.now().toString(),this.usageMarker=IA.addNewComponent(this.selected,Bo),this.rigidbodies=IA.getComponentsInChildren(this.selected,je),ge(this.positionSource,this.lastControllerWorldPos);let r=()=>n?this.lastControllerWorldPos.clone():o.point.clone();this.grabDistance=r().distanceTo(this.lastControllerWorldPos),this.totalChangeAlongDirection=0,this.localPositionOffsetToGrab=this.selected.worldToLocal(r());let a=A.isUsingHands&&n?this.controller.getWristQuaternion().clone():A.rayRotation.clone();bt(this.selected,this.localQuaternionToGrab).premultiply(a.invert());let B=this.controller.webXR.Rig;return B&&this.rigPositionLastFrame.copy(ge(B)),Wt.Add(A.context,this.selected),Xg.Register(this),this.sync&&(this.sync.fastMode=!0),Xg.Events.DidTake?.forEach(Q=>Q(this,C)),this}free(){if(!this.selected)return;let A={controller:this.controller,take:this.selected,hit:this.selected,sync:this.sync,interactable:null};Xg.Events.WillFree?.forEach(i=>i(this,A)),Wt.Remove(this.controller.context,this.selected),Xg.Remove(this),this.sync&&(this.sync.fastMode=!1);let e=this.selectedMesh;e&&this.originalMaterial&&e.material&&(e.material=this.originalMaterial);let t=this.selected;if(this.didReparent&&t.parent){let i=this.selectedParent;i?i.attach(t):this.controller?.context.scene.attach(t)}if(this.usageMarker?.destroy(),this.controller&&(this.controller.grabbed=null),this.selected=null,this.selectedParent=null,this.selectedMesh=null,this.sync=null,this.rigidbodies)for(let i of this.rigidbodies)i.wakeUp(),i.setVelocity(i.smoothedVelocity);this.rigidbodies=null,this.localPositionOffsetToGrab=null,this.quaternionLerp=null,Xg.Events.DidFree?.forEach(i=>i(this,A))}grabPoint=new k;localPositionOffsetToGrab=null;localPositionOffsetToGrab_worldSpace=new k;localQuaternionToGrab=new KA(0,0,0,1);targetDir=null;quaternionLerp=null;controllerDir=new k;controllerWorldPos=new k;lastControllerWorldPos=new k;controllerPosDelta=new k;totalChangeAlongDirection=0;rigPositionLastFrame=new k;controllerMovementSinceLastFrame(){if(!this.positionSource||!this.controller)return 0;this.controllerDir.set(0,0,-1),this.controllerDir.applyQuaternion(this.controller.rayRotation),ge(this.positionSource,this.controllerWorldPos),this.controllerPosDelta.copy(this.controllerWorldPos),this.controllerPosDelta.sub(this.lastControllerWorldPos),this.lastControllerWorldPos.copy(this.controllerWorldPos);let A=this.controller.webXR.Rig;if(A){let t=ge(A),i=this.rigPositionLastFrame.sub(t);this.controllerPosDelta.add(i),this.rigPositionLastFrame.copy(t)}return this.controllerDir.dot(this.controllerPosDelta)}update(){if(this.rigidbodies)for(let A of this.rigidbodies)A.resetVelocities();if(this.sync&&this.controller&&this.controller.context.connection.isInRoom&&this.controller.context.time.time-this.grabTime>3&&this.sync.hasOwnership()===!1&&(console.log("no ownership, will leave",this.sync.guid),this.free()),!(this.interactable&&!this.interactable.canGrab)){if(!this.didReparent&&this.selected&&this.controller){let A=this.controller.webXR.Rig?.scale.x??1;this.totalChangeAlongDirection+=this.controllerMovementSinceLastFrame();let e=1;this.controller.type===0&&(e=Math.max(0,1+this.totalChangeAlongDirection*2/A),e=e*e*e),this.grabDistance/A<.8&&(e=1),this.targetDir||(this.targetDir=new k),this.targetDir.set(0,0,-this.grabDistance*e);let t=this.targetDir.applyQuaternion(this.controller.rayRotation).add(this.controllerWorldPos),i=this.controller.rayRotation.clone().multiplyQuaternions(this.controller.rayRotation,this.localQuaternionToGrab);this.quaternionLerp||(this.quaternionLerp=i.clone()),this.quaternionLerp.slerp(i,this.controller.useSmoothing?this.controller.context.time.deltaTime/.03:1),Og(this.selected,this.quaternionLerp),this.selected.updateWorldMatrix(!1,!1),this.grabPoint.copy(t),this.localPositionOffsetToGrab&&(this.localPositionOffsetToGrab_worldSpace.copy(this.localPositionOffsetToGrab),this.selected.localToWorld(this.localPositionOffsetToGrab_worldSpace).sub(ge(this.selected)),t.sub(this.localPositionOffsetToGrab_worldSpace)),at(this.selected,t)}if(this.rigidbodies!=null)for(let A of this.rigidbodies)A.wakeUp();Et.markDirty(this.selected,!0)}}},aI=Xg;uA(aI,"Events",{}),uA(aI,"Current",[]);var T8=sA("debugmouth"),qr=class extends EA{idle=[];talking=[];marker=null;voip=null;lastMouthChangeTime=0;mouthChangeLength=0;awake(){setTimeout(()=>{this.voip=IA.findObjectOfType(Zg,this.context),this.marker||(this.marker=IA.getComponentInParent(this.gameObject,Dt))},3e3)}update(){if(!this.voip||this.context.time.frameCount%10!==0)return;let A=this.marker?.connectionId??null;if(!A){T8&&(A=null);return}let e=this.voip.getFrequency(A)??0;this.updateLips(e)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;let e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;let e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(!!A){A!=this.idle?this.idle.map(t=>t.visible=!1):this.talking.map(t=>t.visible=!1);for(let t=0;t<A.length;t++){let i=A[t];i&&(i.visible=t===e)}}}};U([F(vA)],qr.prototype,"idle",2),U([F(vA)],qr.prototype,"talking",2);var Xc=class extends EA{voip=null;marker=null;_startPosition=null;awake(){this.voip=IA.findObjectOfType(Zg,this.context),this.marker=IA.getComponentInParent(this.gameObject,Dt)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;let A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let t=e/100;this.gameObject.position.y=this._startPosition.y+t*.07}};var Zn=class extends EA{eyes=[];lastBlinkTime=0;blinkLength=0;eyesOpen=!0;state=null;awake(){this.state=IA.getComponentInParent(this.gameObject,Ii)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(let e of this.eyes)e&&(e.visible=this.eyesOpen)}}};U([F(vA)],Zn.prototype,"eyes",2),U([F()],Zn.prototype,"lastBlinkTime",2),U([F()],Zn.prototype,"blinkLength",2),U([F()],Zn.prototype,"eyesOpen",2);var OU=class extends EA{head=null;eyes=null;target=null;brain=null;awake(){this.brain||(this.brain=IA.getComponentInParent(this.gameObject,As)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=IA.addNewComponent(this.gameObject,As)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}vec=new k;currentTargetPoint=new k;update(){let A=this.target;if(A&&this.head){let e=this.eyes;if(e){let t=ge(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);let i=ge(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;let o=OU.forward;if(o.set(0,0,1),o.applyQuaternion(bt(this.head)),o.dot(g)>.45)for(let C=0;C<e.length;C++)e[C].lookAt(this.currentTargetPoint)}}}},Xn=OU;uA(Xn,"forward",new k(0,0,1)),U([F(vA)],Xn.prototype,"head",2),U([F(vA)],Xn.prototype,"eyes",2),U([F(vA)],Xn.prototype,"target",2);var gs=class extends EA{length=1;depthTest=!0;isGizmo=!0;_axes=null;onEnable(){if(this.isGizmo&&!Nn)return;this._axes||(this._axes=new yI(this.length)),this.gameObject.add(this._axes);let A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){!this._axes||this.gameObject.remove(this._axes)}};U([F()],gs.prototype,"length",2),U([F()],gs.prototype,"depthTest",2),U([F()],gs.prototype,"isGizmo",2);var $c=class extends EA{from;to;hint;desiredDistance=1;onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let A=ge(this.to).clone(),e=ge(this.from).clone(),t=A.distanceTo(e),i=A.clone();i.sub(e);let g=e.clone();g.add(A),g.multiplyScalar(.5);let o=ge(this.hint).clone();o.sub(g);let n=new k;n.crossVectors(o,i),n.crossVectors(i,n),n.normalize();let C=t*.5,s=Math.max(this.desiredDistance,C),r=Math.sqrt(s*s-C*C),a=n.clone();a.multiplyScalar(r),a.add(g),at(this.gameObject,a);let B=g.clone();B.sub(n),this.gameObject.lookAt(B)}};var JI=class extends EA{get isCollider(){return!0}attachedRigidbody=null;isTrigger=!1;sharedMaterial;awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}onDisable(){this.context.physics.removeBody(this)}};U([F(je)],JI.prototype,"attachedRigidbody",2),U([F()],JI.prototype,"isTrigger",2),U([F()],JI.prototype,"sharedMaterial",2);var br=class extends JI{radius=.5;center=new k(0,0,0);onEnable(){super.onEnable(),this.context.physics.addSphereCollider(this,this.center,this.radius)}};U([F()],br.prototype,"radius",2),U([F(k)],br.prototype,"center",2);var xr=class extends JI{size=new k(1,1,1);center=new k(0,0,0);onEnable(){super.onEnable(),this.context.physics.addBoxCollider(this,this.center,this.size)}};U([F(k)],xr.prototype,"size",2),U([F(k)],xr.prototype,"center",2);var LB=class extends JI{sharedMesh;convex=!1;onEnable(){super.onEnable(),this.sharedMesh?.isMesh||this.gameObject instanceof we&&(this.sharedMesh=this.gameObject),this.sharedMesh?.isMesh&&this.context.physics.addMeshCollider(this,this.sharedMesh,this.convex,Fi(this.gameObject))}};U([F()],LB.prototype,"convex",2);var co=class extends JI{center=new k(0,0,0);radius=.5;height=2;onEnable(){super.onEnable(),this.context.physics.addCapsuleCollider(this,this.center,this.height,this.radius)}};U([F(k)],co.prototype,"center",2),U([F()],co.prototype,"radius",2),U([F()],co.prototype,"height",2);var H8=sA("gizmos"),Y8=sA("debugboxhelper"),lo=class extends EA{box=null;_lastMatrixUpdateFrame=-1;isInBox(A,e){if(!A)return;if(this.box||(this.box=new Ot),A.type==="Mesh")lo.testBox.setFromObject(A);else if(A.type==="Group"){if(lo.testBox.makeEmpty(),A.children.length>0)for(let i=0;i<A.children.length;i++)A.children[i].type==="Mesh"&&lo.testBox.expandByObject(A)}else{let i=ge(A,lo._position),g=Fi(A,lo._size);e!==void 0&&g.multiplyScalar(e),lo.testBox.setFromCenterAndSize(i,g)}this.updateBox();let t=this.box?.intersectsBox(lo.testBox);return t&&Y8&&GI.DrawBox3(lo.testBox,16711680,5),t}intersects(A){return A?this.updateBox(!1).intersectsBox(A):!1}updateBox(A=!1){if(this.box||(this.box=new Ot),A||this.context.time.frameCount!=this._lastMatrixUpdateFrame){let e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;let t=e,i=ge(this.gameObject,lo._position,t),g=Fi(this.gameObject,lo._size);this.box.setFromCenterAndSize(i,g)}return this.box}_helper=null;_color=null;awake(){this._helper=null,this._color=null,this.box=null}showHelper(A=null,e=!1){if(!(!H8&&!e)){if(this._helper){A&&this._color?.set(A),this.gameObject.add(this._helper);return}this._helper=Lw(A),this.gameObject.add(this._helper)}}},ig=lo;uA(ig,"testBox",new Ot),uA(ig,"_position",new k),uA(ig,"_size",new k(.01,.01,.01));function PU(I){let A=I[rI];return A||(I.parent?PU(I.parent):null)}function Al(I,A){if(!I)return;let e=I.material;e?.isMaterial===!0&&(e.depthTest=!A.renderOnTop,e.side=A.doubleSided??!0?Ei:bg,e.depthWrite=A.depthWrite??!1,e.shadowSide=A.doubleSided?Ei:bg,I.castShadow=A.castShadows?A.castShadows:!1,I.receiveShadow=A.receiveShadows?A.receiveShadows:!1);for(let t of I.children)Al(t,A)}function Vy(I,A,e){I[A]===void 0&&console.warn("Field",A,"is undefined on",I);let t=Proxy.revocable(I[A],{set(o,n,C,s){let r=o[n],a=Reflect.set(o,n,C,s);return e(C,r),a}}),i=t.revoke,g=I[A];return t.revoke=()=>{I[A]=g,i()},I[A]=t.proxy,t}var ST=Symbol("Scheduled action");function mT(I,A,e=3){let t=I[ST];t||(t=I[ST]={});let i=A.name;t[e]||(t[e]={});let g=t[e];if(g[i])return;function*n(){A?.call(I),g[i]=null}let C=I.startCoroutine(n(),e);g[i]=C}var MT=sA("debugui"),el=class{width;height},vB=class{x;y;width;height},BI=class extends tg{offset=.01;get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}_anchoredPosition;get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new k),this._anchoredPosition}rect;sizeDelta;anchoredPosition3D;pivot;lastMatrix;rectBlock;_transformNeedsUpdate=!1;awake(){super.awake(),this.lastMatrix=new zA,this.rectBlock=new vA,this.rectBlock.position.z=.1,this.rectBlock.name=this.name,this._anchoredPosition||(this._anchoredPosition=new k),Vy(this,"_anchoredPosition",()=>{this._transformNeedsUpdate=!0})}onEnable(){super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0}onDisable(){super.onDisable(),this.removeShadowComponent()}applyTransform(){let A=this.shadowComponent;!A||(this._transformNeedsUpdate=!1,this.isRoot()?A.rotation.y=Math.PI:(A.position.copy(this.gameObject.position),A.position.x*=-1,A.position.z*=-1,A.position.z-=this.offset,A.quaternion.copy(this.gameObject.quaternion),A.rotation.x*=-1,A.rotation.z*=-1,A.scale.copy(this.gameObject.scale)),this.applyAnchoring(A.position),this.lastMatrix.copy(this.gameObject.matrix))}markDirty(){this._transformNeedsUpdate=!0}onBeforeRender(){(this._transformNeedsUpdate||this.lastMatrix.equals(this.gameObject.matrix)===!1)&&(MT&&console.log("updating",this.name),this.applyTransform()),wg.ensureUpdateMeshUI(Wc,this.context)}applyAnchoring(A){if(this.pivot&&this.sizeDelta){let e=this.pivot.x*2-1,t=this.pivot.y*2-1;t-=this.anchoredPosition.y*.05;let i=this.sizeDelta.x*e,g=this.sizeDelta.y*t;A.x-=i*.5,A.y-=g*.5}}getBasicOptions(){let A={width:this.rect.width,height:this.rect.height,offset:this.offset,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}_createdBlocks=[];createNewBlock(A){A={...this.getBasicOptions(),...A},MT&&console.log(this.name,A);let e=new mu(A);return this._createdBlocks.push(e),e}};U([F(vB)],BI.prototype,"rect",2),U([F(SA)],BI.prototype,"sizeDelta",2),U([F(k)],BI.prototype,"anchoredPosition3D",2),U([F(SA)],BI.prototype,"pivot",2);var Ru=class extends tg{get isGraphic(){return!0}get color(){return this._color||(this._color=new ve(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new ve(1,1,1,1)),this._color.copy(A))}onColorChanged(){let A=this.color;this.setOptions({backgroundColor:A,backgroundOpacity:A.alpha,borderOpacity:A.alpha})}get m_Color(){return this._color}raycastTarget=!0;uiObject=null;_color=null;_rect=null;get rectTransform(){return this._rect||(this._rect=IA.getComponent(this.gameObject,BI)),this._rect}setState(A){this.makePanel(),this.uiObject&&this.uiObject.setState(A)}setupState(A){this.makePanel(),this.uiObject&&this.uiObject.setupState(A)}setOptions(A){this.makePanel(),this.uiObject&&(this.uiObject.set(A),(A.backgroundColor!==void 0||A.backgroundOpacity!==void 0)&&this.uiObject.updateBackgroundMaterial?.call(this.uiObject))}awake(){super.awake(),this.makePanel(),Vy(this,"_color",()=>mT(this,this.onColorChanged))}onEnable(){super.onEnable(),this.uiObject&&(this.rectTransform.shadowComponent?.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}_currentlyCreatingPanel=!1;makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;let A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:1};this.onBeforeCreate(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}async setTexture(A){if(!!A&&(this.setOptions({backgroundOpacity:0}),A)){if(A.encoding===me)if(Ru.textureCache.has(A))A=Ru.textureCache.get(A);else{let e=A.clone();e.encoding=cg,Ru.textureCache.set(A,e),A=e}this.setOptions({backgroundTexture:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},QI=Ru;uA(QI,"textureCache",new Map),U([F(ve)],QI.prototype,"color",1),U([F()],QI.prototype,"raycastTarget",2);var Is=class extends QI{onAfterCreated(){this.uiObject&&(this.uiObject.scale.y*=-1)}};var zy=class{texture;rect};U([F(Ye)],zy.prototype,"texture",2);var os=class extends Is{get sprite(){return this._sprite}set sprite(A){this._sprite!==A&&(this._sprite=A,this.onAfterCreated())}_sprite;isBuiltinSprite(){switch(this.sprite?.texture?.name){case"InputFieldBackground":case"UISprite":case"Background":return!0}return this.sprite?.texture?.image?.width===32&&this.sprite?.texture?.image?.height===32}onBeforeCreate(A){this.isBuiltinSprite()&&(A.borderRadius=5,A.borderColor=new W(.4,.4,.4),A.borderOpacity=this.color.alpha,A.borderWidth=.3)}onAfterCreated(){!this.__didAwake||(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture(this.sprite?.texture))}};U([F(zy)],os.prototype,"sprite",1);var TB=class extends Is{get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}_mainTexture;onAfterCreated(){!this.__didAwake||(super.onAfterCreated(),this.setTexture(this.mainTexture))}};U([F(Ye)],TB.prototype,"mainTexture",1);var tl=sA("debugbutton");var ns=class{colorMultiplier;disabledColor;fadeDuration;highlightedColor;normalColor;pressedColor;selectedColor};U([F()],ns.prototype,"colorMultiplier",2),U([F(ve)],ns.prototype,"disabledColor",2),U([F()],ns.prototype,"fadeDuration",2),U([F(ve)],ns.prototype,"highlightedColor",2),U([F(ve)],ns.prototype,"normalColor",2),U([F(ve)],ns.prototype,"pressedColor",2),U([F(ve)],ns.prototype,"selectedColor",2);var ho=class extends EA{onClick;_isHovered=!1;onPointerEnter(A){tl&&console.log("Button Enter",this.animationTriggers?.highlightedTrigger,this.animator),this._isHovered=!0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&this._image?.setState("hovered"),this.context.input.setCursorPointer()}onPointerExit(){tl&&console.log("Button Exit",this.animationTriggers?.highlightedTrigger,this.animator),this._isHovered=!1,this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState("normal"),this.context.input.setCursorNormal()}onPointerDown(A){tl&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&this._image?.setState("pressed")}onPointerUp(A){tl&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState(this._isHovered?"hovered":"normal")}onPointerClick(A){tl&&console.trace("Button Click",this.onClick),this.onClick?.invoke()}colors;transition;animationTriggers;animator;set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}_interactable=!0;set_interactable(A){this.interactable=A}awake(){super.awake(),tl&&console.log(this),this.init()}start(){this._image?.setInteractable(this.interactable)}onEnable(){super.onEnable()}_requestedAnimatorTrigger;*setAnimatorTriggerAtEndOfFrame(A){this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&this.animator?.SetTrigger(A)}_isInit=!1;_image;init(){this._isInit||(this._isInit=!0,this._image=IA.getComponent(this.gameObject,os),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){A.setInteractable(this.interactable);let e=this.getFinalColor(A.color,this.colors?.normalColor),t={state:"normal",attributes:{backgroundColor:e,backgroundOpacity:e.alpha}};A.setupState(t);let i=this.getFinalColor(A.color,this.colors?.highlightedColor),g={state:"hovered",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};A.setupState(g);let o=this.getFinalColor(A.color,this.colors?.pressedColor),n={state:"pressed",attributes:{backgroundColor:o,backgroundOpacity:o.alpha}};A.setupState(n);let C=this.getFinalColor(A.color,this.colors?.selectedColor),s={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};A.setupState(s);let r=this.getFinalColor(A.color,this.colors?.disabledColor),a={state:"disabled",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};A.setupState(a)}getFinalColor(A,e){return e?A.clone().multiply(e):A.clone()}};U([F(Nt)],ho.prototype,"onClick",2),U([F()],ho.prototype,"colors",2),U([F()],ho.prototype,"transition",2),U([F()],ho.prototype,"animationTriggers",2),U([F(ui)],ho.prototype,"animator",2),U([F()],ho.prototype,"interactable",1);var WU=class extends is{set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop}_renderOnTop=!1;set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}_depthWrite=!1;set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}_doubleSided=!0;set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}_castShadows=!0;set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}_receiveShadows=!0;get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}_renderMode=-1;_rootCanvas;set rootCanvas(A){this._rootCanvas instanceof WU||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}_scaleFactor=1;get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){this.shadowComponent=this.gameObject,super.awake()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this.onRenderSettingsChanged()}previousAspect=-1;onBeforeRender(){this.isScreenSpace&&this.context.mainCameraComponent&&this.context.mainCameraComponent.aspect!==this.previousAspect&&(this.previousAspect=this.context.mainCameraComponent.aspect,this.updateRenderMode())}_updateRenderSettingsRoutine;onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),3))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.updateRenderMode(),Al(this.shadowComponent,this);for(let A of IA.getComponentsInChildren(this.gameObject,tg))Al(A.shadowComponent,this)}}_activeRenderMode=-1;get isScreenSpace(){return this._activeRenderMode===1||this._activeRenderMode===0}updateRenderMode(){if(this.renderMode!==this._activeRenderMode)switch(this.renderMode){case 0:case 1:let A=this.context.mainCameraComponent;if(!A)return;let e=this.gameObject;A.gameObject?.add(e);let i=A.farClipPlane;e.position.x=0,e.position.y=0,e.position.z=-i;let g=Math.tan(VA.toRadians(A.fieldOfView)*i)*(A.aspect*1.333333),o=g*(this.context.domHeight/this.context.domWidth);e.scale.x=-g,e.scale.y=o;break;case 2:break}}},gg=WU;U([F()],gg.prototype,"renderOnTop",1),U([F()],gg.prototype,"depthWrite",1),U([F()],gg.prototype,"doubleSided",1),U([F()],gg.prototype,"castShadows",1),U([F()],gg.prototype,"receiveShadows",1),U([F()],gg.prototype,"renderMode",1),U([F(gg)],gg.prototype,"rootCanvas",1),U([F()],gg.prototype,"scaleFactor",1);var Cs=class extends EA{get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}_alpha=1;interactable=!0;blocksRaycasts=!0;_isDirty=!1;markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),3))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}_buffer=[];applyChangesNow(){for(let A of IA.getComponentsInChildren(this.gameObject,QI,this._buffer)){let e=A.color;e.alpha=this._alpha,A.color=e}}};U([F()],Cs.prototype,"alpha",1),U([F()],Cs.prototype,"interactable",2),U([F()],Cs.prototype,"blocksRaycasts",2);var il=class extends ei{};var zU=class extends Kn{constructor(){super([W,ve])}onDeserialize(A){if(A!=null)return A.a!==void 0?new ve(A.r,A.g,A.b,A.a):A.alpha!==void 0?new ve(A.r,A.g,A.b,A.alpha):new W(A.r,A.g,A.b)}onSerialize(A){if(A!=null)return A.a!==void 0?{r:A.r,g:A.g,b:A.b,a:A.a}:{r:A.r,g:A.g,b:A.b}}},UEA=new zU,jU=class extends Kn{constructor(){super(vA)}onSerialize(A,e){if(e.objectToNode!==void 0&&A.uuid){let t=e.objectToNode[A.uuid];return qt&&console.log(t,A.name,A.uuid),{node:t}}}onDeserialize(A,e){if(A){if(A.node!==void 0&&e.nodeToObject){let t=e.nodeToObject[A.node];return qt&&console.log("Deserialized object reference?",A,t,e?.nodeToObject),t||console.warn("Did not find node: "+A.node,e.nodeToObject,e.object),t}else if(A.guid){if(!e.context){console.error("Missing context");return}let t,i=e.gltf?.scene;return i&&(t=IA.findByGuid(A.guid,i)),t||(t=IA.findByGuid(A.guid,e.context.scene)),t?qt&&console.log("Deserialized object reference?",A,t,e?.nodeToObject):((KD()||qt)&&console.warn("Could not resolve object reference",e.path,A,e.target,e.context.scene),A.could_not_resolve=!0),t}}}},_8=new jU,ZU=class extends Kn{constructor(){super([RI,EA])}onSerialize(A,e){if(A?.guid)return{guid:A.guid}}onDeserialize(A,e){if(A?.guid){qt&&console.log(A.guid,e.root,e.object,e.target);let t=this.findObjectForGuid(A.guid,e.root);if(t||e.context&&(t=this.findObjectForGuid(A.guid,e.context?.scene),t))return t;(KD()||qt)&&console.warn("Could not resolve component reference",e.path,A,e.target),A.could_not_resolve=!0;return}}findObjectForGuid(A,e){if(e.guid===A)return e;let t=IA.foreachComponent(e,i=>{if(i.guid===A)return i},!1);if(t!==void 0)return t;for(let i=0;i<e.children.length;i++){let g=e.children[i],o=this.findObjectForGuid(A,g);if(o)return o}}},VU=new ZU,XU=class extends Kn{constructor(){super([Nt])}onSerialize(A,e){console.log("TODO: SERIALIZE EVENT")}onDeserialize(A,e){if(typeof A=="function")return new Nt([new gn(A,!0)]);if(A&&A.type==="EventList"){qt&&console.log("DESERIALIZE EVENT",A);let t=new Array;if(A.calls&&Array.isArray(A.calls))for(let o of A.calls){qt&&console.log(o);let n=VU.findObjectForGuid(o.target,e.root);!n&&e.context?.scene&&(n=VU.findObjectForGuid(o.target,e.context?.scene));let C=o.method?.length>0;if(n&&C){let B=()=>console.warn(`Could not find method ${o.method} on object ${n.name}`,n,typeof n[o.method]);if(typeof n[o.method]!="function"){let Q=!1;o.method.startsWith("set_")&&o.method.length>4&&(o.method=o.method.substring(4),n[o.method]!==void 0&&(Q=!0)),!Q&&(KD()||qt)&&B()}}let s,r=o.argument;o.argument!==void 0?(typeof r=="object"&&(r=_8.onDeserialize(o.argument,e),r||(r=VU.onDeserialize(o.argument,e))),s=new gn(C?(...B)=>a(...B):void 0,o.enabled)):s=new gn(C?(...B)=>a(...B):void 0,o.enabled);let a=(...B)=>{let Q=n[o.method];typeof Q=="function"?r!==void 0?Q?.call(n,r):Q?.call(n,...B):n[o.method]=r};if(s.method||(s.__debuginfo=e.object?.name),!n||!s.method){let B=e.object?"Current object: "+e.object.name+", "+e.object.guid:null;n?console.warn('EventList method not found: "'+o.method+'" on',n):console.warn("EventList is missing target - will be ignored",o.target,B,A)}else t.push(s)}let i=new Nt(t);qt&&console.log(i);let g=e.target;return g!==void 0&&e.path!==void 0&&i.setEventTarget(e.path,g),i}}},FEA=new XU,$U=class extends Kn{constructor(){super([il,ei])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof Ye&&e.type===il){let t=A,i=new il(t.image.width,t.image.height);return i.texture=t,i}}};new $U;var $n=class extends EA{center=new k(0,0,0);radius=.5;height=2;_rigidbody=null;get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(je),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(je)),this.rigidbody)}onEnable(){let A=this.rigidbody,e=this.gameObject.getComponent(co);e||(e=this.gameObject.addNewComponent(co)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}_activeGroundCollisions=new Set;onCollisionEnter(A){for(let e of A.contacts)if(e.normal.y>.1){this._activeGroundCollisions.add(A);break}}onCollisionExit(A){this._activeGroundCollisions.delete(A)}get isGrounded(){return this._activeGroundCollisions.size>0}};U([F(k)],$n.prototype,"center",2),U([F()],$n.prototype,"radius",2),U([F()],$n.prototype,"height",2);var rn=class extends EA{controller;movementSpeed=2;rotationSpeed=2;jumpForce=1;animator;lookForward=!0;_currentSpeed=new k(0,0,0);_currentAngularSpeed=new k(0,0,0);_temp=new k(0,0,0);_jumpCount=0;_currentRotation;awake(){this._currentRotation=new KA}update(){this.controller?.isGrounded&&(this._jumpCount=0,this.animator?.SetBool("doubleJump",!1));let A=this.context.input.isKeyPressed("w"),e=this.context.input.isKeyPressed("s"),t=this.context.input.isKeyPressed("a"),i=this.context.input.isKeyPressed("d"),g=this.context.input.isKeyDown(" "),o=A?1:0+e?-1:0;this._currentSpeed.z+=o*this.movementSpeed*this.context.time.deltaTime,this.animator?.SetBool("running",o!=0),this.animator?.SetBool("jumping",this.controller?.isGrounded===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);let n=t?1:0+i?-1:0;if(this._currentAngularSpeed.y+=VA.toRadians(n*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){let C=this.context.mainCameraComponent.forward;C.y=0,C.normalize(),this._currentRotation.setFromUnitVectors(new k(0,0,1),C),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let C=this.controller?.isGrounded;if(!this.controller?.isGrounded&&this._jumpCount===1&&(C=!0,this.animator?.SetBool("doubleJump",!0)),C){this._jumpCount+=1;let s=this.controller.rigidbody,r=this._jumpCount===2?2:1;s.applyImpulse(new k(0,1,0).multiplyScalar(this.jumpForce*r))}}if(this.controller){let C=this.controller?.rigidbody.getVelocity().y;if(C<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Lg),this._raycastOptions.ray.origin.copy(ge(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);let s=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);let r=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(s),(r.length&&r[0].distance>2||C<-10)&&this.animator?.SetBool("falling",!0)}else this.animator?.SetBool("falling",!1)}}_raycastOptions=new vt};U([F($n)],rn.prototype,"controller",2),U([F()],rn.prototype,"movementSpeed",2),U([F()],rn.prototype,"rotationSpeed",2),U([F()],rn.prototype,"jumpForce",2),U([F(ui)],rn.prototype,"animator",2);var jy=sA("debugvolume"),kT=(t=>(t[t.None=0]="None",t[t.Neutral=1]="Neutral",t[t.ACES=2]="ACES",t))(kT||{}),gl=class{overrideState=!1;value=0},AC=class{active=!1;parameters},vr=class extends AC{mode;get isToneMapping(){return!0}},Tr=class extends AC{postExposure};function P8(I){return"mode"in I?vr:"postExposure"in I?Tr:AC}var GT=Symbol("volumeprofile"),Lr=class{components;apply(A){this.onUpdate(A,!1)}unapply(A){this.onUpdate(A,!0)}onUpdate(A,e){if(!this.components)return;let t=A.renderer,g=t[GT]!==void 0;if(e){if(!g)return}else t[GT]=this;for(let o of this.components)if(o instanceof vr){let n=o;if(!o.active||e){A.renderer.toneMapping=jE;continue}jy&&console.log("VOLUME:",kT[n.mode?.value??0]);let C=n.mode;switch((C?.overrideState?C?.value:0)??0){case 0:A.renderer.toneMapping=jE;break;case 1:A.renderer.toneMapping=MD;break;case 2:A.renderer.toneMapping=md;break}}else if(o instanceof Tr){let n=o;jy&&console.log(n.postExposure);let C=1;n.postExposure&&(C=Math.pow(2,n.postExposure.value)),A.renderer.toneMapping,md;let s=n.postExposure?.overrideState&&!e;A.renderer.toneMappingExposure=s?C:1,A.renderer.toneMapping||(A.renderer.toneMapping=jE)}}};U([F([I=>P8(I),AC])],Lr.prototype,"components",2);var HB=class extends EA{sharedProfile;awake(){jy&&(console.log(this),console.log("Press P to toggle post processing"),window.addEventListener("keydown",A=>{A.key==="p"&&(console.log("Toggle volume: "+this.name,!this.enabled),this.enabled=!this.enabled)}))}onEnable(){jy&&console.log("APPLY VOLUME",this),this.sharedProfile?.apply(this.context)}onDisable(){this.sharedProfile?.unapply(this.context)}};U([F(Lr)],HB.prototype,"sharedProfile",2);var ecA=.5*(Math.sqrt(3)-1),tcA=(3-Math.sqrt(3))/6,icA=1/3,gcA=1/6,W8=(Math.sqrt(5)-1)/4,Ig=(5-Math.sqrt(5))/20,Zy=I=>Math.floor(I)|0;var Xy=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function RT(I=Math.random){let A=V8(I),e=new Float64Array(A).map(o=>Xy[o%32*4]),t=new Float64Array(A).map(o=>Xy[o%32*4+1]),i=new Float64Array(A).map(o=>Xy[o%32*4+2]),g=new Float64Array(A).map(o=>Xy[o%32*4+3]);return function(n,C,s,r){let a,B,Q,l,E,c=(n+C+s+r)*W8,d=Zy(n+c),p=Zy(C+c),h=Zy(s+c),u=Zy(r+c),f=(d+p+h+u)*Ig,w=d-f,S=p-f,D=h-f,y=u-f,M=n-w,N=C-S,L=s-D,x=r-y,q=0,H=0,V=0,gA=0;M>N?q++:H++,M>L?q++:V++,M>x?q++:gA++,N>L?H++:V++,N>x?H++:gA++,L>x?V++:gA++;let $=q>=3?1:0,tA=H>=3?1:0,oA=V>=3?1:0,mA=gA>=3?1:0,Y=q>=2?1:0,iA=H>=2?1:0,lA=V>=2?1:0,dA=gA>=2?1:0,v=q>=1?1:0,UA=H>=1?1:0,GA=V>=1?1:0,NA=gA>=1?1:0,hA=M-$+Ig,PA=N-tA+Ig,AA=L-oA+Ig,X=x-mA+Ig,QA=M-Y+2*Ig,RA=N-iA+2*Ig,cA=L-lA+2*Ig,OA=x-dA+2*Ig,LA=M-v+3*Ig,JA=N-UA+3*Ig,Be=L-GA+3*Ig,oe=x-NA+3*Ig,R=M-1+4*Ig,m=N-1+4*Ig,O=L-1+4*Ig,CA=x-1+4*Ig,BA=d&255,fA=p&255,YA=h&255,DA=u&255,j=.6-M*M-N*N-L*L-x*x;if(j<0)a=0;else{let MA=BA+A[fA+A[YA+A[DA]]];j*=j,a=j*j*(e[MA]*M+t[MA]*N+i[MA]*L+g[MA]*x)}let qA=.6-hA*hA-PA*PA-AA*AA-X*X;if(qA<0)B=0;else{let MA=BA+$+A[fA+tA+A[YA+oA+A[DA+mA]]];qA*=qA,B=qA*qA*(e[MA]*hA+t[MA]*PA+i[MA]*AA+g[MA]*X)}let TA=.6-QA*QA-RA*RA-cA*cA-OA*OA;if(TA<0)Q=0;else{let MA=BA+Y+A[fA+iA+A[YA+lA+A[DA+dA]]];TA*=TA,Q=TA*TA*(e[MA]*QA+t[MA]*RA+i[MA]*cA+g[MA]*OA)}let FA=.6-LA*LA-JA*JA-Be*Be-oe*oe;if(FA<0)l=0;else{let MA=BA+v+A[fA+UA+A[YA+GA+A[DA+NA]]];FA*=FA,l=FA*FA*(e[MA]*LA+t[MA]*JA+i[MA]*Be+g[MA]*oe)}let bA=.6-R*R-m*m-O*O-CA*CA;if(bA<0)E=0;else{let MA=BA+1+A[fA+1+A[YA+1+A[DA+1]]];bA*=bA,E=bA*bA*(e[MA]*R+t[MA]*m+i[MA]*O+g[MA]*CA)}return 27*(a+B+Q+l+E)}}function V8(I){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let i=t+~~(I()*(256-t)),g=e[t];e[t]=e[i],e[i]=g}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var z8=sA("debugparticles");var Bn=class{alphaKeys;colorKeys;get duration(){return 1}evaluate(A,e){let t,i=0,g=null,o=0;for(let n=0;n<this.alphaKeys.length;n++){let C=this.alphaKeys[n];(C.time<A||!t)&&(t=C,i=n)}for(let n=0;n<this.colorKeys.length;n++){let C=this.colorKeys[n];(C.time<A||!g)&&(g=C,o=n)}if(g)if(o+1<this.colorKeys.length){let C=this.colorKeys[o+1],s=VA.remap(A,g.time,C.time,0,1);e.r=VA.lerp(g.color.r,C.color.r,s),e.g=VA.lerp(g.color.g,C.color.g,s),e.b=VA.lerp(g.color.b,C.color.b,s)}else e.r=g.color.r,e.g=g.color.g,e.b=g.color.b;if(t)if(i+1<this.alphaKeys.length){let C=this.alphaKeys[i+1],s=VA.remap(A,t.time,C.time,0,1);e.alpha=VA.lerp(t.alpha,C.alpha,s)}else e.alpha=t.alpha;return e}};U([F()],Bn.prototype,"alphaKeys",2),U([F()],Bn.prototype,"colorKeys",2);var UT=(f=>(f[f.Sphere=0]="Sphere",f[f.SphereShell=1]="SphereShell",f[f.Hemisphere=2]="Hemisphere",f[f.HemisphereShell=3]="HemisphereShell",f[f.Cone=4]="Cone",f[f.Box=5]="Box",f[f.Mesh=6]="Mesh",f[f.ConeShell=7]="ConeShell",f[f.ConeVolume=8]="ConeVolume",f[f.ConeVolumeShell=9]="ConeVolumeShell",f[f.Circle=10]="Circle",f[f.CircleEdge=11]="CircleEdge",f[f.SingleSidedEdge=12]="SingleSidedEdge",f[f.MeshRenderer=13]="MeshRenderer",f[f.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",f[f.BoxShell=15]="BoxShell",f[f.BoxEdge=16]="BoxEdge",f[f.Donut=17]="Donut",f[f.Rectangle=18]="Rectangle",f[f.Sprite=19]="Sprite",f[f.SpriteRenderer=20]="SpriteRenderer",f))(UT||{});var se=class{mode;constant;constantMin;constantMax;curve;curveMin;curveMax;curveMultiplier;evaluate(A,e){let t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=VA.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:let i=A*this.curveMin.duration,g=A*this.curveMax.duration;return VA.lerp(this.curveMin.evaluate(i),this.curveMax.evaluate(g),t%1)*this.curveMultiplier;case 3:return VA.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}};U([F()],se.prototype,"mode",2),U([F()],se.prototype,"constant",2),U([F()],se.prototype,"constantMin",2),U([F()],se.prototype,"constantMax",2),U([F(en)],se.prototype,"curve",2),U([F(en)],se.prototype,"curveMin",2),U([F(en)],se.prototype,"curveMax",2),U([F()],se.prototype,"curveMultiplier",2);var uo=class{mode;color;colorMin;colorMax;gradient;gradientMin;gradientMax;evaluate(A,e){let t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(A,uo._temp),uo._temp;case 2:return uo._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(A,uo._temp),this.gradientMax.evaluate(A,uo._temp2),uo._temp.lerp(uo._temp2,t)}return uo._temp.set(16711935),uo._temp.alpha=1,uo._temp}},Di=uo;uA(Di,"_temp",new ve(0,0,0,1)),uA(Di,"_temp2",new ve(0,0,0,1)),U([F(ve)],Di.prototype,"color",2),U([F(ve)],Di.prototype,"colorMin",2),U([F(ve)],Di.prototype,"colorMax",2),U([F(Bn)],Di.prototype,"gradient",2),U([F(Bn)],Di.prototype,"gradientMin",2),U([F(Bn)],Di.prototype,"gradientMax",2);var Vt=class{cullingMode;duration;emitterVelocityMode;flipRotation;gravityModifier;gravityModifierMultiplier;loop;maxParticles;playOnAwake;prewarm;ringBufferLoopRange;ringBufferMode;scalingMode;simulationSpace;simulationSpeed;startColor;startDelay;startDelayMultiplier;startLifetime;startLifetimeMultiplier;startRotation;startRotationMultiplier;startRotation3D;startRotationX;startRotationXMultiplier;startRotationY;startRotationYMultiplier;startRotationZ;startRotationZMultiplier;startSize;startSize3D;startSizeMultiplier;startSizeX;startSizeXMultiplier;startSizeY;startSizeYMultiplier;startSizeZ;startSizeZMultiplier;startSpeed;startSpeedMultiplier;stopAction;useUnscaledTime};U([F(se)],Vt.prototype,"gravityModifier",2),U([F(Di)],Vt.prototype,"startColor",2),U([F(se)],Vt.prototype,"startDelay",2),U([F(se)],Vt.prototype,"startLifetime",2),U([F(se)],Vt.prototype,"startRotation",2),U([F(se)],Vt.prototype,"startRotationX",2),U([F(se)],Vt.prototype,"startRotationY",2),U([F(se)],Vt.prototype,"startRotationZ",2),U([F(se)],Vt.prototype,"startSize",2),U([F(se)],Vt.prototype,"startSizeX",2),U([F(se)],Vt.prototype,"startSizeY",2),U([F(se)],Vt.prototype,"startSizeZ",2),U([F(se)],Vt.prototype,"startSpeed",2);var rs=class{cycleCount;maxCount;minCount;probability;repeatInterval;time;count;_performed=0;reset(){this._performed=0}run(A){if(A<=this.time)return this.reset(),0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){let t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=VA.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:let i=Math.random();e=VA.lerp(this.count.curveMin.evaluate(i),this.count.curveMax.evaluate(i),Math.random());break}}return e}},EI=class{enabled;get burstCount(){return this.bursts?.length??0}bursts;rateOverTime;rateOverTimeMultiplier;rateOverDistance;rateOverDistanceMultiplier;system;reset(){this.bursts?.forEach(A=>A.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){let t=this.bursts[e];t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}};U([F()],EI.prototype,"enabled",2),U([F()],EI.prototype,"bursts",2),U([F(se)],EI.prototype,"rateOverTime",2),U([F()],EI.prototype,"rateOverTimeMultiplier",2),U([F(se)],EI.prototype,"rateOverDistance",2),U([F()],EI.prototype,"rateOverDistanceMultiplier",2);var ss=class{enabled;color};U([F(Di)],ss.prototype,"color",2);var po=class{enabled;separateAxes;size;sizeMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;_time=0;_temp=new k;evaluate(A,e,t){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{let i=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=i}return e}};U([F(se)],po.prototype,"size",2),U([F(se)],po.prototype,"x",2),U([F(se)],po.prototype,"y",2),U([F(se)],po.prototype,"z",2);var Il=class{get type(){return UT[this.shapeType]}initialize(A){this.getPosition(),A.position.copy(this._vector)}toJSON(){return this}clone(){return new Il}shapeType=5;enabled=!0;alignToDirection=!1;angle=0;arc=360;arcSpread;arcSpeedMultiplier;arcMode;boxThickness;position;rotation;_rotation=new $e;scale;radius;radiusThickness;sphericalDirectionAmount;randomDirectionAmount;randomPositionAmount;system;_space;_worldSpaceMatrix=new zA;_worldSpaceMatrixInverse=new zA;update(A,e,t,i){this.system=A,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}updateRotation(){let A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=VA.toRadians(this.rotation.x),this._rotation.y=-VA.toRadians(this.rotation.y),this._rotation.z=-VA.toRadians(this.rotation.z)),A}_vector=new k(0,0,0);_temp=new k(0,0,0);get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);let A=this._temp.copy(this.position),e=this._space===1;e&&A.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(A);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector,this.scale);break;case 10:this._temp.copy(this.scale),this._temp.z=0,this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector,this._temp);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.updateRotation()&&this._vector.applyEuler(this._rotation),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos))}_dir=new k;getDirection(A){if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:let e=A.x,t=A.y,i=A.z;this._dir.set(e,t,i),this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyMatrix4(this._worldSpaceMatrixInverse),this.updateRotation()&&this._dir.applyEuler(this._rotation),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),z8&&(GI.DrawSphere(A,.01,8925952,.5,!0),GI.DrawDirection(A,this._dir,8925952,.5,!0)),this._dir}randomizePosition(A,e){if(e<=0)return;let t=Il._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,A.add(t)}randomizeDirection(A,e){if(e===0)return;let t=Il._randomQuat,i=Il._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),A.applyQuaternion(t)}spherizeDirection(A,e){if(e===0)return;let t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(t),o=Math.sin(i)*Math.sin(t),n=Math.cos(i),C=new k(g,o,n);A.lerp(C,e)}randomSpherePoint(A,e,t,i,g,o){let n=Math.random(),C=Math.random(),s=2*Math.PI*n*(i/360),r=Math.acos(2*C-1),a=VA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,B=A.x+o.x*(-a*Math.sin(r)*Math.cos(s)),Q=A.y+o.y*(a*Math.sin(r)*Math.sin(s)),l=A.z+o.z*(a*Math.cos(r));g.x=B,g.y=Q,g.z=l}_loopTime=0;_loopDirection=1;randomConePoint(A,e,t,i,g,o,n){let C=0,s=0;switch(o){case 0:C=Math.random(),s=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:C=.5,s=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let r=2*Math.PI*C*(g/360);switch(o){case 2:case 1:r+=Math.PI+.5,r+=this._loopTime*Math.PI*2,r%=VA.toRadians(g);break}let a=Math.acos(2*s-1),B=VA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,Q=A.x+-B*Math.sin(a)*Math.cos(r),l=A.y+B*Math.sin(a)*Math.sin(r),E=A.z;n.x=Q*this.scale.x,n.y=l*this.scale.y,n.z=E*this.scale.z}},Bt=Il;uA(Bt,"_randomQuat",new KA),uA(Bt,"_tempVec",new k),U([F()],Bt.prototype,"shapeType",2),U([F()],Bt.prototype,"enabled",2),U([F()],Bt.prototype,"alignToDirection",2),U([F()],Bt.prototype,"angle",2),U([F()],Bt.prototype,"arc",2),U([F()],Bt.prototype,"arcSpread",2),U([F()],Bt.prototype,"arcSpeedMultiplier",2),U([F()],Bt.prototype,"arcMode",2),U([F(k)],Bt.prototype,"boxThickness",2),U([F(k)],Bt.prototype,"position",2),U([F(k)],Bt.prototype,"rotation",2),U([F(k)],Bt.prototype,"scale",2),U([F()],Bt.prototype,"radius",2),U([F()],Bt.prototype,"radiusThickness",2),U([F()],Bt.prototype,"sphericalDirectionAmount",2),U([F()],Bt.prototype,"randomDirectionAmount",2),U([F()],Bt.prototype,"randomPositionAmount",2);var We=class{damping;enabled;frequency;octaveCount;octaveMultiplier;octaveScale;positionAmount;quality;remap;remapEnabled;remapMultiplier;remapX;remapXMultiplier;remapY;remapYMultiplier;remapZ;remapZMultiplier;scrollSpeedMultiplier;separateAxes;strengthMultiplier;strengthX;strengthXMultiplier;strengthY;strengthYMultiplier;strengthZ;strengthZMultiplier;_noise;_time=0;update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}_temp=new k;apply(A,e,t,i,g,o){if(!this.enabled)return;this._noise||(this._noise=RT(()=>0));let n=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(n.x,n.y,n.z,this._time),s=this._noise(n.x,n.y,n.z,this._time+1e3*this.frequency),r=this._noise(n.x,n.y,n.z,this._time+2e3*this.frequency);this._temp.set(C,s,r).normalize();let a=g/o,B=this.positionAmount.evaluate(a);this.separateAxes?(this._temp.x*=B*this.strengthXMultiplier,this._temp.y*=B*this.strengthYMultiplier,this._temp.z*=B*this.strengthZMultiplier):(this.strengthX&&(B*=this.strengthX.evaluate(a)*1.5),this._temp.multiplyScalar(B)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}};U([F()],We.prototype,"damping",2),U([F()],We.prototype,"enabled",2),U([F()],We.prototype,"frequency",2),U([F()],We.prototype,"octaveCount",2),U([F()],We.prototype,"octaveMultiplier",2),U([F()],We.prototype,"octaveScale",2),U([F(se)],We.prototype,"positionAmount",2),U([F()],We.prototype,"quality",2),U([F(se)],We.prototype,"remap",2),U([F()],We.prototype,"remapEnabled",2),U([F()],We.prototype,"remapMultiplier",2),U([F(se)],We.prototype,"remapX",2),U([F()],We.prototype,"remapXMultiplier",2),U([F(se)],We.prototype,"remapY",2),U([F()],We.prototype,"remapYMultiplier",2),U([F(se)],We.prototype,"remapZ",2),U([F()],We.prototype,"remapZMultiplier",2),U([F()],We.prototype,"scrollSpeedMultiplier",2),U([F()],We.prototype,"separateAxes",2),U([F()],We.prototype,"strengthMultiplier",2),U([F(se)],We.prototype,"strengthX",2),U([F()],We.prototype,"strengthXMultiplier",2),U([F(se)],We.prototype,"strengthY",2),U([F()],We.prototype,"strengthYMultiplier",2),U([F(se)],We.prototype,"strengthZ",2),U([F()],We.prototype,"strengthZMultiplier",2);var ot=class{enabled;attachRibbonToTransform=!1;colorOverLifetime;colorOverTrail;dieWithParticles=!0;inheritParticleColor=!0;lifetime;lifetimeMultiplier;minVertexDistance=.2;mode=0;ratio=1;ribbonCount=1;shadowBias=0;sizeAffectsLifetime=!1;sizeAffectsWidth=!1;splitSubEmitterRibbons=!1;textureMode=0;widthOverTrail;widthOverTrailMultiplier;worldSpace=!1;getWidth(A,e,t){let i=this.widthOverTrail.evaluate(t);return t===0&&(i=A),A*=i,A}getColor(A,e,t){let i=this.colorOverTrail.evaluate(t),g=this.colorOverLifetime.evaluate(e);A.x*=i.r*g.r,A.y*=i.g*g.g,A.z*=i.b*g.b,A.w*=i.alpha*g.alpha}};U([F()],ot.prototype,"enabled",2),U([F()],ot.prototype,"attachRibbonToTransform",2),U([F(Di)],ot.prototype,"colorOverLifetime",2),U([F(Di)],ot.prototype,"colorOverTrail",2),U([F()],ot.prototype,"dieWithParticles",2),U([F()],ot.prototype,"inheritParticleColor",2),U([F(se)],ot.prototype,"lifetime",2),U([F()],ot.prototype,"lifetimeMultiplier",2),U([F()],ot.prototype,"minVertexDistance",2),U([F()],ot.prototype,"mode",2),U([F()],ot.prototype,"ratio",2),U([F()],ot.prototype,"ribbonCount",2),U([F()],ot.prototype,"shadowBias",2),U([F()],ot.prototype,"sizeAffectsLifetime",2),U([F()],ot.prototype,"sizeAffectsWidth",2),U([F()],ot.prototype,"splitSubEmitterRibbons",2),U([F()],ot.prototype,"textureMode",2),U([F(se)],ot.prototype,"widthOverTrail",2),U([F()],ot.prototype,"widthOverTrailMultiplier",2),U([F()],ot.prototype,"worldSpace",2);var qi=class{enabled;space=0;speedModifier;speedModifierMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;_system;update(A){this._system=A}_temp=new k;apply(A,e,t,i,g,o){if(!this.enabled)return;let n=g/o,C=this.speedModifier.evaluate(n)*this.speedModifierMultiplier,s=this.x.evaluate(n),r=this.y.evaluate(n),a=this.z.evaluate(n);this._temp.set(-s,r,a),this._system&&(this.space===1&&this._temp.applyQuaternion(this._system.worldQuaternionInverted),this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z,t.x*=C,t.y*=C,t.z*=C}};U([F()],qi.prototype,"enabled",2),U([F()],qi.prototype,"space",2),U([F(se)],qi.prototype,"speedModifier",2),U([F()],qi.prototype,"speedModifierMultiplier",2),U([F(se)],qi.prototype,"x",2),U([F()],qi.prototype,"xMultiplier",2),U([F(se)],qi.prototype,"y",2),U([F()],qi.prototype,"yMultiplier",2),U([F(se)],qi.prototype,"z",2),U([F()],qi.prototype,"zMultiplier",2);var zt=class{animation;enabled;cycleCount;frameOverTime;frameOverTimeMultiplier;numTilesX;numTilesY;startFrame;startFrameMultiplier;rowMode;rowIndex;spriteCount;timeMode;sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?this.frameOverTime.evaluate(Math.random()):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){let e=this.numTilesX*this.numTilesY,t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}};U([F()],zt.prototype,"animation",2),U([F()],zt.prototype,"enabled",2),U([F()],zt.prototype,"cycleCount",2),U([F(se)],zt.prototype,"frameOverTime",2),U([F()],zt.prototype,"frameOverTimeMultiplier",2),U([F()],zt.prototype,"numTilesX",2),U([F()],zt.prototype,"numTilesY",2),U([F(se)],zt.prototype,"startFrame",2),U([F()],zt.prototype,"startFrameMultiplier",2),U([F()],zt.prototype,"rowMode",2),U([F()],zt.prototype,"rowIndex",2),U([F()],zt.prototype,"spriteCount",2),U([F()],zt.prototype,"timeMode",2);var yg=class{enabled;separateAxes;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}};U([F()],yg.prototype,"enabled",2),U([F()],yg.prototype,"separateAxes",2),U([F(se)],yg.prototype,"x",2),U([F()],yg.prototype,"xMultiplier",2),U([F(se)],yg.prototype,"y",2),U([F()],yg.prototype,"yMultiplier",2),U([F(se)],yg.prototype,"z",2),U([F()],yg.prototype,"zMultiplier",2);var og=class{enabled;range;separateAxes;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){let t=VA.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}};U([F()],og.prototype,"enabled",2),U([F()],og.prototype,"range",2),U([F()],og.prototype,"separateAxes",2),U([F(se)],og.prototype,"x",2),U([F()],og.prototype,"xMultiplier",2),U([F(se)],og.prototype,"y",2),U([F()],og.prototype,"yMultiplier",2),U([F(se)],og.prototype,"z",2),U([F()],og.prototype,"zMultiplier",2);var mt=class{enabled;dampen;drag;dragMultiplier;limit;limitMultiplier;separateAxes;limitX;limitXMultiplier;limitY;limitYMultiplier;limitZ;limitZMultiplier;multiplyDragByParticleSize=!1;multiplyDragByParticleVelocity=!1;space;_temp=new k;_temp2=new k;apply(A,e,t,i,g,o,n){if(!!this.enabled){let C=this.limit.evaluate(g)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let r=this.dampen*.5;e.x=VA.lerp(e.x,this._temp.x,r),e.y=VA.lerp(e.y,this._temp.y,r),e.z=VA.lerp(e.z,this._temp.z,r),t.x=VA.lerp(t.x,this._temp.x,r),t.y=VA.lerp(t.y,this._temp.y,r),t.z=VA.lerp(t.z,this._temp.z,r)}}}};U([F()],mt.prototype,"enabled",2),U([F()],mt.prototype,"dampen",2),U([F(se)],mt.prototype,"drag",2),U([F()],mt.prototype,"dragMultiplier",2),U([F(se)],mt.prototype,"limit",2),U([F()],mt.prototype,"limitMultiplier",2),U([F()],mt.prototype,"separateAxes",2),U([F(se)],mt.prototype,"limitX",2),U([F()],mt.prototype,"limitXMultiplier",2),U([F(se)],mt.prototype,"limitY",2),U([F()],mt.prototype,"limitYMultiplier",2),U([F(se)],mt.prototype,"limitZ",2),U([F()],mt.prototype,"limitZMultiplier",2),U([F()],mt.prototype,"multiplyDragByParticleSize",2),U([F()],mt.prototype,"multiplyDragByParticleVelocity",2),U([F()],mt.prototype,"space",2);var fo=class{enabled;curve;curveMultiplier;mode;system;_lastWorldPosition;_velocity=new k;_temp=new k;update(A){!this.enabled||this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(!!this.enabled&&this.system.worldspace!==!1&&this.mode===0){let e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,t){if(!!this.enabled&&this.system.worldspace!==!1&&this.mode===1){let i=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(i),A.add(this._temp)}}};U([F()],fo.prototype,"enabled",2),U([F(se)],fo.prototype,"curve",2),U([F()],fo.prototype,"curveMultiplier",2),U([F()],fo.prototype,"mode",2);var fi=class{enabled;range;separateAxes;size;sizeMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e,t,i){let g=A.length(),o=VA.remap(g,this.range.x,this.range.y,0,1),n=this.size.evaluate(o,t);return i*n}};U([F()],fi.prototype,"enabled",2),U([F(SA)],fi.prototype,"range",2),U([F()],fi.prototype,"separateAxes",2),U([F(se)],fi.prototype,"size",2),U([F()],fi.prototype,"sizeMultiplier",2),U([F(se)],fi.prototype,"x",2),U([F()],fi.prototype,"xMultiplier",2),U([F(se)],fi.prototype,"y",2),U([F()],fi.prototype,"yMultiplier",2),U([F(se)],fi.prototype,"z",2),U([F()],fi.prototype,"zMultiplier",2);var an=class{enabled;range;color;evaluate(A,e,t){let i=A.length(),g=VA.remap(i,this.range.x,this.range.y,0,1),o=this.color.evaluate(g,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}};U([F()],an.prototype,"enabled",2),U([F(SA)],an.prototype,"range",2),U([F(Di)],an.prototype,"color",2);var YB=class extends ig{},ol=class extends EA{deleteBoxes=[];awake(){this.deleteBoxes=IA.findObjectsOfType(YB,this.context)}update(){for(let A of this.deleteBoxes){let e=this.gameObject;A.isInBox(e)===!0&&(IA.getComponentInParent(this.gameObject,Bo)||ic(this.gameObject,this.context.connection))}}};var _B=class extends EA{visibleOn;onEnable(){this.apply()}apply(){this.test()||IA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:j8()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}};U([F()],_B.prototype,"visibleOn",2);var $y;function j8(){if($y===!0||$y===!1)return $y;let I=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(I=!0)}(navigator.userAgent||navigator.vendor||window.opera),$y=I,I}var AF=!1;var as=class extends ao{static get HasAnySelected(){return this._active>0}transformSelf=!0;orbit=null;selectStartEventListener=[];selectEndEventListener=[];constructor(){super(),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new SA}addDragEventListener(A,e){switch(A){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}_dragHelper=null;start(){this.orbit=IA.findObjectOfType(Xi,this.context)}_draggingRigidbodies=[];allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||pe.IsInWebXR)return;let e=IA.getComponentInParent(A.object,as);!e||e!==this||(as.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){!this.allowEdit(this.gameObject)||pe.IsInWebXR||as.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}_waitingForDragStart=null;onPointerDown(A){!this.allowEdit(this.gameObject)||pe.IsInWebXR||(as._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=A,A.StopPropagation(),this.orbit&&(this.orbit.enabled=!1))}onPointerUp(A){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(as._active>0&&(as._active-=1),!pe.IsInWebXR&&(this.onDragEnd(A),A.StopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){if(!pe.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){let e=this.context.input.getPointerPositionDelta(0);if(e&&this._dragDelta.add(e),this._dragDelta.length()>2)this._didDrag=!0;else return}let A=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(A)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),this._isDragging&&this._dragHelper?.hasSelected===!1&&this.onDragEnd(null)}}_isDragging=!1;_marker=null;_dragDelta;_didDrag=!1;onDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new AS(this.context.mainCamera);else return;if(!A||!A.object)return;let e=IA.getComponentInParent(A.object,as);if(!e||e!==this)return;let t=A.object;this.transformSelf&&(t=this.gameObject);let i={selected:t,attached:t};for(let C of this.selectStartEventListener)C(this,i);if(!i.attached)return;i.attached,t=i.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);let g=IA.getComponentInChildren(t,NI);AF&&console.log("DRAG START",g,t),g&&(g.fastMode=!0,g?.requestOwnership()),this._marker=IA.addNewComponent(t,Bo),this._draggingRigidbodies.length=0;let o=IA.getComponentsInChildren(t,je);o&&this._draggingRigidbodies.push(...o);let n=S0();IA.invokeOnChildren(this._dragHelper.selected,n("onDragStart"))}onUpdateDrag(){if(!!this._dragHelper){this._dragHelper.onUpdate(this.context);for(let A of this._draggingRigidbodies)A.wakeUp(),A.resetVelocities()}}onDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(let i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;let e=this._dragHelper.selected;if(AF&&console.log("DRAG END",e,e?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A?.object){let i=IA.getComponentInChildren(A.object,NI);i&&(i.fastMode=!1),this._marker&&this._marker.destroy()}for(let i of this.selectEndEventListener)i(this);let t=S0();IA.invokeOnChildren(e,t("onDragEnd"))}},eC=as;uA(eC,"_active",0),uA(eC,"lastHovered");var eF=class{get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}_selected=null;_context=null;_camera;_cameraPlane=new Ti;_hasGroundPlane=!1;_groundPlane=new Ti;_groundOffset=new k;_groundOffsetFactor=0;_groundDistance=0;_groundPlanePoint=new k;_raycaster=new xC;_cameraPlaneOffset=new k;_intersection=new k;_worldPosition=new k;_inverseMatrix=new zA;_rbs=[];_groundLine;_groundMarker;constructor(A){this._camera=A;let e=new hg(eF.geometry),t=e.material;t.color=new W(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;let i=new Tg(.5,22,22),g=new yt({color:t.color}),o=new we(i,g);o.visible=!1,o.layers.set(2),this._groundMarker=o}setSelected(A,e){if(this._selected&&e)for(let t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&Wt.Remove(e,this._selected),this._selected=A,this._context=e,this._rbs.length=0,A?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}Wt.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}_groundOffsetVector=new k(0,1,0);_requireUpdateGroundPlane=!0;_didDragOnGroundPlaneLastFrame=!1;onUpdate(A){if(!this._context)return;let e=" ",t="d",i="s",g=this._context?.input.isKeyPressed(e)||this._context?.input.isKeyPressed(t),o=this._context.input.getTouchesPressedCount()>=2||g;if(o){let C=this._context.input.getPointerPositionDelta(0);C&&(this._groundOffsetVector.set(0,1,0),this._selected?.rotateOnWorldAxis(this._groundOffsetVector,C.x*this._context.time.deltaTime))}let n=this._context.input.getPointerPositionRC(0);if(!!n&&(this._raycaster.setFromCamera(n,this._camera),this._selected)){AF&&console.log("UPDATE DRAG",this._selected),this._groundOffsetVector.set(0,1,0);let C=ge(this._camera).clone().sub(ge(this._selected)).normalize(),s=Math.abs(C.dot(this._groundOffsetVector)),r=this._context?.input.isKeyPressed(e)||this._context?.input.isKeyPressed(t),a=!o&&s>.2&&!r&&this._context.input.getPointerPressedCount()<=1,B=this._didDragOnGroundPlaneLastFrame!==a;if(this._didDragOnGroundPlaneLastFrame=a,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!a||B)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){let Q=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=Q,a){this._groundOffsetVector.set(0,1,0);let l=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(l,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);B&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(A,e,t){if(!!this._selected){if(t){let i=ge(this._selected);i.y=A.y,A=i}if(at(this._selected,A),at(this._groundLine,A),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundMarker.visible=e!==null,e){let i=ge(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(i,i,i),at(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;let A=this._context.input.getPointerPositionRC(0);!A||(this._raycaster.setFromCamera(A,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;let A=ge(this._selected),e=new Lg(new k(0,.1,0).add(A),new k(0,-1,0)),t=new vt;t.ignore=[this._selected];let i=this._context.physics.raycastFromRay(e,t);for(let g=0;g<i.length;g++){let o=i[g];if(!o.face||this.contains(this._selected,o.object))continue;let n=new k(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(n,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(A),this._groundOffset.copy(this._intersection).sub(A)}onDidUpdate(){Et.markDirty(this._selected);for(let A of this._rbs)A.wakeUp(),A.resetForcesAndTorques(),A.setAngularVelocity(0,0,0)}contains(A,e){if(A===e)return!0;if(A.children){for(let t of A.children)if(this.contains(t,e))return!0}return!1}},AS=eF;uA(AS,"geometry",new le().setFromPoints([new k(0,0,0),new k(0,-1,0)]));var Qn=class extends EA{url=null;urlParameterName=null;localhost=null;awake(){this.context.connection.registerProvider(this)}getWebsocketUrl(){let A=this.url?Qn.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){let g=sA(this.urlParameterName);g&&typeof g=="string"&&(A=g)}if(!A)return null;let t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(A);return t?.groups?t?.groups.socket_prefix?A:"wss://"+t?.groups.url:null}static GetUrl(A,e){let t=A,i=Qn.IsLocalNetwork()&&e;return i&&(t=e),A?.startsWith("/")&&(t=(i?t:window.location.origin)+A),t}static IsLocalNetwork(A=window.location.hostname){return tI(A)}};var Hr=class extends EA{filesBackendUrl;localhost;_dragOver;_drop;onEnable(){this.filesBackendUrl=this.filesBackendUrl?Qn.GetUrl(this.filesBackendUrl,this.localhost):void 0,this._dragOver=this.onDrag.bind(this),this._drop=this.onDrop.bind(this),this.context.domElement.addEventListener("dragover",this._dragOver),this.context.domElement.addEventListener("drop",this._drop)}onDisable(){this.context.domElement.removeEventListener("dragover",this._dragOver),this.context.domElement.removeEventListener("drop",this._drop)}onDrag(A){A.preventDefault()}async addFiles(A){for(let e of A){if(!e)continue;console.log("Register file "+e.name+" to",this.filesBackendUrl,e);let t=await wR(e,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:e})),t&&this.addObject(void 0,t)}}async onDrop(A){if(console.log(A),!A.dataTransfer)return;A.preventDefault();let e=A.dataTransfer.items;if(!!e)for(let t in e){let i=e[t];if(i.kind==="file"){let g=i.getAsFile();if(!g)continue;console.log("Register file "+g.name+" to",this.filesBackendUrl,g);let o=await wR(g,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:g})),o&&this.addObject(A,o)}else i.kind==="string"&&i.type=="text/plain"&&i.getAsString(async g=>{console.log("dropped url",g);try{let o=new URL(g);if(!o)return;let n=await uv(o,this.context);n&&this.addObject(A,n)}catch{console.log("dropped string is not a valid URL!",g)}})}}async addObject(A,e){console.log("Dropped",e);let t=e.scene;if(A!==void 0){let i=new vt;i.setMask(16777215),i.screenPointFromOffset(A.offsetX,A.offsetY);let g=this.context.physics.raycast(i);if(g&&g.length>0)for(let o of g){t.position.copy(o.point);break}}this.gameObject.add(t),this.dispatchEvent(new CustomEvent("object-added",{detail:e}))}};U([F()],Hr.prototype,"filesBackendUrl",2),U([F()],Hr.prototype,"localhost",2);var tC=class extends ao{parent=null;object=null;limitCount=10;limitInterval=60;_currentCount=0;_startPosition=null;_startQuaternion=null;awake(){if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=this.object.position?.clone()??new k(0,0,0),this._startQuaternion=this.object.quaternion?.clone()??new KA(0,0,0,1)}let A=IA.getComponentInParent(this.gameObject,eC);A?A.addDragEventListener("selectstart",(e,t)=>{if(this._currentCount>=this.limitCount){t.attached=null;return}let i=this.handleDuplication(t.selected);i&&(console.assert(i!==t.selected,"Duplicated object is original"),t.attached=i)}):console.warn("Could no find drag controls in parent",this.name),it.addEventListener("select-start",(e,t)=>{if(this._currentCount>=this.limitCount){t.grab=null;return}let i=this.handleDuplication(t.selected);i&&(t.grab=i)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(A){if(this._currentCount>=this.limitCount||!this.object)return null;if(A===this.gameObject||this.handleMultiObject(A)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);let e=new zi;this.parent||(this.parent=this.gameObject.parent),this.parent&&(e.parent=this.parent.guid??this.parent.userData?.guid,e.keepWorldPosition=!0),e.position=this.worldPosition,e.rotation=this.worldQuaternion,e.context=this.context,this._currentCount+=1;let t=IA.instantiateSynced(this.object,e);return console.assert(t!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),t}return null}handleMultiObject(A){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,A):!1}isInChildren(A,e){if(!A)return!1;if(A===e)return!0;if(A.children){for(let t of A.children)if(this.isInChildren(t,e))return!0}return!1}};U([F(vA)],tC.prototype,"parent",2),U([F(vA)],tC.prototype,"object",2),U([F()],tC.prototype,"limitCount",2),U([F()],tC.prototype,"limitInterval",2);var Uu=class{eventID;callback};U([F()],Uu.prototype,"eventID",2),U([F(Nt)],Uu.prototype,"callback",2);var OB=class extends EA{triggers;invoke(A){if(!!this.triggers)for(let e of this.triggers)e.eventID===A&&e.callback.invoke()}onPointerClick(A){this.invoke(4)}onPointerEnter(A){this.invoke(0)}onPointerExit(A){this.invoke(1)}onPointerDown(A){this.invoke(2)}onPointerUp(A){this.invoke(3)}};U([F(Uu)],OB.prototype,"triggers",2);var Bs=class{get lightmap(){return this.lightmapTexture}set lightmap(A){A!==this.lightmapTexture&&(this.lightmapTexture=A,this.setupLightmap())}lightmapIndex=-1;lightmapScaleOffset=new Ae(1,1,0,0);context;gameObject;lightmapTexture=null;lightmapScaleOffsetUniform={value:new Ae(1,1,0,0)};lightmapUniform={value:null};beforeRenderCallback;constructor(A,e){this.gameObject=A,this.context=e}init(A,e,t,i=!1){if(console.assert(this.gameObject!==void 0&&this.gameObject!==null,"Missing gameobject",this),this.lightmapIndex=A,this.lightmapIndex<0)return;this.lightmapScaleOffset=e,this.lightmapTexture=t,i&&this.setLightmapDebugMaterial(),this.setupLightmap()}bindOnBeforeRender(){this.beforeRenderCallback=this.onBeforeRenderThreeComplete.bind(this),this.context.addBeforeRenderListener(this.gameObject,this.beforeRenderCallback)}onBeforeRenderThreeComplete(A,e,t,i,g,o){this.onBeforeRenderThree(g)}setupLightmap(){if(this.gameObject.type==="Object3D")return;if(this.gameObject.type==="Group"){console.warn("Lightmap on multimaterial object is not supported yet... please ask kindly for implementation.");return}console.assert(this.gameObject.type==="Mesh","Lightmap only works on meshes",this);let A=this.gameObject;A.geometry.getAttribute("uv2")||A.geometry.setAttribute("uv2",A.geometry.getAttribute("uv"));let e=this.gameObject.material.clone();if(this.gameObject.material=e,this.gameObject.material.onBeforeCompile=(t,i)=>{t.uniforms.lightmap=this.lightmapUniform,t.uniforms.lightmapScaleOffset=this.lightmapScaleOffsetUniform},this.lightmapIndex>=0){let t=this.lightmapTexture,i=this.gameObject.material;i&&t&&(i.uniforms||(i.uniforms={}),i.lightMap=t,i.uniforms.lightmap={value:t})}}onBeforeRenderThree(A){let e=A.uniforms;e&&e.lightmap&&(this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,this.lightmapUniform.value=this.lightmapTexture,e.lightmap=this.lightmapUniform,e.lightmapScaleOffset=this.lightmapScaleOffsetUniform)}setLightmapDebugMaterial(){this.gameObject.material=new ut({vertexShader:`
6712
+ See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`);return}let n=IT(e,o),C=Array.from?Array.from(n):String(n).split(""),s=A/t.info.size,r=t.common.lineHeight*s,a=t.common.base*s,B=C.map(Q=>{let l=this.getGlyphDimensions({textType:g,glyph:Q,font:t,fontSize:A}),E=null;return o!==Oc&&(i.includes(Q)||Q.match(/\s/g))&&(E="possible"),Q.match(/\n/g)&&(E=oT(o)),{height:l.height,width:l.width,anchor:l.anchor,xadvance:l.xadvance,xoffset:l.xoffset,lineBreak:E,glyph:Q,fontSize:A,lineHeight:r,lineBase:a}});if(this.getFontKerning()!=="none")for(let Q=1;Q<B.length;Q++){let l=B[Q],E=B[Q-1].glyph+B[Q].glyph,c=this.getGlyphPairKerning(g,t,E);l.kerning=c*(A/t.info.size)}this.inlines=B}},yu=class extends _c.withBase(Te.Object3D)(hT,kU,cT,NU,Oy){constructor(A){super(A),this.isInlineBlock=!0,this.size=new Te.Vector2(1,1),this.frame=new Jy(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(A)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){let A=this.getWidth(),e=this.getHeight();if(this.inlines){let t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(A,e),this.frame.scale.set(A,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}},Nr={fr:[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],eng:[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],ru:[[[{width:1/12,chars:[{lowerCase:"\u0439",upperCase:"\u0419"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"\u0446",upperCase:"\u0426"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"\u0443",upperCase:"\u0423"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"\u043A",upperCase:"\u041A"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"\u0435",upperCase:"\u0415"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"\u043D",upperCase:"\u041D"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"\u0433",upperCase:"\u0413"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"\u0448",upperCase:"\u0428"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"\u0449",upperCase:"\u0429"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"\u0437",upperCase:"\u0417"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"\u0445",upperCase:"\u0425"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"\u044A",upperCase:"\u042A"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"\u0444",upperCase:"\u0424"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"\u044B",upperCase:"\u042B"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"\u0432",upperCase:"\u0412"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"\u0430",upperCase:"\u0410"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"\u043F",upperCase:"\u041F"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"\u0440",upperCase:"\u0420"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"\u043E",upperCase:"\u041E"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"\u043B",upperCase:"\u041B"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"\u0434",upperCase:"\u0414"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"\u0436",upperCase:"\u0416"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"\u044D",upperCase:"\u042D"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"\u0451",upperCase:"\u0401"},{lowerCase:"|",upperCase:"\\"}]}],[{width:1.5/12,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"\u044F",upperCase:"\u042F"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"\u0447",upperCase:"\u0427"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"\u0441",upperCase:"\u0421"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"\u043C",upperCase:"\u041C"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"\u0438",upperCase:"\u0418"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"\u0442",upperCase:"\u0422"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"\u044C",upperCase:"\u042C"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"\u0431",upperCase:"\u0411"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"\u044E",upperCase:"\u042E"},{lowerCase:".",upperCase:""}]},{width:1.5/12,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"\u0410\u0411\u0412"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],de:[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"\xFC",upperCase:"\xDC"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"\xF6",upperCase:"\xD6"}]},{width:1/11,chars:[{lowerCase:"\xE4",upperCase:"\xC4"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],es:[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"\xF1",upperCase:"\xD1"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],el:[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"\u03C2",upperCase:"\u03C2"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"\u03B5",upperCase:"\u0395"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"\u03C1",upperCase:"\u03A1"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"\u03C4",upperCase:"\u03A4"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"\u03C5",upperCase:"\u03A5"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"\u03B8",upperCase:"\u0398"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"\u03B9",upperCase:"\u0399"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"\u03BF",upperCase:"\u039F"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"\u03C0",upperCase:"\u03A0"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"\u03B1",upperCase:"\u0391"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"\u03C3",upperCase:"\u03A3"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"\u03B4",upperCase:"\u0394"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"\u03C6",upperCase:"\u03A6"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"\u03B3",upperCase:"\u0393"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"\u03B7",upperCase:"\u0397"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"\u03BE",upperCase:"\u039E"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"\u03BA",upperCase:"\u039A"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"\u03BB",upperCase:"\u039B"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"\u03B6",upperCase:"\u0396"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"\u03C7",upperCase:"\u03A7"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"\u03C8",upperCase:"\u03A8"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"\u03C9",upperCase:"\u03A9"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"\u03B2",upperCase:"\u0392"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"\u03BD",upperCase:"\u039D"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"\u03BC",upperCase:"\u039C"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],nord:[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"\xE5",upperCase:"\xC5"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"\xE6",upperCase:"\xC6"}]},{width:1/11,chars:[{lowerCase:"\xF8",upperCase:"\xD8"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]]},u8=new Te.TextureLoader,qy=class extends _c.withBase(Te.Object3D)(kU,Oy){constructor(A){A||(A={}),A.width||(A.width=1),A.height||(A.height=.4),A.margin||(A.margin=.003),A.padding||(A.padding=.01),super(A),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1;let e;if(A.language||navigator.language)switch(A.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Nr.fr;break;case"ru":this.charsetCount=2,e=Nr.ru;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Nr.de;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Nr.es;break;case"el":this.charsetCount=2,e=Nr.el;break;case"nord":e=Nr.nord;break;default:e=Nr.eng;break}else e=Nr.eng;this.keys=[],this.panels=e.map(t=>{let i=A.height/t.length-A.margin*2,g=new bB({width:A.width+A.padding*2,height:A.height+A.padding*2,offset:0,padding:A.padding,fontFamily:A.fontFamily,fontTexture:A.fontTexture,backgroundColor:A.backgroundColor,backgroundOpacity:A.backgroundOpacity});return g.charset=0,g.add(...t.map(o=>{let n=new bB({width:A.width,height:i,margin:A.margin,contentDirection:"row",justifyContent:"center"});n.frame.visible=!1;let C=[];return o.forEach(s=>{let r=new bB({width:A.width*s.width-A.margin*2,height:i,margin:A.margin,justifyContent:"center",offset:0}),a=s.chars[g.charset].lowerCase||s.chars[g.charset].icon||"undif";if(a==="enter"&&A.enterTexture||a==="shift"&&A.shiftTexture||a==="backspace"&&A.backspaceTexture){let B=(()=>{switch(a){case"backspace":return A.backspaceTexture;case"enter":return A.enterTexture;case"shift":return A.shiftTexture;default:console.warn("There is no icon image for this key")}})();u8.load(B,Q=>{r.add(new yu({width:r.width*.65,height:r.height*.65,backgroundSize:"contain",backgroundTexture:Q}))})}else r.add(new wu({content:a,offset:0}));r.type="Key",r.info=s,r.info.input=a,r.panel=g,C.push(r),this.keys.push(r)}),n.add(...C),n})),g}),this.add(this.panels[0]),this.set(A)}setNextPanel(){this.panels.forEach(A=>{this.remove(A)}),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach(A=>{if(!this.panels[this.currentPanel].getObjectById(A.id))return;let t=A.info.chars[A.panel.charset]||A.info.chars[0],i=this.isLowerCase||!t.upperCase?t.lowerCase:t.upperCase;if(!A.childrenTexts.length)return;let g=A.childrenTexts[0];A.info.input=i,g.set({content:i}),g.update(!0,!0,!0)})}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach(A=>{let e=A.info.chars[A.panel.charset]||A.info.chars[0],t=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!A.childrenTexts.length)return;let i=A.childrenTexts[0];A.info.input=t,i.set({content:t}),i.update(!0,!0,!0)})}parseParams(){}updateLayout(){}updateInner(){}},uT=()=>es.update(),pT={Block:bB,Text:wu,InlineBlock:yu,Keyboard:qy,FontLibrary:Du,update:uT,TextAlign:Ty,Whitespace:vy,JustifyContent:Ly,AlignItems:xy,ContentDirection:by};typeof global<"u"&&(global.ThreeMeshUI=pT);var p8=pT,f8=KI.g1,mu=KI.gO,D8=KI.km,w8=KI.zV,y8=KI.ol,S8=KI.uM,KU=KI.N1,JU=KI.xv,m8=KI.PH,M8=KI.UH,G8=KI.ZP,qU=KI.Vx;var Py=class{static createButton(A,e={}){let t=document.createElement("button"),i=!1;function g(){if(e.domOverlay===void 0){var s=document.createElement("div");s.style.display="none",document.body.appendChild(s);var r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width",38),r.setAttribute("height",38),r.style.position="absolute",r.style.right="20px",r.style.top="20px",r.addEventListener("click",function(){B.end()}),s.appendChild(r);var a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),a.setAttribute("stroke","#fff"),a.setAttribute("stroke-width",2),r.appendChild(a),e.optionalFeatures===void 0&&(e.optionalFeatures=[]),e.optionalFeatures.push("dom-overlay"),e.domOverlay={root:s},i=!0}e.optionalFeatures===void 0&&(e.optionalFeatures=[]),e.optionalFeatures.push("local-floor"),e.optionalFeatures.push("hand-tracking"),e.optionalFeatures.push("layers");let B=null,Q=null;async function l(c){if(/WebXRViewer\//i.test(navigator.userAgent))if(e.domOverlay?.root){let p=e.domOverlay.root;Q=p.parentElement,Q&&(console.log("Reparent DOM Overlay to body",p,p.style.display),p.style.display="",p.style.visibility="",document.body.appendChild(p))}else console.warn("WebXRViewer: No DOM Overlay found");c.addEventListener("end",E),await A.xr.setSession(c),t.textContent="STOP AR",i&&(e.domOverlay.root.style.display=""),B=c}function E(){B.removeEventListener("end",E),t.textContent="START AR",Q&&Q.appendChild(e.domOverlay.root),i&&(e.domOverlay.root.style.display="none"),B=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="START AR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){B===null?navigator.xr.requestSession("immersive-ar",e).then(l):B.end()}}function o(){t.disabled=!0,t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function n(){o(),t.textContent="AR NOT SUPPORTED"}function C(s){s.style.position="absolute",s.style.bottom="20px",s.style.padding="12px 6px",s.style.border="1px solid #fff",s.style.borderRadius="4px",s.style.background="rgba(0,0,0,0.1)",s.style.color="#fff",s.style.font="normal 13px sans-serif",s.style.textAlign="center",s.style.opacity="0.5",s.style.outline="none",s.style.zIndex="999"}if("xr"in navigator)return t.id="ARButton",t.style.display="none",C(t),navigator.xr.isSessionSupported("immersive-ar").then(function(s){s?g():n()}).catch(n),t;{let s=document.createElement("a");return window.isSecureContext===!1?(s.href=document.location.href.replace(/^http:/,"https:"),s.innerHTML="WEBXR NEEDS HTTPS"):(s.href="https://immersiveweb.dev/",s.innerHTML="WEBXR NOT AVAILABLE"),s.style.left="calc(50% - 90px)",s.style.width="180px",s.style.textDecoration="none",C(s),s}}};var Wy=class{static createButton(A,e){e&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');let t=document.createElement("button");function i(){let C=null;async function s(a){a.addEventListener("end",r),await A.xr.setSession(a),t.textContent="EXIT VR",C=a}function r(){C.removeEventListener("end",r),t.textContent="ENTER VR",C=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR",t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){if(C===null){let a={optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};navigator.xr.requestSession("immersive-vr",a).then(s)}else C.end()}}function g(){t.disabled=!0,t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function o(){g(),t.textContent="VR NOT SUPPORTED"}function n(C){C.style.position="absolute",C.style.bottom="20px",C.style.padding="12px 6px",C.style.border="1px solid #fff",C.style.borderRadius="4px",C.style.background="rgba(0,0,0,0.1)",C.style.color="#fff",C.style.font="normal 13px sans-serif",C.style.textAlign="center",C.style.opacity="0.5",C.style.outline="none",C.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",n(t),navigator.xr.isSessionSupported("immersive-vr").then(function(C){C?i():o(),Wy.xrSessionIsGranted&&(console.log("XR session is granted - will enter immersive web now"),t.click())}),t;{let C=document.createElement("a");return window.isSecureContext===!1?(C.href=document.location.href.replace(/^http:/,"https:"),C.innerHTML="WEBXR NEEDS HTTPS"):(C.href="https://immersiveweb.dev/",C.innerHTML="WEBXR NOT AVAILABLE"),C.style.left="calc(50% - 90px)",C.style.width="180px",C.style.textDecoration="none",n(C),C}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Wy.xrSessionIsGranted=!0})}}},Vc=Wy;uA(Vc,"xrSessionIsGranted",!1);Vc.registerSessionGrantedListener();var fT=Ma(jw(),1);var zc="noVoip",CI=sA("debugvoip"),k8=sA("voip");var bU=class{id;constructor(A){this.id=A}};var xU=class{peer;voip;userId;peerId;call=null;callErrorListener=null;stream=null;constructor(A,e,t,i){this.voip=A,this.peer=e,this.userId=t,this.peerId=i}close(){CI&&console.log("close voip call"),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.open&&this.call.close(),this.stream?.getTracks().forEach(function(A){A.stop()})}updateMute(A){if(!this.stream)return;let e=this.stream?.getAudioTracks();for(let t of e)t.enabled=!A}async startVoipCall(){if(!await Zg.HasMicrophonePermissions()){console.warn("no permission to use microphone, can not start call");return}CI&&console.log("start voip call"),this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),this.updateMute(this.voip.muteOutput),CI&&console.log(this.stream),this.call=this.peer.call(this.peerId,this.stream,{metadata:{userId:this.userId}}),this.call.on("error",e=>{console.error(e)}),this.call.on("stream",e=>{CI&&console.log("received stream from remote again",e)}),this.peer.on("close",this.onCallClose.bind(this)),this.callErrorListener=e=>{e.message.includes(this.peerId)?(console.log("Could not connect to "+this.peerId),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.close(),this.stream?.getTracks().forEach(function(t){t.stop()}),this.stream=null):console.error(e)},this.peer.on("error",this.callErrorListener)}onCallClose(A){CI&&console.log("call closed",A)}},LU=class{get currentStream(){return this.stream}get currentAudio(){return this.audio}get currentAnalyzer(){return this.analyzer}voip;call;audio=null;stream=null;obj;analyzer=null;waitingForStart=!1;closed=!1;audioElement=null;constructor(A,e,t){this.voip=A,this.obj=e,this.call=t}openAudioStream(A){let e=A.getAudioTracks();for(let t of e)if(t.kind==="audio"&&t.readyState==="live"){this.open(t);return}console.warn("failed finding valid audio stream to begin call")}open(A){console.assert(A.kind==="audio","invalid track kind, expected audio but received "+A.kind),!this.waitingForStart&&(this.waitingForStart=!0,ct.userInteractionRegistered||CI&&console.log("Incoming call, waiting for user interaction before opening audio"),ct.registerWaitForAllowAudio(async()=>{if(this.call.open&&!this.closed){CI&&console.log("Setup audio and begin listening"),this.stream=new MediaStream([A]);let e=new AB;this.audio=new ar(e),this.audio.setVolume(this.voip.muteInput?0:1),this.audio.setMediaStreamSource(this.stream);let t=document.createElement("audio");this.audioElement=t,t.style.display="none",document.body.appendChild(t),t.srcObject=this.stream,t.sinkId!==void 0&&navigator.mediaDevices.enumerateDevices().then(i=>{if(!!t){console.log(i);for(let g of i)if(g.label==="Speakerphone"){t.sinkId=g.deviceId;break}}}),CI&&console.log("call is setup, you should hear something now"),this.analyzer=new pd(this.audio,32)}}))}close(){this.closed=!0,this.call?.open&&this.call.close(),this.audio?.disconnect(),this.stream?.getTracks().forEach(A=>{A.stop()}),this.stream=null,this.audioElement&&this.audioElement.remove()}},Zg=class extends EA{requireParam=!1;set muteInput(A){if(A===this._inputMuted||(this._inputMuted=A,!this.currentIncomingCalls))return;let e=this._inputMuted?0:1;for(let t in this.currentIncomingCalls)this.currentIncomingCalls[t]?.currentAudio?.setVolume(e)}get muteInput(){return this._inputMuted}set muteOutput(A){if(A!==this._outputMuted&&(this._outputMuted=A,!!this.connections))for(let e in this.connections)this.connections[e]?.updateMute(A)}get muteOutput(){return this._outputMuted}getFrequency(A){if(A===null){for(let t in this.currentIncomingCalls){let i=this.currentIncomingCalls[t];if(i&&i.currentAnalyzer)return i.currentAnalyzer.getAverageFrequency()}return null}let e=this.currentIncomingCalls[A];return e&&e.currentAnalyzer?e.currentAnalyzer.getAverageFrequency():null}peer=null;model=null;connections={};currentIncomingCalls={};_inputMuted=!1;_outputMuted=!1;awake(){if(sA(zc)){console.log("VOIP is disabled by url parameter: "+zc);return}if(this.requireParam&&!k8){console.debug("VOIP must be enabled explicitly by url parameter");return}if(VQ()&&Zp()){console.log("VOIP is currently not supported on Safari iOS");return}this.peer=new fT.default,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,this.context.connection.beginListen("joined-room",A=>{navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}),this.context.connection.beginListen("peer-update-id",A=>{if(A.id!==this.context.connection.connectionId){let e=this.connections[A.id];if(e&&e.close(),this.peer&&this.context.connection.connectionId){let t=new xU(this,this.peer,this.context.connection.connectionId,A.peerId);this.connections[A.id]=t,t.startVoipCall()}}}),this.context.connection.beginListen("user-left-room",A=>{let{userId:e}=A,t=this.connections[e];this.connections[e]=null,t&&t.close();let i=this.currentIncomingCalls[e];CI&&console.log("UserLeftRoom",A,e,i),i&&(i.close(),this.currentIncomingCalls[e]=null)}),this.peer.on("open",this.onOpenPeerConnection.bind(this))}onEnable(){}onDisable(){console.log("TODO: close all");for(let A in this.currentIncomingCalls)try{this.currentIncomingCalls[A]?.close(),this.connections[A]?.close()}catch(e){console.error(e)}}async onOpenPeerConnection(A){CI&&console.log("Peer connection established and received id"),this.model=new bU(A),this.context.connection.send("peer-update-id",this.model,1),this.peer&&(this.peer.on("call",this.onReceiveCall.bind(this)),this.peer.on("connection",function(e){CI&&console.log("CONNECTION",e),e.on("data",function(t){CI&&console.log("Received",t)})}))}async onReceiveCall(A){let{metadata:e}=A;console.assert(e.userId);let{userId:t}=e,{peer:i}=A,g=this.currentIncomingCalls[t];if(g&&g.close(),CI&&console.log("received call"),await Zg.HasMicrophonePermissions()){let o=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});A.answer(o)}else A.answer(null);this.currentIncomingCalls[t]=new LU(this,this.gameObject,A),A.on("stream",o=>{CI&&console.log("receive caller stream, will setup audio now"),this.currentIncomingCalls[t]?.openAudioStream(o)}),A.on("error",console.error)}static async HasMicrophonePermissions(){return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}};var sI=class extends EA{webAR=null;get rig(){return this.webAR?.webxr.Rig}invertForward=!1;get arScale(){return this._arScale}set arScale(A){A!==this._arScale&&(this._arScale=A,this.setScale(A))}_initalMatrix=new zA;_selectStartFn=this.onSelectStart.bind(this);_selectEndFn=this.onSelectEnd.bind(this);start(){let A=IA.findObjectOfType(pe);A&&(A.Rig.updateMatrix(),this._initalMatrix.copy(A.Rig.matrix))}_arScale=5;_rig=null;_startPose=null;_placementPose=null;_isTouching=!1;_rigStartPose=null;onBegin(A){this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose=this.gameObject.matrix.clone(),this._rigStartPose=this.rig?.matrix.clone(),A.addEventListener("selectstart",this._selectStartFn),A.addEventListener("selectend",this._selectEndFn),this.gameObject.visible=!1,this.rig&&(this.rig.matrixAutoUpdate=!0,this._initalMatrix.decompose(this.rig.position,this.rig.quaternion,this.rig.scale))}onUpdate(A,e,t){return t&&!this._placementPose&&this._isTouching?(this.webAR&&this.webAR.setReticleActive(!1),this.placeAt(A,new zA().fromArray(t.transform.matrix).invert()),!0):!1}placeAt(A,e){this._placementPose||(this._placementPose=new zA),this._placementPose.copy(e);let t=this.gameObject.matrixWorld.clone().invert();if(this._placementPose.premultiply(t),A){if(this.invertForward){let i=new zA().makeRotationY(Math.PI);this._placementPose.premultiply(i)}this._rig=A,this.setScale(this.arScale)}else this._rig=null;this.gameObject.visible=!0}onEnd(A,e){this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose&&this.gameObject.matrix.copy(this._startPose),A&&(A.matrixAutoUpdate=!0,this._rigStartPose&&this._rigStartPose.decompose(A.position,A.quaternion,A.scale)),Et.markDirty(this.gameObject,!0),setTimeout(()=>{this.gameObject.matrixAutoUpdate=!0,this.gameObject.visible=!0},100)}onSelectStart(){this._isTouching=!0}onSelectEnd(){this._isTouching=!1}setScale(A){let e=this._rig;!e||!this._placementPose||(this._rigStartPose||(this._rigStartPose=e.matrix.clone()),e.matrixAutoUpdate=!1,e.matrix.multiplyMatrices(new zA().makeScale(A,A,A),this._placementPose),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(),console.log("Place",e.position))}};U([F()],sI.prototype,"invertForward",2),U([F()],sI.prototype,"arScale",1);var on=class extends EA{objectBounds=!1;color;isGizmo=!0;_gizmoObject=null;_boxHelper=null;onEnable(){this.isGizmo&&!Nn||(this._gizmoObject||(this.objectBounds&&this.gameObject.isMesh===!0?this._gizmoObject=new LC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=Lw(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),3)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(;this._boxHelper;)this._boxHelper?.update(),yield}};U([F()],on.prototype,"objectBounds",2),U([F(W)],on.prototype,"color",2),U([F()],on.prototype,"isGizmo",2);var R8=sA("debugrig"),Kr=class extends EA{awake(){if(R8){let A=new vA;A.position.y+=.5,this.gameObject.add(A);let e=A.addNewComponent(on);e&&(e.isGizmo=!1)}}};var zn=class{bb=null;bb_pos=0;__init(A,e){return this.bb_pos=A,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}w(){return this.bb.readFloat32(this.bb_pos+12)}static sizeOf(){return 16}static createVec4(A,e,t,i,g){return A.prep(4,16),A.writeFloat32(g),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}};var pi=class{bb=null;bb_pos=0;__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsVrUserStateBuffer(A,e){return(e||new pi).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsVrUserStateBuffer(A,e){return A.setPosition(A.position()+4),(e||new pi).__init(A.readInt32(A.position())+A.position(),A)}guid(A){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}time(){let A=this.bb.__offset(this.bb_pos,6);return A?this.bb.readInt64(this.bb_pos+A):this.bb.createLong(0,0)}avatarId(A){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,A):null}position(A){let e=this.bb.__offset(this.bb_pos,10);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}rotation(A){let e=this.bb.__offset(this.bb_pos,12);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}scale(){let A=this.bb.__offset(this.bb_pos,14);return A?this.bb.readFloat32(this.bb_pos+A):0}posLeftHand(A){let e=this.bb.__offset(this.bb_pos,16);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}posRightHand(A){let e=this.bb.__offset(this.bb_pos,18);return e?(A||new oi).__init(this.bb_pos+e,this.bb):null}rotLeftHand(A){let e=this.bb.__offset(this.bb_pos,20);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}rotRightHand(A){let e=this.bb.__offset(this.bb_pos,22);return e?(A||new zn).__init(this.bb_pos+e,this.bb):null}static startVrUserStateBuffer(A){A.startObject(10)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addTime(A,e){A.addFieldInt64(1,e,A.createLong(0,0))}static addAvatarId(A,e){A.addFieldOffset(2,e,0)}static addPosition(A,e){A.addFieldStruct(3,e,0)}static addRotation(A,e){A.addFieldStruct(4,e,0)}static addScale(A,e){A.addFieldFloat32(5,e,0)}static addPosLeftHand(A,e){A.addFieldStruct(6,e,0)}static addPosRightHand(A,e){A.addFieldStruct(7,e,0)}static addRotLeftHand(A,e){A.addFieldStruct(8,e,0)}static addRotRightHand(A,e){A.addFieldStruct(9,e,0)}static endVrUserStateBuffer(A){return A.endObject()}static finishVrUserStateBufferBuffer(A,e){A.finish(e)}static finishSizePrefixedVrUserStateBufferBuffer(A,e){A.finish(e,void 0,!0)}};var DT=sA("debugxr"),Mu=sA("debugavatar");var TU="VRUS";kc(TU,pi.getRootAsVrUserStateBuffer);function vU(){return new Date().getTime()}function U8(I){let A=I&4294967295,e=I/Math.pow(2,32)&1048575;return pg.create(A,e)}var Gu=class{guid;time;avatarId;position=new k;rotation=new Ae;scale=1;posLeftHand=new k;posRightHand=new k;rotLeftHand=new KA;rotRightHand=new KA;constructor(A){this.guid=A}update(A,e,t,i,g){this.time=vU(),this.avatarId=g,this.position.set(e.x,e.y,e.z),A&&this.position.applyMatrix4(A.matrixWorld);let o=Gu.quat0,n=Gu.quat1;o.set(t.x,t.y,t.z,t.w),o=o.multiplyQuaternions(o,Gu.invertRotation),A&&(A.getWorldQuaternion(n),o.multiplyQuaternions(n,o)),this.rotation.set(o.x,o.y,o.z,o.w),this.scale=A.scale.x;let C=i.LeftController?.controllerGrip;C&&(C.getWorldPosition(this.posLeftHand),C.getWorldQuaternion(this.rotLeftHand));let s=i.RightController?.controllerGrip;if(s&&(s.getWorldPosition(this.posRightHand),s.getWorldQuaternion(this.rotRightHand)),i.LeftController?.hand?.visible){let r=i.LeftController.wrist;r&&(r.getWorldPosition(this.posLeftHand),r.getWorldQuaternion(this.rotLeftHand))}if(i.RightController?.hand?.visible){let r=i.RightController.wrist;r&&(r.getWorldPosition(this.posRightHand),r.getWorldQuaternion(this.rotRightHand))}}sendAsBuffer(A,e){A.clear();let t=A.createString(this.guid),i=A.createString(this.avatarId);pi.startVrUserStateBuffer(A),pi.addGuid(A,t),pi.addTime(A,U8(this.time)),pi.addAvatarId(A,i),pi.addPosition(A,oi.createVec3(A,this.position.x,this.position.y,this.position.z)),pi.addRotation(A,zn.createVec4(A,this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)),pi.addScale(A,this.scale),pi.addPosLeftHand(A,oi.createVec3(A,this.posLeftHand.x,this.posLeftHand.y,this.posLeftHand.z)),pi.addPosRightHand(A,oi.createVec3(A,this.posRightHand.x,this.posRightHand.y,this.posRightHand.z)),pi.addRotLeftHand(A,zn.createVec4(A,this.rotLeftHand.x,this.rotLeftHand.y,this.rotLeftHand.z,this.rotLeftHand.w)),pi.addRotRightHand(A,zn.createVec4(A,this.rotRightHand.x,this.rotRightHand.y,this.rotRightHand.z,this.rotRightHand.w));let g=pi.endVrUserStateBuffer(A);A.finish(g,TU);let o=A.asUint8Array();e.sendBinary(o)}setFromBuffer(A,e){if(!A)return;this.guid=A,this.time=e.time().toFloat64();let t=e.avatarId();t&&(this.avatarId=t);let i=e.position();i&&this.position.set(i.x(),i.y(),i.z());let g=e.rotation();g&&this.rotation.set(g.x(),g.y(),g.z(),g.w());let o=e.posLeftHand();o&&this.posLeftHand.set(o.x(),o.y(),o.z());let n=e.posRightHand();n&&this.posRightHand.set(n.x(),n.y(),n.z());let C=e.rotLeftHand();C&&this.rotLeftHand.set(C.x(),C.y(),C.z(),C.w());let s=e.rotRightHand();s&&this.rotRightHand.set(s.x(),s.y(),s.z(),s.w()),this.scale=e.scale()}},Eo=Gu;uA(Eo,"invertRotation",new KA().setFromAxisAngle(new k(0,1,0),Math.PI)),uA(Eo,"quat0",new KA),uA(Eo,"quat1",new KA);var ts=class extends EA{webXR=null;debugAvatarUser=null;voip=null;async awake(){if(this.webXR||(this.webXR=IA.getComponent(this.gameObject,pe)),this.webXR||(this.webXR=IA.findObjectOfType(pe,this.context)),!this.webXR&&(console.log("Missing webxr component"),this.webXR=IA.findObjectOfType(pe,this.context),!this.webXR)){console.error("Could not find webxr component");return}if(this.voip||(this.voip=IA.findObjectOfType(Zg,this.context)),Mu){let A="debug-avatar-"+Mu,e=new ro(this.context,A,this.webXR);if(this.debugAvatarUser=e,typeof Mu=="string"&&Mu.length>0)if(await e.setAvatarOverride(Mu)){let t=new Eo(A);t.position.y+=1;let i=.5;t.posLeftHand.y+=i,t.posLeftHand.x+=i,t.posRightHand.y+=i,t.posRightHand.x-=i,e.tryUpdate(t,0)}else e.destroy()}}onEnable(){if(!this.webXR&&(this.webXR=IA.getComponent(this.gameObject,pe),!this.webXR)){console.warn("Missing webxr component on "+this.gameObject.name);return}this.eventSub_WebXRStartEvent=this.onXRSessionStart.bind(this),pe.addEventListener("xrStarted",this.eventSub_WebXRStartEvent),this.eventSub_WebXRUpdateEvent=this.onXRSessionUpdate.bind(this),pe.addEventListener("xrUpdate",this.eventSub_WebXRUpdateEvent),this.eventSub_WebXREndEvent=this.onXRSessionEnded.bind(this),pe.addEventListener("xrStopped",this.eventSub_WebXREndEvent),this.eventSub_ConnectionEvent=this.onConnected.bind(this),this.context.connection.beginListen("joined-room",this.eventSub_ConnectionEvent),this.context.connection.beginListen("webxr-user-joined",A=>{console.log("webxr user joined evt")}),this.context.connection.beginListen("webxr-user-left",A=>{let e=A.id!==null&&A.id!==void 0;!e||(console.log("webxr user left evt"),e&&(this.avatars[A.id]?.destroy(),this.avatars[A.id]=void 0))}),this.context.connection.beginListenBinrary(TU,A=>{let e=A.guid();if(!e)return;let t=A.time().toFloat64(),i=this.tempState;i.setFromBuffer(e,A),this.onTryGetAvatar(e,t)?.tryUpdate(i,t)}),this.context.connection.beginListen("vr-session-update",A=>{let e=A.guid,t=A.time;this.onTryGetAvatar(e,t)?.tryUpdate(A,t)})}tempState=new Eo("");onTryGetAvatar(A,e){if(A===this.context.connection.connectionId)return null;let t=new Date().getTime()-e;if(t>5e3)return DT&&console.log("old data",t,A),null;let i=this.avatars[A];if(i===void 0)try{console.log("create new avatar");let g=new ro(this.context,A,this.webXR);i=g,this.avatars[A]=g}catch(g){this.avatars[A]=null,console.error(g)}return i}onDisable(){this.eventSub_ConnectionEvent&&this.context.connection.stopListening("joined-room",this.eventSub_ConnectionEvent),pe.removeEventListener("xrStarted",this.eventSub_WebXRStartEvent),pe.removeEventListener("xrUpdate",this.eventSub_WebXRUpdateEvent),pe.removeEventListener("xrStopped",this.eventSub_WebXREndEvent)}update(){let A=vU();this.debugAvatarUser&&(this.debugAvatarUser.lastUpdate=A),this.detectPotentiallyDisconnectedAvatarsAndRemove();for(let e in this.avatars){let t=this.avatars[e];!t||t.update()}}_removeAvatarsList=[];detectPotentiallyDisconnectedAvatarsAndRemove(){let A=vU();for(let e in this.avatars){let t=this.avatars[e];if(!t){this._removeAvatarsList.push(e);continue}A-t.lastUpdate>1e4&&(console.log("avatar timed out (didnt receive any updates in a while) - destroying it now"),t.destroy(),this.avatars[e]=void 0)}for(let e of this._removeAvatarsList)delete this.avatars[e];this._removeAvatarsList.length=0}buildLocalAvatar(){if(this.localAvatar)return;let A=this.context.connection?.connectionId??this.k_LocalAvatarNoNetworkingGuid;this.localAvatar=new ro(this.context,A,this.webXR),this.localAvatar.isLocalAvatar=!0,this.localAvatar.setAvatarOverride(this.getAvatarId()),this.avatars[this.localAvatar.guid]=this.localAvatar}eventSub_ConnectionEvent=null;eventSub_WebXRStartEvent=null;eventSub_WebXREndEvent=null;eventSub_WebXRUpdateEvent=null;avatars={};localAvatar=null;k_LocalAvatarNoNetworkingGuid="local";onConnected(){DT&&console.log("Hey you are connected as "+this.context.connection.connectionId),this.localAvatar?.guid===this.k_LocalAvatarNoNetworkingGuid&&(this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0),this.localAvatar=null,this.xrState=null,this.ownership?.freeOwnership(),this.ownership=null)}onXRSessionStart(A){if(console.log("XR session started"),this.context.connection.send("webxr-user-joined",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null),this.xrState=null,this.ownership?.freeOwnership(),this.ownership=null,this.avatars)for(let e in this.avatars)this.avatars[e]?.updateFlags()}onXRSessionEnded(A){console.log("XR session ended"),this.context.connection.send("webxr-user-left",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&(this.localAvatar?.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null)}ownership=null;xrState=null;builder=new kI(1024);onXRSessionUpdate(A){this.xrState??=new Eo(this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid),this.ownership??=new wr(this.context.connection,this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid),this.ownership.guid=this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid,this.buildLocalAvatar();let{frame:e,xr:t,rig:i}=A,g=e.getViewerPose(t.getReferenceSpace());if(!g)return;let o=g?.transform,n=o.position,C=o.orientation;this.xrState.update(i,n,C,this.webXR,this.getAvatarId()),this.localAvatar&&(this.context.connection.connectionId&&(this.localAvatar.guid=this.context.connection.connectionId),this.localAvatar.tryUpdate(this.xrState,0)),!(this.ownership&&!this.ownership.hasOwnership&&this.context.connection.isConnected&&(this.context.time.frameCount%120===0&&this.ownership.requestOwnership(),!this.ownership.hasOwnership))&&(!this.context.connection.isConnected||!this.context.connection.connectionId||this.xrState.sendAsBuffer(this.builder,this.context.connection))}getAvatarId(){return sA("avatar")??null}};async function F8(){return jp()?!0:"xr"in navigator?await navigator.xr.isSessionSupported("immersive-ar")===!0:!1}async function N8(){return"xr"in navigator?await navigator.xr.isSessionSupported("immersive-vr")===!0:!1}var HU=!1,YU=!1;F8().then(I=>HU=I);N8().then(I=>YU=I);var Ki=class extends EA{enableVR=!0;enableAR=!0;defaultAvatar;handModelPath="";createVRButton=!0;createARButton=!0;static get IsInWebXR(){return this._isInXr}static get XRSupported(){return"xr"in navigator&&(HU||YU)}static get IsARSupported(){return HU}static get IsVRSupported(){return YU}static addEventListener(A,e){return this.events.addEventListener(A,e),e}static removeEventListener(A,e){return this.events.removeEventListener(A,e),e}static createVRButton(A,e){Ki.XRSupported?A.__internalAwake():console.warn("WebXR is not supported on this device");let t=Vc.createButton(A.context.renderer);return t.classList.add("webxr-ar-button"),t.classList.add("webxr-button"),this.resetButtonStyles(t),(e?.registerClick??!0)&&t.addEventListener("click",A.onClickedVRButton.bind(A)),t}static createARButton(A,e){A.__internalAwake();let t=A.webAR?.getAROverlayContainer(),i={};t?(i.domOverlay={root:t},i.optionalFeatures=["hit-test","dom-overlay"]):console.warn("No dom overlay root found, HTML overlays on top of screen-based AR will not work."),i.optionalFeatures.push("plane-detection"),i.optionalFeatures.push("anchors");let g=Py.createButton(A.context.renderer,i);return g.classList.add("webxr-ar-button"),g.classList.add("webxr-button"),Ki.resetButtonStyles(g),(e?.registerClick??!0)&&g.addEventListener("click",A.onClickedARButton.bind(A)),g}static resetButtonStyles(A){!A||(A.style.position="",A.style.bottom="",A.style.left="")}endSession(){let A=this.context.renderer.xr.getSession();A&&A.end()}get Rig(){return this.rig||this.ensureRig(),this.rig}controllers=[];get Controllers(){return this.controllers}get LeftController(){return this.controllers.length>0&&this.controllers[0].input?.handedness==="left"?this.controllers[0]:this.controllers.length>1&&this.controllers[1].input?.handedness==="left"?this.controllers[1]:null}get RightController(){return this.controllers.length>0&&this.controllers[0].input?.handedness==="right"?this.controllers[0]:this.controllers.length>1&&this.controllers[1].input?.handedness==="right"?this.controllers[1]:null}get ARButton(){return this._arButton}get VRButton(){return this._vrButton}get IsInVR(){return this._isInVR}get IsInAR(){return this._isInAR}rig;isInit=!1;_requestedAR=!1;_requestedVR=!1;_isInAR=!1;_isInVR=!1;_arButton;_vrButton;webAR=null;awake(){if(this.defaultAvatar&&typeof this.defaultAvatar=="string"&&(this.defaultAvatar=jg.getOrCreate(this.sourceId??"/",this.defaultAvatar,this.context)),!IA.findObjectOfType(ts,this.context)){let A=IA.addNewComponent(this.gameObject,ts,!1);A.webXR=this}this.webAR=new Jr(this)}onEnable(){if(this.isInit||!this.enableAR&&!this.enableVR)return;this.isInit=!0,this.context.renderer.xr.enabled=!0;let A=Ki.XRSupported,e,t,i=document.createElement("div");i.classList.add("webxr-buttons"),this.context.domElement.append(i),this.enableAR&&this.createARButton&&(e=Ki.createARButton(this),this._arButton=e,i.appendChild(e)),this.createVRButton&&this.enableVR&&(t=Ki.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Ki.resetButtonStyles(t),Ki.resetButtonStyles(e)},1e3)}_transformOrientation=new KA;get TransformOrientation(){return this._transformOrientation}_currentHeadPose=null;get HeadPose(){return this._currentHeadPose}onBeforeRender(A){if(!A)return;let e=this.context.renderer.xr.getSession();if(e){let t=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!t)return;this._currentHeadPose=t;let i=t?.transform;i&&this._transformOrientation.set(i.orientation.x,i.orientation.y,i.orientation.z,i.orientation.w),Ki._isInXr===!1&&e&&this.onEnterXR(e,A);for(let g of this.controllers)g.onUpdate(e);this._isInAR&&this.webAR?.onUpdate(e,A)}Ki.events.dispatchEvent({type:"xrUpdate",frame:A,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let A=0;A<2;A++)it.Create(this,A,this.gameObject,0);Ki.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ge(this.context.mainCamera)),this._originalCameraRotation.copy(bt(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){let A=IA.findObjectOfType(Kr,this.context);A?this.rig=A.gameObject:(this.rig=new xo,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}_originalCameraParent=null;_originalCameraPosition=new k;_originalCameraRotation=new KA;_originalXRRigParent=null;_originalXRRigPosition=new k;_originalXRRigRotation=new KA;onEnterXR(A,e){console.log("[XR] session begin",A),Ki._isInXr=!0,this.ensureRig();let t=this.context.renderer.xr.getReferenceSpace();if(t&&this.rig){let n=e.getViewerPose(t)?.transform.orientation;if(n){let C=new KA(n.x,n.y,n.z,n.w),s=new $e().setFromQuaternion(C);this.rig.rotateY(s.y)}}let i=this.context.renderer.xr;if(this.context.mainCamera){let o=i.getCamera(this.context.mainCamera);for(let n of o.cameras)n.layers.enableAll();this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}let g=this._requestedAR?2:4;switch(FI.Global.Set(g),g){case 2:this.context.xrSessionMode="immersive-ar",this._isInAR=!0,this.webAR?.onBegin(A);break;case 4:this.context.xrSessionMode="immersive-vr",this._isInVR=!0,this.onEnterVR(A);break}A.addEventListener("end",()=>{console.log("[XR] session end"),Ki._isInXr=!1,this.onExitXR(A)}),this.onEnterXR_HandleMirrorWindow(A),Ki.events.dispatchEvent({type:"xrStarted",session:A})}onExitXR(A){let e=this._isInAR;this._isInAR&&A&&this.webAR?.onEnd(A),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&(this._originalCameraParent?.add(this.context.mainCamera),at(this.context.mainCamera,this._originalCameraPosition),Og(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),e&&(this._originalXRRigParent?.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),FI.Global.Set(17),Ki.events.dispatchEvent({type:"xrStopped",session:A})}onEnterVR(A){}destroyControllers(){for(let A=this.controllers.length-1;A>=0;A-=1)this.controllers[A]?.destroy();this.controllers.length=0}xrMirrorWindow=null;onEnterXR_HandleMirrorWindow(A){!sA("mirror")||setTimeout(()=>{if(!Ki.IsInWebXR)return;let e=new URL(window.location.href);OQ(e.searchParams,zc,1),OQ(e.searchParams,"isMirror",1);let t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Ki.IsInWebXR&&A.end()})})},1e3)}},pe=Ki;uA(pe,"_isInXr",!1),uA(pe,"events",new _i),U([F()],pe.prototype,"enableVR",2),U([F()],pe.prototype,"enableAR",2),U([F(jg)],pe.prototype,"defaultAvatar",2),U([F()],pe.prototype,"handModelPath",2),U([F()],pe.prototype,"createVRButton",2),U([F()],pe.prototype,"createARButton",2);var jc=class{get webxr(){return this._webxr}_webxr;reticle=null;reticleParent=null;hitTestSource=null;reticleActive=!0;previousBackground=null;previousEnvironment=null;sessionRoot=null;_previousParent=null;get context(){return this.webxr.context}constructor(A){this._webxr=A}arDomOverlay=null;arOverlayElement=null;noHitTestAvailable=!1;didPlaceARSessionRoot=!1;getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;let A=this.arDomOverlay;return A.getAROverlayContainer?this.arOverlayElement=A.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(A){this.reticleActive=A}async onBegin(A){let e=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();let t=navigator.userAgent?.includes("OculusBrowser")?0:1,i=t===1?4:2;for(let o=0;o<i;o++)it.Create(this.webxr,o,this.webxr.gameObject,t);(!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=IA.findObjectOfType(sI,e)),this.previousBackground=e.scene.background,this.previousEnvironment=e.scene.environment,e.scene.background=null,A.requestReferenceSpace("viewer").then(o=>{A.requestHitTestSource?.call(A,{space:o})?.then(n=>{this.hitTestSource=n}).catch(n=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",n)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new we(new Gn(.07,.09,32).rotateX(-Math.PI/2),new yt),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new vA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,jc.tempWebXRObject||(jc.tempWebXRObject=new vA),this.context.scene.add(jc.tempWebXRObject),IA.addComponent(jc.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,this.sessionRoot?.onBegin(A)):console.warn("No WebARSessionRoot found in scene");let g=this.context.domElement;g?.onEnterAR?.call(g,A,this.arOverlayElement),this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera()}onEnd(A){this._previousParent&&(IA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;let e=this.webxr.context;e.scene.background=this.previousBackground,e.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,A);let t=this.context.domElement;t.onExitAR?.call(t,A),this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera()}onUpdate(A,e){if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;let i=this.webxr.Rig,g=K8.clone();this.sessionRoot?.placeAt(i,g)}return}if(!this.hitTestSource)return;let t=e.getHitTestResults(this.hitTestSource);if(t.length){let i=t[0],g=this.webxr.context.renderer.xr.getReferenceSpace();if(g){let o=i.getPose(g);if(this.sessionRoot){let n=this.sessionRoot.onUpdate(this.webxr.Rig,A,o);this.didPlaceARSessionRoot=n}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&o)){let n=o.transform.matrix;this.reticle.matrix.fromArray(n),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else this.sessionRoot?.onUpdate(this.webxr.Rig,A,null),this.reticle&&(this.reticle.visible=!1)}},Jr=jc;uA(Jr,"tempWebXRObject");var K8=new zA().identity().makeTranslation(0,0,0);var nn=class{used=!1;Use(){this.used=!0}StopPropagation(){this.event?.stopImmediatePropagation()}inputSource;object;isDown;isUp;isPressed;isClicked;event;constructor(A){this.event=A}};var q8=sA("debugeventsystem"),jn=class extends EA{static createIfNoneExists(A){this.didSearchEventSystem||(this.didSearchEventSystem=!0,jn.systems.length<=0&&jn.systems.push(...IA.findObjectsOfType(jn,A)));for(let t of jn.systems)if(t.context===A)return;let e=new vA;IA.addNewComponent(e,jn),A.scene.add(e)}static get systems(){let A=Ee.Current;return this._eventSystemMap.has(A)||this._eventSystemMap.set(A,[]),this._eventSystemMap.get(A)}static ensureUpdateMeshUI(A,e){Cn.update(A,e)}static markUIDirty(A){Cn.markDirty()}static get instance(){return this.systems[0]}orbitControl=null;orbitControlWasEnabled=!1;raycaster=[];constructor(){super(),jn.systems.push(this)}onDestroy(){jn.systems.splice(jn.systems.indexOf(this),1)}start(){}register(A){A&&this.raycaster&&!this.raycaster.includes(A)&&this.raycaster?.push(A)}unregister(A){let e=this.raycaster?.indexOf(A);e!==void 0&&e!==-1&&this.raycaster?.splice(e,1)}_selectStartFn;_selectEndFn;_selectUpdateFn;onEnable(){let A=new Map;this._selectStartFn??=(t,i)=>{if(!i.grab)return;Cn.resetLastSelected();let g=new nn;g.inputSource=t,g.isDown=t.selectionDown,g.isUp=t.selectionUp,g.isPressed=t.selectionPressed,g.isClicked=!1,A.set(t,i.grab),i.grab&&!this.handleEvents(i.grab,g)&&(i.grab=null)},this._selectEndFn??=(t,i)=>{if(!i.grab)return;let g=new nn;g.inputSource=t,g.isDown=t.selectionDown,g.isUp=t.selectionUp,g.isPressed=t.selectionPressed,g.isClicked=t.selectionClick,this.handleEvents(i.grab,g);let o=A.get(t);if(A.set(t,null),o)for(let n=0;n<this.raisedPointerDownEvents.length;n++){let C=this.raisedPointerDownEvents[n];this.raisedPointerDownObjects[n]===o&&C&&(C.onPointerUp?.call(C,g),this.raisedPointerDownEvents.splice(n,1),this.raisedPointerDownObjects.splice(n,1),n--)}};let e=new vt;this._selectUpdateFn??=t=>{e.ray=t.getRay();let i=this.performRaycast(e);if(!i)return;let g=new nn;g.inputSource=t,this.handleIntersections(i,g)},it.addEventListener("select-start",this._selectStartFn),it.addEventListener("select-end",this._selectEndFn),it.addEventListener("update",this._selectUpdateFn),this.context.pre_update_callbacks.push(this.onBeforeUpdate.bind(this)),this.context.input.addEventListener("pointerdown",this.onPointerDown.bind(this))}onDisable(){it.removeEventListener("select-start",this._selectStartFn),it.removeEventListener("select-end",this._selectEndFn),it.removeEventListener("update",this._selectUpdateFn)}onPointerDown(){this.onBeforeUpdate()}lastPointerEvent=null;objectsHoveredThisFrame=[];objectsHoveredLastFrame=[];raisedPointerDownEvents=[];raisedPointerDownObjects=[];_didMove=!1;onBeforeUpdate(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),pe.IsInWebXR||this.context.input.isKeyPressed("Alt"))return;if(!this._didMove){let g=this.context.input.getPointerPositionRC(0);if(g&&g.x===0&&g.y===0)return;this._didMove=!0}let A=this.performRaycast(null),e=new nn(this.context.input.getPointerEvent(0));if(e.inputSource=this.context.input,e.isClicked=this.context.input.mouseClick,e.isDown=this.context.input.mouseDown,e.isUp=this.context.input.mouseUp,e.isPressed=this.context.input.mousePressed,this.lastPointerEvent=e,!A)return;let t=null,i=null;this.context.input.mouseDown&&this.currentActiveMeshUIComponents.length>0&&this.context.mainCameraComponent&&(t=IA.getComponent(this.context.mainCameraComponent.gameObject,Xi)??null,t&&(i=t.enabled,t.enabled=!1)),this.handleIntersections(A,e),t&&(this.orbitControl=t,this.orbitControl?.enabled?(this.orbitControlWasEnabled=this.orbitControl.enabled,this.orbitControl.enabled=!1):this.orbitControl&&!this.context.input.mousePressed&&(this.orbitControl.enabled=this.orbitControlWasEnabled,this.orbitControl=null))}_tempComponentsArray=[];onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(let e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(let e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;let t=IA.getComponentsInParent(e,EA,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let i=0;i<t.length;i++){let g=t[i];if(!g.gameObject||g.destroyed)continue;let o=g;o.onPointerExit&&o.onPointerExit(this.lastPointerEvent)}}let A=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=A}_sortedHits=[];performRaycast(A){if(!this.raycaster)return null;this._sortedHits.length=0;for(let e of this.raycaster){if(!e.activeAndEnabled)continue;let t=e.performRaycast(A);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(A,e){if(!A||A.length<=0)return!1;A=this.sortCandidates(A);for(let t of A){let{object:i}=t;if(this.handleEvents(i,e))return!0}return!1}_sortingBuffer=[];_noDepthTestingResults=[];sortCandidates(A){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<A.length;e++){let t=A[e],i=t.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(let e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventsArray=[];out={};handleEvents(A,e){if(!this.testIsVisible(A))return e.isClicked&&q8&&console.log("not allowed",A),!1;let t=A;e.object=A,this.lastPointerEvent=e;let i=A.parent,g=!1,o=e.isClicked??!1,n=null;if(i&&i.isUI){let C=(e.isPressed||e.isClicked)??!1;if(i[rI]){let s=i[rI].gameObject;if(s){if(!sn.isInteractable(s,this.out))return this.out.canvasGroup?.interactable??!1;n=this.out.canvasGroup??null;let a=this.handleMeshUIIntersection(A,C);A=s,g=!0}}if(!g&&this.handleMeshUiObjectWithoutShadowDom(i,C))return!0}if(this.objectsHoveredThisFrame.push(A),n===null||n.interactable){let C=this.objectsHoveredLastFrame.indexOf(A)>=0;this.handleEventsArray.length=0;let s=IA.getComponentsInParent(A,EA,this.handleEventsArray);for(let r=0;r<s.length;r++){if(e.used)return!0;if(s[r].destroyed)continue;let a=s[r];a.interactable!==!1&&(a.onPointerEnter&&(C||a.onPointerEnter(e)),e.isDown&&a.onPointerDown&&!this.raisedPointerDownEvents.includes(a)&&(a.onPointerDown(e),this.raisedPointerDownEvents.push(a),this.raisedPointerDownObjects.push(t)),e.isUp&&a.onPointerUp&&a.onPointerUp(e),e.isClicked&&a.onPointerClick&&a.onPointerClick(e))}}return!0}handleMeshUiObjectWithoutShadowDom(A,e){return!A||!A.isUI?!0:this.handleMeshUIIntersection(A,e)}currentActiveMeshUIComponents=[];handleMeshUIIntersection(A,e){let t=Cn.updateState(A,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Cn.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let A=0;A<this.currentActiveMeshUIComponents.length;A++){let e=this.currentActiveMeshUIComponents[A];Cn.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(A){return A?IA.isActiveSelf(A)?this.testIsVisible(A.parent):!1:!0}},wg=jn;uA(wg,"_eventSystemMap",new Map),uA(wg,"didSearchEventSystem",!1);var Cn=class{static markDirty(){this.needsUpdate=!0}static update(A,e){for(let t of this.lastUpdateFrame)if(t.context===e){if(e.time.frameCount===t.frame)return;t.frame=e.time.frameCount,(this.needsUpdate||e.time.frameCount<30)&&(this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:e.time.frameCount}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;e?(this.lastSelected=t,t.states.pressed&&t.setState("pressed")):t.states.hovered&&t.setState("hovered"),this.needsUpdate=!0}return t}static resetLastSelected(){let A=this.lastSelected;!A||(this.lastSelected=null,this.resetState(A))}static resetState(A){if(!A)return;A.interactable===!1?A.states.disabled&&A.setState("disabled"):A===this.lastSelected&&A.states.selected?A.setState("selected"):A.setState("normal"),this.needsUpdate=!0}static findBlockInParent(A){return A?A.isBlock&&Object.keys(A.states).length>0?A:this.findBlockInParent(A.parent):null}};uA(Cn,"lastSelected",null),uA(Cn,"lastUpdateFrame",[]),uA(Cn,"needsUpdate",!1);var Zc="./include";mu.prototype.interactable={get(){return this.interactive},set(I){this.interactable=I}};var rI=Symbol("shadowDomOwner"),tg=class extends EA{isRoot(){return this.Root?.gameObject===this.gameObject}markDirty(){wg.markUIDirty(this.context)}shadowComponent=null;_controlsChildLayout=!0;get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(A){this._controlsChildLayout=A,this.shadowComponent&&(this.shadowComponent.autoLayout=A)}_root=void 0;get Root(){return this._root===void 0&&(this._root=IA.getComponentInParent(this.gameObject,is)),this._root}_parentComponent=void 0;onEnable(){super.onEnable()}addShadowComponent(A,e){this.removeShadowComponent();let t=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=IA.getComponentInParent(t,tg),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have a UI element outside a Canvas?`,this);return}A.name=this.name+" ("+(this.constructor.name??"UI")+")",A.autoLayout=this._parentComponent.controlsChildLayout,A[rI]=this,A.traverse(g=>{g[rI]===void 0&&(g[rI]=this)});let i=!1;if(this.Root?.gameObject===this.gameObject)this.gameObject.add(A);else{let g=this._parentComponent.shadowComponent;g&&(g?.add(A),i=!0)}this.shadowComponent=A,e&&e.shadowComponent&&this.shadowComponent&&e.shadowComponent.add(this.shadowComponent),Nn&&A.add(new yI(.5)),this.onAfterAddedToScene(),i&&qU()}set(A){}traverseOwnedShadowComponents(A,e,t){if(!!A&&A[rI]===e){t(A);for(let i of A.children)this.traverseOwnedShadowComponents(i,e,t)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(A){this.shadowComponent&&(this.shadowComponent.interactable=A)}},is=class extends tg{awake(){super.awake()}};var sn=class{static getObject(A){let e=A[rI];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;let t=this.tryFindCanvasGroup(A);if(t?.isCanvasGroup===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;let i=Oo(A,g=>{if(g.isGraphic===!0)return g},!1);return e&&i?.isGraphic===!0&&(e.graphic=i),i?.raycastTarget!==!1}static tryFindCanvasGroup(A){if(!A)return null;let e=Oo(A,t=>{let i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}};var ku=sA("debugwebxrcontroller");var xB=class extends EA{},Ji=class extends EA{static CreateRaycastLine(){let A=new hg(this.geometry),e=A.material;return e.color=this.raycastColor,A.layers.set(2),A.name="line",A.scale.z=1,A}static CreateRaycastHitPoint(){let A=new Tg(.5,22,22),e=new yt({color:this.raycastColor}),t=new we(A,e);return t.visible=!1,t.layers.set(2),t}static Create(A,e,t,i){let g=t?IA.addNewComponent(t,Ji,!1):new Ji;g.webXR=A,g.index=e,g.type=i;let o=A.context;g.controller=o.renderer.xr.getController(e),g.controllerGrip=o.renderer.xr.getControllerGrip(e),g.controllerModel=this.Factory.createControllerModel(g.controller),g.controllerGrip.add(g.controllerModel),g.hand=o.renderer.xr.getHand(e);let n=new v8;VC(n,o),g.webXR.handModelPath&&g.webXR.handModelPath!==""?n.setPath(Sn(A.sourceId,g.webXR.handModelPath)):n.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/");let C=new b8(g.hand,n);return g.hand.add(C),g.hand.traverse(s=>s.layers.set(2)),g.handPointerModel=new x8(g.hand,g.controller),g.controller.addEventListener("connected",s=>{g.setControllerLayers(g.controllerModel,2),g.setControllerLayers(g.controllerGrip,2),g.setControllerLayers(g.hand,2),setTimeout(()=>{g.setControllerLayers(g.controllerModel,2),g.setControllerLayers(g.controllerGrip,2),g.setControllerLayers(g.hand,2)},1e3)}),g.hand.addEventListener("connected",s=>{if(s.data.hand){A.Rig&&A.Rig.add(g.hand),g.type=0,g.handPointerModel.traverse(B=>B.layers.set(2)),g.handPointerModel.pointerObject?.traverse(B=>B.layers.set(2));let a=g.hand.joints;if(a)for(let B of Object.keys(a)){let Q=a[B];Q.parent||g.hand.add(Q)}}}),g}static addEventListener(A,e){let t=this.eventSubs[A]??[];t.push(e),this.eventSubs[A]=t}static removeEventListener(A,e){if(!e)return;let t=this.eventSubs[A]??[],i=t.indexOf(e);i>=0&&t.splice(i,1),this.eventSubs[A]=t}webXR;index=-1;controllerModel;controller;controllerGrip;hand;handPointerModel;grabbed=null;input=null;type=0;showRaycastLine=!0;get isUsingHands(){let A=this.input?.hand;return A!=null}get wrist(){if(!this.hand)return null;let A=this.hand.joints;return A?A.wrist:null}_wristQuaternion=null;getWristQuaternion(){let A=this.wrist;return A?(this._wristQuaternion||(this._wristQuaternion=new KA),bt(A).multiply(this._wristQuaternion.setFromEuler(new $e(-Math.PI/4,0,0)))):null}movementVector=new k;worldRot=new KA;joystick=new SA;didRotate=!1;didTeleport=!1;didChangeScale=!1;lastHit=null;raycastLine=null;_raycastHitPoint=null;_connnectedCallback=null;_disconnectedCallback=null;_selectStartEvt=null;_selectEndEvt=null;get selectionDown(){return this._selectionPressed&&!this._selectionPressedLastFrame}get selectionUp(){return!this._selectionPressed&&this._selectionPressedLastFrame}get selectionPressed(){return this._selectionPressed}get selectionClick(){return this._selectionEndTime-this._selectionStartTime<.3}get raycastHitPoint(){return this._raycastHitPoint}_selectionPressed=!1;_selectionPressedLastFrame=!1;_selectionStartTime=0;_selectionEndTime=0;get useSmoothing(){return this._useSmoothing}_useSmoothing=!0;awake(){if(!this.controller){console.warn("Missing Controller!!!",this);return}this._connnectedCallback=this.onSourceConnected.bind(this),this._disconnectedCallback=this.onSourceDisconnected.bind(this),this._selectStartEvt=this.onSelectStart.bind(this),this._selectEndEvt=this.onSelectEnd.bind(this),this.type===1&&(this.controllerGrip.addEventListener("connected",this._connnectedCallback),this.controllerGrip.addEventListener("disconnected",this._disconnectedCallback),this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt))}onDestroy(){this.type===1&&(this.controllerGrip.removeEventListener("connected",this._connnectedCallback),this.controllerGrip.removeEventListener("disconnected",this._disconnectedCallback),this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.hand?.clear(),this.controllerGrip?.clear(),this.controller?.clear()}onEnable(){this.hand&&(this.hand.name="Hand"),this.controllerGrip&&(this.controllerGrip.name="ControllerGrip"),this.controller&&(this.controller.name="Controller"),this.raycastLine&&(this.raycastLine.name="RaycastLine;"),this.webXR.Controllers.indexOf(this)<0&&this.webXR.Controllers.push(this),this.raycastLine||(this.raycastLine=Ji.CreateRaycastLine()),this._raycastHitPoint||(this._raycastHitPoint=Ji.CreateRaycastHitPoint()),this.webXR.Rig?.add(this.hand),this.webXR.Rig?.add(this.controllerGrip),this.webXR.Rig?.add(this.controller),this.webXR.Rig?.add(this.raycastLine),this.raycastLine?.add(this._raycastHitPoint),this._raycastHitPoint.visible=!1,this.hand.add(this.handPointerModel),ku&&console.log("ADDED TO RIG",this.webXR.Rig)}onDisable(){this.hand?.removeFromParent(),this.controllerGrip?.removeFromParent(),this.controller?.removeFromParent(),this.raycastLine?.removeFromParent(),this._raycastHitPoint?.removeFromParent();let A=this.webXR.Controllers.indexOf(this);A>=0&&this.webXR.Controllers.splice(A,1)}_isConnected=!1;onSourceConnected(A){if(this._isConnected){console.warn("Received connected event for controller that is already connected",this.index,A);return}this._isConnected=!0,this.input=A.data,this.type===1&&(this.onSelectStart(),this.createPointerEvent("down"))}onSourceDisconnected(A){if(!this._isConnected){console.warn("Received discnnected event for controller that is not connected",A);return}this._isConnected=!1,this.type===1&&(this.onSelectEnd(),this.createPointerEvent("up")),this.input=null}createPointerEvent(A){switch(A){case"down":this.context.input.createPointerDown({clientX:0,clientY:0,button:this.index,pointerType:"touch"});break;case"move":break;case"up":this.context.input.createPointerUp({clientX:0,clientY:0,button:this.index,pointerType:"touch"});break}}rayRotation=new KA;update(){this.context.time.frameCount%60===0&&(this.setControllerLayers(this.controller,2),this.setControllerLayers(this.controllerGrip,2),this.setControllerLayers(this.hand,2));let A=Ji.eventSubs["update"];if(A&&A.length>0)for(let i of A)i(this);let e=1;this.type===0?e=this.context.time.deltaTime/.1:this.isUsingHands&&this.handPointerModel.pinched&&(e=this.context.time.deltaTime/.3),this.rayRotation.slerp(bt(this.controller),this.useSmoothing?e:1);let t=ge(this.controller);if(this.isUsingHands&&this.handPointerModel.cursorObject&&(this.handPointerModel.cursorObject.visible=!1),this.raycastLine){let i=this.showRaycastLine&&this.type!==1;if(this.type===1)this.raycastLine.visible=!1;else if(this.isUsingHands){this.raycastLine.visible=!this.grabbed&&i,at(this.raycastLine,t);let g=this.hand.joints;if(g&&g.wrist&&this.grabbed&&this.grabbed.isCloseGrab){let n=this.getWristQuaternion();n&&this.rayRotation.copy(n)}Og(this.raycastLine,this.rayRotation)}else this.raycastLine.visible=i,Og(this.raycastLine,this.rayRotation),at(this.raycastLine,t)}this.lastHit=this.updateLastHit(),this.grabbed&&this.grabbed.update(),this._selectionPressedLastFrame=this._selectionPressed,this.selectStartCallback&&this.selectStartCallback()}_pinchStartTime=void 0;onUpdate(A){if(this.lastHit=null,!A||A.inputSources.length<=this.index){this.input=null;return}if(this.type===0&&(this.input=A.inputSources[this.index]),!this.input)return;let e=this.webXR.Rig;if(!e)return;this._didNotEndSelection&&!this.handPointerModel.pinched&&(this._didNotEndSelection=!1,this.onSelectEnd()),this.updateStick(this.input);let t=this.input?.gamepad?.buttons;switch(this.input.handedness){case"left":let i=3*Ji.MovementSpeedFactor,g=2,o=VA.clamp01(this.joystick.length()*2),n=this.joystick.x>0?1:-1,C=Math.pow(this.joystick.x,g);C*=n,C*=o;let s=this.joystick.y>0?1:-1,r=Math.pow(this.joystick.y,g);r*=s,C*=o,e.getWorldQuaternion(this.worldRot),this.movementVector.set(C,0,r),this.movementVector.applyQuaternion(this.webXR.TransformOrientation),this.movementVector.y=0,this.movementVector.applyQuaternion(this.worldRot),this.movementVector.multiplyScalar(i*this.context.time.deltaTime),e.position.add(this.movementVector),this.isUsingHands&&this.runTeleport(e,t);break;case"right":let a=this.joystick.x,B=Math.abs(a);if(B<.4)this.didRotate=!1;else if(B>.5&&!this.didRotate){let Q=a>0?-1:1;e.rotateY(VA.toRadians(30*Q)),this.didRotate=!0}this.runTeleport(e,t);break}}runTeleport(A,e){let t=-this.joystick.y;if(this.hand?.visible&&!this.grabbed){let n=this.handPointerModel.isPinched();n&&this._pinchStartTime===void 0&&(this._pinchStartTime=this.context.time.time),n&&this._pinchStartTime&&this.context.time.time-this._pinchStartTime>.8&&(t=this.handPointerModel.isPinched()?1:0),n||(this._pinchStartTime=void 0)}else this._pinchStartTime=void 0;let i=t>.5&&this.webXR.IsInVR,g=this.webXR.Rig?this.webXR.Rig?.scale?.x<.999:!1,o=null;if(e&&this.input&&!this.input.hand)for(let n=0;n<e.length;n++){let C=e[n];if(n===4)if(C.pressed&&!this.didChangeScale&&this.webXR.IsInVR){this.didChangeScale=!0;let s=this.webXR.Rig;if(s)if(g){g=!1,s.scale.set(1,1,1),o=1,Ji.MovementSpeedFactor=1;let r=this.context.mainCamera;Ji.PreviousCameraFarDistance&&(r.far=Ji.PreviousCameraFarDistance)}else{g=!0,i=!0,o=.1,Ji.MovementSpeedFactor=o*2;let r=this.context.mainCamera;Ji.PreviousCameraFarDistance=r.far,r.far/=o}}else C.pressed||(this.didChangeScale=!1)}if(i){if(!this.didTeleport){let n=this.raycast();if(this.didTeleport=!0,n&&n.length>0){let C=n[0];if(g||this.isValidTeleportTarget(C.object)){let s=C.point;at(A,s)}}}}else t<.1&&(this.didTeleport=!1);o!==null&&(A.scale.set(o,o,o),A.updateMatrixWorld())}isValidTeleportTarget(A){return IA.getComponentInParent(A,xB)!=null}updateStick(A){!A||!A.gamepad||A.gamepad.axes?.length<4||(this.joystick.x=A.gamepad.axes[2],this.joystick.y=A.gamepad.axes[3])}updateLastHit(){let A=this.raycast(),e=A?A[0]:null;this.lastHit=e;let t=1;if(this.webXR.Rig&&(t/=this.webXR.Rig.scale.x),this.raycastLine){this.raycastLine.scale.z=t*(this.lastHit?.distance??9999);let i=this.raycastLine.material;e!=null?i.color=Ji.raycastColor:i.color=Ji.raycastNoHitColor}if(this._raycastHitPoint){if(this.lastHit!=null){this._raycastHitPoint.position.z=-1;let i=VA.clamp(this.lastHit.distance*.01*t,.015,.1);this._raycastHitPoint.scale.set(i,i,i)}this._raycastHitPoint.visible=this.lastHit!==null&&this.lastHit!==void 0}return e}onSelectStart(){!this.context.connection.allowEditing||(this.selectStartCallback=()=>this.onHandleSelectStart())}selectStartCallback=null;lastSelectStartObject=null;onHandleSelectStart(){this.selectStartCallback=null,this._selectionPressed=!0,this._selectionStartTime=this.context.time.time,this._selectionEndTime=1e3;let A=null,e=!1;if(this.isUsingHands?(A=this.overlap(),A.length<=0?(A=this.raycast(),e=!1):e=!0):A=this.raycast(),ku&&console.log("onHandleSelectStart","close grab? "+e,"intersections",A),A&&A.length>0)for(let t of A){let i=t.object;this.lastSelectStartObject=i;let g={selected:i,grab:i},o=Ji.eventSubs["select-start"];if(o&&o.length>0)for(let n of o)n(this,g);g.grab!==i&&ku&&console.log("Grabbed object changed","original",i,"new",g.grab),g.grab&&(this.grabbed=aI.TryTake(this,g.grab,t,e));break}else{let t=Ji.eventSubs["select-start"],i={selected:null,grab:null};if(t&&t.length>0)for(let g of t)g(this,i)}}_didNotEndSelection=!1;onSelectEnd(){if(this.isUsingHands&&this.handPointerModel.pinched){this._didNotEndSelection=!0;return}if(!this._selectionPressed)return;this.selectStartCallback=null,this._selectionPressed=!1,this._selectionEndTime=this.context.time.time;let A={grab:this.grabbed?.selected??this.lastSelectStartObject},e=Ji.eventSubs["select-end"];if(e&&e.length>0)for(let t of e)t(this,A);this.grabbed&&(this.grabbed.free(),this.grabbed=null)}testIsVisible(A){return!(!A||IA.isActiveInHierarchy(A)===!1||sn.isInteractable(A)===!1)}setControllerLayers(A,e){if(!!A&&(A.layers.set(e),A.children))for(let t of A.children)this.grabbed?.selected===t||this.grabbed?.selectedMesh===t||this.setControllerLayers(t,e)}getRay(){let A=new Lg;return A.origin.copy(ge(this.controller)),A.direction.set(0,0,-1).applyQuaternion(this.rayRotation),A}closeGrabBoundingBoxHelper;overlap(){let A=this.isUsingHands&&this.handPointerModel?this.handPointerModel.pointerObject:this.controllerGrip;if(ku&&(!this.closeGrabBoundingBoxHelper&&A&&(this.closeGrabBoundingBoxHelper=new LC(A,16776960),this.scene.add(this.closeGrabBoundingBoxHelper)),this.closeGrabBoundingBoxHelper&&A&&this.closeGrabBoundingBoxHelper.setFromObject(A)),!A)return new Array;let e=ge(A).clone();return this.context.physics.sphereOverlap(e,.02)}raycast(){let A=new vt;A.layerMask=new vg,A.layerMask.set(0),A.layerMask.disable(2),A.ray=this.getRay();let e=this.context.physics.raycast(A);for(let t=0;t<e.length;t++){let i=e[t],g=i.object;if(!this.testIsVisible(g)){e.splice(t,1),t--;continue}i.object=sn.getObject(g);break}return e}},it=Ji;uA(it,"Factory",new L8),uA(it,"raycastColor",new W(.9,.3,.3)),uA(it,"raycastNoHitColor",new W(.6,.6,.6)),uA(it,"geometry",new le().setFromPoints([new k(0,0,0),new k(0,0,-1)])),uA(it,"handModels",{}),uA(it,"eventSubs",{}),uA(it,"PreviousCameraFarDistance"),uA(it,"MovementSpeedFactor",1);var Xg=class{static AddEventListener(A,e){return Xg.Events[A]||(Xg.Events[A]=[]),Xg.Events[A].push(e),e}static RemoveEventListener(A,e){if(!e||!Xg.Events[A])return;let t=Xg.Events[A].indexOf(e);t>=0&&Xg.Events[A].splice(t,1)}static Register(A){this.Current.find(e=>e===A)||this.Current.push(A)}static Remove(A){let e=this.Current.indexOf(A);e>=0&&this.Current.splice(e,1)}static TryTake(A,e,t,i){let g=IA.getComponentInParent(e,ao);if(g)e=g.gameObject;else return ku&&console.warn("Prevented taking object that is not interactable",e),null;let o=e,n=IA.getComponentInParent(e,NI);n&&(n.requestOwnership(),o=n.gameObject);for(let s of this.Current)if(s.selected===o)return s.controller===A||(s.free(),s.Take(A,o,e,n,g,t,i)),s;let C=new Xg;return C.Take(A,o,e,n,g,t,i),C}sync=null;selected=null;selectedParent=null;selectedMesh=null;controller=null;grabTime=0;grabUUID="";isCloseGrab=!1;originalMaterial=null;usageMarker=null;rigidbodies=null;didReparent=!1;grabDistance=0;interactable=null;positionSource=null;Take(A,e,t,i,g,o,n){if(console.assert(e!==null,"Expected object to be taken but was",e),A.isUsingHands?this.positionSource=n?A.wrist:A.controller:this.positionSource=A.controller,!this.positionSource)return console.warn("No position source"),this;let C={controller:A,take:e,hit:t,sync:i,interactable:g};Xg.Events.WillTake?.forEach(Q=>Q(this,C));let s=t;s?.material&&(this.originalMaterial=s.material,Array.isArray(s.material)||(s.material=s.material.clone(),s.material&&s.material.emissive&&(s.material.emissive.b=.2))),this.selected=e,this.selectedParent||(this.selectedParent=e.parent),this.selectedMesh=s,this.controller=A,this.interactable=g,this.isCloseGrab=n,this.didReparent=!1,this.sync=i,this.grabTime=A.context.time.time,this.grabUUID=Date.now().toString(),this.usageMarker=IA.addNewComponent(this.selected,Bo),this.rigidbodies=IA.getComponentsInChildren(this.selected,je),ge(this.positionSource,this.lastControllerWorldPos);let r=()=>n?this.lastControllerWorldPos.clone():o.point.clone();this.grabDistance=r().distanceTo(this.lastControllerWorldPos),this.totalChangeAlongDirection=0,this.localPositionOffsetToGrab=this.selected.worldToLocal(r());let a=A.isUsingHands&&n?this.controller.getWristQuaternion().clone():A.rayRotation.clone();bt(this.selected,this.localQuaternionToGrab).premultiply(a.invert());let B=this.controller.webXR.Rig;return B&&this.rigPositionLastFrame.copy(ge(B)),Wt.Add(A.context,this.selected),Xg.Register(this),this.sync&&(this.sync.fastMode=!0),Xg.Events.DidTake?.forEach(Q=>Q(this,C)),this}free(){if(!this.selected)return;let A={controller:this.controller,take:this.selected,hit:this.selected,sync:this.sync,interactable:null};Xg.Events.WillFree?.forEach(i=>i(this,A)),Wt.Remove(this.controller.context,this.selected),Xg.Remove(this),this.sync&&(this.sync.fastMode=!1);let e=this.selectedMesh;e&&this.originalMaterial&&e.material&&(e.material=this.originalMaterial);let t=this.selected;if(this.didReparent&&t.parent){let i=this.selectedParent;i?i.attach(t):this.controller?.context.scene.attach(t)}if(this.usageMarker?.destroy(),this.controller&&(this.controller.grabbed=null),this.selected=null,this.selectedParent=null,this.selectedMesh=null,this.sync=null,this.rigidbodies)for(let i of this.rigidbodies)i.wakeUp(),i.setVelocity(i.smoothedVelocity);this.rigidbodies=null,this.localPositionOffsetToGrab=null,this.quaternionLerp=null,Xg.Events.DidFree?.forEach(i=>i(this,A))}grabPoint=new k;localPositionOffsetToGrab=null;localPositionOffsetToGrab_worldSpace=new k;localQuaternionToGrab=new KA(0,0,0,1);targetDir=null;quaternionLerp=null;controllerDir=new k;controllerWorldPos=new k;lastControllerWorldPos=new k;controllerPosDelta=new k;totalChangeAlongDirection=0;rigPositionLastFrame=new k;controllerMovementSinceLastFrame(){if(!this.positionSource||!this.controller)return 0;this.controllerDir.set(0,0,-1),this.controllerDir.applyQuaternion(this.controller.rayRotation),ge(this.positionSource,this.controllerWorldPos),this.controllerPosDelta.copy(this.controllerWorldPos),this.controllerPosDelta.sub(this.lastControllerWorldPos),this.lastControllerWorldPos.copy(this.controllerWorldPos);let A=this.controller.webXR.Rig;if(A){let t=ge(A),i=this.rigPositionLastFrame.sub(t);this.controllerPosDelta.add(i),this.rigPositionLastFrame.copy(t)}return this.controllerDir.dot(this.controllerPosDelta)}update(){if(this.rigidbodies)for(let A of this.rigidbodies)A.resetVelocities();if(this.sync&&this.controller&&this.controller.context.connection.isInRoom&&this.controller.context.time.time-this.grabTime>3&&this.sync.hasOwnership()===!1&&(console.log("no ownership, will leave",this.sync.guid),this.free()),!(this.interactable&&!this.interactable.canGrab)){if(!this.didReparent&&this.selected&&this.controller){let A=this.controller.webXR.Rig?.scale.x??1;this.totalChangeAlongDirection+=this.controllerMovementSinceLastFrame();let e=1;this.controller.type===0&&(e=Math.max(0,1+this.totalChangeAlongDirection*2/A),e=e*e*e),this.grabDistance/A<.8&&(e=1),this.targetDir||(this.targetDir=new k),this.targetDir.set(0,0,-this.grabDistance*e);let t=this.targetDir.applyQuaternion(this.controller.rayRotation).add(this.controllerWorldPos),i=this.controller.rayRotation.clone().multiplyQuaternions(this.controller.rayRotation,this.localQuaternionToGrab);this.quaternionLerp||(this.quaternionLerp=i.clone()),this.quaternionLerp.slerp(i,this.controller.useSmoothing?this.controller.context.time.deltaTime/.03:1),Og(this.selected,this.quaternionLerp),this.selected.updateWorldMatrix(!1,!1),this.grabPoint.copy(t),this.localPositionOffsetToGrab&&(this.localPositionOffsetToGrab_worldSpace.copy(this.localPositionOffsetToGrab),this.selected.localToWorld(this.localPositionOffsetToGrab_worldSpace).sub(ge(this.selected)),t.sub(this.localPositionOffsetToGrab_worldSpace)),at(this.selected,t)}if(this.rigidbodies!=null)for(let A of this.rigidbodies)A.wakeUp();Et.markDirty(this.selected,!0)}}},aI=Xg;uA(aI,"Events",{}),uA(aI,"Current",[]);var T8=sA("debugmouth"),qr=class extends EA{idle=[];talking=[];marker=null;voip=null;lastMouthChangeTime=0;mouthChangeLength=0;awake(){setTimeout(()=>{this.voip=IA.findObjectOfType(Zg,this.context),this.marker||(this.marker=IA.getComponentInParent(this.gameObject,Dt))},3e3)}update(){if(!this.voip||this.context.time.frameCount%10!==0)return;let A=this.marker?.connectionId??null;if(!A){T8&&(A=null);return}let e=this.voip.getFrequency(A)??0;this.updateLips(e)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;let e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;let e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(!!A){A!=this.idle?this.idle.map(t=>t.visible=!1):this.talking.map(t=>t.visible=!1);for(let t=0;t<A.length;t++){let i=A[t];i&&(i.visible=t===e)}}}};U([F(vA)],qr.prototype,"idle",2),U([F(vA)],qr.prototype,"talking",2);var Xc=class extends EA{voip=null;marker=null;_startPosition=null;awake(){this.voip=IA.findObjectOfType(Zg,this.context),this.marker=IA.getComponentInParent(this.gameObject,Dt)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;let A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let t=e/100;this.gameObject.position.y=this._startPosition.y+t*.07}};var Zn=class extends EA{eyes=[];lastBlinkTime=0;blinkLength=0;eyesOpen=!0;state=null;awake(){this.state=IA.getComponentInParent(this.gameObject,Ii)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(let e of this.eyes)e&&(e.visible=this.eyesOpen)}}};U([F(vA)],Zn.prototype,"eyes",2),U([F()],Zn.prototype,"lastBlinkTime",2),U([F()],Zn.prototype,"blinkLength",2),U([F()],Zn.prototype,"eyesOpen",2);var OU=class extends EA{head=null;eyes=null;target=null;brain=null;awake(){this.brain||(this.brain=IA.getComponentInParent(this.gameObject,As)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=IA.addNewComponent(this.gameObject,As)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}vec=new k;currentTargetPoint=new k;update(){let A=this.target;if(A&&this.head){let e=this.eyes;if(e){let t=ge(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);let i=ge(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;let o=OU.forward;if(o.set(0,0,1),o.applyQuaternion(bt(this.head)),o.dot(g)>.45)for(let C=0;C<e.length;C++)e[C].lookAt(this.currentTargetPoint)}}}},Xn=OU;uA(Xn,"forward",new k(0,0,1)),U([F(vA)],Xn.prototype,"head",2),U([F(vA)],Xn.prototype,"eyes",2),U([F(vA)],Xn.prototype,"target",2);var gs=class extends EA{length=1;depthTest=!0;isGizmo=!0;_axes=null;onEnable(){if(this.isGizmo&&!Nn)return;this._axes||(this._axes=new yI(this.length)),this.gameObject.add(this._axes);let A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){!this._axes||this.gameObject.remove(this._axes)}};U([F()],gs.prototype,"length",2),U([F()],gs.prototype,"depthTest",2),U([F()],gs.prototype,"isGizmo",2);var $c=class extends EA{from;to;hint;desiredDistance=1;onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let A=ge(this.to).clone(),e=ge(this.from).clone(),t=A.distanceTo(e),i=A.clone();i.sub(e);let g=e.clone();g.add(A),g.multiplyScalar(.5);let o=ge(this.hint).clone();o.sub(g);let n=new k;n.crossVectors(o,i),n.crossVectors(i,n),n.normalize();let C=t*.5,s=Math.max(this.desiredDistance,C),r=Math.sqrt(s*s-C*C),a=n.clone();a.multiplyScalar(r),a.add(g),at(this.gameObject,a);let B=g.clone();B.sub(n),this.gameObject.lookAt(B)}};var JI=class extends EA{get isCollider(){return!0}attachedRigidbody=null;isTrigger=!1;sharedMaterial;awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(je))}onDisable(){this.context.physics.removeBody(this)}};U([F(je)],JI.prototype,"attachedRigidbody",2),U([F()],JI.prototype,"isTrigger",2),U([F()],JI.prototype,"sharedMaterial",2);var br=class extends JI{radius=.5;center=new k(0,0,0);onEnable(){super.onEnable(),this.context.physics.addSphereCollider(this,this.center,this.radius)}};U([F()],br.prototype,"radius",2),U([F(k)],br.prototype,"center",2);var xr=class extends JI{size=new k(1,1,1);center=new k(0,0,0);onEnable(){super.onEnable(),this.context.physics.addBoxCollider(this,this.center,this.size)}};U([F(k)],xr.prototype,"size",2),U([F(k)],xr.prototype,"center",2);var LB=class extends JI{sharedMesh;convex=!1;onEnable(){super.onEnable(),this.sharedMesh?.isMesh||this.gameObject instanceof we&&(this.sharedMesh=this.gameObject),this.sharedMesh?.isMesh&&this.context.physics.addMeshCollider(this,this.sharedMesh,this.convex,Fi(this.gameObject))}};U([F()],LB.prototype,"convex",2);var co=class extends JI{center=new k(0,0,0);radius=.5;height=2;onEnable(){super.onEnable(),this.context.physics.addCapsuleCollider(this,this.center,this.height,this.radius)}};U([F(k)],co.prototype,"center",2),U([F()],co.prototype,"radius",2),U([F()],co.prototype,"height",2);var H8=sA("gizmos"),Y8=sA("debugboxhelper"),lo=class extends EA{box=null;_lastMatrixUpdateFrame=-1;isInBox(A,e){if(!A)return;if(this.box||(this.box=new Ot),A.type==="Mesh")lo.testBox.setFromObject(A);else if(A.type==="Group"){if(lo.testBox.makeEmpty(),A.children.length>0)for(let i=0;i<A.children.length;i++)A.children[i].type==="Mesh"&&lo.testBox.expandByObject(A)}else{let i=ge(A,lo._position),g=Fi(A,lo._size);e!==void 0&&g.multiplyScalar(e),lo.testBox.setFromCenterAndSize(i,g)}this.updateBox();let t=this.box?.intersectsBox(lo.testBox);return t&&Y8&&GI.DrawBox3(lo.testBox,16711680,5),t}intersects(A){return A?this.updateBox(!1).intersectsBox(A):!1}updateBox(A=!1){if(this.box||(this.box=new Ot),A||this.context.time.frameCount!=this._lastMatrixUpdateFrame){let e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;let t=e,i=ge(this.gameObject,lo._position,t),g=Fi(this.gameObject,lo._size);this.box.setFromCenterAndSize(i,g)}return this.box}_helper=null;_color=null;awake(){this._helper=null,this._color=null,this.box=null}showHelper(A=null,e=!1){if(!(!H8&&!e)){if(this._helper){A&&this._color?.set(A),this.gameObject.add(this._helper);return}this._helper=Lw(A),this.gameObject.add(this._helper)}}},ig=lo;uA(ig,"testBox",new Ot),uA(ig,"_position",new k),uA(ig,"_size",new k(.01,.01,.01));function PU(I){let A=I[rI];return A||(I.parent?PU(I.parent):null)}function Al(I,A){if(!I)return;let e=I.material;e?.isMaterial===!0&&(e.depthTest=!A.renderOnTop,e.side=A.doubleSided??!0?Ei:bg,e.depthWrite=A.depthWrite??!1,e.shadowSide=A.doubleSided?Ei:bg,I.castShadow=A.castShadows?A.castShadows:!1,I.receiveShadow=A.receiveShadows?A.receiveShadows:!1);for(let t of I.children)Al(t,A)}function Vy(I,A,e){I[A]===void 0&&console.warn("Field",A,"is undefined on",I);let t=Proxy.revocable(I[A],{set(o,n,C,s){let r=o[n],a=Reflect.set(o,n,C,s);return e(C,r),a}}),i=t.revoke,g=I[A];return t.revoke=()=>{I[A]=g,i()},I[A]=t.proxy,t}var ST=Symbol("Scheduled action");function mT(I,A,e=3){let t=I[ST];t||(t=I[ST]={});let i=A.name;t[e]||(t[e]={});let g=t[e];if(g[i])return;function*n(){A?.call(I),g[i]=null}let C=I.startCoroutine(n(),e);g[i]=C}var MT=sA("debugui"),el=class{width;height},vB=class{x;y;width;height},BI=class extends tg{offset=.01;get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}_anchoredPosition;get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new k),this._anchoredPosition}rect;sizeDelta;anchoredPosition3D;pivot;lastMatrix;rectBlock;_transformNeedsUpdate=!1;awake(){super.awake(),this.lastMatrix=new zA,this.rectBlock=new vA,this.rectBlock.position.z=.1,this.rectBlock.name=this.name,this._anchoredPosition||(this._anchoredPosition=new k),Vy(this,"_anchoredPosition",()=>{this._transformNeedsUpdate=!0})}onEnable(){super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0}onDisable(){super.onDisable(),this.removeShadowComponent()}applyTransform(){let A=this.shadowComponent;!A||(this._transformNeedsUpdate=!1,this.isRoot()?A.rotation.y=Math.PI:(A.position.copy(this.gameObject.position),A.position.x*=-1,A.position.z*=-1,A.position.z-=this.offset,A.quaternion.copy(this.gameObject.quaternion),A.rotation.x*=-1,A.rotation.z*=-1,A.scale.copy(this.gameObject.scale)),this.applyAnchoring(A.position),this.lastMatrix.copy(this.gameObject.matrix))}markDirty(){this._transformNeedsUpdate=!0}onBeforeRender(){(this._transformNeedsUpdate||this.lastMatrix.equals(this.gameObject.matrix)===!1)&&(MT&&console.log("updating",this.name),this.applyTransform()),wg.ensureUpdateMeshUI(Wc,this.context)}applyAnchoring(A){if(this.pivot&&this.sizeDelta){let e=this.pivot.x*2-1,t=this.pivot.y*2-1;t-=this.anchoredPosition.y*.05;let i=this.sizeDelta.x*e,g=this.sizeDelta.y*t;A.x-=i*.5,A.y-=g*.5}}getBasicOptions(){let A={width:this.rect.width,height:this.rect.height,offset:this.offset,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}_createdBlocks=[];createNewBlock(A){A={...this.getBasicOptions(),...A},MT&&console.log(this.name,A);let e=new mu(A);return this._createdBlocks.push(e),e}};U([F(vB)],BI.prototype,"rect",2),U([F(SA)],BI.prototype,"sizeDelta",2),U([F(k)],BI.prototype,"anchoredPosition3D",2),U([F(SA)],BI.prototype,"pivot",2);var Ru=class extends tg{get isGraphic(){return!0}get color(){return this._color||(this._color=new ve(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new ve(1,1,1,1)),this._color.copy(A))}onColorChanged(){let A=this.color;this.setOptions({backgroundColor:A,backgroundOpacity:A.alpha,borderOpacity:A.alpha})}get m_Color(){return this._color}raycastTarget=!0;uiObject=null;_color=null;_rect=null;get rectTransform(){return this._rect||(this._rect=IA.getComponent(this.gameObject,BI)),this._rect}setState(A){this.makePanel(),this.uiObject&&this.uiObject.setState(A)}setupState(A){this.makePanel(),this.uiObject&&this.uiObject.setupState(A)}setOptions(A){this.makePanel(),this.uiObject&&(this.uiObject.set(A),(A.backgroundColor!==void 0||A.backgroundOpacity!==void 0)&&this.uiObject.updateBackgroundMaterial?.call(this.uiObject))}awake(){super.awake(),this.makePanel(),Vy(this,"_color",()=>mT(this,this.onColorChanged))}onEnable(){super.onEnable(),this.uiObject&&(this.rectTransform.shadowComponent?.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}_currentlyCreatingPanel=!1;makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;let A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:1};this.onBeforeCreate(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}async setTexture(A){if(!!A&&(this.setOptions({backgroundOpacity:0}),A)){if(A.encoding===me)if(Ru.textureCache.has(A))A=Ru.textureCache.get(A);else{let e=A.clone();e.encoding=cg,Ru.textureCache.set(A,e),A=e}this.setOptions({backgroundTexture:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},QI=Ru;uA(QI,"textureCache",new Map),U([F(ve)],QI.prototype,"color",1),U([F()],QI.prototype,"raycastTarget",2);var Is=class extends QI{_flippedObject=!1;onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}};var zy=class{texture;rect};U([F(Ye)],zy.prototype,"texture",2);var os=class extends Is{get sprite(){return this._sprite}set sprite(A){this._sprite!==A&&(this._sprite=A,this.onAfterCreated())}_sprite;isBuiltinSprite(){switch(this.sprite?.texture?.name){case"InputFieldBackground":case"UISprite":case"Background":return!0}return this.sprite?.texture?.image?.width===32&&this.sprite?.texture?.image?.height===32}onBeforeCreate(A){this.isBuiltinSprite()&&(A.borderRadius=5,A.borderColor=new W(.4,.4,.4),A.borderOpacity=this.color.alpha,A.borderWidth=.3)}onAfterCreated(){!this.__didAwake||(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture(this.sprite?.texture))}};U([F(zy)],os.prototype,"sprite",1);var TB=class extends Is{get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}_mainTexture;onAfterCreated(){!this.__didAwake||(super.onAfterCreated(),this.setTexture(this.mainTexture))}};U([F(Ye)],TB.prototype,"mainTexture",1);var tl=sA("debugbutton");var ns=class{colorMultiplier;disabledColor;fadeDuration;highlightedColor;normalColor;pressedColor;selectedColor};U([F()],ns.prototype,"colorMultiplier",2),U([F(ve)],ns.prototype,"disabledColor",2),U([F()],ns.prototype,"fadeDuration",2),U([F(ve)],ns.prototype,"highlightedColor",2),U([F(ve)],ns.prototype,"normalColor",2),U([F(ve)],ns.prototype,"pressedColor",2),U([F(ve)],ns.prototype,"selectedColor",2);var ho=class extends EA{onClick;_isHovered=!1;onPointerEnter(A){tl&&console.log("Button Enter",this.animationTriggers?.highlightedTrigger,this.animator),this._isHovered=!0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&this._image?.setState("hovered"),this.context.input.setCursorPointer()}onPointerExit(){tl&&console.log("Button Exit",this.animationTriggers?.highlightedTrigger,this.animator),this._isHovered=!1,this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState("normal"),this.context.input.setCursorNormal()}onPointerDown(A){tl&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&this._image?.setState("pressed")}onPointerUp(A){tl&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.transition==3&&this.animationTriggers&&this.animator?this.animator.SetTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState(this._isHovered?"hovered":"normal")}onPointerClick(A){tl&&console.trace("Button Click",this.onClick),this.onClick?.invoke()}colors;transition;animationTriggers;animator;set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}_interactable=!0;set_interactable(A){this.interactable=A}awake(){super.awake(),tl&&console.log(this),this.init()}start(){this._image?.setInteractable(this.interactable)}onEnable(){super.onEnable()}_requestedAnimatorTrigger;*setAnimatorTriggerAtEndOfFrame(A){this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&this.animator?.SetTrigger(A)}_isInit=!1;_image;init(){this._isInit||(this._isInit=!0,this._image=IA.getComponent(this.gameObject,os),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){A.setInteractable(this.interactable);let e=this.getFinalColor(A.color,this.colors?.normalColor),t={state:"normal",attributes:{backgroundColor:e,backgroundOpacity:e.alpha}};A.setupState(t);let i=this.getFinalColor(A.color,this.colors?.highlightedColor),g={state:"hovered",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};A.setupState(g);let o=this.getFinalColor(A.color,this.colors?.pressedColor),n={state:"pressed",attributes:{backgroundColor:o,backgroundOpacity:o.alpha}};A.setupState(n);let C=this.getFinalColor(A.color,this.colors?.selectedColor),s={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};A.setupState(s);let r=this.getFinalColor(A.color,this.colors?.disabledColor),a={state:"disabled",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};A.setupState(a)}getFinalColor(A,e){return e?A.clone().multiply(e):A.clone()}};U([F(Nt)],ho.prototype,"onClick",2),U([F()],ho.prototype,"colors",2),U([F()],ho.prototype,"transition",2),U([F()],ho.prototype,"animationTriggers",2),U([F(ui)],ho.prototype,"animator",2),U([F()],ho.prototype,"interactable",1);var WU=class extends is{set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop}_renderOnTop=!1;set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}_depthWrite=!1;set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}_doubleSided=!0;set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}_castShadows=!0;set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}_receiveShadows=!0;get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}_renderMode=-1;_rootCanvas;set rootCanvas(A){this._rootCanvas instanceof WU||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}_scaleFactor=1;get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){this.shadowComponent=this.gameObject,super.awake()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this.onRenderSettingsChanged()}previousAspect=-1;onBeforeRender(){this.isScreenSpace&&this.context.mainCameraComponent&&this.context.mainCameraComponent.aspect!==this.previousAspect&&(this.previousAspect=this.context.mainCameraComponent.aspect,this.updateRenderMode())}_updateRenderSettingsRoutine;onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),3))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.updateRenderMode(),Al(this.shadowComponent,this);for(let A of IA.getComponentsInChildren(this.gameObject,tg))Al(A.shadowComponent,this)}}_activeRenderMode=-1;get isScreenSpace(){return this._activeRenderMode===1||this._activeRenderMode===0}updateRenderMode(){if(this.renderMode!==this._activeRenderMode)switch(this.renderMode){case 0:case 1:let A=this.context.mainCameraComponent;if(!A)return;let e=this.gameObject;A.gameObject?.add(e);let i=A.farClipPlane;e.position.x=0,e.position.y=0,e.position.z=-i;let g=Math.tan(VA.toRadians(A.fieldOfView)*i)*(A.aspect*1.333333),o=g*(this.context.domHeight/this.context.domWidth);e.scale.x=-g,e.scale.y=o;break;case 2:break}}},gg=WU;U([F()],gg.prototype,"renderOnTop",1),U([F()],gg.prototype,"depthWrite",1),U([F()],gg.prototype,"doubleSided",1),U([F()],gg.prototype,"castShadows",1),U([F()],gg.prototype,"receiveShadows",1),U([F()],gg.prototype,"renderMode",1),U([F(gg)],gg.prototype,"rootCanvas",1),U([F()],gg.prototype,"scaleFactor",1);var Cs=class extends EA{get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}_alpha=1;interactable=!0;blocksRaycasts=!0;_isDirty=!1;markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),3))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}_buffer=[];applyChangesNow(){for(let A of IA.getComponentsInChildren(this.gameObject,QI,this._buffer)){let e=A.color;e.alpha=this._alpha,A.color=e}}};U([F()],Cs.prototype,"alpha",1),U([F()],Cs.prototype,"interactable",2),U([F()],Cs.prototype,"blocksRaycasts",2);var il=class extends ei{};var zU=class extends Kn{constructor(){super([W,ve])}onDeserialize(A){if(A!=null)return A.a!==void 0?new ve(A.r,A.g,A.b,A.a):A.alpha!==void 0?new ve(A.r,A.g,A.b,A.alpha):new W(A.r,A.g,A.b)}onSerialize(A){if(A!=null)return A.a!==void 0?{r:A.r,g:A.g,b:A.b,a:A.a}:{r:A.r,g:A.g,b:A.b}}},UEA=new zU,jU=class extends Kn{constructor(){super(vA)}onSerialize(A,e){if(e.objectToNode!==void 0&&A.uuid){let t=e.objectToNode[A.uuid];return qt&&console.log(t,A.name,A.uuid),{node:t}}}onDeserialize(A,e){if(A){if(A.node!==void 0&&e.nodeToObject){let t=e.nodeToObject[A.node];return qt&&console.log("Deserialized object reference?",A,t,e?.nodeToObject),t||console.warn("Did not find node: "+A.node,e.nodeToObject,e.object),t}else if(A.guid){if(!e.context){console.error("Missing context");return}let t,i=e.gltf?.scene;return i&&(t=IA.findByGuid(A.guid,i)),t||(t=IA.findByGuid(A.guid,e.context.scene)),t?qt&&console.log("Deserialized object reference?",A,t,e?.nodeToObject):((KD()||qt)&&console.warn("Could not resolve object reference",e.path,A,e.target,e.context.scene),A.could_not_resolve=!0),t}}}},_8=new jU,ZU=class extends Kn{constructor(){super([RI,EA])}onSerialize(A,e){if(A?.guid)return{guid:A.guid}}onDeserialize(A,e){if(A?.guid){qt&&console.log(A.guid,e.root,e.object,e.target);let t=this.findObjectForGuid(A.guid,e.root);if(t||e.context&&(t=this.findObjectForGuid(A.guid,e.context?.scene),t))return t;(KD()||qt)&&console.warn("Could not resolve component reference",e.path,A,e.target),A.could_not_resolve=!0;return}}findObjectForGuid(A,e){if(e.guid===A)return e;let t=IA.foreachComponent(e,i=>{if(i.guid===A)return i},!1);if(t!==void 0)return t;for(let i=0;i<e.children.length;i++){let g=e.children[i],o=this.findObjectForGuid(A,g);if(o)return o}}},VU=new ZU,XU=class extends Kn{constructor(){super([Nt])}onSerialize(A,e){console.log("TODO: SERIALIZE EVENT")}onDeserialize(A,e){if(typeof A=="function")return new Nt([new gn(A,!0)]);if(A&&A.type==="EventList"){qt&&console.log("DESERIALIZE EVENT",A);let t=new Array;if(A.calls&&Array.isArray(A.calls))for(let o of A.calls){qt&&console.log(o);let n=VU.findObjectForGuid(o.target,e.root);!n&&e.context?.scene&&(n=VU.findObjectForGuid(o.target,e.context?.scene));let C=o.method?.length>0;if(n&&C){let B=()=>console.warn(`Could not find method ${o.method} on object ${n.name}`,n,typeof n[o.method]);if(typeof n[o.method]!="function"){let Q=!1;o.method.startsWith("set_")&&o.method.length>4&&(o.method=o.method.substring(4),n[o.method]!==void 0&&(Q=!0)),!Q&&(KD()||qt)&&B()}}let s,r=o.argument;o.argument!==void 0?(typeof r=="object"&&(r=_8.onDeserialize(o.argument,e),r||(r=VU.onDeserialize(o.argument,e))),s=new gn(C?(...B)=>a(...B):void 0,o.enabled)):s=new gn(C?(...B)=>a(...B):void 0,o.enabled);let a=(...B)=>{let Q=n[o.method];typeof Q=="function"?r!==void 0?Q?.call(n,r):Q?.call(n,...B):n[o.method]=r};if(s.method||(s.__debuginfo=e.object?.name),!n||!s.method){let B=e.object?"Current object: "+e.object.name+", "+e.object.guid:null;n?console.warn('EventList method not found: "'+o.method+'" on',n):console.warn("EventList is missing target - will be ignored",o.target,B,A)}else t.push(s)}let i=new Nt(t);qt&&console.log(i);let g=e.target;return g!==void 0&&e.path!==void 0&&i.setEventTarget(e.path,g),i}}},FEA=new XU,$U=class extends Kn{constructor(){super([il,ei])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof Ye&&e.type===il){let t=A,i=new il(t.image.width,t.image.height);return i.texture=t,i}}};new $U;var $n=class extends EA{center=new k(0,0,0);radius=.5;height=2;_rigidbody=null;get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(je),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(je)),this.rigidbody)}onEnable(){let A=this.rigidbody,e=this.gameObject.getComponent(co);e||(e=this.gameObject.addNewComponent(co)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}_activeGroundCollisions=new Set;onCollisionEnter(A){for(let e of A.contacts)if(e.normal.y>.1){this._activeGroundCollisions.add(A);break}}onCollisionExit(A){this._activeGroundCollisions.delete(A)}get isGrounded(){return this._activeGroundCollisions.size>0}};U([F(k)],$n.prototype,"center",2),U([F()],$n.prototype,"radius",2),U([F()],$n.prototype,"height",2);var rn=class extends EA{controller;movementSpeed=2;rotationSpeed=2;jumpForce=1;animator;lookForward=!0;_currentSpeed=new k(0,0,0);_currentAngularSpeed=new k(0,0,0);_temp=new k(0,0,0);_jumpCount=0;_currentRotation;awake(){this._currentRotation=new KA}update(){this.controller?.isGrounded&&(this._jumpCount=0,this.animator?.SetBool("doubleJump",!1));let A=this.context.input.isKeyPressed("w"),e=this.context.input.isKeyPressed("s"),t=this.context.input.isKeyPressed("a"),i=this.context.input.isKeyPressed("d"),g=this.context.input.isKeyDown(" "),o=A?1:0+e?-1:0;this._currentSpeed.z+=o*this.movementSpeed*this.context.time.deltaTime,this.animator?.SetBool("running",o!=0),this.animator?.SetBool("jumping",this.controller?.isGrounded===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);let n=t?1:0+i?-1:0;if(this._currentAngularSpeed.y+=VA.toRadians(n*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){let C=this.context.mainCameraComponent.forward;C.y=0,C.normalize(),this._currentRotation.setFromUnitVectors(new k(0,0,1),C),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let C=this.controller?.isGrounded;if(!this.controller?.isGrounded&&this._jumpCount===1&&(C=!0,this.animator?.SetBool("doubleJump",!0)),C){this._jumpCount+=1;let s=this.controller.rigidbody,r=this._jumpCount===2?2:1;s.applyImpulse(new k(0,1,0).multiplyScalar(this.jumpForce*r))}}if(this.controller){let C=this.controller?.rigidbody.getVelocity().y;if(C<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Lg),this._raycastOptions.ray.origin.copy(ge(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);let s=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);let r=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(s),(r.length&&r[0].distance>2||C<-10)&&this.animator?.SetBool("falling",!0)}else this.animator?.SetBool("falling",!1)}}_raycastOptions=new vt};U([F($n)],rn.prototype,"controller",2),U([F()],rn.prototype,"movementSpeed",2),U([F()],rn.prototype,"rotationSpeed",2),U([F()],rn.prototype,"jumpForce",2),U([F(ui)],rn.prototype,"animator",2);var jy=sA("debugvolume"),kT=(t=>(t[t.None=0]="None",t[t.Neutral=1]="Neutral",t[t.ACES=2]="ACES",t))(kT||{}),gl=class{overrideState=!1;value=0},AC=class{active=!1;parameters},vr=class extends AC{mode;get isToneMapping(){return!0}},Tr=class extends AC{postExposure};function P8(I){return"mode"in I?vr:"postExposure"in I?Tr:AC}var GT=Symbol("volumeprofile"),Lr=class{components;apply(A){this.onUpdate(A,!1)}unapply(A){this.onUpdate(A,!0)}onUpdate(A,e){if(!this.components)return;let t=A.renderer,g=t[GT]!==void 0;if(e){if(!g)return}else t[GT]=this;for(let o of this.components)if(o instanceof vr){let n=o;if(!o.active||e){A.renderer.toneMapping=jE;continue}jy&&console.log("VOLUME:",kT[n.mode?.value??0]);let C=n.mode;switch((C?.overrideState?C?.value:0)??0){case 0:A.renderer.toneMapping=jE;break;case 1:A.renderer.toneMapping=MD;break;case 2:A.renderer.toneMapping=md;break}}else if(o instanceof Tr){let n=o;jy&&console.log(n.postExposure);let C=1;n.postExposure&&(C=Math.pow(2,n.postExposure.value)),A.renderer.toneMapping,md;let s=n.postExposure?.overrideState&&!e;A.renderer.toneMappingExposure=s?C:1,A.renderer.toneMapping||(A.renderer.toneMapping=jE)}}};U([F([I=>P8(I),AC])],Lr.prototype,"components",2);var HB=class extends EA{sharedProfile;awake(){jy&&(console.log(this),console.log("Press P to toggle post processing"),window.addEventListener("keydown",A=>{A.key==="p"&&(console.log("Toggle volume: "+this.name,!this.enabled),this.enabled=!this.enabled)}))}onEnable(){jy&&console.log("APPLY VOLUME",this),this.sharedProfile?.apply(this.context)}onDisable(){this.sharedProfile?.unapply(this.context)}};U([F(Lr)],HB.prototype,"sharedProfile",2);var ecA=.5*(Math.sqrt(3)-1),tcA=(3-Math.sqrt(3))/6,icA=1/3,gcA=1/6,W8=(Math.sqrt(5)-1)/4,Ig=(5-Math.sqrt(5))/20,Zy=I=>Math.floor(I)|0;var Xy=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function RT(I=Math.random){let A=V8(I),e=new Float64Array(A).map(o=>Xy[o%32*4]),t=new Float64Array(A).map(o=>Xy[o%32*4+1]),i=new Float64Array(A).map(o=>Xy[o%32*4+2]),g=new Float64Array(A).map(o=>Xy[o%32*4+3]);return function(n,C,s,r){let a,B,Q,l,E,c=(n+C+s+r)*W8,d=Zy(n+c),p=Zy(C+c),h=Zy(s+c),u=Zy(r+c),f=(d+p+h+u)*Ig,w=d-f,S=p-f,D=h-f,y=u-f,M=n-w,N=C-S,L=s-D,x=r-y,q=0,H=0,V=0,gA=0;M>N?q++:H++,M>L?q++:V++,M>x?q++:gA++,N>L?H++:V++,N>x?H++:gA++,L>x?V++:gA++;let $=q>=3?1:0,tA=H>=3?1:0,oA=V>=3?1:0,mA=gA>=3?1:0,Y=q>=2?1:0,iA=H>=2?1:0,lA=V>=2?1:0,dA=gA>=2?1:0,v=q>=1?1:0,UA=H>=1?1:0,GA=V>=1?1:0,NA=gA>=1?1:0,hA=M-$+Ig,PA=N-tA+Ig,AA=L-oA+Ig,X=x-mA+Ig,QA=M-Y+2*Ig,RA=N-iA+2*Ig,cA=L-lA+2*Ig,OA=x-dA+2*Ig,LA=M-v+3*Ig,JA=N-UA+3*Ig,Be=L-GA+3*Ig,oe=x-NA+3*Ig,R=M-1+4*Ig,m=N-1+4*Ig,O=L-1+4*Ig,CA=x-1+4*Ig,BA=d&255,fA=p&255,YA=h&255,DA=u&255,j=.6-M*M-N*N-L*L-x*x;if(j<0)a=0;else{let MA=BA+A[fA+A[YA+A[DA]]];j*=j,a=j*j*(e[MA]*M+t[MA]*N+i[MA]*L+g[MA]*x)}let qA=.6-hA*hA-PA*PA-AA*AA-X*X;if(qA<0)B=0;else{let MA=BA+$+A[fA+tA+A[YA+oA+A[DA+mA]]];qA*=qA,B=qA*qA*(e[MA]*hA+t[MA]*PA+i[MA]*AA+g[MA]*X)}let TA=.6-QA*QA-RA*RA-cA*cA-OA*OA;if(TA<0)Q=0;else{let MA=BA+Y+A[fA+iA+A[YA+lA+A[DA+dA]]];TA*=TA,Q=TA*TA*(e[MA]*QA+t[MA]*RA+i[MA]*cA+g[MA]*OA)}let FA=.6-LA*LA-JA*JA-Be*Be-oe*oe;if(FA<0)l=0;else{let MA=BA+v+A[fA+UA+A[YA+GA+A[DA+NA]]];FA*=FA,l=FA*FA*(e[MA]*LA+t[MA]*JA+i[MA]*Be+g[MA]*oe)}let bA=.6-R*R-m*m-O*O-CA*CA;if(bA<0)E=0;else{let MA=BA+1+A[fA+1+A[YA+1+A[DA+1]]];bA*=bA,E=bA*bA*(e[MA]*R+t[MA]*m+i[MA]*O+g[MA]*CA)}return 27*(a+B+Q+l+E)}}function V8(I){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let i=t+~~(I()*(256-t)),g=e[t];e[t]=e[i],e[i]=g}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var z8=sA("debugparticles");var Bn=class{alphaKeys;colorKeys;get duration(){return 1}evaluate(A,e){let t,i=0,g=null,o=0;for(let n=0;n<this.alphaKeys.length;n++){let C=this.alphaKeys[n];(C.time<A||!t)&&(t=C,i=n)}for(let n=0;n<this.colorKeys.length;n++){let C=this.colorKeys[n];(C.time<A||!g)&&(g=C,o=n)}if(g)if(o+1<this.colorKeys.length){let C=this.colorKeys[o+1],s=VA.remap(A,g.time,C.time,0,1);e.r=VA.lerp(g.color.r,C.color.r,s),e.g=VA.lerp(g.color.g,C.color.g,s),e.b=VA.lerp(g.color.b,C.color.b,s)}else e.r=g.color.r,e.g=g.color.g,e.b=g.color.b;if(t)if(i+1<this.alphaKeys.length){let C=this.alphaKeys[i+1],s=VA.remap(A,t.time,C.time,0,1);e.alpha=VA.lerp(t.alpha,C.alpha,s)}else e.alpha=t.alpha;return e}};U([F()],Bn.prototype,"alphaKeys",2),U([F()],Bn.prototype,"colorKeys",2);var UT=(f=>(f[f.Sphere=0]="Sphere",f[f.SphereShell=1]="SphereShell",f[f.Hemisphere=2]="Hemisphere",f[f.HemisphereShell=3]="HemisphereShell",f[f.Cone=4]="Cone",f[f.Box=5]="Box",f[f.Mesh=6]="Mesh",f[f.ConeShell=7]="ConeShell",f[f.ConeVolume=8]="ConeVolume",f[f.ConeVolumeShell=9]="ConeVolumeShell",f[f.Circle=10]="Circle",f[f.CircleEdge=11]="CircleEdge",f[f.SingleSidedEdge=12]="SingleSidedEdge",f[f.MeshRenderer=13]="MeshRenderer",f[f.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",f[f.BoxShell=15]="BoxShell",f[f.BoxEdge=16]="BoxEdge",f[f.Donut=17]="Donut",f[f.Rectangle=18]="Rectangle",f[f.Sprite=19]="Sprite",f[f.SpriteRenderer=20]="SpriteRenderer",f))(UT||{});var se=class{mode;constant;constantMin;constantMax;curve;curveMin;curveMax;curveMultiplier;evaluate(A,e){let t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=VA.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:let i=A*this.curveMin.duration,g=A*this.curveMax.duration;return VA.lerp(this.curveMin.evaluate(i),this.curveMax.evaluate(g),t%1)*this.curveMultiplier;case 3:return VA.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}};U([F()],se.prototype,"mode",2),U([F()],se.prototype,"constant",2),U([F()],se.prototype,"constantMin",2),U([F()],se.prototype,"constantMax",2),U([F(en)],se.prototype,"curve",2),U([F(en)],se.prototype,"curveMin",2),U([F(en)],se.prototype,"curveMax",2),U([F()],se.prototype,"curveMultiplier",2);var uo=class{mode;color;colorMin;colorMax;gradient;gradientMin;gradientMax;evaluate(A,e){let t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(A,uo._temp),uo._temp;case 2:return uo._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(A,uo._temp),this.gradientMax.evaluate(A,uo._temp2),uo._temp.lerp(uo._temp2,t)}return uo._temp.set(16711935),uo._temp.alpha=1,uo._temp}},Di=uo;uA(Di,"_temp",new ve(0,0,0,1)),uA(Di,"_temp2",new ve(0,0,0,1)),U([F(ve)],Di.prototype,"color",2),U([F(ve)],Di.prototype,"colorMin",2),U([F(ve)],Di.prototype,"colorMax",2),U([F(Bn)],Di.prototype,"gradient",2),U([F(Bn)],Di.prototype,"gradientMin",2),U([F(Bn)],Di.prototype,"gradientMax",2);var Vt=class{cullingMode;duration;emitterVelocityMode;flipRotation;gravityModifier;gravityModifierMultiplier;loop;maxParticles;playOnAwake;prewarm;ringBufferLoopRange;ringBufferMode;scalingMode;simulationSpace;simulationSpeed;startColor;startDelay;startDelayMultiplier;startLifetime;startLifetimeMultiplier;startRotation;startRotationMultiplier;startRotation3D;startRotationX;startRotationXMultiplier;startRotationY;startRotationYMultiplier;startRotationZ;startRotationZMultiplier;startSize;startSize3D;startSizeMultiplier;startSizeX;startSizeXMultiplier;startSizeY;startSizeYMultiplier;startSizeZ;startSizeZMultiplier;startSpeed;startSpeedMultiplier;stopAction;useUnscaledTime};U([F(se)],Vt.prototype,"gravityModifier",2),U([F(Di)],Vt.prototype,"startColor",2),U([F(se)],Vt.prototype,"startDelay",2),U([F(se)],Vt.prototype,"startLifetime",2),U([F(se)],Vt.prototype,"startRotation",2),U([F(se)],Vt.prototype,"startRotationX",2),U([F(se)],Vt.prototype,"startRotationY",2),U([F(se)],Vt.prototype,"startRotationZ",2),U([F(se)],Vt.prototype,"startSize",2),U([F(se)],Vt.prototype,"startSizeX",2),U([F(se)],Vt.prototype,"startSizeY",2),U([F(se)],Vt.prototype,"startSizeZ",2),U([F(se)],Vt.prototype,"startSpeed",2);var rs=class{cycleCount;maxCount;minCount;probability;repeatInterval;time;count;_performed=0;reset(){this._performed=0}run(A){if(A<=this.time)return this.reset(),0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){let t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=VA.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:let i=Math.random();e=VA.lerp(this.count.curveMin.evaluate(i),this.count.curveMax.evaluate(i),Math.random());break}}return e}},EI=class{enabled;get burstCount(){return this.bursts?.length??0}bursts;rateOverTime;rateOverTimeMultiplier;rateOverDistance;rateOverDistanceMultiplier;system;reset(){this.bursts?.forEach(A=>A.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){let t=this.bursts[e];t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}};U([F()],EI.prototype,"enabled",2),U([F()],EI.prototype,"bursts",2),U([F(se)],EI.prototype,"rateOverTime",2),U([F()],EI.prototype,"rateOverTimeMultiplier",2),U([F(se)],EI.prototype,"rateOverDistance",2),U([F()],EI.prototype,"rateOverDistanceMultiplier",2);var ss=class{enabled;color};U([F(Di)],ss.prototype,"color",2);var po=class{enabled;separateAxes;size;sizeMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;_time=0;_temp=new k;evaluate(A,e,t){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{let i=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=i}return e}};U([F(se)],po.prototype,"size",2),U([F(se)],po.prototype,"x",2),U([F(se)],po.prototype,"y",2),U([F(se)],po.prototype,"z",2);var Il=class{get type(){return UT[this.shapeType]}initialize(A){this.getPosition(),A.position.copy(this._vector)}toJSON(){return this}clone(){return new Il}shapeType=5;enabled=!0;alignToDirection=!1;angle=0;arc=360;arcSpread;arcSpeedMultiplier;arcMode;boxThickness;position;rotation;_rotation=new $e;scale;radius;radiusThickness;sphericalDirectionAmount;randomDirectionAmount;randomPositionAmount;system;_space;_worldSpaceMatrix=new zA;_worldSpaceMatrixInverse=new zA;update(A,e,t,i){this.system=A,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}updateRotation(){let A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=VA.toRadians(this.rotation.x),this._rotation.y=-VA.toRadians(this.rotation.y),this._rotation.z=-VA.toRadians(this.rotation.z)),A}_vector=new k(0,0,0);_temp=new k(0,0,0);get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);let A=this._temp.copy(this.position),e=this._space===1;e&&A.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(A);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector,this.scale);break;case 10:this._temp.copy(this.scale),this._temp.z=0,this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector,this._temp);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.updateRotation()&&this._vector.applyEuler(this._rotation),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos))}_dir=new k;getDirection(A){if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:let e=A.x,t=A.y,i=A.z;this._dir.set(e,t,i),this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyMatrix4(this._worldSpaceMatrixInverse),this.updateRotation()&&this._dir.applyEuler(this._rotation),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),z8&&(GI.DrawSphere(A,.01,8925952,.5,!0),GI.DrawDirection(A,this._dir,8925952,.5,!0)),this._dir}randomizePosition(A,e){if(e<=0)return;let t=Il._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,A.add(t)}randomizeDirection(A,e){if(e===0)return;let t=Il._randomQuat,i=Il._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),A.applyQuaternion(t)}spherizeDirection(A,e){if(e===0)return;let t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(t),o=Math.sin(i)*Math.sin(t),n=Math.cos(i),C=new k(g,o,n);A.lerp(C,e)}randomSpherePoint(A,e,t,i,g,o){let n=Math.random(),C=Math.random(),s=2*Math.PI*n*(i/360),r=Math.acos(2*C-1),a=VA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,B=A.x+o.x*(-a*Math.sin(r)*Math.cos(s)),Q=A.y+o.y*(a*Math.sin(r)*Math.sin(s)),l=A.z+o.z*(a*Math.cos(r));g.x=B,g.y=Q,g.z=l}_loopTime=0;_loopDirection=1;randomConePoint(A,e,t,i,g,o,n){let C=0,s=0;switch(o){case 0:C=Math.random(),s=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:C=.5,s=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let r=2*Math.PI*C*(g/360);switch(o){case 2:case 1:r+=Math.PI+.5,r+=this._loopTime*Math.PI*2,r%=VA.toRadians(g);break}let a=Math.acos(2*s-1),B=VA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,Q=A.x+-B*Math.sin(a)*Math.cos(r),l=A.y+B*Math.sin(a)*Math.sin(r),E=A.z;n.x=Q*this.scale.x,n.y=l*this.scale.y,n.z=E*this.scale.z}},Bt=Il;uA(Bt,"_randomQuat",new KA),uA(Bt,"_tempVec",new k),U([F()],Bt.prototype,"shapeType",2),U([F()],Bt.prototype,"enabled",2),U([F()],Bt.prototype,"alignToDirection",2),U([F()],Bt.prototype,"angle",2),U([F()],Bt.prototype,"arc",2),U([F()],Bt.prototype,"arcSpread",2),U([F()],Bt.prototype,"arcSpeedMultiplier",2),U([F()],Bt.prototype,"arcMode",2),U([F(k)],Bt.prototype,"boxThickness",2),U([F(k)],Bt.prototype,"position",2),U([F(k)],Bt.prototype,"rotation",2),U([F(k)],Bt.prototype,"scale",2),U([F()],Bt.prototype,"radius",2),U([F()],Bt.prototype,"radiusThickness",2),U([F()],Bt.prototype,"sphericalDirectionAmount",2),U([F()],Bt.prototype,"randomDirectionAmount",2),U([F()],Bt.prototype,"randomPositionAmount",2);var We=class{damping;enabled;frequency;octaveCount;octaveMultiplier;octaveScale;positionAmount;quality;remap;remapEnabled;remapMultiplier;remapX;remapXMultiplier;remapY;remapYMultiplier;remapZ;remapZMultiplier;scrollSpeedMultiplier;separateAxes;strengthMultiplier;strengthX;strengthXMultiplier;strengthY;strengthYMultiplier;strengthZ;strengthZMultiplier;_noise;_time=0;update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}_temp=new k;apply(A,e,t,i,g,o){if(!this.enabled)return;this._noise||(this._noise=RT(()=>0));let n=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(n.x,n.y,n.z,this._time),s=this._noise(n.x,n.y,n.z,this._time+1e3*this.frequency),r=this._noise(n.x,n.y,n.z,this._time+2e3*this.frequency);this._temp.set(C,s,r).normalize();let a=g/o,B=this.positionAmount.evaluate(a);this.separateAxes?(this._temp.x*=B*this.strengthXMultiplier,this._temp.y*=B*this.strengthYMultiplier,this._temp.z*=B*this.strengthZMultiplier):(this.strengthX&&(B*=this.strengthX.evaluate(a)*1.5),this._temp.multiplyScalar(B)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}};U([F()],We.prototype,"damping",2),U([F()],We.prototype,"enabled",2),U([F()],We.prototype,"frequency",2),U([F()],We.prototype,"octaveCount",2),U([F()],We.prototype,"octaveMultiplier",2),U([F()],We.prototype,"octaveScale",2),U([F(se)],We.prototype,"positionAmount",2),U([F()],We.prototype,"quality",2),U([F(se)],We.prototype,"remap",2),U([F()],We.prototype,"remapEnabled",2),U([F()],We.prototype,"remapMultiplier",2),U([F(se)],We.prototype,"remapX",2),U([F()],We.prototype,"remapXMultiplier",2),U([F(se)],We.prototype,"remapY",2),U([F()],We.prototype,"remapYMultiplier",2),U([F(se)],We.prototype,"remapZ",2),U([F()],We.prototype,"remapZMultiplier",2),U([F()],We.prototype,"scrollSpeedMultiplier",2),U([F()],We.prototype,"separateAxes",2),U([F()],We.prototype,"strengthMultiplier",2),U([F(se)],We.prototype,"strengthX",2),U([F()],We.prototype,"strengthXMultiplier",2),U([F(se)],We.prototype,"strengthY",2),U([F()],We.prototype,"strengthYMultiplier",2),U([F(se)],We.prototype,"strengthZ",2),U([F()],We.prototype,"strengthZMultiplier",2);var ot=class{enabled;attachRibbonToTransform=!1;colorOverLifetime;colorOverTrail;dieWithParticles=!0;inheritParticleColor=!0;lifetime;lifetimeMultiplier;minVertexDistance=.2;mode=0;ratio=1;ribbonCount=1;shadowBias=0;sizeAffectsLifetime=!1;sizeAffectsWidth=!1;splitSubEmitterRibbons=!1;textureMode=0;widthOverTrail;widthOverTrailMultiplier;worldSpace=!1;getWidth(A,e,t){let i=this.widthOverTrail.evaluate(t);return t===0&&(i=A),A*=i,A}getColor(A,e,t){let i=this.colorOverTrail.evaluate(t),g=this.colorOverLifetime.evaluate(e);A.x*=i.r*g.r,A.y*=i.g*g.g,A.z*=i.b*g.b,A.w*=i.alpha*g.alpha}};U([F()],ot.prototype,"enabled",2),U([F()],ot.prototype,"attachRibbonToTransform",2),U([F(Di)],ot.prototype,"colorOverLifetime",2),U([F(Di)],ot.prototype,"colorOverTrail",2),U([F()],ot.prototype,"dieWithParticles",2),U([F()],ot.prototype,"inheritParticleColor",2),U([F(se)],ot.prototype,"lifetime",2),U([F()],ot.prototype,"lifetimeMultiplier",2),U([F()],ot.prototype,"minVertexDistance",2),U([F()],ot.prototype,"mode",2),U([F()],ot.prototype,"ratio",2),U([F()],ot.prototype,"ribbonCount",2),U([F()],ot.prototype,"shadowBias",2),U([F()],ot.prototype,"sizeAffectsLifetime",2),U([F()],ot.prototype,"sizeAffectsWidth",2),U([F()],ot.prototype,"splitSubEmitterRibbons",2),U([F()],ot.prototype,"textureMode",2),U([F(se)],ot.prototype,"widthOverTrail",2),U([F()],ot.prototype,"widthOverTrailMultiplier",2),U([F()],ot.prototype,"worldSpace",2);var qi=class{enabled;space=0;speedModifier;speedModifierMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;_system;update(A){this._system=A}_temp=new k;apply(A,e,t,i,g,o){if(!this.enabled)return;let n=g/o,C=this.speedModifier.evaluate(n)*this.speedModifierMultiplier,s=this.x.evaluate(n),r=this.y.evaluate(n),a=this.z.evaluate(n);this._temp.set(-s,r,a),this._system&&(this.space===1&&this._temp.applyQuaternion(this._system.worldQuaternionInverted),this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z,t.x*=C,t.y*=C,t.z*=C}};U([F()],qi.prototype,"enabled",2),U([F()],qi.prototype,"space",2),U([F(se)],qi.prototype,"speedModifier",2),U([F()],qi.prototype,"speedModifierMultiplier",2),U([F(se)],qi.prototype,"x",2),U([F()],qi.prototype,"xMultiplier",2),U([F(se)],qi.prototype,"y",2),U([F()],qi.prototype,"yMultiplier",2),U([F(se)],qi.prototype,"z",2),U([F()],qi.prototype,"zMultiplier",2);var zt=class{animation;enabled;cycleCount;frameOverTime;frameOverTimeMultiplier;numTilesX;numTilesY;startFrame;startFrameMultiplier;rowMode;rowIndex;spriteCount;timeMode;sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?this.frameOverTime.evaluate(Math.random()):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){let e=this.numTilesX*this.numTilesY,t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}};U([F()],zt.prototype,"animation",2),U([F()],zt.prototype,"enabled",2),U([F()],zt.prototype,"cycleCount",2),U([F(se)],zt.prototype,"frameOverTime",2),U([F()],zt.prototype,"frameOverTimeMultiplier",2),U([F()],zt.prototype,"numTilesX",2),U([F()],zt.prototype,"numTilesY",2),U([F(se)],zt.prototype,"startFrame",2),U([F()],zt.prototype,"startFrameMultiplier",2),U([F()],zt.prototype,"rowMode",2),U([F()],zt.prototype,"rowIndex",2),U([F()],zt.prototype,"spriteCount",2),U([F()],zt.prototype,"timeMode",2);var yg=class{enabled;separateAxes;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}};U([F()],yg.prototype,"enabled",2),U([F()],yg.prototype,"separateAxes",2),U([F(se)],yg.prototype,"x",2),U([F()],yg.prototype,"xMultiplier",2),U([F(se)],yg.prototype,"y",2),U([F()],yg.prototype,"yMultiplier",2),U([F(se)],yg.prototype,"z",2),U([F()],yg.prototype,"zMultiplier",2);var og=class{enabled;range;separateAxes;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){let t=VA.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}};U([F()],og.prototype,"enabled",2),U([F()],og.prototype,"range",2),U([F()],og.prototype,"separateAxes",2),U([F(se)],og.prototype,"x",2),U([F()],og.prototype,"xMultiplier",2),U([F(se)],og.prototype,"y",2),U([F()],og.prototype,"yMultiplier",2),U([F(se)],og.prototype,"z",2),U([F()],og.prototype,"zMultiplier",2);var mt=class{enabled;dampen;drag;dragMultiplier;limit;limitMultiplier;separateAxes;limitX;limitXMultiplier;limitY;limitYMultiplier;limitZ;limitZMultiplier;multiplyDragByParticleSize=!1;multiplyDragByParticleVelocity=!1;space;_temp=new k;_temp2=new k;apply(A,e,t,i,g,o,n){if(!!this.enabled){let C=this.limit.evaluate(g)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let r=this.dampen*.5;e.x=VA.lerp(e.x,this._temp.x,r),e.y=VA.lerp(e.y,this._temp.y,r),e.z=VA.lerp(e.z,this._temp.z,r),t.x=VA.lerp(t.x,this._temp.x,r),t.y=VA.lerp(t.y,this._temp.y,r),t.z=VA.lerp(t.z,this._temp.z,r)}}}};U([F()],mt.prototype,"enabled",2),U([F()],mt.prototype,"dampen",2),U([F(se)],mt.prototype,"drag",2),U([F()],mt.prototype,"dragMultiplier",2),U([F(se)],mt.prototype,"limit",2),U([F()],mt.prototype,"limitMultiplier",2),U([F()],mt.prototype,"separateAxes",2),U([F(se)],mt.prototype,"limitX",2),U([F()],mt.prototype,"limitXMultiplier",2),U([F(se)],mt.prototype,"limitY",2),U([F()],mt.prototype,"limitYMultiplier",2),U([F(se)],mt.prototype,"limitZ",2),U([F()],mt.prototype,"limitZMultiplier",2),U([F()],mt.prototype,"multiplyDragByParticleSize",2),U([F()],mt.prototype,"multiplyDragByParticleVelocity",2),U([F()],mt.prototype,"space",2);var fo=class{enabled;curve;curveMultiplier;mode;system;_lastWorldPosition;_velocity=new k;_temp=new k;update(A){!this.enabled||this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(!!this.enabled&&this.system.worldspace!==!1&&this.mode===0){let e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,t){if(!!this.enabled&&this.system.worldspace!==!1&&this.mode===1){let i=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(i),A.add(this._temp)}}};U([F()],fo.prototype,"enabled",2),U([F(se)],fo.prototype,"curve",2),U([F()],fo.prototype,"curveMultiplier",2),U([F()],fo.prototype,"mode",2);var fi=class{enabled;range;separateAxes;size;sizeMultiplier;x;xMultiplier;y;yMultiplier;z;zMultiplier;evaluate(A,e,t,i){let g=A.length(),o=VA.remap(g,this.range.x,this.range.y,0,1),n=this.size.evaluate(o,t);return i*n}};U([F()],fi.prototype,"enabled",2),U([F(SA)],fi.prototype,"range",2),U([F()],fi.prototype,"separateAxes",2),U([F(se)],fi.prototype,"size",2),U([F()],fi.prototype,"sizeMultiplier",2),U([F(se)],fi.prototype,"x",2),U([F()],fi.prototype,"xMultiplier",2),U([F(se)],fi.prototype,"y",2),U([F()],fi.prototype,"yMultiplier",2),U([F(se)],fi.prototype,"z",2),U([F()],fi.prototype,"zMultiplier",2);var an=class{enabled;range;color;evaluate(A,e,t){let i=A.length(),g=VA.remap(i,this.range.x,this.range.y,0,1),o=this.color.evaluate(g,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}};U([F()],an.prototype,"enabled",2),U([F(SA)],an.prototype,"range",2),U([F(Di)],an.prototype,"color",2);var YB=class extends ig{},ol=class extends EA{deleteBoxes=[];awake(){this.deleteBoxes=IA.findObjectsOfType(YB,this.context)}update(){for(let A of this.deleteBoxes){let e=this.gameObject;A.isInBox(e)===!0&&(IA.getComponentInParent(this.gameObject,Bo)||ic(this.gameObject,this.context.connection))}}};var _B=class extends EA{visibleOn;onEnable(){this.apply()}apply(){this.test()||IA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:j8()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}};U([F()],_B.prototype,"visibleOn",2);var $y;function j8(){if($y===!0||$y===!1)return $y;let I=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(I=!0)}(navigator.userAgent||navigator.vendor||window.opera),$y=I,I}var AF=!1;var as=class extends ao{static get HasAnySelected(){return this._active>0}transformSelf=!0;orbit=null;selectStartEventListener=[];selectEndEventListener=[];constructor(){super(),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new SA}addDragEventListener(A,e){switch(A){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}_dragHelper=null;start(){this.orbit=IA.findObjectOfType(Xi,this.context)}_draggingRigidbodies=[];allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||pe.IsInWebXR)return;let e=IA.getComponentInParent(A.object,as);!e||e!==this||(as.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){!this.allowEdit(this.gameObject)||pe.IsInWebXR||as.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}_waitingForDragStart=null;onPointerDown(A){!this.allowEdit(this.gameObject)||pe.IsInWebXR||(as._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=A,A.StopPropagation(),this.orbit&&(this.orbit.enabled=!1))}onPointerUp(A){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(as._active>0&&(as._active-=1),!pe.IsInWebXR&&(this.onDragEnd(A),A.StopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){if(!pe.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){let e=this.context.input.getPointerPositionDelta(0);if(e&&this._dragDelta.add(e),this._dragDelta.length()>2)this._didDrag=!0;else return}let A=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(A)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),this._isDragging&&this._dragHelper?.hasSelected===!1&&this.onDragEnd(null)}}_isDragging=!1;_marker=null;_dragDelta;_didDrag=!1;onDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new AS(this.context.mainCamera);else return;if(!A||!A.object)return;let e=IA.getComponentInParent(A.object,as);if(!e||e!==this)return;let t=A.object;this.transformSelf&&(t=this.gameObject);let i={selected:t,attached:t};for(let C of this.selectStartEventListener)C(this,i);if(!i.attached)return;i.attached,t=i.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);let g=IA.getComponentInChildren(t,NI);AF&&console.log("DRAG START",g,t),g&&(g.fastMode=!0,g?.requestOwnership()),this._marker=IA.addNewComponent(t,Bo),this._draggingRigidbodies.length=0;let o=IA.getComponentsInChildren(t,je);o&&this._draggingRigidbodies.push(...o);let n=S0();IA.invokeOnChildren(this._dragHelper.selected,n("onDragStart"))}onUpdateDrag(){if(!!this._dragHelper){this._dragHelper.onUpdate(this.context);for(let A of this._draggingRigidbodies)A.wakeUp(),A.resetVelocities()}}onDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(let i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;let e=this._dragHelper.selected;if(AF&&console.log("DRAG END",e,e?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A?.object){let i=IA.getComponentInChildren(A.object,NI);i&&(i.fastMode=!1),this._marker&&this._marker.destroy()}for(let i of this.selectEndEventListener)i(this);let t=S0();IA.invokeOnChildren(e,t("onDragEnd"))}},eC=as;uA(eC,"_active",0),uA(eC,"lastHovered");var eF=class{get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}_selected=null;_context=null;_camera;_cameraPlane=new Ti;_hasGroundPlane=!1;_groundPlane=new Ti;_groundOffset=new k;_groundOffsetFactor=0;_groundDistance=0;_groundPlanePoint=new k;_raycaster=new xC;_cameraPlaneOffset=new k;_intersection=new k;_worldPosition=new k;_inverseMatrix=new zA;_rbs=[];_groundLine;_groundMarker;constructor(A){this._camera=A;let e=new hg(eF.geometry),t=e.material;t.color=new W(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;let i=new Tg(.5,22,22),g=new yt({color:t.color}),o=new we(i,g);o.visible=!1,o.layers.set(2),this._groundMarker=o}setSelected(A,e){if(this._selected&&e)for(let t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&Wt.Remove(e,this._selected),this._selected=A,this._context=e,this._rbs.length=0,A?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}Wt.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}_groundOffsetVector=new k(0,1,0);_requireUpdateGroundPlane=!0;_didDragOnGroundPlaneLastFrame=!1;onUpdate(A){if(!this._context)return;let e=" ",t="d",i="s",g=this._context?.input.isKeyPressed(e)||this._context?.input.isKeyPressed(t),o=this._context.input.getTouchesPressedCount()>=2||g;if(o){let C=this._context.input.getPointerPositionDelta(0);C&&(this._groundOffsetVector.set(0,1,0),this._selected?.rotateOnWorldAxis(this._groundOffsetVector,C.x*this._context.time.deltaTime))}let n=this._context.input.getPointerPositionRC(0);if(!!n&&(this._raycaster.setFromCamera(n,this._camera),this._selected)){AF&&console.log("UPDATE DRAG",this._selected),this._groundOffsetVector.set(0,1,0);let C=ge(this._camera).clone().sub(ge(this._selected)).normalize(),s=Math.abs(C.dot(this._groundOffsetVector)),r=this._context?.input.isKeyPressed(e)||this._context?.input.isKeyPressed(t),a=!o&&s>.2&&!r&&this._context.input.getPointerPressedCount()<=1,B=this._didDragOnGroundPlaneLastFrame!==a;if(this._didDragOnGroundPlaneLastFrame=a,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!a||B)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){let Q=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=Q,a){this._groundOffsetVector.set(0,1,0);let l=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(l,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);B&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(A,e,t){if(!!this._selected){if(t){let i=ge(this._selected);i.y=A.y,A=i}if(at(this._selected,A),at(this._groundLine,A),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundMarker.visible=e!==null,e){let i=ge(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(i,i,i),at(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;let A=this._context.input.getPointerPositionRC(0);!A||(this._raycaster.setFromCamera(A,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;let A=ge(this._selected),e=new Lg(new k(0,.1,0).add(A),new k(0,-1,0)),t=new vt;t.ignore=[this._selected];let i=this._context.physics.raycastFromRay(e,t);for(let g=0;g<i.length;g++){let o=i[g];if(!o.face||this.contains(this._selected,o.object))continue;let n=new k(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(n,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(A),this._groundOffset.copy(this._intersection).sub(A)}onDidUpdate(){Et.markDirty(this._selected);for(let A of this._rbs)A.wakeUp(),A.resetForcesAndTorques(),A.setAngularVelocity(0,0,0)}contains(A,e){if(A===e)return!0;if(A.children){for(let t of A.children)if(this.contains(t,e))return!0}return!1}},AS=eF;uA(AS,"geometry",new le().setFromPoints([new k(0,0,0),new k(0,-1,0)]));var Qn=class extends EA{url=null;urlParameterName=null;localhost=null;awake(){this.context.connection.registerProvider(this)}getWebsocketUrl(){let A=this.url?Qn.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){let g=sA(this.urlParameterName);g&&typeof g=="string"&&(A=g)}if(!A)return null;let t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(A);return t?.groups?t?.groups.socket_prefix?A:"wss://"+t?.groups.url:null}static GetUrl(A,e){let t=A,i=Qn.IsLocalNetwork()&&e;return i&&(t=e),A?.startsWith("/")&&(t=(i?t:window.location.origin)+A),t}static IsLocalNetwork(A=window.location.hostname){return tI(A)}};var Hr=class extends EA{filesBackendUrl;localhost;_dragOver;_drop;onEnable(){this.filesBackendUrl=this.filesBackendUrl?Qn.GetUrl(this.filesBackendUrl,this.localhost):void 0,this._dragOver=this.onDrag.bind(this),this._drop=this.onDrop.bind(this),this.context.domElement.addEventListener("dragover",this._dragOver),this.context.domElement.addEventListener("drop",this._drop)}onDisable(){this.context.domElement.removeEventListener("dragover",this._dragOver),this.context.domElement.removeEventListener("drop",this._drop)}onDrag(A){A.preventDefault()}async addFiles(A){for(let e of A){if(!e)continue;console.log("Register file "+e.name+" to",this.filesBackendUrl,e);let t=await wR(e,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:e})),t&&this.addObject(void 0,t)}}async onDrop(A){if(console.log(A),!A.dataTransfer)return;A.preventDefault();let e=A.dataTransfer.items;if(!!e)for(let t in e){let i=e[t];if(i.kind==="file"){let g=i.getAsFile();if(!g)continue;console.log("Register file "+g.name+" to",this.filesBackendUrl,g);let o=await wR(g,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:g})),o&&this.addObject(A,o)}else i.kind==="string"&&i.type=="text/plain"&&i.getAsString(async g=>{console.log("dropped url",g);try{let o=new URL(g);if(!o)return;let n=await uv(o,this.context);n&&this.addObject(A,n)}catch{console.log("dropped string is not a valid URL!",g)}})}}async addObject(A,e){console.log("Dropped",e);let t=e.scene;if(A!==void 0){let i=new vt;i.setMask(16777215),i.screenPointFromOffset(A.offsetX,A.offsetY);let g=this.context.physics.raycast(i);if(g&&g.length>0)for(let o of g){t.position.copy(o.point);break}}this.gameObject.add(t),this.dispatchEvent(new CustomEvent("object-added",{detail:e}))}};U([F()],Hr.prototype,"filesBackendUrl",2),U([F()],Hr.prototype,"localhost",2);var tC=class extends ao{parent=null;object=null;limitCount=10;limitInterval=60;_currentCount=0;_startPosition=null;_startQuaternion=null;awake(){if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=this.object.position?.clone()??new k(0,0,0),this._startQuaternion=this.object.quaternion?.clone()??new KA(0,0,0,1)}let A=IA.getComponentInParent(this.gameObject,eC);A?A.addDragEventListener("selectstart",(e,t)=>{if(this._currentCount>=this.limitCount){t.attached=null;return}let i=this.handleDuplication(t.selected);i&&(console.assert(i!==t.selected,"Duplicated object is original"),t.attached=i)}):console.warn("Could no find drag controls in parent",this.name),it.addEventListener("select-start",(e,t)=>{if(this._currentCount>=this.limitCount){t.grab=null;return}let i=this.handleDuplication(t.selected);i&&(t.grab=i)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(A){if(this._currentCount>=this.limitCount||!this.object)return null;if(A===this.gameObject||this.handleMultiObject(A)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);let e=new zi;this.parent||(this.parent=this.gameObject.parent),this.parent&&(e.parent=this.parent.guid??this.parent.userData?.guid,e.keepWorldPosition=!0),e.position=this.worldPosition,e.rotation=this.worldQuaternion,e.context=this.context,this._currentCount+=1;let t=IA.instantiateSynced(this.object,e);return console.assert(t!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),t}return null}handleMultiObject(A){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,A):!1}isInChildren(A,e){if(!A)return!1;if(A===e)return!0;if(A.children){for(let t of A.children)if(this.isInChildren(t,e))return!0}return!1}};U([F(vA)],tC.prototype,"parent",2),U([F(vA)],tC.prototype,"object",2),U([F()],tC.prototype,"limitCount",2),U([F()],tC.prototype,"limitInterval",2);var Uu=class{eventID;callback};U([F()],Uu.prototype,"eventID",2),U([F(Nt)],Uu.prototype,"callback",2);var OB=class extends EA{triggers;invoke(A){if(!!this.triggers)for(let e of this.triggers)e.eventID===A&&e.callback.invoke()}onPointerClick(A){this.invoke(4)}onPointerEnter(A){this.invoke(0)}onPointerExit(A){this.invoke(1)}onPointerDown(A){this.invoke(2)}onPointerUp(A){this.invoke(3)}};U([F(Uu)],OB.prototype,"triggers",2);var Bs=class{get lightmap(){return this.lightmapTexture}set lightmap(A){A!==this.lightmapTexture&&(this.lightmapTexture=A,this.setupLightmap())}lightmapIndex=-1;lightmapScaleOffset=new Ae(1,1,0,0);context;gameObject;lightmapTexture=null;lightmapScaleOffsetUniform={value:new Ae(1,1,0,0)};lightmapUniform={value:null};beforeRenderCallback;constructor(A,e){this.gameObject=A,this.context=e}init(A,e,t,i=!1){if(console.assert(this.gameObject!==void 0&&this.gameObject!==null,"Missing gameobject",this),this.lightmapIndex=A,this.lightmapIndex<0)return;this.lightmapScaleOffset=e,this.lightmapTexture=t,i&&this.setLightmapDebugMaterial(),this.setupLightmap()}bindOnBeforeRender(){this.beforeRenderCallback=this.onBeforeRenderThreeComplete.bind(this),this.context.addBeforeRenderListener(this.gameObject,this.beforeRenderCallback)}onBeforeRenderThreeComplete(A,e,t,i,g,o){this.onBeforeRenderThree(g)}setupLightmap(){if(this.gameObject.type==="Object3D")return;if(this.gameObject.type==="Group"){console.warn("Lightmap on multimaterial object is not supported yet... please ask kindly for implementation.");return}console.assert(this.gameObject.type==="Mesh","Lightmap only works on meshes",this);let A=this.gameObject;A.geometry.getAttribute("uv2")||A.geometry.setAttribute("uv2",A.geometry.getAttribute("uv"));let e=this.gameObject.material.clone();if(this.gameObject.material=e,this.gameObject.material.onBeforeCompile=(t,i)=>{t.uniforms.lightmap=this.lightmapUniform,t.uniforms.lightmapScaleOffset=this.lightmapScaleOffsetUniform},this.lightmapIndex>=0){let t=this.lightmapTexture,i=this.gameObject.material;i&&t&&(i.uniforms||(i.uniforms={}),i.lightMap=t,i.uniforms.lightmap={value:t})}}onBeforeRenderThree(A){let e=A.uniforms;e&&e.lightmap&&(this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,this.lightmapUniform.value=this.lightmapTexture,e.lightmap=this.lightmapUniform,e.lightmapScaleOffset=this.lightmapScaleOffsetUniform)}setLightmapDebugMaterial(){this.gameObject.material=new ut({vertexShader:`
6713
6713
  attribute vec2 uv2;
6714
6714
  varying vec2 vUv2;
6715
6715
  void main()