@dcl/wearable-preview 2.8.1 → 2.8.2

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.
@@ -13293,7 +13293,7 @@ tUV=uv*stageSize;
13293
13293
  gl_Position=worldViewProjection*p;
13294
13294
  }`;ce.ShadersStore[u5]=f5;var M8=function(){function n(t,e,i,r,o){var a=this;this.name=t,this.sprites=[],this.atlasJSON=e,this.sprites=this.atlasJSON.frames,this.spriteSheet=i,this.options=r,r.stageSize=r.stageSize||new Ie(1,1),r.outputSize=r.outputSize||r.stageSize,r.outputPosition=r.outputPosition||y.Zero(),r.outputRotation=r.outputRotation||y.Zero(),r.layerCount=r.layerCount||1,r.maxAnimationFrames=r.maxAnimationFrames||0,r.baseTile=r.baseTile||0,r.flipU=r.flipU||!1,r.colorMultiply=r.colorMultiply||new y(1,1,1),this._scene=o,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var s=0;s<r.layerCount;s++)this._tileMaps.push(this._createTileBuffer(null,s));this._animationMap=this._createTileAnimationBuffer(null);var l=[];l.push("#define LAYERS "+r.layerCount),r.flipU&&l.push("#define FLIPU"),l.push("#define MAX_ANIMATION_FRAMES "+r.maxAnimationFrames+".0");var u=ce.ShadersStore.spriteMapPixelShader,f;if(this._scene.getEngine().webGLVersion===1){f="";for(var s=0;s<r.layerCount;s++)f+="if ("+s+" == i) { frameID = texture2D(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x; }"}else{f="switch(i) {";for(var s=0;s<r.layerCount;s++)f+="case "+s+" : frameID = texture(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x;",f+="break;";f+="}"}ce.ShadersStore["spriteMap"+this.name+"PixelShader"]=u.replace("#define LAYER_ID_SWITCH",f),this._material=new Ca("spriteMap:"+this.name,this._scene,{vertex:"spriteMap",fragment:"spriteMap"+this.name},{defines:l,attributes:["position","normal","uv"],uniforms:["worldViewProjection","time","stageSize","outputSize","spriteMapSize","spriteCount","time","colorMul","mousePosition","curTile","flipU"],samplers:["spriteSheet","frameMap","tileMaps","animationMap"],needAlphaBlending:!0}),this._time=0,this._material.setFloat("spriteCount",this.spriteCount),this._material.setVector2("stageSize",r.stageSize),this._material.setVector2("outputSize",r.outputSize),this._material.setTexture("spriteSheet",this.spriteSheet),this._material.setVector2("spriteMapSize",new Ie(1,1)),this._material.setVector3("colorMul",r.colorMultiply);var c=0,h=function(){if(a.spriteSheet&&a.spriteSheet.isReady()&&a.spriteSheet._texture){a._material.setVector2("spriteMapSize",new Ie(a.spriteSheet._texture.baseWidth||1,a.spriteSheet._texture.baseHeight||1));return}c<100&&setTimeout(function(){c++,h()},100)};h(),this._material.setVector3("colorMul",r.colorMultiply),this._material.setTexture("frameMap",this._frameMap),this._material.setTextureArray("tileMaps",this._tileMaps),this._material.setTexture("animationMap",this._animationMap),this._material.setFloat("time",this._time),this._output=ne.CreatePlane(t+":output",1,o,!0),this._output.scaling.x=r.outputSize.x,this._output.scaling.y=r.outputSize.y,this.position=r.outputPosition,this.rotation=r.outputRotation;var p=function(){a._time+=a._scene.getEngine().getDeltaTime(),a._material.setFloat("time",a._time)};this._scene.onBeforeRenderObservable.add(p),this._output.material=this._material}return Object.defineProperty(n.prototype,"spriteCount",{get:function(){return this.sprites.length},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"position",{get:function(){return this._output.position},set:function(t){this._output.position=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this._output.rotation},set:function(t){this._output.rotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"animationMap",{get:function(){return this._animationMap},set:function(t){var e=t._texture._bufferView,i=this._createTileAnimationBuffer(e);this._animationMap.dispose(),this._animationMap=i,this._material.setTexture("animationMap",this._animationMap)},enumerable:!1,configurable:!0}),n.prototype.getTileID=function(){var t=this.getMousePosition();return t.multiplyInPlace(this.options.stageSize||Ie.Zero()),t.x=Math.floor(t.x),t.y=Math.floor(t.y),t},n.prototype.getMousePosition=function(){var t=this._output,e=this._scene.pick(this._scene.pointerX,this._scene.pointerY,function(r){return r===t});if(!e||!e.hit||!e.getTextureCoordinates)return new Ie(-1,-1);var i=e.getTextureCoordinates();return i||new Ie(-1,-1)},n.prototype._createFrameBuffer=function(){for(var t=new Array,e=0;e<this.spriteCount;e++)t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0);for(var e=0;e<this.spriteCount;e++){var i=this.sprites[e].frame,r=this.sprites[e].spriteSourceSize,o=this.sprites[e].sourceSize,a=this.sprites[e].rotated?1:0,s=this.sprites[e].trimmed?1:0;t[e*4]=i.x,t[e*4+1]=i.y,t[e*4+2]=i.w,t[e*4+3]=i.h,t[e*4+this.spriteCount*4]=r.x,t[e*4+1+this.spriteCount*4]=r.y,t[e*4+3+this.spriteCount*4]=r.h,t[e*4+this.spriteCount*8]=o.w,t[e*4+1+this.spriteCount*8]=o.h,t[e*4+2+this.spriteCount*8]=a,t[e*4+3+this.spriteCount*8]=s}var l=new Float32Array(t),u=Vo.CreateRGBATexture(l,this.spriteCount,4,this._scene,!1,!1,he.NEAREST_NEAREST,Me.TEXTURETYPE_FLOAT);return u},n.prototype._createTileBuffer=function(t,e){e===void 0&&(e=0);var i=new Array,r=this.options.stageSize.y||0,o=this.options.stageSize.x||0;if(t)i=t;else{var a=this.options.baseTile;e!=0&&(a=0);for(var s=0;s<r;s++)for(var l=0;l<o*4;l+=4)i.push(a,0,0,0)}var u=new Float32Array(i),f=Vo.CreateRGBATexture(u,o,r,this._scene,!1,!1,he.NEAREST_NEAREST,Me.TEXTURETYPE_FLOAT);return f},n.prototype.changeTiles=function(t,e,i){t===void 0&&(t=0),i===void 0&&(i=0);var r;if(r=this._tileMaps[t]._texture._bufferView,r!==null){var o=new Array;e instanceof Ie?o.push(e):o=e;for(var a=this.options.stageSize.x||0,s=0;s<o.length;s++){var l=o[s];l.x=Math.floor(l.x),l.y=Math.floor(l.y);var u=l.x*4+l.y*(a*4);r[u]=i}var f=this._createTileBuffer(r);this._tileMaps[t].dispose(),this._tileMaps[t]=f,this._material.setTextureArray("tileMap",this._tileMaps)}},n.prototype._createTileAnimationBuffer=function(t){var e=new Array,i;if(t)i=t;else{for(var r=0;r<this.spriteCount;r++){e.push(0,0,0,0);for(var o=1;o<(this.options.maxAnimationFrames||4);)e.push(0,0,0,0),o++}i=new Float32Array(e)}var a=Vo.CreateRGBATexture(i,this.spriteCount,this.options.maxAnimationFrames||4,this._scene,!1,!1,he.NEAREST_NEAREST,Me.TEXTURETYPE_FLOAT);return a},n.prototype.addAnimationToTile=function(t,e,i,r,o){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=0),o===void 0&&(o=1);var a=this._animationMap._texture._bufferView,s=t*4+this.spriteCount*4*e;if(a){a[s]=i,a[s+1]=r,a[s+2]=o;var l=this._createTileAnimationBuffer(a);this._animationMap.dispose(),this._animationMap=l,this._material.setTexture("animationMap",this._animationMap)}},n.prototype.saveTileMaps=function(){for(var t="",e=0;e<this._tileMaps.length;e++)e>0&&(t+=`
13295
13295
  \r`),t+=this._tileMaps[e]._texture._bufferView.toString();var i=document.createElement("a");i.href="data:octet/stream;charset=utf-8,"+encodeURI(t),i.target="_blank",i.download=this.name+".tilemaps",i.click(),i.remove()},n.prototype.loadTileMaps=function(t){var e=this,i=new XMLHttpRequest;i.open("GET",t);var r=this.options.layerCount||0;i.onload=function(){for(var o=i.response.split(`
13296
- \r`),a=0;a<r;a++){var s=o[a].split(",").map(Number),l=e._createTileBuffer(s);e._tileMaps[a].dispose(),e._tileMaps[a]=l}e._material.setTextureArray("tileMap",e._tileMaps)},i.send()},n.prototype.dispose=function(){this._output.dispose(),this._material.dispose(),this._animationMap.dispose(),this._tileMaps.forEach(function(t){t.dispose()}),this._frameMap.dispose()},n}(),x8=function(n){j(t,n);function t(e,i,r,o,a,s,l){a===void 0&&(a=null),s===void 0&&(s=.01),l===void 0&&(l=he.TRILINEAR_SAMPLINGMODE);var u=n.call(this,e,i,r,64,o,s,l,!0,a)||this;return u.name=e,u}return t}(a5),ya;(function(n){n[n.INIT=0]="INIT",n[n.RUNNING=1]="RUNNING",n[n.DONE=2]="DONE",n[n.ERROR=3]="ERROR"})(ya||(ya={}));var Ra=function(){function n(t){this.name=t,this._isCompleted=!1,this._taskState=ya.INIT}return Object.defineProperty(n.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"taskState",{get:function(){return this._taskState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),n.prototype._setErrorObject=function(t,e){this._errorObject||(this._errorObject={message:t,exception:e})},n.prototype.run=function(t,e,i){var r=this;this._taskState=ya.RUNNING,this.runTask(t,function(){r.onDoneCallback(e,i)},function(o,a){r.onErrorCallback(i,o,a)})},n.prototype.runTask=function(t,e,i){throw new Error("runTask is not implemented")},n.prototype.reset=function(){this._taskState=ya.INIT},n.prototype.onErrorCallback=function(t,e,i){this._taskState=ya.ERROR,this._errorObject={message:e,exception:i},this.onError&&this.onError(this,e,i),t()},n.prototype.onDoneCallback=function(t,e){try{this._taskState=ya.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),t()}catch(i){this.onErrorCallback(e,"Task is done, error executing success callback(s)",i)}},n}(),c5=function(){function n(t,e,i){this.remainingCount=t,this.totalCount=e,this.task=i}return n}(),h5=function(n){j(t,n);function t(e,i,r,o){var a=n.call(this,e)||this;return a.name=e,a.meshesNames=i,a.rootUrl=r,a.sceneFilename=o,a}return t.prototype.runTask=function(e,i,r){var o=this;$t.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,function(a){o.loadedContainer=a,o.loadedMeshes=a.meshes,o.loadedParticleSystems=a.particleSystems,o.loadedSkeletons=a.skeletons,o.loadedAnimationGroups=a.animationGroups,i()},null,function(a,s,l){r(s,l)})},t}(Ra),d5=function(n){j(t,n);function t(e,i,r,o){var a=n.call(this,e)||this;return a.name=e,a.meshesNames=i,a.rootUrl=r,a.sceneFilename=o,a}return t.prototype.runTask=function(e,i,r){var o=this;$t.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,function(a,s,l,u){o.loadedMeshes=a,o.loadedParticleSystems=s,o.loadedSkeletons=l,o.loadedAnimationGroups=u,i()},null,function(a,s,l){r(s,l)})},t}(Ra),p5=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this;e._loadFile(this.url,function(a){o.text=a,i()},void 0,!1,!1,function(a,s){a&&r(a.status+" "+a.statusText,s)})},t}(Ra),NI=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this;e._loadFile(this.url,function(a){o.data=a,i()},void 0,!0,!0,function(a,s){a&&r(a.status+" "+a.statusText,s)})},t}(Ra),_5=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this,a=new Image;Ee.SetCorsBehavior(this.url,a),a.onload=function(){o.image=a,i()},a.onerror=function(s){r("Error loading image",s)},a.src=this.url},t}(Ra),Xb=function(n){j(t,n);function t(e,i,r,o,a){o===void 0&&(o=!0),a===void 0&&(a=he.TRILINEAR_SAMPLINGMODE);var s=n.call(this,e)||this;return s.name=e,s.url=i,s.noMipmap=r,s.invertY=o,s.samplingMode=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new he(this.url,e,this.noMipmap,this.invertY,this.samplingMode,o,a)},t}(Ra),m5=function(n){j(t,n);function t(e,i,r,o,a){var s=n.call(this,e)||this;return s.name=e,s.url=i,s.extensions=r,s.noMipmap=o,s.files=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new Yo(this.url,e,this.extensions,this.noMipmap,this.files,o,a)},t}(Ra),g5=function(n){j(t,n);function t(e,i,r,o,a,s,l){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=!1);var u=n.call(this,e)||this;return u.name=e,u.url=i,u.size=r,u.noMipmap=o,u.generateHarmonics=a,u.gammaSpace=s,u.reserved=l,u}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new Ub(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,o,a)},t}(Ra),v5=function(n){j(t,n);function t(e,i,r,o,a){o===void 0&&(o=!1),a===void 0&&(a=!0);var s=n.call(this,e)||this;return s.name=e,s.url=i,s.size=r,s.noMipmap=o,s.gammaSpace=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new $G(this.url,e,this.size,this.noMipmap,this.gammaSpace,o,a)},t}(Ra),I8=function(){function n(t){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new ie,this.onTaskErrorObservable=new ie,this.onTasksDoneObservable=new ie,this.onProgressObservable=new ie,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=t}return n.prototype.addContainerTask=function(t,e,i,r){var o=new h5(t,e,i,r);return this._tasks.push(o),o},n.prototype.addMeshTask=function(t,e,i,r){var o=new d5(t,e,i,r);return this._tasks.push(o),o},n.prototype.addTextFileTask=function(t,e){var i=new p5(t,e);return this._tasks.push(i),i},n.prototype.addBinaryFileTask=function(t,e){var i=new NI(t,e);return this._tasks.push(i),i},n.prototype.addImageTask=function(t,e){var i=new _5(t,e);return this._tasks.push(i),i},n.prototype.addTextureTask=function(t,e,i,r,o){o===void 0&&(o=he.TRILINEAR_SAMPLINGMODE);var a=new Xb(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.addCubeTextureTask=function(t,e,i,r,o){var a=new m5(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.addHDRCubeTextureTask=function(t,e,i,r,o,a,s){r===void 0&&(r=!1),o===void 0&&(o=!0),a===void 0&&(a=!1),s===void 0&&(s=!1);var l=new g5(t,e,i,r,o,a,s);return this._tasks.push(l),l},n.prototype.addEquiRectangularCubeTextureAssetTask=function(t,e,i,r,o){r===void 0&&(r=!1),o===void 0&&(o=!0);var a=new v5(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.removeTask=function(t){var e=this._tasks.indexOf(t);e>-1&&this._tasks.splice(e,1)},n.prototype._decreaseWaitingTasksCount=function(t){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,t),this.onProgressObservable.notifyObservers(new c5(this._waitingTasksCount,this._totalTasksCount,t))}catch(a){de.Error("Error running progress callbacks."),console.log(a)}if(this._waitingTasksCount===0){try{var e=this._tasks.slice();this.onFinish&&this.onFinish(e);for(var i=0,r=e;i<r.length;i++){var t=r[i];if(t.taskState===ya.DONE){var o=this._tasks.indexOf(t);o>-1&&this._tasks.splice(o,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(a){de.Error("Error running tasks-done callbacks."),console.log(a)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},n.prototype._runTask=function(t){var e=this,i=function(){try{e.onTaskSuccess&&e.onTaskSuccess(t),e.onTaskSuccessObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)}catch(o){r("Error executing task success callbacks",o)}},r=function(o,a){t._setErrorObject(o,a),e.onTaskError&&e.onTaskError(t),e.onTaskErrorObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)};t.run(this._scene,i,r)},n.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},n.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var t=0;t<this._tasks.length;t++){var e=this._tasks[t];e.taskState===ya.INIT&&this._runTask(e)}return this},n.prototype.loadAsync=function(){var t=this;return new Promise(function(e,i){if(t._isLoading){e();return}t.onTasksDoneObservable.addOnce(function(r){r&&r.length?i(r):e()}),t.load()})},n}(),Nf=function(){function n(){var t=this;this.promise=new Promise(function(e,i){t._resolve=e,t._reject=i})}return Object.defineProperty(n.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),n}(),D8=function(){function n(t,e){this._meshesOrigins=[],this._toCenterVectors=[],this._scaledDirection=y.Zero(),this._newPosition=y.Zero(),this._centerPosition=y.Zero(),this._meshes=t.slice(),e?this._centerMesh=e:this._setCenterMesh();var i=this._meshes.indexOf(this._centerMesh);i>=0&&this._meshes.splice(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r];this._meshesOrigins[r]=o.getAbsolutePosition().clone(),this._toCenterVectors[r]=y.Zero(),o._boundingInfo&&this._centerMesh._boundingInfo&&o._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld,this._toCenterVectors[r])}}return n.prototype._setCenterMesh=function(){for(var t=y.Zero(),e=y.Zero(),i=Number.MAX_VALUE,r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r],a=o.getBoundingInfo();a&&e.addInPlace(a.boundingBox.centerWorld)}t=e.scale(1/this._meshes.length);for(var r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r],a=o.getBoundingInfo();if(a){var s=a.boundingBox.centerWorld.subtract(t).lengthSquared();s<i&&(this._centerMesh=o,i=s)}}},n.prototype.getClassName=function(){return"MeshExploder"},n.prototype.getMeshes=function(){var t=this._meshes.slice();return t.unshift(this._centerMesh),t},n.prototype.explode=function(t){t===void 0&&(t=1);for(var e=0;e<this._meshes.length;e++)this._meshes[e]&&this._meshesOrigins[e]&&this._toCenterVectors[e]&&(this._toCenterVectors[e].scaleToRef(t,this._scaledDirection),this._meshesOrigins[e].addToRef(this._scaledDirection,this._newPosition),this._meshes[e].setAbsolutePosition(this._newPosition));this._centerMesh.setAbsolutePosition(this._centerPosition)},n}(),w8=function(){function n(t,e,i,r,o,a,s,l,u){this.onProcessFileCallback=function(){return!0},this._engine=t,this._currentScene=e,this._sceneLoadedCallback=i,this._progressCallback=r,this._additionalRenderLoopLogicCallback=o,this._textureLoadingCallback=a,this._startingProcessingFilesCallback=s,this._onReloadCallback=l,this._errorCallback=u}return Object.defineProperty(n,"FilesToLoad",{get:function(){return Gl.FilesToLoad},enumerable:!1,configurable:!0}),n.prototype.monitorElementForDragNDrop=function(t){var e=this;t&&(this._elementToMonitor=t,this._dragEnterHandler=function(i){e.drag(i)},this._dragOverHandler=function(i){e.drag(i)},this._dropHandler=function(i){e.drop(i)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},Object.defineProperty(n.prototype,"filesToLoad",{get:function(){return this._filesToLoad},enumerable:!1,configurable:!0}),n.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},n.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var t=this._currentScene.getWaitingItemsCount();t>0&&this._textureLoadingCallback(t)}this._currentScene.render()}},n.prototype.drag=function(t){t.stopPropagation(),t.preventDefault()},n.prototype.drop=function(t){t.stopPropagation(),t.preventDefault(),this.loadFiles(t)},n.prototype._traverseFolder=function(t,e,i,r){var o=this,a=t.createReader(),s=t.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");a.readEntries(function(l){i.count+=l.length;for(var u=0,f=l;u<f.length;u++){var c=f[u];c.isFile?c.file(function(h){h.correctName=s+h.name,e.push(h),--i.count===0&&r()}):c.isDirectory&&o._traverseFolder(c,e,i,r)}--i.count===0&&r()})},n.prototype._processFiles=function(t){for(var e=0;e<t.length;e++){var i=t[e].correctName.toLowerCase(),r=i.split(".").pop();this.onProcessFileCallback(t[e],i,r)&&($t.IsPluginForExtensionAvailable("."+r)&&(this._sceneFileToLoad=t[e]),n.FilesToLoad[i]=t[e])}},n.prototype.loadFiles=function(t){var e=this;if(t&&t.dataTransfer&&t.dataTransfer.files&&(this._filesToLoad=t.dataTransfer.files),t&&t.target&&t.target.files&&(this._filesToLoad=t.target.files),!(!this._filesToLoad||this._filesToLoad.length===0)&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var i=new Array,r=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a<this._filesToLoad.length;a++){var s=this._filesToLoad[a],l=s.name.toLowerCase(),u=void 0;if(s.correctName=l,o){var f=o[a];f.getAsEntry?u=f.getAsEntry():f.webkitGetAsEntry&&(u=f.webkitGetAsEntry())}u&&u.isDirectory?r.push(u):i.push(s)}if(r.length===0)this._processFiles(i),this._processReload();else for(var c={count:r.length},h=0,p=r;h<p.length;h++){var _=p[h];this._traverseFolder(_,i,c,function(){e._processFiles(i),c.count===0&&e._processReload()})}}},n.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},n.prototype.reload=function(){var t=this;this._sceneFileToLoad?(this._currentScene&&(de.errorsCount>0&&de.ClearLogCache(),this._engine.stopRenderLoop()),$t.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),$t.LoadAsync("file:",this._sceneFileToLoad,this._engine,function(e){t._progressCallback&&t._progressCallback(e)}).then(function(e){t._currentScene&&t._currentScene.dispose(),t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady(function(){t._engine.hideLoadingUI(),t._engine.runRenderLoop(function(){t.renderFunction()})})}).catch(function(e){t._engine.hideLoadingUI(),t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,e.message)})):de.Error("Please provide a valid .babylon file.")},n}(),Oa=function(){function n(t){t===void 0&&(t=0),this.priority=t}return n.prototype.getDescription=function(){return""},n.prototype.apply=function(t,e){return!0},n}(),zv=function(n){j(t,n);function t(e,i,r){e===void 0&&(e=0),i===void 0&&(i=1024),r===void 0&&(r=.5);var o=n.call(this,e)||this;return o.priority=e,o.maximumSize=i,o.step=r,o}return t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,i){for(var r=!0,o=0;o<e.textures.length;o++){var a=e.textures[o];if(!(!a.canRescale||a.getContext)){var s=a.getSize(),l=Math.max(s.width,s.height);l>this.maximumSize&&(a.scale(this.step),r=!1)}}return r},t}(Oa),NO=function(n){j(t,n);function t(e,i,r){e===void 0&&(e=0),i===void 0&&(i=2),r===void 0&&(r=.25);var o=n.call(this,e)||this;return o.priority=e,o.maximumScale=i,o.step=r,o._currentScale=-1,o._directionOffset=1,o}return t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,i){return this._currentScale===-1&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),this._directionOffset===1?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(Oa),Gv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,i){return e.shadowsEnabled=i.isInImprovementMode,!0},t}(Oa),Wv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,i){return e.postProcessesEnabled=i.isInImprovementMode,!0},t}(Oa),Hv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,i){return e.lensFlaresEnabled=i.isInImprovementMode,!0},t}(Oa),y5=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,i){return this.onApply?this.onApply(e,i):!0},t}(Oa),jv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,i){return e.particlesEnabled=i.isInImprovementMode,!0},t}(Oa),FO=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,i){return e.renderTargetsEnabled=i.isInImprovementMode,!0},t}(Oa),Xv=function(n){j(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._canBeMerged=function(i){if(!(i instanceof ne))return!1;var r=i;return!(r.isDisposed()||!r.isVisible||!r.isEnabled()||r.instances.length>0||r.skeleton||r.hasLODLevels)},e}return Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,r){for(var o=e.meshes.slice(0),a=o.length,s=0;s<a;s++){var l=new Array,u=o[s];if(this._canBeMerged(u)){l.push(u);for(var f=s+1;f<a;f++){var c=o[f];this._canBeMerged(c)&&c.material===u.material&&c.checkCollisions===u.checkCollisions&&(l.push(c),a--,o.splice(f,1),f--)}l.length<2||ne.MergeMeshes(l,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(r!=null?r&&h.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(Oa),BO=function(){function n(t,e){t===void 0&&(t=60),e===void 0&&(e=2e3),this.targetFrameRate=t,this.trackerDuration=e,this.optimizations=new Array}return n.prototype.addOptimization=function(t){return this.optimizations.push(t),this},n.prototype.addCustomOptimization=function(t,e,i){i===void 0&&(i=0);var r=new y5(i);return r.onApply=t,r.onGetDescription=e,this.optimizations.push(r),this},n.LowDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,1024)),e},n.ModerateDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,512)),i++,e.addOptimization(new FO(i)),i++,e.addOptimization(new NO(i,2)),e},n.HighDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,256)),i++,e.addOptimization(new FO(i)),i++,e.addOptimization(new NO(i,4)),e},n}(),L8=function(){function n(t,e,i,r){var o=this;if(i===void 0&&(i=!0),r===void 0&&(r=!1),this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new ie,this.onNewOptimizationAppliedObservable=new ie,this.onFailureObservable=new ie,e?this._options=e:this._options=new BO,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i)for(var a=0,s=0,l=this._options.optimizations;s<l.length;s++){var u=l[s];u.priority=a++}this._improvementMode=r,this._scene=t||pt.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(n.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(t){this._trackerDuration=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!1,configurable:!0}),n.prototype.stop=function(){this._isRunning=!1},n.prototype.reset=function(){this._currentPriorityLevel=0},n.prototype.start=function(){var t=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)}))},n.prototype._checkCurrentState=function(){var t=this;if(this._isRunning){var e=this._scene,i=this._options;if(this._currentFrameRate=Math.round(e.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate){this._isRunning=!1,this.onSuccessObservable.notifyObservers(this);return}for(var r=!0,o=!0,a=0;a<i.optimizations.length;a++){var s=i.optimizations[a];s.priority===this._currentPriorityLevel&&(o=!1,r=r&&s.apply(e,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(o){this._isRunning=!1,this.onFailureObservable.notifyObservers(this);return}r&&this._currentPriorityLevel++,e.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)})}},n.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},n.OptimizeAsync=function(t,e,i,r){var o=new n(t,e||BO.ModerateDegradationAllowed(),!1);return i&&o.onSuccessObservable.add(function(){i()}),r&&o.onFailureObservable.add(function(){r()}),o.start(),o},n}(),$d=[],Yb=function(n,t){$d[n.id]||n.doNotSerialize||(t.vertexData.push(n.serializeVerticeData()),$d[n.id]=!0)},FI=function(n,t){var e={},i=n._geometry;return i&&(n.getScene().getGeometryByID(i.id)||Yb(i,t.geometries)),n.serialize&&n.serialize(e),e},b5=function(n,t){if(n.delayLoadState===1||n.delayLoadState===0){if(n.material&&!n.material.doNotSerialize)if(n.material instanceof Go){if(t.multiMaterials=t.multiMaterials||[],t.materials=t.materials||[],!t.multiMaterials.some(function(s){return s.id===n.material.id})){t.multiMaterials.push(n.material.serialize());for(var e=function(s){s&&(t.materials.some(function(l){return l.id===s.id})||t.materials.push(s.serialize()))},i=0,r=n.material.subMaterials;i<r.length;i++){var o=r[i];e(o)}}}else t.materials=t.materials||[],t.materials.some(function(s){return s.id===n.material.id})||t.materials.push(n.material.serialize());var a=n._geometry;a&&(t.geometries||(t.geometries={},t.geometries.boxes=[],t.geometries.spheres=[],t.geometries.cylinders=[],t.geometries.toruses=[],t.geometries.grounds=[],t.geometries.planes=[],t.geometries.torusKnots=[],t.geometries.vertexData=[]),Yb(a,t.geometries)),n.skeleton&&!n.skeleton.doNotSerialize&&(t.skeletons=t.skeletons||[],t.skeletons.push(n.skeleton.serialize())),t.meshes=t.meshes||[],t.meshes.push(FI(n,t))}},VO=function(){function n(){}return n.ClearCache=function(){$d=[]},n.Serialize=function(t){var e={};if(n.ClearCache(),e.useDelayedTextureLoading=t.useDelayedTextureLoading,e.autoClear=t.autoClear,e.clearColor=t.clearColor.asArray(),e.ambientColor=t.ambientColor.asArray(),e.gravity=t.gravity.asArray(),e.collisionsEnabled=t.collisionsEnabled,t.fogMode&&t.fogMode!==0&&(e.fogMode=t.fogMode,e.fogColor=t.fogColor.asArray(),e.fogStart=t.fogStart,e.fogEnd=t.fogEnd,e.fogDensity=t.fogDensity),t.isPhysicsEnabled()){var i=t.getPhysicsEngine();i&&(e.physicsEnabled=!0,e.physicsGravity=i.gravity.asArray(),e.physicsEngine=i.getPhysicsPluginName())}t.metadata&&(e.metadata=t.metadata),e.morphTargetManagers=[];for(var r=0,o=t.meshes;r<o.length;r++){var a=o[r],s=a.morphTargetManager;s&&e.morphTargetManagers.push(s.serialize())}e.lights=[];var l,u;for(l=0;l<t.lights.length;l++)u=t.lights[l],u.doNotSerialize||e.lights.push(u.serialize());for(e.cameras=[],l=0;l<t.cameras.length;l++){var f=t.cameras[l];f.doNotSerialize||e.cameras.push(f.serialize())}if(t.activeCamera&&(e.activeCameraID=t.activeCamera.id),Be.AppendSerializedAnimations(t,e),t.animationGroups&&t.animationGroups.length>0){e.animationGroups=[];for(var c=0;c<t.animationGroups.length;c++){var h=t.animationGroups[c];e.animationGroups.push(h.serialize())}}if(t.reflectionProbes&&t.reflectionProbes.length>0)for(e.reflectionProbes=[],l=0;l<t.reflectionProbes.length;l++){var p=t.reflectionProbes[l];e.reflectionProbes.push(p.serialize())}e.materials=[],e.multiMaterials=[];var _;for(l=0;l<t.materials.length;l++)_=t.materials[l],_.doNotSerialize||e.materials.push(_.serialize());for(e.multiMaterials=[],l=0;l<t.multiMaterials.length;l++){var g=t.multiMaterials[l];e.multiMaterials.push(g.serialize())}for(t.environmentTexture&&(e.environmentTexture=t.environmentTexture.name),e.environmentIntensity=t.environmentIntensity,e.skeletons=[],l=0;l<t.skeletons.length;l++){var v=t.skeletons[l];v.doNotSerialize||e.skeletons.push(v.serialize())}for(e.transformNodes=[],l=0;l<t.transformNodes.length;l++)t.transformNodes[l].doNotSerialize||e.transformNodes.push(t.transformNodes[l].serialize());e.geometries={},e.geometries.boxes=[],e.geometries.spheres=[],e.geometries.cylinders=[],e.geometries.toruses=[],e.geometries.grounds=[],e.geometries.planes=[],e.geometries.torusKnots=[],e.geometries.vertexData=[],$d=[];var E=t.getGeometries();for(l=0;l<E.length;l++){var T=E[l];T.isReady()&&Yb(T,e.geometries)}for(e.meshes=[],l=0;l<t.meshes.length;l++){var a=t.meshes[l];if(a instanceof ne){var S=a;S.doNotSerialize||(S.delayLoadState===1||S.delayLoadState===0)&&e.meshes.push(FI(S,e))}}for(e.particleSystems=[],l=0;l<t.particleSystems.length;l++)e.particleSystems.push(t.particleSystems[l].serialize(!1));for(e.postProcesses=[],l=0;l<t.postProcesses.length;l++)e.postProcesses.push(t.postProcesses[l].serialize());t.actionManager&&(e.actions=t.actionManager.serialize("scene"));for(var C=0,O=t._serializableComponents;C<O.length;C++){var A=O[C];A.serialize(e)}return e},n.SerializeMesh=function(t,e,i){e===void 0&&(e=!1),i===void 0&&(i=!1);var r={};if(n.ClearCache(),t=t instanceof Array?t:[t],e||i)for(var o=0;o<t.length;++o)i&&t[o].getDescendants().forEach(function(a){a instanceof ne&&t.indexOf(a)<0&&!a.doNotSerialize&&t.push(a)}),e&&t[o].parent&&t.indexOf(t[o].parent)<0&&!t[o].parent.doNotSerialize&&t.push(t[o].parent);return t.forEach(function(a){b5(a,r)}),r},n}(),N8=function(){function n(){}return n.CreateResizedCopy=function(t,e,i,r){r===void 0&&(r=!0);var o=t.getScene(),a=o.getEngine(),s=new ji("resized"+t.name,{width:e,height:i},o,!t.noMipmap,!0,t._texture.type,!1,t.samplingMode,!1);s.wrapU=t.wrapU,s.wrapV=t.wrapV,s.uOffset=t.uOffset,s.vOffset=t.vOffset,s.uScale=t.uScale,s.vScale=t.vScale,s.uAng=t.uAng,s.vAng=t.vAng,s.wAng=t.wAng,s.coordinatesIndex=t.coordinatesIndex,s.level=t.level,s.anisotropicFilteringLevel=t.anisotropicFilteringLevel,s._texture.isReady=!1,t.wrapU=he.CLAMP_ADDRESSMODE,t.wrapV=he.CLAMP_ADDRESSMODE;var l=new rl("pass",1,null,r?he.BILINEAR_SAMPLINGMODE:he.NEAREST_SAMPLINGMODE,a,!1,0);return l.getEffect().executeWhenCompiled(function(){l.onApply=function(f){f.setTexture("textureSampler",t)};var u=s.getInternalTexture();u&&(o.postProcessManager.directRender([l],u),a.unBindFramebuffer(u),s.disposeFramebufferObjects(),l.dispose(),u.isReady=!0)}),s},n}(),F8=function(){function n(t,e){if(e===void 0&&(e=null),!n.IsSupported(t))throw"Your browser does not support recording so far.";var i=t.getRenderingCanvas();if(!i)throw"The babylon engine must have a canvas to be recorded";this._canvas=i,this._canvas.isRecording=!1,this._options=Ot(Ot({},n._defaultOptions),e);var r=this._canvas.captureStream(this._options.fps);if(this._options.audioTracks)for(var o=0,a=this._options.audioTracks;o<a.length;o++){var s=a[o];r.addTrack(s)}this._mediaRecorder=new MediaRecorder(r,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return n.IsSupported=function(t){var e=t.getRenderingCanvas();return!!e&&typeof e.captureStream=="function"},Object.defineProperty(n.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!1,configurable:!0}),n.prototype.stopRecording=function(){!this._canvas||!this._mediaRecorder||this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},n.prototype.startRecording=function(t,e){var i=this;if(t===void 0&&(t="babylonjs.webm"),e===void 0&&(e=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return e>0&&setTimeout(function(){i.stopRecording()},e*1e3),this._fileName=t,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(r,o){i._resolve=r,i._reject=o})},n.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},n.prototype._handleDataAvailable=function(t){t.data.size>0&&this._recordedChunks.push(t.data)},n.prototype._handleError=function(t){if(this.stopRecording(),this._reject)this._reject(t.error);else throw new t.error},n.prototype._handleStop=function(){this.stopRecording();var t=new Blob(this._recordedChunks);this._resolve&&this._resolve(t),window.URL.createObjectURL(t),this._fileName&&Ee.Download(t,this._fileName)},n._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},n}(),vp=function(){function n(){}return n.CreateScreenshot=function(t,e,i,r,o){o===void 0&&(o="image/png");var a=n._getScreenshotSize(t,e,i),s=a.height,l=a.width;if(!(s&&l)){de.Error("Invalid 'size' parameter !");return}Ee._ScreenshotCanvas||(Ee._ScreenshotCanvas=document.createElement("canvas")),Ee._ScreenshotCanvas.width=l,Ee._ScreenshotCanvas.height=s;var u=Ee._ScreenshotCanvas.getContext("2d"),f=t.getRenderWidth()/t.getRenderHeight(),c=l,h=c/f;h>s&&(h=s,c=h*f);var p=Math.max(0,l-c)/2,_=Math.max(0,s-h)/2,g=t.getRenderingCanvas();u&&g&&u.drawImage(g,p,_,c,h),Ee.EncodeScreenshotCanvasData(r,o)},n.CreateScreenshotAsync=function(t,e,i,r){return r===void 0&&(r="image/png"),new Promise(function(o,a){n.CreateScreenshot(t,e,i,function(s){typeof s<"u"?o(s):a(new Error("Data is undefined"))},r)})},n.CreateScreenshotUsingRenderTarget=function(t,e,i,r,o,a,s,l,u,f){o===void 0&&(o="image/png"),a===void 0&&(a=1),s===void 0&&(s=!1),u===void 0&&(u=!1),f===void 0&&(f=!1);var c=n._getScreenshotSize(t,e,i),h=c.height,p=c.width,_={width:p,height:h};if(!(h&&p)){de.Error("Invalid 'size' parameter !");return}var g=t.getRenderingCanvas();if(!g){de.Error("No rendering canvas found !");return}var v={width:g.width,height:g.height};t.setSize(p,h);var E=e.getScene(),T=null,S=E.activeCameras;(E.activeCamera!==e||E.activeCameras&&E.activeCameras.length)&&(T=E.activeCamera,E.activeCamera=e),E.render();var C=new ji("screenShot",_,E,!1,!1,0,!1,he.NEAREST_SAMPLINGMODE,void 0,f);C.renderList=null,C.samples=a,C.renderSprites=u,C.onAfterRenderObservable.add(function(){Ee.DumpFramebuffer(p,h,t,r,o,l)});var O=function(){E.incrementRenderId(),E.resetCachedMaterial(),C.render(!0),C.dispose(),T&&(E.activeCamera=T),E.activeCameras=S,t.setSize(v.width,v.height),e.getProjectionMatrix(!0)};if(s){var A=new gp("antialiasing",1,E.activeCamera);C.addPostProcess(A),A.getEffect().isReady()?O():A.getEffect().onCompiled=function(){O()}}else O()},n.CreateScreenshotUsingRenderTargetAsync=function(t,e,i,r,o,a,s,l){return r===void 0&&(r="image/png"),o===void 0&&(o=1),a===void 0&&(a=!1),l===void 0&&(l=!1),new Promise(function(u,f){n.CreateScreenshotUsingRenderTarget(t,e,i,function(c){typeof c<"u"?u(c):f(new Error("Data is undefined"))},r,o,a,s,l)})},n._getScreenshotSize=function(t,e,i){var r=0,o=0;if(typeof i=="object"){var a=i.precision?Math.abs(i.precision):1;i.width&&i.height?(r=i.height*a,o=i.width*a):i.width&&!i.height?(o=i.width*a,r=Math.round(o/t.getAspectRatio(e))):i.height&&!i.width?(r=i.height*a,o=Math.round(r*t.getAspectRatio(e))):(o=Math.round(t.getRenderWidth()*a),r=Math.round(o/t.getAspectRatio(e)))}else isNaN(i)||(r=i,o=i);return o&&(o=Math.floor(o)),r&&(r=Math.floor(r)),{height:r|0,width:o|0}},n}();Ee.CreateScreenshot=vp.CreateScreenshot;Ee.CreateScreenshotAsync=vp.CreateScreenshotAsync;Ee.CreateScreenshotUsingRenderTarget=vp.CreateScreenshotUsingRenderTarget;Ee.CreateScreenshotUsingRenderTargetAsync=vp.CreateScreenshotUsingRenderTargetAsync;var UO;(function(n){n[n.Checkbox=0]="Checkbox",n[n.Slider=1]="Slider",n[n.Vector3=2]="Vector3",n[n.Quaternion=3]="Quaternion",n[n.Color3=4]="Color3",n[n.String=5]="String"})(UO||(UO={}));var Td=function(){function n(t){this.byteOffset=0,this.buffer=t}return n.prototype.loadAsync=function(t){var e=this;return this.buffer.readAsync(this.byteOffset,t).then(function(i){e._dataView=new DataView(i.buffer,i.byteOffset,i.byteLength),e._dataByteOffset=0})},n.prototype.readUint32=function(){var t=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,t},n.prototype.readUint8Array=function(t){var e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,t);return this._dataByteOffset+=t,this.byteOffset+=t,e},n.prototype.readString=function(t){return Oi.Decode(this.readUint8Array(t))},n.prototype.skipBytes=function(t){this._dataByteOffset+=t,this.byteOffset+=t},n}(),B8=function(){function n(){}return n._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch{var t={};return{getItem:function(i){var r=t[i];return r===void 0?null:r},setItem:function(i,r){t[i]=r}}}},n.ReadString=function(t,e){var i=this._Storage.getItem(t);return i!==null?i:e},n.WriteString=function(t,e){this._Storage.setItem(t,e)},n.ReadBoolean=function(t,e){var i=this._Storage.getItem(t);return i!==null?i==="true":e},n.WriteBoolean=function(t,e){this._Storage.setItem(t,e?"true":"false")},n.ReadNumber=function(t,e){var i=this._Storage.getItem(t);return i!==null?parseFloat(i):e},n.WriteNumber=function(t,e){this._Storage.setItem(t,e.toString())},n._Storage=n._GetStorage(),n}(),V8=function(){function n(){this._trackedScene=null}return n.prototype.track=function(t){this._trackedScene=t,this._savedJSON=VO.Serialize(t)},n.prototype.getDelta=function(){if(!this._trackedScene)return null;var t=VO.Serialize(this._trackedScene),e={};for(var i in t)this._compareCollections(i,this._savedJSON[i],t[i],e);return e},n.prototype._compareArray=function(t,e,i,r){if(e.length===0&&i.length===0)return!0;if(e.length&&!isNaN(e[0])||i.length&&!isNaN(i[0])){if(e.length!==i.length)return!1;if(e.length===0)return!0;for(var o=0;o<e.length;o++)if(e[o]!==i[o])return r[t]=i,!1;return!0}for(var a=[],s=function(){var c=e[o],h=c.uniqueId;a.push(h);var p=i.filter(function(v){return v.uniqueId===h});if(p.length){var _=p[0],g={};l._compareObjects(c,_,g)||(r[t]||(r[t]=[]),g.__state={id:_.id||_.name},r[t].push(g))}else{var g={__state:{deleteId:c.id||c.name}};r[t].push(g)}},l=this,o=0;o<e.length;o++)s();for(var o=0;o<i.length;o++){var u=i[o],f=u.uniqueId;a.indexOf(f)===-1&&(r[t]||(r[t]=[]),r[t].push(u))}return!0},n.prototype._compareObjects=function(t,e,i){var r=!1;for(var o in t)if(t.hasOwnProperty(o)){var a=t[o],s=e[o],l=!1;Array.isArray(a)?l=JSON.stringify(a)!==JSON.stringify(s):(!isNaN(a)||Object.prototype.toString.call(a)=="[object String]")&&(l=a!==s),l&&(r=!0,i[o]=s)}return!r},n.prototype._compareCollections=function(t,e,i,r){if(e!==i&&e&&i){if(Array.isArray(e)&&Array.isArray(i)){if(this._compareArray(t,e,i,r))return}else if(typeof e=="object"&&typeof i=="object"){var o={};this._compareObjects(e,i,o)||(r[t]=o);return}}},n.GetShadowGeneratorById=function(t,e){for(var i=t.lights.map(function(s){return s.getShadowGenerator()}),r=0,o=i;r<o.length;r++){var a=o[r];if(a&&a.id===e)return a}return null},n.ApplyDelta=function(t,e){var i=this;typeof t=="string"&&(t=JSON.parse(t));var r=e;for(var o in t){var a=t[o],s=r[o];if(Array.isArray(s)||o==="shadowGenerators")switch(o){case"cameras":this._ApplyDeltaForEntity(a,e,e.getCameraByID.bind(e),function(l){return dt.Parse(l,e)});break;case"lights":this._ApplyDeltaForEntity(a,e,e.getLightByID.bind(e),function(l){return Wr.Parse(l,e)});break;case"shadowGenerators":this._ApplyDeltaForEntity(a,e,function(l){return i.GetShadowGeneratorById(e,l)},function(l){return zn.Parse(l,e)});break;case"meshes":this._ApplyDeltaForEntity(a,e,e.getMeshByID.bind(e),function(l){return ne.Parse(l,e,"")});break;case"skeletons":this._ApplyDeltaForEntity(a,e,e.getSkeletonById.bind(e),function(l){return du.Parse(l,e)});break;case"materials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(l){return gt.Parse(l,e,"")});break;case"multiMaterials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(l){return Go.Parse(l,e,"")});break;case"transformNodes":this._ApplyDeltaForEntity(a,e,e.getTransformNodeByID.bind(e),function(l){return nr.Parse(l,e,"")});break;case"particleSystems":this._ApplyDeltaForEntity(a,e,e.getParticleSystemByID.bind(e),function(l){return vr.Parse(l,e,"")});break;case"morphTargetManagers":this._ApplyDeltaForEntity(a,e,e.getMorphTargetById.bind(e),function(l){return _p.Parse(l,e)});break;case"postProcesses":this._ApplyDeltaForEntity(a,e,e.getPostProcessByName.bind(e),function(l){return _t.Parse(l,e,"")});break}else isNaN(s)?s.fromArray&&s.fromArray(a):r[o]=a}},n._ApplyPropertiesToEntity=function(t,e){for(var i in t){var r=t[i],o=e[i];o!==void 0&&(!isNaN(o)||Array.isArray(o)?e[i]=r:o.fromArray&&o.fromArray(r))}},n._ApplyDeltaForEntity=function(t,e,i,r){for(var o=0,a=t;o<a.length;o++){var s=a[o];if(s.__state&&s.__state.id!==void 0){var l=i(s.__state.id);l&&this._ApplyPropertiesToEntity(s,l)}else if(s.__state&&s.__state.deleteId!==void 0){var u=i(s.__state.deleteId);u==null||u.dispose()}else r(s)}},n}(),hu;(function(n){var t=function(){function i(r,o,a,s){o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),o=o??function(){return 1},a=a??function(){return 1},s=s??function(c,h){return c===h?0:1},this._characterToIdx=new Map,this._insertionCosts=new Array(r.length),this._deletionCosts=new Array(r.length),this._substitutionCosts=new Array(r.length);for(var l,u=0;u<r.length;++u){l=r[u],this._characterToIdx.set(l,u),this._insertionCosts[u]=o(l),this._deletionCosts[u]=a(l),this._substitutionCosts[u]=new Array(r.length);for(var f=u;f<r.length;++f)this._substitutionCosts[u][f]=s(l,r[f])}}return i.prototype.serialize=function(){var r={},o=new Array(this._characterToIdx.size);return this._characterToIdx.forEach(function(a,s){o[a]=s}),r.characters=o,r.insertionCosts=this._insertionCosts,r.deletionCosts=this._deletionCosts,r.substitutionCosts=this._substitutionCosts,JSON.stringify(r)},i.Deserialize=function(r){var o=JSON.parse(r),a=new i(o.characters);return a._insertionCosts=o.insertionCosts,a._deletionCosts=o.deletionCosts,a._substitutionCosts=o.substitutionCosts,a},i.prototype.getCharacterIdx=function(r){return this._characterToIdx.get(r)},i.prototype.getInsertionCost=function(r){return this._insertionCosts[r]},i.prototype.getDeletionCost=function(r){return this._deletionCosts[r]},i.prototype.getSubstitutionCost=function(r,o){var a=Math.min(r,o),s=Math.max(r,o);return this._substitutionCosts[a][s]},i}();n.Alphabet=t;var e=function(){function i(r,o){var a=this;if(r.length>i.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+i.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=o,this._characters=r.map(function(s){return a._alphabet.getCharacterIdx(s)})}return i.prototype.serialize=function(){return JSON.stringify(this._characters)},i.Deserialize=function(r,o){var a=new i([],o);return a._characters=JSON.parse(r),a},i.prototype.distance=function(r){return i._distance(this,r)},i._distance=function(r,o){var a=r._alphabet;if(a!==o._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var s=r._characters,l=o._characters,u=s.length,f=l.length,c=i._costMatrix;c[0][0]=0;for(var h=0;h<u;++h)c[h+1][0]=c[h][0]+a.getInsertionCost(s[h]);for(var h=0;h<f;++h)c[0][h+1]=c[0][h]+a.getInsertionCost(l[h]);for(var p=0;p<u;++p)for(var _=0;_<f;++_)i._insertionCost=c[p+1][_]+a.getInsertionCost(l[_]),i._deletionCost=c[p][_+1]+a.getDeletionCost(s[p]),i._substitutionCost=c[p][_]+a.getSubstitutionCost(s[p],l[_]),c[p+1][_+1]=Math.min(i._insertionCost,i._deletionCost,i._substitutionCost);return c[u][f]},i.MAX_SEQUENCE_LENGTH=256,i._costMatrix=jM(Array(i.MAX_SEQUENCE_LENGTH+1)).map(function(r){return new Array(i.MAX_SEQUENCE_LENGTH+1)}),i}();n.Sequence=e})(hu||(hu={}));var U8=function(){function n(t){t===void 0&&(t=.01),this._points=[],this._segmentLength=t}return n.prototype.serialize=function(){return JSON.stringify(this)},n.Deserialize=function(t){var e=JSON.parse(t),i=new n(e._segmentLength);return i._points=e._points.map(function(r){return new y(r._x,r._y,r._z)}),i},n.prototype.getLength=function(){return this._points.length*this._segmentLength},n.prototype.add=function(t){var e=this,i=this._points.length;if(i===0)this._points.push(t.clone());else for(var r=function(){return e._segmentLength/y.Distance(e._points[i-1],t)},o=r();o<=1;o=r()){var a=this._points[i-1].scale(1-o);t.scaleAndAddToRef(o,a),this._points.push(a),++i}},n.prototype.resampleAtTargetResolution=function(t){var e=new n(this.getLength()/t);return this._points.forEach(function(i){e.add(i)}),e},n.prototype.tokenize=function(t){for(var e=[],i=new y,r=2;r<this._points.length;++r)n._transformSegmentDirToRef(this._points[r-2],this._points[r-1],this._points[r],i)&&e.push(n._tokenizeSegment(i,t));return e},n._transformSegmentDirToRef=function(t,e,i,r){var o=.98;return e.subtractToRef(t,n._forwardDir),n._forwardDir.normalize(),e.scaleToRef(-1,n._inverseFromVec),n._inverseFromVec.normalize(),Math.abs(y.Dot(n._forwardDir,n._inverseFromVec))>o?!1:(y.CrossToRef(n._forwardDir,n._inverseFromVec,n._upDir),n._upDir.normalize(),te.LookAtLHToRef(t,e,n._upDir,n._lookMatrix),i.subtractToRef(e,n._fromToVec),n._fromToVec.normalize(),y.TransformNormalToRef(n._fromToVec,n._lookMatrix,r),!0)},n._tokenizeSegment=function(t,e){n._bestMatch=0,n._score=y.Dot(t,e[0]),n._bestScore=n._score;for(var i=1;i<e.length;++i)n._score=y.Dot(t,e[i]),n._score>n._bestScore&&(n._bestMatch=i,n._bestScore=n._score);return n._bestMatch},n._forwardDir=new y,n._inverseFromVec=new y,n._upDir=new y,n._fromToVec=new y,n._lookMatrix=new te,n}(),kO=function(){function n(t){this.chars=new Array(t)}return n.Generate=function(t,e,i,r,o){t===void 0&&(t=64),e===void 0&&(e=256),i===void 0&&(i=.1),r===void 0&&(r=.001),o===void 0&&(o=[]);for(var a=.001,s=a*a,l=new n(t),u=0;u<t;++u)l.chars[u]=new y(Math.random()-.5,Math.random()-.5,Math.random()-.5),l.chars[u].normalize();for(var u=0;u<o.length;++u)l.chars[u].copyFrom(o[u]);for(var f,c,h=new y,p=new y,_=function(E,T,S){return(1-S)*E+S*T},g=0;g<e;++g){f=_(i,r,g/(e-1));for(var v=function(E){h.copyFromFloats(0,0,0),l.chars.forEach(function(T){l.chars[E].subtractToRef(T,p),c=p.lengthSquared(),c>s&&p.scaleAndAddToRef(1/(p.lengthSquared()*c),h)}),h.scaleInPlace(f),l.chars[E].addInPlace(h),l.chars[E].normalize()},u=o.length;u<l.chars.length;++u)v(u)}return l},n.prototype.serialize=function(){return JSON.stringify(this.chars)},n.Deserialize=function(t){for(var e=JSON.parse(t),i=new n(e.length),r=0;r<e.length;++r)i.chars[r]=new y(e[r]._x,e[r]._y,e[r]._z);return i},n}(),Ny=function(){function n(){this._sequences=[]}return n.prototype.serialize=function(){return JSON.stringify(this._sequences.map(function(t){return t.serialize()}))},n.Deserialize=function(t,e){var i=new n;return i._sequences=JSON.parse(t).map(function(r){return hu.Sequence.Deserialize(r,e)}),i},n.CreateFromTrajectory=function(t,e,i){return n.CreateFromTokenizationPyramid(n._getTokenizationPyramid(t,e),i)},n.CreateFromTokenizationPyramid=function(t,e){var i=new n;return i._sequences=t.map(function(r){return new hu.Sequence(r,e)}),i},n._getTokenizationPyramid=function(t,e,i){i===void 0&&(i=n.FINEST_DESCRIPTOR_RESOLUTION);for(var r=[],o=i;o>4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(e.chars));return r},n.prototype.distance=function(t){for(var e=0,i,r=0;r<this._sequences.length;++r)i=Math.pow(2,r),e+=i*this._sequences[r].distance(t._sequences[r]);return e},n.FINEST_DESCRIPTOR_RESOLUTION=32,n}(),zO=function(){function n(t){t===void 0&&(t=[]),this._descriptors=t,this._centroidIdx=-1,this._averageDistance=0,this._refreshDescription()}return n.prototype.serialize=function(){var t={};return t.descriptors=this._descriptors.map(function(e){return e.serialize()}),t.centroidIdx=this._centroidIdx,t.averageDistance=this._averageDistance,JSON.stringify(t)},n.Deserialize=function(t,e){var i=JSON.parse(t),r=new n;return r._descriptors=i.descriptors.map(function(o){return Ny.Deserialize(o,e)}),r._centroidIdx=i.centroidIdx,r._averageDistance=i.averageDistance,r},n.prototype.add=function(t){this._descriptors.push(t),this._refreshDescription()},n.prototype.getMatchCost=function(t){return t.distance(this._descriptors[this._centroidIdx])/this._averageDistance},n.prototype.getMatchMinimumDistance=function(t){return Math.min.apply(Math,this._descriptors.map(function(e){return e.distance(t)}))},n.prototype._refreshDescription=function(){var t=this;this._centroidIdx=-1;for(var e,i=this._descriptors.map(function(o){return e=0,t._descriptors.forEach(function(a){e+=o.distance(a)}),e}),r=0;r<i.length;++r)(this._centroidIdx<0||i[r]<i[this._centroidIdx])&&(this._centroidIdx=r);this._averageDistance=0,this._descriptors.forEach(function(o){t._averageDistance+=o.distance(t._descriptors[t._centroidIdx])}),this._descriptors.length>0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,n.MIN_AVERAGE_DISTANCE))},n.MIN_AVERAGE_DISTANCE=1,n}(),k8=function(){function n(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return n.prototype.serialize=function(){var t={};return t.maximumAllowableMatchCost=this._maximumAllowableMatchCost,t.vector3Alphabet=this._vector3Alphabet.serialize(),t.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),t.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach(function(e,i){t.nameToDescribedTrajectory.push(i),t.nameToDescribedTrajectory.push(e.serialize())}),JSON.stringify(t)},n.Deserialize=function(t){var e=JSON.parse(t),i=new n;i._maximumAllowableMatchCost=e.maximumAllowableMatchCost,i._vector3Alphabet=kO.Deserialize(e.vector3Alphabet),i._levenshteinAlphabet=hu.Alphabet.Deserialize(e.levenshteinAlphabet);for(var r=0;r<e.nameToDescribedTrajectory.length;r+=2)i._nameToDescribedTrajectory.set(e.nameToDescribedTrajectory[r],zO.Deserialize(e.nameToDescribedTrajectory[r+1],i._levenshteinAlphabet));return i},n.Generate=function(){for(var t=kO.Generate(64,256,.1,.001,[y.Forward()]),e=new Array(t.chars.length),i=0;i<e.length;++i)e[i]=i;var r=new hu.Alphabet(e,function(a){return a===0?0:1},function(a){return a===0?0:1},function(a,s){return Math.min(1-y.Dot(t.chars[a],t.chars[s]),1)}),o=new n;return o._vector3Alphabet=t,o._levenshteinAlphabet=r,o},n.prototype.addTrajectoryToClassification=function(t,e){this._nameToDescribedTrajectory.has(e)||this._nameToDescribedTrajectory.set(e,new zO),this._nameToDescribedTrajectory.get(e).add(Ny.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet))},n.prototype.deleteClassification=function(t){return this._nameToDescribedTrajectory.delete(t)},n.prototype.classifyTrajectory=function(t){var e=this,i=Ny.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet),r=[];if(this._nameToDescribedTrajectory.forEach(function(u,f){u.getMatchCost(i)<e._maximumAllowableMatchCost&&r.push(f)}),r.length===0)return null;for(var o=0,a=this._nameToDescribedTrajectory.get(r[o]).getMatchMinimumDistance(i),s,l=0;l<r.length;++l)s=this._nameToDescribedTrajectory.get(r[l]).getMatchMinimumDistance(i),s<a&&(a=s,o=l);return r[o]},n}(),Yv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r._direction=new y(0,0,-1),r._mat=new te,r._onSelectEnabled=!1,r._origin=new y(0,0,0),r.lastNativeXRHitResults=[],r.onHitTestResultObservable=new ie,r._onHitTestResults=function(o){var a=o.map(function(s){var l=te.FromArray(s.hitMatrix);return r._xrSessionManager.scene.useRightHandedSystem||l.toggleModelMatrixHandInPlace(),r.options.worldParentNode&&l.multiplyToRef(r.options.worldParentNode.getWorldMatrix(),l),{xrHitResult:s,transformationMatrix:l}});r.lastNativeXRHitResults=o,r.onHitTestResultObservable.notifyObservers(a)},r._onSelect=function(o){r._onSelectEnabled&&t.XRHitTestWithSelectEvent(o,r._xrSessionManager.referenceSpace)},r.xrNativeFeatureName="hit-test",Ee.Warn("A newer version of this plugin is available"),r}return t.XRHitTestWithRay=function(e,i,r,o){return e.requestHitTest(i,r).then(function(a){var s=o||function(l){return!!l.hitMatrix};return a.filter(s)})},t.XRHitTestWithSelectEvent=function(e,i){var r=e.frame.getPose(e.inputSource.targetRaySpace,i);if(!r)return Promise.resolve([]);var o=new XRRay(r.transform);return this.XRHitTestWithRay(e.frame.session,o,i)},t.prototype.attach=function(){return n.prototype.attach.call(this)?(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0):!1},t.prototype.detach=function(){return n.prototype.detach.call(this)?(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(!(!this.attached||this.options.testOnPointerDownOnly)){var i=e.getViewerPose(this._xrSessionManager.referenceSpace);if(i){te.FromArrayToRef(i.transform.matrix,0,this._mat),y.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),y.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var r=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,r,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=Ko.HIT_TEST,t.Version=1,t}(qo);Mo.AddWebXRFeature(Yv.Name,function(n,t){return function(){return new Yv(n,t)}},Yv.Version,!1);var E5=0,Kv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r._options=i,r._lastFrameDetected=new Set,r._trackedAnchors=[],r._futureAnchors=[],r.onAnchorAddedObservable=new ie,r.onAnchorRemovedObservable=new ie,r.onAnchorUpdatedObservable=new ie,r._tmpVector=new y,r._tmpQuaternion=new Re,r.xrNativeFeatureName="anchors",r}return Object.defineProperty(t.prototype,"referenceSpaceForFrameAnchors",{set:function(e){this._referenceSpaceForFrameAnchors=e},enumerable:!1,configurable:!0}),t.prototype._populateTmpTransformation=function(e,i){return this._tmpVector.copyFrom(e),this._tmpQuaternion.copyFrom(i),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpVector.z*=-1,this._tmpQuaternion.z*=-1,this._tmpQuaternion.w*=-1),{position:this._tmpVector,rotationQuaternion:this._tmpQuaternion}},t.prototype.addAnchorPointUsingHitTestResultAsync=function(e,i,r){return i===void 0&&(i=new y),r===void 0&&(r=new Re),eu(this,void 0,void 0,function(){var o,a,s,l=this;return tu(this,function(u){switch(u.label){case 0:if(this._populateTmpTransformation(i,r),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),e.xrHitResult.createAnchor)return[3,1];throw this.detach(),new Error("Anchors not enabled in this environment/browser");case 1:return u.trys.push([1,3,,4]),[4,e.xrHitResult.createAnchor(o)];case 2:return a=u.sent(),[2,new Promise(function(f,c){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!0,xrTransformation:o,resolve:f,reject:c})})];case 3:throw s=u.sent(),new Error(s);case 4:return[2]}})})},t.prototype.addAnchorAtPositionAndRotationAsync=function(e,i,r){return i===void 0&&(i=new Re),r===void 0&&(r=!1),eu(this,void 0,void 0,function(){var o,a,s,l=this;return tu(this,function(u){switch(u.label){case 0:return this._populateTmpTransformation(e,i),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),r&&this.attached&&this._xrSessionManager.currentFrame?[4,this._createAnchorAtTransformation(o,this._xrSessionManager.currentFrame)]:[3,2];case 1:return s=u.sent(),[3,3];case 2:s=void 0,u.label=3;case 3:return a=s,[2,new Promise(function(f,c){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!1,xrTransformation:o,resolve:f,reject:c})})]}})})},Object.defineProperty(t.prototype,"anchors",{get:function(){return this._trackedAnchors},enumerable:!1,configurable:!0}),t.prototype.detach=function(){if(!n.prototype.detach.call(this))return!1;if(!this._options.doNotRemoveAnchorsOnSessionEnded)for(;this._trackedAnchors.length;){var e=this._trackedAnchors.pop();if(e){try{e.remove()}catch{}this.onAnchorRemovedObservable.notifyObservers(e)}}return!0},t.prototype.dispose=function(){this._futureAnchors.length=0,n.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||!e)){var r=e.trackedAnchors;if(r){var o=this._trackedAnchors.filter(function(s){return!r.has(s.xrAnchor)}).map(function(s){var l=i._trackedAnchors.indexOf(s);return l}),a=0;o.forEach(function(s){var l=i._trackedAnchors.splice(s-a,1)[0];i.onAnchorRemovedObservable.notifyObservers(l),a++}),r.forEach(function(s){if(i._lastFrameDetected.has(s)){var h=i._findIndexInAnchorArray(s),u=i._trackedAnchors[h];try{i._updateAnchorWithXRFrame(s,u,e),u.attachedNode&&(u.attachedNode.rotationQuaternion=u.attachedNode.rotationQuaternion||new Re,u.transformationMatrix.decompose(u.attachedNode.scaling,u.attachedNode.rotationQuaternion,u.attachedNode.position)),i.onAnchorUpdatedObservable.notifyObservers(u)}catch{Ee.Warn("Anchor could not be updated")}}else{var l={id:E5++,xrAnchor:s,remove:s.delete},u=i._updateAnchorWithXRFrame(s,l,e);i._trackedAnchors.push(u),i.onAnchorAddedObservable.notifyObservers(u);var f=i._futureAnchors.filter(function(p){return p.nativeAnchor===s}),c=f[0];c&&(c.resolve(u),c.resolved=!0)}}),this._lastFrameDetected=r}this._futureAnchors.forEach(function(s){!s.resolved&&!s.submitted&&(i._createAnchorAtTransformation(s.xrTransformation,e).then(function(l){s.nativeAnchor=l},function(l){s.resolved=!0,s.reject(l)}),s.submitted=!0)})}},t.prototype._findIndexInAnchorArray=function(e){for(var i=0;i<this._trackedAnchors.length;++i)if(this._trackedAnchors[i].xrAnchor===e)return i;return-1},t.prototype._updateAnchorWithXRFrame=function(e,i,r){var o=r.getPose(e.anchorSpace,this._xrSessionManager.referenceSpace);if(o){var a=i.transformationMatrix||new te;te.FromArrayToRef(o.transform.matrix,0,a),this._xrSessionManager.scene.useRightHandedSystem||a.toggleModelMatrixHandInPlace(),i.transformationMatrix=a,this._options.worldParentNode&&a.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),a)}return i},t.prototype._createAnchorAtTransformation=function(e,i){var r;return eu(this,void 0,void 0,function(){return tu(this,function(o){if(i.createAnchor)try{return[2,i.createAnchor(e,(r=this._referenceSpaceForFrameAnchors)!==null&&r!==void 0?r:this._xrSessionManager.referenceSpace)]}catch(a){throw new Error(a)}else throw this.detach(),new Error("Anchors are not enabled in your browser");return[2]})})},t.Name=Ko.ANCHOR_SYSTEM,t.Version=1,t}(qo);Mo.AddWebXRFeature(Kv.Name,function(n,t){return function(){return new Kv(n,t)}},Kv.Version);var T5=0,qv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r._options=i,r._detectedPlanes=[],r._enabled=!1,r._lastFrameDetected=new Set,r.onPlaneAddedObservable=new ie,r.onPlaneRemovedObservable=new ie,r.onPlaneUpdatedObservable=new ie,r.xrNativeFeatureName="plane-detection",r._xrSessionManager.session?r._init():r._xrSessionManager.onXRSessionInit.addOnce(function(){r._init()}),r}return t.prototype.detach=function(){if(!n.prototype.detach.call(this))return!1;if(!this._options.doNotRemovePlanesOnSessionEnded)for(;this._detectedPlanes.length;){var e=this._detectedPlanes.pop();e&&this.onPlaneRemovedObservable.notifyObservers(e)}return!0},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onPlaneAddedObservable.clear(),this.onPlaneRemovedObservable.clear(),this.onPlaneUpdatedObservable.clear()},t.prototype.isCompatible=function(){return typeof XRPlane<"u"},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||!this._enabled||!e)){var r=e.worldInformation.detectedPlanes;if(r){var o=this._detectedPlanes.filter(function(s){return!r.has(s.xrPlane)}).map(function(s){return i._detectedPlanes.indexOf(s)}),a=0;o.forEach(function(s){var l=i._detectedPlanes.splice(s-a,1)[0];i.onPlaneRemovedObservable.notifyObservers(l),a++}),r.forEach(function(s){if(i._lastFrameDetected.has(s)){if(s.lastChangedTime===i._xrSessionManager.currentTimestamp){var f=i.findIndexInPlaneArray(s),u=i._detectedPlanes[f];i._updatePlaneWithXRPlane(s,u,e),i.onPlaneUpdatedObservable.notifyObservers(u)}}else{var l={id:T5++,xrPlane:s,polygonDefinition:[]},u=i._updatePlaneWithXRPlane(s,l,e);i._detectedPlanes.push(u),i.onPlaneAddedObservable.notifyObservers(u)}}),this._lastFrameDetected=r}}},t.prototype._init=function(){var e=this,i,r,o=function(){e._enabled=!0,e._detectedPlanes.length&&(e._detectedPlanes.length=0)};if(!this._xrSessionManager.session.updateWorldTrackingState){var a=(r=(i=this._xrSessionManager.session.worldTrackingState)===null||i===void 0?void 0:i.planeDetectionState)===null||r===void 0?void 0:r.enabled;a&&o();return}this._xrSessionManager.session.updateWorldTrackingState({planeDetectionState:{enabled:!0}}),o()},t.prototype._updatePlaneWithXRPlane=function(e,i,r){var o=this;i.polygonDefinition=e.polygon.map(function(l){var u=o._xrSessionManager.scene.useRightHandedSystem?1:-1;return new y(l.x,l.y,l.z*u)});var a=r.getPose(e.planeSpace,this._xrSessionManager.referenceSpace);if(a){var s=i.transformationMatrix||new te;te.FromArrayToRef(a.transform.matrix,0,s),this._xrSessionManager.scene.useRightHandedSystem||s.toggleModelMatrixHandInPlace(),i.transformationMatrix=s,this._options.worldParentNode&&s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),s)}return i},t.prototype.findIndexInPlaneArray=function(e){for(var i=0;i<this._detectedPlanes.length;++i)if(this._detectedPlanes[i].xrPlane===e)return i;return-1},t.Name=Ko.PLANE_DETECTION,t.Version=1,t}(qo);Mo.AddWebXRFeature(qv.Name,function(n,t){return function(){return new qv(n,t)}},qv.Version);var Qv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r.onBackgroundStateChangedObservable=new ie,r}return t.prototype.attach=function(){return this._setBackgroundState(!1),n.prototype.attach.call(this)},t.prototype.detach=function(){return this._setBackgroundState(!0),n.prototype.detach.call(this)},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onBackgroundStateChangedObservable.clear()},t.prototype._onXRFrame=function(e){},t.prototype._setBackgroundState=function(e){var i=this._xrSessionManager.scene;if(!this.options.ignoreEnvironmentHelper)if(this.options.environmentHelperRemovalFlags){if(this.options.environmentHelperRemovalFlags.skyBox){var r=i.getMeshByName("BackgroundSkybox");r&&r.setEnabled(e)}if(this.options.environmentHelperRemovalFlags.ground){var o=i.getMeshByName("BackgroundPlane");o&&o.setEnabled(e)}}else{var a=i.getMeshByName("BackgroundHelper");a&&a.setEnabled(e)}this.options.backgroundMeshes&&this.options.backgroundMeshes.forEach(function(s){return s.setEnabled(e)}),this.onBackgroundStateChangedObservable.notifyObservers(e)},t.Name=Ko.BACKGROUND_REMOVER,t.Version=1,t}(qo);Mo.AddWebXRFeature(Qv.Name,function(n,t){return function(){return new Qv(n,t)}},Qv.Version,!0);var z8=function(){function n(){}return n}(),$v=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r._options=i,r._attachController=function(o){if(!r._controllers[o.uniqueId])if(r._xrSessionManager.scene.isPhysicsEnabled()||de.Warn("physics engine not enabled, skipped. Please add this controller manually."),r._options.physicsProperties.useControllerMesh&&o.inputSource.gamepad)o.onMotionControllerInitObservable.addOnce(function(c){c.onModelLoadedObservable.addOnce(function(){var h=new It(c.rootMesh,It.MeshImpostor,Ot({mass:0},r._options.physicsProperties)),p=o.grip||o.pointer;r._controllers[o.uniqueId]={xrController:o,impostor:h,oldPos:p.position.clone(),oldRotation:p.rotationQuaternion.clone()}})});else{var a=r._options.physicsProperties.impostorType||It.SphereImpostor,s=r._options.physicsProperties.impostorSize||.1,l=tn.CreateSphere("impostor-mesh-"+o.uniqueId,{diameterX:typeof s=="number"?s:s.width,diameterY:typeof s=="number"?s:s.height,diameterZ:typeof s=="number"?s:s.depth});l.isVisible=r._debugMode,l.isPickable=!1,l.rotationQuaternion=new Re;var u=o.grip||o.pointer;l.position.copyFrom(u.position),l.rotationQuaternion.copyFrom(u.rotationQuaternion);var f=new It(l,a,Ot({mass:0},r._options.physicsProperties));r._controllers[o.uniqueId]={xrController:o,impostor:f,impostorMesh:l}}},r._controllers={},r._debugMode=!1,r._delta=0,r._lastTimestamp=0,r._tmpQuaternion=new Re,r._tmpVector=new y,r._options.physicsProperties||(r._options.physicsProperties={}),r}return t.prototype._enablePhysicsDebug=function(){var e=this;this._debugMode=!0,Object.keys(this._controllers).forEach(function(i){var r=e._controllers[i];r.impostorMesh&&(r.impostorMesh.isVisible=!0)})},t.prototype.addController=function(e){this._attachController(e)},t.prototype.attach=function(){var e=this;if(!n.prototype.attach.call(this))return!1;if(!this._options.xrInput)return!0;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(o){e._detachController(o.uniqueId)}),this._options.enableHeadsetImpostor){var i=this._options.headsetImpostorParams||{impostorType:It.SphereImpostor,restitution:.8,impostorSize:.3},r=i.impostorSize||.3;this._headsetMesh=tn.CreateSphere("headset-mesh",{diameterX:typeof r=="number"?r:r.width,diameterY:typeof r=="number"?r:r.height,diameterZ:typeof r=="number"?r:r.depth}),this._headsetMesh.rotationQuaternion=new Re,this._headsetMesh.isVisible=!1,this._headsetImpostor=new It(this._headsetMesh,i.impostorType,Ot({mass:0},i))}return!0},t.prototype.detach=function(){var e=this;return n.prototype.detach.call(this)?(Object.keys(this._controllers).forEach(function(i){e._detachController(i)}),this._headsetMesh&&this._headsetMesh.dispose(),!0):!1},t.prototype.getHeadsetImpostor=function(){return this._headsetImpostor},t.prototype.getImpostorForController=function(e){var i=typeof e=="string"?e:e.uniqueId;return this._controllers[i]?this._controllers[i].impostor:null},t.prototype.setPhysicsProperties=function(e){this._options.physicsProperties=Ot(Ot({},this._options.physicsProperties),e)},t.prototype._onXRFrame=function(e){var i=this;this._delta=this._xrSessionManager.currentTimestamp-this._lastTimestamp,this._lastTimestamp=this._xrSessionManager.currentTimestamp,this._headsetMesh&&(this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.position),this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.rotationQuaternion)),Object.keys(this._controllers).forEach(function(r){var o=i._controllers[r],a=o.xrController.grip||o.xrController.pointer,s=o.oldPos||o.impostorMesh.position,l=o.oldRotation||o.impostorMesh.rotationQuaternion;if(a.position.subtractToRef(s,i._tmpVector),i._tmpVector.scaleInPlace(1e3/i._delta),o.impostor.setLinearVelocity(i._tmpVector),i._debugMode&&console.log(i._tmpVector,"linear"),!l.equalsWithEpsilon(a.rotationQuaternion)){l.conjugateInPlace().multiplyToRef(a.rotationQuaternion,i._tmpQuaternion);var u=Math.sqrt(i._tmpQuaternion.x*i._tmpQuaternion.x+i._tmpQuaternion.y*i._tmpQuaternion.y+i._tmpQuaternion.z*i._tmpQuaternion.z);if(i._tmpVector.set(i._tmpQuaternion.x,i._tmpQuaternion.y,i._tmpQuaternion.z),u<.001)i._tmpVector.scaleInPlace(2);else{var f=2*Math.atan2(u,i._tmpQuaternion.w);i._tmpVector.scaleInPlace(f/(u*(i._delta/1e3)))}o.impostor.setAngularVelocity(i._tmpVector),i._debugMode&&console.log(i._tmpVector,i._tmpQuaternion,"angular")}s.copyFrom(a.position),l.copyFrom(a.rotationQuaternion)})},t.prototype._detachController=function(e){var i=this._controllers[e];i&&(i.impostorMesh&&i.impostorMesh.dispose(),delete this._controllers[e])},t.Name=Ko.PHYSICS_CONTROLLERS,t.Version=1,t}(qo);Mo.AddWebXRFeature($v.Name,function(n,t){return function(){return new $v(n,t)}},$v.Version,!0);var Zv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r._tmpMat=new te,r._tmpPos=new y,r._tmpQuat=new Re,r.initHitTestSource=function(o){if(o){var a=new XRRay(r.options.offsetRay||{}),s={space:r.options.useReferenceSpace?o:r._xrSessionManager.viewerReferenceSpace,offsetRay:a};if(r.options.entityTypes&&(s.entityTypes=r.options.entityTypes),!s.space){Ee.Warn("waiting for viewer reference space to initialize");return}r._xrSessionManager.session.requestHitTestSource(s).then(function(l){r._xrHitTestSource&&r._xrHitTestSource.cancel(),r._xrHitTestSource=l})}},r.autoCloneTransformation=!1,r.onHitTestResultObservable=new ie,r.paused=!1,r.xrNativeFeatureName="hit-test",Ee.Warn("Hit test is an experimental and unstable feature."),r}return t.prototype.attach=function(){var e=this;if(!n.prototype.attach.call(this)||!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this.initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this.initHitTestSource)),this.options.enableTransientHitTest){var i=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:"generic-touchscreen",offsetRay:i,entityTypes:this.options.entityTypes}).then(function(r){e._transientXrHitTestSource=r})}return!0},t.prototype.detach=function(){return n.prototype.detach.call(this)?(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this.initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||this.paused)){if(this._xrHitTestSource){var r=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(r)}if(this._transientXrHitTestSource){var o=e.getHitTestResultsForTransientInput(this._transientXrHitTestSource);o.forEach(function(a){i._processWebXRHitTestResult(a.results,a.inputSource)})}}},t.prototype._processWebXRHitTestResult=function(e,i){var r=this,o=[];e.forEach(function(a){var s=a.getPose(r._xrSessionManager.referenceSpace);if(s){var l=s.transform.position,u=s.transform.orientation;r._tmpPos.set(l.x,l.y,l.z),r._tmpQuat.set(u.x,u.y,u.z,u.w),te.FromFloat32ArrayToRefScaled(s.transform.matrix,0,1,r._tmpMat),r._xrSessionManager.scene.useRightHandedSystem||(r._tmpPos.z*=-1,r._tmpQuat.z*=-1,r._tmpQuat.w*=-1,r._tmpMat.toggleModelMatrixHandInPlace());var f={position:r.autoCloneTransformation?r._tmpPos.clone():r._tmpPos,rotationQuaternion:r.autoCloneTransformation?r._tmpQuat.clone():r._tmpQuat,transformationMatrix:r.autoCloneTransformation?r._tmpMat.clone():r._tmpMat,inputSource:i,isTransient:!!i,xrHitResult:a};o.push(f)}}),this.onHitTestResultObservable.notifyObservers(o)},t.Name=Ko.HIT_TEST,t.Version=2,t}(qo);Mo.AddWebXRFeature(Zv.Name,function(n,t){return function(){return new Zv(n,t)}},Zv.Version,!1);var Jv=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i._enabled=!1,i._featurePointCloud=[],i.onFeaturePointsAddedObservable=new ie,i.onFeaturePointsUpdatedObservable=new ie,i.xrNativeFeatureName="bjsfeature-points",i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce(function(){i._init()}),i}return Object.defineProperty(t.prototype,"featurePointCloud",{get:function(){return this._featurePointCloud},enumerable:!1,configurable:!0}),t.prototype.detach=function(){return n.prototype.detach.call(this)?(this.featurePointCloud.length=0,!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this._featurePointCloud.length=0,this.onFeaturePointsUpdatedObservable.clear(),this.onFeaturePointsAddedObservable.clear()},t.prototype._onXRFrame=function(e){if(!(!this.attached||!this._enabled||!e)){var i=e.featurePointCloud;if(!(!i||i.length===0)){if(i.length%5!==0)throw new Error("Received malformed feature point cloud of length: "+i.length);for(var r=i.length/5,o=new Array,a=new Array,s=0;s<r;s++){var l=s*5,u=i[l+4];this._featurePointCloud[u]?o.push(u):(this._featurePointCloud[u]={position:new y,confidenceValue:0},a.push(u)),this._featurePointCloud[u].position.x=i[l],this._featurePointCloud[u].position.y=i[l+1],this._featurePointCloud[u].position.z=i[l+2],this._featurePointCloud[u].confidenceValue=i[l+3]}a.length>0&&this.onFeaturePointsAddedObservable.notifyObservers(a),o.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(o)}}},t.prototype._init=function(){!this._xrSessionManager.session.trySetFeaturePointCloudEnabled||!this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)||(this._enabled=!0)},t.Name=Ko.FEATURE_POINTS,t.Version=1,t}(qo);Mo.AddWebXRFeature(Jv.Name,function(n){return function(){return new Jv(n)}},Jv.Version);var S5=function(){function n(t,e,i,r,o){this.xrController=t,this.trackedMeshes=e,this._handMesh=i,this._rigMapping=r,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(t.inputSource.hand),this._scene=e[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:o||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add(function(a){a.rootMesh&&a.rootMesh.setEnabled(!1)})),this.xrController.onMotionControllerInitObservable.add(function(a){a.onModelLoadedObservable.add(function(s){s.rootMesh&&s.rootMesh.setEnabled(!1)}),a.rootMesh&&a.rootMesh.setEnabled(!1)})}return n.prototype.generateHandPartsDefinition=function(t){var e;return e={},e.wrist=[t.WRIST],e.thumb=[t.THUMB_METACARPAL,t.THUMB_PHALANX_PROXIMAL,t.THUMB_PHALANX_DISTAL,t.THUMB_PHALANX_TIP],e.index=[t.INDEX_METACARPAL,t.INDEX_PHALANX_PROXIMAL,t.INDEX_PHALANX_INTERMEDIATE,t.INDEX_PHALANX_DISTAL,t.INDEX_PHALANX_TIP],e.middle=[t.MIDDLE_METACARPAL,t.MIDDLE_PHALANX_PROXIMAL,t.MIDDLE_PHALANX_INTERMEDIATE,t.MIDDLE_PHALANX_DISTAL,t.MIDDLE_PHALANX_TIP],e.ring=[t.RING_METACARPAL,t.RING_PHALANX_PROXIMAL,t.RING_PHALANX_INTERMEDIATE,t.RING_PHALANX_DISTAL,t.RING_PHALANX_TIP],e.little=[t.LITTLE_METACARPAL,t.LITTLE_PHALANX_PROXIMAL,t.LITTLE_PHALANX_INTERMEDIATE,t.LITTLE_PHALANX_DISTAL,t.LITTLE_PHALANX_TIP],e},n.prototype.updateFromXRFrame=function(t,e,i){var r=this;i===void 0&&(i=2);var o=this.xrController.inputSource.hand;o&&this.trackedMeshes.forEach(function(a,s){var l=o[s];if(l){var u=t.getJointPose(l,e);if(!u||!u.transform)return;var f=u.transform.position,c=u.transform.orientation;a.position.set(f.x,f.y,f.z),a.rotationQuaternion.set(c.x,c.y,c.z,c.w);var h=(u.radius||.008)*i;a.scaling.set(h,h,h),r._handMesh&&r._rigMapping&&r._rigMapping[s]&&(r._transformNodeMapping[s]=r._transformNodeMapping[s]||r._scene.getTransformNodeByName(r._rigMapping[s]),r._transformNodeMapping[s]&&(r._transformNodeMapping[s].position.copyFrom(a.position),r._transformNodeMapping[s].rotationQuaternion.copyFrom(a.rotationQuaternion),a.isVisible=!1)),a.getScene().useRightHandedSystem||(a.position.z*=-1,a.rotationQuaternion.z*=-1,a.rotationQuaternion.w*=-1)}})},n.prototype.getHandPartMeshes=function(t){var e=this;return this.handPartsDefinition[t].map(function(i){return e.trackedMeshes[i]})},n.prototype.dispose=function(){this.trackedMeshes.forEach(function(t){return t.dispose()}),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},n.prototype._generateDefaultHandMesh=function(){return eu(this,void 0,void 0,function(){var t,e,i,r,o,a,s,l;return tu(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),t=this.xrController.inputSource.handedness==="right"?"right":"left",e=(t==="right"?"r":"l")+"_hand_"+(this._scene.useRightHandedSystem?"r":"l")+"hs.glb",[4,$t.ImportMeshAsync("","https://assets.babylonjs.com/meshes/HandMeshes/",e,this._scene)];case 1:return i=u.sent(),r={base:_e.FromInts(116,63,203),fresnel:_e.FromInts(149,102,229),fingerColor:_e.FromInts(177,130,255),tipFresnel:_e.FromInts(220,200,255)},o=new Wb("leftHandShader",this._scene,{emitComments:!1}),[4,o.loadAsync("https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json")];case 2:if(u.sent(),o.build(!1),o.needDepthPrePass=!0,o.transparencyMode=gt.MATERIAL_ALPHABLEND,o.alphaMode=Me.ALPHA_COMBINE,a={base:o.getBlockByName("baseColor"),fresnel:o.getBlockByName("fresnelColor"),fingerColor:o.getBlockByName("fingerColor"),tipFresnel:o.getBlockByName("tipFresnelColor")},a.base.value=r.base,a.fresnel.value=r.fresnel,a.fingerColor.value=r.fingerColor,a.tipFresnel.value=r.tipFresnel,i.meshes[1].material=o,this._defaultHandMesh=!0,this._handMesh=i.meshes[0],this._rigMapping=["wrist_","thumb_metacarpal_","thumb_proxPhalanx_","thumb_distPhalanx_","thumb_tip_","index_metacarpal_","index_proxPhalanx_","index_intPhalanx_","index_distPhalanx_","index_tip_","middle_metacarpal_","middle_proxPhalanx_","middle_intPhalanx_","middle_distPhalanx_","middle_tip_","ring_metacarpal_","ring_proxPhalanx_","ring_intPhalanx_","ring_distPhalanx_","ring_tip_","little_metacarpal_","little_proxPhalanx_","little_intPhalanx_","little_distPhalanx_","little_tip_"].map(function(f){return""+f+(t==="right"?"R":"L")}),s=this._scene.getTransformNodeByName(this._rigMapping[0]),s)s.parent&&s.parent.rotate(Mi.Y,Math.PI);else throw new Error("could not find the wrist node");return[3,4];case 3:return l=u.sent(),Ee.Error("error loading hand mesh"),console.log(l),[3,4];case 4:return[2]}})})},n}(),ey=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.options=i,r.onHandAddedObservable=new ie,r.onHandRemovedObservable=new ie,r._hands={},r._attachHand=function(o){var a,s,l,u,f,c,h,p,_,g;if(!(!o.inputSource.hand||r._hands[o.uniqueId])){var v=o.inputSource.hand,E=[],T=((a=r.options.jointMeshes)===null||a===void 0?void 0:a.sourceMesh)||tn.CreateSphere("jointParent",{diameter:1});T.isVisible=!!(!((s=r.options.jointMeshes)===null||s===void 0)&&s.keepOriginalVisible);for(var S=0;S<v.length;++S){var C=T.createInstance(o.uniqueId+"-handJoint-"+S);if(!((l=r.options.jointMeshes)===null||l===void 0)&&l.onHandJointMeshGenerated){var O=r.options.jointMeshes.onHandJointMeshGenerated(C,S,o.uniqueId);O&&O!==C&&(C.dispose(),C=O)}if(C.isPickable=!1,!((u=r.options.jointMeshes)===null||u===void 0)&&u.enablePhysics){var A=r.options.jointMeshes.physicsProps||{},M=A.impostorType!==void 0?A.impostorType:It.SphereImpostor;C.physicsImpostor=new It(C,M,Ot({mass:0},A))}C.rotationQuaternion=new Re,!((f=r.options.jointMeshes)===null||f===void 0)&&f.invisible&&(C.isVisible=!1),E.push(C)}var D=o.inputSource.handedness==="right"?"right":"left",U=((c=r.options.jointMeshes)===null||c===void 0?void 0:c.handMeshes)&&((h=r.options.jointMeshes)===null||h===void 0?void 0:h.handMeshes[D]),V=((p=r.options.jointMeshes)===null||p===void 0?void 0:p.rigMapping)&&((_=r.options.jointMeshes)===null||_===void 0?void 0:_.rigMapping[D]),B=new S5(o,E,U,V,(g=r.options.jointMeshes)===null||g===void 0?void 0:g.disableDefaultHandMesh);r._hands[o.uniqueId]={handObject:B,id:t._idCounter++},r.onHandAddedObservable.notifyObservers(B)}},r.xrNativeFeatureName="hand-tracking",r}return t.prototype.isCompatible=function(){return typeof XRHand<"u"},t.prototype.attach=function(){var e=this;return n.prototype.attach.call(this)?(this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,function(i){e._detachHand(i.uniqueId)}),!0):!1},t.prototype.detach=function(){var e=this;return n.prototype.detach.call(this)?(Object.keys(this._hands).forEach(function(i){e._detachHand(i)}),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var i;return((i=this._hands[e])===null||i===void 0?void 0:i.handObject)||null},t.prototype.getHandByHandedness=function(e){var i=this,r=Object.keys(this._hands).map(function(a){return i._hands[a].handObject.xrController.inputSource.handedness}),o=r.indexOf(e);return o!==-1?this._hands[o].handObject:null},t.prototype._onXRFrame=function(e){var i=this;Object.keys(this._hands).forEach(function(r){var o;i._hands[r].handObject.updateFromXRFrame(e,i._xrSessionManager.referenceSpace,(o=i.options.jointMeshes)===null||o===void 0?void 0:o.scaleFactor)})},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=Ko.HAND_TRACKING,t.Version=1,t}(qo);Mo.AddWebXRFeature(ey.Name,function(n,t){return function(){return new ey(n,t)}},ey.Version,!1);var C5=function(n){j(t,n);function t(e,i,r){var o=n.call(this,e,P5["left-right"],i,r)||this;return o._mapping={defaultButton:{valueNodeName:"VALUE",unpressedNodeName:"UNPRESSED",pressedNodeName:"PRESSED"},defaultAxis:{valueNodeName:"VALUE",minNodeName:"MIN",maxNodeName:"MAX"},buttons:{"xr-standard-trigger":{rootNodeName:"SELECT",componentProperty:"button",states:["default","touched","pressed"]},"xr-standard-squeeze":{rootNodeName:"GRASP",componentProperty:"state",states:["pressed"]},"xr-standard-touchpad":{rootNodeName:"TOUCHPAD_PRESS",labelAnchorNodeName:"squeeze-label",touchPointNodeName:"TOUCH"},"xr-standard-thumbstick":{rootNodeName:"THUMBSTICK_PRESS",componentProperty:"state",states:["pressed"]}},axes:{"xr-standard-touchpad":{"x-axis":{rootNodeName:"TOUCHPAD_TOUCH_X"},"y-axis":{rootNodeName:"TOUCHPAD_TOUCH_Y"}},"xr-standard-thumbstick":{"x-axis":{rootNodeName:"THUMBSTICK_X"},"y-axis":{rootNodeName:"THUMBSTICK_Y"}}}},o.profileId="microsoft-mixed-reality",o}return t.prototype._getFilenameAndPath=function(){var e="";this.handedness==="left"?e=t.MODEL_LEFT_FILENAME:e=t.MODEL_RIGHT_FILENAME;var i="default",r=t.MODEL_BASE_URL+i+"/";return{filename:e,path:r}},t.prototype._getModelLoadingConstraints=function(){var e=$t.IsPluginForExtensionAvailable(".glb");return e||de.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var i=this;this.rootMesh&&(this.getComponentIds().forEach(function(r,o){if(!i.disableAnimation&&r&&i.rootMesh){var a=i._mapping.buttons[r],s=a.rootNodeName;if(!s){de.Log("Skipping unknown button at index: "+o+" with mapped name: "+r);return}var l=i._getChildByName(i.rootMesh,s);if(!l){de.Warn("Missing button mesh with name: "+s);return}if(a.valueMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.valueNodeName),a.pressedMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.pressedNodeName),a.unpressedMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.unpressedNodeName),a.valueMesh&&a.pressedMesh&&a.unpressedMesh){var u=i.getComponent(r);u&&u.onButtonStateChangedObservable.add(function(f){i._lerpTransform(a,f.value)},void 0,!0)}else de.Warn("Missing button submesh under mesh with name: "+s)}}),this.getComponentIds().forEach(function(r,o){var a=i.getComponent(r);a.isAxes()&&["x-axis","y-axis"].forEach(function(s){if(i.rootMesh){var l=i._mapping.axes[r][s],u=i._getChildByName(i.rootMesh,l.rootNodeName);if(!u){de.Warn("Missing axis mesh with name: "+l.rootNodeName);return}l.valueMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.valueNodeName),l.minMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.minNodeName),l.maxMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.maxNodeName),l.valueMesh&&l.minMesh&&l.maxMesh?a&&a.onAxisValueChangedObservable.add(function(f){var c=s==="x-axis"?f.x:f.y;i._lerpTransform(l,c,!0)},void 0,!0):de.Warn("Missing axis submesh under mesh with name: "+l.rootNodeName)}})}))},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i,r=0;r<e.length;r++){var o=e[r];o.isPickable=!1,o.parent||(i=o)}i&&i.setParent(this.rootMesh),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t}(cc);Gn.RegisterController("windows-mixed-reality",function(n,t){return new C5(t,n.gamepad,n.handedness)});var P5={},BI=function(n){j(t,n);function t(e,i,r,o,a){a===void 0&&(a=!1);var s=n.call(this,e,A5[r],i,r)||this;return s._forceLegacyControllers=a,s.profileId="oculus-touch",s}return t.prototype._getFilenameAndPath=function(){var e="";this.handedness==="left"?e=t.MODEL_LEFT_FILENAME:e=t.MODEL_RIGHT_FILENAME;var i=this._isQuest()?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL;return{filename:e,path:i}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var i=this,r=this._isQuest(),o=this.handedness==="right"?-1:1;this.getComponentIds().forEach(function(a){var s=a&&i.getComponent(a);s&&s.onButtonStateChangedObservable.add(function(l){if(!(!i.rootMesh||i.disableAnimation))switch(a){case"xr-standard-trigger":r||(i._modelRootNode.getChildren()[3].rotation.x=-l.value*.2,i._modelRootNode.getChildren()[3].position.y=-l.value*.005,i._modelRootNode.getChildren()[3].position.z=-l.value*.005);return;case"xr-standard-squeeze":r||(i._modelRootNode.getChildren()[4].position.x=o*l.value*.0035);return;case"xr-standard-thumbstick":return;case"a-button":case"x-button":r||(l.pressed?i._modelRootNode.getChildren()[1].position.y=-.001:i._modelRootNode.getChildren()[1].position.y=0);return;case"b-button":case"y-button":r||(l.pressed?i._modelRootNode.getChildren()[2].position.y=-.001:i._modelRootNode.getChildren()[2].position.y=0);return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0)),e.forEach(function(i){i.isPickable=!1}),this._isQuest()?this._modelRootNode=e[0]:(this._modelRootNode=e[1],this.rootMesh.position.y=.034,this.rootMesh.position.z=.052),this._modelRootNode.parent=this.rootMesh},t.prototype._updateModel=function(){},t.prototype._isQuest=function(){return!!navigator.userAgent.match(/Quest/gi)&&!this._forceLegacyControllers},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t}(cc);Gn.RegisterController("oculus-touch",function(n,t){return new BI(t,n.gamepad,n.handedness)});Gn.RegisterController("oculus-touch-legacy",function(n,t){return new BI(t,n.gamepad,n.handedness,!0)});var A5={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"x-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"x_button",visualResponses:{}},"y-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"y_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"a-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"a_button",visualResponses:{}},"b-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"b_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-right",assetPath:"right.glb"}},R5=function(n){j(t,n);function t(e,i,r){var o=n.call(this,e,O5[r],i,r)||this;return o.profileId="htc-vive",o}return t.prototype._getFilenameAndPath=function(){var e=t.MODEL_FILENAME,i=t.MODEL_BASE_URL;return{filename:e,path:i}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var i=this;this.getComponentIds().forEach(function(r){var o=r&&i.getComponent(r);o&&o.onButtonStateChangedObservable.add(function(a){if(!(!i.rootMesh||i.disableAnimation))switch(r){case"xr-standard-trigger":i._modelRootNode.getChildren()[6].rotation.x=-a.value*.15;return;case"xr-standard-touchpad":return;case"xr-standard-squeeze":return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),e.forEach(function(i){i.isPickable=!1}),this._modelRootNode=e[1],this._modelRootNode.parent=this.rootMesh,this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(cc);Gn.RegisterController("htc-vive",function(n,t){return new R5(t,n.gamepad,n.handedness)});var O5={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc-vive-none",assetPath:"none.glb"}};function ou(n){return n.startsWith("#")?n:"#"+n}function M5(n){return n.startsWith("#")?n.slice(1):n}function ty(n){return("0"+(n*255|0).toString(16)).slice(-2)}function au(n){return ty(n.r)+ty(n.g)+ty(n.b)}function Fy(n){const t=M5(n);return new _e(parseInt(t.slice(0,2),16)/256,parseInt(t.slice(2,4),16)/256,parseInt(t.slice(4,6),16)/256)}function VI(n,t){return n.bodyShapes.includes(t)}function x5(n){return VI(n,Ce.BodyShape.MALE)}function I5(n){return VI(n,Ce.BodyShape.FEMALE)}function Kb(n,t=Ce.BodyShape.MALE){const e=n.emoteDataADR74.representations.find(i=>i.bodyShapes.includes(t));if(!e)throw new Error(`Could not find a representation of bodyShape=${t} for emote="${n.id}"`);return e}function mu(n,t=Ce.BodyShape.MALE){switch(t){case Ce.BodyShape.FEMALE:{const e=n.data.representations.find(I5);if(!e)throw new Error(`Could not find a BaseFemale representation for wearable="${n.id}"`);return e}case Ce.BodyShape.MALE:{const e=n.data.representations.find(x5);if(!e)throw new Error(`Could not find a BaseMale representation for wearable="${n.id}"`);return e}}}function qb(n,t=Ce.BodyShape.MALE){if(Qb(n,t))return mu(n,t);if(n.data.representations.length>0)return n.data.representations[0];throw new Error(`The wearable="${n.id}" has no representation`)}function Qb(n,t=Ce.BodyShape.MALE){try{return mu(n,t),!0}catch{return!1}}function D5(n){const t=n.contents.find(e=>e.key===n.mainFile);if(!t)throw new Error("Could not find main file");return t.url}function yp(n){return n.mainFile.endsWith("png")}const UI=1,w5=2.8,L5=w5-UI;function N5(n){return Math.min(Math.max(n,0),100)/100*L5+UI}function F5(n){const t=n?parseFloat(n):null;return t===null||isNaN(t)?null:t}function B5(n){switch(n&&Co(n)?null:n==null?void 0:n.data.category){case Ce.WearableCategory.UPPER_BODY:return 2;case Ce.WearableCategory.SKIN:return 1.75;default:return 1.25}}const Nd="default",V5=6,GO="collections-thirdparty",U5=10;function k5(n){const t=n.split(":"),e=t.length;let i;return n.includes(GO)&&e===U5?i={assetUrn:t.slice(0,7).join(":"),tokenId:t[9],contractAddress:t[8],network:t[7]}:!n.includes(GO)&&e>V5&&(i={assetUrn:t.slice(0,-1).join(":"),tokenId:t[e-1]}),i??{assetUrn:n,tokenId:void 0}}async function z5(n,t){const[e,i]=await Zd([n],t);if(e.length===1)return e[0];if(i.length===1)return i[0];throw new Error(`Could not find wearable or emote for urn="${n}"`)}function G5(n){const t=n.map(r=>JSON.parse(atob(r))),e=t.filter(as),i=t.filter(Co);return[e,i]}function iy(n){return typeof n=="number"&&!isNaN(n)}function W5(n){return/^0x[a-fA-F0-9]{40}$/g.test(n)}function H5(n){return/^baf[a-z2-7]{56}$/.test(n)}function kI(n){return n?n===Nd?{type:"address",value:n}:n.startsWith(Nd)?isNaN(Number(n.replace(Nd,"")))?null:{type:"address",value:n}:W5(n)?{type:"address",value:n}:H5(n)?{type:"entity",value:n}:null:null}async function j5(n,t){if(!n)return[];const[e]=await Zd(n.avatar.wearables,t);return e}async function Zd(n,t){if(n.length===0)return[[],[]];const e=n.map(i=>i.replace(/^dcl:\/\/base-avatars\//,"urn:decentraland:off-chain:base-avatars:")).map(i=>k5(i).assetUrn);return Cb.fetchItems(e,t)}async function X5(n){if(n.length===0)return[[],[]];const t=n.map(o=>fetch(o).then(a=>a.json()).catch()),e=await Promise.all(t),i=e.filter(as),r=e.filter(Co);return[i,r]}const zI=qF();async function GI(n,t){return zI.memo(n,async()=>n===Nd?null:await Cb.fetchProfile(n,t).then(i=>i&&i.avatars.length>0?i.avatars[0]:null).catch(i=>console.log(`Failed to load profile="${n}"`,i))||null)}async function WI(n,t){return zI.memo(n,async()=>await Cb.fetchProfileEntity(n,t).then(i=>i&&i.avatars.length>0?i.avatars[0]:null).catch(i=>console.log(`Failed to load profile="${n}"`,i))||null)}async function HI(n){const{contractAddress:t,itemId:e,tokenId:i,peerUrl:r,marketplaceServerUrl:o}=n;if(!e&&!i)throw new Error("You need to provide an itemId or a tokenId");const a=Wf.get("NETWORK");let s=`urn:decentraland:${a}:collections-v2:${t}:${e}`;if(!e&&!i)throw new Error("You must provide either tokenId or itemId");if(!e&&i){const l=await UF.fetchNFT(t,i,o);s=l.network!==Ce.Network.ETHEREUM?`urn:decentraland:${a}:collections-v2:${t}:${l.itemId}`:l.image.split("contents/")[1].split("/thumbnail")[0]}return z5(s,r)}async function Y5(n,t,e,i,r,o,a,s){const[l,[u,f],[c,h]]=await Promise.all([j5(n,s),Zd([r,...t],s),X5(e)]),[p,_]=G5(i);let g=[...l,...u,...c,...p];const v=[...f,...h,..._];g=g.filter(S=>Qb(S,r));const E=[],T=o&&a?HF():o?WF():a?GF():[];for(const S of T)if(!zF(g,S)){const O=jF(S,r);if(O)E.push(O);else throw new Error(`Could not get default URN for category="${S}"`)}if(E.length>0){const[S]=await Zd(E,s);g=[...g,...S]}return[g,v]}async function K5(n={}){const{contractAddress:t,tokenId:e,itemId:i}=n,r=n.peerUrl||Wf.get("PEER_URL"),o=n.marketplaceServerUrl||n.nftServerUrl||Wf.get("MARKETPLACE_SERVER_URL");let a=Promise.resolve();t&&(a=HI({contractAddress:t,tokenId:e,itemId:i,peerUrl:r,marketplaceServerUrl:o}));const s=kI(n.profile),l=s?s.type==="address"?GI(s.value,r):WI(s.value,r):Promise.resolve(null),[u,f]=await Promise.all([a,l]),c=n.bodyShape||f&&f.avatar.bodyShape||(u&&as(u)?XF(u):Ce.BodyShape.MALE),h=ou(n.skin||f&&au(f.avatar.skin.color)||"cc9b76"),p=ou(n.hair||f&&au(f.avatar.hair.color)||"000000"),_=ou(n.eyes||f&&au(f.avatar.eyes.color)||"000000"),g=[...n.urns||[]],v=n.urls||[],E=n.base64s||[],T=n.blob?q5(n.blob):null;let S=[],C=[],O=1.75,A=Ce.PreviewType.WEARABLE,M={color:"#4b4852",transparent:n.disableBackground===!0};if(g.length>0||v.length>0||E.length>0||u&&Co(u)||n.profile){A=Ce.PreviewType.AVATAR;const[W,$]=await Y5(f,g,v,E,c,!n.disableDefaultWearables&&!(f!=null&&f.avatar),!n.disableFace,r);S=W,C=$}if(u){if(O=S.length>0?O:B5(u),as(u)){const W=qb(u);yp(W)&&A!==Ce.PreviewType.AVATAR&&(A=Ce.PreviewType.TEXTURE)}if(M={...M,image:u.thumbnail},Ce.isStandard(u)){const W=Ce.Rarity.getColor(u.rarity);M={...M,image:u.thumbnail,color:W}}}let D=n.disableDefaultEmotes||Co(u)?null:n.emote?n.emote:Ce.PreviewEmote.IDLE;n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)&&(D=n.emote);let U=Ce.PreviewCamera.INTERACTIVE;n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)&&(U=n.camera);let V=Ce.PreviewProjection.PERSPECTIVE;n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)&&(V=n.projection);const B=typeof n.autoRotateSpeed=="number"&&!isNaN(n.autoRotateSpeed)?n.autoRotateSpeed:.2,z=!n.disableAutoCenter;let J=1,X=100,re=50;ry(n.wheelZoom)&&(J=Math.max(n.wheelZoom,1)),ry(n.wheelPrecision)&&(X=Math.max(n.wheelPrecision,1)),ry(n.wheelStart)&&(re=100-Math.min(Math.max(n.wheelStart,0),100)),n.background&&(M.color=n.background);let ae=0,se=0,H=0;switch(A){case Ce.PreviewType.WEARABLE:{ae=-2,se=2,H=2;break}case Ce.PreviewType.AVATAR:{ae=0,se=1,H=3.5;break}}iy(n.cameraX)&&(ae=n.cameraX),iy(n.cameraY)&&(se=n.cameraY),iy(n.cameraZ)&&(H=n.cameraZ);let Z=null;(n==null?void 0:n.type)===Ce.PreviewType.WEARABLE&&S.length>=2&&(A=n.type,Z=S[1]);const q=typeof n.zoomScale!="number"||isNaN(n.zoomScale)||n.zoomScale<=0?1:n.zoomScale,F=n.socialEmote??kF(Co(u)?u:null)??void 0;return{item:u??T??Z??C.pop(),wearables:S,bodyShape:c,forceRender:(f==null?void 0:f.avatar.forceRender)||[],skin:h,hair:p,eyes:_,type:A,background:M,face:n.disableFace!==!1,emote:D,camera:U,projection:V,autoRotateSpeed:n.disableAutoRotate?0:B,centerBoundingBox:z,offsetX:n.offsetX||0,offsetY:n.offsetY||0,offsetZ:n.offsetZ||0,cameraX:ae,cameraY:se,cameraZ:H,zoom:(typeof n.zoom=="number"?N5(n.zoom):O)*q,wheelZoom:J,wheelPrecision:X,wheelStart:re,fadeEffect:!n.disableFadeEffect,showSceneBoundaries:!!n.showSceneBoundaries,showThumbnailBoundaries:!!n.showThumbnailBoundaries,panning:!!n.panning,lockAlpha:!!n.lockAlpha,lockBeta:!!n.lockBeta,lockRadius:!!n.lockRadius,socialEmote:F}}function ry(n){return typeof n=="number"&&!isNaN(n)}function WO(n){return{...n,contents:n.contents.map(t=>({key:t.key,url:URL.createObjectURL(t.blob)}))}}function q5(n){return"emoteDataADR74"in n?{...n,emoteDataADR74:{...n.emoteDataADR74,representations:n.emoteDataADR74.representations.map(WO)}}:{...n,data:{...n.data,representations:n.data.representations.map(WO)}}}const Fd={};function ny(n,t){return t===Fd[n]}function Q5(n,t,e=[]){const[i,r]=Ct.useState(!1),[o,a]=Ct.useState(null),[s,l]=Ct.useState("");return typeof Fd[n]>"u"&&(Fd[n]=0),Ct.useEffect(()=>{const u=++Fd[n];r(!0),t().then(f=>{ny(n,u)&&a(f)}).catch(f=>{ny(n,u)&&l(f.message)}).finally(()=>{ny(n,u)&&r(!1)})},e),[o,i,s]}var $5=Jd();const Z5=ub($5),jI=n=>{const t=Ct.useCallback(n,[]);Ct.useEffect(()=>{function e(i){t(i)}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])},J5=()=>{const[n,t]=Ct.useState({});return jI(e=>{if(e.data&&e.data.type===Ce.PreviewMessageType.UPDATE&&typeof e.data.payload=="object"&&typeof e.data.payload.options=="object"){const{options:i}=e.data.payload;Z5(n,i)||t(i)}}),n},$b=()=>{const[n,t]=Ct.useState(()=>new URLSearchParams(window.location.search)),e=Ct.useRef(window.location.search);Ct.useEffect(()=>{const a=window.location.search;a!==e.current&&(t(new URLSearchParams(a)),e.current=a)});const i=Ct.useMemo(()=>{const a=n.get("autoRotateSpeed"),s=n.get("offsetX"),l=n.get("offsetY"),u=n.get("offsetZ"),f=n.get("cameraX"),c=n.get("cameraY"),h=n.get("cameraZ"),p=n.get("zoomScale"),_=n.get("wheelZoom"),g=n.get("wheelPrecision"),v=n.get("wheelStart"),E=n.get("bodyShape"),T=n.get("panning"),S=n.get("lockAlpha"),C=n.get("lockBeta"),O=n.get("lockRadius"),A=n.has("transparentBackground");A&&console.warn('Deprecated: you are using the query param "transparentBackground" that has been deprecated in favor of "disableBackground". Please switch to the new query param since in the future this will not be supported.');const M=n.get("centerBoundingBox")!=="false";return{contractAddress:n.get("contract"),tokenId:n.get("token"),itemId:n.get("item"),skin:n.get("skin"),hair:n.get("hair"),eyes:n.get("eyes"),emote:n.get("emote"),camera:n.get("camera"),projection:n.get("projection"),background:n.get("background"),autoRotateSpeed:a?parseFloat(a):null,offsetX:s?parseFloat(s):null,offsetY:l?parseFloat(l):null,offsetZ:u?parseFloat(u):null,cameraX:f?parseFloat(f):null,cameraY:c?parseFloat(c):null,cameraZ:h?parseFloat(h):null,wheelZoom:_?parseFloat(_):null,wheelPrecision:g?parseFloat(g):null,wheelStart:v?parseFloat(v):null,zoom:F5(n.get("zoom")),zoomScale:p?parseFloat(p):null,bodyShape:E==="female"||E===Ce.BodyShape.FEMALE?Ce.BodyShape.FEMALE:E==="male"||E===Ce.BodyShape.MALE?Ce.BodyShape.MALE:null,urns:n.getAll("urn"),urls:n.getAll("url"),base64s:n.getAll("base64"),profile:n.get("profile"),showSceneBoundaries:n.has("showSceneBoundaries")||!1,showThumbnailBoundaries:n.has("showThumbnailBoundaries")||!1,disableBackground:n.has("disableBackground")||A,disableAutoCenter:n.has("disableAutoCenter")||!M,disableAutoRotate:n.has("disableAutoRotate")||!M,disableFace:n.has("disableFace"),disableDefaultWearables:n.has("disableDefaultWearables"),disableDefaultEmotes:n.has("disableDefaultEmotes"),disableFadeEffect:n.has("disableFadeEffect"),peerUrl:n.get("peerUrl"),marketplaceServerUrl:n.get("marketplaceServerUrl"),nftServerUrl:n.get("nftServerUrl"),type:n.get("type"),panning:T==="true"||T===null,lockAlpha:S==="true",lockBeta:C==="true",lockRadius:O==="true",unityMode:n.get("mode"),disableLoader:n.has("disableLoader"),username:n.get("username"),socialEmote:(()=>{const U=n.get("socialEmote");if(!U)return null;try{return JSON.parse(U)}catch{return null}})()}},[n]),r=J5();return Ct.useMemo(()=>{const a={...i,...r},s={};return Object.keys(r).forEach(l=>{r[l]!==void 0&&(s[l]=!0)}),{options:a,overrideSources:s}},[i,r])};function eX(){const{options:n}=$b(),[t,e,i]=Q5("useConfig",()=>K5(n),[n]);return[t,e,i]}function cn(){return window.parent||window}const XI=()=>{const[n,t]=Ct.useState(!1);Ct.useEffect(()=>{n||(Ce.sendMessage(cn(),Ce.PreviewMessageType.READY,null),t(!0))},[n])};function tX(n,t){Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:n,ok:!0,result:t})}function Sd(n,t){Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:n,ok:!1,error:t})}const YI=()=>{const n=Ct.useRef();return jI(async t=>{if(t.data&&t.data.type===Ce.PreviewMessageType.CONTROLLER_REQUEST&&typeof t.data.payload=="object"&&typeof t.data.payload.id=="string"&&typeof t.data.payload.namespace=="string"&&typeof t.data.payload.method=="string"&&typeof t.data.payload.params=="object"&&Array.isArray(t.data.payload.params)){const{id:e,method:i,namespace:r,params:o}=t.data.payload;if(n.current)if(r in n.current)if(i in n.current[r])try{const l=await n.current[r][i].apply(null,o);tX(e,l)}catch(a){Sd(e,a.message)}else Sd(e,"Invalid method");else Sd(e,"Invalid namespace");else Sd(e,"Controller not ready")}}),n};function iX(n){return t=>t.data.category===n}function lf(n){return t=>t.wearable.data.category===n||(t.wearable.data.hides||[]).includes(n)||(t.wearable.data.replaces||[]).includes(n)}function rX(n){return n.some(t=>{var o,a;const e=t.wearable.data.category===Ce.WearableCategory.UPPER_BODY,i=(o=t.wearable.data.hides)==null?void 0:o.includes(Ce.WearableCategory.UPPER_BODY),r=(a=t.wearable.data.removesDefaultHiding)==null?void 0:a.includes(Ce.BodyPartCategory.HANDS);return(e||i)&&!r})}function nX(n){return!!n}function KI(n){const t=qb(n);return!yp(t)}function oX(n){return!KI(n)}function aX(n,t){var s,l,u;const e=n.name.toLowerCase(),i=e.includes("prop")||e.includes("armature_prop"),r=e.includes("avatarother")||e.includes("armature_other"),o=e.includes("avatar")||e.includes("armature")||!i&&!r;return[((s=t==null?void 0:t.Armature_Prop)==null?void 0:s.animation.toLowerCase())===e&&i,((l=t==null?void 0:t.Armature_Other)==null?void 0:l.animation.toLowerCase())===e&&r,((u=t==null?void 0:t.Armature)==null?void 0:u.animation.toLowerCase())===e&&o,!(t!=null&&t.Armature)&&!(t!=null&&t.Armature_Other)&&!(t!=null&&t.Armature_Prop)].some(f=>f)}function sX(n){const t=[...n.transformNodes,...n.meshes],e=new Set(t);return t.filter(i=>!i.parent||!e.has(i.parent))}function lX(n,t){const e=new Map,i=sX(n),r=(a,s)=>{e.set(a,s);const l=a.getChildren(),u=s.getChildren(),f=Math.min(l.length,u.length);for(let c=0;c<f;c++)r(l[c],u[c])},o=Math.min(i.length,t.length);for(let a=0;a<o;a++)r(i[a],t[a]);return e}const uX=(n,t)=>{for(const e of n)e.getChildMeshes().forEach(i=>{if(!i.material)return;const r=i.material.clone(i.material.name+"_Other");if(!r)return;const o=r.name.toLowerCase().includes("skin");if(o&&r instanceof Ci){const a=r.albedoTexture;a&&a.dispose(),r.albedoTexture=void 0;const s=r.bumpTexture;s&&s.dispose(),r.bumpTexture=void 0;const l=r.metallicTexture;l&&l.dispose(),r.metallicTexture=void 0,r.albedoColor=t,r.specularIntensity=0,i.material=r}else if(o&&r instanceof Mt){const a=r.diffuseTexture;a&&a.dispose(),r.diffuseTexture=void 0;const s=r.bumpTexture;s&&s.dispose(),r.bumpTexture=void 0;const l=r.specularTexture;l&&l.dispose(),r.specularTexture=void 0,r.diffuseColor=t,r.specularColor=_e.Black(),i.material=r}else r.dispose(),i.visibility=0})};function fX(n){const t=n.find(l=>l.wearable.data.category===Ce.WearableCategory.BODY_SHAPE);if(!t)return null;const e=n.some(l=>l.wearable.data.category===Ce.WearableCategory.SKIN),i=e||n.some(lf(Ce.WearableCategory.UPPER_BODY)),r=e||n.some(lf(Ce.WearableCategory.LOWER_BODY)),o=e||n.some(lf(Ce.WearableCategory.FEET)),a=e||n.some(lf(Ce.BodyPartCategory.HEAD)),s=e||n.some(lf(Ce.BodyPartCategory.HANDS))||rX(n);for(const l of t.container.meshes){const u=l.name.toLowerCase();u.endsWith("ubody_basemesh")&&i&&l.setEnabled(!1),u.endsWith("lbody_basemesh")&&r&&l.setEnabled(!1),u.endsWith("feet_basemesh")&&o&&l.setEnabled(!1),u.endsWith("head")&&a&&l.setEnabled(!1),u.endsWith("head_basemesh")&&a&&l.setEnabled(!1),u.endsWith("mask_eyes")&&a&&l.setEnabled(!1),u.endsWith("mask_eyebrows")&&a&&l.setEnabled(!1),u.endsWith("mask_mouth")&&a&&l.setEnabled(!1),u.endsWith("hands_basemesh")&&s&&l.setEnabled(!1)}return t}const qI=[Ce.WearableCategory.HELMET,Ce.WearableCategory.HAIR,Ce.WearableCategory.FACIAL_HAIR,Ce.WearableCategory.MOUTH,Ce.WearableCategory.EYEBROWS,Ce.WearableCategory.EYES,Ce.WearableCategory.UPPER_BODY,Ce.WearableCategory.LOWER_BODY,Ce.WearableCategory.FEET,Ce.WearableCategory.HANDS_WEAR,Ce.BodyPartCategory.HANDS],cX=[Ce.WearableCategory.SKIN,Ce.WearableCategory.UPPER_BODY,Ce.WearableCategory.HANDS_WEAR,Ce.WearableCategory.LOWER_BODY,Ce.WearableCategory.FEET,Ce.WearableCategory.HELMET,Ce.WearableCategory.HAT,Ce.WearableCategory.TOP_HEAD,Ce.WearableCategory.MASK,Ce.WearableCategory.EYEWEAR,Ce.WearableCategory.EARRING,Ce.WearableCategory.TIARA,Ce.WearableCategory.HAIR,Ce.WearableCategory.EYEBROWS,Ce.WearableCategory.EYES,Ce.WearableCategory.MOUTH,Ce.WearableCategory.FACIAL_HAIR,Ce.WearableCategory.BODY_SHAPE];function hX(n){const t=n.data.category,e=n.data.replaces||[],i=n.data.hides||[];return t===Ce.WearableCategory.SKIN&&i.push(...qI),Array.from(new Set([...e,...i])).filter(r=>r!==t)}function dX(n){const t=new Map;let e=[...n.wearables];if(n.item&&as(n.item)){e=[];for(const a of n.wearables){const{category:s,hides:l,replaces:u}=n.item.data;a.data.category==="skin"&&(qI.includes(s)||l&&l.includes(Ce.BodyPartCategory.HEAD)||u&&u.includes(Ce.BodyPartCategory.HEAD))||a.data.hides&&a.data.hides.includes(s)||a.data.replaces&&a.data.replaces.includes(s)||e.push(a)}e.push(n.item)}for(const a of e){const s=a.data.category;Qb(a,n.bodyShape)&&t.set(s,a)}const i=n.forceRender||[],r=new Set;for(const a of cX){const s=t.get(a);if(s&&!r.has(a))for(const l of hX(s))r.add(l)}const o=Array.from(r).filter(a=>!i.includes(a));for(const a of o)t.delete(a);return t}function QI(n,t){n&&(n.useAutoRotationBehavior=!0,n.autoRotationBehavior&&(n.autoRotationBehavior.idleRotationSpeed=t.autoRotateSpeed))}const pX="modulepreload",_X=function(n){return"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.1/"+n},HO={},mX=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){let a=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(c=>({status:"fulfilled",value:c}),c=>({status:"rejected",reason:c}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),l=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));r=a(e.map(u=>{if(u=_X(u),u in HO)return;HO[u]=!0;const f=u.endsWith(".css"),c=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${c}`))return;const h=document.createElement("link");if(h.rel=f?"stylesheet":pX,f||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),f)return new Promise((p,_)=>{h.addEventListener("load",p),h.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return r.then(a=>{for(const s of a||[])s.status==="rejected"&&o(s.reason);return t().catch(o)})};var zt=function(){function n(t,e,i){e===void 0&&(e=n.UNITMODE_PIXEL),i===void 0&&(i=!0),this.unit=e,this.negativeValueAllowed=i,this._value=1,this.ignoreAdaptiveScaling=!1,this._value=t,this._originalUnit=e}return Object.defineProperty(n.prototype,"isPercentage",{get:function(){return this.unit===n.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isPixel",{get:function(){return this.unit===n.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),n.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},n.prototype.updateInPlace=function(t,e){return e===void 0&&(e=n.UNITMODE_PIXEL),this._value=t,this.unit=e,this},n.prototype.getValue=function(t){if(t&&!this.ignoreAdaptiveScaling&&this.unit!==n.UNITMODE_PERCENTAGE){var e=0,i=0;if(t.idealWidth&&(e=this._value*t.getSize().width/t.idealWidth),t.idealHeight&&(i=this._value*t.getSize().height/t.idealHeight),t.useSmallestIdeal&&t.idealWidth&&t.idealHeight)return window.innerWidth<window.innerHeight?e:i;if(t.idealWidth)return e;if(t.idealHeight)return i}return this._value},n.prototype.toString=function(t,e){switch(this.unit){case n.UNITMODE_PERCENTAGE:var i=this.getValue(t)*100;return(e?i.toFixed(e):i)+"%";case n.UNITMODE_PIXEL:var r=this.getValue(t);return(e?r.toFixed(e):r)+"px"}return this.unit.toString()},n.prototype.fromString=function(t){var e=n._Regex.exec(t.toString());if(!e||e.length===0)return!1;var i=parseFloat(e[1]),r=this._originalUnit;if(this.negativeValueAllowed||i<0&&(i=0),e.length===4)switch(e[3]){case"px":r=n.UNITMODE_PIXEL;break;case"%":r=n.UNITMODE_PERCENTAGE,i/=100;break}return i===this._value&&r===this.unit?!1:(this._value=i,this.unit=r,!0)},Object.defineProperty(n,"UNITMODE_PERCENTAGE",{get:function(){return n._UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(n,"UNITMODE_PIXEL",{get:function(){return n._UNITMODE_PIXEL},enumerable:!1,configurable:!0}),n._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,n._UNITMODE_PERCENTAGE=0,n._UNITMODE_PIXEL=1,n}(),Vl=[new Ie(0,0),new Ie(0,0),new Ie(0,0),new Ie(0,0)],uf=[new Ie(0,0),new Ie(0,0),new Ie(0,0),new Ie(0,0)],ha=new Ie(0,0),Gs=new Ie(0,0),Jr=function(){function n(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r}return n.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},n.prototype.copyFromFloats=function(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r},n.CombineToRef=function(t,e,i){var r=Math.min(t.left,e.left),o=Math.min(t.top,e.top),a=Math.max(t.left+t.width,e.left+e.width),s=Math.max(t.top+t.height,e.top+e.height);i.left=r,i.top=o,i.width=a-r,i.height=s-o},n.prototype.addAndTransformToRef=function(t,e,i,r,o,a){var s=this.left+e,l=this.top+i,u=this.width+r,f=this.height+o;Vl[0].copyFromFloats(s,l),Vl[1].copyFromFloats(s+u,l),Vl[2].copyFromFloats(s+u,l+f),Vl[3].copyFromFloats(s,l+f),ha.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE),Gs.copyFromFloats(0,0);for(var c=0;c<4;c++)t.transformCoordinates(Vl[c].x,Vl[c].y,uf[c]),ha.x=Math.floor(Math.min(ha.x,uf[c].x)),ha.y=Math.floor(Math.min(ha.y,uf[c].y)),Gs.x=Math.ceil(Math.max(Gs.x,uf[c].x)),Gs.y=Math.ceil(Math.max(Gs.y,uf[c].y));a.left=ha.x,a.top=ha.y,a.width=Gs.x-ha.x,a.height=Gs.y-ha.y},n.prototype.transformToRef=function(t,e){this.addAndTransformToRef(t,0,0,0,0,e)},n.prototype.isEqualsTo=function(t){return!(this.left!==t.left||this.top!==t.top||this.width!==t.width||this.height!==t.height)},n.Empty=function(){return new n(0,0,0,0)},n}(),oy=function(n){j(t,n);function t(e,i){i===void 0&&(i=0);var r=n.call(this,e.x,e.y)||this;return r.buttonIndex=i,r}return t}(Ie),ay=function(){function n(t,e,i,r,o,a){this.m=new Float32Array(6),this.fromValues(t,e,i,r,o,a)}return n.prototype.fromValues=function(t,e,i,r,o,a){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=r,this.m[4]=o,this.m[5]=a,this},n.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},n.prototype.invertToRef=function(t){var e=this.m[0],i=this.m[1],r=this.m[2],o=this.m[3],a=this.m[4],s=this.m[5],l=this.determinant();if(l<Zt*Zt)return t.m[0]=0,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[5]=0,this;var u=1/l,f=r*s-o*a,c=i*a-e*s;return t.m[0]=o*u,t.m[1]=-i*u,t.m[2]=-r*u,t.m[3]=e*u,t.m[4]=f*u,t.m[5]=c*u,this},n.prototype.multiplyToRef=function(t,e){var i=this.m[0],r=this.m[1],o=this.m[2],a=this.m[3],s=this.m[4],l=this.m[5],u=t.m[0],f=t.m[1],c=t.m[2],h=t.m[3],p=t.m[4],_=t.m[5];return e.m[0]=i*u+r*c,e.m[1]=i*f+r*h,e.m[2]=o*u+a*c,e.m[3]=o*f+a*h,e.m[4]=s*u+l*c+p,e.m[5]=s*f+l*h+_,this},n.prototype.transformCoordinates=function(t,e,i){return i.x=t*this.m[0]+e*this.m[2]+this.m[4],i.y=t*this.m[1]+e*this.m[3]+this.m[5],this},n.Identity=function(){return new n(1,0,0,1,0,0)},n.TranslationToRef=function(t,e,i){i.fromValues(1,0,0,1,t,e)},n.ScalingToRef=function(t,e,i){i.fromValues(t,0,0,e,0,0)},n.RotationToRef=function(t,e){var i=Math.sin(t),r=Math.cos(t);e.fromValues(r,i,-i,r,0,0)},n.ComposeToRef=function(t,e,i,r,o,a,s){n.TranslationToRef(t,e,n._TempPreTranslationMatrix),n.ScalingToRef(r,o,n._TempScalingMatrix),n.RotationToRef(i,n._TempRotationMatrix),n.TranslationToRef(-t,-e,n._TempPostTranslationMatrix),n._TempPreTranslationMatrix.multiplyToRef(n._TempScalingMatrix,n._TempCompose0),n._TempCompose0.multiplyToRef(n._TempRotationMatrix,n._TempCompose1),a?(n._TempCompose1.multiplyToRef(n._TempPostTranslationMatrix,n._TempCompose2),n._TempCompose2.multiplyToRef(a,s)):n._TempCompose1.multiplyToRef(n._TempPostTranslationMatrix,s)},n._TempPreTranslationMatrix=n.Identity(),n._TempPostTranslationMatrix=n.Identity(),n._TempRotationMatrix=n.Identity(),n._TempScalingMatrix=n.Identity(),n._TempCompose0=n.Identity(),n._TempCompose1=n.Identity(),n._TempCompose2=n.Identity(),n}(),ot=function(){function n(t){this.name=t,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=Jr.Empty(),this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new zt(18,zt.UNITMODE_PIXEL,!1),this._width=new zt(1,zt.UNITMODE_PERCENTAGE,!1),this._height=new zt(1,zt.UNITMODE_PERCENTAGE,!1),this._color="",this._style=null,this._horizontalAlignment=n.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=n.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._wasDirty=!1,this._tempParentMeasure=Jr.Empty(),this._prevCurrentMeasureTransformedIntoGlobalSpace=Jr.Empty(),this._cachedParentMeasure=Jr.Empty(),this._paddingLeft=new zt(0),this._paddingRight=new zt(0),this._paddingTop=new zt(0),this._paddingBottom=new zt(0),this._left=new zt(0),this._top=new zt(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=ay.Identity(),this._invertTransformMatrix=ay.Identity(),this._transformedPosition=Ie.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._isHighlighted=!1,this._fontSet=!1,this._dummyVector2=Ie.Zero(),this._downCount=0,this._enterCount=-1,this._doNotRender=!1,this._downPointerIds={},this._isEnabled=!0,this._disabledColor="#9a9a9a",this._disabledColorItem="#6a6a6a",this._rebuildLayout=!1,this._customData={},this._isClipped=!1,this._automaticSize=!1,this.metadata=null,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this.isFocusInvisible=!1,this.clipChildren=!0,this.clipContent=!0,this.useBitmapCache=!1,this._shadowOffsetX=0,this._shadowOffsetY=0,this._shadowBlur=0,this._shadowColor="black",this.hoverCursor="",this._linkOffsetX=new zt(0),this._linkOffsetY=new zt(0),this.onWheelObservable=new ie,this.onPointerMoveObservable=new ie,this.onPointerOutObservable=new ie,this.onPointerDownObservable=new ie,this.onPointerUpObservable=new ie,this.onPointerClickObservable=new ie,this.onPointerEnterObservable=new ie,this.onDirtyObservable=new ie,this.onBeforeDrawObservable=new ie,this.onAfterDrawObservable=new ie,this.onDisposeObservable=new ie,this.fixedRatio=0,this._fixedRatioMasterIsWidth=!0,this._tmpMeasureA=new Jr(0,0,0,0)}return Object.defineProperty(n.prototype,"shadowOffsetX",{get:function(){return this._shadowOffsetX},set:function(t){this._shadowOffsetX!==t&&(this._shadowOffsetX=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowOffsetY",{get:function(){return this._shadowOffsetY},set:function(t){this._shadowOffsetY!==t&&(this._shadowOffsetY=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowBlur",{get:function(){return this._shadowBlur},set:function(t){this._shadowBlur!==t&&(this._shadowBlur=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(t){this._shadowColor!==t&&(this._shadowColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),n.prototype.getClassName=function(){return this._getTypeName()},Object.defineProperty(n.prototype,"host",{get:function(){return this._host},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontOffset",{get:function(){return this._fontOffset},set:function(t){this._fontOffset=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alphaSet=!0,this._alpha=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isHighlighted",{get:function(){return this._isHighlighted},set:function(t){this._isHighlighted!==t&&(this._isHighlighted=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this._scaleX!==t&&(this._scaleX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this._scaleY!==t&&(this._scaleY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(t){this._transformCenterY!==t&&(this._transformCenterY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(t){this._transformCenterX!==t&&(this._transformCenterX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(t){this._horizontalAlignment!==t&&(this._horizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(t){this._verticalAlignment!==t&&(this._verticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!0,this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"widthInPixels",{get:function(){return this._width.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!0,this.width=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!1,this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"heightInPixels",{get:function(){return this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!1,this.height=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontFamily",{get:function(){return this._fontSet?this._fontFamily:""},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"style",{get:function(){return this._style},set:function(t){var e=this;this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._style=t,this._style&&(this._styleObserver=this._style.onChangedObservable.add(function(){e._markAsDirty(),e._resetFontCache()})),this._markAsDirty(),this._resetFontCache()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_isFontSizeInPercentage",{get:function(){return this._fontSize.isPercentage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontSizeInPixels",{get:function(){var t=this._style?this._style._fontSize:this._fontSize;return t.isPixel?t.getValue(this._host):t.getValueInPixel(this._host,this._tempParentMeasure.height||this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.fontSize=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&(this._markAsDirty(),this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"color",{get:function(){return this._color},set:function(t){this._color!==t&&(this._color=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this.zIndex!==t&&(this._zIndex=t,this.parent&&this.parent._reOrderControl(this))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"notRenderable",{get:function(){return this._doNotRender},set:function(t){this._doNotRender!==t&&(this._doNotRender=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!==t&&(this._isVisible=t,this._markAsDirty(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkedMesh",{get:function(){return this._linkedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(t){this._paddingLeft.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingLeftInPixels",{get:function(){return this._paddingLeft.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingLeft=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(t){this._paddingRight.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingRightInPixels",{get:function(){return this._paddingRight.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingRight=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(t){this._paddingTop.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingTopInPixels",{get:function(){return this._paddingTop.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingTop=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(t){this._paddingBottom.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingBottomInPixels",{get:function(){return this._paddingBottom.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingBottom=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(t){this._left.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"leftInPixels",{get:function(){return this._left.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.left=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(t){this._top.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"topInPixels",{get:function(){return this._top.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.top=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(t){this._linkOffsetX.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetXInPixels",{get:function(){return this._linkOffsetX.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.linkOffsetX=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(t){this._linkOffsetY.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetYInPixels",{get:function(){return this._linkOffsetY.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.linkOffsetY=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"disabledColor",{get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"disabledColorItem",{get:function(){return this._disabledColorItem},set:function(t){this._disabledColorItem!==t&&(this._disabledColorItem=t,this._markAsDirty())},enumerable:!1,configurable:!0}),n.prototype._getTypeName=function(){return"Control"},n.prototype.getAscendantOfClass=function(t){return this.parent?this.parent.getClassName()===t?this.parent:this.parent.getAscendantOfClass(t):null},n.prototype._resetFontCache=function(){this._fontSet=!0,this._markAsDirty()},n.prototype.isAscendant=function(t){return this.parent?this.parent===t?!0:this.parent.isAscendant(t):!1},n.prototype.getLocalCoordinates=function(t){var e=Ie.Zero();return this.getLocalCoordinatesToRef(t,e),e},n.prototype.getLocalCoordinatesToRef=function(t,e){return e.x=t.x-this._currentMeasure.left,e.y=t.y-this._currentMeasure.top,this},n.prototype.getParentLocalCoordinates=function(t){var e=Ie.Zero();return e.x=t.x-this._cachedParentMeasure.left,e.y=t.y-this._cachedParentMeasure.top,e},n.prototype.moveToVector3=function(t,e){if(!this._host||this.parent!==this._host._rootContainer){Ee.Error("Cannot move a control to a vector3 if the control is not at root level");return}this.horizontalAlignment=n.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=n.VERTICAL_ALIGNMENT_TOP;var i=this._host._getGlobalViewport(e),r=y.Project(t,te.Identity(),e.getTransformMatrix(),i);if(this._moveToProjectedPosition(r),r.z<0||r.z>1){this.notRenderable=!0;return}this.notRenderable=!1},n.prototype.getDescendantsToRef=function(t,e,i){},n.prototype.getDescendants=function(t,e){var i=new Array;return this.getDescendantsToRef(i,t,e),i},n.prototype.linkWithMesh=function(t){if(!this._host||this.parent&&this.parent!==this._host._rootContainer){t&&Ee.Error("Cannot link a control to a mesh if the control is not at root level");return}var e=this._host._linkedControls.indexOf(this);if(e!==-1){this._linkedMesh=t,t||this._host._linkedControls.splice(e,1);return}else if(!t)return;this.horizontalAlignment=n.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=n.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=t,this._host._linkedControls.push(this)},n.prototype._moveToProjectedPosition=function(t){var e=this._left.getValue(this._host),i=this._top.getValue(this._host),r=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,o=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-e)<.5&&(r=e),Math.abs(o-i)<.5&&(o=i)),this.left=r+"px",this.top=o+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},n.prototype._offsetLeft=function(t){this._isDirty=!0,this._currentMeasure.left+=t},n.prototype._offsetTop=function(t){this._isDirty=!0,this._currentMeasure.top+=t},n.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},n.prototype._flagDescendantsAsMatrixDirty=function(){},n.prototype._intersectsRect=function(t){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=t.left+t.width||this._tmpMeasureA.top>=t.top+t.height||this._tmpMeasureA.left+this._tmpMeasureA.width<=t.left||this._tmpMeasureA.top+this._tmpMeasureA.height<=t.top)},n.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),Jr.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var t=this.shadowOffsetX,e=this.shadowOffsetY,i=this.shadowBlur,r=Math.min(Math.min(t,0)-i*2,0),o=Math.max(Math.max(t,0)+i*2,0),a=Math.min(Math.min(e,0)-i*2,0),s=Math.max(Math.max(e,0)+i*2,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+r),Math.floor(this._tmpMeasureA.top+a),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+o),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+s))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},n.prototype._markAsDirty=function(t){t===void 0&&(t=!1),!(!this._isVisible&&!t)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},n.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},n.prototype._link=function(t){this._host=t,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},n.prototype._transform=function(t){if(!(!this._isMatrixDirty&&this._scaleX===1&&this._scaleY===1&&this._rotation===0)){var e=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t&&(t.translate(e,i),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-e,-i)),(this._isMatrixDirty||this._cachedOffsetX!==e||this._cachedOffsetY!==i)&&(this._cachedOffsetX=e,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),ay.ComposeToRef(-e,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},n.prototype._renderHighlight=function(t){this.isHighlighted&&(t.save(),t.strokeStyle="#4affff",t.lineWidth=2,this._renderHighlightSpecific(t),t.restore())},n.prototype._renderHighlightSpecific=function(t){t.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},n.prototype._applyStates=function(t){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),n.AllowAlphaInheritance?t.globalAlpha*=this._alpha:this._alphaSet&&(t.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},n.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(t)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,-this.paddingLeftInPixels|0,-this.paddingTopInPixels|0,this.paddingRightInPixels|0,this.paddingBottomInPixels|0,this._prevCurrentMeasureTransformedIntoGlobalSpace),e.save(),this._applyStates(e);var i=0;do this._rebuildLayout=!1,this._processMeasures(t,e),i++;while(this._rebuildLayout&&i<3);i>=3&&de.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this.invalidateRect(),this._evaluateClippingState(t)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},n.prototype._processMeasures=function(t,e){this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=this._currentMeasure.left|0,this._currentMeasure.top=this._currentMeasure.top|0,this._currentMeasure.width=this._currentMeasure.width|0,this._currentMeasure.height=this._currentMeasure.height|0,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},n.prototype._evaluateClippingState=function(t){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>t.left+t.width){this._isClipped=!0;return}if(this._currentMeasure.left+this._currentMeasure.width<t.left){this._isClipped=!0;return}if(this._currentMeasure.top>t.top+t.height){this._isClipped=!0;return}if(this._currentMeasure.top+this._currentMeasure.height<t.top){this._isClipped=!0;return}}this._isClipped=!1},n.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host),this.fixedRatio!==0&&(this._fixedRatioMasterIsWidth?this._currentMeasure.height=this._currentMeasure.width*this.fixedRatio:this._currentMeasure.width=this._currentMeasure.height*this.fixedRatio)},n.prototype._computeAlignment=function(t,e){var i=this._currentMeasure.width,r=this._currentMeasure.height,o=t.width,a=t.height,s=0,l=0;switch(this.horizontalAlignment){case n.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case n.HORIZONTAL_ALIGNMENT_RIGHT:s=o-i;break;case n.HORIZONTAL_ALIGNMENT_CENTER:s=(o-i)/2;break}switch(this.verticalAlignment){case n.VERTICAL_ALIGNMENT_TOP:l=0;break;case n.VERTICAL_ALIGNMENT_BOTTOM:l=a-r;break;case n.VERTICAL_ALIGNMENT_CENTER:l=(a-r)/2;break}this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=o*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=o*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=o*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=a*this._paddingTop.getValue(this._host),this._currentMeasure.height-=a*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=a*this._paddingBottom.getValue(this._host),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=o*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=a*this._top.getValue(this._host),this._currentMeasure.left+=s,this._currentMeasure.top+=l},n.prototype._preMeasure=function(t,e){},n.prototype._additionalProcessing=function(t,e){},n.prototype._clipForChildren=function(t){},n.prototype._clip=function(t,e){if(t.beginPath(),n._ClipMeasure.copyFrom(this._currentMeasure),e){e.transformToRef(this._invertTransformMatrix,this._tmpMeasureA);var i=new Jr(0,0,0,0);i.left=Math.max(this._tmpMeasureA.left,this._currentMeasure.left),i.top=Math.max(this._tmpMeasureA.top,this._currentMeasure.top),i.width=Math.min(this._tmpMeasureA.left+this._tmpMeasureA.width,this._currentMeasure.left+this._currentMeasure.width)-i.left,i.height=Math.min(this._tmpMeasureA.top+this._tmpMeasureA.height,this._currentMeasure.top+this._currentMeasure.height)-i.top,n._ClipMeasure.copyFrom(i)}if(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var r=this.shadowOffsetX,o=this.shadowOffsetY,a=this.shadowBlur,s=Math.min(Math.min(r,0)-a*2,0),l=Math.max(Math.max(r,0)+a*2,0),u=Math.min(Math.min(o,0)-a*2,0),f=Math.max(Math.max(o,0)+a*2,0);t.rect(n._ClipMeasure.left+s,n._ClipMeasure.top+u,n._ClipMeasure.width+l-s,n._ClipMeasure.height+f-u)}else t.rect(n._ClipMeasure.left,n._ClipMeasure.top,n._ClipMeasure.width,n._ClipMeasure.height);t.clip()},n.prototype._render=function(t,e){return!this.isVisible||this.notRenderable||this._isClipped?(this._isDirty=!1,!1):(this.host._numRenderCalls++,t.save(),this._applyStates(t),this._transform(t),this.clipContent&&this._clip(t,e),this.onBeforeDrawObservable.hasObservers()&&this.onBeforeDrawObservable.notifyObservers(this),this.useBitmapCache&&!this._wasDirty&&this._cacheData?t.putImageData(this._cacheData,this._currentMeasure.left,this._currentMeasure.top):this._draw(t,e),this.useBitmapCache&&this._wasDirty&&(this._cacheData=t.getImageData(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._renderHighlight(t),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this),t.restore(),!0)},n.prototype._draw=function(t,e){},n.prototype.contains=function(t,e){return this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y,t<this._currentMeasure.left||t>this._currentMeasure.left+this._currentMeasure.width||e<this._currentMeasure.top||e>this._currentMeasure.top+this._currentMeasure.height?!1:(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0)},n.prototype._processPicking=function(t,e,i,r,o,a,s,l){return!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this._doNotRender||!this.contains(t,e)?!1:(this._processObservables(r,t,e,i,o,a,s,l),!0)},n.prototype._onPointerMove=function(t,e,i,r){var o=this.onPointerMoveObservable.notifyObservers(e,-1,t,this,r);o&&this.parent!=null&&this.parent._onPointerMove(t,e,i,r)},n.prototype._onPointerEnter=function(t,e){if(!this._isEnabled||this._enterCount>0)return!1;this._enterCount===-1&&(this._enterCount=0),this._enterCount++;var i=this.onPointerEnterObservable.notifyObservers(this,-1,t,this,e);return i&&this.parent!=null&&this.parent._onPointerEnter(t,e),!0},n.prototype._onPointerOut=function(t,e,i){if(i===void 0&&(i=!1),!(!i&&(!this._isEnabled||t===this))){this._enterCount=0;var r=!0;t.isAscendant(this)||(r=this.onPointerOutObservable.notifyObservers(this,-1,t,this,e)),r&&this.parent!=null&&this.parent._onPointerOut(t,e,i)}},n.prototype._onPointerDown=function(t,e,i,r,o){if(this._onPointerEnter(this,o),this._downCount!==0)return!1;this._downCount++,this._downPointerIds[i]=!0;var a=this.onPointerDownObservable.notifyObservers(new oy(e,r),-1,t,this,o);return a&&this.parent!=null&&this.parent._onPointerDown(t,e,i,r,o),!0},n.prototype._onPointerUp=function(t,e,i,r,o,a){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var s=o;o&&(this._enterCount>0||this._enterCount===-1)&&(s=this.onPointerClickObservable.notifyObservers(new oy(e,r),-1,t,this,a));var l=this.onPointerUpObservable.notifyObservers(new oy(e,r),-1,t,this,a);l&&this.parent!=null&&this.parent._onPointerUp(t,e,i,r,s,a)}},n.prototype._forcePointerUp=function(t){if(t===void 0&&(t=null),t!==null)this._onPointerUp(this,Ie.Zero(),t,0,!0);else for(var e in this._downPointerIds)this._onPointerUp(this,Ie.Zero(),+e,0,!0)},n.prototype._onWheelScroll=function(t,e){if(this._isEnabled){var i=this.onWheelObservable.notifyObservers(new Ie(t,e));i&&this.parent!=null&&this.parent._onWheelScroll(t,e)}},n.prototype._onCanvasBlur=function(){},n.prototype._processObservables=function(t,e,i,r,o,a,s,l){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(e,i),t===He.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,o,r);var u=this._host._lastControlOver[o];return u&&u!==this&&u._onPointerOut(this,r),u!==this&&this._onPointerEnter(this,r),this._host._lastControlOver[o]=this,!0}return t===He.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,o,a,r),this._host._registerLastControlDown(this,o),this._host._lastPickedControl=this,!0):t===He.POINTERUP?(this._host._lastControlDown[o]&&this._host._lastControlDown[o]._onPointerUp(this,this._dummyVector2,o,a,!0,r),delete this._host._lastControlDown[o],!0):t===He.POINTERWHEEL&&this._host._lastControlOver[o]?(this._host._lastControlOver[o]._onWheelScroll(s,l),!0):!1},n.prototype._prepareFont=function(){!this._font&&!this._fontSet||(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=n._GetFontOffset(this._font))},n.prototype.dispose=function(){if(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host){var t=this._host._linkedControls.indexOf(this);t>-1&&this.linkWithMesh(null)}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return n._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return n._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return n._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_TOP",{get:function(){return n._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return n._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return n._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),n._GetFontOffset=function(t){if(n._FontHeightSizes[t])return n._FontHeightSizes[t];var e=document.createElement("span");e.innerHTML="Hg",e.style.font=t;var i=document.createElement("div");i.style.display="inline-block",i.style.width="1px",i.style.height="0px",i.style.verticalAlign="bottom";var r=document.createElement("div");r.style.whiteSpace="nowrap",r.appendChild(e),r.appendChild(i),document.body.appendChild(r);var o=0,a=0;try{a=i.getBoundingClientRect().top-e.getBoundingClientRect().top,i.style.verticalAlign="baseline",o=i.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(r)}var s={ascent:o,height:a,descent:a-o};return n._FontHeightSizes[t]=s,s},n.drawEllipse=function(t,e,i,r,o){o.translate(t,e),o.scale(i,r),o.beginPath(),o.arc(0,0,1,0,2*Math.PI),o.closePath(),o.scale(1/i,1/r),o.translate(-t,-e)},n.AllowAlphaInheritance=!1,n._ClipMeasure=new Jr(0,0,0,0),n._HORIZONTAL_ALIGNMENT_LEFT=0,n._HORIZONTAL_ALIGNMENT_RIGHT=1,n._HORIZONTAL_ALIGNMENT_CENTER=2,n._VERTICAL_ALIGNMENT_TOP=0,n._VERTICAL_ALIGNMENT_BOTTOM=1,n._VERTICAL_ALIGNMENT_CENTER=2,n._FontHeightSizes={},n.AddHeader=function(){},n}();Ae.RegisteredTypes["BABYLON.GUI.Control"]=ot;var so=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._children=new Array,i._measureForChildren=Jr.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return Object.defineProperty(t.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(e){this._adaptHeightToChildren!==e&&(this._adaptHeightToChildren=e,e&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(e){this._adaptWidthToChildren!==e&&(this._adaptWidthToChildren=e,e&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Container"},t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,i=this.children;e<i.length;e++){var r=i[e];r._markMatrixAsDirty()}},t.prototype.getChildByName=function(e){for(var i=0,r=this.children;i<r.length;i++){var o=r[i];if(o.name===e)return o}return null},t.prototype.getChildByType=function(e,i){for(var r=0,o=this.children;r<o.length;r++){var a=o[r];if(a.typeName===i)return a}return null},t.prototype.containsControl=function(e){return this.children.indexOf(e)!==-1},t.prototype.addControl=function(e){if(!e)return this;var i=this._children.indexOf(e);return i!==-1?this:(e._link(this._host),e._markAllAsDirty(),this._reOrderControl(e),this._markAsDirty(),this)},t.prototype.clearControls=function(){for(var e=this.children.slice(),i=0,r=e;i<r.length;i++){var o=r[i];this.removeControl(o)}return this},t.prototype.removeControl=function(e){var i=this._children.indexOf(e);return i!==-1&&(this._children.splice(i,1),e.parent=null),e.linkWithMesh(null),this._host&&this._host._cleanControlAfterRemoval(e),this._markAsDirty(),this},t.prototype._reOrderControl=function(e){this.removeControl(e);for(var i=!1,r=0;r<this._children.length;r++)if(this._children[r].zIndex>e.zIndex){this._children.splice(r,0,e),i=!0;break}i||this._children.push(e),e.parent=this,this._markAsDirty()},t.prototype._offsetLeft=function(e){n.prototype._offsetLeft.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._offsetLeft(e)}},t.prototype._offsetTop=function(e){n.prototype._offsetTop.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._offsetTop(e)}},t.prototype._markAllAsDirty=function(){n.prototype._markAllAsDirty.call(this);for(var e=0;e<this._children.length;e++)this._children[e]._markAllAsDirty()},t.prototype._localDraw=function(e){this._background&&(e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),e.restore())},t.prototype._link=function(e){n.prototype._link.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._link(e)}},t.prototype._beforeLayout=function(){},t.prototype._processMeasures=function(e,i){(this._isDirty||!this._cachedParentMeasure.isEqualsTo(e))&&(n.prototype._processMeasures.call(this,e,i),this._evaluateClippingState(e))},t.prototype._layout=function(e,i){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;this.host._numLayoutCalls++,this._isDirty&&this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace);var r=0;i.save(),this._applyStates(i),this._beforeLayout();do{var o=-1,a=-1;if(this._rebuildLayout=!1,this._processMeasures(e,i),!this._isClipped){for(var s=0,l=this._children;s<l.length;s++){var u=l[s];u._tempParentMeasure.copyFrom(this._measureForChildren),u._layout(this._measureForChildren,i)&&(this.adaptWidthToChildren&&u._width.isPixel&&(o=Math.max(o,u._currentMeasure.width+u.paddingLeftInPixels+u.paddingRightInPixels)),this.adaptHeightToChildren&&u._height.isPixel&&(a=Math.max(a,u._currentMeasure.height+u.paddingTopInPixels+u.paddingBottomInPixels)))}this.adaptWidthToChildren&&o>=0&&(o+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==o+"px"&&(this.width=o+"px",this._rebuildLayout=!0)),this.adaptHeightToChildren&&a>=0&&(a+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==a+"px"&&(this.height=a+"px",this._rebuildLayout=!0)),this._postMeasure()}r++}while(this._rebuildLayout&&r<this.maxLayoutCycle);return r>=3&&this.logLayoutCycleErrors&&de.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),i.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},t.prototype._postMeasure=function(){},t.prototype._draw=function(e,i){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);for(var r=0,o=this._children;r<o.length;r++){var a=o[r];i&&!a._intersectsRect(i)||a._render(e,i)}},t.prototype.getDescendantsToRef=function(e,i,r){if(i===void 0&&(i=!1),!!this.children)for(var o=0;o<this.children.length;o++){var a=this.children[o];(!r||r(a))&&e.push(a),i||a.getDescendantsToRef(e,!1,r)}},t.prototype._processPicking=function(e,i,r,o,a,s,l,u){if(!this._isEnabled||!this.isVisible||this.notRenderable||!n.prototype.contains.call(this,e,i))return!1;for(var f=this._children.length-1;f>=0;f--){var c=this._children[f];if(c._processPicking(e,i,r,o,a,s,l,u))return c.hoverCursor&&this._host._changeCursor(c.hoverCursor),!0}return this.isHitTestVisible?this._processObservables(o,e,i,r,a,s,l,u):!1},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(this._currentMeasure)},t.prototype.dispose=function(){n.prototype.dispose.call(this);for(var e=this.children.length-1;e>=0;e--)this.children[e].dispose()},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.Container"]=so;var lo=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(e){e<0&&(e=0),this._cornerRadius!==e&&(this._cornerRadius=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Rectangle"},t.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._background&&(e.fillStyle=this._background,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.fill()):e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.stroke()):e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),e.restore()},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},t.prototype._drawRoundedRect=function(e,i){i===void 0&&(i=0);var r=this._currentMeasure.left+i,o=this._currentMeasure.top+i,a=this._currentMeasure.width-i*2,s=this._currentMeasure.height-i*2,l=Math.min(s/2-2,Math.min(a/2-2,this._cornerRadius));e.beginPath(),e.moveTo(r+l,o),e.lineTo(r+a-l,o),e.quadraticCurveTo(r+a,o,r+a,o+l),e.lineTo(r+a,o+s-l),e.quadraticCurveTo(r+a,o+s,r+a-l,o+s),e.lineTo(r+l,o+s),e.quadraticCurveTo(r,o+s,r,o+s-l),e.lineTo(r,o+l),e.quadraticCurveTo(r,o,r+l,o),e.closePath()},t.prototype._clipForChildren=function(e){this._cornerRadius&&(this._drawRoundedRect(e,this._thickness),e.clip())},t}(so);Ae.RegisteredTypes["BABYLON.GUI.Rectangle"]=lo;var $l;(function(n){n[n.Clip=0]="Clip",n[n.WordWrap=1]="WordWrap",n[n.Ellipsis=2]="Ellipsis"})($l||($l={}));var Mn=function(n){j(t,n);function t(e,i){i===void 0&&(i="");var r=n.call(this,e)||this;return r.name=e,r._text="",r._textWrapping=$l.Clip,r._textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,r._textVerticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,r._resizeToFit=!1,r._lineSpacing=new zt(0),r._outlineWidth=0,r._outlineColor="white",r._underline=!1,r._lineThrough=!1,r.onTextChangedObservable=new ie,r.onLinesReadyObservable=new ie,r.text=i,r}return Object.defineProperty(t.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(e){this._resizeToFit!==e&&(this._resizeToFit=e,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(e){this._textWrapping!==e&&(this._textWrapping=+e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"text",{get:function(){return this._text},set:function(e){this._text!==e&&(this._text=e,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(e){this._textHorizontalAlignment!==e&&(this._textHorizontalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(e){this._textVerticalAlignment!==e&&(this._textVerticalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(e){this._lineSpacing.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(e){this._outlineWidth!==e&&(this._outlineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"underline",{get:function(){return this._underline},set:function(e){this._underline!==e&&(this._underline=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(e){this._lineThrough!==e&&(this._lineThrough=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(e){this._outlineColor!==e&&(this._outlineColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"TextBlock"},t.prototype._processMeasures=function(e,i){this._fontOffset||(this._fontOffset=ot._GetFontOffset(i.font)),n.prototype._processMeasures.call(this,e,i),this._lines=this._breakLines(this._currentMeasure.width,i),this.onLinesReadyObservable.notifyObservers(this);for(var r=0,o=0;o<this._lines.length;o++){var a=this._lines[o];a.width>r&&(r=a.width)}if(this._resizeToFit){if(this._textWrapping===$l.Clip){var s=this.paddingLeftInPixels+this.paddingRightInPixels+r|0;s!==this._width.internalValue&&(this._width.updateInPlace(s,zt.UNITMODE_PIXEL),this._rebuildLayout=!0)}var l=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&this._lineSpacing.internalValue!==0){var u=0;this._lineSpacing.isPixel?u=this._lineSpacing.getValue(this._host):u=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),l+=(this._lines.length-1)*u}l!==this._height.internalValue&&(this._height.updateInPlace(l,zt.UNITMODE_PIXEL),this._rebuildLayout=!0)}},t.prototype._drawText=function(e,i,r,o){var a=this._currentMeasure.width,s=0;switch(this._textHorizontalAlignment){case ot.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case ot.HORIZONTAL_ALIGNMENT_RIGHT:s=a-i;break;case ot.HORIZONTAL_ALIGNMENT_CENTER:s=(a-i)/2;break}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(o.shadowColor=this.shadowColor,o.shadowBlur=this.shadowBlur,o.shadowOffsetX=this.shadowOffsetX,o.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&o.strokeText(e,this._currentMeasure.left+s,r),o.fillText(e,this._currentMeasure.left+s,r),this._underline&&(o.beginPath(),o.lineWidth=Math.round(this.fontSizeInPixels*.05),o.moveTo(this._currentMeasure.left+s,r+3),o.lineTo(this._currentMeasure.left+s+i,r+3),o.stroke(),o.closePath()),this._lineThrough&&(o.beginPath(),o.lineWidth=Math.round(this.fontSizeInPixels*.05),o.moveTo(this._currentMeasure.left+s,r-this.fontSizeInPixels/3),o.lineTo(this._currentMeasure.left+s+i,r-this.fontSizeInPixels/3),o.stroke(),o.closePath())},t.prototype._draw=function(e,i){e.save(),this._applyStates(e),this._renderLines(e),e.restore()},t.prototype._applyStates=function(e){n.prototype._applyStates.call(this,e),this.outlineWidth&&(e.lineWidth=this.outlineWidth,e.strokeStyle=this.outlineColor,e.lineJoin="miter",e.miterLimit=2)},t.prototype._breakLines=function(e,i){var r=[],o=this.text.split(`
13296
+ \r`),a=0;a<r;a++){var s=o[a].split(",").map(Number),l=e._createTileBuffer(s);e._tileMaps[a].dispose(),e._tileMaps[a]=l}e._material.setTextureArray("tileMap",e._tileMaps)},i.send()},n.prototype.dispose=function(){this._output.dispose(),this._material.dispose(),this._animationMap.dispose(),this._tileMaps.forEach(function(t){t.dispose()}),this._frameMap.dispose()},n}(),x8=function(n){j(t,n);function t(e,i,r,o,a,s,l){a===void 0&&(a=null),s===void 0&&(s=.01),l===void 0&&(l=he.TRILINEAR_SAMPLINGMODE);var u=n.call(this,e,i,r,64,o,s,l,!0,a)||this;return u.name=e,u}return t}(a5),ya;(function(n){n[n.INIT=0]="INIT",n[n.RUNNING=1]="RUNNING",n[n.DONE=2]="DONE",n[n.ERROR=3]="ERROR"})(ya||(ya={}));var Ra=function(){function n(t){this.name=t,this._isCompleted=!1,this._taskState=ya.INIT}return Object.defineProperty(n.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"taskState",{get:function(){return this._taskState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),n.prototype._setErrorObject=function(t,e){this._errorObject||(this._errorObject={message:t,exception:e})},n.prototype.run=function(t,e,i){var r=this;this._taskState=ya.RUNNING,this.runTask(t,function(){r.onDoneCallback(e,i)},function(o,a){r.onErrorCallback(i,o,a)})},n.prototype.runTask=function(t,e,i){throw new Error("runTask is not implemented")},n.prototype.reset=function(){this._taskState=ya.INIT},n.prototype.onErrorCallback=function(t,e,i){this._taskState=ya.ERROR,this._errorObject={message:e,exception:i},this.onError&&this.onError(this,e,i),t()},n.prototype.onDoneCallback=function(t,e){try{this._taskState=ya.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),t()}catch(i){this.onErrorCallback(e,"Task is done, error executing success callback(s)",i)}},n}(),c5=function(){function n(t,e,i){this.remainingCount=t,this.totalCount=e,this.task=i}return n}(),h5=function(n){j(t,n);function t(e,i,r,o){var a=n.call(this,e)||this;return a.name=e,a.meshesNames=i,a.rootUrl=r,a.sceneFilename=o,a}return t.prototype.runTask=function(e,i,r){var o=this;$t.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,function(a){o.loadedContainer=a,o.loadedMeshes=a.meshes,o.loadedParticleSystems=a.particleSystems,o.loadedSkeletons=a.skeletons,o.loadedAnimationGroups=a.animationGroups,i()},null,function(a,s,l){r(s,l)})},t}(Ra),d5=function(n){j(t,n);function t(e,i,r,o){var a=n.call(this,e)||this;return a.name=e,a.meshesNames=i,a.rootUrl=r,a.sceneFilename=o,a}return t.prototype.runTask=function(e,i,r){var o=this;$t.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,function(a,s,l,u){o.loadedMeshes=a,o.loadedParticleSystems=s,o.loadedSkeletons=l,o.loadedAnimationGroups=u,i()},null,function(a,s,l){r(s,l)})},t}(Ra),p5=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this;e._loadFile(this.url,function(a){o.text=a,i()},void 0,!1,!1,function(a,s){a&&r(a.status+" "+a.statusText,s)})},t}(Ra),NI=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this;e._loadFile(this.url,function(a){o.data=a,i()},void 0,!0,!0,function(a,s){a&&r(a.status+" "+a.statusText,s)})},t}(Ra),_5=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.name=e,r.url=i,r}return t.prototype.runTask=function(e,i,r){var o=this,a=new Image;Ee.SetCorsBehavior(this.url,a),a.onload=function(){o.image=a,i()},a.onerror=function(s){r("Error loading image",s)},a.src=this.url},t}(Ra),Xb=function(n){j(t,n);function t(e,i,r,o,a){o===void 0&&(o=!0),a===void 0&&(a=he.TRILINEAR_SAMPLINGMODE);var s=n.call(this,e)||this;return s.name=e,s.url=i,s.noMipmap=r,s.invertY=o,s.samplingMode=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new he(this.url,e,this.noMipmap,this.invertY,this.samplingMode,o,a)},t}(Ra),m5=function(n){j(t,n);function t(e,i,r,o,a){var s=n.call(this,e)||this;return s.name=e,s.url=i,s.extensions=r,s.noMipmap=o,s.files=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new Yo(this.url,e,this.extensions,this.noMipmap,this.files,o,a)},t}(Ra),g5=function(n){j(t,n);function t(e,i,r,o,a,s,l){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=!1);var u=n.call(this,e)||this;return u.name=e,u.url=i,u.size=r,u.noMipmap=o,u.generateHarmonics=a,u.gammaSpace=s,u.reserved=l,u}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new Ub(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,o,a)},t}(Ra),v5=function(n){j(t,n);function t(e,i,r,o,a){o===void 0&&(o=!1),a===void 0&&(a=!0);var s=n.call(this,e)||this;return s.name=e,s.url=i,s.size=r,s.noMipmap=o,s.gammaSpace=a,s}return t.prototype.runTask=function(e,i,r){var o=function(){i()},a=function(s,l){r(s,l)};this.texture=new $G(this.url,e,this.size,this.noMipmap,this.gammaSpace,o,a)},t}(Ra),I8=function(){function n(t){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new ie,this.onTaskErrorObservable=new ie,this.onTasksDoneObservable=new ie,this.onProgressObservable=new ie,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=t}return n.prototype.addContainerTask=function(t,e,i,r){var o=new h5(t,e,i,r);return this._tasks.push(o),o},n.prototype.addMeshTask=function(t,e,i,r){var o=new d5(t,e,i,r);return this._tasks.push(o),o},n.prototype.addTextFileTask=function(t,e){var i=new p5(t,e);return this._tasks.push(i),i},n.prototype.addBinaryFileTask=function(t,e){var i=new NI(t,e);return this._tasks.push(i),i},n.prototype.addImageTask=function(t,e){var i=new _5(t,e);return this._tasks.push(i),i},n.prototype.addTextureTask=function(t,e,i,r,o){o===void 0&&(o=he.TRILINEAR_SAMPLINGMODE);var a=new Xb(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.addCubeTextureTask=function(t,e,i,r,o){var a=new m5(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.addHDRCubeTextureTask=function(t,e,i,r,o,a,s){r===void 0&&(r=!1),o===void 0&&(o=!0),a===void 0&&(a=!1),s===void 0&&(s=!1);var l=new g5(t,e,i,r,o,a,s);return this._tasks.push(l),l},n.prototype.addEquiRectangularCubeTextureAssetTask=function(t,e,i,r,o){r===void 0&&(r=!1),o===void 0&&(o=!0);var a=new v5(t,e,i,r,o);return this._tasks.push(a),a},n.prototype.removeTask=function(t){var e=this._tasks.indexOf(t);e>-1&&this._tasks.splice(e,1)},n.prototype._decreaseWaitingTasksCount=function(t){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,t),this.onProgressObservable.notifyObservers(new c5(this._waitingTasksCount,this._totalTasksCount,t))}catch(a){de.Error("Error running progress callbacks."),console.log(a)}if(this._waitingTasksCount===0){try{var e=this._tasks.slice();this.onFinish&&this.onFinish(e);for(var i=0,r=e;i<r.length;i++){var t=r[i];if(t.taskState===ya.DONE){var o=this._tasks.indexOf(t);o>-1&&this._tasks.splice(o,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(a){de.Error("Error running tasks-done callbacks."),console.log(a)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},n.prototype._runTask=function(t){var e=this,i=function(){try{e.onTaskSuccess&&e.onTaskSuccess(t),e.onTaskSuccessObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)}catch(o){r("Error executing task success callbacks",o)}},r=function(o,a){t._setErrorObject(o,a),e.onTaskError&&e.onTaskError(t),e.onTaskErrorObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)};t.run(this._scene,i,r)},n.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},n.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var t=0;t<this._tasks.length;t++){var e=this._tasks[t];e.taskState===ya.INIT&&this._runTask(e)}return this},n.prototype.loadAsync=function(){var t=this;return new Promise(function(e,i){if(t._isLoading){e();return}t.onTasksDoneObservable.addOnce(function(r){r&&r.length?i(r):e()}),t.load()})},n}(),Nf=function(){function n(){var t=this;this.promise=new Promise(function(e,i){t._resolve=e,t._reject=i})}return Object.defineProperty(n.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),n}(),D8=function(){function n(t,e){this._meshesOrigins=[],this._toCenterVectors=[],this._scaledDirection=y.Zero(),this._newPosition=y.Zero(),this._centerPosition=y.Zero(),this._meshes=t.slice(),e?this._centerMesh=e:this._setCenterMesh();var i=this._meshes.indexOf(this._centerMesh);i>=0&&this._meshes.splice(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r];this._meshesOrigins[r]=o.getAbsolutePosition().clone(),this._toCenterVectors[r]=y.Zero(),o._boundingInfo&&this._centerMesh._boundingInfo&&o._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld,this._toCenterVectors[r])}}return n.prototype._setCenterMesh=function(){for(var t=y.Zero(),e=y.Zero(),i=Number.MAX_VALUE,r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r],a=o.getBoundingInfo();a&&e.addInPlace(a.boundingBox.centerWorld)}t=e.scale(1/this._meshes.length);for(var r=0;r<this._meshes.length;r++)if(this._meshes[r]){var o=this._meshes[r],a=o.getBoundingInfo();if(a){var s=a.boundingBox.centerWorld.subtract(t).lengthSquared();s<i&&(this._centerMesh=o,i=s)}}},n.prototype.getClassName=function(){return"MeshExploder"},n.prototype.getMeshes=function(){var t=this._meshes.slice();return t.unshift(this._centerMesh),t},n.prototype.explode=function(t){t===void 0&&(t=1);for(var e=0;e<this._meshes.length;e++)this._meshes[e]&&this._meshesOrigins[e]&&this._toCenterVectors[e]&&(this._toCenterVectors[e].scaleToRef(t,this._scaledDirection),this._meshesOrigins[e].addToRef(this._scaledDirection,this._newPosition),this._meshes[e].setAbsolutePosition(this._newPosition));this._centerMesh.setAbsolutePosition(this._centerPosition)},n}(),w8=function(){function n(t,e,i,r,o,a,s,l,u){this.onProcessFileCallback=function(){return!0},this._engine=t,this._currentScene=e,this._sceneLoadedCallback=i,this._progressCallback=r,this._additionalRenderLoopLogicCallback=o,this._textureLoadingCallback=a,this._startingProcessingFilesCallback=s,this._onReloadCallback=l,this._errorCallback=u}return Object.defineProperty(n,"FilesToLoad",{get:function(){return Gl.FilesToLoad},enumerable:!1,configurable:!0}),n.prototype.monitorElementForDragNDrop=function(t){var e=this;t&&(this._elementToMonitor=t,this._dragEnterHandler=function(i){e.drag(i)},this._dragOverHandler=function(i){e.drag(i)},this._dropHandler=function(i){e.drop(i)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},Object.defineProperty(n.prototype,"filesToLoad",{get:function(){return this._filesToLoad},enumerable:!1,configurable:!0}),n.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},n.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var t=this._currentScene.getWaitingItemsCount();t>0&&this._textureLoadingCallback(t)}this._currentScene.render()}},n.prototype.drag=function(t){t.stopPropagation(),t.preventDefault()},n.prototype.drop=function(t){t.stopPropagation(),t.preventDefault(),this.loadFiles(t)},n.prototype._traverseFolder=function(t,e,i,r){var o=this,a=t.createReader(),s=t.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");a.readEntries(function(l){i.count+=l.length;for(var u=0,f=l;u<f.length;u++){var c=f[u];c.isFile?c.file(function(h){h.correctName=s+h.name,e.push(h),--i.count===0&&r()}):c.isDirectory&&o._traverseFolder(c,e,i,r)}--i.count===0&&r()})},n.prototype._processFiles=function(t){for(var e=0;e<t.length;e++){var i=t[e].correctName.toLowerCase(),r=i.split(".").pop();this.onProcessFileCallback(t[e],i,r)&&($t.IsPluginForExtensionAvailable("."+r)&&(this._sceneFileToLoad=t[e]),n.FilesToLoad[i]=t[e])}},n.prototype.loadFiles=function(t){var e=this;if(t&&t.dataTransfer&&t.dataTransfer.files&&(this._filesToLoad=t.dataTransfer.files),t&&t.target&&t.target.files&&(this._filesToLoad=t.target.files),!(!this._filesToLoad||this._filesToLoad.length===0)&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var i=new Array,r=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a<this._filesToLoad.length;a++){var s=this._filesToLoad[a],l=s.name.toLowerCase(),u=void 0;if(s.correctName=l,o){var f=o[a];f.getAsEntry?u=f.getAsEntry():f.webkitGetAsEntry&&(u=f.webkitGetAsEntry())}u&&u.isDirectory?r.push(u):i.push(s)}if(r.length===0)this._processFiles(i),this._processReload();else for(var c={count:r.length},h=0,p=r;h<p.length;h++){var _=p[h];this._traverseFolder(_,i,c,function(){e._processFiles(i),c.count===0&&e._processReload()})}}},n.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},n.prototype.reload=function(){var t=this;this._sceneFileToLoad?(this._currentScene&&(de.errorsCount>0&&de.ClearLogCache(),this._engine.stopRenderLoop()),$t.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),$t.LoadAsync("file:",this._sceneFileToLoad,this._engine,function(e){t._progressCallback&&t._progressCallback(e)}).then(function(e){t._currentScene&&t._currentScene.dispose(),t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady(function(){t._engine.hideLoadingUI(),t._engine.runRenderLoop(function(){t.renderFunction()})})}).catch(function(e){t._engine.hideLoadingUI(),t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,e.message)})):de.Error("Please provide a valid .babylon file.")},n}(),Oa=function(){function n(t){t===void 0&&(t=0),this.priority=t}return n.prototype.getDescription=function(){return""},n.prototype.apply=function(t,e){return!0},n}(),zv=function(n){j(t,n);function t(e,i,r){e===void 0&&(e=0),i===void 0&&(i=1024),r===void 0&&(r=.5);var o=n.call(this,e)||this;return o.priority=e,o.maximumSize=i,o.step=r,o}return t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,i){for(var r=!0,o=0;o<e.textures.length;o++){var a=e.textures[o];if(!(!a.canRescale||a.getContext)){var s=a.getSize(),l=Math.max(s.width,s.height);l>this.maximumSize&&(a.scale(this.step),r=!1)}}return r},t}(Oa),NO=function(n){j(t,n);function t(e,i,r){e===void 0&&(e=0),i===void 0&&(i=2),r===void 0&&(r=.25);var o=n.call(this,e)||this;return o.priority=e,o.maximumScale=i,o.step=r,o._currentScale=-1,o._directionOffset=1,o}return t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,i){return this._currentScale===-1&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),this._directionOffset===1?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(Oa),Gv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,i){return e.shadowsEnabled=i.isInImprovementMode,!0},t}(Oa),Wv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,i){return e.postProcessesEnabled=i.isInImprovementMode,!0},t}(Oa),Hv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,i){return e.lensFlaresEnabled=i.isInImprovementMode,!0},t}(Oa),y5=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,i){return this.onApply?this.onApply(e,i):!0},t}(Oa),jv=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,i){return e.particlesEnabled=i.isInImprovementMode,!0},t}(Oa),FO=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,i){return e.renderTargetsEnabled=i.isInImprovementMode,!0},t}(Oa),Xv=function(n){j(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._canBeMerged=function(i){if(!(i instanceof ne))return!1;var r=i;return!(r.isDisposed()||!r.isVisible||!r.isEnabled()||r.instances.length>0||r.skeleton||r.hasLODLevels)},e}return Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,r){for(var o=e.meshes.slice(0),a=o.length,s=0;s<a;s++){var l=new Array,u=o[s];if(this._canBeMerged(u)){l.push(u);for(var f=s+1;f<a;f++){var c=o[f];this._canBeMerged(c)&&c.material===u.material&&c.checkCollisions===u.checkCollisions&&(l.push(c),a--,o.splice(f,1),f--)}l.length<2||ne.MergeMeshes(l,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(r!=null?r&&h.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(Oa),BO=function(){function n(t,e){t===void 0&&(t=60),e===void 0&&(e=2e3),this.targetFrameRate=t,this.trackerDuration=e,this.optimizations=new Array}return n.prototype.addOptimization=function(t){return this.optimizations.push(t),this},n.prototype.addCustomOptimization=function(t,e,i){i===void 0&&(i=0);var r=new y5(i);return r.onApply=t,r.onGetDescription=e,this.optimizations.push(r),this},n.LowDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,1024)),e},n.ModerateDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,512)),i++,e.addOptimization(new FO(i)),i++,e.addOptimization(new NO(i,2)),e},n.HighDegradationAllowed=function(t){var e=new n(t),i=0;return e.addOptimization(new Xv(i)),e.addOptimization(new Gv(i)),e.addOptimization(new Hv(i)),i++,e.addOptimization(new Wv(i)),e.addOptimization(new jv(i)),i++,e.addOptimization(new zv(i,256)),i++,e.addOptimization(new FO(i)),i++,e.addOptimization(new NO(i,4)),e},n}(),L8=function(){function n(t,e,i,r){var o=this;if(i===void 0&&(i=!0),r===void 0&&(r=!1),this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new ie,this.onNewOptimizationAppliedObservable=new ie,this.onFailureObservable=new ie,e?this._options=e:this._options=new BO,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i)for(var a=0,s=0,l=this._options.optimizations;s<l.length;s++){var u=l[s];u.priority=a++}this._improvementMode=r,this._scene=t||pt.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(n.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(t){this._trackerDuration=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!1,configurable:!0}),n.prototype.stop=function(){this._isRunning=!1},n.prototype.reset=function(){this._currentPriorityLevel=0},n.prototype.start=function(){var t=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)}))},n.prototype._checkCurrentState=function(){var t=this;if(this._isRunning){var e=this._scene,i=this._options;if(this._currentFrameRate=Math.round(e.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate){this._isRunning=!1,this.onSuccessObservable.notifyObservers(this);return}for(var r=!0,o=!0,a=0;a<i.optimizations.length;a++){var s=i.optimizations[a];s.priority===this._currentPriorityLevel&&(o=!1,r=r&&s.apply(e,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(o){this._isRunning=!1,this.onFailureObservable.notifyObservers(this);return}r&&this._currentPriorityLevel++,e.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)})}},n.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},n.OptimizeAsync=function(t,e,i,r){var o=new n(t,e||BO.ModerateDegradationAllowed(),!1);return i&&o.onSuccessObservable.add(function(){i()}),r&&o.onFailureObservable.add(function(){r()}),o.start(),o},n}(),$d=[],Yb=function(n,t){$d[n.id]||n.doNotSerialize||(t.vertexData.push(n.serializeVerticeData()),$d[n.id]=!0)},FI=function(n,t){var e={},i=n._geometry;return i&&(n.getScene().getGeometryByID(i.id)||Yb(i,t.geometries)),n.serialize&&n.serialize(e),e},b5=function(n,t){if(n.delayLoadState===1||n.delayLoadState===0){if(n.material&&!n.material.doNotSerialize)if(n.material instanceof Go){if(t.multiMaterials=t.multiMaterials||[],t.materials=t.materials||[],!t.multiMaterials.some(function(s){return s.id===n.material.id})){t.multiMaterials.push(n.material.serialize());for(var e=function(s){s&&(t.materials.some(function(l){return l.id===s.id})||t.materials.push(s.serialize()))},i=0,r=n.material.subMaterials;i<r.length;i++){var o=r[i];e(o)}}}else t.materials=t.materials||[],t.materials.some(function(s){return s.id===n.material.id})||t.materials.push(n.material.serialize());var a=n._geometry;a&&(t.geometries||(t.geometries={},t.geometries.boxes=[],t.geometries.spheres=[],t.geometries.cylinders=[],t.geometries.toruses=[],t.geometries.grounds=[],t.geometries.planes=[],t.geometries.torusKnots=[],t.geometries.vertexData=[]),Yb(a,t.geometries)),n.skeleton&&!n.skeleton.doNotSerialize&&(t.skeletons=t.skeletons||[],t.skeletons.push(n.skeleton.serialize())),t.meshes=t.meshes||[],t.meshes.push(FI(n,t))}},VO=function(){function n(){}return n.ClearCache=function(){$d=[]},n.Serialize=function(t){var e={};if(n.ClearCache(),e.useDelayedTextureLoading=t.useDelayedTextureLoading,e.autoClear=t.autoClear,e.clearColor=t.clearColor.asArray(),e.ambientColor=t.ambientColor.asArray(),e.gravity=t.gravity.asArray(),e.collisionsEnabled=t.collisionsEnabled,t.fogMode&&t.fogMode!==0&&(e.fogMode=t.fogMode,e.fogColor=t.fogColor.asArray(),e.fogStart=t.fogStart,e.fogEnd=t.fogEnd,e.fogDensity=t.fogDensity),t.isPhysicsEnabled()){var i=t.getPhysicsEngine();i&&(e.physicsEnabled=!0,e.physicsGravity=i.gravity.asArray(),e.physicsEngine=i.getPhysicsPluginName())}t.metadata&&(e.metadata=t.metadata),e.morphTargetManagers=[];for(var r=0,o=t.meshes;r<o.length;r++){var a=o[r],s=a.morphTargetManager;s&&e.morphTargetManagers.push(s.serialize())}e.lights=[];var l,u;for(l=0;l<t.lights.length;l++)u=t.lights[l],u.doNotSerialize||e.lights.push(u.serialize());for(e.cameras=[],l=0;l<t.cameras.length;l++){var f=t.cameras[l];f.doNotSerialize||e.cameras.push(f.serialize())}if(t.activeCamera&&(e.activeCameraID=t.activeCamera.id),Be.AppendSerializedAnimations(t,e),t.animationGroups&&t.animationGroups.length>0){e.animationGroups=[];for(var c=0;c<t.animationGroups.length;c++){var h=t.animationGroups[c];e.animationGroups.push(h.serialize())}}if(t.reflectionProbes&&t.reflectionProbes.length>0)for(e.reflectionProbes=[],l=0;l<t.reflectionProbes.length;l++){var p=t.reflectionProbes[l];e.reflectionProbes.push(p.serialize())}e.materials=[],e.multiMaterials=[];var _;for(l=0;l<t.materials.length;l++)_=t.materials[l],_.doNotSerialize||e.materials.push(_.serialize());for(e.multiMaterials=[],l=0;l<t.multiMaterials.length;l++){var g=t.multiMaterials[l];e.multiMaterials.push(g.serialize())}for(t.environmentTexture&&(e.environmentTexture=t.environmentTexture.name),e.environmentIntensity=t.environmentIntensity,e.skeletons=[],l=0;l<t.skeletons.length;l++){var v=t.skeletons[l];v.doNotSerialize||e.skeletons.push(v.serialize())}for(e.transformNodes=[],l=0;l<t.transformNodes.length;l++)t.transformNodes[l].doNotSerialize||e.transformNodes.push(t.transformNodes[l].serialize());e.geometries={},e.geometries.boxes=[],e.geometries.spheres=[],e.geometries.cylinders=[],e.geometries.toruses=[],e.geometries.grounds=[],e.geometries.planes=[],e.geometries.torusKnots=[],e.geometries.vertexData=[],$d=[];var E=t.getGeometries();for(l=0;l<E.length;l++){var T=E[l];T.isReady()&&Yb(T,e.geometries)}for(e.meshes=[],l=0;l<t.meshes.length;l++){var a=t.meshes[l];if(a instanceof ne){var S=a;S.doNotSerialize||(S.delayLoadState===1||S.delayLoadState===0)&&e.meshes.push(FI(S,e))}}for(e.particleSystems=[],l=0;l<t.particleSystems.length;l++)e.particleSystems.push(t.particleSystems[l].serialize(!1));for(e.postProcesses=[],l=0;l<t.postProcesses.length;l++)e.postProcesses.push(t.postProcesses[l].serialize());t.actionManager&&(e.actions=t.actionManager.serialize("scene"));for(var C=0,O=t._serializableComponents;C<O.length;C++){var A=O[C];A.serialize(e)}return e},n.SerializeMesh=function(t,e,i){e===void 0&&(e=!1),i===void 0&&(i=!1);var r={};if(n.ClearCache(),t=t instanceof Array?t:[t],e||i)for(var o=0;o<t.length;++o)i&&t[o].getDescendants().forEach(function(a){a instanceof ne&&t.indexOf(a)<0&&!a.doNotSerialize&&t.push(a)}),e&&t[o].parent&&t.indexOf(t[o].parent)<0&&!t[o].parent.doNotSerialize&&t.push(t[o].parent);return t.forEach(function(a){b5(a,r)}),r},n}(),N8=function(){function n(){}return n.CreateResizedCopy=function(t,e,i,r){r===void 0&&(r=!0);var o=t.getScene(),a=o.getEngine(),s=new ji("resized"+t.name,{width:e,height:i},o,!t.noMipmap,!0,t._texture.type,!1,t.samplingMode,!1);s.wrapU=t.wrapU,s.wrapV=t.wrapV,s.uOffset=t.uOffset,s.vOffset=t.vOffset,s.uScale=t.uScale,s.vScale=t.vScale,s.uAng=t.uAng,s.vAng=t.vAng,s.wAng=t.wAng,s.coordinatesIndex=t.coordinatesIndex,s.level=t.level,s.anisotropicFilteringLevel=t.anisotropicFilteringLevel,s._texture.isReady=!1,t.wrapU=he.CLAMP_ADDRESSMODE,t.wrapV=he.CLAMP_ADDRESSMODE;var l=new rl("pass",1,null,r?he.BILINEAR_SAMPLINGMODE:he.NEAREST_SAMPLINGMODE,a,!1,0);return l.getEffect().executeWhenCompiled(function(){l.onApply=function(f){f.setTexture("textureSampler",t)};var u=s.getInternalTexture();u&&(o.postProcessManager.directRender([l],u),a.unBindFramebuffer(u),s.disposeFramebufferObjects(),l.dispose(),u.isReady=!0)}),s},n}(),F8=function(){function n(t,e){if(e===void 0&&(e=null),!n.IsSupported(t))throw"Your browser does not support recording so far.";var i=t.getRenderingCanvas();if(!i)throw"The babylon engine must have a canvas to be recorded";this._canvas=i,this._canvas.isRecording=!1,this._options=Ot(Ot({},n._defaultOptions),e);var r=this._canvas.captureStream(this._options.fps);if(this._options.audioTracks)for(var o=0,a=this._options.audioTracks;o<a.length;o++){var s=a[o];r.addTrack(s)}this._mediaRecorder=new MediaRecorder(r,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return n.IsSupported=function(t){var e=t.getRenderingCanvas();return!!e&&typeof e.captureStream=="function"},Object.defineProperty(n.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!1,configurable:!0}),n.prototype.stopRecording=function(){!this._canvas||!this._mediaRecorder||this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},n.prototype.startRecording=function(t,e){var i=this;if(t===void 0&&(t="babylonjs.webm"),e===void 0&&(e=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return e>0&&setTimeout(function(){i.stopRecording()},e*1e3),this._fileName=t,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(r,o){i._resolve=r,i._reject=o})},n.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},n.prototype._handleDataAvailable=function(t){t.data.size>0&&this._recordedChunks.push(t.data)},n.prototype._handleError=function(t){if(this.stopRecording(),this._reject)this._reject(t.error);else throw new t.error},n.prototype._handleStop=function(){this.stopRecording();var t=new Blob(this._recordedChunks);this._resolve&&this._resolve(t),window.URL.createObjectURL(t),this._fileName&&Ee.Download(t,this._fileName)},n._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},n}(),vp=function(){function n(){}return n.CreateScreenshot=function(t,e,i,r,o){o===void 0&&(o="image/png");var a=n._getScreenshotSize(t,e,i),s=a.height,l=a.width;if(!(s&&l)){de.Error("Invalid 'size' parameter !");return}Ee._ScreenshotCanvas||(Ee._ScreenshotCanvas=document.createElement("canvas")),Ee._ScreenshotCanvas.width=l,Ee._ScreenshotCanvas.height=s;var u=Ee._ScreenshotCanvas.getContext("2d"),f=t.getRenderWidth()/t.getRenderHeight(),c=l,h=c/f;h>s&&(h=s,c=h*f);var p=Math.max(0,l-c)/2,_=Math.max(0,s-h)/2,g=t.getRenderingCanvas();u&&g&&u.drawImage(g,p,_,c,h),Ee.EncodeScreenshotCanvasData(r,o)},n.CreateScreenshotAsync=function(t,e,i,r){return r===void 0&&(r="image/png"),new Promise(function(o,a){n.CreateScreenshot(t,e,i,function(s){typeof s<"u"?o(s):a(new Error("Data is undefined"))},r)})},n.CreateScreenshotUsingRenderTarget=function(t,e,i,r,o,a,s,l,u,f){o===void 0&&(o="image/png"),a===void 0&&(a=1),s===void 0&&(s=!1),u===void 0&&(u=!1),f===void 0&&(f=!1);var c=n._getScreenshotSize(t,e,i),h=c.height,p=c.width,_={width:p,height:h};if(!(h&&p)){de.Error("Invalid 'size' parameter !");return}var g=t.getRenderingCanvas();if(!g){de.Error("No rendering canvas found !");return}var v={width:g.width,height:g.height};t.setSize(p,h);var E=e.getScene(),T=null,S=E.activeCameras;(E.activeCamera!==e||E.activeCameras&&E.activeCameras.length)&&(T=E.activeCamera,E.activeCamera=e),E.render();var C=new ji("screenShot",_,E,!1,!1,0,!1,he.NEAREST_SAMPLINGMODE,void 0,f);C.renderList=null,C.samples=a,C.renderSprites=u,C.onAfterRenderObservable.add(function(){Ee.DumpFramebuffer(p,h,t,r,o,l)});var O=function(){E.incrementRenderId(),E.resetCachedMaterial(),C.render(!0),C.dispose(),T&&(E.activeCamera=T),E.activeCameras=S,t.setSize(v.width,v.height),e.getProjectionMatrix(!0)};if(s){var A=new gp("antialiasing",1,E.activeCamera);C.addPostProcess(A),A.getEffect().isReady()?O():A.getEffect().onCompiled=function(){O()}}else O()},n.CreateScreenshotUsingRenderTargetAsync=function(t,e,i,r,o,a,s,l){return r===void 0&&(r="image/png"),o===void 0&&(o=1),a===void 0&&(a=!1),l===void 0&&(l=!1),new Promise(function(u,f){n.CreateScreenshotUsingRenderTarget(t,e,i,function(c){typeof c<"u"?u(c):f(new Error("Data is undefined"))},r,o,a,s,l)})},n._getScreenshotSize=function(t,e,i){var r=0,o=0;if(typeof i=="object"){var a=i.precision?Math.abs(i.precision):1;i.width&&i.height?(r=i.height*a,o=i.width*a):i.width&&!i.height?(o=i.width*a,r=Math.round(o/t.getAspectRatio(e))):i.height&&!i.width?(r=i.height*a,o=Math.round(r*t.getAspectRatio(e))):(o=Math.round(t.getRenderWidth()*a),r=Math.round(o/t.getAspectRatio(e)))}else isNaN(i)||(r=i,o=i);return o&&(o=Math.floor(o)),r&&(r=Math.floor(r)),{height:r|0,width:o|0}},n}();Ee.CreateScreenshot=vp.CreateScreenshot;Ee.CreateScreenshotAsync=vp.CreateScreenshotAsync;Ee.CreateScreenshotUsingRenderTarget=vp.CreateScreenshotUsingRenderTarget;Ee.CreateScreenshotUsingRenderTargetAsync=vp.CreateScreenshotUsingRenderTargetAsync;var UO;(function(n){n[n.Checkbox=0]="Checkbox",n[n.Slider=1]="Slider",n[n.Vector3=2]="Vector3",n[n.Quaternion=3]="Quaternion",n[n.Color3=4]="Color3",n[n.String=5]="String"})(UO||(UO={}));var Td=function(){function n(t){this.byteOffset=0,this.buffer=t}return n.prototype.loadAsync=function(t){var e=this;return this.buffer.readAsync(this.byteOffset,t).then(function(i){e._dataView=new DataView(i.buffer,i.byteOffset,i.byteLength),e._dataByteOffset=0})},n.prototype.readUint32=function(){var t=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,t},n.prototype.readUint8Array=function(t){var e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,t);return this._dataByteOffset+=t,this.byteOffset+=t,e},n.prototype.readString=function(t){return Oi.Decode(this.readUint8Array(t))},n.prototype.skipBytes=function(t){this._dataByteOffset+=t,this.byteOffset+=t},n}(),B8=function(){function n(){}return n._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch{var t={};return{getItem:function(i){var r=t[i];return r===void 0?null:r},setItem:function(i,r){t[i]=r}}}},n.ReadString=function(t,e){var i=this._Storage.getItem(t);return i!==null?i:e},n.WriteString=function(t,e){this._Storage.setItem(t,e)},n.ReadBoolean=function(t,e){var i=this._Storage.getItem(t);return i!==null?i==="true":e},n.WriteBoolean=function(t,e){this._Storage.setItem(t,e?"true":"false")},n.ReadNumber=function(t,e){var i=this._Storage.getItem(t);return i!==null?parseFloat(i):e},n.WriteNumber=function(t,e){this._Storage.setItem(t,e.toString())},n._Storage=n._GetStorage(),n}(),V8=function(){function n(){this._trackedScene=null}return n.prototype.track=function(t){this._trackedScene=t,this._savedJSON=VO.Serialize(t)},n.prototype.getDelta=function(){if(!this._trackedScene)return null;var t=VO.Serialize(this._trackedScene),e={};for(var i in t)this._compareCollections(i,this._savedJSON[i],t[i],e);return e},n.prototype._compareArray=function(t,e,i,r){if(e.length===0&&i.length===0)return!0;if(e.length&&!isNaN(e[0])||i.length&&!isNaN(i[0])){if(e.length!==i.length)return!1;if(e.length===0)return!0;for(var o=0;o<e.length;o++)if(e[o]!==i[o])return r[t]=i,!1;return!0}for(var a=[],s=function(){var c=e[o],h=c.uniqueId;a.push(h);var p=i.filter(function(v){return v.uniqueId===h});if(p.length){var _=p[0],g={};l._compareObjects(c,_,g)||(r[t]||(r[t]=[]),g.__state={id:_.id||_.name},r[t].push(g))}else{var g={__state:{deleteId:c.id||c.name}};r[t].push(g)}},l=this,o=0;o<e.length;o++)s();for(var o=0;o<i.length;o++){var u=i[o],f=u.uniqueId;a.indexOf(f)===-1&&(r[t]||(r[t]=[]),r[t].push(u))}return!0},n.prototype._compareObjects=function(t,e,i){var r=!1;for(var o in t)if(t.hasOwnProperty(o)){var a=t[o],s=e[o],l=!1;Array.isArray(a)?l=JSON.stringify(a)!==JSON.stringify(s):(!isNaN(a)||Object.prototype.toString.call(a)=="[object String]")&&(l=a!==s),l&&(r=!0,i[o]=s)}return!r},n.prototype._compareCollections=function(t,e,i,r){if(e!==i&&e&&i){if(Array.isArray(e)&&Array.isArray(i)){if(this._compareArray(t,e,i,r))return}else if(typeof e=="object"&&typeof i=="object"){var o={};this._compareObjects(e,i,o)||(r[t]=o);return}}},n.GetShadowGeneratorById=function(t,e){for(var i=t.lights.map(function(s){return s.getShadowGenerator()}),r=0,o=i;r<o.length;r++){var a=o[r];if(a&&a.id===e)return a}return null},n.ApplyDelta=function(t,e){var i=this;typeof t=="string"&&(t=JSON.parse(t));var r=e;for(var o in t){var a=t[o],s=r[o];if(Array.isArray(s)||o==="shadowGenerators")switch(o){case"cameras":this._ApplyDeltaForEntity(a,e,e.getCameraByID.bind(e),function(l){return dt.Parse(l,e)});break;case"lights":this._ApplyDeltaForEntity(a,e,e.getLightByID.bind(e),function(l){return Wr.Parse(l,e)});break;case"shadowGenerators":this._ApplyDeltaForEntity(a,e,function(l){return i.GetShadowGeneratorById(e,l)},function(l){return zn.Parse(l,e)});break;case"meshes":this._ApplyDeltaForEntity(a,e,e.getMeshByID.bind(e),function(l){return ne.Parse(l,e,"")});break;case"skeletons":this._ApplyDeltaForEntity(a,e,e.getSkeletonById.bind(e),function(l){return du.Parse(l,e)});break;case"materials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(l){return gt.Parse(l,e,"")});break;case"multiMaterials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(l){return Go.Parse(l,e,"")});break;case"transformNodes":this._ApplyDeltaForEntity(a,e,e.getTransformNodeByID.bind(e),function(l){return nr.Parse(l,e,"")});break;case"particleSystems":this._ApplyDeltaForEntity(a,e,e.getParticleSystemByID.bind(e),function(l){return vr.Parse(l,e,"")});break;case"morphTargetManagers":this._ApplyDeltaForEntity(a,e,e.getMorphTargetById.bind(e),function(l){return _p.Parse(l,e)});break;case"postProcesses":this._ApplyDeltaForEntity(a,e,e.getPostProcessByName.bind(e),function(l){return _t.Parse(l,e,"")});break}else isNaN(s)?s.fromArray&&s.fromArray(a):r[o]=a}},n._ApplyPropertiesToEntity=function(t,e){for(var i in t){var r=t[i],o=e[i];o!==void 0&&(!isNaN(o)||Array.isArray(o)?e[i]=r:o.fromArray&&o.fromArray(r))}},n._ApplyDeltaForEntity=function(t,e,i,r){for(var o=0,a=t;o<a.length;o++){var s=a[o];if(s.__state&&s.__state.id!==void 0){var l=i(s.__state.id);l&&this._ApplyPropertiesToEntity(s,l)}else if(s.__state&&s.__state.deleteId!==void 0){var u=i(s.__state.deleteId);u==null||u.dispose()}else r(s)}},n}(),hu;(function(n){var t=function(){function i(r,o,a,s){o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),o=o??function(){return 1},a=a??function(){return 1},s=s??function(c,h){return c===h?0:1},this._characterToIdx=new Map,this._insertionCosts=new Array(r.length),this._deletionCosts=new Array(r.length),this._substitutionCosts=new Array(r.length);for(var l,u=0;u<r.length;++u){l=r[u],this._characterToIdx.set(l,u),this._insertionCosts[u]=o(l),this._deletionCosts[u]=a(l),this._substitutionCosts[u]=new Array(r.length);for(var f=u;f<r.length;++f)this._substitutionCosts[u][f]=s(l,r[f])}}return i.prototype.serialize=function(){var r={},o=new Array(this._characterToIdx.size);return this._characterToIdx.forEach(function(a,s){o[a]=s}),r.characters=o,r.insertionCosts=this._insertionCosts,r.deletionCosts=this._deletionCosts,r.substitutionCosts=this._substitutionCosts,JSON.stringify(r)},i.Deserialize=function(r){var o=JSON.parse(r),a=new i(o.characters);return a._insertionCosts=o.insertionCosts,a._deletionCosts=o.deletionCosts,a._substitutionCosts=o.substitutionCosts,a},i.prototype.getCharacterIdx=function(r){return this._characterToIdx.get(r)},i.prototype.getInsertionCost=function(r){return this._insertionCosts[r]},i.prototype.getDeletionCost=function(r){return this._deletionCosts[r]},i.prototype.getSubstitutionCost=function(r,o){var a=Math.min(r,o),s=Math.max(r,o);return this._substitutionCosts[a][s]},i}();n.Alphabet=t;var e=function(){function i(r,o){var a=this;if(r.length>i.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+i.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=o,this._characters=r.map(function(s){return a._alphabet.getCharacterIdx(s)})}return i.prototype.serialize=function(){return JSON.stringify(this._characters)},i.Deserialize=function(r,o){var a=new i([],o);return a._characters=JSON.parse(r),a},i.prototype.distance=function(r){return i._distance(this,r)},i._distance=function(r,o){var a=r._alphabet;if(a!==o._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var s=r._characters,l=o._characters,u=s.length,f=l.length,c=i._costMatrix;c[0][0]=0;for(var h=0;h<u;++h)c[h+1][0]=c[h][0]+a.getInsertionCost(s[h]);for(var h=0;h<f;++h)c[0][h+1]=c[0][h]+a.getInsertionCost(l[h]);for(var p=0;p<u;++p)for(var _=0;_<f;++_)i._insertionCost=c[p+1][_]+a.getInsertionCost(l[_]),i._deletionCost=c[p][_+1]+a.getDeletionCost(s[p]),i._substitutionCost=c[p][_]+a.getSubstitutionCost(s[p],l[_]),c[p+1][_+1]=Math.min(i._insertionCost,i._deletionCost,i._substitutionCost);return c[u][f]},i.MAX_SEQUENCE_LENGTH=256,i._costMatrix=jM(Array(i.MAX_SEQUENCE_LENGTH+1)).map(function(r){return new Array(i.MAX_SEQUENCE_LENGTH+1)}),i}();n.Sequence=e})(hu||(hu={}));var U8=function(){function n(t){t===void 0&&(t=.01),this._points=[],this._segmentLength=t}return n.prototype.serialize=function(){return JSON.stringify(this)},n.Deserialize=function(t){var e=JSON.parse(t),i=new n(e._segmentLength);return i._points=e._points.map(function(r){return new y(r._x,r._y,r._z)}),i},n.prototype.getLength=function(){return this._points.length*this._segmentLength},n.prototype.add=function(t){var e=this,i=this._points.length;if(i===0)this._points.push(t.clone());else for(var r=function(){return e._segmentLength/y.Distance(e._points[i-1],t)},o=r();o<=1;o=r()){var a=this._points[i-1].scale(1-o);t.scaleAndAddToRef(o,a),this._points.push(a),++i}},n.prototype.resampleAtTargetResolution=function(t){var e=new n(this.getLength()/t);return this._points.forEach(function(i){e.add(i)}),e},n.prototype.tokenize=function(t){for(var e=[],i=new y,r=2;r<this._points.length;++r)n._transformSegmentDirToRef(this._points[r-2],this._points[r-1],this._points[r],i)&&e.push(n._tokenizeSegment(i,t));return e},n._transformSegmentDirToRef=function(t,e,i,r){var o=.98;return e.subtractToRef(t,n._forwardDir),n._forwardDir.normalize(),e.scaleToRef(-1,n._inverseFromVec),n._inverseFromVec.normalize(),Math.abs(y.Dot(n._forwardDir,n._inverseFromVec))>o?!1:(y.CrossToRef(n._forwardDir,n._inverseFromVec,n._upDir),n._upDir.normalize(),te.LookAtLHToRef(t,e,n._upDir,n._lookMatrix),i.subtractToRef(e,n._fromToVec),n._fromToVec.normalize(),y.TransformNormalToRef(n._fromToVec,n._lookMatrix,r),!0)},n._tokenizeSegment=function(t,e){n._bestMatch=0,n._score=y.Dot(t,e[0]),n._bestScore=n._score;for(var i=1;i<e.length;++i)n._score=y.Dot(t,e[i]),n._score>n._bestScore&&(n._bestMatch=i,n._bestScore=n._score);return n._bestMatch},n._forwardDir=new y,n._inverseFromVec=new y,n._upDir=new y,n._fromToVec=new y,n._lookMatrix=new te,n}(),kO=function(){function n(t){this.chars=new Array(t)}return n.Generate=function(t,e,i,r,o){t===void 0&&(t=64),e===void 0&&(e=256),i===void 0&&(i=.1),r===void 0&&(r=.001),o===void 0&&(o=[]);for(var a=.001,s=a*a,l=new n(t),u=0;u<t;++u)l.chars[u]=new y(Math.random()-.5,Math.random()-.5,Math.random()-.5),l.chars[u].normalize();for(var u=0;u<o.length;++u)l.chars[u].copyFrom(o[u]);for(var f,c,h=new y,p=new y,_=function(E,T,S){return(1-S)*E+S*T},g=0;g<e;++g){f=_(i,r,g/(e-1));for(var v=function(E){h.copyFromFloats(0,0,0),l.chars.forEach(function(T){l.chars[E].subtractToRef(T,p),c=p.lengthSquared(),c>s&&p.scaleAndAddToRef(1/(p.lengthSquared()*c),h)}),h.scaleInPlace(f),l.chars[E].addInPlace(h),l.chars[E].normalize()},u=o.length;u<l.chars.length;++u)v(u)}return l},n.prototype.serialize=function(){return JSON.stringify(this.chars)},n.Deserialize=function(t){for(var e=JSON.parse(t),i=new n(e.length),r=0;r<e.length;++r)i.chars[r]=new y(e[r]._x,e[r]._y,e[r]._z);return i},n}(),Ny=function(){function n(){this._sequences=[]}return n.prototype.serialize=function(){return JSON.stringify(this._sequences.map(function(t){return t.serialize()}))},n.Deserialize=function(t,e){var i=new n;return i._sequences=JSON.parse(t).map(function(r){return hu.Sequence.Deserialize(r,e)}),i},n.CreateFromTrajectory=function(t,e,i){return n.CreateFromTokenizationPyramid(n._getTokenizationPyramid(t,e),i)},n.CreateFromTokenizationPyramid=function(t,e){var i=new n;return i._sequences=t.map(function(r){return new hu.Sequence(r,e)}),i},n._getTokenizationPyramid=function(t,e,i){i===void 0&&(i=n.FINEST_DESCRIPTOR_RESOLUTION);for(var r=[],o=i;o>4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(e.chars));return r},n.prototype.distance=function(t){for(var e=0,i,r=0;r<this._sequences.length;++r)i=Math.pow(2,r),e+=i*this._sequences[r].distance(t._sequences[r]);return e},n.FINEST_DESCRIPTOR_RESOLUTION=32,n}(),zO=function(){function n(t){t===void 0&&(t=[]),this._descriptors=t,this._centroidIdx=-1,this._averageDistance=0,this._refreshDescription()}return n.prototype.serialize=function(){var t={};return t.descriptors=this._descriptors.map(function(e){return e.serialize()}),t.centroidIdx=this._centroidIdx,t.averageDistance=this._averageDistance,JSON.stringify(t)},n.Deserialize=function(t,e){var i=JSON.parse(t),r=new n;return r._descriptors=i.descriptors.map(function(o){return Ny.Deserialize(o,e)}),r._centroidIdx=i.centroidIdx,r._averageDistance=i.averageDistance,r},n.prototype.add=function(t){this._descriptors.push(t),this._refreshDescription()},n.prototype.getMatchCost=function(t){return t.distance(this._descriptors[this._centroidIdx])/this._averageDistance},n.prototype.getMatchMinimumDistance=function(t){return Math.min.apply(Math,this._descriptors.map(function(e){return e.distance(t)}))},n.prototype._refreshDescription=function(){var t=this;this._centroidIdx=-1;for(var e,i=this._descriptors.map(function(o){return e=0,t._descriptors.forEach(function(a){e+=o.distance(a)}),e}),r=0;r<i.length;++r)(this._centroidIdx<0||i[r]<i[this._centroidIdx])&&(this._centroidIdx=r);this._averageDistance=0,this._descriptors.forEach(function(o){t._averageDistance+=o.distance(t._descriptors[t._centroidIdx])}),this._descriptors.length>0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,n.MIN_AVERAGE_DISTANCE))},n.MIN_AVERAGE_DISTANCE=1,n}(),k8=function(){function n(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return n.prototype.serialize=function(){var t={};return t.maximumAllowableMatchCost=this._maximumAllowableMatchCost,t.vector3Alphabet=this._vector3Alphabet.serialize(),t.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),t.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach(function(e,i){t.nameToDescribedTrajectory.push(i),t.nameToDescribedTrajectory.push(e.serialize())}),JSON.stringify(t)},n.Deserialize=function(t){var e=JSON.parse(t),i=new n;i._maximumAllowableMatchCost=e.maximumAllowableMatchCost,i._vector3Alphabet=kO.Deserialize(e.vector3Alphabet),i._levenshteinAlphabet=hu.Alphabet.Deserialize(e.levenshteinAlphabet);for(var r=0;r<e.nameToDescribedTrajectory.length;r+=2)i._nameToDescribedTrajectory.set(e.nameToDescribedTrajectory[r],zO.Deserialize(e.nameToDescribedTrajectory[r+1],i._levenshteinAlphabet));return i},n.Generate=function(){for(var t=kO.Generate(64,256,.1,.001,[y.Forward()]),e=new Array(t.chars.length),i=0;i<e.length;++i)e[i]=i;var r=new hu.Alphabet(e,function(a){return a===0?0:1},function(a){return a===0?0:1},function(a,s){return Math.min(1-y.Dot(t.chars[a],t.chars[s]),1)}),o=new n;return o._vector3Alphabet=t,o._levenshteinAlphabet=r,o},n.prototype.addTrajectoryToClassification=function(t,e){this._nameToDescribedTrajectory.has(e)||this._nameToDescribedTrajectory.set(e,new zO),this._nameToDescribedTrajectory.get(e).add(Ny.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet))},n.prototype.deleteClassification=function(t){return this._nameToDescribedTrajectory.delete(t)},n.prototype.classifyTrajectory=function(t){var e=this,i=Ny.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet),r=[];if(this._nameToDescribedTrajectory.forEach(function(u,f){u.getMatchCost(i)<e._maximumAllowableMatchCost&&r.push(f)}),r.length===0)return null;for(var o=0,a=this._nameToDescribedTrajectory.get(r[o]).getMatchMinimumDistance(i),s,l=0;l<r.length;++l)s=this._nameToDescribedTrajectory.get(r[l]).getMatchMinimumDistance(i),s<a&&(a=s,o=l);return r[o]},n}(),Yv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r._direction=new y(0,0,-1),r._mat=new te,r._onSelectEnabled=!1,r._origin=new y(0,0,0),r.lastNativeXRHitResults=[],r.onHitTestResultObservable=new ie,r._onHitTestResults=function(o){var a=o.map(function(s){var l=te.FromArray(s.hitMatrix);return r._xrSessionManager.scene.useRightHandedSystem||l.toggleModelMatrixHandInPlace(),r.options.worldParentNode&&l.multiplyToRef(r.options.worldParentNode.getWorldMatrix(),l),{xrHitResult:s,transformationMatrix:l}});r.lastNativeXRHitResults=o,r.onHitTestResultObservable.notifyObservers(a)},r._onSelect=function(o){r._onSelectEnabled&&t.XRHitTestWithSelectEvent(o,r._xrSessionManager.referenceSpace)},r.xrNativeFeatureName="hit-test",Ee.Warn("A newer version of this plugin is available"),r}return t.XRHitTestWithRay=function(e,i,r,o){return e.requestHitTest(i,r).then(function(a){var s=o||function(l){return!!l.hitMatrix};return a.filter(s)})},t.XRHitTestWithSelectEvent=function(e,i){var r=e.frame.getPose(e.inputSource.targetRaySpace,i);if(!r)return Promise.resolve([]);var o=new XRRay(r.transform);return this.XRHitTestWithRay(e.frame.session,o,i)},t.prototype.attach=function(){return n.prototype.attach.call(this)?(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0):!1},t.prototype.detach=function(){return n.prototype.detach.call(this)?(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(!(!this.attached||this.options.testOnPointerDownOnly)){var i=e.getViewerPose(this._xrSessionManager.referenceSpace);if(i){te.FromArrayToRef(i.transform.matrix,0,this._mat),y.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),y.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var r=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,r,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=Ko.HIT_TEST,t.Version=1,t}(qo);Mo.AddWebXRFeature(Yv.Name,function(n,t){return function(){return new Yv(n,t)}},Yv.Version,!1);var E5=0,Kv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r._options=i,r._lastFrameDetected=new Set,r._trackedAnchors=[],r._futureAnchors=[],r.onAnchorAddedObservable=new ie,r.onAnchorRemovedObservable=new ie,r.onAnchorUpdatedObservable=new ie,r._tmpVector=new y,r._tmpQuaternion=new Re,r.xrNativeFeatureName="anchors",r}return Object.defineProperty(t.prototype,"referenceSpaceForFrameAnchors",{set:function(e){this._referenceSpaceForFrameAnchors=e},enumerable:!1,configurable:!0}),t.prototype._populateTmpTransformation=function(e,i){return this._tmpVector.copyFrom(e),this._tmpQuaternion.copyFrom(i),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpVector.z*=-1,this._tmpQuaternion.z*=-1,this._tmpQuaternion.w*=-1),{position:this._tmpVector,rotationQuaternion:this._tmpQuaternion}},t.prototype.addAnchorPointUsingHitTestResultAsync=function(e,i,r){return i===void 0&&(i=new y),r===void 0&&(r=new Re),eu(this,void 0,void 0,function(){var o,a,s,l=this;return tu(this,function(u){switch(u.label){case 0:if(this._populateTmpTransformation(i,r),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),e.xrHitResult.createAnchor)return[3,1];throw this.detach(),new Error("Anchors not enabled in this environment/browser");case 1:return u.trys.push([1,3,,4]),[4,e.xrHitResult.createAnchor(o)];case 2:return a=u.sent(),[2,new Promise(function(f,c){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!0,xrTransformation:o,resolve:f,reject:c})})];case 3:throw s=u.sent(),new Error(s);case 4:return[2]}})})},t.prototype.addAnchorAtPositionAndRotationAsync=function(e,i,r){return i===void 0&&(i=new Re),r===void 0&&(r=!1),eu(this,void 0,void 0,function(){var o,a,s,l=this;return tu(this,function(u){switch(u.label){case 0:return this._populateTmpTransformation(e,i),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),r&&this.attached&&this._xrSessionManager.currentFrame?[4,this._createAnchorAtTransformation(o,this._xrSessionManager.currentFrame)]:[3,2];case 1:return s=u.sent(),[3,3];case 2:s=void 0,u.label=3;case 3:return a=s,[2,new Promise(function(f,c){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!1,xrTransformation:o,resolve:f,reject:c})})]}})})},Object.defineProperty(t.prototype,"anchors",{get:function(){return this._trackedAnchors},enumerable:!1,configurable:!0}),t.prototype.detach=function(){if(!n.prototype.detach.call(this))return!1;if(!this._options.doNotRemoveAnchorsOnSessionEnded)for(;this._trackedAnchors.length;){var e=this._trackedAnchors.pop();if(e){try{e.remove()}catch{}this.onAnchorRemovedObservable.notifyObservers(e)}}return!0},t.prototype.dispose=function(){this._futureAnchors.length=0,n.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||!e)){var r=e.trackedAnchors;if(r){var o=this._trackedAnchors.filter(function(s){return!r.has(s.xrAnchor)}).map(function(s){var l=i._trackedAnchors.indexOf(s);return l}),a=0;o.forEach(function(s){var l=i._trackedAnchors.splice(s-a,1)[0];i.onAnchorRemovedObservable.notifyObservers(l),a++}),r.forEach(function(s){if(i._lastFrameDetected.has(s)){var h=i._findIndexInAnchorArray(s),u=i._trackedAnchors[h];try{i._updateAnchorWithXRFrame(s,u,e),u.attachedNode&&(u.attachedNode.rotationQuaternion=u.attachedNode.rotationQuaternion||new Re,u.transformationMatrix.decompose(u.attachedNode.scaling,u.attachedNode.rotationQuaternion,u.attachedNode.position)),i.onAnchorUpdatedObservable.notifyObservers(u)}catch{Ee.Warn("Anchor could not be updated")}}else{var l={id:E5++,xrAnchor:s,remove:s.delete},u=i._updateAnchorWithXRFrame(s,l,e);i._trackedAnchors.push(u),i.onAnchorAddedObservable.notifyObservers(u);var f=i._futureAnchors.filter(function(p){return p.nativeAnchor===s}),c=f[0];c&&(c.resolve(u),c.resolved=!0)}}),this._lastFrameDetected=r}this._futureAnchors.forEach(function(s){!s.resolved&&!s.submitted&&(i._createAnchorAtTransformation(s.xrTransformation,e).then(function(l){s.nativeAnchor=l},function(l){s.resolved=!0,s.reject(l)}),s.submitted=!0)})}},t.prototype._findIndexInAnchorArray=function(e){for(var i=0;i<this._trackedAnchors.length;++i)if(this._trackedAnchors[i].xrAnchor===e)return i;return-1},t.prototype._updateAnchorWithXRFrame=function(e,i,r){var o=r.getPose(e.anchorSpace,this._xrSessionManager.referenceSpace);if(o){var a=i.transformationMatrix||new te;te.FromArrayToRef(o.transform.matrix,0,a),this._xrSessionManager.scene.useRightHandedSystem||a.toggleModelMatrixHandInPlace(),i.transformationMatrix=a,this._options.worldParentNode&&a.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),a)}return i},t.prototype._createAnchorAtTransformation=function(e,i){var r;return eu(this,void 0,void 0,function(){return tu(this,function(o){if(i.createAnchor)try{return[2,i.createAnchor(e,(r=this._referenceSpaceForFrameAnchors)!==null&&r!==void 0?r:this._xrSessionManager.referenceSpace)]}catch(a){throw new Error(a)}else throw this.detach(),new Error("Anchors are not enabled in your browser");return[2]})})},t.Name=Ko.ANCHOR_SYSTEM,t.Version=1,t}(qo);Mo.AddWebXRFeature(Kv.Name,function(n,t){return function(){return new Kv(n,t)}},Kv.Version);var T5=0,qv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r._options=i,r._detectedPlanes=[],r._enabled=!1,r._lastFrameDetected=new Set,r.onPlaneAddedObservable=new ie,r.onPlaneRemovedObservable=new ie,r.onPlaneUpdatedObservable=new ie,r.xrNativeFeatureName="plane-detection",r._xrSessionManager.session?r._init():r._xrSessionManager.onXRSessionInit.addOnce(function(){r._init()}),r}return t.prototype.detach=function(){if(!n.prototype.detach.call(this))return!1;if(!this._options.doNotRemovePlanesOnSessionEnded)for(;this._detectedPlanes.length;){var e=this._detectedPlanes.pop();e&&this.onPlaneRemovedObservable.notifyObservers(e)}return!0},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onPlaneAddedObservable.clear(),this.onPlaneRemovedObservable.clear(),this.onPlaneUpdatedObservable.clear()},t.prototype.isCompatible=function(){return typeof XRPlane<"u"},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||!this._enabled||!e)){var r=e.worldInformation.detectedPlanes;if(r){var o=this._detectedPlanes.filter(function(s){return!r.has(s.xrPlane)}).map(function(s){return i._detectedPlanes.indexOf(s)}),a=0;o.forEach(function(s){var l=i._detectedPlanes.splice(s-a,1)[0];i.onPlaneRemovedObservable.notifyObservers(l),a++}),r.forEach(function(s){if(i._lastFrameDetected.has(s)){if(s.lastChangedTime===i._xrSessionManager.currentTimestamp){var f=i.findIndexInPlaneArray(s),u=i._detectedPlanes[f];i._updatePlaneWithXRPlane(s,u,e),i.onPlaneUpdatedObservable.notifyObservers(u)}}else{var l={id:T5++,xrPlane:s,polygonDefinition:[]},u=i._updatePlaneWithXRPlane(s,l,e);i._detectedPlanes.push(u),i.onPlaneAddedObservable.notifyObservers(u)}}),this._lastFrameDetected=r}}},t.prototype._init=function(){var e=this,i,r,o=function(){e._enabled=!0,e._detectedPlanes.length&&(e._detectedPlanes.length=0)};if(!this._xrSessionManager.session.updateWorldTrackingState){var a=(r=(i=this._xrSessionManager.session.worldTrackingState)===null||i===void 0?void 0:i.planeDetectionState)===null||r===void 0?void 0:r.enabled;a&&o();return}this._xrSessionManager.session.updateWorldTrackingState({planeDetectionState:{enabled:!0}}),o()},t.prototype._updatePlaneWithXRPlane=function(e,i,r){var o=this;i.polygonDefinition=e.polygon.map(function(l){var u=o._xrSessionManager.scene.useRightHandedSystem?1:-1;return new y(l.x,l.y,l.z*u)});var a=r.getPose(e.planeSpace,this._xrSessionManager.referenceSpace);if(a){var s=i.transformationMatrix||new te;te.FromArrayToRef(a.transform.matrix,0,s),this._xrSessionManager.scene.useRightHandedSystem||s.toggleModelMatrixHandInPlace(),i.transformationMatrix=s,this._options.worldParentNode&&s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),s)}return i},t.prototype.findIndexInPlaneArray=function(e){for(var i=0;i<this._detectedPlanes.length;++i)if(this._detectedPlanes[i].xrPlane===e)return i;return-1},t.Name=Ko.PLANE_DETECTION,t.Version=1,t}(qo);Mo.AddWebXRFeature(qv.Name,function(n,t){return function(){return new qv(n,t)}},qv.Version);var Qv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r.onBackgroundStateChangedObservable=new ie,r}return t.prototype.attach=function(){return this._setBackgroundState(!1),n.prototype.attach.call(this)},t.prototype.detach=function(){return this._setBackgroundState(!0),n.prototype.detach.call(this)},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onBackgroundStateChangedObservable.clear()},t.prototype._onXRFrame=function(e){},t.prototype._setBackgroundState=function(e){var i=this._xrSessionManager.scene;if(!this.options.ignoreEnvironmentHelper)if(this.options.environmentHelperRemovalFlags){if(this.options.environmentHelperRemovalFlags.skyBox){var r=i.getMeshByName("BackgroundSkybox");r&&r.setEnabled(e)}if(this.options.environmentHelperRemovalFlags.ground){var o=i.getMeshByName("BackgroundPlane");o&&o.setEnabled(e)}}else{var a=i.getMeshByName("BackgroundHelper");a&&a.setEnabled(e)}this.options.backgroundMeshes&&this.options.backgroundMeshes.forEach(function(s){return s.setEnabled(e)}),this.onBackgroundStateChangedObservable.notifyObservers(e)},t.Name=Ko.BACKGROUND_REMOVER,t.Version=1,t}(qo);Mo.AddWebXRFeature(Qv.Name,function(n,t){return function(){return new Qv(n,t)}},Qv.Version,!0);var z8=function(){function n(){}return n}(),$v=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r._options=i,r._attachController=function(o){if(!r._controllers[o.uniqueId])if(r._xrSessionManager.scene.isPhysicsEnabled()||de.Warn("physics engine not enabled, skipped. Please add this controller manually."),r._options.physicsProperties.useControllerMesh&&o.inputSource.gamepad)o.onMotionControllerInitObservable.addOnce(function(c){c.onModelLoadedObservable.addOnce(function(){var h=new It(c.rootMesh,It.MeshImpostor,Ot({mass:0},r._options.physicsProperties)),p=o.grip||o.pointer;r._controllers[o.uniqueId]={xrController:o,impostor:h,oldPos:p.position.clone(),oldRotation:p.rotationQuaternion.clone()}})});else{var a=r._options.physicsProperties.impostorType||It.SphereImpostor,s=r._options.physicsProperties.impostorSize||.1,l=tn.CreateSphere("impostor-mesh-"+o.uniqueId,{diameterX:typeof s=="number"?s:s.width,diameterY:typeof s=="number"?s:s.height,diameterZ:typeof s=="number"?s:s.depth});l.isVisible=r._debugMode,l.isPickable=!1,l.rotationQuaternion=new Re;var u=o.grip||o.pointer;l.position.copyFrom(u.position),l.rotationQuaternion.copyFrom(u.rotationQuaternion);var f=new It(l,a,Ot({mass:0},r._options.physicsProperties));r._controllers[o.uniqueId]={xrController:o,impostor:f,impostorMesh:l}}},r._controllers={},r._debugMode=!1,r._delta=0,r._lastTimestamp=0,r._tmpQuaternion=new Re,r._tmpVector=new y,r._options.physicsProperties||(r._options.physicsProperties={}),r}return t.prototype._enablePhysicsDebug=function(){var e=this;this._debugMode=!0,Object.keys(this._controllers).forEach(function(i){var r=e._controllers[i];r.impostorMesh&&(r.impostorMesh.isVisible=!0)})},t.prototype.addController=function(e){this._attachController(e)},t.prototype.attach=function(){var e=this;if(!n.prototype.attach.call(this))return!1;if(!this._options.xrInput)return!0;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(o){e._detachController(o.uniqueId)}),this._options.enableHeadsetImpostor){var i=this._options.headsetImpostorParams||{impostorType:It.SphereImpostor,restitution:.8,impostorSize:.3},r=i.impostorSize||.3;this._headsetMesh=tn.CreateSphere("headset-mesh",{diameterX:typeof r=="number"?r:r.width,diameterY:typeof r=="number"?r:r.height,diameterZ:typeof r=="number"?r:r.depth}),this._headsetMesh.rotationQuaternion=new Re,this._headsetMesh.isVisible=!1,this._headsetImpostor=new It(this._headsetMesh,i.impostorType,Ot({mass:0},i))}return!0},t.prototype.detach=function(){var e=this;return n.prototype.detach.call(this)?(Object.keys(this._controllers).forEach(function(i){e._detachController(i)}),this._headsetMesh&&this._headsetMesh.dispose(),!0):!1},t.prototype.getHeadsetImpostor=function(){return this._headsetImpostor},t.prototype.getImpostorForController=function(e){var i=typeof e=="string"?e:e.uniqueId;return this._controllers[i]?this._controllers[i].impostor:null},t.prototype.setPhysicsProperties=function(e){this._options.physicsProperties=Ot(Ot({},this._options.physicsProperties),e)},t.prototype._onXRFrame=function(e){var i=this;this._delta=this._xrSessionManager.currentTimestamp-this._lastTimestamp,this._lastTimestamp=this._xrSessionManager.currentTimestamp,this._headsetMesh&&(this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.position),this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.rotationQuaternion)),Object.keys(this._controllers).forEach(function(r){var o=i._controllers[r],a=o.xrController.grip||o.xrController.pointer,s=o.oldPos||o.impostorMesh.position,l=o.oldRotation||o.impostorMesh.rotationQuaternion;if(a.position.subtractToRef(s,i._tmpVector),i._tmpVector.scaleInPlace(1e3/i._delta),o.impostor.setLinearVelocity(i._tmpVector),i._debugMode&&console.log(i._tmpVector,"linear"),!l.equalsWithEpsilon(a.rotationQuaternion)){l.conjugateInPlace().multiplyToRef(a.rotationQuaternion,i._tmpQuaternion);var u=Math.sqrt(i._tmpQuaternion.x*i._tmpQuaternion.x+i._tmpQuaternion.y*i._tmpQuaternion.y+i._tmpQuaternion.z*i._tmpQuaternion.z);if(i._tmpVector.set(i._tmpQuaternion.x,i._tmpQuaternion.y,i._tmpQuaternion.z),u<.001)i._tmpVector.scaleInPlace(2);else{var f=2*Math.atan2(u,i._tmpQuaternion.w);i._tmpVector.scaleInPlace(f/(u*(i._delta/1e3)))}o.impostor.setAngularVelocity(i._tmpVector),i._debugMode&&console.log(i._tmpVector,i._tmpQuaternion,"angular")}s.copyFrom(a.position),l.copyFrom(a.rotationQuaternion)})},t.prototype._detachController=function(e){var i=this._controllers[e];i&&(i.impostorMesh&&i.impostorMesh.dispose(),delete this._controllers[e])},t.Name=Ko.PHYSICS_CONTROLLERS,t.Version=1,t}(qo);Mo.AddWebXRFeature($v.Name,function(n,t){return function(){return new $v(n,t)}},$v.Version,!0);var Zv=function(n){j(t,n);function t(e,i){i===void 0&&(i={});var r=n.call(this,e)||this;return r.options=i,r._tmpMat=new te,r._tmpPos=new y,r._tmpQuat=new Re,r.initHitTestSource=function(o){if(o){var a=new XRRay(r.options.offsetRay||{}),s={space:r.options.useReferenceSpace?o:r._xrSessionManager.viewerReferenceSpace,offsetRay:a};if(r.options.entityTypes&&(s.entityTypes=r.options.entityTypes),!s.space){Ee.Warn("waiting for viewer reference space to initialize");return}r._xrSessionManager.session.requestHitTestSource(s).then(function(l){r._xrHitTestSource&&r._xrHitTestSource.cancel(),r._xrHitTestSource=l})}},r.autoCloneTransformation=!1,r.onHitTestResultObservable=new ie,r.paused=!1,r.xrNativeFeatureName="hit-test",Ee.Warn("Hit test is an experimental and unstable feature."),r}return t.prototype.attach=function(){var e=this;if(!n.prototype.attach.call(this)||!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this.initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this.initHitTestSource)),this.options.enableTransientHitTest){var i=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:"generic-touchscreen",offsetRay:i,entityTypes:this.options.entityTypes}).then(function(r){e._transientXrHitTestSource=r})}return!0},t.prototype.detach=function(){return n.prototype.detach.call(this)?(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this.initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){var i=this;if(!(!this.attached||this.paused)){if(this._xrHitTestSource){var r=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(r)}if(this._transientXrHitTestSource){var o=e.getHitTestResultsForTransientInput(this._transientXrHitTestSource);o.forEach(function(a){i._processWebXRHitTestResult(a.results,a.inputSource)})}}},t.prototype._processWebXRHitTestResult=function(e,i){var r=this,o=[];e.forEach(function(a){var s=a.getPose(r._xrSessionManager.referenceSpace);if(s){var l=s.transform.position,u=s.transform.orientation;r._tmpPos.set(l.x,l.y,l.z),r._tmpQuat.set(u.x,u.y,u.z,u.w),te.FromFloat32ArrayToRefScaled(s.transform.matrix,0,1,r._tmpMat),r._xrSessionManager.scene.useRightHandedSystem||(r._tmpPos.z*=-1,r._tmpQuat.z*=-1,r._tmpQuat.w*=-1,r._tmpMat.toggleModelMatrixHandInPlace());var f={position:r.autoCloneTransformation?r._tmpPos.clone():r._tmpPos,rotationQuaternion:r.autoCloneTransformation?r._tmpQuat.clone():r._tmpQuat,transformationMatrix:r.autoCloneTransformation?r._tmpMat.clone():r._tmpMat,inputSource:i,isTransient:!!i,xrHitResult:a};o.push(f)}}),this.onHitTestResultObservable.notifyObservers(o)},t.Name=Ko.HIT_TEST,t.Version=2,t}(qo);Mo.AddWebXRFeature(Zv.Name,function(n,t){return function(){return new Zv(n,t)}},Zv.Version,!1);var Jv=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i._enabled=!1,i._featurePointCloud=[],i.onFeaturePointsAddedObservable=new ie,i.onFeaturePointsUpdatedObservable=new ie,i.xrNativeFeatureName="bjsfeature-points",i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce(function(){i._init()}),i}return Object.defineProperty(t.prototype,"featurePointCloud",{get:function(){return this._featurePointCloud},enumerable:!1,configurable:!0}),t.prototype.detach=function(){return n.prototype.detach.call(this)?(this.featurePointCloud.length=0,!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this._featurePointCloud.length=0,this.onFeaturePointsUpdatedObservable.clear(),this.onFeaturePointsAddedObservable.clear()},t.prototype._onXRFrame=function(e){if(!(!this.attached||!this._enabled||!e)){var i=e.featurePointCloud;if(!(!i||i.length===0)){if(i.length%5!==0)throw new Error("Received malformed feature point cloud of length: "+i.length);for(var r=i.length/5,o=new Array,a=new Array,s=0;s<r;s++){var l=s*5,u=i[l+4];this._featurePointCloud[u]?o.push(u):(this._featurePointCloud[u]={position:new y,confidenceValue:0},a.push(u)),this._featurePointCloud[u].position.x=i[l],this._featurePointCloud[u].position.y=i[l+1],this._featurePointCloud[u].position.z=i[l+2],this._featurePointCloud[u].confidenceValue=i[l+3]}a.length>0&&this.onFeaturePointsAddedObservable.notifyObservers(a),o.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(o)}}},t.prototype._init=function(){!this._xrSessionManager.session.trySetFeaturePointCloudEnabled||!this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)||(this._enabled=!0)},t.Name=Ko.FEATURE_POINTS,t.Version=1,t}(qo);Mo.AddWebXRFeature(Jv.Name,function(n){return function(){return new Jv(n)}},Jv.Version);var S5=function(){function n(t,e,i,r,o){this.xrController=t,this.trackedMeshes=e,this._handMesh=i,this._rigMapping=r,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(t.inputSource.hand),this._scene=e[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:o||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add(function(a){a.rootMesh&&a.rootMesh.setEnabled(!1)})),this.xrController.onMotionControllerInitObservable.add(function(a){a.onModelLoadedObservable.add(function(s){s.rootMesh&&s.rootMesh.setEnabled(!1)}),a.rootMesh&&a.rootMesh.setEnabled(!1)})}return n.prototype.generateHandPartsDefinition=function(t){var e;return e={},e.wrist=[t.WRIST],e.thumb=[t.THUMB_METACARPAL,t.THUMB_PHALANX_PROXIMAL,t.THUMB_PHALANX_DISTAL,t.THUMB_PHALANX_TIP],e.index=[t.INDEX_METACARPAL,t.INDEX_PHALANX_PROXIMAL,t.INDEX_PHALANX_INTERMEDIATE,t.INDEX_PHALANX_DISTAL,t.INDEX_PHALANX_TIP],e.middle=[t.MIDDLE_METACARPAL,t.MIDDLE_PHALANX_PROXIMAL,t.MIDDLE_PHALANX_INTERMEDIATE,t.MIDDLE_PHALANX_DISTAL,t.MIDDLE_PHALANX_TIP],e.ring=[t.RING_METACARPAL,t.RING_PHALANX_PROXIMAL,t.RING_PHALANX_INTERMEDIATE,t.RING_PHALANX_DISTAL,t.RING_PHALANX_TIP],e.little=[t.LITTLE_METACARPAL,t.LITTLE_PHALANX_PROXIMAL,t.LITTLE_PHALANX_INTERMEDIATE,t.LITTLE_PHALANX_DISTAL,t.LITTLE_PHALANX_TIP],e},n.prototype.updateFromXRFrame=function(t,e,i){var r=this;i===void 0&&(i=2);var o=this.xrController.inputSource.hand;o&&this.trackedMeshes.forEach(function(a,s){var l=o[s];if(l){var u=t.getJointPose(l,e);if(!u||!u.transform)return;var f=u.transform.position,c=u.transform.orientation;a.position.set(f.x,f.y,f.z),a.rotationQuaternion.set(c.x,c.y,c.z,c.w);var h=(u.radius||.008)*i;a.scaling.set(h,h,h),r._handMesh&&r._rigMapping&&r._rigMapping[s]&&(r._transformNodeMapping[s]=r._transformNodeMapping[s]||r._scene.getTransformNodeByName(r._rigMapping[s]),r._transformNodeMapping[s]&&(r._transformNodeMapping[s].position.copyFrom(a.position),r._transformNodeMapping[s].rotationQuaternion.copyFrom(a.rotationQuaternion),a.isVisible=!1)),a.getScene().useRightHandedSystem||(a.position.z*=-1,a.rotationQuaternion.z*=-1,a.rotationQuaternion.w*=-1)}})},n.prototype.getHandPartMeshes=function(t){var e=this;return this.handPartsDefinition[t].map(function(i){return e.trackedMeshes[i]})},n.prototype.dispose=function(){this.trackedMeshes.forEach(function(t){return t.dispose()}),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},n.prototype._generateDefaultHandMesh=function(){return eu(this,void 0,void 0,function(){var t,e,i,r,o,a,s,l;return tu(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),t=this.xrController.inputSource.handedness==="right"?"right":"left",e=(t==="right"?"r":"l")+"_hand_"+(this._scene.useRightHandedSystem?"r":"l")+"hs.glb",[4,$t.ImportMeshAsync("","https://assets.babylonjs.com/meshes/HandMeshes/",e,this._scene)];case 1:return i=u.sent(),r={base:_e.FromInts(116,63,203),fresnel:_e.FromInts(149,102,229),fingerColor:_e.FromInts(177,130,255),tipFresnel:_e.FromInts(220,200,255)},o=new Wb("leftHandShader",this._scene,{emitComments:!1}),[4,o.loadAsync("https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json")];case 2:if(u.sent(),o.build(!1),o.needDepthPrePass=!0,o.transparencyMode=gt.MATERIAL_ALPHABLEND,o.alphaMode=Me.ALPHA_COMBINE,a={base:o.getBlockByName("baseColor"),fresnel:o.getBlockByName("fresnelColor"),fingerColor:o.getBlockByName("fingerColor"),tipFresnel:o.getBlockByName("tipFresnelColor")},a.base.value=r.base,a.fresnel.value=r.fresnel,a.fingerColor.value=r.fingerColor,a.tipFresnel.value=r.tipFresnel,i.meshes[1].material=o,this._defaultHandMesh=!0,this._handMesh=i.meshes[0],this._rigMapping=["wrist_","thumb_metacarpal_","thumb_proxPhalanx_","thumb_distPhalanx_","thumb_tip_","index_metacarpal_","index_proxPhalanx_","index_intPhalanx_","index_distPhalanx_","index_tip_","middle_metacarpal_","middle_proxPhalanx_","middle_intPhalanx_","middle_distPhalanx_","middle_tip_","ring_metacarpal_","ring_proxPhalanx_","ring_intPhalanx_","ring_distPhalanx_","ring_tip_","little_metacarpal_","little_proxPhalanx_","little_intPhalanx_","little_distPhalanx_","little_tip_"].map(function(f){return""+f+(t==="right"?"R":"L")}),s=this._scene.getTransformNodeByName(this._rigMapping[0]),s)s.parent&&s.parent.rotate(Mi.Y,Math.PI);else throw new Error("could not find the wrist node");return[3,4];case 3:return l=u.sent(),Ee.Error("error loading hand mesh"),console.log(l),[3,4];case 4:return[2]}})})},n}(),ey=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r.options=i,r.onHandAddedObservable=new ie,r.onHandRemovedObservable=new ie,r._hands={},r._attachHand=function(o){var a,s,l,u,f,c,h,p,_,g;if(!(!o.inputSource.hand||r._hands[o.uniqueId])){var v=o.inputSource.hand,E=[],T=((a=r.options.jointMeshes)===null||a===void 0?void 0:a.sourceMesh)||tn.CreateSphere("jointParent",{diameter:1});T.isVisible=!!(!((s=r.options.jointMeshes)===null||s===void 0)&&s.keepOriginalVisible);for(var S=0;S<v.length;++S){var C=T.createInstance(o.uniqueId+"-handJoint-"+S);if(!((l=r.options.jointMeshes)===null||l===void 0)&&l.onHandJointMeshGenerated){var O=r.options.jointMeshes.onHandJointMeshGenerated(C,S,o.uniqueId);O&&O!==C&&(C.dispose(),C=O)}if(C.isPickable=!1,!((u=r.options.jointMeshes)===null||u===void 0)&&u.enablePhysics){var A=r.options.jointMeshes.physicsProps||{},M=A.impostorType!==void 0?A.impostorType:It.SphereImpostor;C.physicsImpostor=new It(C,M,Ot({mass:0},A))}C.rotationQuaternion=new Re,!((f=r.options.jointMeshes)===null||f===void 0)&&f.invisible&&(C.isVisible=!1),E.push(C)}var D=o.inputSource.handedness==="right"?"right":"left",U=((c=r.options.jointMeshes)===null||c===void 0?void 0:c.handMeshes)&&((h=r.options.jointMeshes)===null||h===void 0?void 0:h.handMeshes[D]),V=((p=r.options.jointMeshes)===null||p===void 0?void 0:p.rigMapping)&&((_=r.options.jointMeshes)===null||_===void 0?void 0:_.rigMapping[D]),B=new S5(o,E,U,V,(g=r.options.jointMeshes)===null||g===void 0?void 0:g.disableDefaultHandMesh);r._hands[o.uniqueId]={handObject:B,id:t._idCounter++},r.onHandAddedObservable.notifyObservers(B)}},r.xrNativeFeatureName="hand-tracking",r}return t.prototype.isCompatible=function(){return typeof XRHand<"u"},t.prototype.attach=function(){var e=this;return n.prototype.attach.call(this)?(this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,function(i){e._detachHand(i.uniqueId)}),!0):!1},t.prototype.detach=function(){var e=this;return n.prototype.detach.call(this)?(Object.keys(this._hands).forEach(function(i){e._detachHand(i)}),!0):!1},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var i;return((i=this._hands[e])===null||i===void 0?void 0:i.handObject)||null},t.prototype.getHandByHandedness=function(e){var i=this,r=Object.keys(this._hands).map(function(a){return i._hands[a].handObject.xrController.inputSource.handedness}),o=r.indexOf(e);return o!==-1?this._hands[o].handObject:null},t.prototype._onXRFrame=function(e){var i=this;Object.keys(this._hands).forEach(function(r){var o;i._hands[r].handObject.updateFromXRFrame(e,i._xrSessionManager.referenceSpace,(o=i.options.jointMeshes)===null||o===void 0?void 0:o.scaleFactor)})},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=Ko.HAND_TRACKING,t.Version=1,t}(qo);Mo.AddWebXRFeature(ey.Name,function(n,t){return function(){return new ey(n,t)}},ey.Version,!1);var C5=function(n){j(t,n);function t(e,i,r){var o=n.call(this,e,P5["left-right"],i,r)||this;return o._mapping={defaultButton:{valueNodeName:"VALUE",unpressedNodeName:"UNPRESSED",pressedNodeName:"PRESSED"},defaultAxis:{valueNodeName:"VALUE",minNodeName:"MIN",maxNodeName:"MAX"},buttons:{"xr-standard-trigger":{rootNodeName:"SELECT",componentProperty:"button",states:["default","touched","pressed"]},"xr-standard-squeeze":{rootNodeName:"GRASP",componentProperty:"state",states:["pressed"]},"xr-standard-touchpad":{rootNodeName:"TOUCHPAD_PRESS",labelAnchorNodeName:"squeeze-label",touchPointNodeName:"TOUCH"},"xr-standard-thumbstick":{rootNodeName:"THUMBSTICK_PRESS",componentProperty:"state",states:["pressed"]}},axes:{"xr-standard-touchpad":{"x-axis":{rootNodeName:"TOUCHPAD_TOUCH_X"},"y-axis":{rootNodeName:"TOUCHPAD_TOUCH_Y"}},"xr-standard-thumbstick":{"x-axis":{rootNodeName:"THUMBSTICK_X"},"y-axis":{rootNodeName:"THUMBSTICK_Y"}}}},o.profileId="microsoft-mixed-reality",o}return t.prototype._getFilenameAndPath=function(){var e="";this.handedness==="left"?e=t.MODEL_LEFT_FILENAME:e=t.MODEL_RIGHT_FILENAME;var i="default",r=t.MODEL_BASE_URL+i+"/";return{filename:e,path:r}},t.prototype._getModelLoadingConstraints=function(){var e=$t.IsPluginForExtensionAvailable(".glb");return e||de.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var i=this;this.rootMesh&&(this.getComponentIds().forEach(function(r,o){if(!i.disableAnimation&&r&&i.rootMesh){var a=i._mapping.buttons[r],s=a.rootNodeName;if(!s){de.Log("Skipping unknown button at index: "+o+" with mapped name: "+r);return}var l=i._getChildByName(i.rootMesh,s);if(!l){de.Warn("Missing button mesh with name: "+s);return}if(a.valueMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.valueNodeName),a.pressedMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.pressedNodeName),a.unpressedMesh=i._getImmediateChildByName(l,i._mapping.defaultButton.unpressedNodeName),a.valueMesh&&a.pressedMesh&&a.unpressedMesh){var u=i.getComponent(r);u&&u.onButtonStateChangedObservable.add(function(f){i._lerpTransform(a,f.value)},void 0,!0)}else de.Warn("Missing button submesh under mesh with name: "+s)}}),this.getComponentIds().forEach(function(r,o){var a=i.getComponent(r);a.isAxes()&&["x-axis","y-axis"].forEach(function(s){if(i.rootMesh){var l=i._mapping.axes[r][s],u=i._getChildByName(i.rootMesh,l.rootNodeName);if(!u){de.Warn("Missing axis mesh with name: "+l.rootNodeName);return}l.valueMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.valueNodeName),l.minMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.minNodeName),l.maxMesh=i._getImmediateChildByName(u,i._mapping.defaultAxis.maxNodeName),l.valueMesh&&l.minMesh&&l.maxMesh?a&&a.onAxisValueChangedObservable.add(function(f){var c=s==="x-axis"?f.x:f.y;i._lerpTransform(l,c,!0)},void 0,!0):de.Warn("Missing axis submesh under mesh with name: "+l.rootNodeName)}})}))},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i,r=0;r<e.length;r++){var o=e[r];o.isPickable=!1,o.parent||(i=o)}i&&i.setParent(this.rootMesh),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t}(cc);Gn.RegisterController("windows-mixed-reality",function(n,t){return new C5(t,n.gamepad,n.handedness)});var P5={},BI=function(n){j(t,n);function t(e,i,r,o,a){a===void 0&&(a=!1);var s=n.call(this,e,A5[r],i,r)||this;return s._forceLegacyControllers=a,s.profileId="oculus-touch",s}return t.prototype._getFilenameAndPath=function(){var e="";this.handedness==="left"?e=t.MODEL_LEFT_FILENAME:e=t.MODEL_RIGHT_FILENAME;var i=this._isQuest()?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL;return{filename:e,path:i}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var i=this,r=this._isQuest(),o=this.handedness==="right"?-1:1;this.getComponentIds().forEach(function(a){var s=a&&i.getComponent(a);s&&s.onButtonStateChangedObservable.add(function(l){if(!(!i.rootMesh||i.disableAnimation))switch(a){case"xr-standard-trigger":r||(i._modelRootNode.getChildren()[3].rotation.x=-l.value*.2,i._modelRootNode.getChildren()[3].position.y=-l.value*.005,i._modelRootNode.getChildren()[3].position.z=-l.value*.005);return;case"xr-standard-squeeze":r||(i._modelRootNode.getChildren()[4].position.x=o*l.value*.0035);return;case"xr-standard-thumbstick":return;case"a-button":case"x-button":r||(l.pressed?i._modelRootNode.getChildren()[1].position.y=-.001:i._modelRootNode.getChildren()[1].position.y=0);return;case"b-button":case"y-button":r||(l.pressed?i._modelRootNode.getChildren()[2].position.y=-.001:i._modelRootNode.getChildren()[2].position.y=0);return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0)),e.forEach(function(i){i.isPickable=!1}),this._isQuest()?this._modelRootNode=e[0]:(this._modelRootNode=e[1],this.rootMesh.position.y=.034,this.rootMesh.position.z=.052),this._modelRootNode.parent=this.rootMesh},t.prototype._updateModel=function(){},t.prototype._isQuest=function(){return!!navigator.userAgent.match(/Quest/gi)&&!this._forceLegacyControllers},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t}(cc);Gn.RegisterController("oculus-touch",function(n,t){return new BI(t,n.gamepad,n.handedness)});Gn.RegisterController("oculus-touch-legacy",function(n,t){return new BI(t,n.gamepad,n.handedness,!0)});var A5={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"x-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"x_button",visualResponses:{}},"y-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"y_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"a-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"a_button",visualResponses:{}},"b-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"b_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-right",assetPath:"right.glb"}},R5=function(n){j(t,n);function t(e,i,r){var o=n.call(this,e,O5[r],i,r)||this;return o.profileId="htc-vive",o}return t.prototype._getFilenameAndPath=function(){var e=t.MODEL_FILENAME,i=t.MODEL_BASE_URL;return{filename:e,path:i}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var i=this;this.getComponentIds().forEach(function(r){var o=r&&i.getComponent(r);o&&o.onButtonStateChangedObservable.add(function(a){if(!(!i.rootMesh||i.disableAnimation))switch(r){case"xr-standard-trigger":i._modelRootNode.getChildren()[6].rotation.x=-a.value*.15;return;case"xr-standard-touchpad":return;case"xr-standard-squeeze":return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new ne(this.profileId+" "+this.handedness,this.scene),e.forEach(function(i){i.isPickable=!1}),this._modelRootNode=e[1],this._modelRootNode.parent=this.rootMesh,this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=Re.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(cc);Gn.RegisterController("htc-vive",function(n,t){return new R5(t,n.gamepad,n.handedness)});var O5={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc-vive-none",assetPath:"none.glb"}};function ou(n){return n.startsWith("#")?n:"#"+n}function M5(n){return n.startsWith("#")?n.slice(1):n}function ty(n){return("0"+(n*255|0).toString(16)).slice(-2)}function au(n){return ty(n.r)+ty(n.g)+ty(n.b)}function Fy(n){const t=M5(n);return new _e(parseInt(t.slice(0,2),16)/256,parseInt(t.slice(2,4),16)/256,parseInt(t.slice(4,6),16)/256)}function VI(n,t){return n.bodyShapes.includes(t)}function x5(n){return VI(n,Ce.BodyShape.MALE)}function I5(n){return VI(n,Ce.BodyShape.FEMALE)}function Kb(n,t=Ce.BodyShape.MALE){const e=n.emoteDataADR74.representations.find(i=>i.bodyShapes.includes(t));if(!e)throw new Error(`Could not find a representation of bodyShape=${t} for emote="${n.id}"`);return e}function mu(n,t=Ce.BodyShape.MALE){switch(t){case Ce.BodyShape.FEMALE:{const e=n.data.representations.find(I5);if(!e)throw new Error(`Could not find a BaseFemale representation for wearable="${n.id}"`);return e}case Ce.BodyShape.MALE:{const e=n.data.representations.find(x5);if(!e)throw new Error(`Could not find a BaseMale representation for wearable="${n.id}"`);return e}}}function qb(n,t=Ce.BodyShape.MALE){if(Qb(n,t))return mu(n,t);if(n.data.representations.length>0)return n.data.representations[0];throw new Error(`The wearable="${n.id}" has no representation`)}function Qb(n,t=Ce.BodyShape.MALE){try{return mu(n,t),!0}catch{return!1}}function D5(n){const t=n.contents.find(e=>e.key===n.mainFile);if(!t)throw new Error("Could not find main file");return t.url}function yp(n){return n.mainFile.endsWith("png")}const UI=1,w5=2.8,L5=w5-UI;function N5(n){return Math.min(Math.max(n,0),100)/100*L5+UI}function F5(n){const t=n?parseFloat(n):null;return t===null||isNaN(t)?null:t}function B5(n){switch(n&&Co(n)?null:n==null?void 0:n.data.category){case Ce.WearableCategory.UPPER_BODY:return 2;case Ce.WearableCategory.SKIN:return 1.75;default:return 1.25}}const Nd="default",V5=6,GO="collections-thirdparty",U5=10;function k5(n){const t=n.split(":"),e=t.length;let i;return n.includes(GO)&&e===U5?i={assetUrn:t.slice(0,7).join(":"),tokenId:t[9],contractAddress:t[8],network:t[7]}:!n.includes(GO)&&e>V5&&(i={assetUrn:t.slice(0,-1).join(":"),tokenId:t[e-1]}),i??{assetUrn:n,tokenId:void 0}}async function z5(n,t){const[e,i]=await Zd([n],t);if(e.length===1)return e[0];if(i.length===1)return i[0];throw new Error(`Could not find wearable or emote for urn="${n}"`)}function G5(n){const t=n.map(r=>JSON.parse(atob(r))),e=t.filter(as),i=t.filter(Co);return[e,i]}function iy(n){return typeof n=="number"&&!isNaN(n)}function W5(n){return/^0x[a-fA-F0-9]{40}$/g.test(n)}function H5(n){return/^baf[a-z2-7]{56}$/.test(n)}function kI(n){return n?n===Nd?{type:"address",value:n}:n.startsWith(Nd)?isNaN(Number(n.replace(Nd,"")))?null:{type:"address",value:n}:W5(n)?{type:"address",value:n}:H5(n)?{type:"entity",value:n}:null:null}async function j5(n,t){if(!n)return[];const[e]=await Zd(n.avatar.wearables,t);return e}async function Zd(n,t){if(n.length===0)return[[],[]];const e=n.map(i=>i.replace(/^dcl:\/\/base-avatars\//,"urn:decentraland:off-chain:base-avatars:")).map(i=>k5(i).assetUrn);return Cb.fetchItems(e,t)}async function X5(n){if(n.length===0)return[[],[]];const t=n.map(o=>fetch(o).then(a=>a.json()).catch()),e=await Promise.all(t),i=e.filter(as),r=e.filter(Co);return[i,r]}const zI=qF();async function GI(n,t){return zI.memo(n,async()=>n===Nd?null:await Cb.fetchProfile(n,t).then(i=>i&&i.avatars.length>0?i.avatars[0]:null).catch(i=>console.log(`Failed to load profile="${n}"`,i))||null)}async function WI(n,t){return zI.memo(n,async()=>await Cb.fetchProfileEntity(n,t).then(i=>i&&i.avatars.length>0?i.avatars[0]:null).catch(i=>console.log(`Failed to load profile="${n}"`,i))||null)}async function HI(n){const{contractAddress:t,itemId:e,tokenId:i,peerUrl:r,marketplaceServerUrl:o}=n;if(!e&&!i)throw new Error("You need to provide an itemId or a tokenId");const a=Wf.get("NETWORK");let s=`urn:decentraland:${a}:collections-v2:${t}:${e}`;if(!e&&!i)throw new Error("You must provide either tokenId or itemId");if(!e&&i){const l=await UF.fetchNFT(t,i,o);s=l.network!==Ce.Network.ETHEREUM?`urn:decentraland:${a}:collections-v2:${t}:${l.itemId}`:l.image.split("contents/")[1].split("/thumbnail")[0]}return z5(s,r)}async function Y5(n,t,e,i,r,o,a,s){const[l,[u,f],[c,h]]=await Promise.all([j5(n,s),Zd([r,...t],s),X5(e)]),[p,_]=G5(i);let g=[...l,...u,...c,...p];const v=[...f,...h,..._];g=g.filter(S=>Qb(S,r));const E=[],T=o&&a?HF():o?WF():a?GF():[];for(const S of T)if(!zF(g,S)){const O=jF(S,r);if(O)E.push(O);else throw new Error(`Could not get default URN for category="${S}"`)}if(E.length>0){const[S]=await Zd(E,s);g=[...g,...S]}return[g,v]}async function K5(n={}){const{contractAddress:t,tokenId:e,itemId:i}=n,r=n.peerUrl||Wf.get("PEER_URL"),o=n.marketplaceServerUrl||n.nftServerUrl||Wf.get("MARKETPLACE_SERVER_URL");let a=Promise.resolve();t&&(a=HI({contractAddress:t,tokenId:e,itemId:i,peerUrl:r,marketplaceServerUrl:o}));const s=kI(n.profile),l=s?s.type==="address"?GI(s.value,r):WI(s.value,r):Promise.resolve(null),[u,f]=await Promise.all([a,l]),c=n.bodyShape||f&&f.avatar.bodyShape||(u&&as(u)?XF(u):Ce.BodyShape.MALE),h=ou(n.skin||f&&au(f.avatar.skin.color)||"cc9b76"),p=ou(n.hair||f&&au(f.avatar.hair.color)||"000000"),_=ou(n.eyes||f&&au(f.avatar.eyes.color)||"000000"),g=[...n.urns||[]],v=n.urls||[],E=n.base64s||[],T=n.blob?q5(n.blob):null;let S=[],C=[],O=1.75,A=Ce.PreviewType.WEARABLE,M={color:"#4b4852",transparent:n.disableBackground===!0};if(g.length>0||v.length>0||E.length>0||u&&Co(u)||n.profile){A=Ce.PreviewType.AVATAR;const[W,$]=await Y5(f,g,v,E,c,!n.disableDefaultWearables&&!(f!=null&&f.avatar),!n.disableFace,r);S=W,C=$}if(u){if(O=S.length>0?O:B5(u),as(u)){const W=qb(u);yp(W)&&A!==Ce.PreviewType.AVATAR&&(A=Ce.PreviewType.TEXTURE)}if(M={...M,image:u.thumbnail},Ce.isStandard(u)){const W=Ce.Rarity.getColor(u.rarity);M={...M,image:u.thumbnail,color:W}}}let D=n.disableDefaultEmotes||Co(u)?null:n.emote?n.emote:Ce.PreviewEmote.IDLE;n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)&&(D=n.emote);let U=Ce.PreviewCamera.INTERACTIVE;n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)&&(U=n.camera);let V=Ce.PreviewProjection.PERSPECTIVE;n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)&&(V=n.projection);const B=typeof n.autoRotateSpeed=="number"&&!isNaN(n.autoRotateSpeed)?n.autoRotateSpeed:.2,z=!n.disableAutoCenter;let J=1,X=100,re=50;ry(n.wheelZoom)&&(J=Math.max(n.wheelZoom,1)),ry(n.wheelPrecision)&&(X=Math.max(n.wheelPrecision,1)),ry(n.wheelStart)&&(re=100-Math.min(Math.max(n.wheelStart,0),100)),n.background&&(M.color=n.background);let ae=0,se=0,H=0;switch(A){case Ce.PreviewType.WEARABLE:{ae=-2,se=2,H=2;break}case Ce.PreviewType.AVATAR:{ae=0,se=1,H=3.5;break}}iy(n.cameraX)&&(ae=n.cameraX),iy(n.cameraY)&&(se=n.cameraY),iy(n.cameraZ)&&(H=n.cameraZ);let Z=null;(n==null?void 0:n.type)===Ce.PreviewType.WEARABLE&&S.length>=2&&(A=n.type,Z=S[1]);const q=typeof n.zoomScale!="number"||isNaN(n.zoomScale)||n.zoomScale<=0?1:n.zoomScale,F=n.socialEmote??kF(Co(u)?u:null)??void 0;return{item:u??T??Z??C.pop(),wearables:S,bodyShape:c,forceRender:(f==null?void 0:f.avatar.forceRender)||[],skin:h,hair:p,eyes:_,type:A,background:M,face:n.disableFace!==!1,emote:D,camera:U,projection:V,autoRotateSpeed:n.disableAutoRotate?0:B,centerBoundingBox:z,offsetX:n.offsetX||0,offsetY:n.offsetY||0,offsetZ:n.offsetZ||0,cameraX:ae,cameraY:se,cameraZ:H,zoom:(typeof n.zoom=="number"?N5(n.zoom):O)*q,wheelZoom:J,wheelPrecision:X,wheelStart:re,fadeEffect:!n.disableFadeEffect,showSceneBoundaries:!!n.showSceneBoundaries,showThumbnailBoundaries:!!n.showThumbnailBoundaries,panning:!!n.panning,lockAlpha:!!n.lockAlpha,lockBeta:!!n.lockBeta,lockRadius:!!n.lockRadius,socialEmote:F}}function ry(n){return typeof n=="number"&&!isNaN(n)}function WO(n){return{...n,contents:n.contents.map(t=>({key:t.key,url:URL.createObjectURL(t.blob)}))}}function q5(n){return"emoteDataADR74"in n?{...n,emoteDataADR74:{...n.emoteDataADR74,representations:n.emoteDataADR74.representations.map(WO)}}:{...n,data:{...n.data,representations:n.data.representations.map(WO)}}}const Fd={};function ny(n,t){return t===Fd[n]}function Q5(n,t,e=[]){const[i,r]=Ct.useState(!1),[o,a]=Ct.useState(null),[s,l]=Ct.useState("");return typeof Fd[n]>"u"&&(Fd[n]=0),Ct.useEffect(()=>{const u=++Fd[n];r(!0),t().then(f=>{ny(n,u)&&a(f)}).catch(f=>{ny(n,u)&&l(f.message)}).finally(()=>{ny(n,u)&&r(!1)})},e),[o,i,s]}var $5=Jd();const Z5=ub($5),jI=n=>{const t=Ct.useCallback(n,[]);Ct.useEffect(()=>{function e(i){t(i)}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])},J5=()=>{const[n,t]=Ct.useState({});return jI(e=>{if(e.data&&e.data.type===Ce.PreviewMessageType.UPDATE&&typeof e.data.payload=="object"&&typeof e.data.payload.options=="object"){const{options:i}=e.data.payload;Z5(n,i)||t(i)}}),n},$b=()=>{const[n,t]=Ct.useState(()=>new URLSearchParams(window.location.search)),e=Ct.useRef(window.location.search);Ct.useEffect(()=>{const a=window.location.search;a!==e.current&&(t(new URLSearchParams(a)),e.current=a)});const i=Ct.useMemo(()=>{const a=n.get("autoRotateSpeed"),s=n.get("offsetX"),l=n.get("offsetY"),u=n.get("offsetZ"),f=n.get("cameraX"),c=n.get("cameraY"),h=n.get("cameraZ"),p=n.get("zoomScale"),_=n.get("wheelZoom"),g=n.get("wheelPrecision"),v=n.get("wheelStart"),E=n.get("bodyShape"),T=n.get("panning"),S=n.get("lockAlpha"),C=n.get("lockBeta"),O=n.get("lockRadius"),A=n.has("transparentBackground");A&&console.warn('Deprecated: you are using the query param "transparentBackground" that has been deprecated in favor of "disableBackground". Please switch to the new query param since in the future this will not be supported.');const M=n.get("centerBoundingBox")!=="false";return{contractAddress:n.get("contract"),tokenId:n.get("token"),itemId:n.get("item"),skin:n.get("skin"),hair:n.get("hair"),eyes:n.get("eyes"),emote:n.get("emote"),camera:n.get("camera"),projection:n.get("projection"),background:n.get("background"),autoRotateSpeed:a?parseFloat(a):null,offsetX:s?parseFloat(s):null,offsetY:l?parseFloat(l):null,offsetZ:u?parseFloat(u):null,cameraX:f?parseFloat(f):null,cameraY:c?parseFloat(c):null,cameraZ:h?parseFloat(h):null,wheelZoom:_?parseFloat(_):null,wheelPrecision:g?parseFloat(g):null,wheelStart:v?parseFloat(v):null,zoom:F5(n.get("zoom")),zoomScale:p?parseFloat(p):null,bodyShape:E==="female"||E===Ce.BodyShape.FEMALE?Ce.BodyShape.FEMALE:E==="male"||E===Ce.BodyShape.MALE?Ce.BodyShape.MALE:null,urns:n.getAll("urn"),urls:n.getAll("url"),base64s:n.getAll("base64"),profile:n.get("profile"),showSceneBoundaries:n.has("showSceneBoundaries")||!1,showThumbnailBoundaries:n.has("showThumbnailBoundaries")||!1,disableBackground:n.has("disableBackground")||A,disableAutoCenter:n.has("disableAutoCenter")||!M,disableAutoRotate:n.has("disableAutoRotate")||!M,disableFace:n.has("disableFace"),disableDefaultWearables:n.has("disableDefaultWearables"),disableDefaultEmotes:n.has("disableDefaultEmotes"),disableFadeEffect:n.has("disableFadeEffect"),peerUrl:n.get("peerUrl"),marketplaceServerUrl:n.get("marketplaceServerUrl"),nftServerUrl:n.get("nftServerUrl"),type:n.get("type"),panning:T==="true"||T===null,lockAlpha:S==="true",lockBeta:C==="true",lockRadius:O==="true",unityMode:n.get("mode"),disableLoader:n.has("disableLoader"),username:n.get("username"),socialEmote:(()=>{const U=n.get("socialEmote");if(!U)return null;try{return JSON.parse(U)}catch{return null}})()}},[n]),r=J5();return Ct.useMemo(()=>{const a={...i,...r},s={};return Object.keys(r).forEach(l=>{r[l]!==void 0&&(s[l]=!0)}),{options:a,overrideSources:s}},[i,r])};function eX(){const{options:n}=$b(),[t,e,i]=Q5("useConfig",()=>K5(n),[n]);return[t,e,i]}function cn(){return window.parent||window}const XI=()=>{const[n,t]=Ct.useState(!1);Ct.useEffect(()=>{n||(Ce.sendMessage(cn(),Ce.PreviewMessageType.READY,null),t(!0))},[n])};function tX(n,t){Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:n,ok:!0,result:t})}function Sd(n,t){Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:n,ok:!1,error:t})}const YI=()=>{const n=Ct.useRef();return jI(async t=>{if(t.data&&t.data.type===Ce.PreviewMessageType.CONTROLLER_REQUEST&&typeof t.data.payload=="object"&&typeof t.data.payload.id=="string"&&typeof t.data.payload.namespace=="string"&&typeof t.data.payload.method=="string"&&typeof t.data.payload.params=="object"&&Array.isArray(t.data.payload.params)){const{id:e,method:i,namespace:r,params:o}=t.data.payload;if(n.current)if(r in n.current)if(i in n.current[r])try{const l=await n.current[r][i].apply(null,o);tX(e,l)}catch(a){Sd(e,a.message)}else Sd(e,"Invalid method");else Sd(e,"Invalid namespace");else Sd(e,"Controller not ready")}}),n};function iX(n){return t=>t.data.category===n}function lf(n){return t=>t.wearable.data.category===n||(t.wearable.data.hides||[]).includes(n)||(t.wearable.data.replaces||[]).includes(n)}function rX(n){return n.some(t=>{var o,a;const e=t.wearable.data.category===Ce.WearableCategory.UPPER_BODY,i=(o=t.wearable.data.hides)==null?void 0:o.includes(Ce.WearableCategory.UPPER_BODY),r=(a=t.wearable.data.removesDefaultHiding)==null?void 0:a.includes(Ce.BodyPartCategory.HANDS);return(e||i)&&!r})}function nX(n){return!!n}function KI(n){const t=qb(n);return!yp(t)}function oX(n){return!KI(n)}function aX(n,t){var s,l,u;const e=n.name.toLowerCase(),i=e.includes("prop")||e.includes("armature_prop"),r=e.includes("avatarother")||e.includes("armature_other"),o=e.includes("avatar")||e.includes("armature")||!i&&!r;return[((s=t==null?void 0:t.Armature_Prop)==null?void 0:s.animation.toLowerCase())===e&&i,((l=t==null?void 0:t.Armature_Other)==null?void 0:l.animation.toLowerCase())===e&&r,((u=t==null?void 0:t.Armature)==null?void 0:u.animation.toLowerCase())===e&&o,!(t!=null&&t.Armature)&&!(t!=null&&t.Armature_Other)&&!(t!=null&&t.Armature_Prop)].some(f=>f)}function sX(n){const t=[...n.transformNodes,...n.meshes],e=new Set(t);return t.filter(i=>!i.parent||!e.has(i.parent))}function lX(n,t){const e=new Map,i=sX(n),r=(a,s)=>{e.set(a,s);const l=a.getChildren(),u=s.getChildren(),f=Math.min(l.length,u.length);for(let c=0;c<f;c++)r(l[c],u[c])},o=Math.min(i.length,t.length);for(let a=0;a<o;a++)r(i[a],t[a]);return e}const uX=(n,t)=>{for(const e of n)e.getChildMeshes().forEach(i=>{if(!i.material)return;const r=i.material.clone(i.material.name+"_Other");if(!r)return;const o=r.name.toLowerCase().includes("skin");if(o&&r instanceof Ci){const a=r.albedoTexture;a&&a.dispose(),r.albedoTexture=void 0;const s=r.bumpTexture;s&&s.dispose(),r.bumpTexture=void 0;const l=r.metallicTexture;l&&l.dispose(),r.metallicTexture=void 0,r.albedoColor=t,r.specularIntensity=0,i.material=r}else if(o&&r instanceof Mt){const a=r.diffuseTexture;a&&a.dispose(),r.diffuseTexture=void 0;const s=r.bumpTexture;s&&s.dispose(),r.bumpTexture=void 0;const l=r.specularTexture;l&&l.dispose(),r.specularTexture=void 0,r.diffuseColor=t,r.specularColor=_e.Black(),i.material=r}else r.dispose(),i.visibility=0})};function fX(n){const t=n.find(l=>l.wearable.data.category===Ce.WearableCategory.BODY_SHAPE);if(!t)return null;const e=n.some(l=>l.wearable.data.category===Ce.WearableCategory.SKIN),i=e||n.some(lf(Ce.WearableCategory.UPPER_BODY)),r=e||n.some(lf(Ce.WearableCategory.LOWER_BODY)),o=e||n.some(lf(Ce.WearableCategory.FEET)),a=e||n.some(lf(Ce.BodyPartCategory.HEAD)),s=e||n.some(lf(Ce.BodyPartCategory.HANDS))||rX(n);for(const l of t.container.meshes){const u=l.name.toLowerCase();u.endsWith("ubody_basemesh")&&i&&l.setEnabled(!1),u.endsWith("lbody_basemesh")&&r&&l.setEnabled(!1),u.endsWith("feet_basemesh")&&o&&l.setEnabled(!1),u.endsWith("head")&&a&&l.setEnabled(!1),u.endsWith("head_basemesh")&&a&&l.setEnabled(!1),u.endsWith("mask_eyes")&&a&&l.setEnabled(!1),u.endsWith("mask_eyebrows")&&a&&l.setEnabled(!1),u.endsWith("mask_mouth")&&a&&l.setEnabled(!1),u.endsWith("hands_basemesh")&&s&&l.setEnabled(!1)}return t}const qI=[Ce.WearableCategory.HELMET,Ce.WearableCategory.HAIR,Ce.WearableCategory.FACIAL_HAIR,Ce.WearableCategory.MOUTH,Ce.WearableCategory.EYEBROWS,Ce.WearableCategory.EYES,Ce.WearableCategory.UPPER_BODY,Ce.WearableCategory.LOWER_BODY,Ce.WearableCategory.FEET,Ce.WearableCategory.HANDS_WEAR,Ce.BodyPartCategory.HANDS],cX=[Ce.WearableCategory.SKIN,Ce.WearableCategory.UPPER_BODY,Ce.WearableCategory.HANDS_WEAR,Ce.WearableCategory.LOWER_BODY,Ce.WearableCategory.FEET,Ce.WearableCategory.HELMET,Ce.WearableCategory.HAT,Ce.WearableCategory.TOP_HEAD,Ce.WearableCategory.MASK,Ce.WearableCategory.EYEWEAR,Ce.WearableCategory.EARRING,Ce.WearableCategory.TIARA,Ce.WearableCategory.HAIR,Ce.WearableCategory.EYEBROWS,Ce.WearableCategory.EYES,Ce.WearableCategory.MOUTH,Ce.WearableCategory.FACIAL_HAIR,Ce.WearableCategory.BODY_SHAPE];function hX(n){const t=n.data.category,e=n.data.replaces||[],i=n.data.hides||[];return t===Ce.WearableCategory.SKIN&&i.push(...qI),Array.from(new Set([...e,...i])).filter(r=>r!==t)}function dX(n){const t=new Map;let e=[...n.wearables];if(n.item&&as(n.item)){e=[];for(const a of n.wearables){const{category:s,hides:l,replaces:u}=n.item.data;a.data.category==="skin"&&(qI.includes(s)||l&&l.includes(Ce.BodyPartCategory.HEAD)||u&&u.includes(Ce.BodyPartCategory.HEAD))||a.data.hides&&a.data.hides.includes(s)||a.data.replaces&&a.data.replaces.includes(s)||e.push(a)}e.push(n.item)}for(const a of e){const s=a.data.category;Qb(a,n.bodyShape)&&t.set(s,a)}const i=n.forceRender||[],r=new Set;for(const a of cX){const s=t.get(a);if(s&&!r.has(a))for(const l of hX(s))r.add(l)}const o=Array.from(r).filter(a=>!i.includes(a));for(const a of o)t.delete(a);return t}function QI(n,t){n&&(n.useAutoRotationBehavior=!0,n.autoRotationBehavior&&(n.autoRotationBehavior.idleRotationSpeed=t.autoRotateSpeed))}const pX="modulepreload",_X=function(n){return"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.2/"+n},HO={},mX=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){let a=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(c=>({status:"fulfilled",value:c}),c=>({status:"rejected",reason:c}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),l=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));r=a(e.map(u=>{if(u=_X(u),u in HO)return;HO[u]=!0;const f=u.endsWith(".css"),c=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${c}`))return;const h=document.createElement("link");if(h.rel=f?"stylesheet":pX,f||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),f)return new Promise((p,_)=>{h.addEventListener("load",p),h.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return r.then(a=>{for(const s of a||[])s.status==="rejected"&&o(s.reason);return t().catch(o)})};var zt=function(){function n(t,e,i){e===void 0&&(e=n.UNITMODE_PIXEL),i===void 0&&(i=!0),this.unit=e,this.negativeValueAllowed=i,this._value=1,this.ignoreAdaptiveScaling=!1,this._value=t,this._originalUnit=e}return Object.defineProperty(n.prototype,"isPercentage",{get:function(){return this.unit===n.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isPixel",{get:function(){return this.unit===n.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),n.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},n.prototype.updateInPlace=function(t,e){return e===void 0&&(e=n.UNITMODE_PIXEL),this._value=t,this.unit=e,this},n.prototype.getValue=function(t){if(t&&!this.ignoreAdaptiveScaling&&this.unit!==n.UNITMODE_PERCENTAGE){var e=0,i=0;if(t.idealWidth&&(e=this._value*t.getSize().width/t.idealWidth),t.idealHeight&&(i=this._value*t.getSize().height/t.idealHeight),t.useSmallestIdeal&&t.idealWidth&&t.idealHeight)return window.innerWidth<window.innerHeight?e:i;if(t.idealWidth)return e;if(t.idealHeight)return i}return this._value},n.prototype.toString=function(t,e){switch(this.unit){case n.UNITMODE_PERCENTAGE:var i=this.getValue(t)*100;return(e?i.toFixed(e):i)+"%";case n.UNITMODE_PIXEL:var r=this.getValue(t);return(e?r.toFixed(e):r)+"px"}return this.unit.toString()},n.prototype.fromString=function(t){var e=n._Regex.exec(t.toString());if(!e||e.length===0)return!1;var i=parseFloat(e[1]),r=this._originalUnit;if(this.negativeValueAllowed||i<0&&(i=0),e.length===4)switch(e[3]){case"px":r=n.UNITMODE_PIXEL;break;case"%":r=n.UNITMODE_PERCENTAGE,i/=100;break}return i===this._value&&r===this.unit?!1:(this._value=i,this.unit=r,!0)},Object.defineProperty(n,"UNITMODE_PERCENTAGE",{get:function(){return n._UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(n,"UNITMODE_PIXEL",{get:function(){return n._UNITMODE_PIXEL},enumerable:!1,configurable:!0}),n._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,n._UNITMODE_PERCENTAGE=0,n._UNITMODE_PIXEL=1,n}(),Vl=[new Ie(0,0),new Ie(0,0),new Ie(0,0),new Ie(0,0)],uf=[new Ie(0,0),new Ie(0,0),new Ie(0,0),new Ie(0,0)],ha=new Ie(0,0),Gs=new Ie(0,0),Jr=function(){function n(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r}return n.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},n.prototype.copyFromFloats=function(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r},n.CombineToRef=function(t,e,i){var r=Math.min(t.left,e.left),o=Math.min(t.top,e.top),a=Math.max(t.left+t.width,e.left+e.width),s=Math.max(t.top+t.height,e.top+e.height);i.left=r,i.top=o,i.width=a-r,i.height=s-o},n.prototype.addAndTransformToRef=function(t,e,i,r,o,a){var s=this.left+e,l=this.top+i,u=this.width+r,f=this.height+o;Vl[0].copyFromFloats(s,l),Vl[1].copyFromFloats(s+u,l),Vl[2].copyFromFloats(s+u,l+f),Vl[3].copyFromFloats(s,l+f),ha.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE),Gs.copyFromFloats(0,0);for(var c=0;c<4;c++)t.transformCoordinates(Vl[c].x,Vl[c].y,uf[c]),ha.x=Math.floor(Math.min(ha.x,uf[c].x)),ha.y=Math.floor(Math.min(ha.y,uf[c].y)),Gs.x=Math.ceil(Math.max(Gs.x,uf[c].x)),Gs.y=Math.ceil(Math.max(Gs.y,uf[c].y));a.left=ha.x,a.top=ha.y,a.width=Gs.x-ha.x,a.height=Gs.y-ha.y},n.prototype.transformToRef=function(t,e){this.addAndTransformToRef(t,0,0,0,0,e)},n.prototype.isEqualsTo=function(t){return!(this.left!==t.left||this.top!==t.top||this.width!==t.width||this.height!==t.height)},n.Empty=function(){return new n(0,0,0,0)},n}(),oy=function(n){j(t,n);function t(e,i){i===void 0&&(i=0);var r=n.call(this,e.x,e.y)||this;return r.buttonIndex=i,r}return t}(Ie),ay=function(){function n(t,e,i,r,o,a){this.m=new Float32Array(6),this.fromValues(t,e,i,r,o,a)}return n.prototype.fromValues=function(t,e,i,r,o,a){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=r,this.m[4]=o,this.m[5]=a,this},n.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},n.prototype.invertToRef=function(t){var e=this.m[0],i=this.m[1],r=this.m[2],o=this.m[3],a=this.m[4],s=this.m[5],l=this.determinant();if(l<Zt*Zt)return t.m[0]=0,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[5]=0,this;var u=1/l,f=r*s-o*a,c=i*a-e*s;return t.m[0]=o*u,t.m[1]=-i*u,t.m[2]=-r*u,t.m[3]=e*u,t.m[4]=f*u,t.m[5]=c*u,this},n.prototype.multiplyToRef=function(t,e){var i=this.m[0],r=this.m[1],o=this.m[2],a=this.m[3],s=this.m[4],l=this.m[5],u=t.m[0],f=t.m[1],c=t.m[2],h=t.m[3],p=t.m[4],_=t.m[5];return e.m[0]=i*u+r*c,e.m[1]=i*f+r*h,e.m[2]=o*u+a*c,e.m[3]=o*f+a*h,e.m[4]=s*u+l*c+p,e.m[5]=s*f+l*h+_,this},n.prototype.transformCoordinates=function(t,e,i){return i.x=t*this.m[0]+e*this.m[2]+this.m[4],i.y=t*this.m[1]+e*this.m[3]+this.m[5],this},n.Identity=function(){return new n(1,0,0,1,0,0)},n.TranslationToRef=function(t,e,i){i.fromValues(1,0,0,1,t,e)},n.ScalingToRef=function(t,e,i){i.fromValues(t,0,0,e,0,0)},n.RotationToRef=function(t,e){var i=Math.sin(t),r=Math.cos(t);e.fromValues(r,i,-i,r,0,0)},n.ComposeToRef=function(t,e,i,r,o,a,s){n.TranslationToRef(t,e,n._TempPreTranslationMatrix),n.ScalingToRef(r,o,n._TempScalingMatrix),n.RotationToRef(i,n._TempRotationMatrix),n.TranslationToRef(-t,-e,n._TempPostTranslationMatrix),n._TempPreTranslationMatrix.multiplyToRef(n._TempScalingMatrix,n._TempCompose0),n._TempCompose0.multiplyToRef(n._TempRotationMatrix,n._TempCompose1),a?(n._TempCompose1.multiplyToRef(n._TempPostTranslationMatrix,n._TempCompose2),n._TempCompose2.multiplyToRef(a,s)):n._TempCompose1.multiplyToRef(n._TempPostTranslationMatrix,s)},n._TempPreTranslationMatrix=n.Identity(),n._TempPostTranslationMatrix=n.Identity(),n._TempRotationMatrix=n.Identity(),n._TempScalingMatrix=n.Identity(),n._TempCompose0=n.Identity(),n._TempCompose1=n.Identity(),n._TempCompose2=n.Identity(),n}(),ot=function(){function n(t){this.name=t,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=Jr.Empty(),this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new zt(18,zt.UNITMODE_PIXEL,!1),this._width=new zt(1,zt.UNITMODE_PERCENTAGE,!1),this._height=new zt(1,zt.UNITMODE_PERCENTAGE,!1),this._color="",this._style=null,this._horizontalAlignment=n.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=n.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._wasDirty=!1,this._tempParentMeasure=Jr.Empty(),this._prevCurrentMeasureTransformedIntoGlobalSpace=Jr.Empty(),this._cachedParentMeasure=Jr.Empty(),this._paddingLeft=new zt(0),this._paddingRight=new zt(0),this._paddingTop=new zt(0),this._paddingBottom=new zt(0),this._left=new zt(0),this._top=new zt(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=ay.Identity(),this._invertTransformMatrix=ay.Identity(),this._transformedPosition=Ie.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._isHighlighted=!1,this._fontSet=!1,this._dummyVector2=Ie.Zero(),this._downCount=0,this._enterCount=-1,this._doNotRender=!1,this._downPointerIds={},this._isEnabled=!0,this._disabledColor="#9a9a9a",this._disabledColorItem="#6a6a6a",this._rebuildLayout=!1,this._customData={},this._isClipped=!1,this._automaticSize=!1,this.metadata=null,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this.isFocusInvisible=!1,this.clipChildren=!0,this.clipContent=!0,this.useBitmapCache=!1,this._shadowOffsetX=0,this._shadowOffsetY=0,this._shadowBlur=0,this._shadowColor="black",this.hoverCursor="",this._linkOffsetX=new zt(0),this._linkOffsetY=new zt(0),this.onWheelObservable=new ie,this.onPointerMoveObservable=new ie,this.onPointerOutObservable=new ie,this.onPointerDownObservable=new ie,this.onPointerUpObservable=new ie,this.onPointerClickObservable=new ie,this.onPointerEnterObservable=new ie,this.onDirtyObservable=new ie,this.onBeforeDrawObservable=new ie,this.onAfterDrawObservable=new ie,this.onDisposeObservable=new ie,this.fixedRatio=0,this._fixedRatioMasterIsWidth=!0,this._tmpMeasureA=new Jr(0,0,0,0)}return Object.defineProperty(n.prototype,"shadowOffsetX",{get:function(){return this._shadowOffsetX},set:function(t){this._shadowOffsetX!==t&&(this._shadowOffsetX=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowOffsetY",{get:function(){return this._shadowOffsetY},set:function(t){this._shadowOffsetY!==t&&(this._shadowOffsetY=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowBlur",{get:function(){return this._shadowBlur},set:function(t){this._shadowBlur!==t&&(this._shadowBlur=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(t){this._shadowColor!==t&&(this._shadowColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),n.prototype.getClassName=function(){return this._getTypeName()},Object.defineProperty(n.prototype,"host",{get:function(){return this._host},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontOffset",{get:function(){return this._fontOffset},set:function(t){this._fontOffset=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alphaSet=!0,this._alpha=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isHighlighted",{get:function(){return this._isHighlighted},set:function(t){this._isHighlighted!==t&&(this._isHighlighted=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this._scaleX!==t&&(this._scaleX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this._scaleY!==t&&(this._scaleY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(t){this._transformCenterY!==t&&(this._transformCenterY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(t){this._transformCenterX!==t&&(this._transformCenterX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(t){this._horizontalAlignment!==t&&(this._horizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(t){this._verticalAlignment!==t&&(this._verticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!0,this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"widthInPixels",{get:function(){return this._width.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!0,this.width=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!1,this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"heightInPixels",{get:function(){return this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!1,this.height=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontFamily",{get:function(){return this._fontSet?this._fontFamily:""},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"style",{get:function(){return this._style},set:function(t){var e=this;this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._style=t,this._style&&(this._styleObserver=this._style.onChangedObservable.add(function(){e._markAsDirty(),e._resetFontCache()})),this._markAsDirty(),this._resetFontCache()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_isFontSizeInPercentage",{get:function(){return this._fontSize.isPercentage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontSizeInPixels",{get:function(){var t=this._style?this._style._fontSize:this._fontSize;return t.isPixel?t.getValue(this._host):t.getValueInPixel(this._host,this._tempParentMeasure.height||this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.fontSize=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&(this._markAsDirty(),this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"color",{get:function(){return this._color},set:function(t){this._color!==t&&(this._color=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this.zIndex!==t&&(this._zIndex=t,this.parent&&this.parent._reOrderControl(this))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"notRenderable",{get:function(){return this._doNotRender},set:function(t){this._doNotRender!==t&&(this._doNotRender=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!==t&&(this._isVisible=t,this._markAsDirty(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkedMesh",{get:function(){return this._linkedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(t){this._paddingLeft.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingLeftInPixels",{get:function(){return this._paddingLeft.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingLeft=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(t){this._paddingRight.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingRightInPixels",{get:function(){return this._paddingRight.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingRight=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(t){this._paddingTop.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingTopInPixels",{get:function(){return this._paddingTop.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingTop=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(t){this._paddingBottom.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paddingBottomInPixels",{get:function(){return this._paddingBottom.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingBottom=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(t){this._left.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"leftInPixels",{get:function(){return this._left.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.left=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(t){this._top.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"topInPixels",{get:function(){return this._top.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.top=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(t){this._linkOffsetX.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetXInPixels",{get:function(){return this._linkOffsetX.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.linkOffsetX=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(t){this._linkOffsetY.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linkOffsetYInPixels",{get:function(){return this._linkOffsetY.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.linkOffsetY=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"disabledColor",{get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"disabledColorItem",{get:function(){return this._disabledColorItem},set:function(t){this._disabledColorItem!==t&&(this._disabledColorItem=t,this._markAsDirty())},enumerable:!1,configurable:!0}),n.prototype._getTypeName=function(){return"Control"},n.prototype.getAscendantOfClass=function(t){return this.parent?this.parent.getClassName()===t?this.parent:this.parent.getAscendantOfClass(t):null},n.prototype._resetFontCache=function(){this._fontSet=!0,this._markAsDirty()},n.prototype.isAscendant=function(t){return this.parent?this.parent===t?!0:this.parent.isAscendant(t):!1},n.prototype.getLocalCoordinates=function(t){var e=Ie.Zero();return this.getLocalCoordinatesToRef(t,e),e},n.prototype.getLocalCoordinatesToRef=function(t,e){return e.x=t.x-this._currentMeasure.left,e.y=t.y-this._currentMeasure.top,this},n.prototype.getParentLocalCoordinates=function(t){var e=Ie.Zero();return e.x=t.x-this._cachedParentMeasure.left,e.y=t.y-this._cachedParentMeasure.top,e},n.prototype.moveToVector3=function(t,e){if(!this._host||this.parent!==this._host._rootContainer){Ee.Error("Cannot move a control to a vector3 if the control is not at root level");return}this.horizontalAlignment=n.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=n.VERTICAL_ALIGNMENT_TOP;var i=this._host._getGlobalViewport(e),r=y.Project(t,te.Identity(),e.getTransformMatrix(),i);if(this._moveToProjectedPosition(r),r.z<0||r.z>1){this.notRenderable=!0;return}this.notRenderable=!1},n.prototype.getDescendantsToRef=function(t,e,i){},n.prototype.getDescendants=function(t,e){var i=new Array;return this.getDescendantsToRef(i,t,e),i},n.prototype.linkWithMesh=function(t){if(!this._host||this.parent&&this.parent!==this._host._rootContainer){t&&Ee.Error("Cannot link a control to a mesh if the control is not at root level");return}var e=this._host._linkedControls.indexOf(this);if(e!==-1){this._linkedMesh=t,t||this._host._linkedControls.splice(e,1);return}else if(!t)return;this.horizontalAlignment=n.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=n.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=t,this._host._linkedControls.push(this)},n.prototype._moveToProjectedPosition=function(t){var e=this._left.getValue(this._host),i=this._top.getValue(this._host),r=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,o=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-e)<.5&&(r=e),Math.abs(o-i)<.5&&(o=i)),this.left=r+"px",this.top=o+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},n.prototype._offsetLeft=function(t){this._isDirty=!0,this._currentMeasure.left+=t},n.prototype._offsetTop=function(t){this._isDirty=!0,this._currentMeasure.top+=t},n.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},n.prototype._flagDescendantsAsMatrixDirty=function(){},n.prototype._intersectsRect=function(t){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=t.left+t.width||this._tmpMeasureA.top>=t.top+t.height||this._tmpMeasureA.left+this._tmpMeasureA.width<=t.left||this._tmpMeasureA.top+this._tmpMeasureA.height<=t.top)},n.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),Jr.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var t=this.shadowOffsetX,e=this.shadowOffsetY,i=this.shadowBlur,r=Math.min(Math.min(t,0)-i*2,0),o=Math.max(Math.max(t,0)+i*2,0),a=Math.min(Math.min(e,0)-i*2,0),s=Math.max(Math.max(e,0)+i*2,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+r),Math.floor(this._tmpMeasureA.top+a),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+o),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+s))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},n.prototype._markAsDirty=function(t){t===void 0&&(t=!1),!(!this._isVisible&&!t)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},n.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},n.prototype._link=function(t){this._host=t,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},n.prototype._transform=function(t){if(!(!this._isMatrixDirty&&this._scaleX===1&&this._scaleY===1&&this._rotation===0)){var e=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t&&(t.translate(e,i),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-e,-i)),(this._isMatrixDirty||this._cachedOffsetX!==e||this._cachedOffsetY!==i)&&(this._cachedOffsetX=e,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),ay.ComposeToRef(-e,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},n.prototype._renderHighlight=function(t){this.isHighlighted&&(t.save(),t.strokeStyle="#4affff",t.lineWidth=2,this._renderHighlightSpecific(t),t.restore())},n.prototype._renderHighlightSpecific=function(t){t.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},n.prototype._applyStates=function(t){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),n.AllowAlphaInheritance?t.globalAlpha*=this._alpha:this._alphaSet&&(t.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},n.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(t)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,-this.paddingLeftInPixels|0,-this.paddingTopInPixels|0,this.paddingRightInPixels|0,this.paddingBottomInPixels|0,this._prevCurrentMeasureTransformedIntoGlobalSpace),e.save(),this._applyStates(e);var i=0;do this._rebuildLayout=!1,this._processMeasures(t,e),i++;while(this._rebuildLayout&&i<3);i>=3&&de.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this.invalidateRect(),this._evaluateClippingState(t)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},n.prototype._processMeasures=function(t,e){this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=this._currentMeasure.left|0,this._currentMeasure.top=this._currentMeasure.top|0,this._currentMeasure.width=this._currentMeasure.width|0,this._currentMeasure.height=this._currentMeasure.height|0,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},n.prototype._evaluateClippingState=function(t){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>t.left+t.width){this._isClipped=!0;return}if(this._currentMeasure.left+this._currentMeasure.width<t.left){this._isClipped=!0;return}if(this._currentMeasure.top>t.top+t.height){this._isClipped=!0;return}if(this._currentMeasure.top+this._currentMeasure.height<t.top){this._isClipped=!0;return}}this._isClipped=!1},n.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host),this.fixedRatio!==0&&(this._fixedRatioMasterIsWidth?this._currentMeasure.height=this._currentMeasure.width*this.fixedRatio:this._currentMeasure.width=this._currentMeasure.height*this.fixedRatio)},n.prototype._computeAlignment=function(t,e){var i=this._currentMeasure.width,r=this._currentMeasure.height,o=t.width,a=t.height,s=0,l=0;switch(this.horizontalAlignment){case n.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case n.HORIZONTAL_ALIGNMENT_RIGHT:s=o-i;break;case n.HORIZONTAL_ALIGNMENT_CENTER:s=(o-i)/2;break}switch(this.verticalAlignment){case n.VERTICAL_ALIGNMENT_TOP:l=0;break;case n.VERTICAL_ALIGNMENT_BOTTOM:l=a-r;break;case n.VERTICAL_ALIGNMENT_CENTER:l=(a-r)/2;break}this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=o*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=o*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=o*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=a*this._paddingTop.getValue(this._host),this._currentMeasure.height-=a*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=a*this._paddingBottom.getValue(this._host),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=o*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=a*this._top.getValue(this._host),this._currentMeasure.left+=s,this._currentMeasure.top+=l},n.prototype._preMeasure=function(t,e){},n.prototype._additionalProcessing=function(t,e){},n.prototype._clipForChildren=function(t){},n.prototype._clip=function(t,e){if(t.beginPath(),n._ClipMeasure.copyFrom(this._currentMeasure),e){e.transformToRef(this._invertTransformMatrix,this._tmpMeasureA);var i=new Jr(0,0,0,0);i.left=Math.max(this._tmpMeasureA.left,this._currentMeasure.left),i.top=Math.max(this._tmpMeasureA.top,this._currentMeasure.top),i.width=Math.min(this._tmpMeasureA.left+this._tmpMeasureA.width,this._currentMeasure.left+this._currentMeasure.width)-i.left,i.height=Math.min(this._tmpMeasureA.top+this._tmpMeasureA.height,this._currentMeasure.top+this._currentMeasure.height)-i.top,n._ClipMeasure.copyFrom(i)}if(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var r=this.shadowOffsetX,o=this.shadowOffsetY,a=this.shadowBlur,s=Math.min(Math.min(r,0)-a*2,0),l=Math.max(Math.max(r,0)+a*2,0),u=Math.min(Math.min(o,0)-a*2,0),f=Math.max(Math.max(o,0)+a*2,0);t.rect(n._ClipMeasure.left+s,n._ClipMeasure.top+u,n._ClipMeasure.width+l-s,n._ClipMeasure.height+f-u)}else t.rect(n._ClipMeasure.left,n._ClipMeasure.top,n._ClipMeasure.width,n._ClipMeasure.height);t.clip()},n.prototype._render=function(t,e){return!this.isVisible||this.notRenderable||this._isClipped?(this._isDirty=!1,!1):(this.host._numRenderCalls++,t.save(),this._applyStates(t),this._transform(t),this.clipContent&&this._clip(t,e),this.onBeforeDrawObservable.hasObservers()&&this.onBeforeDrawObservable.notifyObservers(this),this.useBitmapCache&&!this._wasDirty&&this._cacheData?t.putImageData(this._cacheData,this._currentMeasure.left,this._currentMeasure.top):this._draw(t,e),this.useBitmapCache&&this._wasDirty&&(this._cacheData=t.getImageData(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._renderHighlight(t),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this),t.restore(),!0)},n.prototype._draw=function(t,e){},n.prototype.contains=function(t,e){return this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y,t<this._currentMeasure.left||t>this._currentMeasure.left+this._currentMeasure.width||e<this._currentMeasure.top||e>this._currentMeasure.top+this._currentMeasure.height?!1:(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0)},n.prototype._processPicking=function(t,e,i,r,o,a,s,l){return!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this._doNotRender||!this.contains(t,e)?!1:(this._processObservables(r,t,e,i,o,a,s,l),!0)},n.prototype._onPointerMove=function(t,e,i,r){var o=this.onPointerMoveObservable.notifyObservers(e,-1,t,this,r);o&&this.parent!=null&&this.parent._onPointerMove(t,e,i,r)},n.prototype._onPointerEnter=function(t,e){if(!this._isEnabled||this._enterCount>0)return!1;this._enterCount===-1&&(this._enterCount=0),this._enterCount++;var i=this.onPointerEnterObservable.notifyObservers(this,-1,t,this,e);return i&&this.parent!=null&&this.parent._onPointerEnter(t,e),!0},n.prototype._onPointerOut=function(t,e,i){if(i===void 0&&(i=!1),!(!i&&(!this._isEnabled||t===this))){this._enterCount=0;var r=!0;t.isAscendant(this)||(r=this.onPointerOutObservable.notifyObservers(this,-1,t,this,e)),r&&this.parent!=null&&this.parent._onPointerOut(t,e,i)}},n.prototype._onPointerDown=function(t,e,i,r,o){if(this._onPointerEnter(this,o),this._downCount!==0)return!1;this._downCount++,this._downPointerIds[i]=!0;var a=this.onPointerDownObservable.notifyObservers(new oy(e,r),-1,t,this,o);return a&&this.parent!=null&&this.parent._onPointerDown(t,e,i,r,o),!0},n.prototype._onPointerUp=function(t,e,i,r,o,a){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var s=o;o&&(this._enterCount>0||this._enterCount===-1)&&(s=this.onPointerClickObservable.notifyObservers(new oy(e,r),-1,t,this,a));var l=this.onPointerUpObservable.notifyObservers(new oy(e,r),-1,t,this,a);l&&this.parent!=null&&this.parent._onPointerUp(t,e,i,r,s,a)}},n.prototype._forcePointerUp=function(t){if(t===void 0&&(t=null),t!==null)this._onPointerUp(this,Ie.Zero(),t,0,!0);else for(var e in this._downPointerIds)this._onPointerUp(this,Ie.Zero(),+e,0,!0)},n.prototype._onWheelScroll=function(t,e){if(this._isEnabled){var i=this.onWheelObservable.notifyObservers(new Ie(t,e));i&&this.parent!=null&&this.parent._onWheelScroll(t,e)}},n.prototype._onCanvasBlur=function(){},n.prototype._processObservables=function(t,e,i,r,o,a,s,l){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(e,i),t===He.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,o,r);var u=this._host._lastControlOver[o];return u&&u!==this&&u._onPointerOut(this,r),u!==this&&this._onPointerEnter(this,r),this._host._lastControlOver[o]=this,!0}return t===He.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,o,a,r),this._host._registerLastControlDown(this,o),this._host._lastPickedControl=this,!0):t===He.POINTERUP?(this._host._lastControlDown[o]&&this._host._lastControlDown[o]._onPointerUp(this,this._dummyVector2,o,a,!0,r),delete this._host._lastControlDown[o],!0):t===He.POINTERWHEEL&&this._host._lastControlOver[o]?(this._host._lastControlOver[o]._onWheelScroll(s,l),!0):!1},n.prototype._prepareFont=function(){!this._font&&!this._fontSet||(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=n._GetFontOffset(this._font))},n.prototype.dispose=function(){if(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host){var t=this._host._linkedControls.indexOf(this);t>-1&&this.linkWithMesh(null)}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return n._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return n._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(n,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return n._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_TOP",{get:function(){return n._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return n._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(n,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return n._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),n._GetFontOffset=function(t){if(n._FontHeightSizes[t])return n._FontHeightSizes[t];var e=document.createElement("span");e.innerHTML="Hg",e.style.font=t;var i=document.createElement("div");i.style.display="inline-block",i.style.width="1px",i.style.height="0px",i.style.verticalAlign="bottom";var r=document.createElement("div");r.style.whiteSpace="nowrap",r.appendChild(e),r.appendChild(i),document.body.appendChild(r);var o=0,a=0;try{a=i.getBoundingClientRect().top-e.getBoundingClientRect().top,i.style.verticalAlign="baseline",o=i.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(r)}var s={ascent:o,height:a,descent:a-o};return n._FontHeightSizes[t]=s,s},n.drawEllipse=function(t,e,i,r,o){o.translate(t,e),o.scale(i,r),o.beginPath(),o.arc(0,0,1,0,2*Math.PI),o.closePath(),o.scale(1/i,1/r),o.translate(-t,-e)},n.AllowAlphaInheritance=!1,n._ClipMeasure=new Jr(0,0,0,0),n._HORIZONTAL_ALIGNMENT_LEFT=0,n._HORIZONTAL_ALIGNMENT_RIGHT=1,n._HORIZONTAL_ALIGNMENT_CENTER=2,n._VERTICAL_ALIGNMENT_TOP=0,n._VERTICAL_ALIGNMENT_BOTTOM=1,n._VERTICAL_ALIGNMENT_CENTER=2,n._FontHeightSizes={},n.AddHeader=function(){},n}();Ae.RegisteredTypes["BABYLON.GUI.Control"]=ot;var so=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._children=new Array,i._measureForChildren=Jr.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return Object.defineProperty(t.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(e){this._adaptHeightToChildren!==e&&(this._adaptHeightToChildren=e,e&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(e){this._adaptWidthToChildren!==e&&(this._adaptWidthToChildren=e,e&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Container"},t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,i=this.children;e<i.length;e++){var r=i[e];r._markMatrixAsDirty()}},t.prototype.getChildByName=function(e){for(var i=0,r=this.children;i<r.length;i++){var o=r[i];if(o.name===e)return o}return null},t.prototype.getChildByType=function(e,i){for(var r=0,o=this.children;r<o.length;r++){var a=o[r];if(a.typeName===i)return a}return null},t.prototype.containsControl=function(e){return this.children.indexOf(e)!==-1},t.prototype.addControl=function(e){if(!e)return this;var i=this._children.indexOf(e);return i!==-1?this:(e._link(this._host),e._markAllAsDirty(),this._reOrderControl(e),this._markAsDirty(),this)},t.prototype.clearControls=function(){for(var e=this.children.slice(),i=0,r=e;i<r.length;i++){var o=r[i];this.removeControl(o)}return this},t.prototype.removeControl=function(e){var i=this._children.indexOf(e);return i!==-1&&(this._children.splice(i,1),e.parent=null),e.linkWithMesh(null),this._host&&this._host._cleanControlAfterRemoval(e),this._markAsDirty(),this},t.prototype._reOrderControl=function(e){this.removeControl(e);for(var i=!1,r=0;r<this._children.length;r++)if(this._children[r].zIndex>e.zIndex){this._children.splice(r,0,e),i=!0;break}i||this._children.push(e),e.parent=this,this._markAsDirty()},t.prototype._offsetLeft=function(e){n.prototype._offsetLeft.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._offsetLeft(e)}},t.prototype._offsetTop=function(e){n.prototype._offsetTop.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._offsetTop(e)}},t.prototype._markAllAsDirty=function(){n.prototype._markAllAsDirty.call(this);for(var e=0;e<this._children.length;e++)this._children[e]._markAllAsDirty()},t.prototype._localDraw=function(e){this._background&&(e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),e.restore())},t.prototype._link=function(e){n.prototype._link.call(this,e);for(var i=0,r=this._children;i<r.length;i++){var o=r[i];o._link(e)}},t.prototype._beforeLayout=function(){},t.prototype._processMeasures=function(e,i){(this._isDirty||!this._cachedParentMeasure.isEqualsTo(e))&&(n.prototype._processMeasures.call(this,e,i),this._evaluateClippingState(e))},t.prototype._layout=function(e,i){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;this.host._numLayoutCalls++,this._isDirty&&this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace);var r=0;i.save(),this._applyStates(i),this._beforeLayout();do{var o=-1,a=-1;if(this._rebuildLayout=!1,this._processMeasures(e,i),!this._isClipped){for(var s=0,l=this._children;s<l.length;s++){var u=l[s];u._tempParentMeasure.copyFrom(this._measureForChildren),u._layout(this._measureForChildren,i)&&(this.adaptWidthToChildren&&u._width.isPixel&&(o=Math.max(o,u._currentMeasure.width+u.paddingLeftInPixels+u.paddingRightInPixels)),this.adaptHeightToChildren&&u._height.isPixel&&(a=Math.max(a,u._currentMeasure.height+u.paddingTopInPixels+u.paddingBottomInPixels)))}this.adaptWidthToChildren&&o>=0&&(o+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==o+"px"&&(this.width=o+"px",this._rebuildLayout=!0)),this.adaptHeightToChildren&&a>=0&&(a+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==a+"px"&&(this.height=a+"px",this._rebuildLayout=!0)),this._postMeasure()}r++}while(this._rebuildLayout&&r<this.maxLayoutCycle);return r>=3&&this.logLayoutCycleErrors&&de.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),i.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},t.prototype._postMeasure=function(){},t.prototype._draw=function(e,i){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);for(var r=0,o=this._children;r<o.length;r++){var a=o[r];i&&!a._intersectsRect(i)||a._render(e,i)}},t.prototype.getDescendantsToRef=function(e,i,r){if(i===void 0&&(i=!1),!!this.children)for(var o=0;o<this.children.length;o++){var a=this.children[o];(!r||r(a))&&e.push(a),i||a.getDescendantsToRef(e,!1,r)}},t.prototype._processPicking=function(e,i,r,o,a,s,l,u){if(!this._isEnabled||!this.isVisible||this.notRenderable||!n.prototype.contains.call(this,e,i))return!1;for(var f=this._children.length-1;f>=0;f--){var c=this._children[f];if(c._processPicking(e,i,r,o,a,s,l,u))return c.hoverCursor&&this._host._changeCursor(c.hoverCursor),!0}return this.isHitTestVisible?this._processObservables(o,e,i,r,a,s,l,u):!1},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(this._currentMeasure)},t.prototype.dispose=function(){n.prototype.dispose.call(this);for(var e=this.children.length-1;e>=0;e--)this.children[e].dispose()},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.Container"]=so;var lo=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(e){e<0&&(e=0),this._cornerRadius!==e&&(this._cornerRadius=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Rectangle"},t.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._background&&(e.fillStyle=this._background,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.fill()):e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.stroke()):e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),e.restore()},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},t.prototype._drawRoundedRect=function(e,i){i===void 0&&(i=0);var r=this._currentMeasure.left+i,o=this._currentMeasure.top+i,a=this._currentMeasure.width-i*2,s=this._currentMeasure.height-i*2,l=Math.min(s/2-2,Math.min(a/2-2,this._cornerRadius));e.beginPath(),e.moveTo(r+l,o),e.lineTo(r+a-l,o),e.quadraticCurveTo(r+a,o,r+a,o+l),e.lineTo(r+a,o+s-l),e.quadraticCurveTo(r+a,o+s,r+a-l,o+s),e.lineTo(r+l,o+s),e.quadraticCurveTo(r,o+s,r,o+s-l),e.lineTo(r,o+l),e.quadraticCurveTo(r,o,r+l,o),e.closePath()},t.prototype._clipForChildren=function(e){this._cornerRadius&&(this._drawRoundedRect(e,this._thickness),e.clip())},t}(so);Ae.RegisteredTypes["BABYLON.GUI.Rectangle"]=lo;var $l;(function(n){n[n.Clip=0]="Clip",n[n.WordWrap=1]="WordWrap",n[n.Ellipsis=2]="Ellipsis"})($l||($l={}));var Mn=function(n){j(t,n);function t(e,i){i===void 0&&(i="");var r=n.call(this,e)||this;return r.name=e,r._text="",r._textWrapping=$l.Clip,r._textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,r._textVerticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,r._resizeToFit=!1,r._lineSpacing=new zt(0),r._outlineWidth=0,r._outlineColor="white",r._underline=!1,r._lineThrough=!1,r.onTextChangedObservable=new ie,r.onLinesReadyObservable=new ie,r.text=i,r}return Object.defineProperty(t.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(e){this._resizeToFit!==e&&(this._resizeToFit=e,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(e){this._textWrapping!==e&&(this._textWrapping=+e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"text",{get:function(){return this._text},set:function(e){this._text!==e&&(this._text=e,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(e){this._textHorizontalAlignment!==e&&(this._textHorizontalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(e){this._textVerticalAlignment!==e&&(this._textVerticalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(e){this._lineSpacing.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(e){this._outlineWidth!==e&&(this._outlineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"underline",{get:function(){return this._underline},set:function(e){this._underline!==e&&(this._underline=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(e){this._lineThrough!==e&&(this._lineThrough=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(e){this._outlineColor!==e&&(this._outlineColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"TextBlock"},t.prototype._processMeasures=function(e,i){this._fontOffset||(this._fontOffset=ot._GetFontOffset(i.font)),n.prototype._processMeasures.call(this,e,i),this._lines=this._breakLines(this._currentMeasure.width,i),this.onLinesReadyObservable.notifyObservers(this);for(var r=0,o=0;o<this._lines.length;o++){var a=this._lines[o];a.width>r&&(r=a.width)}if(this._resizeToFit){if(this._textWrapping===$l.Clip){var s=this.paddingLeftInPixels+this.paddingRightInPixels+r|0;s!==this._width.internalValue&&(this._width.updateInPlace(s,zt.UNITMODE_PIXEL),this._rebuildLayout=!0)}var l=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&this._lineSpacing.internalValue!==0){var u=0;this._lineSpacing.isPixel?u=this._lineSpacing.getValue(this._host):u=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),l+=(this._lines.length-1)*u}l!==this._height.internalValue&&(this._height.updateInPlace(l,zt.UNITMODE_PIXEL),this._rebuildLayout=!0)}},t.prototype._drawText=function(e,i,r,o){var a=this._currentMeasure.width,s=0;switch(this._textHorizontalAlignment){case ot.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case ot.HORIZONTAL_ALIGNMENT_RIGHT:s=a-i;break;case ot.HORIZONTAL_ALIGNMENT_CENTER:s=(a-i)/2;break}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(o.shadowColor=this.shadowColor,o.shadowBlur=this.shadowBlur,o.shadowOffsetX=this.shadowOffsetX,o.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&o.strokeText(e,this._currentMeasure.left+s,r),o.fillText(e,this._currentMeasure.left+s,r),this._underline&&(o.beginPath(),o.lineWidth=Math.round(this.fontSizeInPixels*.05),o.moveTo(this._currentMeasure.left+s,r+3),o.lineTo(this._currentMeasure.left+s+i,r+3),o.stroke(),o.closePath()),this._lineThrough&&(o.beginPath(),o.lineWidth=Math.round(this.fontSizeInPixels*.05),o.moveTo(this._currentMeasure.left+s,r-this.fontSizeInPixels/3),o.lineTo(this._currentMeasure.left+s+i,r-this.fontSizeInPixels/3),o.stroke(),o.closePath())},t.prototype._draw=function(e,i){e.save(),this._applyStates(e),this._renderLines(e),e.restore()},t.prototype._applyStates=function(e){n.prototype._applyStates.call(this,e),this.outlineWidth&&(e.lineWidth=this.outlineWidth,e.strokeStyle=this.outlineColor,e.lineJoin="miter",e.miterLimit=2)},t.prototype._breakLines=function(e,i){var r=[],o=this.text.split(`
13297
13297
  `);if(this._textWrapping===$l.Ellipsis)for(var a=0,s=o;a<s.length;a++){var l=s[a];r.push(this._parseLineEllipsis(l,e,i))}else if(this._textWrapping===$l.WordWrap)for(var u=0,f=o;u<f.length;u++){var l=f[u];r.push.apply(r,this._parseLineWordWrap(l,e,i))}else for(var c=0,h=o;c<h.length;c++){var l=h[c];r.push(this._parseLine(l,i))}return r},t.prototype._parseLine=function(e,i){return e===void 0&&(e=""),{text:e,width:i.measureText(e).width}},t.prototype._parseLineEllipsis=function(e,i,r){e===void 0&&(e="");var o=r.measureText(e).width;o>i&&(e+="…");var a=Array.from&&Array.from(e);if(a)for(;a.length&&o>i;)a.pop(),e=a.join("")+"...",o=r.measureText(e).width;else for(;e.length>2&&o>i;)e=e.slice(0,-2)+"…",o=r.measureText(e).width;return{text:e,width:o}},t.prototype._parseLineWordWrap=function(e,i,r){e===void 0&&(e="");for(var o=[],a=this.wordSplittingFunction?this.wordSplittingFunction(e):e.split(" "),s=0,l=0;l<a.length;l++){var u=l>0?e+" "+a[l]:a[0],f=r.measureText(u),c=f.width;c>i&&l>0?(o.push({text:e,width:s}),e=a[l],s=r.measureText(e).width):(s=c,e=u)}return o.push({text:e,width:s}),o},t.prototype._renderLines=function(e){var i=this._currentMeasure.height,r=0;switch(this._textVerticalAlignment){case ot.VERTICAL_ALIGNMENT_TOP:r=this._fontOffset.ascent;break;case ot.VERTICAL_ALIGNMENT_BOTTOM:r=i-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case ot.VERTICAL_ALIGNMENT_CENTER:r=this._fontOffset.ascent+(i-this._fontOffset.height*this._lines.length)/2;break}r+=this._currentMeasure.top;for(var o=0;o<this._lines.length;o++){var a=this._lines[o];o!==0&&this._lineSpacing.internalValue!==0&&(this._lineSpacing.isPixel?r+=this._lineSpacing.getValue(this._host):r=r+this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)),this._drawText(a.text,a.width,r,e),r+=this._fontOffset.height}},t.prototype.computeExpectedHeight=function(){if(this.text&&this.widthInPixels){var e=document.createElement("canvas").getContext("2d");if(e){this._applyStates(e),this._fontOffset||(this._fontOffset=ot._GetFontOffset(e.font));var i=this._lines?this._lines:this._breakLines(this.widthInPixels-this.paddingLeftInPixels-this.paddingRightInPixels,e),r=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*i.length;if(i.length>0&&this._lineSpacing.internalValue!==0){var o=0;this._lineSpacing.isPixel?o=this._lineSpacing.getValue(this._host):o=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),r+=(i.length-1)*o}return r}}return 0},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onTextChangedObservable.clear()},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.TextBlock"]=Mn;var Za=function(n){j(t,n);function t(e,i){i===void 0&&(i=null);var r=n.call(this,e)||this;return r.name=e,r._workingCanvas=null,r._loaded=!1,r._stretch=t.STRETCH_FILL,r._autoScale=!1,r._sourceLeft=0,r._sourceTop=0,r._sourceWidth=0,r._sourceHeight=0,r._svgAttributesComputationCompleted=!1,r._isSVG=!1,r._cellWidth=0,r._cellHeight=0,r._cellId=-1,r._populateNinePatchSlicesFromImage=!1,r._imageDataCache={data:null,key:""},r.onImageLoadedObservable=new ie,r.onSVGAttributesComputedObservable=new ie,r.source=i,r}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(e){this._populateNinePatchSlicesFromImage!==e&&(this._populateNinePatchSlicesFromImage=e,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(e){this._detectPointerOnOpaqueOnly!==e&&(this._detectPointerOnOpaqueOnly=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(e){this._sliceLeft!==e&&(this._sliceLeft=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(e){this._sliceRight!==e&&(this._sliceRight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(e){this._sliceTop!==e&&(this._sliceTop=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(e){this._sliceBottom!==e&&(this._sliceBottom=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(e){this._sourceLeft!==e&&(this._sourceLeft=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(e){this._sourceTop!==e&&(this._sourceTop=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(e){this._sourceWidth!==e&&(this._sourceWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(e){this._sourceHeight!==e&&(this._sourceHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSVG",{get:function(){return this._isSVG},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"svgAttributesComputationCompleted",{get:function(){return this._svgAttributesComputationCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoScale",{get:function(){return this._autoScale},set:function(e){this._autoScale!==e&&(this._autoScale=e,e&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stretch",{get:function(){return this._stretch},set:function(e){this._stretch!==e&&(this._stretch=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._rotate90=function(e,i){i===void 0&&(i=!1);var r=document.createElement("canvas"),o=r.getContext("2d"),a=this._domImage.width,s=this._domImage.height;r.width=s,r.height=a,o.translate(r.width/2,r.height/2),o.rotate(e*Math.PI/2),o.drawImage(this._domImage,0,0,a,s,-a/2,-s/2,a,s);var l=r.toDataURL("image/jpg"),u=new t(this.name+"rotated",l);return i&&(u._stretch=this._stretch,u._autoScale=this._autoScale,u._cellId=this._cellId,u._cellWidth=e%1?this._cellHeight:this._cellWidth,u._cellHeight=e%1?this._cellWidth:this._cellHeight),this._handleRotationForSVGImage(this,u,e),this._imageDataCache.data=null,u},t.prototype._handleRotationForSVGImage=function(e,i,r){var o=this;e._isSVG&&(e._svgAttributesComputationCompleted?(this._rotate90SourceProperties(e,i,r),this._markAsDirty()):e.onSVGAttributesComputedObservable.addOnce(function(){o._rotate90SourceProperties(e,i,r),o._markAsDirty()}))},t.prototype._rotate90SourceProperties=function(e,i,r){var o,a,s=e.sourceLeft,l=e.sourceTop,u=e.domImage.width,f=e.domImage.height,c=s,h=l,p=e.sourceWidth,_=e.sourceHeight;if(r!=0){var g=r<0?-1:1;r=r%4;for(var v=0;v<Math.abs(r);++v)c=-(l-f/2)*g+f/2,h=(s-u/2)*g+u/2,o=[_,p],p=o[0],_=o[1],r<0?h-=_:c-=p,s=c,l=h,a=[f,u],u=a[0],f=a[1]}i.sourceLeft=c,i.sourceTop=h,i.sourceWidth=p,i.sourceHeight=_},Object.defineProperty(t.prototype,"domImage",{get:function(){return this._domImage},set:function(e){var i=this;this._domImage=e,this._loaded=!1,this._imageDataCache.data=null,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){i._onImageLoaded()}},enumerable:!1,configurable:!0}),t.prototype._onImageLoaded=function(){this._imageDataCache.data=null,this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._populateNinePatchSlicesFromImage&&this._extractNinePatchSliceDataFromImage(),this._autoScale&&this.synchronizeSizeWithContent(),this.onImageLoadedObservable.notifyObservers(this),this._markAsDirty()},t.prototype._extractNinePatchSliceDataFromImage=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var e=this._workingCanvas,i=e.getContext("2d"),r=this._domImage.width,o=this._domImage.height;e.width=r,e.height=o,i.drawImage(this._domImage,0,0,r,o);var a=i.getImageData(0,0,r,o);this._sliceLeft=-1,this._sliceRight=-1;for(var s=0;s<r;s++){var l=a.data[s*4+3];if(l>127&&this._sliceLeft===-1){this._sliceLeft=s;continue}if(l<127&&this._sliceLeft>-1){this._sliceRight=s;break}}this._sliceTop=-1,this._sliceBottom=-1;for(var u=0;u<o;u++){var l=a.data[u*r*4+3];if(l>127&&this._sliceTop===-1){this._sliceTop=u;continue}if(l<127&&this._sliceTop>-1){this._sliceBottom=u;break}}},Object.defineProperty(t.prototype,"source",{set:function(e){var i=this;this._source!==e&&(this._loaded=!1,this._source=e,this._imageDataCache.data=null,e&&(e=this._svgCheck(e)),this._domImage=document.createElement("img"),this._domImage.onload=function(){i._onImageLoaded()},e&&(Ee.SetCorsBehavior(e,this._domImage),this._domImage.src=e))},enumerable:!1,configurable:!0}),t.prototype._svgCheck=function(e){var i=this;if(window.SVGSVGElement&&e.search(/.svg#/gi)!==-1&&e.indexOf("#")===e.lastIndexOf("#")){this._isSVG=!0;var r=e.split("#")[0],o=e.split("#")[1],a=document.body.querySelector('object[data="'+r+'"]');if(a){var s=a.contentDocument;if(s&&s.documentElement){var l=s.documentElement.getAttribute("viewBox"),u=Number(s.documentElement.getAttribute("width")),f=Number(s.documentElement.getAttribute("height")),c=s.getElementById(o);if(c&&l&&u&&f)return this._getSVGAttribs(a,o),e}a.addEventListener("load",function(){i._getSVGAttribs(a,o)})}else{var h=document.createElement("object");h.data=r,h.type="image/svg+xml",h.width="0%",h.height="0%",document.body.appendChild(h),h.onload=function(){var p=document.body.querySelector('object[data="'+r+'"]');p&&i._getSVGAttribs(p,o)}}return r}else return e},t.prototype._getSVGAttribs=function(e,i){var r=e.contentDocument;if(r&&r.documentElement){var o=r.documentElement.getAttribute("viewBox"),a=Number(r.documentElement.getAttribute("width")),s=Number(r.documentElement.getAttribute("height")),l=r.getElementById(i);if(o&&a&&s&&l){var u=Number(o.split(" ")[2]),f=Number(o.split(" ")[3]),c=l.getBBox(),h=1,p=1,_=0,g=0;l.transform&&l.transform.baseVal.consolidate()&&(h=l.transform.baseVal.consolidate().matrix.a,p=l.transform.baseVal.consolidate().matrix.d,_=l.transform.baseVal.consolidate().matrix.e,g=l.transform.baseVal.consolidate().matrix.f),this.sourceLeft=(h*c.x+_)*a/u,this.sourceTop=(p*c.y+g)*s/f,this.sourceWidth=c.width*h*(a/u),this.sourceHeight=c.height*p*(s/f),this._svgAttributesComputationCompleted=!0,this.onSVGAttributesComputedObservable.notifyObservers(this)}}},Object.defineProperty(t.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth!==e&&(this._cellWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight!==e&&(this._cellHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cellId",{get:function(){return this._cellId},set:function(e){this._cellId!==e&&(this._cellId=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype.contains=function(e,i){if(!n.prototype.contains.call(this,e,i))return!1;if(!this._detectPointerOnOpaqueOnly||!this._workingCanvas)return!0;var r=this._currentMeasure.width|0,o=this._currentMeasure.height|0,a=r+"_"+o,s=this._imageDataCache.data;if(!s||this._imageDataCache.key!==a){var l=this._workingCanvas,u=l.getContext("2d");this._imageDataCache.data=s=u.getImageData(0,0,r,o).data,this._imageDataCache.key=a}e=e-this._currentMeasure.left|0,i=i-this._currentMeasure.top|0;var f=s[(e+i*r)*4+3];return f>0},t.prototype._getTypeName=function(){return"Image"},t.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},t.prototype._processMeasures=function(e,i){if(this._loaded)switch(this._stretch){case t.STRETCH_NONE:break;case t.STRETCH_FILL:break;case t.STRETCH_UNIFORM:break;case t.STRETCH_NINE_PATCH:break;case t.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0);break}n.prototype._processMeasures.call(this,e,i)},t.prototype._prepareWorkingCanvasForOpaqueDetection=function(){if(this._detectPointerOnOpaqueOnly){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var e=this._workingCanvas,i=this._currentMeasure.width,r=this._currentMeasure.height,o=e.getContext("2d");e.width=i,e.height=r,o.clearRect(0,0,i,r)}},t.prototype._drawImage=function(e,i,r,o,a,s,l,u,f){if(e.drawImage(this._domImage,i,r,o,a,s,l,u,f),!!this._detectPointerOnOpaqueOnly){var c=this._workingCanvas;e=c.getContext("2d"),e.drawImage(this._domImage,i,r,o,a,s-this._currentMeasure.left,l-this._currentMeasure.top,u,f)}},t.prototype._draw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY);var i,r,o,a;if(this.cellId==-1)i=this._sourceLeft,r=this._sourceTop,o=this._sourceWidth?this._sourceWidth:this._imageWidth,a=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var s=this._domImage.naturalWidth/this.cellWidth,l=this.cellId/s>>0,u=this.cellId%s;i=this.cellWidth*u,r=this.cellHeight*l,o=this.cellWidth,a=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(e),this._loaded)switch(this._stretch){case t.STRETCH_NONE:this._drawImage(e,i,r,o,a,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case t.STRETCH_FILL:this._drawImage(e,i,r,o,a,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case t.STRETCH_UNIFORM:var f=this._currentMeasure.width/o,c=this._currentMeasure.height/a,h=Math.min(f,c),p=(this._currentMeasure.width-o*h)/2,_=(this._currentMeasure.height-a*h)/2;this._drawImage(e,i,r,o,a,this._currentMeasure.left+p,this._currentMeasure.top+_,o*h,a*h);break;case t.STRETCH_EXTEND:this._drawImage(e,i,r,o,a,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case t.STRETCH_NINE_PATCH:this._renderNinePatch(e);break}e.restore()},t.prototype._renderCornerPatch=function(e,i,r,o,a,s,l){this._drawImage(e,i,r,o,a,this._currentMeasure.left+s,this._currentMeasure.top+l,o,a)},t.prototype._renderNinePatch=function(e){var i=this._imageHeight,r=this._sliceLeft,o=this._sliceTop,a=this._imageHeight-this._sliceBottom,s=this._imageWidth-this._sliceRight,l=0,u=0;this._populateNinePatchSlicesFromImage&&(l=1,u=1,i-=2,r-=1,o-=1,a-=1,s-=1);var f=this._sliceRight-this._sliceLeft,c=this._currentMeasure.width-s-this.sliceLeft,h=this._currentMeasure.height-i+this._sliceBottom;this._renderCornerPatch(e,l,u,r,o,0,0),this._renderCornerPatch(e,l,this._sliceBottom,r,i-this._sliceBottom,0,h),this._renderCornerPatch(e,this._sliceRight,u,s,o,this._currentMeasure.width-s,0),this._renderCornerPatch(e,this._sliceRight,this._sliceBottom,s,i-this._sliceBottom,this._currentMeasure.width-s,h),this._drawImage(e,this._sliceLeft,this._sliceTop,f,this._sliceBottom-this._sliceTop,this._currentMeasure.left+r,this._currentMeasure.top+o,c,h-o),this._drawImage(e,l,this._sliceTop,r,this._sliceBottom-this._sliceTop,this._currentMeasure.left,this._currentMeasure.top+o,r,h-o),this._drawImage(e,this._sliceRight,this._sliceTop,r,this._sliceBottom-this._sliceTop,this._currentMeasure.left+this._currentMeasure.width-s,this._currentMeasure.top+o,r,h-o),this._drawImage(e,this._sliceLeft,u,f,o,this._currentMeasure.left+r,this._currentMeasure.top,c,o),this._drawImage(e,this._sliceLeft,this._sliceBottom,f,a,this._currentMeasure.left+r,this._currentMeasure.top+h,c,a)},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onImageLoadedObservable.clear(),this.onSVGAttributesComputedObservable.clear()},t.STRETCH_NONE=0,t.STRETCH_FILL=1,t.STRETCH_UNIFORM=2,t.STRETCH_EXTEND=3,t.STRETCH_NINE_PATCH=4,t}(ot);Ae.RegisteredTypes["BABYLON.GUI.Image"]=Za;var _a=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;i.name=e,i.delegatePickingToChildren=!1,i.thickness=1,i.isPointerBlocker=!0;var r=null;return i.pointerEnterAnimation=function(){r=i.alpha,i.alpha-=.1},i.pointerOutAnimation=function(){r!==null&&(i.alpha=r)},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return Object.defineProperty(t.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textBlock",{get:function(){return this._textBlock},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Button"},t.prototype._processPicking=function(e,i,r,o,a,s,l,u){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable||!n.prototype.contains.call(this,e,i))return!1;if(this.delegatePickingToChildren){for(var f=!1,c=this._children.length-1;c>=0;c--){var h=this._children[c];if(h.isEnabled&&h.isHitTestVisible&&h.isVisible&&!h.notRenderable&&h.contains(e,i)){f=!0;break}}if(!f)return!1}return this._processObservables(o,e,i,r,a,s,l,u),!0},t.prototype._onPointerEnter=function(e,i){return n.prototype._onPointerEnter.call(this,e,i)?(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0):!1},t.prototype._onPointerOut=function(e,i,r){r===void 0&&(r=!1),this.pointerOutAnimation&&this.pointerOutAnimation(),n.prototype._onPointerOut.call(this,e,i,r)},t.prototype._onPointerDown=function(e,i,r,o,a){return n.prototype._onPointerDown.call(this,e,i,r,o,a)?(this.pointerDownAnimation&&this.pointerDownAnimation(),!0):!1},t.prototype._onPointerUp=function(e,i,r,o,a,s){this.pointerUpAnimation&&this.pointerUpAnimation(),n.prototype._onPointerUp.call(this,e,i,r,o,a,s)},t.CreateImageButton=function(e,i,r){var o=new t(e),a=new Mn(e+"_button",i);a.textWrapping=!0,a.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,a.paddingLeft="20%",o.addControl(a);var s=new Za(e+"_icon",r);return s.width="20%",s.stretch=Za.STRETCH_UNIFORM,s.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,o.addControl(s),o._image=s,o._textBlock=a,o},t.CreateImageOnlyButton=function(e,i){var r=new t(e),o=new Za(e+"_icon",i);return o.stretch=Za.STRETCH_FILL,o.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,r.addControl(o),r._image=o,r},t.CreateSimpleButton=function(e,i){var r=new t(e),o=new Mn(e+"_button",i);return o.textWrapping=!0,o.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,r.addControl(o),r._textBlock=o,r},t.CreateImageWithCenterTextButton=function(e,i,r){var o=new t(e),a=new Za(e+"_icon",r);a.stretch=Za.STRETCH_FILL,o.addControl(a);var s=new Mn(e+"_button",i);return s.textWrapping=!0,s.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,o.addControl(s),o._image=a,o._textBlock=s,o},t}(lo);Ae.RegisteredTypes["BABYLON.GUI.Button"]=_a;var Pa=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._isVertical=!0,i._manualWidth=!1,i._manualHeight=!1,i._doNotTrackManualChanges=!1,i.ignoreLayoutWarnings=!1,i}return Object.defineProperty(t.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==e&&this._width.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==e&&this._height.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"StackPanel"},t.prototype._preMeasure=function(e,i){for(var r=0,o=this._children;r<o.length;r++){var a=o[r];this._isVertical?a.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP:a.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT}n.prototype._preMeasure.call(this,e,i)},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(e),this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,(!this.isVertical||this._manualWidth)&&(this._measureForChildren.width=this._currentMeasure.width),(this.isVertical||this._manualHeight)&&(this._measureForChildren.height=this._currentMeasure.height)},t.prototype._postMeasure=function(){for(var e=0,i=0,r=0,o=this._children;r<o.length;r++){var a=o[r];!a.isVisible||a.notRenderable||(this._isVertical?(a.top!==i+"px"&&(a.top=i+"px",this._rebuildLayout=!0,a._top.ignoreAdaptiveScaling=!0),a._height.isPercentage&&!a._automaticSize?this.ignoreLayoutWarnings||Ee.Warn("Control (Name:"+a.name+", UniqueId:"+a.uniqueId+") is using height in percentage mode inside a vertical StackPanel"):i+=a._currentMeasure.height+a.paddingTopInPixels+a.paddingBottomInPixels):(a.left!==e+"px"&&(a.left=e+"px",this._rebuildLayout=!0,a._left.ignoreAdaptiveScaling=!0),a._width.isPercentage&&!a._automaticSize?this.ignoreLayoutWarnings||Ee.Warn("Control (Name:"+a.name+", UniqueId:"+a.uniqueId+") is using width in percentage mode inside a horizontal StackPanel"):e+=a._currentMeasure.width+a.paddingLeftInPixels+a.paddingRightInPixels))}e+=this.paddingLeftInPixels+this.paddingRightInPixels,i+=this.paddingTopInPixels+this.paddingBottomInPixels,this._doNotTrackManualChanges=!0;var s=!1,l=!1;if(!this._manualHeight&&this._isVertical){var u=this.height;this.height=i+"px",l=u!==this.height||!this._height.ignoreAdaptiveScaling}if(!this._manualWidth&&!this._isVertical){var f=this.width;this.width=e+"px",s=f!==this.width||!this._width.ignoreAdaptiveScaling}l&&(this._height.ignoreAdaptiveScaling=!0),s&&(this._width.ignoreAdaptiveScaling=!0),this._doNotTrackManualChanges=!1,(s||l)&&(this._rebuildLayout=!0),n.prototype._postMeasure.call(this)},t}(so);Ae.RegisteredTypes["BABYLON.GUI.StackPanel"]=Pa;var $I=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.onIsCheckedChangedObservable=new ie,i.isPointerBlocker=!0,i}return Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(e){e=Math.max(Math.min(1,e),0),this._checkSizeRatio!==e&&(this._checkSizeRatio=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isChecked",{get:function(){return this._isChecked},set:function(e){this._isChecked!==e&&(this._isChecked=e,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(e))},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Checkbox"},t.prototype._draw=function(e,i){e.save(),this._applyStates(e);var r=this._currentMeasure.width-this._thickness,o=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fillRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,r,o),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._isChecked){e.fillStyle=this._isEnabled?this.color:this._disabledColorItem;var a=r*this._checkSizeRatio,s=o*this._checkSizeRatio;e.fillRect(this._currentMeasure.left+this._thickness/2+(r-a)/2,this._currentMeasure.top+this._thickness/2+(o-s)/2,a,s)}e.strokeStyle=this.color,e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,r,o),e.restore()},t.prototype._onPointerDown=function(e,i,r,o,a){return n.prototype._onPointerDown.call(this,e,i,r,o,a)?(this.isChecked=!this.isChecked,!0):!1},t.AddCheckBoxWithHeader=function(e,i){var r=new Pa;r.isVertical=!1,r.height="30px";var o=new t;o.width="20px",o.height="20px",o.isChecked=!0,o.color="green",o.onIsCheckedChangedObservable.add(i),r.addControl(o);var a=new Mn;return a.text=e,a.width="180px",a.paddingLeft="5px",a.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,a.color="white",r.addControl(a),r},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.Checkbox"]=$I;var By=function(){function n(){}return Object.defineProperty(n.prototype,"text",{get:function(){return this._characters?this._characters.join(""):this._text},set:function(t){this._text=t,this._characters=Array.from&&Array.from(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"length",{get:function(){return this._characters?this._characters.length:this._text.length},enumerable:!1,configurable:!0}),n.prototype.removePart=function(t,e,i){var r;if(this._text=this._text.slice(0,t)+(i||"")+this._text.slice(e),this._characters){var o=i?Array.from(i):[];(r=this._characters).splice.apply(r,jM([t,e-t],o))}},n.prototype.charAt=function(t){return this._characters?this._characters[t]:this._text.charAt(t)},n.prototype.substr=function(t,e){if(this._characters){isNaN(t)?t=0:t>=0?t=Math.min(t,this._characters.length):t=this._characters.length+Math.max(t,-this._characters.length),e===void 0?e=this._characters.length-t:(isNaN(e)||e<0)&&(e=0);for(var i=[];--e>=0;)i[e]=this._characters[t+e];return i.join("")}return this._text.substr(t,e)},n.prototype.substring=function(t,e){if(this._characters){isNaN(t)?t=0:t>this._characters.length?t=this._characters.length:t<0&&(t=0),e===void 0?e=this._characters.length:isNaN(e)?e=0:e>this._characters.length?e=this._characters.length:e<0&&(e=0);for(var i=[],r=0;t<e;)i[r++]=this._characters[t++];return i.join("")}return this._text.substring(t,e)},n.prototype.isWord=function(t){var e=/\w/g;return this._characters?this._characters[t].search(e)!==-1:this._text.search(e)!==-1},n}(),ma=function(n){j(t,n);function t(e,i){i===void 0&&(i="");var r=n.call(this,e)||this;return r.name=e,r._placeholderText="",r._background="#222222",r._focusedBackground="#000000",r._focusedColor="white",r._placeholderColor="gray",r._thickness=1,r._margin=new zt(10,zt.UNITMODE_PIXEL),r._autoStretchWidth=!0,r._maxWidth=new zt(1,zt.UNITMODE_PERCENTAGE,!1),r._isFocused=!1,r._blinkIsEven=!1,r._cursorOffset=0,r._deadKey=!1,r._addKey=!0,r._currentKey="",r._isTextHighlightOn=!1,r._textHighlightColor="#d5e0ff",r._highligherOpacity=.4,r._highlightedText="",r._startHighlightIndex=0,r._endHighlightIndex=0,r._cursorIndex=-1,r._onFocusSelectAll=!1,r._isPointerDown=!1,r.promptMessage="Please enter text:",r.disableMobilePrompt=!1,r.onTextChangedObservable=new ie,r.onBeforeKeyAddObservable=new ie,r.onFocusObservable=new ie,r.onBlurObservable=new ie,r.onTextHighlightObservable=new ie,r.onTextCopyObservable=new ie,r.onTextCutObservable=new ie,r.onTextPasteObservable=new ie,r.onKeyboardEventProcessedObservable=new ie,r.text=i,r.isPointerBlocker=!0,r}return Object.defineProperty(t.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(e){this._maxWidth.toString(this._host)!==e&&this._maxWidth.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxWidthInPixels",{get:function(){return this._maxWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highligherOpacity",{get:function(){return this._highligherOpacity},set:function(e){this._highligherOpacity!==e&&(this._highligherOpacity=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onFocusSelectAll",{get:function(){return this._onFocusSelectAll},set:function(e){this._onFocusSelectAll!==e&&(this._onFocusSelectAll=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textHighlightColor",{get:function(){return this._textHighlightColor},set:function(e){this._textHighlightColor!==e&&(this._textHighlightColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(e){this._margin.toString(this._host)!==e&&this._margin.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"marginInPixels",{get:function(){return this._margin.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(e){this._autoStretchWidth!==e&&(this._autoStretchWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"focusedBackground",{get:function(){return this._focusedBackground},set:function(e){this._focusedBackground!==e&&(this._focusedBackground=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"focusedColor",{get:function(){return this._focusedColor},set:function(e){this._focusedColor!==e&&(this._focusedColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"placeholderColor",{get:function(){return this._placeholderColor},set:function(e){this._placeholderColor!==e&&(this._placeholderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"placeholderText",{get:function(){return this._placeholderText},set:function(e){this._placeholderText!==e&&(this._placeholderText=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deadKey",{get:function(){return this._deadKey},set:function(e){this._deadKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightedText",{get:function(){return this._highlightedText},set:function(e){this._highlightedText!==e&&(this._highlightedText=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"addKey",{get:function(){return this._addKey},set:function(e){this._addKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentKey",{get:function(){return this._currentKey},set:function(e){this._currentKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"text",{get:function(){return this._textWrapper.text},set:function(e){var i=e.toString();this._textWrapper||(this._textWrapper=new By),this._textWrapper.text!==i&&(this._textWrapper.text=i,this._textHasChanged())},enumerable:!1,configurable:!0}),t.prototype._textHasChanged=function(){this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this)},Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._width.toString(this._host)!==e&&(this._width.fromString(e)&&this._markAsDirty(),this.autoStretchWidth=!1)},enumerable:!1,configurable:!0}),t.prototype.onBlur=function(){this._isFocused=!1,this._scrollLeft=null,this._cursorOffset=0,clearTimeout(this._blinkTimeout),this._markAsDirty(),this.onBlurObservable.notifyObservers(this),this._host.unRegisterClipboardEvents(),this._onClipboardObserver&&this._host.onClipboardObservable.remove(this._onClipboardObserver);var e=this._host.getScene();this._onPointerDblTapObserver&&e&&e.onPointerObservable.remove(this._onPointerDblTapObserver)},t.prototype.onFocus=function(){var e=this;if(this._isEnabled){if(this._scrollLeft=null,this._isFocused=!0,this._blinkIsEven=!1,this._cursorOffset=0,this._markAsDirty(),this.onFocusObservable.notifyObservers(this),navigator.userAgent.indexOf("Mobile")!==-1&&!this.disableMobilePrompt){var i=prompt(this.promptMessage);i!==null&&(this.text=i),this._host.focusedControl=null;return}this._host.registerClipboardEvents(),this._onClipboardObserver=this._host.onClipboardObservable.add(function(o){switch(o.type){case Sa.COPY:e._onCopyText(o.event),e.onTextCopyObservable.notifyObservers(e);break;case Sa.CUT:e._onCutText(o.event),e.onTextCutObservable.notifyObservers(e);break;case Sa.PASTE:e._onPasteText(o.event),e.onTextPasteObservable.notifyObservers(e);break;default:return}});var r=this._host.getScene();r&&(this._onPointerDblTapObserver=r.onPointerObservable.add(function(o){e._isFocused&&o.type===He.POINTERDOUBLETAP&&e._processDblClick(o)})),this._onFocusSelectAll&&this._selectAllText()}},t.prototype._getTypeName=function(){return"InputText"},t.prototype.keepsFocusWith=function(){return this._connectedVirtualKeyboard?[this._connectedVirtualKeyboard]:null},t.prototype.processKey=function(e,i,r){if(!(r&&(r.ctrlKey||r.metaKey)&&(e===67||e===86||e===88))){if(r&&(r.ctrlKey||r.metaKey)&&e===65){this._selectAllText(),r.preventDefault();return}switch(e){case 32:i=" ";break;case 191:r&&r.preventDefault();break;case 8:if(this._textWrapper.text&&this._textWrapper.length>0){if(this._isTextHighlightOn){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._blinkIsEven=!1,r&&r.preventDefault();return}if(this._cursorOffset===0)this.text=this._textWrapper.substr(0,this._textWrapper.length-1);else{var o=this._textWrapper.length-this._cursorOffset;o>0&&(this._textWrapper.removePart(o-1,o),this._textHasChanged())}}r&&r.preventDefault();return;case 46:if(this._isTextHighlightOn){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,r&&r.preventDefault();return}if(this._textWrapper.text&&this._textWrapper.length>0&&this._cursorOffset>0){var o=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(o,o+1),this._textHasChanged(),this._cursorOffset--}r&&r.preventDefault();return;case 13:this._host.focusedControl=null,this._isTextHighlightOn=!1;return;case 35:this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._markAsDirty();return;case 36:this._cursorOffset=this._textWrapper.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._markAsDirty();return;case 37:if(this._cursorOffset++,this._cursorOffset>this._textWrapper.length&&(this._cursorOffset=this._textWrapper.length),r&&r.shiftKey){if(this._blinkIsEven=!1,r.ctrlKey||r.metaKey){if(!this._isTextHighlightOn){if(this._textWrapper.length===this._cursorOffset)return;this._endHighlightIndex=this._textWrapper.length-this._cursorOffset+1}this._startHighlightIndex=0,this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._textWrapper.length,this._isTextHighlightOn=!0,this._markAsDirty();return}this._isTextHighlightOn?this._cursorIndex===-1&&(this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._startHighlightIndex===0?this._textWrapper.length:this._textWrapper.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._textWrapper.length?this._textWrapper.length:this._cursorOffset-1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,this._markAsDirty();return}this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._isTextHighlightOn=!1),r&&(r.ctrlKey||r.metaKey)&&(this._cursorOffset=this._textWrapper.length,r.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,this._markAsDirty();return;case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),r&&r.shiftKey){if(this._blinkIsEven=!1,r.ctrlKey||r.metaKey){if(!this._isTextHighlightOn){if(this._cursorOffset===0)return;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset-1}this._endHighlightIndex=this._textWrapper.length,this._isTextHighlightOn=!0,this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=0,this._markAsDirty();return}this._isTextHighlightOn?this._cursorIndex===-1&&(this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=this._textWrapper.length===this._endHighlightIndex?0:this._textWrapper.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,this._markAsDirty();return}this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._endHighlightIndex,this._isTextHighlightOn=!1),r&&(r.ctrlKey||r.metaKey)&&(this._cursorOffset=0,r.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,this._markAsDirty();return;case 222:r&&r.preventDefault(),this._cursorIndex=-1,this.deadKey=!0;break}if(i&&(e===-1||e===32||e>47&&e<64||e>64&&e<91||e>159&&e<193||e>218&&e<223||e>95&&e<112)&&(this._currentKey=i,this.onBeforeKeyAddObservable.notifyObservers(this),i=this._currentKey,this._addKey))if(this._isTextHighlightOn)this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex,i),this._textHasChanged(),this._cursorOffset=this._textWrapper.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(this._cursorOffset===0)this.text+=i;else{var a=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(a,a,i),this._textHasChanged()}}},t.prototype._updateValueFromCursorIndex=function(e){if(this._blinkIsEven=!1,this._cursorIndex===-1)this._cursorIndex=e;else if(this._cursorIndex<this._cursorOffset)this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset;else if(this._cursorIndex>this._cursorOffset)this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex;else{this._isTextHighlightOn=!1,this._markAsDirty();return}this._isTextHighlightOn=!0,this._markAsDirty()},t.prototype._processDblClick=function(e){this._startHighlightIndex=this._textWrapper.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;var i,r;do r=this._endHighlightIndex<this._textWrapper.length&&this._textWrapper.isWord(this._endHighlightIndex)?++this._endHighlightIndex:0,i=this._startHighlightIndex>0&&this._textWrapper.isWord(this._startHighlightIndex-1)?--this._startHighlightIndex:0;while(i||r);this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},t.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._textWrapper.length,this._cursorOffset=this._textWrapper.length,this._cursorIndex=-1,this._markAsDirty()},t.prototype.processKeyboard=function(e){this.processKey(e.keyCode,e.key,e),this.onKeyboardEventProcessedObservable.notifyObservers(e)},t.prototype._onCopyText=function(e){this._isTextHighlightOn=!1;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch{}this._host.clipboardData=this._highlightedText},t.prototype._onCutText=function(e){if(this._highlightedText){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch{}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},t.prototype._onPasteText=function(e){var i="";e.clipboardData&&e.clipboardData.types.indexOf("text/plain")!==-1?i=e.clipboardData.getData("text/plain"):i=this._host.clipboardData;var r=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(r,r,i),this._textHasChanged()},t.prototype._draw=function(e,i){var r=this;e.save(),this._applyStates(e),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(e.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._fontOffset||(this._fontOffset=ot._GetFontOffset(e.font));var o=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(e.fillStyle=this.color);var a=this._beforeRenderText(this._textWrapper);!this._isFocused&&!this._textWrapper.text&&this._placeholderText&&(a=new By,a.text=this._placeholderText,this._placeholderColor&&(e.fillStyle=this._placeholderColor)),this._textWidth=e.measureText(a.text).width;var s=this._margin.getValueInPixel(this._host,this._tempParentMeasure.width)*2;this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+s)+"px");var l=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,u=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-s;if(e.save(),e.beginPath(),e.rect(o,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,u+2,this._currentMeasure.height),e.clip(),this._isFocused&&this._textWidth>u){var f=o-this._textWidth+u;this._scrollLeft||(this._scrollLeft=f)}else this._scrollLeft=o;if(e.fillText(a.text,this._scrollLeft,this._currentMeasure.top+l),this._isFocused){if(this._clickedCoordinate){var c=this._scrollLeft+this._textWidth,h=c-this._clickedCoordinate,p=0;this._cursorOffset=0;var _=0;do this._cursorOffset&&(_=Math.abs(h-p)),this._cursorOffset++,p=e.measureText(a.substr(a.length-this._cursorOffset,this._cursorOffset)).width;while(p<h&&a.length>=this._cursorOffset);Math.abs(h-p)>_&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var g=a.substr(a.length-this._cursorOffset),v=e.measureText(g).width,E=this._scrollLeft+this._textWidth-v;E<o?(this._scrollLeft+=o-E,E=o,this._markAsDirty()):E>o+u&&(this._scrollLeft+=o+u-E,E=o+u,this._markAsDirty()),this._isTextHighlightOn||e.fillRect(E,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout(function(){r._blinkIsEven=!r._blinkIsEven,r._markAsDirty()},500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var T=e.measureText(a.substring(this._startHighlightIndex)).width,S=this._scrollLeft+this._textWidth-T;this._highlightedText=a.substring(this._startHighlightIndex,this._endHighlightIndex);var C=e.measureText(a.substring(this._startHighlightIndex,this._endHighlightIndex)).width;S<o&&(C=C-(o-S),C||(C=e.measureText(a.charAt(a.length-this._cursorOffset)).width),S=o),e.globalAlpha=this._highligherOpacity,e.fillStyle=this._textHighlightColor,e.fillRect(S,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,C,this._fontOffset.height),e.globalAlpha=1}}e.restore(),this._thickness&&(this._isFocused?this.focusedColor&&(e.strokeStyle=this.focusedColor):this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),e.restore()},t.prototype._onPointerDown=function(e,i,r,o,a){return n.prototype._onPointerDown.call(this,e,i,r,o,a)?(this._clickedCoordinate=i.x,this._isTextHighlightOn=!1,this._highlightedText="",this._cursorIndex=-1,this._isPointerDown=!0,this._host._capturingControl[r]=this,this._host.focusedControl===this?(clearTimeout(this._blinkTimeout),this._markAsDirty(),!0):this._isEnabled?(this._host.focusedControl=this,!0):!1):!1},t.prototype._onPointerMove=function(e,i,r,o){this._host.focusedControl===this&&this._isPointerDown&&(this._clickedCoordinate=i.x,this._markAsDirty(),this._updateValueFromCursorIndex(this._cursorOffset)),n.prototype._onPointerMove.call(this,e,i,r,o)},t.prototype._onPointerUp=function(e,i,r,o,a){this._isPointerDown=!1,delete this._host._capturingControl[r],n.prototype._onPointerUp.call(this,e,i,r,o,a)},t.prototype._beforeRenderText=function(e){return e},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onTextChangedObservable.clear(),this.onTextCopyObservable.clear(),this.onTextCutObservable.clear(),this.onTextPasteObservable.clear(),this.onTextHighlightObservable.clear(),this.onKeyboardEventProcessedObservable.clear()},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.InputText"]=ma;var un=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._rowDefinitions=new Array,i._columnDefinitions=new Array,i._cells={},i._childControls=new Array,i}return Object.defineProperty(t.prototype,"columnCount",{get:function(){return this._columnDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rowCount",{get:function(){return this._rowDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"children",{get:function(){return this._childControls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._cells},enumerable:!1,configurable:!0}),t.prototype.getRowDefinition=function(e){return e<0||e>=this._rowDefinitions.length?null:this._rowDefinitions[e]},t.prototype.getColumnDefinition=function(e){return e<0||e>=this._columnDefinitions.length?null:this._columnDefinitions[e]},t.prototype.addRowDefinition=function(e,i){return i===void 0&&(i=!1),this._rowDefinitions.push(new zt(e,i?zt.UNITMODE_PIXEL:zt.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},t.prototype.addColumnDefinition=function(e,i){return i===void 0&&(i=!1),this._columnDefinitions.push(new zt(e,i?zt.UNITMODE_PIXEL:zt.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},t.prototype.setRowDefinition=function(e,i,r){if(r===void 0&&(r=!1),e<0||e>=this._rowDefinitions.length)return this;var o=this._rowDefinitions[e];return o&&o.isPixel===r&&o.internalValue===i?this:(this._rowDefinitions[e]=new zt(i,r?zt.UNITMODE_PIXEL:zt.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},t.prototype.setColumnDefinition=function(e,i,r){if(r===void 0&&(r=!1),e<0||e>=this._columnDefinitions.length)return this;var o=this._columnDefinitions[e];return o&&o.isPixel===r&&o.internalValue===i?this:(this._columnDefinitions[e]=new zt(i,r?zt.UNITMODE_PIXEL:zt.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},t.prototype.getChildrenAt=function(e,i){var r=this._cells[e+":"+i];return r?r.children:null},t.prototype.getChildCellInfo=function(e){return e._tag},t.prototype._removeCell=function(e,i){if(e){n.prototype.removeControl.call(this,e);for(var r=0,o=e.children;r<o.length;r++){var a=o[r],s=this._childControls.indexOf(a);s!==-1&&this._childControls.splice(s,1)}delete this._cells[i]}},t.prototype._offsetCell=function(e,i){if(this._cells[i]){this._cells[e]=this._cells[i];for(var r=0,o=this._cells[e].children;r<o.length;r++){var a=o[r];a._tag=e}delete this._cells[i]}},t.prototype.removeColumnDefinition=function(e){if(e<0||e>=this._columnDefinitions.length)return this;for(var i=0;i<this._rowDefinitions.length;i++){var r=i+":"+e,o=this._cells[r];this._removeCell(o,r)}for(var i=0;i<this._rowDefinitions.length;i++)for(var a=e+1;a<this._columnDefinitions.length;a++){var s=i+":"+(a-1),r=i+":"+a;this._offsetCell(s,r)}return this._columnDefinitions.splice(e,1),this._markAsDirty(),this},t.prototype.removeRowDefinition=function(e){if(e<0||e>=this._rowDefinitions.length)return this;for(var i=0;i<this._columnDefinitions.length;i++){var r=e+":"+i,o=this._cells[r];this._removeCell(o,r)}for(var i=0;i<this._columnDefinitions.length;i++)for(var a=e+1;a<this._rowDefinitions.length;a++){var s=a-1+":"+i,r=a+":"+i;this._offsetCell(s,r)}return this._rowDefinitions.splice(e,1),this._markAsDirty(),this},t.prototype.addControl=function(e,i,r){if(i===void 0&&(i=0),r===void 0&&(r=0),this._rowDefinitions.length===0&&this.addRowDefinition(1,!1),this._columnDefinitions.length===0&&this.addColumnDefinition(1,!1),this._childControls.indexOf(e)!==-1)return Ee.Warn("Control (Name:"+e.name+", UniqueId:"+e.uniqueId+") is already associated with this grid. You must remove it before reattaching it"),this;var o=Math.min(i,this._rowDefinitions.length-1),a=Math.min(r,this._columnDefinitions.length-1),s=o+":"+a,l=this._cells[s];return l||(l=new so(s),this._cells[s]=l,l.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,l.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,n.prototype.addControl.call(this,l)),l.addControl(e),this._childControls.push(e),e._tag=s,e.parent=this,this._markAsDirty(),this},t.prototype.removeControl=function(e){var i=this._childControls.indexOf(e);i!==-1&&this._childControls.splice(i,1);var r=this._cells[e._tag];return r&&(r.removeControl(e),e._tag=null),this._markAsDirty(),this},t.prototype._getTypeName=function(){return"Grid"},t.prototype._getGridDefinitions=function(e){for(var i=[],r=[],o=[],a=[],s=this._currentMeasure.width,l=0,u=this._currentMeasure.height,f=0,c=0,h=0,p=this._rowDefinitions;h<p.length;h++){var _=p[h];if(_.isPixel){var g=_.getValue(this._host);u-=g,r[c]=g}else f+=_.internalValue;c++}var v=0;c=0;for(var E=0,T=this._rowDefinitions;E<T.length;E++){var _=T[E];if(a.push(v),_.isPixel)v+=_.getValue(this._host);else{var g=_.internalValue/f*u;v+=g,r[c]=g}c++}c=0;for(var S=0,C=this._columnDefinitions;S<C.length;S++){var _=C[S];if(_.isPixel){var O=_.getValue(this._host);s-=O,i[c]=O}else l+=_.internalValue;c++}var A=0;c=0;for(var M=0,D=this._columnDefinitions;M<D.length;M++){var _=D[M];if(o.push(A),_.isPixel)A+=_.getValue(this._host);else{var O=_.internalValue/l*s;A+=O,i[c]=O}c++}e(o,a,i,r)},t.prototype._additionalProcessing=function(e,i){var r=this;this._getGridDefinitions(function(o,a,s,l){for(var u in r._cells)if(r._cells.hasOwnProperty(u)){var f=u.split(":"),c=parseInt(f[0]),h=parseInt(f[1]),p=r._cells[u];p.left=o[h]+"px",p.top=a[c]+"px",p.width=s[h]+"px",p.height=l[c]+"px",p._left.ignoreAdaptiveScaling=!0,p._top.ignoreAdaptiveScaling=!0,p._width.ignoreAdaptiveScaling=!0,p._height.ignoreAdaptiveScaling=!0}}),n.prototype._additionalProcessing.call(this,e,i)},t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e in this._cells)if(this._cells.hasOwnProperty(e)){var i=this._cells[e];i._markMatrixAsDirty()}},t.prototype._renderHighlightSpecific=function(e){var i=this;n.prototype._renderHighlightSpecific.call(this,e),this._getGridDefinitions(function(r,o,a,s){for(var l=0;l<r.length;l++){var u=i._currentMeasure.left+r[l]+a[l];e.beginPath(),e.moveTo(u,i._currentMeasure.top),e.lineTo(u,i._currentMeasure.top+i._currentMeasure.height),e.stroke()}for(var l=0;l<o.length;l++){var f=i._currentMeasure.top+o[l]+s[l];e.beginPath(),e.moveTo(i._currentMeasure.left,f),e.lineTo(i._currentMeasure.left+i._currentMeasure.width,f),e.stroke()}}),e.restore()},t.prototype.dispose=function(){n.prototype.dispose.call(this);for(var e=0,i=this._childControls;e<i.length;e++){var r=i[e];r.dispose()}this._childControls=[]},t}(so);Ae.RegisteredTypes["BABYLON.GUI.Grid"]=un;var gX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._value=_e.Red(),i._tmpColor=new _e,i._pointerStartedOnSquare=!1,i._pointerStartedOnWheel=!1,i._squareLeft=0,i._squareTop=0,i._squareSize=0,i._h=360,i._s=1,i._v=1,i._lastPointerDownID=-1,i.onValueChangedObservable=new ie,i._pointerIsDown=!1,i.value=new _e(.88,.1,.1),i.size="200px",i.isPointerBlocker=!0,i}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(e){this._value.equals(e)||(this._value.copyFrom(e),this._value.toHSVToRef(this._tmpColor),this._h=this._tmpColor.r,this._s=Math.max(this._tmpColor.g,1e-5),this._v=Math.max(this._tmpColor.b,1e-5),this._markAsDirty(),this._value.r<=t._Epsilon&&(this._value.r=0),this._value.g<=t._Epsilon&&(this._value.g=0),this._value.b<=t._Epsilon&&(this._value.b=0),this._value.r>=1-t._Epsilon&&(this._value.r=1),this._value.g>=1-t._Epsilon&&(this._value.g=1),this._value.b>=1-t._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._width.toString(this._host)!==e&&this._width.fromString(e)&&(this._height.fromString(e),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._height.toString(this._host)!==e&&this._height.fromString(e)&&(this._width.fromString(e),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"ColorPicker"},t.prototype._preMeasure=function(e,i){e.width<e.height?this._currentMeasure.height=e.width:this._currentMeasure.width=e.height},t.prototype._updateSquareProps=function(){var e=Math.min(this._currentMeasure.width,this._currentMeasure.height)*.5,i=e*.2,r=(e-i)*2,o=r/Math.sqrt(2),a=e-o*.5;this._squareLeft=this._currentMeasure.left+a,this._squareTop=this._currentMeasure.top+a,this._squareSize=o},t.prototype._drawGradientSquare=function(e,i,r,o,a,s){var l=s.createLinearGradient(i,r,o+i,r);l.addColorStop(0,"#fff"),l.addColorStop(1,"hsl("+e+", 100%, 50%)"),s.fillStyle=l,s.fillRect(i,r,o,a);var u=s.createLinearGradient(i,r,i,a+r);u.addColorStop(0,"rgba(0,0,0,0)"),u.addColorStop(1,"#000"),s.fillStyle=u,s.fillRect(i,r,o,a)},t.prototype._drawCircle=function(e,i,r,o){o.beginPath(),o.arc(e,i,r+1,0,2*Math.PI,!1),o.lineWidth=3,o.strokeStyle="#333333",o.stroke(),o.beginPath(),o.arc(e,i,r,0,2*Math.PI,!1),o.lineWidth=3,o.strokeStyle="#ffffff",o.stroke()},t.prototype._createColorWheelCanvas=function(e,i){var r=document.createElement("canvas");r.width=e*2,r.height=e*2;for(var o=r.getContext("2d"),a=o.getImageData(0,0,e*2,e*2),s=a.data,l=this._tmpColor,u=e*e,f=e-i,c=f*f,h=-e;h<e;h++)for(var p=-e;p<e;p++){var _=h*h+p*p;if(!(_>u||_<c)){var g=Math.sqrt(_),v=Math.atan2(p,h);_e.HSVtoRGBToRef(v*180/Math.PI+180,g/e,1,l);var E=(h+e+(p+e)*2*e)*4;s[E]=l.r*255,s[E+1]=l.g*255,s[E+2]=l.b*255;var M=(g-f)/(e-f),T=.2,S=.2,C=.04,O=50,A=150;e<O?T=S:e>A?T=C:T=(C-S)*(e-O)/(A-O)+S;var M=(g-f)/(e-f);M<T?s[E+3]=255*(M/T):M>1-T?s[E+3]=255*(1-(M-(1-T))/T):s[E+3]=255}}return o.putImageData(a,0,0),r},t.prototype._draw=function(e){e.save(),this._applyStates(e);var i=Math.min(this._currentMeasure.width,this._currentMeasure.height)*.5,r=i*.2,o=this._currentMeasure.left,a=this._currentMeasure.top;(!this._colorWheelCanvas||this._colorWheelCanvas.width!=i*2)&&(this._colorWheelCanvas=this._createColorWheelCanvas(i,r)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY,e.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),e.drawImage(this._colorWheelCanvas,o,a),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var s=this._squareLeft+this._squareSize*this._s,l=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(s,l,i*.04,e);var u=i-r*.5;s=o+i+Math.cos((this._h-180)*Math.PI/180)*u,l=a+i+Math.sin((this._h-180)*Math.PI/180)*u,this._drawCircle(s,l,r*.35,e),e.restore()},t.prototype._updateValueFromPointer=function(e,i){if(this._pointerStartedOnWheel){var r=Math.min(this._currentMeasure.width,this._currentMeasure.height)*.5,o=r+this._currentMeasure.left,a=r+this._currentMeasure.top;this._h=Math.atan2(i-a,e-o)*180/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(e-this._squareLeft)/this._squareSize,this._v=1-(i-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,t._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,t._Epsilon));_e.HSVtoRGBToRef(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},t.prototype._isPointOnSquare=function(e,i){this._updateSquareProps();var r=this._squareLeft,o=this._squareTop,a=this._squareSize;return e>=r&&e<=r+a&&i>=o&&i<=o+a},t.prototype._isPointOnWheel=function(e,i){var r=Math.min(this._currentMeasure.width,this._currentMeasure.height)*.5,o=r+this._currentMeasure.left,a=r+this._currentMeasure.top,s=r*.2,l=r-s,u=r*r,f=l*l,c=e-o,h=i-a,p=c*c+h*h;return p<=u&&p>=f},t.prototype._onPointerDown=function(e,i,r,o,a){if(!n.prototype._onPointerDown.call(this,e,i,r,o,a))return!1;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var s=this._transformedPosition.x,l=this._transformedPosition.y;return this._isPointOnSquare(s,l)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(s,l)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(s,l),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0},t.prototype._onPointerMove=function(e,i,r,o){if(r==this._lastPointerDownID){this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var a=this._transformedPosition.x,s=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(a,s),n.prototype._onPointerMove.call(this,e,i,r,o)}},t.prototype._onPointerUp=function(e,i,r,o,a,s){this._pointerIsDown=!1,delete this._host._capturingControl[r],n.prototype._onPointerUp.call(this,e,i,r,o,a,s)},t.prototype._onCanvasBlur=function(){this._forcePointerUp(),n.prototype._onCanvasBlur.call(this)},t.ShowPickerDialogAsync=function(e,i){return new Promise(function(r,o){i.pickerWidth=i.pickerWidth||"640px",i.pickerHeight=i.pickerHeight||"400px",i.headerHeight=i.headerHeight||"35px",i.lastColor=i.lastColor||"#000000",i.swatchLimit=i.swatchLimit||20,i.numSwatchesPerLine=i.numSwatchesPerLine||10;var a=i.swatchLimit/i.numSwatchesPerLine,s=parseFloat(i.pickerWidth)/i.numSwatchesPerLine,l=Math.floor(s*.25),u=l*(i.numSwatchesPerLine+1),f=Math.floor((parseFloat(i.pickerWidth)-u)/i.numSwatchesPerLine),c=f*a+l*(a+1),h=(parseInt(i.pickerHeight)+c+Math.floor(f*.25)).toString()+"px",p="#c0c0c0",_="#535353",g="#414141",v="515151",E="#555555",T="#454545",S="#404040",C=_e.FromHexString("#dddddd"),O=C.r+C.g+C.b,A="#aaaaaa",M="#ffffff",D,U,V,B,z,J=["R","G","B"],X="#454545",re="#f0f0f0",ae,se,H,Z=!1,q,F,W,$,L,G,Y,Q,fe,Se,ee;function pe(Ge,$e){ee=$e;var qe=Ge.toHexString();if(fe.background=qe,F.name!=ee&&(F.text=Math.floor(Ge.r*255).toString()),W.name!=ee&&(W.text=Math.floor(Ge.g*255).toString()),$.name!=ee&&($.text=Math.floor(Ge.b*255).toString()),L.name!=ee&&(L.text=Ge.r.toString()),G.name!=ee&&(G.text=Ge.g.toString()),Y.name!=ee&&(Y.text=Ge.b.toString()),Q.name!=ee){var Ft=qe.split("#");Q.text=Ft[1]}q.name!=ee&&(q.value=Ge)}function Pe(Ge,$e){var qe=Ge.text,Ft=/[^0-9]/g.test(qe);if(Ft){Ge.text=Se;return}else qe!=""&&(Math.floor(parseInt(qe))<0?qe="0":Math.floor(parseInt(qe))>255?qe="255":isNaN(parseInt(qe))&&(qe="0")),ee==Ge.name&&(Se=qe);if(qe!=""){qe=parseInt(qe).toString(),Ge.text=qe;var xt=_e.FromHexString(fe.background);ee==Ge.name&&($e=="r"?pe(new _e(parseInt(qe)/255,xt.g,xt.b),Ge.name):$e=="g"?pe(new _e(xt.r,parseInt(qe)/255,xt.b),Ge.name):pe(new _e(xt.r,xt.g,parseInt(qe)/255),Ge.name))}}function xe(Ge,$e){var qe=Ge.text,Ft=/[^0-9\.]/g.test(qe);if(Ft){Ge.text=Se;return}else qe!=""&&qe!="."&&parseFloat(qe)!=0&&(parseFloat(qe)<0?qe="0.0":parseFloat(qe)>1?qe="1.0":isNaN(parseFloat(qe))&&(qe="0.0")),ee==Ge.name&&(Se=qe);qe!=""&&qe!="."&&parseFloat(qe)!=0?(qe=parseFloat(qe).toString(),Ge.text=qe):qe="0.0";var xt=_e.FromHexString(fe.background);ee==Ge.name&&($e=="r"?pe(new _e(parseFloat(qe),xt.g,xt.b),Ge.name):$e=="g"?pe(new _e(xt.r,parseFloat(qe),xt.b),Ge.name):pe(new _e(xt.r,xt.g,parseFloat(qe)),Ge.name))}function We(Ge){i.savedColors&&i.savedColors.splice(Ge,1),i.savedColors&&i.savedColors.length==0&&(we(!1),Z=!1)}function je(){if(i.savedColors&&i.savedColors[se]){if(Z)var Ge="b";else var Ge="";var $e=_a.CreateSimpleButton("Swatch_"+se,Ge);$e.fontFamily="BabylonJSglyphs";var qe=_e.FromHexString(i.savedColors[se]),Ft=qe.r+qe.g+qe.b;Ft>O?$e.color=A:$e.color=M,$e.fontSize=Math.floor(f*.7),$e.textBlock.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,$e.height=$e.width=f.toString()+"px",$e.background=i.savedColors[se],$e.thickness=2;var xt=se;return $e.pointerDownAnimation=function(){$e.thickness=4},$e.pointerUpAnimation=function(){$e.thickness=3},$e.pointerEnterAnimation=function(){$e.thickness=3},$e.pointerOutAnimation=function(){$e.thickness=2},$e.onPointerClickObservable.add(function(){Z?(We(xt),ft("",ri)):i.savedColors&&pe(_e.FromHexString(i.savedColors[xt]),$e.name)}),$e}else return null}function Xe(Ge){if(Ge!==void 0&&(Z=Ge),Z){for(var $e=0;$e<H.children.length;$e++){var qe=H.children[$e];qe.textBlock.text="b"}V!==void 0&&(V.textBlock.text="Done")}else{for(var $e=0;$e<H.children.length;$e++){var qe=H.children[$e];qe.textBlock.text=""}V!==void 0&&(V.textBlock.text="Edit")}}function ft(Ge,$e){if(i.savedColors){Ge!=""&&i.savedColors.push(Ge),se=0,H.clearControls();var qe=Math.ceil(i.savedColors.length/i.numSwatchesPerLine);if(qe==0)var Ft=0;else var Ft=qe+1;if(H.rowCount!=qe+Ft){for(var xt=H.rowCount,Bt=0;Bt<xt;Bt++)H.removeRowDefinition(0);for(var Bt=0;Bt<qe+Ft;Bt++)Bt%2?H.addRowDefinition(f,!0):H.addRowDefinition(l,!0)}H.height=(f*qe+Ft*l).toString()+"px";for(var ai=1,yi=1;ai<qe+Ft;ai+=2,yi++){if(i.savedColors.length>yi*i.numSwatchesPerLine)var Dt=i.numSwatchesPerLine;else var Dt=i.savedColors.length-(yi-1)*i.numSwatchesPerLine;for(var pi=Math.min(Math.max(Dt,0),i.numSwatchesPerLine),Di=0,Ei=1;Di<pi;Di++)if(!(Di>i.numSwatchesPerLine)){var ci=je();if(ci!=null)H.addControl(ci,ai,Ei),Ei+=2,se++;else continue}}i.savedColors.length>=i.swatchLimit?Ye($e,!0):Ye($e,!1)}}function we(Ge){Ge?(V=_a.CreateSimpleButton("butEdit","Edit"),V.width=B,V.height=z,V.left=Math.floor(parseInt(B)*.1).toString()+"px",V.top=(parseFloat(V.left)*-1).toString()+"px",V.verticalAlignment=ot.VERTICAL_ALIGNMENT_BOTTOM,V.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,V.thickness=2,V.color=p,V.fontSize=U,V.background=_,V.onPointerEnterObservable.add(function(){V.background=g}),V.onPointerOutObservable.add(function(){V.background=_}),V.pointerDownAnimation=function(){V.background=v},V.pointerUpAnimation=function(){V.background=g},V.onPointerClickObservable.add(function(){Z?Z=!1:Z=!0,Xe()}),er.addControl(V,1,0)):er.removeControl(V)}function Ye(Ge,$e){$e?(Ge.color=E,Ge.background=T):(Ge.color=p,Ge.background=_)}function tt(Ge){i.savedColors&&i.savedColors.length>0?r({savedColors:i.savedColors,pickedColor:Ge}):r({pickedColor:Ge}),e.removeControl(lt)}var lt=new un;if(lt.name="Dialog Container",lt.width=i.pickerWidth,i.savedColors){lt.height=h;var yt=parseInt(i.pickerHeight)/parseInt(h);lt.addRowDefinition(yt,!1),lt.addRowDefinition(1-yt,!1)}else lt.height=i.pickerHeight,lt.addRowDefinition(1,!1);if(e.addControl(lt),i.savedColors){H=new un,H.name="Swatch Drawer",H.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,H.background=_,H.width=i.pickerWidth;var bt=i.savedColors.length/i.numSwatchesPerLine;if(bt==0)var Yt=0;else var Yt=bt+1;H.height=(f*bt+Yt*l).toString()+"px",H.top=Math.floor(f*.25).toString()+"px";for(var Ut=0;Ut<Math.ceil(i.savedColors.length/i.numSwatchesPerLine)*2+1;Ut++)Ut%2!=0?H.addRowDefinition(f,!0):H.addRowDefinition(l,!0);for(var Ut=0;Ut<i.numSwatchesPerLine*2+1;Ut++)Ut%2!=0?H.addColumnDefinition(f,!0):H.addColumnDefinition(l,!0);lt.addControl(H,1,0)}var ei=new un;ei.name="Picker Panel",ei.height=i.pickerHeight;var ar=parseInt(i.headerHeight)/parseInt(i.pickerHeight),xi=[ar,1-ar];ei.addRowDefinition(xi[0],!1),ei.addRowDefinition(xi[1],!1),lt.addControl(ei,0,0);var si=new lo;si.name="Dialogue Header Bar",si.background="#cccccc",si.thickness=0,ei.addControl(si,0,0);var Kt=_a.CreateSimpleButton("closeButton","a");Kt.fontFamily="BabylonJSglyphs";var sr=_e.FromHexString(si.background);D=new _e(1-sr.r,1-sr.g,1-sr.b),Kt.color=D.toHexString(),Kt.fontSize=Math.floor(parseInt(i.headerHeight)*.6),Kt.textBlock.textVerticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,Kt.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_RIGHT,Kt.height=Kt.width=i.headerHeight,Kt.background=si.background,Kt.thickness=0,Kt.pointerDownAnimation=function(){},Kt.pointerUpAnimation=function(){Kt.background=si.background},Kt.pointerEnterAnimation=function(){Kt.color=si.background,Kt.background="red"},Kt.pointerOutAnimation=function(){Kt.color=D.toHexString(),Kt.background=si.background},Kt.onPointerClickObservable.add(function(){tt(Fi.background)}),ei.addControl(Kt,0,0);var Wt=new un;Wt.name="Dialogue Body",Wt.background=_;var lr=[.4375,.5625];Wt.addRowDefinition(1,!1),Wt.addColumnDefinition(lr[0],!1),Wt.addColumnDefinition(lr[1],!1),ei.addControl(Wt,1,0);var er=new un;er.name="Picker Grid",er.addRowDefinition(.85,!1),er.addRowDefinition(.15,!1),Wt.addControl(er,0,0),q=new t,q.name="GUI Color Picker",i.pickerHeight<i.pickerWidth?q.width=.89:q.height=.89,q.value=_e.FromHexString(i.lastColor),q.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,q.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,q.onPointerDownObservable.add(function(){ee=q.name,Se="",Xe(!1)}),q.onValueChangedObservable.add(function(Ge){ee==q.name&&pe(Ge,q.name)}),er.addControl(q,0,0);var Pi=new un;Pi.name="Dialogue Right Half",Pi.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT;var Yi=[.514,.486];Pi.addRowDefinition(Yi[0],!1),Pi.addRowDefinition(Yi[1],!1),Wt.addControl(Pi,1,1);var Ai=new un;Ai.name="Swatches and Buttons";var nn=[.417,.583];Ai.addRowDefinition(1,!1),Ai.addColumnDefinition(nn[0],!1),Ai.addColumnDefinition(nn[1],!1),Pi.addControl(Ai,0,0);var ur=new un;ur.name="New and Current Swatches";var pr=[.04,.16,.64,.16];ur.addRowDefinition(pr[0],!1),ur.addRowDefinition(pr[1],!1),ur.addRowDefinition(pr[2],!1),ur.addRowDefinition(pr[3],!1),Ai.addControl(ur,0,0);var zi=new un;zi.name="Active Swatches",zi.width=.67,zi.addRowDefinition(.5,!1),zi.addRowDefinition(.5,!1),ur.addControl(zi,2,0);var Sr=Math.floor(parseInt(i.pickerWidth)*lr[1]*nn[0]*.11),dn=Math.floor(parseInt(i.pickerHeight)*xi[1]*Yi[0]*pr[1]*.5);if(i.pickerWidth>i.pickerHeight)var tr=dn;else var tr=Sr;var kr=new Mn;kr.text="new",kr.name="New Color Label",kr.color=p,kr.fontSize=tr,ur.addControl(kr,1,0),fe=new lo,fe.name="New Color Swatch",fe.background=i.lastColor,fe.thickness=0,zi.addControl(fe,0,0);var Fi=_a.CreateSimpleButton("currentSwatch","");Fi.background=i.lastColor,Fi.thickness=0,Fi.onPointerClickObservable.add(function(){var Ge=_e.FromHexString(Fi.background);pe(Ge,Fi.name),Xe(!1)}),Fi.pointerDownAnimation=function(){},Fi.pointerUpAnimation=function(){},Fi.pointerEnterAnimation=function(){},Fi.pointerOutAnimation=function(){},zi.addControl(Fi,1,0);var Lr=new lo;Lr.name="Swatch Outline",Lr.width=.67,Lr.thickness=2,Lr.color=S,Lr.isHitTestVisible=!1,ur.addControl(Lr,2,0);var Ki=new Mn;Ki.name="Current Color Label",Ki.text="current",Ki.color=p,Ki.fontSize=tr,ur.addControl(Ki,3,0);var Ii=new un;Ii.name="Button Grid",Ii.height=.8;var _r=1/3;Ii.addRowDefinition(_r,!1),Ii.addRowDefinition(_r,!1),Ii.addRowDefinition(_r,!1),Ai.addControl(Ii,0,1),B=Math.floor(parseInt(i.pickerWidth)*lr[1]*nn[1]*.67).toString()+"px",z=Math.floor(parseInt(i.pickerHeight)*xi[1]*Yi[0]*(parseFloat(Ii.height.toString())/100)*_r*.7).toString()+"px",parseFloat(B)>parseFloat(z)?U=Math.floor(parseFloat(z)*.45):U=Math.floor(parseFloat(B)*.11);var vi=_a.CreateSimpleButton("butOK","OK");vi.width=B,vi.height=z,vi.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,vi.thickness=2,vi.color=p,vi.fontSize=U,vi.background=_,vi.onPointerEnterObservable.add(function(){vi.background=g}),vi.onPointerOutObservable.add(function(){vi.background=_}),vi.pointerDownAnimation=function(){vi.background=v},vi.pointerUpAnimation=function(){vi.background=g},vi.onPointerClickObservable.add(function(){Xe(!1),tt(fe.background)}),Ii.addControl(vi,0,0);var fi=_a.CreateSimpleButton("butCancel","Cancel");if(fi.width=B,fi.height=z,fi.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,fi.thickness=2,fi.color=p,fi.fontSize=U,fi.background=_,fi.onPointerEnterObservable.add(function(){fi.background=g}),fi.onPointerOutObservable.add(function(){fi.background=_}),fi.pointerDownAnimation=function(){fi.background=v},fi.pointerUpAnimation=function(){fi.background=g},fi.onPointerClickObservable.add(function(){Xe(!1),tt(Fi.background)}),Ii.addControl(fi,1,0),i.savedColors){var ri=_a.CreateSimpleButton("butSave","Save");ri.width=B,ri.height=z,ri.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,ri.thickness=2,ri.fontSize=U,i.savedColors.length<i.swatchLimit?(ri.color=p,ri.background=_):Ye(ri,!0),ri.onPointerEnterObservable.add(function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(ri.background=g)}),ri.onPointerOutObservable.add(function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(ri.background=_)}),ri.pointerDownAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(ri.background=v)},ri.pointerUpAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(ri.background=g)},ri.onPointerClickObservable.add(function(){i.savedColors&&(i.savedColors.length==0&&we(!0),i.savedColors.length<i.swatchLimit&&ft(fe.background,ri),Xe(!1))}),i.savedColors.length>0&&we(!0),Ii.addControl(ri,2,0)}var ve=new un;ve.name="Dialog Lower Right",ve.addRowDefinition(.02,!1),ve.addRowDefinition(.63,!1),ve.addRowDefinition(.21,!1),ve.addRowDefinition(.14,!1),Pi.addControl(ve,1,0),ae=_e.FromHexString(i.lastColor);var le=new un;le.name="RGB Values",le.width=.82,le.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,le.addRowDefinition(1/3,!1),le.addRowDefinition(1/3,!1),le.addRowDefinition(1/3,!1),le.addColumnDefinition(.1,!1),le.addColumnDefinition(.2,!1),le.addColumnDefinition(.7,!1),ve.addControl(le,1,0);for(var Ut=0;Ut<J.length;Ut++){var Le=new Mn;Le.text=J[Ut],Le.color=p,Le.fontSize=U,le.addControl(Le,Ut,0)}F=new ma,F.width=.83,F.height=.72,F.name="rIntField",F.fontSize=U,F.text=(ae.r*255).toString(),F.color=re,F.background=X,F.onFocusObservable.add(function(){ee=F.name,Se=F.text,Xe(!1)}),F.onBlurObservable.add(function(){F.text==""&&(F.text="0"),Pe(F,"r"),ee==F.name&&(ee="")}),F.onTextChangedObservable.add(function(){ee==F.name&&Pe(F,"r")}),le.addControl(F,0,1),W=new ma,W.width=.83,W.height=.72,W.name="gIntField",W.fontSize=U,W.text=(ae.g*255).toString(),W.color=re,W.background=X,W.onFocusObservable.add(function(){ee=W.name,Se=W.text,Xe(!1)}),W.onBlurObservable.add(function(){W.text==""&&(W.text="0"),Pe(W,"g"),ee==W.name&&(ee="")}),W.onTextChangedObservable.add(function(){ee==W.name&&Pe(W,"g")}),le.addControl(W,1,1),$=new ma,$.width=.83,$.height=.72,$.name="bIntField",$.fontSize=U,$.text=(ae.b*255).toString(),$.color=re,$.background=X,$.onFocusObservable.add(function(){ee=$.name,Se=$.text,Xe(!1)}),$.onBlurObservable.add(function(){$.text==""&&($.text="0"),Pe($,"b"),ee==$.name&&(ee="")}),$.onTextChangedObservable.add(function(){ee==$.name&&Pe($,"b")}),le.addControl($,2,1),L=new ma,L.width=.95,L.height=.72,L.name="rDecField",L.fontSize=U,L.text=ae.r.toString(),L.color=re,L.background=X,L.onFocusObservable.add(function(){ee=L.name,Se=L.text,Xe(!1)}),L.onBlurObservable.add(function(){(parseFloat(L.text)==0||L.text=="")&&(L.text="0",xe(L,"r")),ee==L.name&&(ee="")}),L.onTextChangedObservable.add(function(){ee==L.name&&xe(L,"r")}),le.addControl(L,0,2),G=new ma,G.width=.95,G.height=.72,G.name="gDecField",G.fontSize=U,G.text=ae.g.toString(),G.color=re,G.background=X,G.onFocusObservable.add(function(){ee=G.name,Se=G.text,Xe(!1)}),G.onBlurObservable.add(function(){(parseFloat(G.text)==0||G.text=="")&&(G.text="0",xe(G,"g")),ee==G.name&&(ee="")}),G.onTextChangedObservable.add(function(){ee==G.name&&xe(G,"g")}),le.addControl(G,1,2),Y=new ma,Y.width=.95,Y.height=.72,Y.name="bDecField",Y.fontSize=U,Y.text=ae.b.toString(),Y.color=re,Y.background=X,Y.onFocusObservable.add(function(){ee=Y.name,Se=Y.text,Xe(!1)}),Y.onBlurObservable.add(function(){(parseFloat(Y.text)==0||Y.text=="")&&(Y.text="0",xe(Y,"b")),ee==Y.name&&(ee="")}),Y.onTextChangedObservable.add(function(){ee==Y.name&&xe(Y,"b")}),le.addControl(Y,2,2);var be=new un;be.name="Hex Value",be.width=.82,be.addRowDefinition(1,!1),be.addColumnDefinition(.1,!1),be.addColumnDefinition(.9,!1),ve.addControl(be,2,0);var Le=new Mn;Le.text="#",Le.color=p,Le.fontSize=U,be.addControl(Le,0,0),Q=new ma,Q.width=.96,Q.height=.72,Q.name="hexField",Q.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,Q.fontSize=U;var Ne=i.lastColor.split("#");Q.text=Ne[1],Q.color=re,Q.background=X,Q.onFocusObservable.add(function(){ee=Q.name,Se=Q.text,Xe(!1)}),Q.onBlurObservable.add(function(){if(Q.text.length==3){var Ge=Q.text.split("");Q.text=Ge[0]+Ge[0]+Ge[1]+Ge[1]+Ge[2]+Ge[2]}Q.text==""&&(Q.text="000000",pe(_e.FromHexString(Q.text),"b")),ee==Q.name&&(ee="")}),Q.onTextChangedObservable.add(function(){var Ge=Q.text,$e=/[^0-9A-F]/i.test(Ge);if((Q.text.length>6||$e)&&ee==Q.name)Q.text=Se;else{if(Q.text.length<6)for(var qe=6-Q.text.length,Ft=0;Ft<qe;Ft++)Ge="0"+Ge;if(Q.text.length==3){var xt=Q.text.split("");Ge=xt[0]+xt[0]+xt[1]+xt[1]+xt[2]+xt[2]}Ge="#"+Ge,ee==Q.name&&(Se=Q.text,pe(_e.FromHexString(Ge),Q.name))}}),be.addControl(Q,0,1),i.savedColors&&i.savedColors.length>0&&ft("",ri)})},t._Epsilon=1e-6,t}(ot);Ae.RegisteredTypes["BABYLON.GUI.ColorPicker"]=gX;var vX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._thickness=1,i}return Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Ellipse"},t.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),ot.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),this._background&&(e.fillStyle=this._background,e.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.stroke()),e.restore()},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},t.prototype._clipForChildren=function(e){ot.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,e),e.clip()},t}(so);Ae.RegisteredTypes["BABYLON.GUI.Ellipse"]=vX;var yX=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype._beforeRenderText=function(e){for(var i=new By,r="",o=0;o<e.length;o++)r+="•";return i.text=r,i},t}(ma);Ae.RegisteredTypes["BABYLON.GUI.InputPassword"]=yX;var bX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._lineWidth=1,i._x1=new zt(0),i._y1=new zt(0),i._x2=new zt(0),i._y2=new zt(0),i._dash=new Array,i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,i}return Object.defineProperty(t.prototype,"dash",{get:function(){return this._dash},set:function(e){this._dash!==e&&(this._dash=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectedControl",{get:function(){return this._connectedControl},set:function(e){var i=this;this._connectedControl!==e&&(this._connectedControlDirtyObserver&&this._connectedControl&&(this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver),this._connectedControlDirtyObserver=null),e&&(this._connectedControlDirtyObserver=e.onDirtyObservable.add(function(){return i._markAsDirty()})),this._connectedControl=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x1",{get:function(){return this._x1.toString(this._host)},set:function(e){this._x1.toString(this._host)!==e&&this._x1.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y1",{get:function(){return this._y1.toString(this._host)},set:function(e){this._y1.toString(this._host)!==e&&this._y1.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x2",{get:function(){return this._x2.toString(this._host)},set:function(e){this._x2.toString(this._host)!==e&&this._x2.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y2",{get:function(){return this._y2.toString(this._host)},set:function(e){this._y2.toString(this._host)!==e&&this._y2.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(e){this._lineWidth!==e&&(this._lineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Line"},t.prototype._draw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath(),e.moveTo(this._cachedParentMeasure.left+this._x1.getValue(this._host),this._cachedParentMeasure.top+this._y1.getValue(this._host)),e.lineTo(this._cachedParentMeasure.left+this._effectiveX2,this._cachedParentMeasure.top+this._effectiveY2),e.stroke(),e.restore()},t.prototype._measure=function(){this._currentMeasure.width=Math.abs(this._x1.getValue(this._host)-this._effectiveX2)+this._lineWidth,this._currentMeasure.height=Math.abs(this._y1.getValue(this._host)-this._effectiveY2)+this._lineWidth},t.prototype._computeAlignment=function(e,i){this._currentMeasure.left=e.left+Math.min(this._x1.getValue(this._host),this._effectiveX2)-this._lineWidth/2,this._currentMeasure.top=e.top+Math.min(this._y1.getValue(this._host),this._effectiveY2)-this._lineWidth/2},t.prototype.moveToVector3=function(e,i,r){if(r===void 0&&(r=!1),!this._host||this.parent!==this._host._rootContainer){Ee.Error("Cannot move a control to a vector3 if the control is not at root level");return}var o=this._host._getGlobalViewport(i),a=y.Project(e,te.Identity(),i.getTransformMatrix(),o);if(this._moveToProjectedPosition(a,r),a.z<0||a.z>1){this.notRenderable=!0;return}this.notRenderable=!1},t.prototype._moveToProjectedPosition=function(e,i){i===void 0&&(i=!1);var r=e.x+this._linkOffsetX.getValue(this._host)+"px",o=e.y+this._linkOffsetY.getValue(this._host)+"px";i?(this.x2=r,this.y2=o,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=r,this.y1=o,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.Line"]=bX;var jO=function(){function n(t){this._multiLine=t,this._x=new zt(0),this._y=new zt(0),this._point=new y(0,0,0)}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(t){this._x.toString(this._multiLine._host)!==t&&this._x.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(t){this._y.toString(this._multiLine._host)!==t&&this._y.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"control",{get:function(){return this._control},set:function(t){this._control!==t&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=t,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"mesh",{get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=t,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),n.prototype.resetLinks=function(){this.control=null,this.mesh=null},n.prototype.translate=function(){return this._point=this._translatePoint(),this._point},n.prototype._translatePoint=function(){if(this._mesh!=null)return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(this._control!=null)return new y(this._control.centerX,this._control.centerY,1-Zt);var t=this._multiLine._host,e=this._x.getValueInPixel(t,Number(t._canvas.width)),i=this._y.getValueInPixel(t,Number(t._canvas.height));return new y(e,i,1-Zt)},n.prototype.dispose=function(){this.resetLinks()},n}(),EX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return Object.defineProperty(t.prototype,"dash",{get:function(){return this._dash},set:function(e){this._dash!==e&&(this._dash=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype.getAt=function(e){return this._points[e]||(this._points[e]=new jO(this)),this._points[e]},t.prototype.add=function(){for(var e=this,i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];return i.map(function(o){return e.push(o)})},t.prototype.push=function(e){var i=this.getAt(this._points.length);return e==null||(e instanceof Ht?i.mesh=e:e instanceof ot?i.control=e:e.x!=null&&e.y!=null&&(i.x=e.x,i.y=e.y)),i},t.prototype.remove=function(e){var i;if(e instanceof jO){if(i=this._points.indexOf(e),i===-1)return}else i=e;var r=this._points[i];r&&(r.dispose(),this._points.splice(i,1))},t.prototype.reset=function(){for(;this._points.length>0;)this.remove(this._points.length-1)},t.prototype.resetLinks=function(){this._points.forEach(function(e){e!=null&&e.resetLinks()})},Object.defineProperty(t.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(e){this._lineWidth!==e&&(this._lineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"MultiLine"},t.prototype._draw=function(e,i){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath();var r=!0,o;this._points.forEach(function(a){a&&(r?(e.moveTo(a._point.x,a._point.y),r=!1):a._point.z<1&&o.z<1?e.lineTo(a._point.x,a._point.y):e.moveTo(a._point.x,a._point.y),o=a._point)}),e.stroke(),e.restore()},t.prototype._additionalProcessing=function(e,i){var r=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach(function(o,a){o&&(o.translate(),(r._minX==null||o._point.x<r._minX)&&(r._minX=o._point.x),(r._minY==null||o._point.y<r._minY)&&(r._minY=o._point.y),(r._maxX==null||o._point.x>r._maxX)&&(r._maxX=o._point.x),(r._maxY==null||o._point.y>r._maxY)&&(r._maxY=o._point.y))}),this._minX==null&&(this._minX=0),this._minY==null&&(this._minY=0),this._maxX==null&&(this._maxX=0),this._maxY==null&&(this._maxY=0)},t.prototype._measure=function(){this._minX==null||this._maxX==null||this._minY==null||this._maxY==null||(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},t.prototype._computeAlignment=function(e,i){this._minX==null||this._minY==null||(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},t.prototype.dispose=function(){this.reset(),n.prototype.dispose.call(this)},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.MultiLine"]=EX;var ZI=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.group="",i.onIsCheckedChangedObservable=new ie,i.isPointerBlocker=!0,i}return Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(e){e=Math.max(Math.min(1,e),0),this._checkSizeRatio!==e&&(this._checkSizeRatio=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isChecked",{get:function(){return this._isChecked},set:function(e){var i=this;this._isChecked!==e&&(this._isChecked=e,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(e),this._isChecked&&this._host&&this._host.executeOnAllControls(function(r){if(r!==i&&r.group!==void 0){var o=r;o.group===i.group&&(o.isChecked=!1)}}))},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"RadioButton"},t.prototype._draw=function(e){e.save(),this._applyStates(e);var i=this._currentMeasure.width-this._thickness,r=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),ot.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this.color,e.lineWidth=this._thickness,e.stroke(),this._isChecked){e.fillStyle=this._isEnabled?this.color:this._disabledColor;var o=i*this._checkSizeRatio,a=r*this._checkSizeRatio;ot.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,o/2-this._thickness/2,a/2-this._thickness/2,e),e.fill()}e.restore()},t.prototype._onPointerDown=function(e,i,r,o,a){return n.prototype._onPointerDown.call(this,e,i,r,o,a)?(this.isChecked||(this.isChecked=!0),!0):!1},t.AddRadioButtonWithHeader=function(e,i,r,o){var a=new Pa;a.isVertical=!1,a.height="30px";var s=new t;s.width="20px",s.height="20px",s.isChecked=r,s.color="green",s.group=i,s.onIsCheckedChangedObservable.add(function(u){return o(s,u)}),a.addControl(s);var l=new Mn;return l.text=e,l.width="180px",l.paddingLeft="5px",l.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,l.color="white",a.addControl(l),a},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.RadioButton"]=ZI;var bp=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._thumbWidth=new zt(20,zt.UNITMODE_PIXEL,!1),i._minimum=0,i._maximum=100,i._value=50,i._isVertical=!1,i._barOffset=new zt(5,zt.UNITMODE_PIXEL,!1),i._isThumbClamped=!1,i._displayThumb=!0,i._step=0,i._lastPointerDownID=-1,i._effectiveBarOffset=0,i.onValueChangedObservable=new ie,i._pointerIsDown=!1,i.isPointerBlocker=!0,i}return Object.defineProperty(t.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(e){this._displayThumb!==e&&(this._displayThumb=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"step",{get:function(){return this._step},set:function(e){this._step!==e&&(this._step=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(e){this._barOffset.toString(this._host)!==e&&this._barOffset.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(e){this._thumbWidth.toString(this._host)!==e&&this._thumbWidth.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minimum",{get:function(){return this._minimum},set:function(e){this._minimum!==e&&(this._minimum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maximum",{get:function(){return this._maximum},set:function(e){this._maximum!==e&&(this._maximum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(e){e=Math.max(Math.min(e,this._maximum),this._minimum),this._value!==e&&(this._value=e,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(e){this._isThumbClamped!==e&&(this._isThumbClamped=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"BaseSlider"},t.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},t.prototype._getThumbThickness=function(e){var i=0;switch(e){case"circle":this._thumbWidth.isPixel?i=Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):i=this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":this._thumbWidth.isPixel?i=Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):i=this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return i},t.prototype._prepareRenderingData=function(e){if(this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(e),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height<this._currentMeasure.width){console.error("Height should be greater than width");return}this._barOffset.isPixel?this._effectiveBarOffset=Math.min(this._barOffset.getValue(this._host),this._backgroundBoxThickness):this._effectiveBarOffset=this._backgroundBoxThickness*this._barOffset.getValue(this._host),this._backgroundBoxThickness-=this._effectiveBarOffset*2,this.isVertical?(this._renderLeft+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderTop+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxLength,this._renderWidth=this._backgroundBoxThickness):(this._renderTop+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderLeft+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxThickness,this._renderWidth=this._backgroundBoxLength)},t.prototype._updateValueFromPointer=function(e,i){this.rotation!=0&&(this._invertTransformMatrix.transformCoordinates(e,i,this._transformedPosition),e=this._transformedPosition.x,i=this._transformedPosition.y);var r;this._isVertical?r=this._minimum+(1-(i-this._currentMeasure.top)/this._currentMeasure.height)*(this._maximum-this._minimum):r=this._minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this._maximum-this._minimum);var o=1/this._step|0;this.value=this._step?(r*o|0)/o:r},t.prototype._onPointerDown=function(e,i,r,o,a){return n.prototype._onPointerDown.call(this,e,i,r,o,a)?(this._pointerIsDown=!0,this._updateValueFromPointer(i.x,i.y),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0):!1},t.prototype._onPointerMove=function(e,i,r,o){r==this._lastPointerDownID&&(this._pointerIsDown&&this._updateValueFromPointer(i.x,i.y),n.prototype._onPointerMove.call(this,e,i,r,o))},t.prototype._onPointerUp=function(e,i,r,o,a){this._pointerIsDown=!1,delete this._host._capturingControl[r],n.prototype._onPointerUp.call(this,e,i,r,o,a)},t.prototype._onCanvasBlur=function(){this._forcePointerUp(),n.prototype._onCanvasBlur.call(this)},t}(ot),JI=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._thumbColor="",i._isThumbCircle=!1,i._displayValueBar=!0,i}return Object.defineProperty(t.prototype,"displayValueBar",{get:function(){return this._displayValueBar},set:function(e){this._displayValueBar!==e&&(this._displayValueBar=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"borderColor",{get:function(){return this._borderColor},set:function(e){this._borderColor!==e&&(this._borderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbColor",{get:function(){return this._thumbColor},set:function(e){this._thumbColor!==e&&(this._thumbColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isThumbCircle",{get:function(){return this._isThumbCircle},set:function(e){this._isThumbCircle!==e&&(this._isThumbCircle=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Slider"},t.prototype._draw=function(e,i){e.save(),this._applyStates(e),this._prepareRenderingData(this.isThumbCircle?"circle":"rectangle");var r=this._renderLeft,o=this._renderTop,a=this._renderWidth,s=this._renderHeight,l=0;this.isThumbClamped&&this.isThumbCircle?(this.isVertical?o+=this._effectiveThumbThickness/2:r+=this._effectiveThumbThickness/2,l=this._backgroundBoxThickness/2):l=(this._effectiveThumbThickness-this._effectiveBarOffset)/2,(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY);var u=this._getThumbPosition();e.fillStyle=this._background,this.isVertical?this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(r+this._backgroundBoxThickness/2,o,l,Math.PI,2*Math.PI),e.fill(),e.fillRect(r,o,a,s)):e.fillRect(r,o,a,s+this._effectiveThumbThickness):e.fillRect(r,o,a,s):this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(r+this._backgroundBoxLength,o+this._backgroundBoxThickness/2,l,0,2*Math.PI),e.fill(),e.fillRect(r,o,a,s)):e.fillRect(r,o,a+this._effectiveThumbThickness,s):e.fillRect(r,o,a,s),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.fillStyle=this.color,this._displayValueBar&&(this.isVertical?this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(r+this._backgroundBoxThickness/2,o+this._backgroundBoxLength,l,0,2*Math.PI),e.fill(),e.fillRect(r,o+u,a,s-u)):e.fillRect(r,o+u,a,s-u+this._effectiveThumbThickness):e.fillRect(r,o+u,a,s-u):(this.isThumbClamped&&this.isThumbCircle&&(e.beginPath(),e.arc(r,o+this._backgroundBoxThickness/2,l,0,2*Math.PI),e.fill()),e.fillRect(r,o,u,s))),e.fillStyle=this._thumbColor||this.color,this.displayThumb&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._isThumbCircle?(e.beginPath(),this.isVertical?e.arc(r+this._backgroundBoxThickness/2,o+u,l,0,2*Math.PI):e.arc(r+u,o+this._backgroundBoxThickness/2,l,0,2*Math.PI),e.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this._borderColor,e.stroke()):(this.isVertical?e.fillRect(r-this._effectiveBarOffset,this._currentMeasure.top+u,this._currentMeasure.width,this._effectiveThumbThickness):e.fillRect(this._currentMeasure.left+u,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this._borderColor,this.isVertical?e.strokeRect(r-this._effectiveBarOffset,this._currentMeasure.top+u,this._currentMeasure.width,this._effectiveThumbThickness):e.strokeRect(this._currentMeasure.left+u,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height))),e.restore()},t}(bp);Ae.RegisteredTypes["BABYLON.GUI.Slider"]=JI;var Zb=function(){function n(t){this.name=t,this._groupPanel=new Pa,this._selectors=new Array,this._groupPanel.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,this._groupPanel.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,this._groupHeader=this._addGroupHeader(t)}return Object.defineProperty(n.prototype,"groupPanel",{get:function(){return this._groupPanel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"selectors",{get:function(){return this._selectors},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"header",{get:function(){return this._groupHeader.text},set:function(t){this._groupHeader.text!=="label"&&(this._groupHeader.text=t)},enumerable:!1,configurable:!0}),n.prototype._addGroupHeader=function(t){var e=new Mn("groupHead",t);return e.width=.9,e.height="30px",e.textWrapping=!0,e.color="black",e.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,e.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,e.left="2px",this._groupPanel.addControl(e),e},n.prototype._getSelector=function(t){if(!(t<0||t>=this._selectors.length))return this._selectors[t]},n.prototype.removeSelector=function(t){t<0||t>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[t]),this._selectors.splice(t,1))},n}(),G8=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.addCheckbox=function(e,i,o){i===void 0&&(i=function(l){}),o===void 0&&(o=!1);var o=o||!1,a=new $I;a.width="20px",a.height="20px",a.color="#364249",a.background="#CCCCCC",a.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,a.onIsCheckedChangedObservable.add(function(l){i(l)});var s=ot.AddHeader(a,e,"200px",{isHorizontal:!0,controlFirst:!0});s.height="30px",s.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,s.left="4px",this.groupPanel.addControl(s),this.selectors.push(s),a.isChecked=o,this.groupPanel.parent&&this.groupPanel.parent.parent&&(a.color=this.groupPanel.parent.parent.buttonColor,a.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,i){this.selectors[e].children[1].text=i},t.prototype._setSelectorLabelColor=function(e,i){this.selectors[e].children[1].color=i},t.prototype._setSelectorButtonColor=function(e,i){this.selectors[e].children[0].color=i},t.prototype._setSelectorButtonBackground=function(e,i){this.selectors[e].children[0].background=i},t}(Zb),W8=function(n){j(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._selectNb=0,e}return t.prototype.addRadio=function(e,i,r){i===void 0&&(i=function(l){}),r===void 0&&(r=!1);var o=this._selectNb++,a=new ZI;a.name=e,a.width="20px",a.height="20px",a.color="#364249",a.background="#CCCCCC",a.group=this.name,a.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,a.onIsCheckedChangedObservable.add(function(l){l&&i(o)});var s=ot.AddHeader(a,e,"200px",{isHorizontal:!0,controlFirst:!0});s.height="30px",s.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,s.left="4px",this.groupPanel.addControl(s),this.selectors.push(s),a.isChecked=r,this.groupPanel.parent&&this.groupPanel.parent.parent&&(a.color=this.groupPanel.parent.parent.buttonColor,a.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,i){this.selectors[e].children[1].text=i},t.prototype._setSelectorLabelColor=function(e,i){this.selectors[e].children[1].color=i},t.prototype._setSelectorButtonColor=function(e,i){this.selectors[e].children[0].color=i},t.prototype._setSelectorButtonBackground=function(e,i){this.selectors[e].children[0].background=i},t}(Zb),H8=function(n){j(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.addSlider=function(e,i,r,o,a,s,l){i===void 0&&(i=function(c){}),r===void 0&&(r="Units"),o===void 0&&(o=0),a===void 0&&(a=0),s===void 0&&(s=0),l===void 0&&(l=function(c){return c|0});var u=new JI;u.name=r,u.value=s,u.minimum=o,u.maximum=a,u.width=.9,u.height="20px",u.color="#364249",u.background="#CCCCCC",u.borderColor="black",u.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,u.left="4px",u.paddingBottom="4px",u.onValueChangedObservable.add(function(c){u.parent.children[0].text=u.parent.children[0].name+": "+l(c)+" "+u.name,i(c)});var f=ot.AddHeader(u,e+": "+l(s)+" "+r,"30px",{isHorizontal:!1,controlFirst:!1});f.height="60px",f.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,f.left="4px",f.children[0].name=e,this.groupPanel.addControl(f),this.selectors.push(f),this.groupPanel.parent&&this.groupPanel.parent.parent&&(u.color=this.groupPanel.parent.parent.buttonColor,u.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,i){this.selectors[e].children[0].name=i,this.selectors[e].children[0].text=i+": "+this.selectors[e].children[1].value+" "+this.selectors[e].children[1].name},t.prototype._setSelectorLabelColor=function(e,i){this.selectors[e].children[0].color=i},t.prototype._setSelectorButtonColor=function(e,i){this.selectors[e].children[1].color=i},t.prototype._setSelectorButtonBackground=function(e,i){this.selectors[e].children[1].background=i},t}(Zb),j8=function(n){j(t,n);function t(e,i){i===void 0&&(i=[]);var r=n.call(this,e)||this;if(r.name=e,r.groups=i,r._buttonColor="#364249",r._buttonBackground="#CCCCCC",r._headerColor="black",r._barColor="white",r._barHeight="2px",r._spacerHeight="20px",r._bars=new Array,r._groups=i,r.thickness=2,r._panel=new Pa,r._panel.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,r._panel.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,r._panel.top=5,r._panel.left=5,r._panel.width=.95,i.length>0){for(var o=0;o<i.length-1;o++)r._panel.addControl(i[o].groupPanel),r._addSpacer();r._panel.addControl(i[i.length-1].groupPanel)}return r.addControl(r._panel),r}return t.prototype._getTypeName=function(){return"SelectionPanel"},Object.defineProperty(t.prototype,"panel",{get:function(){return this._panel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerColor",{get:function(){return this._headerColor},set:function(e){this._headerColor!==e&&(this._headerColor=e,this._setHeaderColor())},enumerable:!1,configurable:!0}),t.prototype._setHeaderColor=function(){for(var e=0;e<this._groups.length;e++)this._groups[e].groupPanel.children[0].color=this._headerColor},Object.defineProperty(t.prototype,"buttonColor",{get:function(){return this._buttonColor},set:function(e){this._buttonColor!==e&&(this._buttonColor=e,this._setbuttonColor())},enumerable:!1,configurable:!0}),t.prototype._setbuttonColor=function(){for(var e=0;e<this._groups.length;e++)for(var i=0;i<this._groups[e].selectors.length;i++)this._groups[e]._setSelectorButtonColor(i,this._buttonColor)},Object.defineProperty(t.prototype,"labelColor",{get:function(){return this._labelColor},set:function(e){this._labelColor!==e&&(this._labelColor=e,this._setLabelColor())},enumerable:!1,configurable:!0}),t.prototype._setLabelColor=function(){for(var e=0;e<this._groups.length;e++)for(var i=0;i<this._groups[e].selectors.length;i++)this._groups[e]._setSelectorLabelColor(i,this._labelColor)},Object.defineProperty(t.prototype,"buttonBackground",{get:function(){return this._buttonBackground},set:function(e){this._buttonBackground!==e&&(this._buttonBackground=e,this._setButtonBackground())},enumerable:!1,configurable:!0}),t.prototype._setButtonBackground=function(){for(var e=0;e<this._groups.length;e++)for(var i=0;i<this._groups[e].selectors.length;i++)this._groups[e]._setSelectorButtonBackground(i,this._buttonBackground)},Object.defineProperty(t.prototype,"barColor",{get:function(){return this._barColor},set:function(e){this._barColor!==e&&(this._barColor=e,this._setBarColor())},enumerable:!1,configurable:!0}),t.prototype._setBarColor=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].children[0].background=this._barColor},Object.defineProperty(t.prototype,"barHeight",{get:function(){return this._barHeight},set:function(e){this._barHeight!==e&&(this._barHeight=e,this._setBarHeight())},enumerable:!1,configurable:!0}),t.prototype._setBarHeight=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].children[0].height=this._barHeight},Object.defineProperty(t.prototype,"spacerHeight",{get:function(){return this._spacerHeight},set:function(e){this._spacerHeight!==e&&(this._spacerHeight=e,this._setSpacerHeight())},enumerable:!1,configurable:!0}),t.prototype._setSpacerHeight=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].height=this._spacerHeight},t.prototype._addSpacer=function(){var e=new so;e.width=1,e.height=this._spacerHeight,e.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT;var i=new lo;i.width=1,i.height=this._barHeight,i.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,i.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,i.background=this._barColor,i.color="transparent",e.addControl(i),this._panel.addControl(e),this._bars.push(e)},t.prototype.addGroup=function(e){this._groups.length>0&&this._addSpacer(),this._panel.addControl(e.groupPanel),this._groups.push(e),e.groupPanel.children[0].color=this._headerColor;for(var i=0;i<e.selectors.length;i++)e._setSelectorButtonColor(i,this._buttonColor),e._setSelectorButtonBackground(i,this._buttonBackground)},t.prototype.removeGroup=function(e){if(!(e<0||e>=this._groups.length)){var i=this._groups[e];this._panel.removeControl(i.groupPanel),this._groups.splice(e,1),e<this._bars.length&&(this._panel.removeControl(this._bars[e]),this._bars.splice(e,1))}},t.prototype.setHeaderName=function(e,i){if(!(i<0||i>=this._groups.length)){var r=this._groups[i];r.groupPanel.children[0].text=e}},t.prototype.relabel=function(e,i,r){if(!(i<0||i>=this._groups.length)){var o=this._groups[i];r<0||r>=o.selectors.length||o._setSelectorLabel(r,e)}},t.prototype.removeFromGroupSelector=function(e,i){if(!(e<0||e>=this._groups.length)){var r=this._groups[e];i<0||i>=r.selectors.length||r.removeSelector(i)}},t.prototype.addToGroupCheckbox=function(e,i,r,o){if(r===void 0&&(r=function(){}),o===void 0&&(o=!1),!(e<0||e>=this._groups.length)){var a=this._groups[e];a.addCheckbox(i,r,o)}},t.prototype.addToGroupRadio=function(e,i,r,o){if(r===void 0&&(r=function(){}),o===void 0&&(o=!1),!(e<0||e>=this._groups.length)){var a=this._groups[e];a.addRadio(i,r,o)}},t.prototype.addToGroupSlider=function(e,i,r,o,a,s,l,u){if(r===void 0&&(r=function(){}),o===void 0&&(o="Units"),a===void 0&&(a=0),s===void 0&&(s=0),l===void 0&&(l=0),u===void 0&&(u=function(c){return c|0}),!(e<0||e>=this._groups.length)){var f=this._groups[e];f.addSlider(i,r,o,a,s,l,u)}},t}(lo),TX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i._freezeControls=!1,i._bucketWidth=0,i._bucketHeight=0,i._buckets={},i}return Object.defineProperty(t.prototype,"freezeControls",{get:function(){return this._freezeControls},set:function(e){if(this._freezeControls!==e){e||this._restoreMeasures(),this._freezeControls=!1;var i=this.host.getSize(),r=i.width,o=i.height,a=this.host.getContext(),s=new Jr(0,0,r,o);this.host._numLayoutCalls=0,this.host._rootContainer._layout(s,a),e&&(this._updateMeasures(),this._useBuckets()&&this._makeBuckets()),this._freezeControls=e,this.host.markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucketWidth",{get:function(){return this._bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucketHeight",{get:function(){return this._bucketHeight},enumerable:!1,configurable:!0}),t.prototype.setBucketSizes=function(e,i){this._bucketWidth=e,this._bucketHeight=i,this._useBuckets()?this._freezeControls&&this._makeBuckets():this._buckets={}},t.prototype._useBuckets=function(){return this._bucketWidth>0&&this._bucketHeight>0},t.prototype._makeBuckets=function(){this._buckets={},this._bucketLen=Math.ceil(this.widthInPixels/this._bucketWidth),this._dispatchInBuckets(this._children),this._oldLeft=null,this._oldTop=null},t.prototype._dispatchInBuckets=function(e){for(var i=0;i<e.length;++i){for(var r=e[i],o=Math.max(0,Math.floor((r._customData._origLeft-this._customData.origLeft)/this._bucketWidth)),a=Math.floor((r._customData._origLeft-this._customData.origLeft+r._currentMeasure.width-1)/this._bucketWidth),s=Math.max(0,Math.floor((r._customData._origTop-this._customData.origTop)/this._bucketHeight)),l=Math.floor((r._customData._origTop-this._customData.origTop+r._currentMeasure.height-1)/this._bucketHeight);s<=l;){for(var u=o;u<=a;++u){var f=s*this._bucketLen+u,c=this._buckets[f];c||(c=[],this._buckets[f]=c),c.push(r)}s++}r instanceof so&&r._children.length>0&&this._dispatchInBuckets(r._children)}},t.prototype._updateMeasures=function(){var e=this.leftInPixels|0,i=this.topInPixels|0;this._measureForChildren.left-=e,this._measureForChildren.top-=i,this._currentMeasure.left-=e,this._currentMeasure.top-=i,this._customData.origLeftForChildren=this._measureForChildren.left,this._customData.origTopForChildren=this._measureForChildren.top,this._customData.origLeft=this._currentMeasure.left,this._customData.origTop=this._currentMeasure.top,this._updateChildrenMeasures(this._children,e,i)},t.prototype._updateChildrenMeasures=function(e,i,r){for(var o=0;o<e.length;++o){var a=e[o];a._currentMeasure.left-=i,a._currentMeasure.top-=r,a._customData._origLeft=a._currentMeasure.left,a._customData._origTop=a._currentMeasure.top,a instanceof so&&a._children.length>0&&this._updateChildrenMeasures(a._children,i,r)}},t.prototype._restoreMeasures=function(){var e=this.leftInPixels|0,i=this.topInPixels|0;this._measureForChildren.left=this._customData.origLeftForChildren+e,this._measureForChildren.top=this._customData.origTopForChildren+i,this._currentMeasure.left=this._customData.origLeft+e,this._currentMeasure.top=this._customData.origTop+i},t.prototype._getTypeName=function(){return"ScrollViewerWindow"},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._parentMeasure=e,this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=e.width,this._measureForChildren.height=e.height},t.prototype._layout=function(e,i){return this._freezeControls?(this.invalidateRect(),!1):n.prototype._layout.call(this,e,i)},t.prototype._scrollChildren=function(e,i,r){for(var o=0;o<e.length;++o){var a=e[o];a._currentMeasure.left=a._customData._origLeft+i,a._currentMeasure.top=a._customData._origTop+r,a._isClipped=!1,a instanceof so&&a._children.length>0&&this._scrollChildren(a._children,i,r)}},t.prototype._scrollChildrenWithBuckets=function(e,i,r,o){for(var a=Math.max(0,Math.floor(-e/this._bucketWidth)),s=Math.floor((-e+this._parentMeasure.width-1)/this._bucketWidth),l=Math.max(0,Math.floor(-i/this._bucketHeight)),u=Math.floor((-i+this._parentMeasure.height-1)/this._bucketHeight);l<=u;){for(var f=a;f<=s;++f){var c=l*this._bucketLen+f,h=this._buckets[c];if(h)for(var p=0;p<h.length;++p){var _=h[p];_._currentMeasure.left=_._customData._origLeft+r,_._currentMeasure.top=_._customData._origTop+o,_._isClipped=!1}}l++}},t.prototype._draw=function(e,i){if(!this._freezeControls){n.prototype._draw.call(this,e,i);return}this._localDraw(e),this.clipChildren&&this._clipForChildren(e);var r=this.leftInPixels|0,o=this.topInPixels|0;this._useBuckets()?this._oldLeft!==null&&this._oldTop!==null?(this._scrollChildrenWithBuckets(this._oldLeft,this._oldTop,r,o),this._scrollChildrenWithBuckets(r,o,r,o)):this._scrollChildren(this._children,r,o):this._scrollChildren(this._children,r,o),this._oldLeft=r,this._oldTop=o;for(var a=0,s=this._children;a<s.length;a++){var l=s[a];l._intersectsRect(this._parentMeasure)&&l._render(e,this._parentMeasure)}},t.prototype._postMeasure=function(){if(this._freezeControls){n.prototype._postMeasure.call(this);return}for(var e=this.parentClientWidth,i=this.parentClientHeight,r=0,o=this.children;r<o.length;r++){var a=o[r];!a.isVisible||a.notRenderable||(a.horizontalAlignment===ot.HORIZONTAL_ALIGNMENT_CENTER&&a._offsetLeft(this._currentMeasure.left-a._currentMeasure.left),a.verticalAlignment===ot.VERTICAL_ALIGNMENT_CENTER&&a._offsetTop(this._currentMeasure.top-a._currentMeasure.top),e=Math.max(e,a._currentMeasure.left-this._currentMeasure.left+a._currentMeasure.width+a.paddingRightInPixels),i=Math.max(i,a._currentMeasure.top-this._currentMeasure.top+a._currentMeasure.height+a.paddingBottomInPixels))}this._currentMeasure.width!==e&&(this._width.updateInPlace(e,zt.UNITMODE_PIXEL),this._currentMeasure.width=e,this._rebuildLayout=!0,this._isDirty=!0),this._currentMeasure.height!==i&&(this._height.updateInPlace(i,zt.UNITMODE_PIXEL),this._currentMeasure.height=i,this._rebuildLayout=!0,this._isDirty=!0),n.prototype._postMeasure.call(this)},t}(so),XO=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._tempMeasure=new Jr(0,0,0,0),i}return Object.defineProperty(t.prototype,"borderColor",{get:function(){return this._borderColor},set:function(e){this._borderColor!==e&&(this._borderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Scrollbar"},t.prototype._getThumbThickness=function(){var e=0;return this._thumbWidth.isPixel?e=this._thumbWidth.getValue(this._host):e=this._backgroundBoxThickness*this._thumbWidth.getValue(this._host),e},t.prototype._draw=function(e){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var i=this._renderLeft,r=this._getThumbPosition();e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),e.fillStyle=this.color,this.isVertical?(this._tempMeasure.left=i-this._effectiveBarOffset,this._tempMeasure.top=this._currentMeasure.top+r,this._tempMeasure.width=this._currentMeasure.width,this._tempMeasure.height=this._effectiveThumbThickness):(this._tempMeasure.left=this._currentMeasure.left+r,this._tempMeasure.top=this._currentMeasure.top,this._tempMeasure.width=this._effectiveThumbThickness,this._tempMeasure.height=this._currentMeasure.height),e.fillRect(this._tempMeasure.left,this._tempMeasure.top,this._tempMeasure.width,this._tempMeasure.height),e.restore()},t.prototype._updateValueFromPointer=function(e,i){this.rotation!=0&&(this._invertTransformMatrix.transformCoordinates(e,i,this._transformedPosition),e=this._transformedPosition.x,i=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=e,this._originY=i,(e<this._tempMeasure.left||e>this._tempMeasure.left+this._tempMeasure.width||i<this._tempMeasure.top||i>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(i-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var r=0;this.isVertical?r=-((i-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness)):r=(e-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=r*(this.maximum-this.minimum),this._originX=e,this._originY=i},t.prototype._onPointerDown=function(e,i,r,o,a){return this._first=!0,n.prototype._onPointerDown.call(this,e,i,r,o,a)},t}(bp),YO=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._thumbLength=.5,i._thumbHeight=1,i._barImageHeight=1,i._tempMeasure=new Jr(0,0,0,0),i.num90RotationInVerticalMode=1,i}return Object.defineProperty(t.prototype,"backgroundImage",{get:function(){return this._backgroundBaseImage},set:function(e){var i=this;this._backgroundBaseImage!==e&&(this._backgroundBaseImage=e,this.isVertical&&this.num90RotationInVerticalMode!==0?e.isLoaded?(this._backgroundImage=e._rotate90(this.num90RotationInVerticalMode,!0),this._markAsDirty()):e.onImageLoadedObservable.addOnce(function(){var r=e._rotate90(i.num90RotationInVerticalMode,!0);i._backgroundImage=r,r.isLoaded||r.onImageLoadedObservable.addOnce(function(){i._markAsDirty()}),i._markAsDirty()}):(this._backgroundImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce(function(){i._markAsDirty()}),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbImage",{get:function(){return this._thumbBaseImage},set:function(e){var i=this;this._thumbBaseImage!==e&&(this._thumbBaseImage=e,this.isVertical&&this.num90RotationInVerticalMode!==0?e.isLoaded?(this._thumbImage=e._rotate90(-this.num90RotationInVerticalMode,!0),this._markAsDirty()):e.onImageLoadedObservable.addOnce(function(){var r=e._rotate90(-i.num90RotationInVerticalMode,!0);i._thumbImage=r,r.isLoaded||r.onImageLoadedObservable.addOnce(function(){i._markAsDirty()}),i._markAsDirty()}):(this._thumbImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce(function(){i._markAsDirty()}),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(e){this._thumbLength!==e&&(this._thumbLength=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(e){this._thumbLength!==e&&(this._thumbHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(e){this._barImageHeight!==e&&(this._barImageHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"ImageScrollBar"},t.prototype._getThumbThickness=function(){var e=0;return this._thumbWidth.isPixel?e=this._thumbWidth.getValue(this._host):e=this._backgroundBoxThickness*this._thumbWidth.getValue(this._host),e},t.prototype._draw=function(e){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var i=this._getThumbPosition(),r=this._renderLeft,o=this._renderTop,a=this._renderWidth,s=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(r,o,a,s),this.isVertical?(this._tempMeasure.copyFromFloats(r+a*(1-this._barImageHeight)*.5,this._currentMeasure.top,a*this._barImageHeight,s),this._tempMeasure.height+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)):(this._tempMeasure.copyFromFloats(this._currentMeasure.left,o+s*(1-this._barImageHeight)*.5,a,s*this._barImageHeight),this._tempMeasure.width+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)),this._backgroundImage._draw(e)),this.isVertical?this._tempMeasure.copyFromFloats(r-this._effectiveBarOffset+this._currentMeasure.width*(1-this._thumbHeight)*.5,this._currentMeasure.top+i,this._currentMeasure.width*this._thumbHeight,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+i,this._currentMeasure.top+this._currentMeasure.height*(1-this._thumbHeight)*.5,this._effectiveThumbThickness,this._currentMeasure.height*this._thumbHeight),this._thumbImage&&(this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(e)),e.restore()},t.prototype._updateValueFromPointer=function(e,i){this.rotation!=0&&(this._invertTransformMatrix.transformCoordinates(e,i,this._transformedPosition),e=this._transformedPosition.x,i=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=e,this._originY=i,(e<this._tempMeasure.left||e>this._tempMeasure.left+this._tempMeasure.width||i<this._tempMeasure.top||i>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(i-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var r=0;this.isVertical?r=-((i-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness)):r=(e-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=r*(this.maximum-this.minimum),this._originX=e,this._originY=i},t.prototype._onPointerDown=function(e,i,r,o,a){return this._first=!0,n.prototype._onPointerDown.call(this,e,i,r,o,a)},t}(bp),SX=function(n){j(t,n);function t(e,i){var r=n.call(this,e)||this;return r._barSize=20,r._pointerIsOver=!1,r._wheelPrecision=.05,r._thumbLength=.5,r._thumbHeight=1,r._barImageHeight=1,r._horizontalBarImageHeight=1,r._verticalBarImageHeight=1,r._oldWindowContentsWidth=0,r._oldWindowContentsHeight=0,r._forceHorizontalBar=!1,r._forceVerticalBar=!1,r._useImageBar=i||!1,r.onDirtyObservable.add(function(){r._horizontalBarSpace.color=r.color,r._verticalBarSpace.color=r.color,r._dragSpace.color=r.color}),r.onPointerEnterObservable.add(function(){r._pointerIsOver=!0}),r.onPointerOutObservable.add(function(){r._pointerIsOver=!1}),r._grid=new un,r._useImageBar?(r._horizontalBar=new YO,r._verticalBar=new YO):(r._horizontalBar=new XO,r._verticalBar=new XO),r._window=new TX("scrollViewer_window"),r._window.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,r._window.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,r._grid.addColumnDefinition(1),r._grid.addColumnDefinition(0,!0),r._grid.addRowDefinition(1),r._grid.addRowDefinition(0,!0),n.prototype.addControl.call(r,r._grid),r._grid.addControl(r._window,0,0),r._verticalBarSpace=new lo,r._verticalBarSpace.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,r._verticalBarSpace.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,r._verticalBarSpace.thickness=1,r._grid.addControl(r._verticalBarSpace,0,1),r._addBar(r._verticalBar,r._verticalBarSpace,!0,Math.PI),r._horizontalBarSpace=new lo,r._horizontalBarSpace.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,r._horizontalBarSpace.verticalAlignment=ot.VERTICAL_ALIGNMENT_TOP,r._horizontalBarSpace.thickness=1,r._grid.addControl(r._horizontalBarSpace,1,0),r._addBar(r._horizontalBar,r._horizontalBarSpace,!1,0),r._dragSpace=new lo,r._dragSpace.thickness=1,r._grid.addControl(r._dragSpace,1,1),r._useImageBar||(r.barColor="grey",r.barBackground="transparent"),r}return Object.defineProperty(t.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!1,configurable:!0}),t.prototype.addControl=function(e){return e?(this._window.addControl(e),this):this},t.prototype.removeControl=function(e){return this._window.removeControl(e),this},Object.defineProperty(t.prototype,"children",{get:function(){return this._window.children},enumerable:!1,configurable:!0}),t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,i=this._children;e<i.length;e++){var r=i[e];r._markMatrixAsDirty()}},Object.defineProperty(t.prototype,"freezeControls",{get:function(){return this._window.freezeControls},set:function(e){this._window.freezeControls=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucketWidth",{get:function(){return this._window.bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucketHeight",{get:function(){return this._window.bucketHeight},enumerable:!1,configurable:!0}),t.prototype.setBucketSizes=function(e,i){this._window.setBucketSizes(e,i)},Object.defineProperty(t.prototype,"forceHorizontalBar",{get:function(){return this._forceHorizontalBar},set:function(e){this._grid.setRowDefinition(1,e?this._barSize:0,!0),this._horizontalBar.isVisible=e,this._forceHorizontalBar=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forceVerticalBar",{get:function(){return this._forceVerticalBar},set:function(e){this._grid.setColumnDefinition(1,e?this._barSize:0,!0),this._verticalBar.isVisible=e,this._forceVerticalBar=e},enumerable:!1,configurable:!0}),t.prototype.resetWindow=function(){this._window.width="100%",this._window.height="100%"},t.prototype._getTypeName=function(){return"ScrollViewer"},t.prototype._buildClientSizes=function(){var e=this.host.idealRatio;this._window.parentClientWidth=this._currentMeasure.width-(this._verticalBar.isVisible||this.forceVerticalBar?this._barSize*e:0)-2*this.thickness,this._window.parentClientHeight=this._currentMeasure.height-(this._horizontalBar.isVisible||this.forceHorizontalBar?this._barSize*e:0)-2*this.thickness,this._clientWidth=this._window.parentClientWidth,this._clientHeight=this._window.parentClientHeight},t.prototype._additionalProcessing=function(e,i){n.prototype._additionalProcessing.call(this,e,i),this._buildClientSizes()},t.prototype._postMeasure=function(){n.prototype._postMeasure.call(this),this._updateScroller(),this._setWindowPosition(!1)},Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){return this._wheelPrecision},set:function(e){this._wheelPrecision!==e&&(e<0&&(e=0),e>1&&(e=1),this._wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scrollBackground",{get:function(){return this._horizontalBarSpace.background},set:function(e){this._horizontalBarSpace.background!==e&&(this._horizontalBarSpace.background=e,this._verticalBarSpace.background=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barColor",{get:function(){return this._barColor},set:function(e){this._barColor!==e&&(this._barColor=e,this._horizontalBar.color=e,this._verticalBar.color=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbImage",{get:function(){return this._barImage},set:function(e){if(this._barImage!==e){this._barImage=e;var i=this._horizontalBar,r=this._verticalBar;i.thumbImage=e,r.thumbImage=e}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalThumbImage",{get:function(){return this._horizontalBarImage},set:function(e){if(this._horizontalBarImage!==e){this._horizontalBarImage=e;var i=this._horizontalBar;i.thumbImage=e}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalThumbImage",{get:function(){return this._verticalBarImage},set:function(e){if(this._verticalBarImage!==e){this._verticalBarImage=e;var i=this._verticalBar;i.thumbImage=e}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barSize",{get:function(){return this._barSize},set:function(e){this._barSize!==e&&(this._barSize=e,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(e){if(this._thumbLength!==e){e<=0&&(e=.1),e>1&&(e=1),this._thumbLength=e;var i=this._horizontalBar,r=this._verticalBar;i.thumbLength=e,r.thumbLength=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(e){if(this._thumbHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._thumbHeight=e;var i=this._horizontalBar,r=this._verticalBar;i.thumbHeight=e,r.thumbHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(e){if(this._barImageHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._barImageHeight=e;var i=this._horizontalBar,r=this._verticalBar;i.barImageHeight=e,r.barImageHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalBarImageHeight",{get:function(){return this._horizontalBarImageHeight},set:function(e){if(this._horizontalBarImageHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._horizontalBarImageHeight=e;var i=this._horizontalBar;i.barImageHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalBarImageHeight",{get:function(){return this._verticalBarImageHeight},set:function(e){if(this._verticalBarImageHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._verticalBarImageHeight=e;var i=this._verticalBar;i.barImageHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barBackground",{get:function(){return this._barBackground},set:function(e){if(this._barBackground!==e){this._barBackground=e;var i=this._horizontalBar,r=this._verticalBar;i.background=e,r.background=e,this._dragSpace.background=e}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"barImage",{get:function(){return this._barBackgroundImage},set:function(e){this._barBackgroundImage,this._barBackgroundImage=e;var i=this._horizontalBar,r=this._verticalBar;i.backgroundImage=e,r.backgroundImage=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalBarImage",{get:function(){return this._horizontalBarBackgroundImage},set:function(e){this._horizontalBarBackgroundImage,this._horizontalBarBackgroundImage=e;var i=this._horizontalBar;i.backgroundImage=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalBarImage",{get:function(){return this._verticalBarBackgroundImage},set:function(e){this._verticalBarBackgroundImage,this._verticalBarBackgroundImage=e;var i=this._verticalBar;i.backgroundImage=e},enumerable:!1,configurable:!0}),t.prototype._setWindowPosition=function(e){e===void 0&&(e=!0);var i=this.host.idealRatio,r=this._window._currentMeasure.width,o=this._window._currentMeasure.height;if(!(!e&&this._oldWindowContentsWidth===r&&this._oldWindowContentsHeight===o)){this._oldWindowContentsWidth=r,this._oldWindowContentsHeight=o;var a=this._clientWidth-r,s=this._clientHeight-o,l=this._horizontalBar.value/i*a+"px",u=this._verticalBar.value/i*s+"px";l!==this._window.left&&(this._window.left=l,this.freezeControls||(this._rebuildLayout=!0)),u!==this._window.top&&(this._window.top=u,this.freezeControls||(this._rebuildLayout=!0))}},t.prototype._updateScroller=function(){var e=this._window._currentMeasure.width,i=this._window._currentMeasure.height;this._horizontalBar.isVisible&&e<=this._clientWidth&&!this.forceHorizontalBar?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&(e>this._clientWidth||this.forceHorizontalBar)&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&i<=this._clientHeight&&!this.forceVerticalBar?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&(i>this._clientHeight||this.forceVerticalBar)&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes();var r=this.host.idealRatio;this._horizontalBar.thumbWidth=this._thumbLength*.9*(this._clientWidth/r)+"px",this._verticalBar.thumbWidth=this._thumbLength*.9*(this._clientHeight/r)+"px"},t.prototype._link=function(e){n.prototype._link.call(this,e),this._attachWheel()},t.prototype._addBar=function(e,i,r,o){var a=this;e.paddingLeft=0,e.width="100%",e.height="100%",e.barOffset=0,e.value=0,e.maximum=1,e.horizontalAlignment=ot.HORIZONTAL_ALIGNMENT_CENTER,e.verticalAlignment=ot.VERTICAL_ALIGNMENT_CENTER,e.isVertical=r,e.rotation=o,e.isVisible=!1,i.addControl(e),e.onValueChangedObservable.add(function(s){a._setWindowPosition()})},t.prototype._attachWheel=function(){var e=this;!this._host||this._onWheelObserver||(this._onWheelObserver=this.onWheelObservable.add(function(i){e._pointerIsOver&&(e._verticalBar.isVisible==!0&&(i.y<0&&e._verticalBar.value>0?e._verticalBar.value-=e._wheelPrecision:i.y>0&&e._verticalBar.value<e._verticalBar.maximum&&(e._verticalBar.value+=e._wheelPrecision)),e._horizontalBar.isVisible==!0&&(i.x<0&&e._horizontalBar.value<e._horizontalBar.maximum?e._horizontalBar.value+=e._wheelPrecision:i.x>0&&e._horizontalBar.value>0&&(e._horizontalBar.value-=e._wheelPrecision)))}))},t.prototype._renderHighlightSpecific=function(e){this.isHighlighted&&(n.prototype._renderHighlightSpecific.call(this,e),this._grid._renderHighlightSpecific(e),e.restore())},t.prototype.dispose=function(){this.onWheelObservable.remove(this._onWheelObserver),this._onWheelObserver=null,n.prototype.dispose.call(this)},t}(lo);Ae.RegisteredTypes["BABYLON.GUI.ScrollViewer"]=SX;var X8=function(){function n(){}return n}(),CX=function(n){j(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.onKeyPressObservable=new ie,e.defaultButtonWidth="40px",e.defaultButtonHeight="40px",e.defaultButtonPaddingLeft="2px",e.defaultButtonPaddingRight="2px",e.defaultButtonPaddingTop="2px",e.defaultButtonPaddingBottom="2px",e.defaultButtonColor="#DDD",e.defaultButtonBackground="#070707",e.shiftButtonColor="#7799FF",e.selectedShiftThickness=1,e.shiftState=0,e._currentlyConnectedInputText=null,e._connectedInputTexts=[],e._onKeyPressObserver=null,e}return t.prototype._getTypeName=function(){return"VirtualKeyboard"},t.prototype._createKey=function(e,i){var r=this,o=_a.CreateSimpleButton(e,e);return o.width=i&&i.width?i.width:this.defaultButtonWidth,o.height=i&&i.height?i.height:this.defaultButtonHeight,o.color=i&&i.color?i.color:this.defaultButtonColor,o.background=i&&i.background?i.background:this.defaultButtonBackground,o.paddingLeft=i&&i.paddingLeft?i.paddingLeft:this.defaultButtonPaddingLeft,o.paddingRight=i&&i.paddingRight?i.paddingRight:this.defaultButtonPaddingRight,o.paddingTop=i&&i.paddingTop?i.paddingTop:this.defaultButtonPaddingTop,o.paddingBottom=i&&i.paddingBottom?i.paddingBottom:this.defaultButtonPaddingBottom,o.thickness=0,o.isFocusInvisible=!0,o.shadowColor=this.shadowColor,o.shadowBlur=this.shadowBlur,o.shadowOffsetX=this.shadowOffsetX,o.shadowOffsetY=this.shadowOffsetY,o.onPointerUpObservable.add(function(){r.onKeyPressObservable.notifyObservers(e)}),o},t.prototype.addKeysRow=function(e,i){var r=new Pa;r.isVertical=!1,r.isFocusInvisible=!0;for(var o=null,a=0;a<e.length;a++){var s=null;i&&i.length===e.length&&(s=i[a]);var l=this._createKey(e[a],s);(!o||l.heightInPixels>o.heightInPixels)&&(o=l),r.addControl(l)}r.height=o?o.height:this.defaultButtonHeight,this.addControl(r)},t.prototype.applyShiftState=function(e){if(this.children)for(var i=0;i<this.children.length;i++){var r=this.children[i];if(!(!r||!r.children))for(var o=r,a=0;a<o.children.length;a++){var s=o.children[a];if(!(!s||!s.children[0])){var l=s.children[0];l.text==="⇧"&&(s.color=e?this.shiftButtonColor:this.defaultButtonColor,s.thickness=e>1?this.selectedShiftThickness:0),l.text=e>0?l.text.toUpperCase():l.text.toLowerCase()}}}},Object.defineProperty(t.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!1,configurable:!0}),t.prototype.connect=function(e){var i=this,r=this._connectedInputTexts.some(function(s){return s.input===e});if(!r){this._onKeyPressObserver===null&&(this._onKeyPressObserver=this.onKeyPressObservable.add(function(s){if(i._currentlyConnectedInputText){switch(i._currentlyConnectedInputText._host.focusedControl=i._currentlyConnectedInputText,s){case"⇧":i.shiftState++,i.shiftState>2&&(i.shiftState=0),i.applyShiftState(i.shiftState);return;case"←":i._currentlyConnectedInputText.processKey(8);return;case"↵":i._currentlyConnectedInputText.processKey(13);return}i._currentlyConnectedInputText.processKey(-1,i.shiftState?s.toUpperCase():s),i.shiftState===1&&(i.shiftState=0,i.applyShiftState(i.shiftState))}})),this.isVisible=!1,this._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=this;var o=e.onFocusObservable.add(function(){i._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=i,i.isVisible=!0}),a=e.onBlurObservable.add(function(){e._connectedVirtualKeyboard=null,i._currentlyConnectedInputText=null,i.isVisible=!1});this._connectedInputTexts.push({input:e,onBlurObserver:a,onFocusObserver:o})}},t.prototype.disconnect=function(e){var i=this;if(e){var r=this._connectedInputTexts.filter(function(o){return o.input===e});r.length===1&&(this._removeConnectedInputObservables(r[0]),this._connectedInputTexts=this._connectedInputTexts.filter(function(o){return o.input!==e}),this._currentlyConnectedInputText===e&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach(function(o){i._removeConnectedInputObservables(o)}),this._connectedInputTexts=[];this._connectedInputTexts.length===0&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},t.prototype._removeConnectedInputObservables=function(e){e.input._connectedVirtualKeyboard=null,e.input.onFocusObservable.remove(e.onFocusObserver),e.input.onBlurObservable.remove(e.onBlurObserver)},t.prototype.dispose=function(){n.prototype.dispose.call(this),this.disconnect()},t.CreateDefaultLayout=function(e){var i=new t(e);return i.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),i.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),i.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),i.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),i.addKeysRow([" "],[{width:"200px"}]),i},t}(Pa);Ae.RegisteredTypes["BABYLON.GUI.VirtualKeyboard"]=CX;var PX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._cellWidth=20,i._cellHeight=20,i._minorLineTickness=1,i._minorLineColor="DarkGray",i._majorLineTickness=2,i._majorLineColor="White",i._majorLineFrequency=5,i._background="Black",i._displayMajorLines=!0,i._displayMinorLines=!0,i}return Object.defineProperty(t.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(e){this._displayMinorLines!==e&&(this._displayMinorLines=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(e){this._displayMajorLines!==e&&(this._displayMajorLines=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(e){this._minorLineTickness=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(e){this._minorLineColor=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(e){this._majorLineTickness=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(e){this._majorLineColor=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(e){this._majorLineFrequency=e,this._markAsDirty()},enumerable:!1,configurable:!0}),t.prototype._draw=function(e,i){if(e.save(),this._applyStates(e),this._isEnabled){this._background&&(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var r=this._currentMeasure.width/this._cellWidth,o=this._currentMeasure.height/this._cellHeight,a=this._currentMeasure.left+this._currentMeasure.width/2,s=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){e.strokeStyle=this._minorLineColor,e.lineWidth=this._minorLineTickness;for(var l=-r/2;l<r/2;l++){var u=a+l*this.cellWidth;e.beginPath(),e.moveTo(u,this._currentMeasure.top),e.lineTo(u,this._currentMeasure.top+this._currentMeasure.height),e.stroke()}for(var f=-o/2;f<o/2;f++){var c=s+f*this.cellHeight;e.beginPath(),e.moveTo(this._currentMeasure.left,c),e.lineTo(this._currentMeasure.left+this._currentMeasure.width,c),e.stroke()}}if(this._displayMajorLines){e.strokeStyle=this._majorLineColor,e.lineWidth=this._majorLineTickness;for(var l=-r/2+this._majorLineFrequency;l<r/2;l+=this._majorLineFrequency){var u=a+l*this.cellWidth;e.beginPath(),e.moveTo(u,this._currentMeasure.top),e.lineTo(u,this._currentMeasure.top+this._currentMeasure.height),e.stroke()}for(var f=-o/2+this._majorLineFrequency;f<o/2;f+=this._majorLineFrequency){var c=s+f*this.cellHeight;e.moveTo(this._currentMeasure.left,c),e.lineTo(this._currentMeasure.left+this._currentMeasure.width,c),e.closePath(),e.stroke()}}}e.restore()},t.prototype._getTypeName=function(){return"DisplayGrid"},t}(ot);Ae.RegisteredTypes["BABYLON.GUI.DisplayGrid"]=PX;var AX=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i.name=e,i._tempMeasure=new Jr(0,0,0,0),i}return Object.defineProperty(t.prototype,"displayThumb",{get:function(){return this._displayThumb&&this.thumbImage!=null},set:function(e){this._displayThumb!==e&&(this._displayThumb=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backgroundImage",{get:function(){return this._backgroundImage},set:function(e){var i=this;this._backgroundImage!==e&&(this._backgroundImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce(function(){return i._markAsDirty()}),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueBarImage",{get:function(){return this._valueBarImage},set:function(e){var i=this;this._valueBarImage!==e&&(this._valueBarImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce(function(){return i._markAsDirty()}),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thumbImage",{get:function(){return this._thumbImage},set:function(e){var i=this;this._thumbImage!==e&&(this._thumbImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce(function(){return i._markAsDirty()}),this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"ImageBasedSlider"},t.prototype._draw=function(e,i){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var r=this._getThumbPosition(),o=this._renderLeft,a=this._renderTop,s=this._renderWidth,l=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(o,a,s,l),this.isThumbClamped&&this.displayThumb&&(this.isVertical?this._tempMeasure.height+=this._effectiveThumbThickness:this._tempMeasure.width+=this._effectiveThumbThickness),this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure),this._backgroundImage._draw(e)),this._valueBarImage&&(this.isVertical?this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(o,a+r,s,l-r+this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(o,a+r,s,l-r):this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(o,a,r+this._effectiveThumbThickness/2,l):this._tempMeasure.copyFromFloats(o,a,r,l),this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure),this._valueBarImage._draw(e)),this.displayThumb&&(this.isVertical?this._tempMeasure.copyFromFloats(o-this._effectiveBarOffset,this._currentMeasure.top+r,this._currentMeasure.width,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+r,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(e)),e.restore()},t}(bp);Ae.RegisteredTypes["BABYLON.GUI.ImageBasedSlider"]=AX;var Y8="Statics";ot.AddHeader=function(n,t,e,i){var r=new Pa("panel"),o=i?i.isHorizontal:!0,a=i?i.controlFirst:!0;r.isVertical=!o;var s=new Mn("header");return s.text=t,s.textHorizontalAlignment=ot.HORIZONTAL_ALIGNMENT_LEFT,o?s.width=e:s.height=e,a?(r.addControl(n),r.addControl(s),s.paddingLeft="5px"):(r.addControl(s),r.addControl(n),s.paddingRight="5px"),s.shadowBlur=n.shadowBlur,s.shadowColor=n.shadowColor,s.shadowOffsetX=n.shadowOffsetX,s.shadowOffsetY=n.shadowOffsetY,r};var RX=function(){function n(t){this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new zt(18,zt.UNITMODE_PIXEL,!1),this.onChangedObservable=new ie,this._host=t}return Object.defineProperty(n.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&this.onChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),n.prototype.dispose=function(){this.onChangedObservable.clear()},n}(),Jb=function(n){j(t,n);function t(e,i,r,o,a,s,l){i===void 0&&(i=0),r===void 0&&(r=0),a===void 0&&(a=!1),s===void 0&&(s=he.NEAREST_SAMPLINGMODE);var u=n.call(this,e,{width:i,height:r},o,a,s,To.TEXTUREFORMAT_RGBA,l)||this;return u._isDirty=!1,u._rootContainer=new so("root"),u._lastControlOver={},u._lastControlDown={},u._capturingControl={},u._linkedControls=new Array,u._isFullscreen=!1,u._fullscreenViewport=new Dn(0,0,1,1),u._idealWidth=0,u._idealHeight=0,u._useSmallestIdeal=!1,u._renderAtIdealSize=!1,u._blockNextFocusCheck=!1,u._renderScale=1,u._cursorChanged=!1,u._defaultMousePointerId=0,u._numLayoutCalls=0,u._numRenderCalls=0,u._clipboardData="",u.onClipboardObservable=new ie,u.onControlPickedObservable=new ie,u.onBeginLayoutObservable=new ie,u.onEndLayoutObservable=new ie,u.onBeginRenderObservable=new ie,u.onEndRenderObservable=new ie,u.premulAlpha=!1,u.applyYInversionOnUpdate=!0,u._useInvalidateRectOptimization=!0,u._invalidatedRectangle=null,u._clearMeasure=new Jr(0,0,0,0),u.onClipboardCopy=function(f){var c=f,h=new Pv(Sa.COPY,c);u.onClipboardObservable.notifyObservers(h),c.preventDefault()},u.onClipboardCut=function(f){var c=f,h=new Pv(Sa.CUT,c);u.onClipboardObservable.notifyObservers(h),c.preventDefault()},u.onClipboardPaste=function(f){var c=f,h=new Pv(Sa.PASTE,c);u.onClipboardObservable.notifyObservers(h),c.preventDefault()},o=u.getScene(),!o||!u._texture||(u._rootElement=o.getEngine().getInputElement(),u._renderObserver=o.onBeforeCameraRenderObservable.add(function(f){return u._checkUpdate(f)}),u._preKeyboardObserver=o.onPreKeyboardObservable.add(function(f){u._focusedControl&&(f.type===$s.KEYDOWN&&u._focusedControl.processKeyboard(f.event),f.skipOnPointerObservable=!0)}),u._rootContainer._link(u),u.hasAlpha=!0,(!i||!r)&&(u._resizeObserver=o.getEngine().onResizeObservable.add(function(){return u._onResize()}),u._onResize()),u._texture.isReady=!0),u}return Object.defineProperty(t.prototype,"numLayoutCalls",{get:function(){return this._numLayoutCalls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numRenderCalls",{get:function(){return this._numRenderCalls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderScale",{get:function(){return this._renderScale},set:function(e){e!==this._renderScale&&(this._renderScale=e,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this.markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(e){this._idealWidth!==e&&(this._idealWidth=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(e){this._idealHeight!==e&&(this._idealHeight=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useSmallestIdeal",{get:function(){return this._useSmallestIdeal},set:function(e){this._useSmallestIdeal!==e&&(this._useSmallestIdeal=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(e){this._renderAtIdealSize!==e&&(this._renderAtIdealSize=e,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"idealRatio",{get:function(){var e=0,i=0;return this._idealWidth&&(e=this.getSize().width/this._idealWidth),this._idealHeight&&(i=this.getSize().height/this._idealHeight),this._useSmallestIdeal&&this._idealWidth&&this._idealHeight?window.innerWidth<window.innerHeight?e:i:this._idealWidth?e:this._idealHeight?i:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),t.prototype.getChildren=function(){return[this._rootContainer]},t.prototype.getDescendants=function(e,i){return this._rootContainer.getDescendants(e,i)},Object.defineProperty(t.prototype,"focusedControl",{get:function(){return this._focusedControl},set:function(e){this._focusedControl!=e&&(this._focusedControl&&this._focusedControl.onBlur(),e&&e.onFocus(),this._focusedControl=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isForeground",{get:function(){return this.layer?!this.layer.isBackground:!0},set:function(e){this.layer&&this.layer.isBackground!==!e&&(this.layer.isBackground=!e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clipboardData",{get:function(){return this._clipboardData},set:function(e){this._clipboardData=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"AdvancedDynamicTexture"},t.prototype.executeOnAllControls=function(e,i){i||(i=this._rootContainer),e(i);for(var r=0,o=i.children;r<o.length;r++){var a=o[r];if(a.children){this.executeOnAllControls(e,a);continue}e(a)}},Object.defineProperty(t.prototype,"useInvalidateRectOptimization",{get:function(){return this._useInvalidateRectOptimization},set:function(e){this._useInvalidateRectOptimization=e},enumerable:!1,configurable:!0}),t.prototype.invalidateRect=function(e,i,r,o){if(this._useInvalidateRectOptimization)if(!this._invalidatedRectangle)this._invalidatedRectangle=new Jr(e,i,r-e+1,o-i+1);else{var a=Math.ceil(Math.max(this._invalidatedRectangle.left+this._invalidatedRectangle.width-1,r)),s=Math.ceil(Math.max(this._invalidatedRectangle.top+this._invalidatedRectangle.height-1,o));this._invalidatedRectangle.left=Math.floor(Math.min(this._invalidatedRectangle.left,e)),this._invalidatedRectangle.top=Math.floor(Math.min(this._invalidatedRectangle.top,i)),this._invalidatedRectangle.width=a-this._invalidatedRectangle.left+1,this._invalidatedRectangle.height=s-this._invalidatedRectangle.top+1}},t.prototype.markAsDirty=function(){this._isDirty=!0},t.prototype.createStyle=function(){return new RX(this)},t.prototype.addControl=function(e){return this._rootContainer.addControl(e),this},t.prototype.removeControl=function(e){return this._rootContainer.removeControl(e),this},t.prototype.dispose=function(){var e=this.getScene();e&&(this._rootElement=null,e.onBeforeCameraRenderObservable.remove(this._renderObserver),this._resizeObserver&&e.getEngine().onResizeObservable.remove(this._resizeObserver),this._pointerMoveObserver&&e.onPrePointerObservable.remove(this._pointerMoveObserver),this._pointerObserver&&e.onPointerObservable.remove(this._pointerObserver),this._preKeyboardObserver&&e.onPreKeyboardObservable.remove(this._preKeyboardObserver),this._canvasPointerOutObserver&&e.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver),this._canvasBlurObserver&&e.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver),this._layerToDispose&&(this._layerToDispose.texture=null,this._layerToDispose.dispose(),this._layerToDispose=null),this._rootContainer.dispose(),this.onClipboardObservable.clear(),this.onControlPickedObservable.clear(),this.onBeginRenderObservable.clear(),this.onEndRenderObservable.clear(),this.onBeginLayoutObservable.clear(),this.onEndLayoutObservable.clear(),n.prototype.dispose.call(this))},t.prototype._onResize=function(){var e=this.getScene();if(e){var i=e.getEngine(),r=this.getSize(),o=i.getRenderWidth()*this._renderScale,a=i.getRenderHeight()*this._renderScale;this._renderAtIdealSize&&(this._idealWidth?(a=a*this._idealWidth/o,o=this._idealWidth):this._idealHeight&&(o=o*this._idealHeight/a,a=this._idealHeight)),(r.width!==o||r.height!==a)&&(this.scaleTo(o,a),this.markAsDirty(),(this._idealWidth||this._idealHeight)&&this._rootContainer._markAllAsDirty()),this.invalidateRect(0,0,r.width-1,r.height-1)}},t.prototype._getGlobalViewport=function(e){var i=e.getEngine();return this._fullscreenViewport.toGlobal(i.getRenderWidth(),i.getRenderHeight())},t.prototype.getProjectedPosition=function(e,i){var r=this.getScene();if(!r)return Ie.Zero();var o=this._getGlobalViewport(r),a=y.Project(e,i,r.getTransformMatrix(),o);return a.scaleInPlace(this.renderScale),new Ie(a.x,a.y)},t.prototype.getProjectedPositionWithZ=function(e,i){var r=this.getScene();if(!r)return y.Zero();var o=this._getGlobalViewport(r),a=y.Project(e,i,r.getTransformMatrix(),o);return a.scaleInPlace(this.renderScale),new y(a.x,a.y,a.z)},t.prototype._checkUpdate=function(e){if(!(this._layerToDispose&&(e.layerMask&this._layerToDispose.layerMask)===0)){if(this._isFullscreen&&this._linkedControls.length){var i=this.getScene();if(!i)return;for(var r=this._getGlobalViewport(i),o=function(f){if(!f.isVisible)return"continue";var c=f._linkedMesh;if(!c||c.isDisposed())return Ee.SetImmediate(function(){f.linkWithMesh(null)}),"continue";var h=c.getBoundingInfo?c.getBoundingInfo().boundingSphere.center:y.ZeroReadOnly,p=y.Project(h,c.getWorldMatrix(),i.getTransformMatrix(),r);if(p.z<0||p.z>1)return f.notRenderable=!0,"continue";f.notRenderable=!1,p.scaleInPlace(a.renderScale),f._moveToProjectedPosition(p)},a=this,s=0,l=this._linkedControls;s<l.length;s++){var u=l[s];o(u)}}!this._isDirty&&!this._rootContainer.isDirty||(this._isDirty=!1,this._render(),this.update(this.applyYInversionOnUpdate,this.premulAlpha))}},t.prototype._render=function(){var e=this.getSize(),i=e.width,r=e.height,o=this.getContext();o.font="18px Arial",o.strokeStyle="white",this.onBeginLayoutObservable.notifyObservers(this);var a=new Jr(0,0,i,r);this._numLayoutCalls=0,this._rootContainer._layout(a,o),this.onEndLayoutObservable.notifyObservers(this),this._isDirty=!1,this._invalidatedRectangle?this._clearMeasure.copyFrom(this._invalidatedRectangle):this._clearMeasure.copyFromFloats(0,0,i,r),o.clearRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),this._background&&(o.save(),o.fillStyle=this._background,o.fillRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),o.restore()),this.onBeginRenderObservable.notifyObservers(this),this._numRenderCalls=0,this._rootContainer._render(o,this._invalidatedRectangle),this.onEndRenderObservable.notifyObservers(this),this._invalidatedRectangle=null},t.prototype._changeCursor=function(e){this._rootElement&&(this._rootElement.style.cursor=e,this._cursorChanged=!0)},t.prototype._registerLastControlDown=function(e,i){this._lastControlDown[i]=e,this.onControlPickedObservable.notifyObservers(e)},t.prototype._doPicking=function(e,i,r,o,a,s,l,u){var f=this.getScene();if(f){var c=f.getEngine(),h=this.getSize();if(this._isFullscreen){var p=f.cameraToUseForPointers||f.activeCamera,_=p.viewport;e=e*(h.width/(c.getRenderWidth()*_.width)),i=i*(h.height/(c.getRenderHeight()*_.height))}if(this._capturingControl[a]){this._capturingControl[a]._processObservables(o,e,i,r,a,s);return}this._cursorChanged=!1,this._rootContainer._processPicking(e,i,r,o,a,s,l,u)||(this._changeCursor(""),o===He.POINTERMOVE&&this._lastControlOver[a]&&(this._lastControlOver[a]._onPointerOut(this._lastControlOver[a],r),delete this._lastControlOver[a])),this._cursorChanged||this._changeCursor(""),this._manageFocus()}},t.prototype._cleanControlAfterRemovalFromList=function(e,i){for(var r in e)if(e.hasOwnProperty(r)){var o=e[r];o===i&&delete e[r]}},t.prototype._cleanControlAfterRemoval=function(e){this._cleanControlAfterRemovalFromList(this._lastControlDown,e),this._cleanControlAfterRemovalFromList(this._lastControlOver,e)},t.prototype.attach=function(){var e=this,i=this.getScene();if(i){var r=new Dn(0,0,0,0);this._pointerMoveObserver=i.onPrePointerObservable.add(function(o,a){if(!i.isPointerCaptured(o.event.pointerId)&&!(o.type!==He.POINTERMOVE&&o.type!==He.POINTERUP&&o.type!==He.POINTERDOWN&&o.type!==He.POINTERWHEEL)&&i){o.type===He.POINTERMOVE&&o.event.pointerId&&(e._defaultMousePointerId=o.event.pointerId);var s=i.cameraToUseForPointers||i.activeCamera,l=i.getEngine();s?s.viewport.toGlobalToRef(l.getRenderWidth(),l.getRenderHeight(),r):(r.x=0,r.y=0,r.width=l.getRenderWidth(),r.height=l.getRenderHeight());var u=i.pointerX/l.getHardwareScalingLevel()-r.x,f=i.pointerY/l.getHardwareScalingLevel()-(l.getRenderHeight()-r.y-r.height);e._shouldBlockPointer=!1;var c=o.event.pointerId||e._defaultMousePointerId;e._doPicking(u,f,o,o.type,c,o.event.button,o.event.deltaX,o.event.deltaY),e._shouldBlockPointer&&(o.skipOnPointerObservable=e._shouldBlockPointer)}}),this._attachToOnPointerOut(i),this._attachToOnBlur(i)}},t.prototype.registerClipboardEvents=function(){self.addEventListener("copy",this.onClipboardCopy,!1),self.addEventListener("cut",this.onClipboardCut,!1),self.addEventListener("paste",this.onClipboardPaste,!1)},t.prototype.unRegisterClipboardEvents=function(){self.removeEventListener("copy",this.onClipboardCopy),self.removeEventListener("cut",this.onClipboardCut),self.removeEventListener("paste",this.onClipboardPaste)},t.prototype.attachToMesh=function(e,i){var r=this;i===void 0&&(i=!0);var o=this.getScene();o&&(this._pointerObserver=o.onPointerObservable.add(function(a,s){if(!(a.type!==He.POINTERMOVE&&a.type!==He.POINTERUP&&a.type!==He.POINTERDOWN)){var l=a.event.pointerId||r._defaultMousePointerId;if(a.pickInfo&&a.pickInfo.hit&&a.pickInfo.pickedMesh===e){var u=a.pickInfo.getTextureCoordinates();if(u){var f=r.getSize();r._doPicking(u.x*f.width,(r.applyYInversionOnUpdate?1-u.y:u.y)*f.height,a,a.type,l,a.event.button)}}else if(a.type===He.POINTERUP){if(r._lastControlDown[l]&&r._lastControlDown[l]._forcePointerUp(l),delete r._lastControlDown[l],r.focusedControl){var c=r.focusedControl.keepsFocusWith(),h=!0;if(c)for(var p=0,_=c;p<_.length;p++){var g=_[p];if(r!==g._host){var v=g._host;if(v._lastControlOver[l]&&v._lastControlOver[l].isAscendant(g)){h=!1;break}}}h&&(r.focusedControl=null)}}else a.type===He.POINTERMOVE&&(r._lastControlOver[l]&&r._lastControlOver[l]._onPointerOut(r._lastControlOver[l],a,!0),delete r._lastControlOver[l])}}),e.enablePointerMoveEvents=i,this._attachToOnPointerOut(o),this._attachToOnBlur(o))},t.prototype.moveFocusToControl=function(e){this.focusedControl=e,this._lastPickedControl=e,this._blockNextFocusCheck=!0},t.prototype._manageFocus=function(){if(this._blockNextFocusCheck){this._blockNextFocusCheck=!1,this._lastPickedControl=this._focusedControl;return}if(this._focusedControl&&this._focusedControl!==this._lastPickedControl){if(this._lastPickedControl.isFocusInvisible)return;this.focusedControl=null}},t.prototype._attachToOnPointerOut=function(e){var i=this;this._canvasPointerOutObserver=e.getEngine().onCanvasPointerOutObservable.add(function(r){i._lastControlOver[r.pointerId]&&i._lastControlOver[r.pointerId]._onPointerOut(i._lastControlOver[r.pointerId],null),delete i._lastControlOver[r.pointerId],i._lastControlDown[r.pointerId]&&i._lastControlDown[r.pointerId]!==i._capturingControl[r.pointerId]&&(i._lastControlDown[r.pointerId]._forcePointerUp(),delete i._lastControlDown[r.pointerId])})},t.prototype._attachToOnBlur=function(e){var i=this;this._canvasBlurObserver=e.getEngine().onCanvasBlurObservable.add(function(r){Object.entries(i._lastControlDown).forEach(function(o){o[0];var a=o[1];a._onCanvasBlur()}),i._lastControlDown={}})},t.CreateForMesh=function(e,i,r,o,a,s){i===void 0&&(i=1024),r===void 0&&(r=1024),o===void 0&&(o=!0),a===void 0&&(a=!1);var l=new t(e.name+" AdvancedDynamicTexture",i,r,e.getScene(),!0,he.TRILINEAR_SAMPLINGMODE,s),u=new Mt("AdvancedDynamicTextureMaterial",e.getScene());return u.backFaceCulling=!1,u.diffuseColor=_e.Black(),u.specularColor=_e.Black(),a?(u.diffuseTexture=l,u.emissiveTexture=l,l.hasAlpha=!0):(u.emissiveTexture=l,u.opacityTexture=l),e.material=u,l.attachToMesh(e,o),l},t.CreateForMeshTexture=function(e,i,r,o,a){i===void 0&&(i=1024),r===void 0&&(r=1024),o===void 0&&(o=!0);var s=new t(e.name+" AdvancedDynamicTexture",i,r,e.getScene(),!0,he.TRILINEAR_SAMPLINGMODE,a);return s.attachToMesh(e,o),s},t.CreateFullscreenUI=function(e,i,r,o){i===void 0&&(i=!0),r===void 0&&(r=null),o===void 0&&(o=he.BILINEAR_SAMPLINGMODE);var a=new t(e,0,0,r,!1,o),s=new $z(e+"_layer",null,r,!i);return s.texture=a,a._layerToDispose=s,a._isFullscreen=!0,a.attach(),a},t}(Po),K8=function(){function n(t){this.texture=t,this._captureRenderTime=!1,this._renderTime=new Or,this._captureLayoutTime=!1,this._layoutTime=new Or,this._onBeginRenderObserver=null,this._onEndRenderObserver=null,this._onBeginLayoutObserver=null,this._onEndLayoutObserver=null}return Object.defineProperty(n.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"layoutTimeCounter",{get:function(){return this._layoutTime},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var e=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeginRenderObserver=this.texture.onBeginRenderObservable.add(function(){e._renderTime.beginMonitoring()}),this._onEndRenderObserver=this.texture.onEndRenderObservable.add(function(){e._renderTime.endMonitoring(!0)})):(this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"captureLayoutTime",{get:function(){return this._captureLayoutTime},set:function(t){var e=this;t!==this._captureLayoutTime&&(this._captureLayoutTime=t,t?(this._onBeginLayoutObserver=this.texture.onBeginLayoutObservable.add(function(){e._layoutTime.beginMonitoring()}),this._onEndLayoutObserver=this.texture.onEndLayoutObservable.add(function(){e._layoutTime.endMonitoring(!0)})):(this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null))},enumerable:!1,configurable:!0}),n.prototype.dispose=function(){this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null,this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null,this.texture=null},n}(),q8=function(){function n(t){t===void 0&&(t=null),this._nodes={},this._nodeTypes={element:1,attribute:2,text:3},this._isLoaded=!1,this._objectAttributes={textHorizontalAlignment:1,textVerticalAlignment:2,horizontalAlignment:3,verticalAlignment:4,stretch:5},t&&(this._parentClass=t)}return n.prototype._getChainElement=function(t){var e=window;this._parentClass&&(e=this._parentClass);var i=t;i=i.split(".");for(var r=0;r<i.length;r++)e=e[i[r]];return e},n.prototype._getClassAttribute=function(t){var e=t.split("."),i=Ae.GetClass("BABYLON.GUI."+e[0]);return i[e[1]]},n.prototype._createGuiElement=function(t,e,i){i===void 0&&(i=!0);try{var r=Ae.GetClass("BABYLON.GUI."+t.nodeName),o=new r;e&&i&&e.addControl(o);for(var a=0;a<t.attributes.length;a++)if(!t.attributes[a].name.toLowerCase().includes("datasource"))if(t.attributes[a].name.toLowerCase().includes("observable")){var s=this._getChainElement(t.attributes[a].value);o[t.attributes[a].name].add(s);continue}else if(t.attributes[a].name=="linkWithMesh")this._parentClass?o.linkWithMesh(this._parentClass[t.attributes[a].value]):o.linkWithMesh(window[t.attributes[a].value]);else if(t.attributes[a].value.startsWith("{{")&&t.attributes[a].value.endsWith("}}")){var s=this._getChainElement(t.attributes[a].value.substring(2,t.attributes[a].value.length-2));o[t.attributes[a].name]=s}else this._objectAttributes[t.attributes[a].name]?o[t.attributes[a].name]=this._getClassAttribute(t.attributes[a].value):t.attributes[a].value=="true"||t.attributes[a].value=="false"?o[t.attributes[a].name]=t.attributes[a].value=="true":o[t.attributes[a].name]=isNaN(Number(t.attributes[a].value))?t.attributes[a].value:Number(t.attributes[a].value);if(!t.attributes.getNamedItem("id"))return this._nodes[t.nodeName+Object.keys(this._nodes).length+"_gen"]=o,o;var l=t.attributes.getNamedItem("id").value;if(l.startsWith("{{")&&l.endsWith("}}")&&(l=this._getChainElement(l.substring(2,l.length-2))),!this._nodes[l])this._nodes[l]=o;else throw"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";return o}catch(u){throw"XmlLoader Exception : Error parsing Control "+t.nodeName+","+u+"."}},n.prototype._parseGrid=function(t,e,i){for(var r,o,a,s=t.children,l,u=!1,f,c=-1,h=-1,p=0,_=0;_<s.length;_++)if(s[_].nodeType==this._nodeTypes.element){if(s[_].nodeName!="Row")throw"XmlLoader Exception : Expecting Row node, received "+s[_].nodeName;if(c+=1,a=s[_].children,!s[_].attributes.getNamedItem("height"))throw"XmlLoader Exception : Height must be defined for grid rows";o=Number(s[_].attributes.getNamedItem("height").nodeValue),u=s[_].attributes.getNamedItem("isPixel")?JSON.parse(s[_].attributes.getNamedItem("isPixel").nodeValue):!1,e.addRowDefinition(o,u);for(var g=0;g<a.length;g++)if(a[g].nodeType==this._nodeTypes.element){if(a[g].nodeName!="Column")throw"XmlLoader Exception : Expecting Column node, received "+a[g].nodeName;if(h+=1,c>0&&h>p)throw"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";if(c==0){if(!a[g].attributes.getNamedItem("width"))throw"XmlLoader Exception : Width must be defined for all the grid columns in the first row";r=Number(a[g].attributes.getNamedItem("width").nodeValue),u=a[g].attributes.getNamedItem("isPixel")?JSON.parse(a[g].attributes.getNamedItem("isPixel").nodeValue):!1,e.addColumnDefinition(r,u)}l=a[g].children;for(var v=0;v<l.length;v++)l[v].nodeType==this._nodeTypes.element&&(f=this._createGuiElement(l[v],e,!1),e.addControl(f,c,h),l[v].firstChild&&this._parseXml(l[v].firstChild,f))}c==0&&(p=h),h=-1}t.nextSibling&&this._parseXml(t.nextSibling,i)},n.prototype._parseElement=function(t,e,i){t.firstChild&&this._parseXml(t.firstChild,e),t.nextSibling&&this._parseXml(t.nextSibling,i)},n.prototype._prepareSourceElement=function(t,e,i,r,o){this._parentClass?this._parentClass[i]=r[o]:window[i]=r[o],t.firstChild&&this._parseXml(t.firstChild,e,!0)},n.prototype._parseElementsFromSource=function(t,e,i){var r=t.attributes.getNamedItem("dataSource").value;if(r.includes(" in ")){var o=!0,a=r.split(" in ");if(a.length<2)throw"XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";var s=a[1];if(s.startsWith("{")&&s.endsWith("}")&&(o=!1),(!o||s.startsWith("[")&&s.endsWith("]"))&&(s=s.substring(1,s.length-1)),this._parentClass?s=this._parentClass[s]:s=window[s],o)for(var l=0;l<s.length;l++)this._prepareSourceElement(t,e,a[0],s,l);else for(var l in s)this._prepareSourceElement(t,e,a[0],s,l);t.nextSibling&&this._parseXml(t.nextSibling,i)}else throw"XmlLoader Exception : Malformed XML, Data Source must include an in"},n.prototype._parseXml=function(t,e,i){if(i===void 0&&(i=!1),t.nodeType!=this._nodeTypes.element){t.nextSibling&&this._parseXml(t.nextSibling,e,i);return}i&&t.setAttribute("id",e.id+(e._children.length+1));var r=this._createGuiElement(t,e);t.nodeName=="Grid"?this._parseGrid(t,r,e):t.attributes.getNamedItem("dataSource")?this._parseElementsFromSource(t,r,e):this._parseElement(t,r,e)},n.prototype.isLoaded=function(){return this._isLoaded},n.prototype.getNodeById=function(t){return this._nodes[t]},n.prototype.getNodes=function(){return this._nodes},n.prototype.loadLayout=function(t,e,i){var r=new XMLHttpRequest;r.onreadystatechange=(function(){if(r.readyState==4&&r.status==200){if(!r.responseXML)throw"XmlLoader Exception : XML file is malformed or corrupted.";var o=r.responseXML.documentElement;this._parseXml(o.firstChild,e),this._isLoaded=!0,i&&i()}}).bind(this),r.open("GET",t,!0),r.send()},n}(),sy=function(n){j(t,n);function t(e,i){i===void 0&&(i=0);var r=n.call(this,e.x,e.y,e.z)||this;return r.buttonIndex=i,r}return t}(y),eD=function(){function n(t){this.name=t,this._downCount=0,this._enterCount=-1,this._downPointerIds={},this._isVisible=!0,this.onPointerMoveObservable=new ie,this.onPointerOutObservable=new ie,this.onPointerDownObservable=new ie,this.onPointerUpObservable=new ie,this.onPointerClickObservable=new ie,this.onPointerEnterObservable=new ie,this._behaviors=new Array}return Object.defineProperty(n.prototype,"position",{get:function(){return this._node?this._node.position:y.Zero()},set:function(t){this._node&&(this._node.position=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scaling",{get:function(){return this._node?this._node.scaling:new y(1,1,1)},set:function(t){this._node&&(this._node.scaling=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),n.prototype.addBehavior=function(t){var e=this,i=this._behaviors.indexOf(t);if(i!==-1)return this;t.init();var r=this._host.scene;return r.isLoading?r.onDataLoadedObservable.addOnce(function(){t.attach(e)}):t.attach(this),this._behaviors.push(t),this},n.prototype.removeBehavior=function(t){var e=this._behaviors.indexOf(t);return e===-1?this:(this._behaviors[e].detach(),this._behaviors.splice(e,1),this)},n.prototype.getBehaviorByName=function(t){for(var e=0,i=this._behaviors;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},Object.defineProperty(n.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){if(this._isVisible!==t){this._isVisible=t;var e=this.mesh;e&&e.setEnabled(t)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),n.prototype.getClassName=function(){return this._getTypeName()},n.prototype._getTypeName=function(){return"Control3D"},Object.defineProperty(n.prototype,"node",{get:function(){return this._node},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"mesh",{get:function(){return this._node instanceof Ht?this._node:null},enumerable:!1,configurable:!0}),n.prototype.linkToTransformNode=function(t){return this._node&&(this._node.parent=t),this},n.prototype._prepareNode=function(t){if(!this._node){if(this._node=this._createNode(t),!this.node)return;this._node.metadata=this,this._node.position=this.position,this._node.scaling=this.scaling;var e=this.mesh;e&&(e.isPickable=!0,this._affectMaterial(e))}},n.prototype._createNode=function(t){return null},n.prototype._affectMaterial=function(t){t.material=null},n.prototype._onPointerMove=function(t,e){this.onPointerMoveObservable.notifyObservers(e,-1,t,this)},n.prototype._onPointerEnter=function(t){return this._enterCount>0?!1:(this._enterCount===-1&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this),this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},n.prototype._onPointerOut=function(t){this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this),this.pointerOutAnimation&&this.pointerOutAnimation()},n.prototype._onPointerDown=function(t,e,i,r){return this._downCount!==0?(this._downCount++,!1):(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new sy(e,r),-1,t,this),this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},n.prototype._onPointerUp=function(t,e,i,r,o){if(this._downCount--,delete this._downPointerIds[i],this._downCount<0){this._downCount=0;return}this._downCount==0&&(o&&(this._enterCount>0||this._enterCount===-1)&&this.onPointerClickObservable.notifyObservers(new sy(e,r),-1,t,this),this.onPointerUpObservable.notifyObservers(new sy(e,r),-1,t,this),this.pointerUpAnimation&&this.pointerUpAnimation())},n.prototype.forcePointerUp=function(t){if(t===void 0&&(t=null),t!==null)this._onPointerUp(this,y.Zero(),t,0,!0);else{for(var e in this._downPointerIds)this._onPointerUp(this,y.Zero(),+e,0,!0);this._downCount>0&&(this._downCount=1,this._onPointerUp(this,y.Zero(),0,0,!0))}},n.prototype._processObservables=function(t,e,i,r){if(t===He.POINTERMOVE){this._onPointerMove(this,e);var o=this._host._lastControlOver[i];return o&&o!==this&&o._onPointerOut(this),o!==this&&this._onPointerEnter(this),this._host._lastControlOver[i]=this,!0}return t===He.POINTERDOWN?(this._onPointerDown(this,e,i,r),this._host._lastControlDown[i]=this,this._host._lastPickedControl=this,!0):t===He.POINTERUP||t===He.POINTERDOUBLETAP?(this._host._lastControlDown[i]&&this._host._lastControlDown[i]._onPointerUp(this,e,i,r,!0),delete this._host._lastControlDown[i],!0):!1},n.prototype._disposeNode=function(){this._node&&(this._node.dispose(),this._node=null)},n.prototype.dispose=function(){this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._disposeNode();for(var t=0,e=this._behaviors;t<e.length;t++){var i=e[t];i.detach()}},n}(),OX=function(n){j(t,n);function t(e){return n.call(this,e)||this}return t.prototype._getTypeName=function(){return"AbstractButton3D"},t.prototype._createNode=function(e){return new nr("button"+this.name)},t}(eD),tD=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i._contentResolution=512,i._contentScaleRatio=2,i.pointerEnterAnimation=function(){i.mesh&&(i._currentMaterial.emissiveColor=_e.Red())},i.pointerOutAnimation=function(){i._currentMaterial.emissiveColor=_e.Black()},i.pointerDownAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(.95)},i.pointerUpAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(1/.95)},i}return Object.defineProperty(t.prototype,"contentResolution",{get:function(){return this._contentResolution},set:function(e){this._contentResolution!==e&&(this._contentResolution=e,this._resetContent())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contentScaleRatio",{get:function(){return this._contentScaleRatio},set:function(e){this._contentScaleRatio!==e&&(this._contentScaleRatio=e,this._resetContent())},enumerable:!1,configurable:!0}),t.prototype._disposeFacadeTexture=function(){this._facadeTexture&&(this._facadeTexture.dispose(),this._facadeTexture=null)},t.prototype._resetContent=function(){this._disposeFacadeTexture(),this.content=this._content},Object.defineProperty(t.prototype,"content",{get:function(){return this._content},set:function(e){this._content=e,!(!this._host||!this._host.utilityLayer)&&(this._facadeTexture?this._facadeTexture.rootContainer.clearControls():(this._facadeTexture=new Jb("Facade",this._contentResolution,this._contentResolution,this._host.utilityLayer.utilityLayerScene,!0,he.TRILINEAR_SAMPLINGMODE),this._facadeTexture.rootContainer.scaleX=this._contentScaleRatio,this._facadeTexture.rootContainer.scaleY=this._contentScaleRatio,this._facadeTexture.premulAlpha=!0),this._facadeTexture.addControl(e),this._applyFacade(this._facadeTexture))},enumerable:!1,configurable:!0}),t.prototype._applyFacade=function(e){this._currentMaterial.emissiveTexture=e},t.prototype._getTypeName=function(){return"Button3D"},t.prototype._createNode=function(e){for(var i=new Array(6),r=0;r<6;r++)i[r]=new ni(0,0,0,0);i[1]=new ni(0,0,1,1);var o=Xo.CreateBox(this.name+"_rootMesh",{width:1,height:1,depth:.08,faceUV:i},e);return o},t.prototype._affectMaterial=function(e){var i=new Mt(this.name+"Material",e.getScene());i.specularColor=_e.Black(),e.material=i,this._currentMaterial=i,this._resetContent()},t.prototype.dispose=function(){n.prototype.dispose.call(this),this._disposeFacadeTexture(),this._currentMaterial&&this._currentMaterial.dispose()},t}(OX),br=function(n){j(t,n);function t(e){var i=n.call(this,e)||this;return i._blockLayout=!1,i._children=new Array,i}return Object.defineProperty(t.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blockLayout",{get:function(){return this._blockLayout},set:function(e){this._blockLayout!==e&&(this._blockLayout=e,this._blockLayout||this._arrangeChildren())},enumerable:!1,configurable:!0}),t.prototype.updateLayout=function(){return this._arrangeChildren(),this},t.prototype.containsControl=function(e){return this._children.indexOf(e)!==-1},t.prototype.addControl=function(e){var i=this._children.indexOf(e);return i!==-1?this:(e.parent=this,e._host=this._host,this._children.push(e),this._host.utilityLayer&&(e._prepareNode(this._host.utilityLayer.utilityLayerScene),e.node&&(e.node.parent=this.node),this.blockLayout||this._arrangeChildren()),this)},t.prototype._arrangeChildren=function(){},t.prototype._createNode=function(e){return new nr("ContainerNode",e)},t.prototype.removeControl=function(e){var i=this._children.indexOf(e);return i!==-1&&(this._children.splice(i,1),e.parent=null,e._disposeNode()),this},t.prototype._getTypeName=function(){return"Container3D"},t.prototype.dispose=function(){for(var e=0,i=this._children;e<i.length;e++){var r=i[e];r.dispose()}this._children=[],n.prototype.dispose.call(this)},t.UNSET_ORIENTATION=0,t.FACEORIGIN_ORIENTATION=1,t.FACEORIGINREVERSED_ORIENTATION=2,t.FACEFORWARD_ORIENTATION=3,t.FACEFORWARDREVERSED_ORIENTATION=4,t}(eD),Ep=function(n){j(t,n);function t(){var e=n.call(this)||this;return e._columns=10,e._rows=0,e._rowThenColum=!0,e._orientation=br.FACEORIGIN_ORIENTATION,e.margin=0,e}return Object.defineProperty(t.prototype,"orientation",{get:function(){return this._orientation},set:function(e){var i=this;this._orientation!==e&&(this._orientation=e,Ee.SetImmediate(function(){i._arrangeChildren()}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},set:function(e){var i=this;this._columns!==e&&(this._columns=e,this._rowThenColum=!0,Ee.SetImmediate(function(){i._arrangeChildren()}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._rows},set:function(e){var i=this;this._rows!==e&&(this._rows=e,this._rowThenColum=!1,Ee.SetImmediate(function(){i._arrangeChildren()}))},enumerable:!1,configurable:!0}),t.prototype._arrangeChildren=function(){this._cellWidth=0,this._cellHeight=0;for(var e=0,i=0,r=0,o=te.Invert(this.node.computeWorldMatrix(!0)),a=0,s=this._children;a<s.length;a++){var l=s[a];if(l.mesh){r++,l.mesh.computeWorldMatrix(!0);var u=l.mesh.getHierarchyBoundingVectors(),f=me.Vector3[0],c=me.Vector3[1];u.max.subtractToRef(u.min,c),c.scaleInPlace(.5),y.TransformNormalToRef(c,o,f),this._cellWidth=Math.max(this._cellWidth,f.x*2),this._cellHeight=Math.max(this._cellHeight,f.y*2)}}this._cellWidth+=this.margin*2,this._cellHeight+=this.margin*2,this._rowThenColum?(i=this._columns,e=Math.ceil(r/this._columns)):(e=this._rows,i=Math.ceil(r/this._rows));var h=i*.5*this._cellWidth,p=e*.5*this._cellHeight,_=[],g=0;if(this._rowThenColum)for(var v=0;v<e;v++)for(var E=0;E<i&&(_.push(new y(E*this._cellWidth-h+this._cellWidth/2,v*this._cellHeight-p+this._cellHeight/2,0)),g++,!(g>r));E++);else for(var E=0;E<i;E++)for(var v=0;v<e&&(_.push(new y(E*this._cellWidth-h+this._cellWidth/2,v*this._cellHeight-p+this._cellHeight/2,0)),g++,!(g>r));v++);g=0;for(var T=0,S=this._children;T<S.length;T++){var l=S[T];l.mesh&&(this._mapGridNode(l,_[g]),g++)}this._finalProcessing()},t.prototype._finalProcessing=function(){},t}(br),Q8=function(n){j(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._radius=5,e}return Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){var i=this;this._radius!==e&&(this._radius=e,Ee.SetImmediate(function(){i._arrangeChildren()}))},enumerable:!1,configurable:!0}),t.prototype._mapGridNode=function(e,i){var r=e.mesh;if(r){var o=this._cylindricalMapping(i);switch(e.position=o,this.orientation){case br.FACEORIGIN_ORIENTATION:r.lookAt(new y(2*o.x,o.y,2*o.z));break;case br.FACEORIGINREVERSED_ORIENTATION:r.lookAt(new y(-o.x,o.y,-o.z));break;case br.FACEFORWARD_ORIENTATION:break;case br.FACEFORWARDREVERSED_ORIENTATION:r.rotate(Mi.Y,Math.PI,St.LOCAL);break}}},t.prototype._cylindricalMapping=function(e){var i=new y(0,e.y,this._radius),r=e.x/this._radius;return te.RotationYawPitchRollToRef(r,0,0,me.Matrix[0]),y.TransformNormal(i,me.Matrix[0])},t}(Ep),MX="fluentVertexShader",xX=`precision highp float;
13298
13298
 
13299
13299
  attribute vec3 position;
@@ -16063,7 +16063,7 @@ vReflectionMapTexCoord.z=worldPos.w;
16063
16063
  #endif
16064
16064
  #include<logDepthVertex>
16065
16065
  }
16066
- `;ce.ShadersStore[tK]=iK;var rK=function(n){j(t,n);function t(){var e=n.call(this)||this;return e.BUMP=!1,e.REFLECTION=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.UV1=!1,e.UV2=!1,e.VERTEXCOLOR=!1,e.VERTEXALPHA=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SPECULARTERM=!1,e.LOGARITHMICDEPTH=!1,e.FRESNELSEPARATE=!1,e.BUMPSUPERIMPOSE=!1,e.BUMPAFFECTSREFLECTION=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.rebuild(),e}return t}(Er),nK=function(n){j(t,n);function t(e,i,r){r===void 0&&(r=new Ie(512,512));var o=n.call(this,e,i)||this;return o.renderTargetSize=r,o.diffuseColor=new _e(1,1,1),o.specularColor=new _e(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new Ie(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new _e(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new _e(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new yr(16),o._mesh=null,o._reflectionTransform=te.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,r),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add(function(){o._markAllSubMeshesAsImageProcessingDirty()})),o}return Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&this._refractionRTT.refreshRate===0)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,i,r){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new rK);var o=i._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled)){if(this.bumpTexture&&ke.BumpTextureEnabled)if(this.bumpTexture.isReady())o._needUVs=!0,o.BUMP=!0;else return!1;ke.ReflectionTextureEnabled&&(o.REFLECTION=!0)}if(oe.PrepareDefinesForFrameBoundValues(a,s,o,!!r),oe.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._areMiscDirty&&(this._fresnelSeparate&&(o.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(o.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(o.BUMPAFFECTSREFLECTION=!0)),o._needNormals=oe.PrepareDefinesForLights(a,e,o,!0,this._maxSimultaneousLights,this._disableLighting),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(oe.PrepareDefinesForAttributes(e,o,!0,!0),this._mesh=e,this._waitingRenderList){for(var l=0;l<this._waitingRenderList.length;l++)this.addToRenderList(a.getNodeByID(this._waitingRenderList[l]));this._waitingRenderList=null}if(o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var u=new Tr;o.FOG&&u.addFallback(1,"FOG"),o.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),oe.HandleFallbacksForShadows(o,u,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e);var f=[I.PositionKind];o.NORMAL&&f.push(I.NormalKind),o.UV1&&f.push(I.UVKind),o.UV2&&f.push(I.UV2Kind),o.VERTEXCOLOR&&f.push(I.ColorKind),oe.PrepareAttributesForBones(f,e,o,u),oe.PrepareAttributesForInstances(f,o);var c="water",h=o.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],_=["normalSampler","refractionSampler","reflectionSampler"],g=new Array;Hi&&(Hi.PrepareUniforms(p,o),Hi.PrepareSamplers(_,o)),oe.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(a.getEngine().createEffect(c,{attributes:f,uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:h,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o)}return!i.effect||!i.effect.isReady()?!1:(o._renderId=a.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,i,r){var o=this.getScene(),a=r._materialDefines;if(a){var s=r.effect;if(!(!s||!this._mesh)){this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),oe.BindBonesParameters(i,this._activeEffect),this._mustRebind(o,s)&&(this.bumpTexture&&ke.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),oe.BindClipPlane(this._activeEffect,o),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),oe.BindEyePosition(s,o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),a.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),o.lightsEnabled&&!this.disableLighting&&oe.BindLights(o,i,this._activeEffect,a,this.maxSimultaneousLights),o.fogEnabled&&i.applyFog&&o.fogMode!==Ke.FOGMODE_NONE&&this._activeEffect.setMatrix("view",o.getViewMatrix()),oe.BindFogParameters(o,i,this._activeEffect),oe.BindLogDepth(a,this._activeEffect,o),ke.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var l=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(o.getProjectionMatrix()),u=o.getEngine().getDeltaTime();u!==this._lastDeltaTime&&(this._lastDeltaTime=u,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",l),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,i){var r=this;this._refractionRTT=new ji(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=To.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=To.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new ji(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=To.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=To.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s,l=te.Zero();this._refractionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=zo.FromPositionAndNormal(new y(0,u+.05,0),new y(0,1,0))}},this._refractionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),r.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=zo.FromPositionAndNormal(new y(0,u-.05,0),new y(0,-1,0)),te.ReflectionToRef(e.clipPlane,l)}s=e.getViewMatrix(),l.multiplyToRef(s,r._reflectionTransform),e.setTransformMatrix(r._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=y.TransformCoordinates(e.activeCamera.position,l)},this._reflectionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),e.clipPlane=a,e.setTransformMatrix(s,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);return this._bumpTexture&&e.push(this._bumpTexture),e},t.prototype.hasTexture=function(e){return!!(n.prototype.hasTexture.call(this,e)||this._bumpTexture===e)},t.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);i!=-1&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),i!=-1&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),n.prototype.dispose.call(this,e)},t.prototype.clone=function(e){var i=this;return Be.Clone(function(){return new t(e,i.getScene())},this)},t.prototype.serialize=function(){var e=Be.Serialize(this);if(e.customType="BABYLON.WaterMaterial",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var i=0;i<this._refractionRTT.renderList.length;i++)e.renderList.push(this._refractionRTT.renderList[i].id);return e},t.prototype.getClassName=function(){return"WaterMaterial"},t.Parse=function(e,i,r){var o=Be.Parse(function(){return new t(e.name,i)},e,i,r);return o._waitingRenderList=e.renderList,o},t.CreateDefaultMesh=function(e,i){var r=ne.CreateGround(e,512,512,32,i,!1);return r},R([at("bumpTexture")],t.prototype,"_bumpTexture",void 0),R([ye("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),R([Vt()],t.prototype,"diffuseColor",void 0),R([Vt()],t.prototype,"specularColor",void 0),R([w()],t.prototype,"specularPower",void 0),R([w("disableLighting")],t.prototype,"_disableLighting",void 0),R([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),R([w("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),R([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),R([w()],t.prototype,"windForce",void 0),R([Pb()],t.prototype,"windDirection",void 0),R([w()],t.prototype,"waveHeight",void 0),R([w()],t.prototype,"bumpHeight",void 0),R([w("bumpSuperimpose")],t.prototype,"_bumpSuperimpose",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpSuperimpose",void 0),R([w("fresnelSeparate")],t.prototype,"_fresnelSeparate",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"fresnelSeparate",void 0),R([w("bumpAffectsReflection")],t.prototype,"_bumpAffectsReflection",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpAffectsReflection",void 0),R([Vt()],t.prototype,"waterColor",void 0),R([w()],t.prototype,"colorBlendFactor",void 0),R([Vt()],t.prototype,"waterColor2",void 0),R([w()],t.prototype,"colorBlendFactor2",void 0),R([w()],t.prototype,"waveLength",void 0),R([w()],t.prototype,"waveSpeed",void 0),R([w()],t.prototype,"waveCount",void 0),R([w()],t.prototype,"disableClipPlane",void 0),R([w()],t.prototype,"useLogarithmicDepth",null),t}(wr);Ae.RegisteredTypes["BABYLON.WaterMaterial"]=nK;function oK(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const aK=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function sK(n,t,e){async function i(u,f){return Ee.CreateScreenshotUsingRenderTargetAsync(n,e,{width:u,height:f},void 0,void 0,!0)}async function r(u){e.inertialRadiusOffset=e.inertialRadiusOffset+u}async function o(u){const{x:f,y:c,z:h}=u;e.target.x=f||0,e.target.y=c||0,e.target.z=h||0}async function a(u){const{alpha:f,beta:c,radius:h}=u;f&&(e.alpha=e.alpha+f),c&&(e.beta=e.beta+c),h&&(e.radius=e.radius+h)}async function s(){const u=t.meshes.filter(p=>!p.name.toLowerCase().includes("collider")).reduce((p,_)=>p+Math.floor(_.getTotalIndices()/3),0),f=t.materials.length,c=t.meshes.length,h=t.textures.filter(p=>p.name&&!aK.includes(p.name)).length;return{triangles:u,materials:f,meshes:c,textures:h,bodies:c,entities:1}}async function l(){}return{getScreenshot:i,getMetrics:s,panCamera:o,changeZoom:r,changeCameraPosition:a,cleanup:l}}var lK={};const sD=lK.VITE_REACT_APP_DEBUG;let tM=!1;const uK=async()=>{sD&&!tM&&(await mX(()=>import("./babylon.inspector.bundle.max-4XymwKTS.js").then(n=>n.b),[]),tM=!0)};function fK(n){const t=n.getChildren().filter(e=>e.id!=="__root__");if(t.length>0){const e=t[0];let i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld.add(e.position),o=i.boundingBox.maximumWorld.add(e.position);for(let a=1;a<t.length;a++){const s=t[a];i=s.getBoundingInfo();const l=i.boundingBox.minimumWorld.add(s.position),u=i.boundingBox.maximumWorld.add(s.position);r=y.Minimize(r,l),o=y.Maximize(o,u)}n.setBoundingInfo(new hr(r,o))}}let Ul;async function cK(n,t){Ul&&Ul.dispose(),Ul=new Me(n,!0,{preserveDrawingBuffer:!0,stencil:!0,antialias:!0});const e=new Ke(Ul);if(e.autoClear=!0,e.clearColor=t.background.transparent?new Je(0,0,0,0):Fy(t.background.color).toColor4(),e.ambientColor=new _e(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=Vv.CreateGround("ground",{width:6,height:6},e),l=Vv.CreateGround("ground",{width:6,height:6},e);l.rotate(Mi.Z,Math.PI),l.position.y=-.05;const u=new aD("groundMaterial",e);u.mainColor=new _e(1,1,1),u.lineColor=new _e(0,0,0),u.majorUnitFrequency=0,s.material=u,l.material=u;const f=Vv.CreateCylinder("boundaries",{diameter:2,height:3}),c=new Mt("boundariesMaterial",e);c.alpha=.3,c.diffuseColor=new _e(1,45/255,85/255),f.material=c,f.position.y=1.51}if(t.showThumbnailBoundaries){const s=Jb.CreateFullscreenUI("UI"),l=new lo;l.width=.5,l.height=1,l.color="#736E7D",l.thickness=2,s.addControl(l)}const i=new tl("camera",0,0,0,new y(0,0,0),e);switch(i.position=new y(t.cameraX,t.cameraY,t.cameraZ),i.minZ=.1,t.projection){case Ce.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ce.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ce.PreviewType.WEARABLE&&QI(i,t),t.camera===Ce.PreviewCamera.INTERACTIVE&&i.attachControl(n,!0);const r=new y(t.offsetX,t.offsetY,t.offsetZ);if(i.position.addInPlace(r),i.setTarget(r),i.lowerRadiusLimit=i.radius/t.zoom,i.upperRadiusLimit=i.lowerRadiusLimit*t.wheelZoom,i.radius=i.lowerRadiusLimit+(i.upperRadiusLimit-i.lowerRadiusLimit)*t.wheelStart/100,i.wheelPrecision=t.wheelPrecision,t.panning||(i.panningSensibility=0),t.lockBeta&&(i.lowerBetaLimit=i.beta,i.upperBetaLimit=i.beta),t.lockAlpha&&(i.lowerAlphaLimit=i.alpha,i.upperAlphaLimit=i.alpha),t.lockRadius&&(i.lowerRadiusLimit=i.radius,i.upperRadiusLimit=i.radius),t.type===Ce.PreviewType.WEARABLE){const s=new pu("directional",new y(0,0,1),e);s.intensity=1;const l=new _u("spot",new y(-2,2,2),new y(2,-2,-2),Math.PI/2,1e3,e);l.intensity=1}const o=new jo("top",new y(0,-1,0),e);o.intensity=1;const a=new jo("bottom",new y(0,1,0),e);if(a.intensity=1,!oK()){const s=new pp("glow",e);s.intensity=2}return Ul.runRenderLoop(()=>{e.render()}),sD&&(await uK(),e.debugLayer.show({showExplorer:!0,embedMode:!0})),[e,sK(Ul,e,i)]}async function hK(n,t,e){const i=t.id,o=mu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Xb(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}async function dK(n,t,e){const i=t.id,o=mu(t,e).contents.find(a=>a.key.toLowerCase().endsWith(".png")&&!a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Xb(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function pK(n,t,e){return new Promise((i,r)=>{var u;const o=(u=t.contents.find(f=>e!==null?e?f.key.toLowerCase().endsWith(e.toLowerCase()):null:f.key.toLowerCase().endsWith(".mp3")||f.key.toLowerCase().endsWith("ogg")))==null?void 0:u.url;if(!o)return i(null);const a=new NI("Sound task",o),s=()=>i(new iu("music",a.data,n,null,{spatialSound:!0})),l=f=>r(f);a.run(n,s,l)})}async function lD(n,t){const e=async(i,r)=>$t.LoadAssetContainerAsync(i,"",n,null,r);try{return await e(t,".glb")}catch{return await e(t,".gltf")}}function _K(n){const t=new ne("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);fK(t);const i=t.getBoundingInfo().boundingBox.extendSize.length(),r=new y(1/i,1/i,1/i);t.scaling=r;const o=t.getBoundingInfo().boundingBox.center.multiply(r);t.position.subtractInPlace(o)}var mK={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.1"};const gK=[Ce.PreviewEmote.IDLE,Ce.PreviewEmote.MONEY,Ce.PreviewEmote.CLAP,Ce.PreviewEmote.WALK,Ce.PreviewEmote.RUN,Ce.PreviewEmote.JUMP];let Cd;function vK(n){return gK.includes(n)}function yK(n){let t=mK.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function uD(n,t){const e=await lD(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function bK(n,t,e){const i=Kb(t,e.bodyShape),r=i.contents.find(o=>o.key===i.mainFile);if(!r)throw new Error(`Could not find a valid content in representation for emote=${t.id} and bodyShape=${e.bodyShape}`);return uD(n,r.url)}function EK(n,t,e){const i=Kb(t,e.bodyShape),r=e.socialEmote?e.socialEmote.audio:null;return pK(n,i,r)}async function TK(n,t,e,i){var u,f,c;let r,o=!!e.emote&&vK(e.emote),a=null;if(e.item&&Co(e.item))try{r=await bK(n,e.item,e),o=e.socialEmote?e.socialEmote.loop:e.item.emoteDataADR74.loop,a=await EK(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!r&&e.emote){const h=yK(e.emote);r=await uD(n,h)}r&&r.animationGroups.length>1&&(r.addAllToScene(),n.stopAllAnimations());const s=new Rb("emote",n);function l(){if(e.camera!==Ce.PreviewCamera.STATIC){const h=n.cameras[0];QI(h,e)}}try{for(const p of t){const _=new Map,g=[...p.container.transformNodes,...p.container.meshes];for(const v of g){const E=v.name.replace(/\.\d+$/,""),T=_.get(E)||[];T.push(v),_.set(E,T)}if(r&&r.animationGroups.length>0){for(const v of r.animationGroups)if(!(e.socialEmote&&!aX(v,e.socialEmote)))for(const E of v.targetedAnimations){const T=E.animation.clone(),S=E.target,C=E.animation.getKeys();if(T.setKeys([...C]),e.socialEmote){const O=((u=e.socialEmote.Armature)==null?void 0:u.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature.animation.toLowerCase()),A=((f=e.socialEmote.Armature_Other)==null?void 0:f.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature_Other.animation.toLowerCase()),M=((c=e.socialEmote.Armature_Prop)==null?void 0:c.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature_Prop.animation.toLowerCase());if(O&&!A&&!M){const D=S.name.replace(/\.\d+$/,""),U=_.get(D)||[];if(U.length>0)for(const V of U){const B=T.clone();B.setKeys([...C]),s.addTargetedAnimation(B,V)}else console.warn("No matching bone found for",S.name)}else if(A){const D=S.name.replace(/\.\d+$/,""),U=_.get(D)||[];if(U.length>0)for(const V of U){const B=i==null?void 0:i.get(V);if(!B)continue;const z=T.clone();z.setKeys([...C]),s.addTargetedAnimation(z,B)}else console.warn("No matching bone found for",S.name)}else M&&s.addTargetedAnimation(T,S)}else if(r.animationGroups.length===1||v.name.toLowerCase().includes("avatar")||S.name.startsWith("Avatar_")){const A=S.name.replace(/\.\d+$/,""),M=_.get(A)||[];if(M.length>0)for(const D of M){const U=T.clone();U.setKeys([...C]),s.addTargetedAnimation(U,D)}else console.warn("No matching bone found for",S.name)}else s.addTargetedAnimation(T,S)}}}s.onAnimationGroupEndObservable.addOnce(l);const h=SK(s,o,a,e.item,e.socialEmote);return e.camera===Ce.PreviewCamera.STATIC&&h.stop(),h}catch(h){console.warn(`Could not play emote=${e.emote}`,h)}}function SK(n,t,e,i,r){Me.audioEngine.useCustomUnlockedButton=!0,Me.audioEngine.setGlobalVolume(1);let o,a=!1;async function s(){return Math.max(n.to,0)}async function l(){return n.isPlaying}async function u(){return!!e}async function f(A){a=!0;const M=await l();M&&n.pause(),n.stop(),n.start(!1,1,A,A,!1),o=A,a=!0,M&&c()}async function c(){await l()||(o?(n.start(t,1,o,await s(),!1),e&&(e.stop(),e._startOffset=o,e.play()),o=0):(n.play(t),e==null||e.play()))}async function h(){await l()&&(n.pause(),e==null||e.pause())}async function p(){n.goToFrame(0),n.stop(),e==null||e.stop()}async function _(){e&&(Me.audioEngine.unlock(),Me.audioEngine.setGlobalVolume(1),n.isPlaying&&!e.isPlaying&&e.play(void 0,n.targetedAnimations[0].animation.runtimeAnimations[0].currentFrame))}async function g(){e&&Me.audioEngine.setGlobalVolume(0)}async function v(){return HM(i)}async function E(){return await v()?[{title:"Start Animation",...i.emoteDataADR74.startAnimation},...i.emoteDataADR74.outcomes.map(A=>({title:A.title,loop:A.loop,audio:A.audio,...A.clips}))]:null}async function T(){return r??null}const S=Sb(),C=()=>(Cd&&clearInterval(Cd),window.setInterval(async()=>{var A;if(await l()&&n.animatables[0].masterFrame>0)return S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(A=n.animatables[0])==null?void 0:A.masterFrame})},10)),O=()=>{clearInterval(Cd),a||S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(Cd=C(),S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{S.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),a&&(p(),c(),a=!1),S.emit(Ce.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(O(),t||(a=!1),S.emit(Ce.PreviewEmoteEventType.ANIMATION_END))),{getLength:s,isPlaying:l,goTo:f,play:c,pause:h,stop:p,enableSound:_,disableSound:g,hasSound:u,events:S,emote:i,isSocialEmote:v,getSocialEmoteAnimations:E,getPlayingSocialEmoteAnimation:T}}function CK(n,t,e){return async i=>{const r=t.find(iX(i));return r?Promise.all([dK(n,r,e),hK(n,r,e)]):[null,null]}}async function PK(n,t,e){const i=CK(n,t,e),[r,o,a]=await Promise.all([i(Ce.WearableCategory.EYES),i(Ce.WearableCategory.EYEBROWS),i(Ce.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function AK(n,t,e,i,r,o){for(const a of t.container.meshes){if(a.name.toLowerCase().endsWith("mask_eyes")){const[s,l]=e;s?fy(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?fy(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?fy(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function fy(n,t,e,i,r,o,a){const s=new Mt(`${t}_standard_material`,n);s.alphaMode=Ci.PBRMATERIAL_ALPHABLEND,s.backFaceCulling=!0,s.specularColor=_e.Black(),i.hasAlpha=!0,s.sideOrientation=qs.CW,s.diffuseTexture=i,s.diffuseColor=o?_e.Black():Fy(a),o&&(s.emissiveTexture=o,s.diffuseColor=Fy(r)),e.material=s}function RK(n,t,e=Ce.BodyShape.MALE){const i={};for(const r of n)try{const o=mu(r,e);for(const a of o.contents)i[a.key]=a.url}catch{console.warn(`Skipping generation of mappings for wearable="${r.id}" since it lacks a representation for bodyShape="${e}"`);continue}if(t){const r=Kb(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function OK(n){const t=as(n.item)?[n.item,...n.wearables]:n.wearables,e=Co(n.item)?n.item:void 0,i=RK(t,e,n.bodyShape);$t.OnPluginActivatedObservable.add(r=>{if(r.name==="gltf"){const o=r;o.preprocessUrlAsync=async a=>{const l=a.split("/").pop();if(!l)return a;const f=Object.keys(i).find(c=>c.endsWith(l));return i[f]||a}}})}const MK=`float angleY = 3.14 / 2.0;
16066
+ `;ce.ShadersStore[tK]=iK;var rK=function(n){j(t,n);function t(){var e=n.call(this)||this;return e.BUMP=!1,e.REFLECTION=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.UV1=!1,e.UV2=!1,e.VERTEXCOLOR=!1,e.VERTEXALPHA=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SPECULARTERM=!1,e.LOGARITHMICDEPTH=!1,e.FRESNELSEPARATE=!1,e.BUMPSUPERIMPOSE=!1,e.BUMPAFFECTSREFLECTION=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.rebuild(),e}return t}(Er),nK=function(n){j(t,n);function t(e,i,r){r===void 0&&(r=new Ie(512,512));var o=n.call(this,e,i)||this;return o.renderTargetSize=r,o.diffuseColor=new _e(1,1,1),o.specularColor=new _e(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new Ie(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new _e(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new _e(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new yr(16),o._mesh=null,o._reflectionTransform=te.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,r),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add(function(){o._markAllSubMeshesAsImageProcessingDirty()})),o}return Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&this._refractionRTT.refreshRate===0)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,i,r){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new rK);var o=i._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled)){if(this.bumpTexture&&ke.BumpTextureEnabled)if(this.bumpTexture.isReady())o._needUVs=!0,o.BUMP=!0;else return!1;ke.ReflectionTextureEnabled&&(o.REFLECTION=!0)}if(oe.PrepareDefinesForFrameBoundValues(a,s,o,!!r),oe.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._areMiscDirty&&(this._fresnelSeparate&&(o.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(o.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(o.BUMPAFFECTSREFLECTION=!0)),o._needNormals=oe.PrepareDefinesForLights(a,e,o,!0,this._maxSimultaneousLights,this._disableLighting),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(oe.PrepareDefinesForAttributes(e,o,!0,!0),this._mesh=e,this._waitingRenderList){for(var l=0;l<this._waitingRenderList.length;l++)this.addToRenderList(a.getNodeByID(this._waitingRenderList[l]));this._waitingRenderList=null}if(o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var u=new Tr;o.FOG&&u.addFallback(1,"FOG"),o.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),oe.HandleFallbacksForShadows(o,u,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e);var f=[I.PositionKind];o.NORMAL&&f.push(I.NormalKind),o.UV1&&f.push(I.UVKind),o.UV2&&f.push(I.UV2Kind),o.VERTEXCOLOR&&f.push(I.ColorKind),oe.PrepareAttributesForBones(f,e,o,u),oe.PrepareAttributesForInstances(f,o);var c="water",h=o.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],_=["normalSampler","refractionSampler","reflectionSampler"],g=new Array;Hi&&(Hi.PrepareUniforms(p,o),Hi.PrepareSamplers(_,o)),oe.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(a.getEngine().createEffect(c,{attributes:f,uniformsNames:p,uniformBuffersNames:g,samplers:_,defines:h,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o)}return!i.effect||!i.effect.isReady()?!1:(o._renderId=a.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,i,r){var o=this.getScene(),a=r._materialDefines;if(a){var s=r.effect;if(!(!s||!this._mesh)){this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),oe.BindBonesParameters(i,this._activeEffect),this._mustRebind(o,s)&&(this.bumpTexture&&ke.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),oe.BindClipPlane(this._activeEffect,o),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),oe.BindEyePosition(s,o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),a.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),o.lightsEnabled&&!this.disableLighting&&oe.BindLights(o,i,this._activeEffect,a,this.maxSimultaneousLights),o.fogEnabled&&i.applyFog&&o.fogMode!==Ke.FOGMODE_NONE&&this._activeEffect.setMatrix("view",o.getViewMatrix()),oe.BindFogParameters(o,i,this._activeEffect),oe.BindLogDepth(a,this._activeEffect,o),ke.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var l=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(o.getProjectionMatrix()),u=o.getEngine().getDeltaTime();u!==this._lastDeltaTime&&(this._lastDeltaTime=u,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",l),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,i){var r=this;this._refractionRTT=new ji(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=To.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=To.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new ji(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=To.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=To.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s,l=te.Zero();this._refractionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=zo.FromPositionAndNormal(new y(0,u+.05,0),new y(0,1,0))}},this._refractionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),r.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(r._mesh&&(o=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){a=e.clipPlane;var u=r._mesh?r._mesh.position.y:0;e.clipPlane=zo.FromPositionAndNormal(new y(0,u-.05,0),new y(0,-1,0)),te.ReflectionToRef(e.clipPlane,l)}s=e.getViewMatrix(),l.multiplyToRef(s,r._reflectionTransform),e.setTransformMatrix(r._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=y.TransformCoordinates(e.activeCamera.position,l)},this._reflectionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=o),e.clipPlane=a,e.setTransformMatrix(s,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);return this._bumpTexture&&e.push(this._bumpTexture),e},t.prototype.hasTexture=function(e){return!!(n.prototype.hasTexture.call(this,e)||this._bumpTexture===e)},t.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);i!=-1&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),i!=-1&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),n.prototype.dispose.call(this,e)},t.prototype.clone=function(e){var i=this;return Be.Clone(function(){return new t(e,i.getScene())},this)},t.prototype.serialize=function(){var e=Be.Serialize(this);if(e.customType="BABYLON.WaterMaterial",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var i=0;i<this._refractionRTT.renderList.length;i++)e.renderList.push(this._refractionRTT.renderList[i].id);return e},t.prototype.getClassName=function(){return"WaterMaterial"},t.Parse=function(e,i,r){var o=Be.Parse(function(){return new t(e.name,i)},e,i,r);return o._waitingRenderList=e.renderList,o},t.CreateDefaultMesh=function(e,i){var r=ne.CreateGround(e,512,512,32,i,!1);return r},R([at("bumpTexture")],t.prototype,"_bumpTexture",void 0),R([ye("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),R([Vt()],t.prototype,"diffuseColor",void 0),R([Vt()],t.prototype,"specularColor",void 0),R([w()],t.prototype,"specularPower",void 0),R([w("disableLighting")],t.prototype,"_disableLighting",void 0),R([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),R([w("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),R([ye("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),R([w()],t.prototype,"windForce",void 0),R([Pb()],t.prototype,"windDirection",void 0),R([w()],t.prototype,"waveHeight",void 0),R([w()],t.prototype,"bumpHeight",void 0),R([w("bumpSuperimpose")],t.prototype,"_bumpSuperimpose",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpSuperimpose",void 0),R([w("fresnelSeparate")],t.prototype,"_fresnelSeparate",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"fresnelSeparate",void 0),R([w("bumpAffectsReflection")],t.prototype,"_bumpAffectsReflection",void 0),R([ye("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpAffectsReflection",void 0),R([Vt()],t.prototype,"waterColor",void 0),R([w()],t.prototype,"colorBlendFactor",void 0),R([Vt()],t.prototype,"waterColor2",void 0),R([w()],t.prototype,"colorBlendFactor2",void 0),R([w()],t.prototype,"waveLength",void 0),R([w()],t.prototype,"waveSpeed",void 0),R([w()],t.prototype,"waveCount",void 0),R([w()],t.prototype,"disableClipPlane",void 0),R([w()],t.prototype,"useLogarithmicDepth",null),t}(wr);Ae.RegisteredTypes["BABYLON.WaterMaterial"]=nK;function oK(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)}const aK=["data:EnvironmentBRDFTexture0","GlowLayerBlurRTT","GlowLayerBlurRTT2","HighlightLayerMainRTT"];function sK(n,t,e){async function i(u,f){return Ee.CreateScreenshotUsingRenderTargetAsync(n,e,{width:u,height:f},void 0,void 0,!0)}async function r(u){e.inertialRadiusOffset=e.inertialRadiusOffset+u}async function o(u){const{x:f,y:c,z:h}=u;e.target.x=f||0,e.target.y=c||0,e.target.z=h||0}async function a(u){const{alpha:f,beta:c,radius:h}=u;f&&(e.alpha=e.alpha+f),c&&(e.beta=e.beta+c),h&&(e.radius=e.radius+h)}async function s(){const u=t.meshes.filter(p=>!p.name.toLowerCase().includes("collider")).reduce((p,_)=>p+Math.floor(_.getTotalIndices()/3),0),f=t.materials.length,c=t.meshes.length,h=t.textures.filter(p=>p.name&&!aK.includes(p.name)).length;return{triangles:u,materials:f,meshes:c,textures:h,bodies:c,entities:1}}async function l(){}return{getScreenshot:i,getMetrics:s,panCamera:o,changeZoom:r,changeCameraPosition:a,cleanup:l}}var lK={};const sD=lK.VITE_REACT_APP_DEBUG;let tM=!1;const uK=async()=>{sD&&!tM&&(await mX(()=>import("./babylon.inspector.bundle.max-CG6ul9_J.js").then(n=>n.b),[]),tM=!0)};function fK(n){const t=n.getChildren().filter(e=>e.id!=="__root__");if(t.length>0){const e=t[0];let i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld.add(e.position),o=i.boundingBox.maximumWorld.add(e.position);for(let a=1;a<t.length;a++){const s=t[a];i=s.getBoundingInfo();const l=i.boundingBox.minimumWorld.add(s.position),u=i.boundingBox.maximumWorld.add(s.position);r=y.Minimize(r,l),o=y.Maximize(o,u)}n.setBoundingInfo(new hr(r,o))}}let Ul;async function cK(n,t){Ul&&Ul.dispose(),Ul=new Me(n,!0,{preserveDrawingBuffer:!0,stencil:!0,antialias:!0});const e=new Ke(Ul);if(e.autoClear=!0,e.clearColor=t.background.transparent?new Je(0,0,0,0):Fy(t.background.color).toColor4(),e.ambientColor=new _e(1,1,1),e.preventDefaultOnPointerDown=!1,t.showSceneBoundaries){const s=Vv.CreateGround("ground",{width:6,height:6},e),l=Vv.CreateGround("ground",{width:6,height:6},e);l.rotate(Mi.Z,Math.PI),l.position.y=-.05;const u=new aD("groundMaterial",e);u.mainColor=new _e(1,1,1),u.lineColor=new _e(0,0,0),u.majorUnitFrequency=0,s.material=u,l.material=u;const f=Vv.CreateCylinder("boundaries",{diameter:2,height:3}),c=new Mt("boundariesMaterial",e);c.alpha=.3,c.diffuseColor=new _e(1,45/255,85/255),f.material=c,f.position.y=1.51}if(t.showThumbnailBoundaries){const s=Jb.CreateFullscreenUI("UI"),l=new lo;l.width=.5,l.height=1,l.color="#736E7D",l.thickness=2,s.addControl(l)}const i=new tl("camera",0,0,0,new y(0,0,0),e);switch(i.position=new y(t.cameraX,t.cameraY,t.cameraZ),i.minZ=.1,t.projection){case Ce.PreviewProjection.PERSPECTIVE:{i.mode=dt.PERSPECTIVE_CAMERA;break}case Ce.PreviewProjection.ORTHOGRAPHIC:{i.mode=dt.ORTHOGRAPHIC_CAMERA,i.orthoTop=1,i.orthoBottom=-1,i.orthoLeft=-1,i.orthoRight=1;break}}t.type===Ce.PreviewType.WEARABLE&&QI(i,t),t.camera===Ce.PreviewCamera.INTERACTIVE&&i.attachControl(n,!0);const r=new y(t.offsetX,t.offsetY,t.offsetZ);if(i.position.addInPlace(r),i.setTarget(r),i.lowerRadiusLimit=i.radius/t.zoom,i.upperRadiusLimit=i.lowerRadiusLimit*t.wheelZoom,i.radius=i.lowerRadiusLimit+(i.upperRadiusLimit-i.lowerRadiusLimit)*t.wheelStart/100,i.wheelPrecision=t.wheelPrecision,t.panning||(i.panningSensibility=0),t.lockBeta&&(i.lowerBetaLimit=i.beta,i.upperBetaLimit=i.beta),t.lockAlpha&&(i.lowerAlphaLimit=i.alpha,i.upperAlphaLimit=i.alpha),t.lockRadius&&(i.lowerRadiusLimit=i.radius,i.upperRadiusLimit=i.radius),t.type===Ce.PreviewType.WEARABLE){const s=new pu("directional",new y(0,0,1),e);s.intensity=1;const l=new _u("spot",new y(-2,2,2),new y(2,-2,-2),Math.PI/2,1e3,e);l.intensity=1}const o=new jo("top",new y(0,-1,0),e);o.intensity=1;const a=new jo("bottom",new y(0,1,0),e);if(a.intensity=1,!oK()){const s=new pp("glow",e);s.intensity=2}return Ul.runRenderLoop(()=>{e.render()}),sD&&(await uK(),e.debugLayer.show({showExplorer:!0,embedMode:!0})),[e,sK(Ul,e,i)]}async function hK(n,t,e){const i=t.id,o=mu(t,e).contents.find(a=>a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Xb(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}async function dK(n,t,e){const i=t.id,o=mu(t,e).contents.find(a=>a.key.toLowerCase().endsWith(".png")&&!a.key.toLowerCase().endsWith("_mask.png"));return o?new Promise((a,s)=>{const l=new Xb(i,o.url,!0,!1);l.onError=()=>s(l.errorObject),l.onSuccess=()=>{a(l.texture)},l.run(n,()=>a(l.texture),s)}):null}function pK(n,t,e){return new Promise((i,r)=>{var u;const o=(u=t.contents.find(f=>e!==null?e?f.key.toLowerCase().endsWith(e.toLowerCase()):null:f.key.toLowerCase().endsWith(".mp3")||f.key.toLowerCase().endsWith("ogg")))==null?void 0:u.url;if(!o)return i(null);const a=new NI("Sound task",o),s=()=>i(new iu("music",a.data,n,null,{spatialSound:!0})),l=f=>r(f);a.run(n,s,l)})}async function lD(n,t){const e=async(i,r)=>$t.LoadAssetContainerAsync(i,"",n,null,r);try{return await e(t,".glb")}catch{return await e(t,".gltf")}}function _K(n){const t=new ne("parent",n);for(const a of n.meshes)a!==t&&a.setParent(t);fK(t);const i=t.getBoundingInfo().boundingBox.extendSize.length(),r=new y(1/i,1/i,1/i);t.scaling=r;const o=t.getBoundingInfo().boundingBox.center.multiply(r);t.position.subtractInPlace(o)}var mK={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.2"};const gK=[Ce.PreviewEmote.IDLE,Ce.PreviewEmote.MONEY,Ce.PreviewEmote.CLAP,Ce.PreviewEmote.WALK,Ce.PreviewEmote.RUN,Ce.PreviewEmote.JUMP];let Cd;function vK(n){return gK.includes(n)}function yK(n){let t=mK.VITE_BASE_URL;t.endsWith("/")||(t+="/");const e=`./emotes/${n}.glb`;return t.startsWith("http")?new URL(e,t).href:e}async function uD(n,t){const e=await lD(n,t);if(e.animationGroups.length===0)throw new Error(`No animation groups found for emote with url=${t}`);return e}async function bK(n,t,e){const i=Kb(t,e.bodyShape),r=i.contents.find(o=>o.key===i.mainFile);if(!r)throw new Error(`Could not find a valid content in representation for emote=${t.id} and bodyShape=${e.bodyShape}`);return uD(n,r.url)}function EK(n,t,e){const i=Kb(t,e.bodyShape),r=e.socialEmote?e.socialEmote.audio:null;return pK(n,i,r)}async function TK(n,t,e,i){var u,f,c;let r,o=!!e.emote&&vK(e.emote),a=null;if(e.item&&Co(e.item))try{r=await bK(n,e.item,e),o=e.socialEmote?e.socialEmote.loop:e.item.emoteDataADR74.loop,a=await EK(n,e.item,e)}catch{console.warn(`Could not load emote=${e.item.id}`)}if(!r&&e.emote){const h=yK(e.emote);r=await uD(n,h)}r&&r.animationGroups.length>1&&(r.addAllToScene(),n.stopAllAnimations());const s=new Rb("emote",n);function l(){if(e.camera!==Ce.PreviewCamera.STATIC){const h=n.cameras[0];QI(h,e)}}try{for(const p of t){const _=new Map,g=[...p.container.transformNodes,...p.container.meshes];for(const v of g){const E=v.name.replace(/\.\d+$/,""),T=_.get(E)||[];T.push(v),_.set(E,T)}if(r&&r.animationGroups.length>0){for(const v of r.animationGroups)if(!(e.socialEmote&&!aX(v,e.socialEmote)))for(const E of v.targetedAnimations){const T=E.animation.clone(),S=E.target,C=E.animation.getKeys();if(T.setKeys([...C]),e.socialEmote){const O=((u=e.socialEmote.Armature)==null?void 0:u.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature.animation.toLowerCase()),A=((f=e.socialEmote.Armature_Other)==null?void 0:f.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature_Other.animation.toLowerCase()),M=((c=e.socialEmote.Armature_Prop)==null?void 0:c.animation)&&v.name.toLowerCase().startsWith(e.socialEmote.Armature_Prop.animation.toLowerCase());if(O&&!A&&!M){const D=S.name.replace(/\.\d+$/,""),U=_.get(D)||[];if(U.length>0)for(const V of U){const B=T.clone();B.setKeys([...C]),s.addTargetedAnimation(B,V)}else console.warn("No matching bone found for",S.name)}else if(A){const D=S.name.replace(/\.\d+$/,""),U=_.get(D)||[];if(U.length>0)for(const V of U){const B=i==null?void 0:i.get(V);if(!B)continue;const z=T.clone();z.setKeys([...C]),s.addTargetedAnimation(z,B)}else console.warn("No matching bone found for",S.name)}else M&&s.addTargetedAnimation(T,S)}else if(r.animationGroups.length===1||v.name.toLowerCase().includes("avatar")||S.name.startsWith("Avatar_")){const A=S.name.replace(/\.\d+$/,""),M=_.get(A)||[];if(M.length>0)for(const D of M){const U=T.clone();U.setKeys([...C]),s.addTargetedAnimation(U,D)}else console.warn("No matching bone found for",S.name)}else s.addTargetedAnimation(T,S)}}}s.onAnimationGroupEndObservable.addOnce(l);const h=SK(s,o,a,e.item,e.socialEmote);return e.camera===Ce.PreviewCamera.STATIC&&h.stop(),h}catch(h){console.warn(`Could not play emote=${e.emote}`,h)}}function SK(n,t,e,i,r){Me.audioEngine.useCustomUnlockedButton=!0,Me.audioEngine.setGlobalVolume(1);let o,a=!1;async function s(){return Math.max(n.to,0)}async function l(){return n.isPlaying}async function u(){return!!e}async function f(A){a=!0;const M=await l();M&&n.pause(),n.stop(),n.start(!1,1,A,A,!1),o=A,a=!0,M&&c()}async function c(){await l()||(o?(n.start(t,1,o,await s(),!1),e&&(e.stop(),e._startOffset=o,e.play()),o=0):(n.play(t),e==null||e.play()))}async function h(){await l()&&(n.pause(),e==null||e.pause())}async function p(){n.goToFrame(0),n.stop(),e==null||e.stop()}async function _(){e&&(Me.audioEngine.unlock(),Me.audioEngine.setGlobalVolume(1),n.isPlaying&&!e.isPlaying&&e.play(void 0,n.targetedAnimations[0].animation.runtimeAnimations[0].currentFrame))}async function g(){e&&Me.audioEngine.setGlobalVolume(0)}async function v(){return HM(i)}async function E(){return await v()?[{title:"Start Animation",...i.emoteDataADR74.startAnimation},...i.emoteDataADR74.outcomes.map(A=>({title:A.title,loop:A.loop,audio:A.audio,...A.clips}))]:null}async function T(){return r??null}const S=Sb(),C=()=>(Cd&&clearInterval(Cd),window.setInterval(async()=>{var A;if(await l()&&n.animatables[0].masterFrame>0)return S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:(A=n.animatables[0])==null?void 0:A.masterFrame})},10)),O=()=>{clearInterval(Cd),a||S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:n.to})};return n.onAnimationGroupPlayObservable.add(()=>(Cd=C(),S.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))),n.onAnimationGroupPauseObservable.add(()=>{S.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE)}),n.onAnimationGroupLoopObservable.add(()=>(e==null||e.stop(),e==null||e.play(),a&&(p(),c(),a=!1),S.emit(Ce.PreviewEmoteEventType.ANIMATION_LOOP))),n.onAnimationGroupEndObservable.add(()=>(O(),t||(a=!1),S.emit(Ce.PreviewEmoteEventType.ANIMATION_END))),{getLength:s,isPlaying:l,goTo:f,play:c,pause:h,stop:p,enableSound:_,disableSound:g,hasSound:u,events:S,emote:i,isSocialEmote:v,getSocialEmoteAnimations:E,getPlayingSocialEmoteAnimation:T}}function CK(n,t,e){return async i=>{const r=t.find(iX(i));return r?Promise.all([dK(n,r,e),hK(n,r,e)]):[null,null]}}async function PK(n,t,e){const i=CK(n,t,e),[r,o,a]=await Promise.all([i(Ce.WearableCategory.EYES),i(Ce.WearableCategory.EYEBROWS),i(Ce.WearableCategory.MOUTH)]);return{eyes:r,eyebrows:o,mouth:a}}async function AK(n,t,e,i,r,o){for(const a of t.container.meshes){if(a.name.toLowerCase().endsWith("mask_eyes")){const[s,l]=e;s?fy(n,"eyes",a,s,o.eyes,l,"#ffffff"):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_eyebrows")){const[s,l]=i;s?fy(n,"eyebrows",a,s,o.hair,l,o.hair):a.setEnabled(!1)}if(a.name.toLowerCase().endsWith("mask_mouth")){const[s,l]=r;s?fy(n,"mouth",a,s,o.skin,l,o.skin):a.setEnabled(!1)}}}function fy(n,t,e,i,r,o,a){const s=new Mt(`${t}_standard_material`,n);s.alphaMode=Ci.PBRMATERIAL_ALPHABLEND,s.backFaceCulling=!0,s.specularColor=_e.Black(),i.hasAlpha=!0,s.sideOrientation=qs.CW,s.diffuseTexture=i,s.diffuseColor=o?_e.Black():Fy(a),o&&(s.emissiveTexture=o,s.diffuseColor=Fy(r)),e.material=s}function RK(n,t,e=Ce.BodyShape.MALE){const i={};for(const r of n)try{const o=mu(r,e);for(const a of o.contents)i[a.key]=a.url}catch{console.warn(`Skipping generation of mappings for wearable="${r.id}" since it lacks a representation for bodyShape="${e}"`);continue}if(t){const r=Kb(t,e);for(const o of r.contents)i[o.key]=o.url}return i}function OK(n){const t=as(n.item)?[n.item,...n.wearables]:n.wearables,e=Co(n.item)?n.item:void 0,i=RK(t,e,n.bodyShape);$t.OnPluginActivatedObservable.add(r=>{if(r.name==="gltf"){const o=r;o.preprocessUrlAsync=async a=>{const l=a.split("/").pop();if(!l)return a;const f=Object.keys(i).find(c=>c.endsWith(l));return i[f]||a}}})}const MK=`float angleY = 3.14 / 2.0;
16067
16067
 
16068
16068
  mat3 rotateY = mat3(
16069
16069
  cos(angleY), 0, sin(angleY),
@@ -16105,4 +16105,4 @@ else
16105
16105
  }
16106
16106
  `,cy="#include<pbrBlockFinalColorComposition>",iM="#include<customToonShading>";if(ce.ShadersStore.pbrPixelShader.includes(cy))ce.ShadersStore.pbrPixelShader.includes(iM)||(ce.ShadersStore.pbrPixelShader=ce.ShadersStore.pbrPixelShader.replace(cy,cy+`
16107
16107
  `+iM+`
16108
- `));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=MK;async function hy(n,t,e=Ce.BodyShape.MALE,i,r){const o=mu(t,e);if(yp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=D5(o),s=await lD(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Ci){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=_e.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=_e.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function xK(n,t){const[e,i]=await cK(n,t);try{OK(t);let r;const o=[];if(t.type===Ce.PreviewType.AVATAR){const s=dX(t),l=Array.from(s.values());for(const p of l.filter(KI)){const _=hy(e,p,t.bodyShape,t.skin,t.hair).catch(g=>{console.warn(g.message)});o.push(_)}let u=null;t.socialEmote&&t.socialEmote.Armature_Other&&(u=new ne("parent_other",e));const f=new Map,c=(await Promise.all(o)).filter(nX);for(const p of c)if(p.container.addAllToScene(),u){const _=p.container.instantiateModelsToScene(S=>`${S}_Other`),v=_e.FromHexString("#c9c9c9").toLinearSpace(),E=_.rootNodes;for(const S of E)S.setParent(u);uX(E,v);const T=lX(p.container,E);for(const[S,C]of T)f.set(S,C)}const h=fX(c);if(h){const p=l.filter(oX),{eyes:_,eyebrows:g,mouth:v}=await PK(e,p,t.bodyShape);AK(e,h,_,g,v,t)}r=await TK(e,c,t,f)||CR()}else{const s=t.item;if(s&&!Co(s))try{(await hy(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await hy(e,s,t.bodyShape===Ce.BodyShape.MALE?Ce.BodyShape.FEMALE:Ce.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=CR()}return t.centerBoundingBox&&_K(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new Je(0,0,0,0),r}}function IK(n){const t=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const DK=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=WM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=YI(),[_,g,v]=eX(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,A]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let z={opacity:1};_.background.image&&(T(_.background.image),z.opacity=1,!_.background.transparent&&_.type===Ce.PreviewType.TEXTURE&&(z.backgroundColor=_.background.color)),o(z),_.type===Ce.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):xK(h.current,_).then(J=>{p.current=J,B=IK(p.current)}).catch(J=>t(J.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.BABYLON}),A(!0),((_==null?void 0:_.type)===Ce.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ce.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:M}),A(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(A(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),XI(),On.jsxs("div",{className:Zl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ce.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[On.jsx("img",{src:E,className:Zl("thumbnail",{"is-visible":U}),alt:"preview"}),On.jsx("canvas",{id:"wearable-preview",className:Zl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&On.jsx("div",{className:"error",children:M})]})},wK=aM.memo(DK);var fD=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(fD||{});const LK={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},NK={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},Pd=(n,t,e)=>{if(n)try{const i=String(t);Object.values(fD).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},FK=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(Pd(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{Pd(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=LK[r];if(a){const s=NK[r],l=s?s(o):String(o);Pd(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&Pd(n,"Reload")};var BK={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.1"};const dy=new Map,kl=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function VK(n){if(dy.has(n))return dy.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return dy.set(n,t),t}const UK=async(n,t,e,i,r,o,a,s,l,u,f,c)=>{try{const h=BK.VITE_BASE_URL||"";return await VK(kl(h,t)),await createUnityInstance(n,{dataUrl:kl(h,e),frameworkUrl:kl(h,i),codeUrl:kl(h,r),streamingAssetsUrl:kl(h,a),symbolUrl:kl(h,o),companyName:s,productName:l,productVersion:u,matchWebGLToCanvasSize:f,arguments:c})}catch(h){throw console.error("❌ Failed to load Unity instance:",h),h}};function kK(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},setUsername:async t=>{n&&n.SendMessage("JSBridge","SetUsername",t)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function zK(n){const t=Sb();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function GK(n){let t=null;try{if(t=await UK(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/unity/Build/aang-renderer.symbols.json.br","/emotes","Decentraland","AangRenderer","2.2.2",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=kK(t),i=zK(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const WK=()=>Math.floor(Math.random()*159)+1,cD=()=>`default${WK()}`,HK=(n,t)=>{var e,i,r,o,a,s;return{eyes:ou(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&au(n.avatar.eyes.color)||"#000000"),hair:ou(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&au(n.avatar.hair.color)||"#000000"),skin:ou(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&au(n.avatar.skin.color)||"#cc9b76")}},ff=n=>n||"",rM=n=>n||[],Ad=n=>n.replace("#","");function nM(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function jK(){const{options:n,overrideSources:t}=$b(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Wf.get("PEER_URL"),E=n.marketplaceServerUrl||n.nftServerUrl||Wf.get("MARKETPLACE_SERVER_URL");let T=Ce.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=kI(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=cD());const A=O&&C?C.type==="address"?await GI(O,v):await WI(O,v):null,M=n.bodyShape||((_=A==null?void 0:A.avatar)==null?void 0:_.bodyShape)||Ce.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await HI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,marketplaceServerUrl:E}),D&&as(D))){S={...S,image:D.thumbnail};const Z=qb(D);yp(Z)&&(T=Ce.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=HK(A,{eyes:n.eyes,hair:n.hair,skin:n.skin}),z=n.unityMode||null,J=n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)?n.camera:Ce.PreviewCamera.INTERACTIVE,X=n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)?n.projection:Ce.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)?n.emote:Ce.PreviewEmote.IDLE,ae={background:S,bodyShape:M,mode:z,projection:X,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},se=JSON.stringify(ae),H=JSON.stringify(l.current);if(se!==H){if(l.current=ae,Object.keys(t).length===0){const Z=rM(n.urns),q=rM(n.base64s);if(z===Ce.PreviewUnityMode.CONFIG){const F={mode:ff(z||"")};nM(F)}else{const F={background:S.transparent?"":Ad(S.color),disableLoader:n.disableLoader?"true":"",profile:ff(O||""),bodyShape:ff(M||""),eyeColor:Ad(U||""),hairColor:Ad(V||""),skinColor:Ad(B||""),mode:ff(z||""),camera:J,projection:X,emote:ff((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:q.length>0?q:[""]};nM(F)}}i(ae)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const XK="unity-renderer",YK="unity-canvas",oM=1,KK="Failed to load Unity",qK=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===XK){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})):u==="customization-done"?Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:"customization-done",ok:!0,result:JSON.parse(l.data.payload.payload)}):u==="error"&&(o(c=>({...c,error:f})),Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await GK(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f},o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})}catch(l){const u=l instanceof Error?l.message:KK;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},QK=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||oM,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||oM}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ce.PreviewType.TEXTURE}))},[n]),t},$K=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:cD()}Object.keys(o).length>0&&(FK(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},ZK=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=WM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=YI(),[s,l,u]=jK(),{options:f,overrideSources:c}=$b(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=qK(h,a,s,l),_=QK(s);$K(h.unityInstance,h.lastSentOverrides,p,f,c),XI();const g=Ct.useMemo(()=>{const A=p.error||u,M=!p.isLoaded&&!A,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:A,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ce.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Zl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Zl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Zl({"is-visible":g.showCanvas}),[g.showCanvas]);return On.jsxs("div",{className:S,style:v,children:[On.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),On.jsx("canvas",{ref:h.canvas,id:YK,className:O,width:T.width,height:T.height,style:E}),g.error&&On.jsx("div",{className:"error",children:g.error})]})},JK=aM.memo(ZK),hD=Ct.createContext(null),eq=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return On.jsx(hD.Provider,{value:e,children:n})},tq=()=>{const n=Ct.useContext(hD);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},iq=()=>tq(),rq=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},nq=async()=>{const{platform:n,browser:t,version:e}=rq();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},oq=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=iq();return t&&e?On.jsx(JK,{}):On.jsx(wK,{})},aq=async()=>{const n=await nq();iL.createRoot(document.getElementById("root")).render(On.jsx(Ct.StrictMode,{children:On.jsx(eq,{value:n,children:On.jsx(oq,{})})}))};aq();export{Xd as $,ut as A,$B as B,P2 as C,tl as D,fx as E,Ob as F,cx as G,hx as H,px as I,_x as J,X4 as K,up as L,ya as M,I8 as N,c5 as O,pa as P,Cq as Q,f2 as R,Wo as S,d2 as T,WU as U,Mi as V,ga as W,yd as X,Bb as Y,wv as Z,e2 as _,zl as a,Yo as a$,Yd as a0,jn as a1,bd as a2,o8 as a3,QB as a4,Tq as a5,NI as a6,eH as a7,wO as a8,PI as a9,JB as aA,RI as aB,O4 as aC,xy as aD,Sa as aE,Pv as aF,YW as aG,kU as aH,_e as aI,RW as aJ,Je as aK,cH as aL,Md as aM,bI as aN,QG as aO,D4 as aP,oI as aQ,cq as aR,Hf as aS,eI as aT,To as aU,h5 as aV,pH as aW,js as aX,y2 as aY,M4 as aZ,Nb as a_,Ur as aa,ss as ab,Dq as ac,Aq as ad,Rq as ae,c4 as af,_q as ag,p2 as ah,kd as ai,uk as aj,Oj as ak,hr as al,yy as am,Xo as an,Uf as ao,Hn as ap,d8 as aq,dt as ar,Kq as as,Ir as at,fp as au,jx as av,Ks as aw,vI as ax,EO as ay,AI as az,Ra as b,BG as b$,m5 as b0,mq as b1,qx as b2,ZB as b3,y5 as b4,sf as b5,s8 as b6,Xn as b7,tI as b8,zb as b9,qU as bA,Mb as bB,QU as bC,Uq as bD,Ri as bE,pu as bF,jb as bG,g4 as bH,bH as bI,z4 as bJ,wq as bK,N4 as bL,YM as bM,x4 as bN,OO as bO,oo as bP,Hl as bQ,UR as bR,R2 as bS,Po as bT,jr as bU,DI as bV,ce as bW,Tr as bX,dp as bY,Uz as bZ,FG as b_,Ws as ba,Bf as bb,Td as bc,B8 as bd,AW as be,jR as bf,HU as bg,FR as bh,gI as bi,rn as bj,zU as bk,LG as bl,qH as bm,Nf as bn,OB as bo,Ly as bp,LO as bq,nu as br,gH as bs,T8 as bt,IG as bu,Vb as bv,Mj as bw,jW as bx,y4 as by,aW as bz,Ht as c,Sn as c$,gq as c0,Me as c1,t8 as c2,pt as c3,Gq as c4,qR as c5,os as c6,Zt as c7,$G as c8,v5 as c9,cp as cA,Ex as cB,Tx as cC,Sx as cD,Cx as cE,Rx as cF,V4 as cG,YG as cH,v4 as cI,Yf as cJ,gp as cK,ql as cL,xr as cM,xb as cN,O2 as cO,M2 as cP,XR as cQ,Sy as cR,b2 as cS,Rn as cT,Uo as cU,UH as cV,wn as cW,jq as cX,pp as cY,Z4 as cZ,Fv as c_,QF as ca,oB as cb,t2 as cc,CI as cd,EI as ce,m2 as cf,Zi as cg,w8 as ch,Gl as ci,SH as cj,Mq as ck,T2 as cl,mx as cm,gx as cn,T4 as co,C2 as cp,S2 as cq,vx as cr,yx as cs,bx as ct,b4 as cu,Lf as cv,_2 as cw,xn as cx,Px as cy,Ax as cz,Ji as d,ke as d$,OI as d0,Qs as d1,Ty as d2,Ub as d3,g5 as d4,GG as d5,NG as d6,NO as d7,Py as d8,jo as d9,l2 as dA,$s as dB,Ey as dC,xR as dD,Dv as dE,dO as dF,pI as dG,$z as dH,Xz as dI,G4 as dJ,Zz as dK,Gx as dL,rG as dM,Hv as dN,C8 as dO,L4 as dP,Wr as dQ,S4 as dR,Xq as dS,p4 as dT,Nj as dU,Ui as dV,Hd as dW,gy as dX,de as dY,gt as dZ,Er as d_,iI as da,zx as db,S8 as dc,Nq as dd,Lq as de,n8 as df,z8 as dg,mI as dh,_5 as di,_4 as dj,Hi as dk,jB as dl,wb as dm,iB as dn,Gt as dp,UO as dq,Vx as dr,Bx as ds,h4 as dt,u2 as du,Xi as dv,jt as dw,pB as dx,by as dy,rr as dz,di as e,qG as e$,oe as e0,te as e1,U4 as e2,Xv as e3,ne as e4,d5 as e5,Vv as e6,D8 as e7,r2 as e8,f4 as e9,en as eA,Ed as eB,An as eC,c8 as eD,Rt as eE,a4 as eF,iW as eG,I4 as eH,kq as eI,$U as eJ,ie as eK,$F as eL,Wd as eM,GU as eN,Nx as eO,YR as eP,WG as eQ,Iq as eR,sI as eS,qs as eT,qj as eU,Rr as eV,Yx as eW,Ci as eX,QR as eY,lW as eZ,KG as e_,k4 as ea,xG as eb,Ux as ec,uW as ed,IO as ee,Hx as ef,_p as eg,d4 as eh,MI as ei,Fx as ej,Go as ek,uq as el,Pq as em,Kx as en,My as eo,J4 as ep,Wq as eq,W4 as er,oi as es,Wb as et,ct as eu,Vr as ev,k as ew,ue as ex,Ry as ey,Eo as ez,Wi as f,KH as f$,Wx as f0,OW as f1,Zx as f2,v8 as f3,$x as f4,vr as f5,Uv as f6,Qx as f7,jv as f8,xq as f9,hq as fA,$r as fB,hc as fC,rI as fD,Ta as fE,He as fF,Ja as fG,ex as fH,KB as fI,VR as fJ,b8 as fK,kv as fL,_8 as fM,Kd as fN,gW as fO,jd as fP,qf as fQ,il as fR,Ho as fS,ck as fT,Yq as fU,KR as fV,_t as fW,zd as fX,Jt as fY,dc as fZ,YH as f_,rl as fa,rx as fb,nx as fc,Or as fd,Qa as fe,UB as ff,m4 as fg,qq as fh,Zf as fi,KW as fj,E8 as fk,It as fl,Ni as fm,kf as fn,Qd as fo,TI as fp,ec as fq,Fq as fr,SI as fs,hn as ft,Zr as fu,zo as fv,Kf as fw,Rv as fx,Av as fy,rB as fz,RR as g,Oa as g$,Wv as g0,Q4 as g1,H4 as g2,vq as g3,wI as g4,Fj as g5,uo as g6,ZF as g7,mp as g8,t4 as g9,HH as gA,f8 as gB,Jx as gC,ji as gD,FO as gE,XB as gF,YB as gG,Gd as gH,q4 as gI,LB as gJ,EB as gK,fu as gL,kB as gM,rW as gN,fk as gO,bB as gP,oj as gQ,P8 as gR,Ue as gS,R4 as gT,hk as gU,Ke as gV,rt as gW,i8 as gX,$t as gY,$a as gZ,Bo as g_,VB as ga,ii as gb,wr as gc,yq as gd,SW as ge,bq as gf,Re as gg,Eq as gh,Vk as gi,j4 as gj,s4 as gk,Vo as gl,l8 as gm,u8 as gn,bi as go,Bq as gp,NB as gq,PW as gr,g8 as gs,K4 as gt,nW as gu,cI as gv,jG as gw,P4 as gx,oW as gy,hI as gz,A4 as h,A8 as h$,L8 as h0,BO as h1,V8 as h2,VO as h3,E4 as h4,Rj as h5,II as h6,vp as h7,Be as h8,KM as h9,y8 as hA,XW as hB,iu as hC,c2 as hD,St as hE,tn as hF,nI as hG,Gb as hH,Lb as hI,fc as hJ,_u as hK,$j as hL,a5 as hM,M8 as hN,x8 as hO,Zj as hP,cr as hQ,Mt as hR,wU as hS,dj as hT,JF as hU,MB as hV,B4 as hW,G2 as hX,W2 as hY,H2 as hZ,R8 as h_,eB as ha,tB as hb,GR as hc,Ca as hd,h8 as he,zn as hf,wG as hg,Fb as hh,Gv as hi,cu as hj,xI as hk,uI as hl,tW as hm,CW as hn,yW as ho,m8 as hp,qd as hq,ox as hr,g2 as hs,lu as ht,du as hu,Vq as hv,yr as hw,Hs as hx,Y4 as hy,xO as hz,$q as i,y as i$,j2 as i0,Oq as i1,nB as i2,qM as i3,vy as i4,Oi as i5,Ld as i6,Jf as i7,Wn as i8,Iy as i9,Ea as iA,O8 as iB,Ql as iC,Ee as iD,Qf as iE,dI as iF,Ox as iG,p8 as iH,U8 as iI,k8 as iJ,Oy as iK,nr as iL,aI as iM,$i as iN,_I as iO,lp as iP,lc as iQ,Dr as iR,uc as iS,$2 as iT,Ib as iU,Z2 as iV,wR as iW,VU as iX,xx as iY,XM as iZ,Ie as i_,Hj as ia,F4 as ib,fq as ic,zR as id,Ay as ie,mi as ig,el as ih,qB as ii,p5 as ij,he as ik,Xb as il,C4 as im,zv as io,a8 as ip,CO as iq,N8 as ir,At as is,Ix as it,_W as iu,vW as iv,Xs as iw,qt as ix,me as iy,ko as iz,xB as j,Hq as j$,ni as j0,wd as j1,w4 as j2,I as j3,ze as j4,Dd as j5,e8 as j6,F8 as j7,Lz as j8,lI as j9,Pz as jA,Ko as jB,Jv as jC,Mo as jD,pO as jE,R5 as jF,S5 as jG,ey as jH,Zv as jI,Yv as jJ,xz as jK,Mz as jL,FU as jM,Dx as jN,C5 as jO,Gn as jP,Id as jQ,BI as jR,qv as jS,Rz as jT,wx as jU,Mr as jV,jl as jW,h2 as jX,Cy as jY,kx as jZ,eW as j_,Dn as ja,DR as jb,X2 as jc,sk as jd,Cj as je,$4 as jf,Kl as jg,ZM as jh,jf as ji,DB as jj,Hr as jk,nl as jl,Db as jm,qo as jn,cc as jo,Kv as jp,Qv as jq,Cz as jr,$f as js,$v as jt,xd as ju,wz as jv,Zq as jw,Dz as jx,Iz as jy,Qq as jz,HG as k,ma as k$,Pn as k0,Wl as k1,A2 as k2,kR as k3,r8 as k4,e4 as k5,ax as k6,bz as k7,Ez as k8,dq as k9,dr as kA,_O as kB,OX as kC,Jb as kD,K8 as kE,bp as kF,_a as kG,tD as kH,$I as kI,G8 as kJ,gX as kK,so as kL,br as kM,ot as kN,eD as kO,Q8 as kP,PX as kQ,vX as kR,Vy as kS,wX as kT,r7 as kU,un as kV,$8 as kW,Za as kX,AX as kY,YO as kZ,yX as k_,o2 as ka,Sz as kb,zB as kc,JU as kd,ZG as ke,ZU as kf,Ae as kg,Jq as kh,zq as ki,pq as kj,ui as kk,ye as kl,JM as km,GB as kn,w as ko,hB as kp,Vt as kq,ap as kr,fB as ks,nf as kt,QM as ku,$M as kv,op as kw,cB as kx,at as ky,Pb as kz,V2 as l,mY as l$,X8 as l0,bX as l1,ay as l2,Jr as l3,Z8 as l4,EX as l5,jO as l6,J8 as l7,ZI as l8,W8 as l9,ky as lA,So as lB,KO as lC,zf as lD,JX as lE,rc as lF,va as lG,ba as lH,eY as lI,In as lJ,Tt as lK,tY as lL,iY as lM,rY as lN,SY as lO,Nt as lP,nY as lQ,oY as lR,lY as lS,cY as lT,aY as lU,uY as lV,fY as lW,_Y as lX,pY as lY,sY as lZ,hY as l_,lo as la,e7 as lb,XO as lc,SX as ld,j8 as le,Zb as lf,JI as lg,H8 as lh,t7 as li,Pa as lj,i7 as lk,RX as ll,Mn as lm,By as ln,$l as lo,zt as lp,oy as lq,sy as lr,CX as ls,Ep as lt,q8 as lu,Y8 as lv,Li as lw,rs as lx,zy as ly,fn as lz,U2 as m,gY as m0,vY as m1,yY as m2,bY as m3,EY as m4,TY as m5,is as m6,su as m7,tc as m8,Cn as m9,ub as mA,NX as ma,uy as mb,CY as mc,PY as md,IY as me,wY as mf,n7 as mg,zY as mh,YY as mi,JY as mj,aD as mk,f6 as ml,m6 as mm,T6 as mn,NY as mo,LY as mp,DY as mq,O6 as mr,L6 as ms,k6 as mt,X6 as mu,Z6 as mv,nK as mw,lq as mx,jM as my,sq as mz,k2 as n,Mx as o,z2 as p,Sq as q,sB as r,vd as s,ix as t,Ys as u,i2 as v,Rb as w,Vd as x,Ud as y,fI as z};
16108
+ `));else throw new Error("could not patch the pbrPixelShader");ce.IncludesShadersStore.customToonShading=MK;async function hy(n,t,e=Ce.BodyShape.MALE,i,r){const o=mu(t,e);if(yp(o))throw new Error(`The wearable="${t.id}" is a texture`);const a=D5(o),s=await lD(n,a);for(const l of s.meshes)l.name.toLowerCase().includes("collider")&&(l.isVisible=!1,n.removeMesh(l));for(const l of s.materials)if(l instanceof Ci){const u=l;u.specularIntensity=0,u.metallic&&(u.metallic=0,u.metallicF0Factor=0),u.name.toLowerCase().includes("hair")&&(r?(u.albedoColor=_e.FromHexString(r).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u))),u.name.toLowerCase().includes("skin")&&(i?(u.albedoColor=_e.FromHexString(i).toLinearSpace(),u.specularIntensity=0,u.alpha=1):(u.alpha=0,n.removeMaterial(u)))}for(const l of s.animationGroups)l.stop(),l.reset(),l.dispose();return{container:s,wearable:t}}async function xK(n,t){const[e,i]=await cK(n,t);try{OK(t);let r;const o=[];if(t.type===Ce.PreviewType.AVATAR){const s=dX(t),l=Array.from(s.values());for(const p of l.filter(KI)){const _=hy(e,p,t.bodyShape,t.skin,t.hair).catch(g=>{console.warn(g.message)});o.push(_)}let u=null;t.socialEmote&&t.socialEmote.Armature_Other&&(u=new ne("parent_other",e));const f=new Map,c=(await Promise.all(o)).filter(nX);for(const p of c)if(p.container.addAllToScene(),u){const _=p.container.instantiateModelsToScene(S=>`${S}_Other`),v=_e.FromHexString("#c9c9c9").toLinearSpace(),E=_.rootNodes;for(const S of E)S.setParent(u);uX(E,v);const T=lX(p.container,E);for(const[S,C]of T)f.set(S,C)}const h=fX(c);if(h){const p=l.filter(oX),{eyes:_,eyebrows:g,mouth:v}=await PK(e,p,t.bodyShape);AK(e,h,_,g,v,t)}r=await TK(e,c,t,f)||CR()}else{const s=t.item;if(s&&!Co(s))try{(await hy(e,s,t.bodyShape,t.skin,t.hair)).container.addAllToScene()}catch{(await hy(e,s,t.bodyShape===Ce.BodyShape.MALE?Ce.BodyShape.FEMALE:Ce.BodyShape.MALE,t.skin,t.hair)).container.addAllToScene()}r=CR()}return t.centerBoundingBox&&_K(e),{scene:i,emote:r}}catch(r){throw e.clearColor=new Je(0,0,0,0),r}}function IK(n){const t=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAY,payload:void 0})},e=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PAUSE,payload:void 0})},i=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_LOOP,payload:void 0})},r=()=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_END,payload:void 0})},o=a=>{Ce.sendMessage(cn(),Ce.PreviewMessageType.EMOTE_EVENT,{type:Ce.PreviewEmoteEventType.ANIMATION_PLAYING,payload:a})};return n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.on(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o),()=>{n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAY,t),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PAUSE,e),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_LOOP,i),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_END,r),n.emote.events.off(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,o)}}const DK=()=>{const[n,t]=Ct.useState(""),{width:e,height:i}=WM(),[r,o]=Ct.useState({}),[a,s]=Ct.useState(!1),[l,u]=Ct.useState(!0),[f,c]=Ct.useState(!1),h=Ct.useRef(null),p=YI(),[_,g,v]=eX(),[E,T]=Ct.useState(""),[S,C]=Ct.useState(!0),[O,A]=Ct.useState(!1),M=n||v,D=(l||g)&&!M,U=!!E&&!S&&!D,V=S&&!D;return Ct.useEffect(()=>{let B=()=>{};if(h.current&&_){let z={opacity:1};_.background.image&&(T(_.background.image),z.opacity=1,!_.background.transparent&&_.type===Ce.PreviewType.TEXTURE&&(z.backgroundColor=_.background.color)),o(z),_.type===Ce.PreviewType.TEXTURE?(C(!1),u(!1),c(!0)):xK(h.current,_).then(J=>{p.current=J,B=IK(p.current)}).catch(J=>t(J.message)).finally(()=>{u(!1),c(!0)})}return()=>{B()}},[h.current,_]),Ct.useEffect(()=>{var B;O||(f?(Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.BABYLON}),A(!0),((_==null?void 0:_.type)===Ce.PreviewType.AVATAR||_!=null&&_.emote&&_.emote!==Ce.PreviewEmote.IDLE)&&((B=p.current)==null||B.emote.play())):M&&(Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:M}),A(!0)))},[f,M,O,p,_==null?void 0:_.type,_==null?void 0:_.emote]),Ct.useEffect(()=>{if(g){let B=!1;l||(u(!0),B=!0),O&&(A(!1),B=!0),B&&f&&c(!1)}},[g,l,O,f]),XI(),On.jsxs("div",{className:Zl("Preview",{"is-dragging":a,"is-loading":D,"is-loaded":f,"is-3d":S&&(_==null?void 0:_.camera)===Ce.PreviewCamera.INTERACTIVE,"has-error":!!M,"no-fade-effect":_&&!_.fadeEffect}),style:r,children:[On.jsx("img",{src:E,className:Zl("thumbnail",{"is-visible":U}),alt:"preview"}),On.jsx("canvas",{id:"wearable-preview",className:Zl({"is-visible":V}),width:e,height:i,ref:h,onMouseDown:()=>s(S&&!M),onMouseUp:()=>s(!1)}),M&&On.jsx("div",{className:"error",children:M})]})},wK=aM.memo(DK);var fD=(n=>(n.SET_MODE="SetMode",n.SET_PROFILE="SetProfile",n.SET_EMOTE="SetEmote",n.SET_URNS="SetUrns",n.SET_BACKGROUND="SetBackground",n.SET_SKIN_COLOR="SetSkinColor",n.SET_HAIR_COLOR="SetHairColor",n.SET_EYE_COLOR="SetEyeColor",n.SET_BODY_SHAPE="SetBodyShape",n.SET_SHOW_ANIMATION_REFERENCE="SetShowAnimationReference",n.SET_PROJECTION="SetProjection",n.ADD_BASE64="AddBase64",n.CLEAR_BASE64="ClearBase64",n.SET_CONTRACT="SetContract",n.SET_ITEM_ID="SetItemID",n.SET_TOKEN_ID="SetTokenID",n.SET_DISABLE_LOADER="SetDisableLoader",n.RELOAD="Reload",n.CLEANUP="Cleanup",n))(fD||{});const LK={unityMode:"SetMode",profile:"SetProfile",emote:"SetEmote",urns:"SetUrns",background:"SetBackground",skin:"SetSkinColor",hair:"SetHairColor",eyes:"SetEyeColor",bodyShape:"SetBodyShape",showAnimationReference:"SetShowAnimationReference",projection:"SetProjection",base64s:"AddBase64",contractAddress:"SetContract",itemId:"SetItemID",tokenId:"SetTokenID",disableLoader:"SetDisableLoader"},NK={unityMode:n=>String(n),profile:n=>String(n),emote:n=>String(n),urns:n=>Array.isArray(n)?n.join(","):String(n),background:n=>typeof n=="string"?n.replace("#",""):String(n),skin:n=>typeof n=="string"?n.replace("#",""):String(n),hair:n=>typeof n=="string"?n.replace("#",""):String(n),eyes:n=>typeof n=="string"?n.replace("#",""):String(n),bodyShape:n=>String(n),showAnimationReference:n=>String(n),projection:n=>String(n),contractAddress:n=>String(n),itemId:n=>String(n),tokenId:n=>String(n),disableLoader:n=>String(n)},Pd=(n,t,e)=>{if(n)try{const i=String(t);Object.values(fD).includes(i)||console.warn(`Unknown Unity method: ${i}. Sending anyway...`),e!==void 0?n.SendMessage("JSBridge",i,e):n.SendMessage("JSBridge",i)}catch(i){console.error(`Failed to send Unity message ${t}:`,i)}else console.warn(`Unity instance not ready, cannot send message: ${t}`)},FK=(n,t,e)=>{if(!n){console.warn("Unity instance not available, cannot send override messages");return}let i=0;t.base64s!==void 0&&e.base64s&&(Pd(n,"ClearBase64"),i++,Array.isArray(t.base64s)&&t.base64s.length>0&&t.base64s.forEach(r=>{Pd(n,"AddBase64",r),i++})),Object.entries(t).forEach(([r,o])=>{if(r!=="base64s"&&e[r]&&o!==void 0){const a=LK[r];if(a){const s=NK[r],l=s?s(o):String(o);Pd(n,a,l),i++}else console.warn(`No Unity method mapping found for property: ${r}`)}}),i>0&&Pd(n,"Reload")};var BK={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/wearable-preview/2.8.2"};const dy=new Map,kl=(n,t)=>{if(!t)return n;const e=n.replace(/\/$/,""),i=t.replace(/^\//,"");return`${e}/${i}`};function VK(n){if(dy.has(n))return dy.get(n);const t=new Promise((e,i)=>{const r=document.querySelector(`script[src="${n}"]`);if(r){r.addEventListener("load",()=>e(r)),r.addEventListener("error",a=>i(a));return}const o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>e(o),o.onerror=a=>i(a),document.body.appendChild(o)});return dy.set(n,t),t}const UK=async(n,t,e,i,r,o,a,s,l,u,f,c)=>{try{const h=BK.VITE_BASE_URL||"";return await VK(kl(h,t)),await createUnityInstance(n,{dataUrl:kl(h,e),frameworkUrl:kl(h,i),codeUrl:kl(h,r),streamingAssetsUrl:kl(h,a),symbolUrl:kl(h,o),companyName:s,productName:l,productVersion:u,matchWebGLToCanvasSize:f,arguments:c})}catch(h){throw console.error("❌ Failed to load Unity instance:",h),h}};function kK(n){return{getScreenshot:()=>new Promise(t=>{if(!n){t("");return}n.SendMessage("JSBridge","TakeScreenshot",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="screenshot"&&(window.removeEventListener("message",e),t(o))}})}),getMetrics:()=>new Promise(t=>{if(!n){t({triangles:0,materials:0,textures:0,meshes:0,bodies:0,entities:0});return}n.SendMessage("JSBridge","GetMetrics",""),window.addEventListener("message",function e(i){if(i.data.type==="unity-renderer"){const{type:r,payload:o}=i.data.payload;r==="metrics"&&(window.removeEventListener("message",e),t(o))}})}),changeZoom:async t=>{n&&n.SendMessage("JSBridge","SetZoom",t.toString())},panCamera:async t=>{if(!n)return;const e=t.x??0,i=t.y??0,r=t.z??0;n.SendMessage("JSBridge","SetOffset",`${e},${i},${r}`)},changeCameraPosition:async t=>{if(!n)return;const e=t.alpha??0,i=t.beta??0,r=t.radius??0;n.SendMessage("JSBridge","SetCameraPosition",`${e},${i},${r}`)},setUsername:async t=>{n&&n.SendMessage("JSBridge","SetUsername",t)},cleanup:async()=>{n&&n.SendMessage("JSBridge","Cleanup","")}}}function zK(n){const t=Sb();return{getLength:async()=>new Promise(e=>{if(!n){e(0);return}n.SendMessage("JSBridge","GetEmoteLength",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="emoteLength"&&(window.removeEventListener("message",i),e(a))}})}),isPlaying:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","IsEmotePlaying",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="isEmotePlaying"&&(window.removeEventListener("message",i),e(a))}})}),goTo:async e=>{n&&(n.SendMessage("JSBridge","GoToEmote",e.toString()),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAYING,{length:e}))},play:async()=>{n&&(n.SendMessage("JSBridge","PlayEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PLAY))},pause:async()=>{n&&(n.SendMessage("JSBridge","PauseEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_PAUSE))},stop:async()=>{n&&(n.SendMessage("JSBridge","StopEmote",""),t.emit(Ce.PreviewEmoteEventType.ANIMATION_END))},enableSound:async()=>{n&&n.SendMessage("JSBridge","EnableSound","")},disableSound:async()=>{n&&n.SendMessage("JSBridge","DisableSound","")},hasSound:async()=>new Promise(e=>{if(!n){e(!1);return}n.SendMessage("JSBridge","HasSound",""),window.addEventListener("message",function i(r){if(r.data.type==="unity-renderer"){const{type:o,payload:a}=r.data.payload;o==="hasSound"&&(window.removeEventListener("message",i),e(a))}})}),events:t}}async function GK(n){let t=null;try{if(t=await UK(n,"/unity/Build/aang-renderer.loader.js","/unity/Build/aang-renderer.data.br","/unity/Build/aang-renderer.framework.js.br","/unity/Build/aang-renderer.wasm.br","/unity/Build/aang-renderer.symbols.json.br","/emotes","Decentraland","AangRenderer","2.2.2",!0,[]),!t)throw new Error("Failed to load Unity instance");const e=kK(t),i=zK(t);return{scene:e,emote:i,unity:t}}catch(e){if(console.error("Unity render failed:",e),t!=null&&t.Quit)try{t.Quit()}catch(i){console.error("Error quitting Unity instance:",i)}throw e}}const WK=()=>Math.floor(Math.random()*159)+1,cD=()=>`default${WK()}`,HK=(n,t)=>{var e,i,r,o,a,s;return{eyes:ou(t.eyes||((i=(e=n==null?void 0:n.avatar)==null?void 0:e.eyes)==null?void 0:i.color)&&au(n.avatar.eyes.color)||"#000000"),hair:ou(t.hair||((o=(r=n==null?void 0:n.avatar)==null?void 0:r.hair)==null?void 0:o.color)&&au(n.avatar.hair.color)||"#000000"),skin:ou(t.skin||((s=(a=n==null?void 0:n.avatar)==null?void 0:a.skin)==null?void 0:s.color)&&au(n.avatar.skin.color)||"#cc9b76")}},ff=n=>n||"",rM=n=>n||[],Ad=n=>n.replace("#","");function nM(n){const t=new URL(window.location.href);Object.entries(n).forEach(([e,i])=>{t.searchParams.delete(e),Array.isArray(i)?i.forEach(r=>{r!==""&&t.searchParams.append(e,r)}):i!==""&&t.searchParams.set(e,i)}),window.history.replaceState({},"",t.toString())}function jK(){const{options:n,overrideSources:t}=$b(),[e,i]=Ct.useState(null),[r,o]=Ct.useState(!0),[a,s]=Ct.useState(null),l=Ct.useRef(null),u=Ct.useRef(n),f=Ct.useRef(!0);return Ct.useEffect(()=>{const c=JSON.stringify(n),h=JSON.stringify(u.current);if(!f.current&&c===h)return;f.current=!1,u.current=n,(async()=>{var _,g;try{o(!0),s(null);const v=n.peerUrl||Wf.get("PEER_URL"),E=n.marketplaceServerUrl||n.nftServerUrl||Wf.get("MARKETPLACE_SERVER_URL");let T=Ce.PreviewType.WEARABLE,S={color:n.background||"#4b4852",transparent:n.disableBackground===!0};const C=kI(n.profile);let O=C==null?void 0:C.value;O==="default"&&(O=cD());const A=O&&C?C.type==="address"?await GI(O,v):await WI(O,v):null,M=n.bodyShape||((_=A==null?void 0:A.avatar)==null?void 0:_.bodyShape)||Ce.BodyShape.MALE;let D=null;if(n.contractAddress&&(D=await HI({contractAddress:n.contractAddress,tokenId:n.tokenId,itemId:n.itemId,peerUrl:v,marketplaceServerUrl:E}),D&&as(D))){S={...S,image:D.thumbnail};const Z=qb(D);yp(Z)&&(T=Ce.PreviewType.TEXTURE)}const{eyes:U,hair:V,skin:B}=HK(A,{eyes:n.eyes,hair:n.hair,skin:n.skin}),z=n.unityMode||null,J=n.camera&&Object.values(Ce.PreviewCamera).includes(n.camera)?n.camera:Ce.PreviewCamera.INTERACTIVE,X=n.projection&&Object.values(Ce.PreviewProjection).includes(n.projection)?n.projection:Ce.PreviewProjection.PERSPECTIVE,re=n.disableDefaultEmotes?null:n.emote&&Object.values(Ce.PreviewEmote).includes(n.emote)?n.emote:Ce.PreviewEmote.IDLE,ae={background:S,bodyShape:M,mode:z,projection:X,type:T,base64:((g=n.base64s)==null?void 0:g[0])||null,contract:n.contractAddress||null,disableLoader:n.disableLoader||!1,emote:(re==null?void 0:re.toString())||null,eyeColor:U.replace("#",""),hairColor:V.replace("#",""),item:n.itemId||null,profile:O||null,skinColor:B.replace("#",""),token:n.tokenId||null,urn:n.urns||null,showAnimationReference:null},se=JSON.stringify(ae),H=JSON.stringify(l.current);if(se!==H){if(l.current=ae,Object.keys(t).length===0){const Z=rM(n.urns),q=rM(n.base64s);if(z===Ce.PreviewUnityMode.CONFIG){const F={mode:ff(z||"")};nM(F)}else{const F={background:S.transparent?"":Ad(S.color),disableLoader:n.disableLoader?"true":"",profile:ff(O||""),bodyShape:ff(M||""),eyeColor:Ad(U||""),hairColor:Ad(V||""),skinColor:Ad(B||""),mode:ff(z||""),camera:J,projection:X,emote:ff((re==null?void 0:re.toString())||""),urn:Z.length>0?Z:[""],base64:q.length>0?q:[""]};nM(F)}}i(ae)}o(!1)}catch(v){console.error("[useUnityConfig] Failed to load config:",v),s(v instanceof Error?v.message:"Failed to load config"),o(!1)}})()},[n,t]),[e,r,a]}const XK="unity-renderer",YK="unity-canvas",oM=1,KK="Failed to load Unity",qK=(n,t,e,i)=>{const[r,o]=Ct.useState({isLoaded:!1,isInitialized:!1,error:null}),a=Ct.useCallback(l=>{if(l.data.type===XK){const{type:u,payload:f}=l.data.payload;u==="loaded"&&(f===!0||f==="true")?(o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})):u==="customization-done"?Ce.sendMessage(cn(),Ce.PreviewMessageType.CONTROLLER_RESPONSE,{id:"customization-done",ok:!0,result:JSON.parse(l.data.payload.payload)}):u==="error"&&(o(c=>({...c,error:f})),Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:"Error loading the wearable. Please try again."}))}},[]),s=Ct.useCallback(async()=>{if(!(!n.canvas.current||n.isInitializing.current||n.unityInstance.current)){n.isInitializing.current=!0,o(l=>({...l,isLoaded:!1,error:null}));try{const{unity:l,scene:u,emote:f}=await GK(n.canvas.current);n.unityInstance.current=l,t.current={scene:u,emote:f},o(c=>({...c,isLoaded:!0,isInitialized:!0})),Ce.sendMessage(cn(),Ce.PreviewMessageType.LOAD,{renderer:Ce.PreviewRenderer.UNITY})}catch(l){const u=l instanceof Error?l.message:KK;console.error("Unity init failed:",l),o(f=>({...f,error:u})),Ce.sendMessage(cn(),Ce.PreviewMessageType.ERROR,{message:u})}finally{n.isInitializing.current=!1}}},[n,t]);return Ct.useEffect(()=>{r.isInitialized||i||!e||s()},[e,i,r.isInitialized,s]),Ct.useEffect(()=>{if(e)return window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a,!1)}},[e,a]),r},QK=n=>{const[t,e]=Ct.useState({pixelRatio:window.devicePixelRatio||oM,is3D:!0,backgroundImage:""});return Ct.useEffect(()=>{const i=()=>{e(o=>({...o,pixelRatio:window.devicePixelRatio||oM}))},r=window.matchMedia(`(resolution: ${t.pixelRatio}dppx)`);return r.addEventListener("change",i),()=>{r.removeEventListener("change",i)}},[t.pixelRatio]),Ct.useEffect(()=>{n&&e(i=>({...i,backgroundImage:n.background.image||"",is3D:n.type!==Ce.PreviewType.TEXTURE}))},[n]),t},$K=(n,t,e,i,r)=>{const o=Ct.useMemo(()=>{const a={};for(const s of Object.keys(r))r[s]&&i[s]!==void 0&&(a[s]=i[s]);return a},[r,i]);Ct.useEffect(()=>{if(!(!e.isInitialized||!e.isLoaded||!n.current)){if(o.profile==="default"){const a=t.current.profile;o.profile=a!=null&&a.match(/^default\d+$/)?a:cD()}Object.keys(o).length>0&&(FK(n.current,o,r),t.current=o)}},[e.isInitialized,e.isLoaded,o,r,n,t])},ZK=()=>{const{width:n=window.innerWidth,height:t=window.innerHeight}=WM(),e=Ct.useRef(null),i=Ct.useRef(null),r=Ct.useRef(!1),o=Ct.useRef({}),a=YI(),[s,l,u]=jK(),{options:f,overrideSources:c}=$b(),h=Ct.useMemo(()=>({canvas:e,unityInstance:i,isInitializing:r,lastSentOverrides:o}),[]),p=qK(h,a,s,l),_=QK(s);$K(h.unityInstance,h.lastSentOverrides,p,f,c),XI();const g=Ct.useMemo(()=>{const A=p.error||u,M=!p.isLoaded&&!A,D=!!_.backgroundImage&&!_.is3D&&!M,U=_.is3D&&!M;return{error:A,isLoading:M,showImage:D,showCanvas:U}},[p.error,p.isLoaded,u,_.backgroundImage,_.is3D]),v=Ct.useMemo(()=>({opacity:1,backgroundColor:!(s!=null&&s.background.transparent)&&(s==null?void 0:s.type)===Ce.PreviewType.TEXTURE?s.background.color:void 0}),[s]),E=Ct.useMemo(()=>({width:`${n}px`,height:`${t}px`}),[n,t]),T=Ct.useMemo(()=>({width:Math.round(n*_.pixelRatio),height:Math.round(t*_.pixelRatio)}),[n,t,_.pixelRatio]),S=Ct.useMemo(()=>Zl("Preview",{"is-loading":g.isLoading,"is-loaded":p.isLoaded,"is-3d":_.is3D,"has-error":!!g.error}),[g.isLoading,p.isLoaded,_.is3D,g.error]),C=Ct.useMemo(()=>Zl("thumbnail",{"is-visible":g.showImage}),[g.showImage]),O=Ct.useMemo(()=>Zl({"is-visible":g.showCanvas}),[g.showCanvas]);return On.jsxs("div",{className:S,style:v,children:[On.jsx("img",{src:_.backgroundImage,className:C,alt:"preview"}),On.jsx("canvas",{ref:h.canvas,id:YK,className:O,width:T.width,height:T.height,style:E}),g.error&&On.jsx("div",{className:"error",children:g.error})]})},JK=aM.memo(ZK),hD=Ct.createContext(null),eq=({children:n,value:t})=>{const e={webGPUSupport:t,isSupported:t.isSupported,isAvailable:t.isAvailable};return On.jsx(hD.Provider,{value:e,children:n})},tq=()=>{const n=Ct.useContext(hD);if(!n)throw new Error("useWebGPUContext must be used within a WebGPUProvider");return n},iq=()=>tq(),rq=()=>{const n=navigator.userAgent.toLowerCase();let t="Unknown",e="Unknown",i="Unknown";if(/android/.test(n)){t="Android";const r=n.match(/android\s*([0-9.]+)/);r&&(i=r[1])}else if(/iphone|ipad|ipod/.test(n)){t="iOS";const r=n.match(/os\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/macintosh|mac os x/.test(n)){t="macOS";const r=n.match(/mac os x\s*([0-9_]+)/);r&&(i=r[1].replace(/_/g,"."))}else if(/windows/.test(n)){t="Windows";const r=n.match(/windows nt\s*([0-9.]+)/);r&&(i=r[1])}else if(/linux/.test(n)){t="Linux";const r=n.match(/\(([^)]+)\)/);r&&(i=r[1])}if(/chrome|crios/.test(n)){e="Chrome";const r=n.match(/(?:chrome|crios)\/([0-9.]+)/);r&&(i=r[1])}else if(/firefox|fxios/.test(n)){e="Firefox";const r=n.match(/(?:firefox|fxios)\/([0-9.]+)/);r&&(i=r[1])}else if(/safari/.test(n)&&!/chrome|crios|android/.test(n)){e="Safari";const r=n.match(/version\/([0-9.]+)/);r&&(i=r[1])}else if(/edg/.test(n)){e="Edge";const r=n.match(/edg\/([0-9.]+)/);r&&(i=r[1])}return{platform:t,browser:e,version:i}},nq=async()=>{const{platform:n,browser:t,version:e}=rq();if(!navigator.gpu)return console.warn("❌ navigator.gpu is not available"),{isSupported:!1,isAvailable:!1,error:"WebGPU is not supported in this browser. Please use a compatible browser.",platform:n,browser:t,platformVersion:e,browserVersion:e};try{const i=await navigator.gpu.requestAdapter();return i?await i.requestDevice()?{isSupported:!0,isAvailable:!0,platform:n,browser:t,platformVersion:e,browserVersion:e}:(console.warn("❌ Failed to create WebGPU device"),{isSupported:!0,isAvailable:!1,error:"WebGPU adapter found but failed to create device. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e}):(console.warn("❌ No WebGPU adapter available"),{isSupported:!0,isAvailable:!1,error:"WebGPU is supported but no adapter is available. This might be due to hardware limitations or driver issues.",platform:n,browser:t,platformVersion:e,browserVersion:e})}catch(i){return console.error("❌ WebGPU detection error:",i),{isSupported:!0,isAvailable:!1,error:`WebGPU is supported but failed to initialize: ${i instanceof Error?i.message:"Unknown error"}`,platform:n,browser:t,platformVersion:e,browserVersion:e}}},oq=()=>{const t=new URLSearchParams(window.location.search).get("unity")==="true",{isAvailable:e}=iq();return t&&e?On.jsx(JK,{}):On.jsx(wK,{})},aq=async()=>{const n=await nq();iL.createRoot(document.getElementById("root")).render(On.jsx(Ct.StrictMode,{children:On.jsx(eq,{value:n,children:On.jsx(oq,{})})}))};aq();export{Xd as $,ut as A,$B as B,P2 as C,tl as D,fx as E,Ob as F,cx as G,hx as H,px as I,_x as J,X4 as K,up as L,ya as M,I8 as N,c5 as O,pa as P,Cq as Q,f2 as R,Wo as S,d2 as T,WU as U,Mi as V,ga as W,yd as X,Bb as Y,wv as Z,e2 as _,zl as a,Yo as a$,Yd as a0,jn as a1,bd as a2,o8 as a3,QB as a4,Tq as a5,NI as a6,eH as a7,wO as a8,PI as a9,JB as aA,RI as aB,O4 as aC,xy as aD,Sa as aE,Pv as aF,YW as aG,kU as aH,_e as aI,RW as aJ,Je as aK,cH as aL,Md as aM,bI as aN,QG as aO,D4 as aP,oI as aQ,cq as aR,Hf as aS,eI as aT,To as aU,h5 as aV,pH as aW,js as aX,y2 as aY,M4 as aZ,Nb as a_,Ur as aa,ss as ab,Dq as ac,Aq as ad,Rq as ae,c4 as af,_q as ag,p2 as ah,kd as ai,uk as aj,Oj as ak,hr as al,yy as am,Xo as an,Uf as ao,Hn as ap,d8 as aq,dt as ar,Kq as as,Ir as at,fp as au,jx as av,Ks as aw,vI as ax,EO as ay,AI as az,Ra as b,BG as b$,m5 as b0,mq as b1,qx as b2,ZB as b3,y5 as b4,sf as b5,s8 as b6,Xn as b7,tI as b8,zb as b9,qU as bA,Mb as bB,QU as bC,Uq as bD,Ri as bE,pu as bF,jb as bG,g4 as bH,bH as bI,z4 as bJ,wq as bK,N4 as bL,YM as bM,x4 as bN,OO as bO,oo as bP,Hl as bQ,UR as bR,R2 as bS,Po as bT,jr as bU,DI as bV,ce as bW,Tr as bX,dp as bY,Uz as bZ,FG as b_,Ws as ba,Bf as bb,Td as bc,B8 as bd,AW as be,jR as bf,HU as bg,FR as bh,gI as bi,rn as bj,zU as bk,LG as bl,qH as bm,Nf as bn,OB as bo,Ly as bp,LO as bq,nu as br,gH as bs,T8 as bt,IG as bu,Vb as bv,Mj as bw,jW as bx,y4 as by,aW as bz,Ht as c,Sn as c$,gq as c0,Me as c1,t8 as c2,pt as c3,Gq as c4,qR as c5,os as c6,Zt as c7,$G as c8,v5 as c9,cp as cA,Ex as cB,Tx as cC,Sx as cD,Cx as cE,Rx as cF,V4 as cG,YG as cH,v4 as cI,Yf as cJ,gp as cK,ql as cL,xr as cM,xb as cN,O2 as cO,M2 as cP,XR as cQ,Sy as cR,b2 as cS,Rn as cT,Uo as cU,UH as cV,wn as cW,jq as cX,pp as cY,Z4 as cZ,Fv as c_,QF as ca,oB as cb,t2 as cc,CI as cd,EI as ce,m2 as cf,Zi as cg,w8 as ch,Gl as ci,SH as cj,Mq as ck,T2 as cl,mx as cm,gx as cn,T4 as co,C2 as cp,S2 as cq,vx as cr,yx as cs,bx as ct,b4 as cu,Lf as cv,_2 as cw,xn as cx,Px as cy,Ax as cz,Ji as d,ke as d$,OI as d0,Qs as d1,Ty as d2,Ub as d3,g5 as d4,GG as d5,NG as d6,NO as d7,Py as d8,jo as d9,l2 as dA,$s as dB,Ey as dC,xR as dD,Dv as dE,dO as dF,pI as dG,$z as dH,Xz as dI,G4 as dJ,Zz as dK,Gx as dL,rG as dM,Hv as dN,C8 as dO,L4 as dP,Wr as dQ,S4 as dR,Xq as dS,p4 as dT,Nj as dU,Ui as dV,Hd as dW,gy as dX,de as dY,gt as dZ,Er as d_,iI as da,zx as db,S8 as dc,Nq as dd,Lq as de,n8 as df,z8 as dg,mI as dh,_5 as di,_4 as dj,Hi as dk,jB as dl,wb as dm,iB as dn,Gt as dp,UO as dq,Vx as dr,Bx as ds,h4 as dt,u2 as du,Xi as dv,jt as dw,pB as dx,by as dy,rr as dz,di as e,qG as e$,oe as e0,te as e1,U4 as e2,Xv as e3,ne as e4,d5 as e5,Vv as e6,D8 as e7,r2 as e8,f4 as e9,en as eA,Ed as eB,An as eC,c8 as eD,Rt as eE,a4 as eF,iW as eG,I4 as eH,kq as eI,$U as eJ,ie as eK,$F as eL,Wd as eM,GU as eN,Nx as eO,YR as eP,WG as eQ,Iq as eR,sI as eS,qs as eT,qj as eU,Rr as eV,Yx as eW,Ci as eX,QR as eY,lW as eZ,KG as e_,k4 as ea,xG as eb,Ux as ec,uW as ed,IO as ee,Hx as ef,_p as eg,d4 as eh,MI as ei,Fx as ej,Go as ek,uq as el,Pq as em,Kx as en,My as eo,J4 as ep,Wq as eq,W4 as er,oi as es,Wb as et,ct as eu,Vr as ev,k as ew,ue as ex,Ry as ey,Eo as ez,Wi as f,KH as f$,Wx as f0,OW as f1,Zx as f2,v8 as f3,$x as f4,vr as f5,Uv as f6,Qx as f7,jv as f8,xq as f9,hq as fA,$r as fB,hc as fC,rI as fD,Ta as fE,He as fF,Ja as fG,ex as fH,KB as fI,VR as fJ,b8 as fK,kv as fL,_8 as fM,Kd as fN,gW as fO,jd as fP,qf as fQ,il as fR,Ho as fS,ck as fT,Yq as fU,KR as fV,_t as fW,zd as fX,Jt as fY,dc as fZ,YH as f_,rl as fa,rx as fb,nx as fc,Or as fd,Qa as fe,UB as ff,m4 as fg,qq as fh,Zf as fi,KW as fj,E8 as fk,It as fl,Ni as fm,kf as fn,Qd as fo,TI as fp,ec as fq,Fq as fr,SI as fs,hn as ft,Zr as fu,zo as fv,Kf as fw,Rv as fx,Av as fy,rB as fz,RR as g,Oa as g$,Wv as g0,Q4 as g1,H4 as g2,vq as g3,wI as g4,Fj as g5,uo as g6,ZF as g7,mp as g8,t4 as g9,HH as gA,f8 as gB,Jx as gC,ji as gD,FO as gE,XB as gF,YB as gG,Gd as gH,q4 as gI,LB as gJ,EB as gK,fu as gL,kB as gM,rW as gN,fk as gO,bB as gP,oj as gQ,P8 as gR,Ue as gS,R4 as gT,hk as gU,Ke as gV,rt as gW,i8 as gX,$t as gY,$a as gZ,Bo as g_,VB as ga,ii as gb,wr as gc,yq as gd,SW as ge,bq as gf,Re as gg,Eq as gh,Vk as gi,j4 as gj,s4 as gk,Vo as gl,l8 as gm,u8 as gn,bi as go,Bq as gp,NB as gq,PW as gr,g8 as gs,K4 as gt,nW as gu,cI as gv,jG as gw,P4 as gx,oW as gy,hI as gz,A4 as h,A8 as h$,L8 as h0,BO as h1,V8 as h2,VO as h3,E4 as h4,Rj as h5,II as h6,vp as h7,Be as h8,KM as h9,y8 as hA,XW as hB,iu as hC,c2 as hD,St as hE,tn as hF,nI as hG,Gb as hH,Lb as hI,fc as hJ,_u as hK,$j as hL,a5 as hM,M8 as hN,x8 as hO,Zj as hP,cr as hQ,Mt as hR,wU as hS,dj as hT,JF as hU,MB as hV,B4 as hW,G2 as hX,W2 as hY,H2 as hZ,R8 as h_,eB as ha,tB as hb,GR as hc,Ca as hd,h8 as he,zn as hf,wG as hg,Fb as hh,Gv as hi,cu as hj,xI as hk,uI as hl,tW as hm,CW as hn,yW as ho,m8 as hp,qd as hq,ox as hr,g2 as hs,lu as ht,du as hu,Vq as hv,yr as hw,Hs as hx,Y4 as hy,xO as hz,$q as i,y as i$,j2 as i0,Oq as i1,nB as i2,qM as i3,vy as i4,Oi as i5,Ld as i6,Jf as i7,Wn as i8,Iy as i9,Ea as iA,O8 as iB,Ql as iC,Ee as iD,Qf as iE,dI as iF,Ox as iG,p8 as iH,U8 as iI,k8 as iJ,Oy as iK,nr as iL,aI as iM,$i as iN,_I as iO,lp as iP,lc as iQ,Dr as iR,uc as iS,$2 as iT,Ib as iU,Z2 as iV,wR as iW,VU as iX,xx as iY,XM as iZ,Ie as i_,Hj as ia,F4 as ib,fq as ic,zR as id,Ay as ie,mi as ig,el as ih,qB as ii,p5 as ij,he as ik,Xb as il,C4 as im,zv as io,a8 as ip,CO as iq,N8 as ir,At as is,Ix as it,_W as iu,vW as iv,Xs as iw,qt as ix,me as iy,ko as iz,xB as j,Hq as j$,ni as j0,wd as j1,w4 as j2,I as j3,ze as j4,Dd as j5,e8 as j6,F8 as j7,Lz as j8,lI as j9,Pz as jA,Ko as jB,Jv as jC,Mo as jD,pO as jE,R5 as jF,S5 as jG,ey as jH,Zv as jI,Yv as jJ,xz as jK,Mz as jL,FU as jM,Dx as jN,C5 as jO,Gn as jP,Id as jQ,BI as jR,qv as jS,Rz as jT,wx as jU,Mr as jV,jl as jW,h2 as jX,Cy as jY,kx as jZ,eW as j_,Dn as ja,DR as jb,X2 as jc,sk as jd,Cj as je,$4 as jf,Kl as jg,ZM as jh,jf as ji,DB as jj,Hr as jk,nl as jl,Db as jm,qo as jn,cc as jo,Kv as jp,Qv as jq,Cz as jr,$f as js,$v as jt,xd as ju,wz as jv,Zq as jw,Dz as jx,Iz as jy,Qq as jz,HG as k,ma as k$,Pn as k0,Wl as k1,A2 as k2,kR as k3,r8 as k4,e4 as k5,ax as k6,bz as k7,Ez as k8,dq as k9,dr as kA,_O as kB,OX as kC,Jb as kD,K8 as kE,bp as kF,_a as kG,tD as kH,$I as kI,G8 as kJ,gX as kK,so as kL,br as kM,ot as kN,eD as kO,Q8 as kP,PX as kQ,vX as kR,Vy as kS,wX as kT,r7 as kU,un as kV,$8 as kW,Za as kX,AX as kY,YO as kZ,yX as k_,o2 as ka,Sz as kb,zB as kc,JU as kd,ZG as ke,ZU as kf,Ae as kg,Jq as kh,zq as ki,pq as kj,ui as kk,ye as kl,JM as km,GB as kn,w as ko,hB as kp,Vt as kq,ap as kr,fB as ks,nf as kt,QM as ku,$M as kv,op as kw,cB as kx,at as ky,Pb as kz,V2 as l,mY as l$,X8 as l0,bX as l1,ay as l2,Jr as l3,Z8 as l4,EX as l5,jO as l6,J8 as l7,ZI as l8,W8 as l9,ky as lA,So as lB,KO as lC,zf as lD,JX as lE,rc as lF,va as lG,ba as lH,eY as lI,In as lJ,Tt as lK,tY as lL,iY as lM,rY as lN,SY as lO,Nt as lP,nY as lQ,oY as lR,lY as lS,cY as lT,aY as lU,uY as lV,fY as lW,_Y as lX,pY as lY,sY as lZ,hY as l_,lo as la,e7 as lb,XO as lc,SX as ld,j8 as le,Zb as lf,JI as lg,H8 as lh,t7 as li,Pa as lj,i7 as lk,RX as ll,Mn as lm,By as ln,$l as lo,zt as lp,oy as lq,sy as lr,CX as ls,Ep as lt,q8 as lu,Y8 as lv,Li as lw,rs as lx,zy as ly,fn as lz,U2 as m,gY as m0,vY as m1,yY as m2,bY as m3,EY as m4,TY as m5,is as m6,su as m7,tc as m8,Cn as m9,ub as mA,NX as ma,uy as mb,CY as mc,PY as md,IY as me,wY as mf,n7 as mg,zY as mh,YY as mi,JY as mj,aD as mk,f6 as ml,m6 as mm,T6 as mn,NY as mo,LY as mp,DY as mq,O6 as mr,L6 as ms,k6 as mt,X6 as mu,Z6 as mv,nK as mw,lq as mx,jM as my,sq as mz,k2 as n,Mx as o,z2 as p,Sq as q,sB as r,vd as s,ix as t,Ys as u,i2 as v,Rb as w,Vd as x,Ud as y,fI as z};