var __decorate=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},__extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};if("undefined"==typeof BABYLON)throw"BabylonJS is a required dependency, please include it first!";var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.PropertyChangedInfo=t;var r=(function(){function r(){this._propertyChanged=null}return r.prototype.onPropertyChanged=function(e,n,i,o){if(this.propertyChanged.hasObservers()){var a=r.calling?new t:r.pci;a.oldValue=n,a.newValue=i,a.propertyName=e;try{r.calling=!0,this.propertyChanged.notifyObservers(a,o)}finally{r.calling=!1}}},Object.defineProperty(r.prototype,"propertyChanged",{get:function(){return this._propertyChanged||(this._propertyChanged=new e.Observable),this._propertyChanged},enumerable:!0,configurable:!0}),r.pci=new t,r.calling=!1,r})();e.PropertyChangedBase=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.action=0,this.newItems=new Array,this.removedItems=new Array,this.changedItems=new Array,this.newStartingIndex=-1,this.removedStartingIndex=-1}return Object.defineProperty(e,"clearAction",{get:function(){return e._clearAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"newItemsAction",{get:function(){return e._newItemsAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"removedItemsAction",{get:function(){return e._removedItemsAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"changedItemAction",{get:function(){return e._changedItemAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"replacedArrayAction",{get:function(){return e._replacedArrayAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"lengthChangedAction",{get:function(){return e._lengthChangedAction},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this.action=0,this.newItems.splice(0),this.removedItems.splice(0),this.changedItems.splice(0),this.removedStartingIndex=this.removedStartingIndex=this.changedStartingIndex=0},e._clearAction=1,e._newItemsAction=2,e._removedItemsAction=4,e._replacedArrayAction=8,e._lengthChangedAction=16,e._changedItemAction=32,e})();e.ArrayChanged=t;var r=(function(){function e(){}return e})();e.OAWatchedObjectChangedInfo=r;var n=(function(n){function i(i,o){n.call(this),this.dci=new t,this._callingArrayChanged=!1,this._array=null!=o?o:new Array,this.dci=new t,this._callingArrayChanged=!1,this._arrayChanged=null,this._callingWatchedObjectChanged=!1,this._watchObjectsPropertyChange=i,this._watchedObjectList=this._watchObjectsPropertyChange?new e.StringDictionary:null,this._woci=new r}return __extends(i,n),Object.defineProperty(i.prototype,"length",{get:function(){return this._array.length},set:function(e){if(e!==this._array.length){var t=this._array.length;this._array.length=e,this.onPropertyChanged("length",t,this._array.length)}},enumerable:!0,configurable:!0}),i.prototype.getAt=function(e){return this._array[e]},i.prototype.setAt=function(e,r){if(e<0)return!1;var n=e>=this._array.length||void 0===this._array[e],i=0;n?i=this._array.length:this._watchObjectsPropertyChange&&this._removeWatchedElement(this._array[e]),this._array[e]=r,this._watchObjectsPropertyChange&&this._addWatchedElement(r),n&&this.onPropertyChanged("length",i,this._array.length);var o=this.getArrayChangedObject();o&&(o.action=n?t.newItemsAction:t.changedItemAction,n?(o.newItems.splice(0,o.newItems.length,{index:e,value:r}),o.newStartingIndex=e,o.changedItems.splice(0)):(o.newItems.splice(0),o.changedStartingIndex=e,o.changedItems.splice(0,o.changedItems.length,{index:e,value:r})),o.removedItems.splice(0),o.removedStartingIndex=-1,this.callArrayChanged(o))},i.prototype.toString=function(){return this._array.toString()},i.prototype.toLocaleString=function(){return this._array.toLocaleString()},i.prototype.push=function(){for(var e=[],r=0;r1&&this.mode===t.MODE_ONETIME)){var n=r;this._converter&&(n=this._converter(r)),this._stringFormat&&(n=this._stringFormat(n)),e[this._boundTo.name]=n}},t.prototype._getActualDataSource=function(){return this.dataSource?this.dataSource:this.uiElementId?null:this._owner.dataSource},t.prototype._registerDataSource=function(e){var t=this._getActualDataSource();t!==this._currentDataSource&&(this._currentDataSource&&d.unregisterDataSource(this._currentDataSource,this,0),t&&(d.registerDataSource(t,this),e&&this.canUpdateTarget(!0)&&this.updateTarget()),this._currentDataSource=t)},t.prototype._unregisterDataSource=function(){var e=this._getActualDataSource();e&&d.unregisterDataSource(e,this,0)},t.MODE_DEFAULT=1,t.MODE_ONETIME=2,t.MODE_ONEWAY=3,t.MODE_ONEWAYTOSOURCE=4,t.MODE_TWOWAY=5,t.UPDATESOURCETRIGGER_DEFAULT=1,t.UPDATESOURCETRIGGER_PROPERTYCHANGED=2,t.UPDATESOURCETRIGGER_LOSTFOCUS=3,t.UPDATESOURCETRIGGER_EXPLICIT=4,t=__decorate([e.className("DataBinding","BABYLON")],t)})();e.DataBinding=l;var u=(function(t){function r(){t.call(this),this._dataSource=null,this._dataSourceObserver=null,this._instanceDirtyFlags=0,this._isDisposed=!1,this._bindings=null,this._hasBinding=0,this._bindingSourceChanged=0,this._disposeObservable=null}return __extends(r,t),Object.defineProperty(r.prototype,"disposeObservable",{get:function(){return this._disposeObservable||(this._disposeObservable=new e.Observable),this._disposeObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return!this.isDisposed&&(this._disposeObservable&&this._disposeObservable.hasObservers()&&this._disposeObservable.notifyObservers(this),this._isDisposed=!0,!0)},r.prototype.checkPropertiesDirty=function(e){return 0!==(this._instanceDirtyFlags&e)},r.prototype.clearPropertiesDirty=function(e){return this._instanceDirtyFlags&=~e,this._instanceDirtyFlags},r.prototype._resetPropertiesDirty=function(){this._instanceDirtyFlags=0},r.prototype.addExternalData=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,r)},r.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},r.prototype.getOrAddExternalDataWithFactory=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,r)},r.prototype.removeExternalData=function(e){return!!this._externalData&&this._externalData.remove(e)},r._hookProperty=function(t,n,i,o){return function(a,s,l){o||(o={});var u=r._createPropInfo(a,s,t,i,o);n&&n(u);var c=l.get,h=l.set,d=void 0!==o.typeLevelCompare&&o.typeLevelCompare;l.set=function(t){if(!h)throw Error("Property '"+u.name+"' of type '"+e.Tools.getFullClassName(this)+"' has no setter defined but was invoked as if it had one.");if(!this.isDisposed){var n=c.call(this);if(!r._checkUnchanged(n,t)){var i=this;h.call(this,t),i._handlePropChanged(n,t,s,u,d)}}}}},r._createPropInfo=function(e,t,r,n,i){var u=s.getOrRegister(e,(function(){return new o})),c=u.getLevelOf(e),h=c.levelContent.get(r.toString());if(h)throw new Error("The ID "+r+" is already taken by another property declaration named: "+h.name);return h=new a,h.id=r,h.flagId=Math.pow(2,r),h.kind=n,h.name=t,h.bindingMode=void 0!==i.bindingMode?i.bindingMode:l.MODE_TWOWAY,h.bindingUpdateSourceTrigger=void 0!==i.bindingUpdateSourceTrigger?i.bindingUpdateSourceTrigger:l.UPDATESOURCETRIGGER_PROPERTYCHANGED,h.dirtyBoundingInfo=void 0!==i.dirtyBoundingInfo&&i.dirtyBoundingInfo,h.dirtyParentBoundingInfo=void 0!==i.dirtyParentBoundingBox&&i.dirtyParentBoundingBox,h.typeLevelCompare=void 0!==i.typeLevelCompare&&i.typeLevelCompare,c.levelContent.add(t,h),h},Object.defineProperty(r.prototype,"propDic",{get:function(){if(!this._propInfo){var e=s.get(Object.getPrototypeOf(this));if(!e)throw new Error("Can't access the propDic member in class definition, is this class SmartPropertyPrim based?");this._propInfo=e.fullContent}return this._propInfo; },enumerable:!0,configurable:!0}),r._checkUnchanged=function(e,t){if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(null!=e&&null!=t)if("function"==typeof e.equals){if(e.equals(t))return!0}else if(e===t)return!0;return!1},r.prototype._handlePropChanged=function(t,n,i,o,a){var s=r.propChangeGuarding?new e.PropertyChangedInfo:p.propChangedInfo;s.oldValue=t,s.newValue=n,s.propertyName=i;var l=o?o.flagId:-1;try{r.propChangeGuarding=!0,this.propertyChanged.notifyObservers(s,l)}finally{r.propChangeGuarding=!1}},r.prototype._triggerPropertyChanged=function(e,t){this.isDisposed||e&&this._handlePropChanged(void 0,t,e.name,e,e.typeLevelCompare)},Object.defineProperty(r.prototype,"dataSource",{get:function(){return this._getDataSource()},set:function(e){if(this._dataSource!==e){var t=this._dataSource;if(this._dataSource=e,this._bindings&&null!=e)for(var r=0,n=this._bindings;r=n?t._unregisterBinding(a,u,r):a.monitoredIntermediateProperties.get(c),o=o[l]}},t._unregisterBinding=function(r,n,i){var o=n.toString(),a=null;if(0!==(r.monitoredIntermediateMask&n)&&(a=r.monitoredIntermediateProperties.get(o),r.monitoredIntermediateProperties.remove(o),r.monitoredIntermediateMask&=~n),0!==(r.boundPropertiesMask&n)){var s=r.boundProperties.get(o),l=e.Tools.first(s,(function(e){return e.binding===i}));if(l){var u=s.indexOf(l);s.splice(u,1)}0===s.length&&(r.boundPropertiesMask&=~n)}if(0===r.boundPropertiesMask&&0===r.monitoredIntermediateMask){r.monitoredObject.propertyChanged.remove(r.observer);var c=t._getObjectId(r.monitoredObject);t._monitoredObjects.remove(c)}return a},t._getMonitoredObjectData=function(e){var r=t._getObjectId(e),n=t._monitoredObjects.getOrAddWithFactory(r,(function(t){return new h(e)}));return n},t._getObjectId=function(t){var r=t.__bindingHelperObjectId__;return null==r?(r=e.Tools.RandomId(),t.__bindingHelperObjectId__=r,r):r},t._getObjectTypePropertyIDs=function(r){var n=e.Tools.getFullClassName(r);if(!n)throw Error("Types involved in Data Binding must be decorated with the @className decorator");var i=t._propertiesID.getOrAddWithFactory(n,(function(){return new e.StringDictionary}));return i},t._getPropertyID=function(e,r){var n=t._getObjectTypePropertyIDs(e),i=n.getOrAddWithFactory(r,(function(e){return 1<, left:, right:, bottom:");0===(15&this._flags)&&(this._flags|=t.Pixel<<0),0===(240&this._flags)&&(this._flags|=t.Pixel<<4),0===(3840&this._flags)&&(this._flags|=t.Pixel<<8),0===(61440&this._flags)&&(this._flags|=t.Pixel<<12),this.onChangeCallback()},t.prototype.fromStrings=function(e,t,r,n){return this._clear(),this._setStringValue(e,0,!1),this._setStringValue(t,1,!1),this._setStringValue(r,2,!1),this._setStringValue(n,3,!1),this.onChangeCallback(),this},t.prototype.fromPixels=function(e,t,r,n){return this._clear(),this._pixels[0]=e,this._pixels[1]=t,this._pixels[2]=r,this._pixels[3]=n,this.onChangeCallback(),this},t.prototype.fromUniformPixels=function(e){return this._clear(),this._pixels[0]=e,this._pixels[1]=e,this._pixels[2]=e,this._pixels[3]=e,this.onChangeCallback(),this},t.prototype.copyFrom=function(e){this._clear();for(var t=0;t<4;t++)this._pixels[t]=e._pixels[t],this._percentages[t]=e._percentages[t];this._flags=e._flags,this.onChangeCallback()},t.prototype.auto=function(){return this._clear(),this._flags=t.Auto<<0|t.Auto<<4|t.Auto<<8|t.Auto<<12,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this.onChangeCallback(),this},t.prototype._clear=function(){this._flags=0,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this._percentages[0]=null,this._percentages[1]=null,this._percentages[2]=null,this._percentages[3]=null},t.prototype._extractString=function(e,t){var r=e.trim().toLocaleLowerCase();return 0===r.indexOf("top:")?(r=r.substr(4).trim(),this._setStringValue(r,0,t)):0===r.indexOf("left:")?(r=r.substr(5).trim(),this._setStringValue(r,1,t)):0===r.indexOf("right:")?(r=r.substr(6).trim(),this._setStringValue(r,2,t)):0===r.indexOf("bottom:")&&(r=r.substr(7).trim(),this._setStringValue(r,3,t))},t.prototype._setStringValue=function(e,r,n){var i=e.trim().toLocaleLowerCase();if("auto"===i){if(this._isType(r,t.Auto))return!0;this._setType(r,t.Auto),this._pixels[r]=0,n&&this.onChangeCallback()}else{if("inherit"!==i){var o=i.indexOf("%");if(o!==-1){var a=i.substr(0,o),s=Math.round(Number(a))/100;return!(!this._isType(r,t.Percentage)||this._percentages[r]!==s)||(this._setType(r,t.Percentage),!isNaN(s)&&(this._percentages[r]=s,n&&this.onChangeCallback(),!0))}var l=void 0;o=i.indexOf("px"),l=o!==-1?i.substr(0,o).trim():i;var u=Number(l);return!(!this._isType(r,t.Pixel)||this._pixels[r]!==u)||!isNaN(u)&&(this._pixels[r]=u,this._setType(r,t.Pixel),n&&this.onChangeCallback(),!0)}if(this._isType(r,t.Inherit))return!0;this._setType(r,t.Inherit),this._pixels[r]=null,n&&this.onChangeCallback()}},t.prototype._setPixels=function(e,r,n){e=Math.round(e),this._isType(r,t.Pixel)&&this._pixels[r]===e||(this._setType(r,t.Pixel),this._pixels[r]=e,n&&this.onChangeCallback())},t.prototype._setPercentage=function(e,r,n){e=Math.min(1,e),e=Math.max(0,e),e=Math.round(100*e)/100,this._isType(r,t.Percentage)&&this._percentages[r]===e||(this._setType(r,t.Percentage),this._percentages[r]=e,n&&this.onChangeCallback())},t.prototype._getStringValue=function(e){var r=this._flags>>4*e&15;switch(r){case t.Auto:return"auto";case t.Pixel:return this._pixels[e]+"px";case t.Percentage:return 100*this._percentages[e]+"%";case t.Inherit:return"inherit"}return""},t.prototype._isType=function(e,t){var r=this._flags>>4*e&15;return r===t},t.prototype._getType=function(e,r){var n=this._flags>>4*e&15;if(r&&n===t.Inherit){var i=this._parentAccess();return i?i._getType(e,!0):t.Auto}return n},t.prototype._setType=function(e,t){this._flags&=~(15<<4*e),this._flags|=t<<4*e},t.prototype.setTop=function(e){"string"==typeof e?this._setStringValue(e,0,!0):this.topPixels=e},t.prototype.setLeft=function(e){"string"==typeof e?this._setStringValue(e,1,!0):this.leftPixels=e},t.prototype.setRight=function(e){"string"==typeof e?this._setStringValue(e,2,!0):this.rightPixels=e},t.prototype.setBottom=function(e){"string"==typeof e?this._setStringValue(e,3,!0):this.bottomPixels=e},Object.defineProperty(t.prototype,"top",{get:function(){return this._getStringValue(0)},set:function(e){this._setStringValue(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this._getStringValue(1)},set:function(e){this._setStringValue(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._getStringValue(2)},set:function(e){this._setStringValue(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this._getStringValue(3)},set:function(e){this._setStringValue(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topPixels",{get:function(){return this._pixels[0]},set:function(e){this._setPixels(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPixels",{get:function(){return this._pixels[1]},set:function(e){this._setPixels(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPixels",{get:function(){return this._pixels[2]},set:function(e){this._setPixels(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomPixels",{get:function(){return this._pixels[3]},set:function(e){this._setPixels(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topPercentage",{get:function(){return this._percentages[0]},set:function(e){this._setPercentage(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPercentage",{get:function(){return this._percentages[1]},set:function(e){this._setPercentage(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPercentage",{get:function(){return this._percentages[2]},set:function(e){this._setPercentage(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomPercentage",{get:function(){return this._percentages[3]},set:function(e){this._setPercentage(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topMode",{get:function(){return this._getType(0,!1)},set:function(e){this._setType(0,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftMode",{get:function(){return this._getType(1,!1)},set:function(e){this._setType(1,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightMode",{get:function(){return this._getType(2,!1)},set:function(e){this._setType(2,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomMode",{get:function(){return this._getType(3,!1)},set:function(e){this._setType(3,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isDefault",{get:function(){return 4369===this._flags},enumerable:!0,configurable:!0}),t.prototype._computePixels=function(e,r,n){var i=this._getType(e,!1);if(i===t.Inherit)return void this._parentAccess()._computePixels(e,r,n);if(i===t.Percentage){var o=(0===e||3===e?r.height:r.width)*this._percentages[e];this._pixels[e]=o,n&&this.onChangeCallback()}},t.prototype.onChangeCallback=function(){this._changedCallback&&this._changedCallback()},t.prototype.computeWithAlignment=function(e,r,n,o,a,s){void 0===s&&(s=!1);var l=this._getType(0,!0),u=this._getType(1,!0),c=this._getType(2,!0),h=this._getType(3,!0),d=r&&null!=r.width,p=r&&null!=r.height,f=d?r.width:0,_=p?r.height:0,g=l===t.Auto,y=u===t.Auto,m=c===t.Auto,b=h===t.Auto;switch(n.horizontal){case i.AlignLeft:y?o.x=0:(this._computePixels(1,e,!0),o.x=this.leftPixels),a.width=f,s&&(a.width+=this.leftPixels),o.z=e.width-(o.x+f);break;case i.AlignRight:m?o.x=Math.round(e.width-f):(this._computePixels(2,e,!0),o.x=Math.round(e.width-(f+this.rightPixels))),a.width=f,s&&(a.width+=this.rightPixels),o.z=this.rightPixels;break;case i.AlignStretch:y?o.x=0:(this._computePixels(1,e,!0),o.x=this.leftPixels);var P=0;m||(this._computePixels(2,e,!0),P=this.rightPixels),a.width=e.width-(o.x+P),o.z=this.rightPixels;break;case i.AlignCenter:y||this._computePixels(1,e,!0),m||this._computePixels(2,e,!0);var v=(y?0:this.leftPixels)-(m?0:this.rightPixels);o.x=Math.round((e.width-f)/2+v),a.width=f,o.z=e.width-(o.x+f)}switch(n.vertical){case i.AlignTop:g?o.y=e.height-_:(this._computePixels(0,e,!0),o.y=Math.round(e.height-(_+this.topPixels))),a.height=_,s&&(a.height+=this.topPixels),o.w=this.topPixels;break;case i.AlignBottom:b?o.y=0:(this._computePixels(3,e,!0),o.y=this.bottomPixels),a.height=_,s&&(a.height+=this.bottomPixels),o.w=e.height-(o.y+_);break;case i.AlignStretch:b?o.y=0:(this._computePixels(3,e,!0),o.y=this.bottomPixels);var C=0;g||(this._computePixels(0,e,!0),C=this.topPixels),a.height=e.height-(o.y+C),o.w=this.topPixels;break;case i.AlignCenter:g||this._computePixels(0,e,!0),b||this._computePixels(3,e,!0);var v=(b?0:this.bottomPixels)-(g?0:this.topPixels);o.y=Math.round((e.height-_)/2+v),a.height=_,o.w=e.height-(o.y+_)}},t.prototype.compute=function(e,t,r){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.x=this.leftPixels,r.width=e.width-(t.x+this.rightPixels),t.y=this.bottomPixels,r.height=e.height-(t.y+this.topPixels),t.z=this.rightPixels,t.w=this.topPixels},t.prototype.computeArea=function(e,t){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.width=this.leftPixels+e.width+this.rightPixels,t.height=this.bottomPixels+e.height+this.topPixels},t.prototype.enlarge=function(e,t,r){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.x=this.leftPixels,r.width=e.width+(t.x+this.rightPixels),t.y=this.bottomPixels,r.height=e.height+(t.y+this.topPixels),t.z=this.rightPixels,t.w=this.topPixels},t.Auto=1,t.Inherit=2,t.Percentage=4,t.Pixel=8,t=__decorate([e.className("PrimitiveThickness","BABYLON")],t)})();e.PrimitiveThickness=a;var s=(function(){function t(){this.findFirstOnly=!1,this.intersectHidden=!1,this.pickPosition=e.Vector2.Zero()}return Object.defineProperty(t.prototype,"isIntersected",{get:function(){return this.intersectedPrimitives&&this.intersectedPrimitives.length>0},enumerable:!0,configurable:!0}),t.prototype.isPrimIntersected=function(e){for(var t=0,r=this.intersectedPrimitives;t1&&(t=1),this._opacity!==t&&(this._opacity=t,this._setFlags(e.SmartPropertyPrim.flagActualOpacityDirty),this._spreadActualOpacityChanged(),this._updateRenderMode())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scaleX",{get:function(){return this._scale.x},set:function(t){this._scale.x=t,this._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),this._spreadActualScaleDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scaleY",{get:function(){return this._scale.y},set:function(t){this._scale.y=t,this._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),this._spreadActualScaleDirty()},enumerable:!0,configurable:!0}),r.prototype._spreadActualScaleDirty=function(){for(var t=0,r=this._children;t0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPositionAuto",{get:function(){return null==this._position},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerEventObservable",{get:function(){return this._pointerEventObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"zActualOrderChangedObservable",{get:function(){return this._actualZOrderChangedObservable||(this._actualZOrderChangedObservable=new e.Observable),this._actualZOrderChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"displayDebugAreas",{get:function(){return this._displayDebugAreas},set:function(t){if(this._displayDebugAreas!==t){if(t===!1)this._debugAreaGroup.dispose(),this._debugAreaGroup=null;else{var r="#F0808040",n="#F08080FF",i="#F0F04040",o="#F0F040FF",a="#F040F040",s="#F040F0FF",l="#40F0F040",u="#40F0F0FF",c=new e.Size(10,10),h=e.Vector2.Zero();this._debugAreaGroup=new e.Group2D({dontInheritParentScale:!0,parent:null!=this.parent?this.parent:this,id:"###DEBUG AREA GROUP###",children:[new e.Group2D({id:"###Layout Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Layout Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:n}),new e.Rectangle2D({id:"###Layout Top###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Left###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Right###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Bottom###",position:e.Vector2.Zero(),size:c,fill:r})]}),new e.Group2D({id:"###Margin Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Margin Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:o}),new e.Rectangle2D({id:"###Margin Top###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Left###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Right###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Bottom###",position:e.Vector2.Zero(),size:c,fill:i})]}),new e.Group2D({id:"###Padding Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Padding Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:s}),new e.Rectangle2D({id:"###Padding Top###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Left###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Right###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Bottom###",position:e.Vector2.Zero(),size:c,fill:a})]}),new e.Group2D({id:"###Content Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Content Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:u}),new e.Rectangle2D({id:"###Content Top###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Left###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Right###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Bottom###",position:e.Vector2.Zero(),size:c,fill:l})]})]}),this._debugAreaGroup._setFlags(e.SmartPropertyPrim.flagNoPartOfLayout),this._updateDebugArea()}this._displayDebugAreas=t}},enumerable:!0,configurable:!0}),r.prototype._updateDebugArea=function(){for(var t=["Layout","Margin","Padding","Content"],r=["Area","Frame","Top","Left","Right","Bottom"],n=new Array(4),i=0;i<4;i++){n[i]=new Array(6);for(var o=0;o<6;o++)n[i][o]=this._debugAreaGroup.findById("###"+t[i]+" "+r[o]+"###"),o>1&&(n[i][o].levelVisible=!1)}var a=null!=this._layoutAreaPos,s=0!==this.actualPosition.x||0!==this.actualPosition.y,l=this._hasMargin,u=this._hasPadding;n[0][0].levelVisible=a,n[1][0].levelVisible=l,n[2][0].levelVisible=u,n[3][0].levelVisible=!0;var c=e.Vector2.Zero(),h=0,d=new Array(4),p=function(e,t){var r=e.clone(),n=e.clone();t.width>0&&(n.x+=t.width),t.height>0&&(n.y+=t.height),d[h++]={off:e,size:t,min:r,max:n}},f=this instanceof e.Canvas2D,_=this._marginOffset.x+this._marginOffset.z,g=this._marginOffset.y+this._marginOffset.w,y=this.actualSize.multiplyByFloats(f?1:this.scaleX,f?1:this.scaleY),m=a?this.layoutAreaPos.x+this.layoutArea.width:_+y.width,b=a?this.layoutAreaPos.y+this.layoutArea.height:g+y.height,P=a||l||u||!s?e.Vector2.Zero():this.actualPosition;if(p(P,new e.Size(m,b)),a){var v=this.layoutAreaPos.clone();p(v,l||u?this.layoutArea.clone():y.clone()),c=v.clone()}if(l){var C=c.clone();C.x+=this._marginOffset.x,C.y+=this._marginOffset.y;var O=y;p(C,O),c=C.clone()}if(u){var D=c.clone();D.x+=this._paddingOffset.x,D.y+=this._paddingOffset.y;var S=this.contentArea;p(D,S),c=c.add(D)}var I=function(e,t,r,i){n[e][t].position=r,n[e][t].size=i},x=function(e,t,r){var i=n[e];i[2].levelVisible=!0,i[3].levelVisible=!1,i[4].levelVisible=!1,i[5].levelVisible=!1,I(e,1,t,r),I(e,2,t,r)},A=function(t,r){var i=n[t];i[2].levelVisible=!0,i[3].levelVisible=!0,i[4].levelVisible=!0,i[5].levelVisible=!0;var o=d[r],a=d[r+1],s=new e.Vector2(o.min.x,a.max.y),l=new e.Size(o.size.width,o.max.y-s.y),u=new e.Vector2(o.min.x,a.min.y),c=new e.Size(a.min.x-o.min.x,a.max.y-a.min.y),h=new e.Vector2(a.max.x,a.min.y),p=new e.Size(o.max.x-a.max.x,a.max.y-a.min.y),f=new e.Vector2(o.min.x,o.min.y),_=new e.Size(o.size.width,a.min.y-o.min.y);i[1].position=o.off,i[1].size=o.size,i[2].position=s,i[2].size=l,i[3].position=u,i[3].size=c,i[4].position=h,i[4].size=p,i[5].position=f,i[5].size=_};h=0;for(var T=[!1,a,l,u,!0],R=1;R<5;R++)if(T[R]){var B=d[h];I(R-1,0,e.Vector2.Zero(),B.size),4===R?x(R-1,B.off,B.size):A(R-1,h),++h}},r.prototype.findById=function(e){if(this._id===e)return this;for(var t=0,r=this._children;tc.prim.actualZOffset)&&(t.topMostIntersectedPrimitive=c),t.findFirstOnly)return t._exit(n),!0}if(!u||!t.findFirstOnly)for(var h=0,d=this._children;h0;)this._children[this._children.length-1].dispose();return!0},r.prototype.onPrimBecomesDirty=function(){this._renderGroup&&!this._isFlagSet(e.SmartPropertyPrim.flagPrimInDirtyList)&&(this._renderGroup._addPrimToDirtyList(this),this._setFlags(e.SmartPropertyPrim.flagPrimInDirtyList))},r.prototype._needPrepare=function(){return this._areSomeFlagsSet(e.SmartPropertyPrim.flagVisibilityChanged|e.SmartPropertyPrim.flagModelDirty|e.SmartPropertyPrim.flagNeedRefresh)||0!==this._instanceDirtyFlags||this._globalTransformProcessStep!==this._globalTransformStep},r.prototype._prepareRender=function(e){this._prepareRenderPre(e),this._prepareRenderPost(e)},r.prototype._prepareRenderPre=function(e){},r.prototype._prepareRenderPost=function(t){if(this instanceof e.Group2D){var n=this;if(n.isRenderableGroup)return}this._children.length>0&&(this._globalTransformProcessStep!==this._globalTransformStep||this.checkPropertiesDirty(r.isVisibleProperty.flagId))&&this._children.forEach((function(r){r instanceof e.Group2D&&r.isRenderableGroup||r._prepareRender(t)})),this._clearFlags(e.SmartPropertyPrim.flagModelDirty),this._instanceDirtyFlags=0},r.prototype._canvasPreInit=function(e){},r.CheckParent=function(e){},r.prototype.updateCachedStatesOf=function(e,t){for(var r=0,n=e;r0&&this._firstZDirtyIndex-10)for(var l=0,u=this._children;l0){var l=this._instanceDataParts[0],u=l.renderMode,c=this.renderMode;if(u!==c){a=u===e.Render2DContext.RenderModeTransparent,s=!0;var h=void 0;switch(c){case e.Render2DContext.RenderModeTransparent:h=t.transparentData;break;case e.Render2DContext.RenderModeAlphaTest:h=t.alphaTestData;break;default:h=t.opaqueData}for(var d=0;d0||t.forceRefreshPrimitive)&&(r=n._primDirtyList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),this.updateCachedStatesOf(r,!0));var i=this.actualSize,o=this.actualScale,a=Math.ceil(i.width*o.x),s=Math.ceil(i.height*o.y);if((this instanceof e.Canvas2D||"__cachedCanvasGroup__"===this.id)&&null!=this.owner.designSize&&(a=this.owner.engine.getRenderWidth(),s=this.owner.engine.getRenderHeight()),!this._isCachedGroup){var l=this._globalTransform.getTranslation(),u=this.owner._renderingSize;s=Math.min(s,u.height-l.y),a=Math.min(a,u.width-l.x);var c=l.x,h=l.y;this._viewportPosition.x=c,this._viewportPosition.y=h}if(this._viewportSize.width===a&&this._viewportSize.height===s||(t.forceRefreshPrimitive=!0,this._viewportSize.width=a,this._viewportSize.height=s),n._primDirtyList.length>0||t.forceRefreshPrimitive){if(this._cacheGroupDirty=this._isCachedGroup,n._primNewDirtyList.splice(0),t.forceRefreshPrimitive)for(var d=0,p=this._children;d0)){var a=!i.modelRenderCache.render(i,c);i.opaqueDirty=a,n+=a?1:0}})),r.setAlphaTesting(!0),r.setDepthWrite(!0),c=new e.Render2DContext(e.Render2DContext.RenderModeAlphaTest),this._renderableData._renderGroupInstancesInfo.forEach((function(e,i){var o=t._prepareContext(r,c,i);if(null!==o&&(!t.owner.supportInstancedArray||o>0)){var a=!i.modelRenderCache.render(i,c);i.opaqueDirty=a,n+=a?1:0}})),r.setAlphaTesting(!0),r.setDepthWrite(!1),this._renderableData._transparentListChanged&&this._updateTransparentData(),n+=this._renderTransparentData(),this._cacheGroupDirty=0!==n,this.isCachedGroup?this._unbindCacheTarget():s&&r.setViewport(s),r.setAlphaTesting(l),r.setDepthWrite(u)}},n.prototype._setCacheGroupDirty=function(){this._cacheGroupDirty=!0},n.prototype._updateTransparentData=function(){this.owner._addUpdateTransparentDataCount(1);var t=this._renderableData;t._transparentPrimitives.sort((function(e,t){return t._primitive.actualZOffset-e._primitive.actualZOffset}));for(var r=function(e,r){var n=t._transparentPrimitives[r];return e.groupInsanceInfo===n._groupInstanceInfo&&(n._transparentSegment=e,n._primitive._updateTransparentSegmentIndices(e),!0)},n=0,i=t._transparentSegments;n=this.owner.minPartCountToUseInstancedArray){if(s.partBuffers){if(l.transparentDirty)for(var d=0;d0){for(var l=0;!r.groupInfoPartData[l];)l++;r.partDataEndIndex=r.groupInfoPartData[l]._partData.usedElementCount}return s},n.prototype._setRenderingScale=function(e){this._renderableData._renderingScale!==e&&(this._renderableData._renderingScale=e)},n.prototype._bindCacheTarget=function(){var t,r,i,o=this._renderableData,a=o._renderingScale,s=o._noResizeOnScale,l=null==this.parent;i=s?l?n._uV:this.parent.actualScale:this.actualScale,l&&this.owner.cachingStrategy===e.Canvas2D.CACHESTRATEGY_CANVAS&&this.owner.isScreenSpace?this.owner.designSize||this.owner.fitRenderingDevice?(n._s.width=this.owner.engine.getRenderWidth(),n._s.height=this.owner.engine.getRenderHeight()):n._s.copyFrom(this.owner.size):(n._s.width=Math.ceil(this.actualSize.width*i.x*a),n._s.height=Math.ceil(this.actualSize.height*i.y*a));var u=!n._s.equals(o._cacheSize);if(o._cacheNode){var c=o._cacheNode.contentSize;if(c.width=i._i1.y?(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n):(i._i1.x=t.width-r,i._i1.y=t.height-r,i._i0.x>=i._i1.x&&i._i0.y>=i._i1.y?(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n):(i._i1.x=t.width-r,i._i1.y=r,!(i._i0.x>=i._i1.x&&i._i0.y<=i._i1.y)||(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n))))},i.prototype.updateLevelBoundingInfo=function(){e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo)},i.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},i.prototype.setupModelRenderCache=function(t){var r=t,n=this.owner.engine;if(this.fill){for(var o=4*(this.notRounded?1:i.roundSubdivisions)+1,a=new Float32Array(o),s=0;s0&&e.push(this.texture),e},i.prototype.levelIntersect=function(e){return!0},i.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},i.prototype.setupModelRenderCache=function(e){for(var t=e,r=this.owner.engine,n=new Float32Array(4),o=0;o<4;o++)n[o]=o;t.vb=r.createVertexBuffer(n);var a=new Float32Array(6);a[0]=0,a[1]=2,a[2]=1,a[3]=0,a[4]=3,a[5]=2,t.ib=r.createIndexBuffer(a),t.texture=this.texture;var s=this.getDataPartEffectInfo(i.SPRITE2D_MAINPARTID,["index"],["alphaTest"],!0);return s&&(t.effectInstanced=r.createEffect("sprite2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null)),s=this.getDataPartEffectInfo(i.SPRITE2D_MAINPARTID,["index"],["alphaTest"],!1),t.effect=r.createEffect("sprite2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null),t},i.prototype.createInstanceDataParts=function(){return[new r(i.SPRITE2D_MAINPARTID)]},i.prototype.beforeRefreshForLayoutConstruction=function(e){i.layoutConstructMode=!0},i.prototype.afterRefreshForLayoutConstruction=function(e,t){i.layoutConstructMode=!1},i.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(!this.texture.isReady()&&!i.layoutConstructMode)return!1;if(t.id===i.SPRITE2D_MAINPARTID){var r=this._instanceDataParts[0];if(i.layoutConstructMode)r.topLeftUV=e.Vector2.Zero(),r.sizeUV=e.Vector2.Zero(),r.properties=e.Vector3.Zero(),r.textureSize=e.Vector2.Zero(),r.scaleFactor=e.Vector2.Zero();else{var o=this.texture.getBaseSize(),a=this.spriteLocation,s=this.actualSize,l=this.spriteScaleFactor;r.topLeftUV=new e.Vector2(a.x/o.width,a.y/o.height);var u=new e.Vector2(s.width/o.width,s.height/o.height);r.sizeUV=u,r.scaleFactor=l,i._prop.x=this.spriteFrame,i._prop.y=this.invertY?1:0,i._prop.z=this.alignToPixel?1:0,r.properties=i._prop,r.textureSize=new e.Vector2(o.width,o.height)}}return!0},i.prototype._mustUpdateInstance=function(){var e=this._oldTextureHasAlpha!==(null!=this.texture&&this.texture.hasAlpha);return this._oldTextureHasAlpha=null!=this.texture&&this.texture.hasAlpha,e&&this._updateRenderMode(),e},i.prototype._useTextureAlpha=function(){return null!=this.texture&&this.texture.hasAlpha},i.prototype._shouldUseAlphaFromTexture=function(){return null!=this.texture&&this.texture.hasAlpha&&this.useAlphaFromTexture},i.SPRITE2D_MAINPARTID=1,i._prop=e.Vector3.Zero(),i.layoutConstructMode=!1,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,(function(e){return i.textureProperty=e}))],i.prototype,"texture",null),__decorate([e.dynamicLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,(function(e){return i.useAlphaFromTextureProperty=e}))],i.prototype,"useAlphaFromTexture",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,(function(e){return i.actualSizeProperty=e}),!1,!0)],i.prototype,"actualSize",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+4,(function(e){return i.spriteLocationProperty=e}))],i.prototype,"spriteLocation",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,(function(e){return i.spriteFrameProperty=e}))],i.prototype,"spriteFrame",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+6,(function(e){return i.invertYProperty=e}))],i.prototype,"invertY",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+7,(function(e){return i.spriteScaleFactorProperty=e}))],i.prototype,"spriteScaleFactor",null),i=__decorate([e.className("Sprite2D","BABYLON")],i)})(e.RenderablePrim2D);e.Sprite2D=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(){t.apply(this,arguments),this.effectsReady=!1,this.vb=null,this.ib=null,this.instancingAttributes=null,this.fontTexture=null,this.effect=null,this.effectInstanced=null}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var i=t.owner.owner,o=i.engine;this.fontTexture.update();var a=r.useInstancing?this.effectInstanced:this.effect;o.enableEffect(a),a.setTexture("diffuseSampler",this.fontTexture),o.bindBuffersDirectly(this.vb,this.ib,[1],4,a);var s,l=this.fontTexture.isSignedDistanceField;l||(s=o.getAlphaMode(),o.setAlphaMode(e.Engine.ALPHA_COMBINE,!0));var u=r.groupInfoPartData[0];if(r.useInstancing){this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(n.TEXT2D_MAINPARTID,a));var c=r.instancedBuffers?r.instancedBuffers[0]:u._partBuffer,h=r.instancedBuffers?r.instancesCount:u._partData.usedElementCount;i._addDrawCallCount(1,r.renderMode),o.updateAndBindInstancesBuffer(c,null,this.instancingAttributes),o.draw(!0,0,6,h),o.unbindInstanceAttributes()}else{i._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;dMath.max(e,r))&&!(uMath.max(i,a))},i.prototype._updateMinMax=function(e,t){t>=e.length||(this._boundingMin.x=Math.min(this._boundingMin.x,e[t]),this._boundingMax.x=Math.max(this._boundingMax.x,e[t]),this._boundingMin.y=Math.min(this._boundingMin.y,e[t+1]),this._boundingMax.y=Math.max(this._boundingMax.y,e[t+1]))},i.prototype._store=function(t,r,n,o,a,s,l,u,c){var h=null!=u&&!isNaN(u),d=n*(h?8:4);if(!(d>=t.length)){0===n?this._perp(s,i._startDir):n===o-1&&(this._perp(s,i._endDir),i._endDir.x*=-1,i._endDir.y*=-1);var p=!1;if(t[d+0]=a.x+s.x*l,t[d+1]=a.y+s.y*l,t[d+2]=a.x+s.x*-l,t[d+3]=a.y+s.y*-l,this._updateMinMax(t,d),this._updateMinMax(t,d+2),0!=c){var f=c*(h?8:4);if(this._intersect(t[d+0],t[d+1],t[f+0],t[f+1],t[d+2],t[d+3],t[f+2],t[f+3])){p=!0;var _=t[d+0];t[d+0]=t[d+2],t[d+2]=_,_=t[d+1],t[d+1]=t[d+3],t[d+3]=_}}if(h){var g=l+u;t[d+4]=a.x+s.x*(p?-g:g),t[d+5]=a.y+s.y*(p?-g:g),t[d+6]=a.x+s.x*(p?g:-g),t[d+7]=a.y+s.y*(p?g:-g),this._updateMinMax(t,d+4),this._updateMinMax(t,d+6)}r&&(d+=h?4:0,r.push(new e.Vector2(t[d+0],t[d+1])),r.push(new e.Vector2(t[d+2],t[d+3])))}},i.prototype._getCapSize=function(e,t){void 0===t&&(t=!1);var r=i._roundCapSubDiv,n=0,o=0;switch(e){case i.NoCap:!this.closed&&t?(n=4,o=6):n=o=0;break;case i.RoundCap:t?(n=r,o=3*(r-2)):(n=r/2+1,o=r/2*3);break;case i.ArrowCap:t?(n=12,o=24):(n=3,o=3);break;case i.TriangleCap:t?(n=6,o=12):(n=3,o=3);break;case i.DiamondAnchorCap:t?(n=10,o=24):(n=5,o=9);break;case i.SquareAnchorCap:t?(n=12,o=30):(n=4,o=6);break;case i.RoundAnchorCap:t?(n=2*r,o=6*(r-1)):(n=r+1,o=3*(r+1))}return{vbsize:2*n,ibsize:o}},i.prototype._storeVertex=function(e,t,r,n,o,a,s){var l=Math.cos(o),u=Math.sin(o);i._tpsV.x=l*a.x+-u*a.y+n.x,i._tpsV.y=u*a.x+l*a.y+n.y;var c=t+2*r;return e[c+0]=i._tpsV.x,e[c+1]=i._tpsV.y,s&&(s.push(i._tpsV.x),s.push(i._tpsV.y)),this._updateMinMax(e,c),(t+2*r)/2},i.prototype._storeIndex=function(e,t,r,n){e[t+r]=n},i.prototype._buildCap=function(t,r,n,o,a,s,l,u,c,h){var d=i._roundCapSubDiv,p=new e.Vector2(1,0),f=Math.atan2(c.y,c.x)-Math.atan2(p.y,p.x),_=s/2,g=s,y=null!=l,m=l;switch(u){case i.NoCap:if(y&&!this.closed){var b=0,P=0,v=this._storeVertex(t,r,b++,a,f,new e.Vector2(0,_+m),h),C=this._storeVertex(t,r,b++,a,f,new e.Vector2(m,_+m),h),O=this._storeVertex(t,r,b++,a,f,new e.Vector2(m,(-(_+m))),h),D=this._storeVertex(t,r,b++,a,f,new e.Vector2(0,(-(_+m))),h);this._storeIndex(n,o,P++,v),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,O),this._storeIndex(n,o,P++,v),this._storeIndex(n,o,P++,O),this._storeIndex(n,o,P++,D)}break;case i.ArrowCap:_*=2;case i.TriangleCap:if(y){var S=u===i.TriangleCap?m:Math.sqrt(m*m*2),v=this._storeVertex(t,r,0,a,f,new e.Vector2(0,_),null),C=this._storeVertex(t,r,1,a,f,new e.Vector2(_,0),null),O=this._storeVertex(t,r,2,a,f,new e.Vector2(0,(-_)),null),D=this._storeVertex(t,r,3,a,f,new e.Vector2(0,_+S),h),I=this._storeVertex(t,r,4,a,f,new e.Vector2(_+S,0),h),x=this._storeVertex(t,r,5,a,f,new e.Vector2(0,(-(_+S))),h),P=0;if(this._storeIndex(n,o,P++,v),this._storeIndex(n,o,P++,D),this._storeIndex(n,o,P++,I),this._storeIndex(n,o,P++,v),this._storeIndex(n,o,P++,I),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,x),this._storeIndex(n,o,P++,O),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,x),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,I),u===i.ArrowCap){var A=s/2,T=this._storeVertex(t,r,9,a,f,new e.Vector2(0,(-(A+m))),null),R=this._storeVertex(t,r,11,a,f,new e.Vector2((-m),(-(_+S))),h),B=this._storeVertex(t,r,10,a,f,new e.Vector2((-m),(-(A+m))),h),w=this._storeVertex(t,r,6,a,f,new e.Vector2(0,A+m),null),E=this._storeVertex(t,r,7,a,f,new e.Vector2((-m),A+m),h),L=this._storeVertex(t,r,8,a,f,new e.Vector2((-m),_+S),h);this._storeIndex(n,o,P++,w),this._storeIndex(n,o,P++,E),this._storeIndex(n,o,P++,L),this._storeIndex(n,o,P++,w),this._storeIndex(n,o,P++,L),this._storeIndex(n,o,P++,D),this._storeIndex(n,o,P++,T),this._storeIndex(n,o,P++,R),this._storeIndex(n,o,P++,B),this._storeIndex(n,o,P++,T),this._storeIndex(n,o,P++,x),this._storeIndex(n,o,P++,R)}}else{var v=this._storeVertex(t,r,0,a,f,new e.Vector2(0,_),h),C=this._storeVertex(t,r,1,a,f,new e.Vector2(_,0),h),O=this._storeVertex(t,r,2,a,f,new e.Vector2(0,(-_)),h);this._storeIndex(n,o,0,v),this._storeIndex(n,o,1,C),this._storeIndex(n,o,2,O)}break;case i.RoundCap:if(y)for(var M=-Math.PI/2,F=Math.PI/(d/2-1),P=0,N=0;N0&&(this._storeIndex(n,o,P++,v-2),this._storeIndex(n,o,P++,C-2),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,v-2),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,v)),M+=F}else{var V=this._storeVertex(t,r,0,a,f,new e.Vector2(0,0),null),M=-Math.PI/2,F=Math.PI/(d/2-1);this._storeVertex(t,r,1,a,f,new e.Vector2(Math.cos(M)*_,Math.sin(M)*_),null),M+=F;for(var N=1;N0&&(this._storeIndex(n,o,P++,v-2),this._storeIndex(n,o,P++,C-2),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,v-2),this._storeIndex(n,o,P++,C),this._storeIndex(n,o,P++,v)),M+=F}else{var V=this._storeVertex(t,r,0,a,f,G,null);this._storeVertex(t,r,1,a,f,new e.Vector2(z+Math.cos(M)*g,Math.sin(M)*g),null),M+=F;for(var N=1;N2&&this.closed){var g=this.points[c-2],y=this.points[0],m=this.points[1];this._direction(y,g,o),this._direction(m,y,a),this._perp(o,u);var b=this._computeMiter(s,l,o,a);if(this._store(t,null,0,c,this.points[0],l,b*n,b*i,1),r){var P=null==i?0:4;r[0].x=t[P+0],r[0].y=t[P+1],r[1].x=t[P+2],r[1].y=t[P+3]}}this.closed&&this.points.splice(c-1)},i.prototype.setupModelRenderCache=function(t){var r=t,n=this.owner.engine;if(null===this._fillVB&&this._computeLines2D(),this.fill){r.fillVB=n.createVertexBuffer(this._fillVB),r.fillIB=n.createIndexBuffer(this._fillIB),r.fillIndicesCount=this._fillIB.length;var i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],null,!0);i&&(r.effectFillInstanced=n.createEffect("lines2d",i.attributes,i.uniforms,[],i.defines,null)),i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],null,!1),r.effectFill=n.createEffect("lines2d",i.attributes,i.uniforms,[],i.defines,null)}if(this.border){r.borderVB=n.createVertexBuffer(this._borderVB),r.borderIB=n.createIndexBuffer(this._borderIB),r.borderIndicesCount=this._borderIB.length;var i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],null,!0);i&&(r.effectBorderInstanced=n.createEffect({vertex:"lines2d",fragment:"lines2d"},i.attributes,i.uniforms,[],i.defines,null)),i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],null,!1),r.effectBorder=n.createEffect({vertex:"lines2d",fragment:"lines2d"},i.attributes,i.uniforms,[],i.defines,null)}return this._fillVB=null,this._fillIB=null,this._borderVB=null,this._borderIB=null,r},i.prototype._computeLines2D=function(){this._boundingMin=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),this._boundingMax=new e.Vector2(Number.MIN_VALUE,Number.MIN_VALUE);var t=new Array,r=new Array,n=new Array;if(this.fill){var o=this._getCapSize(this.startCap),a=this._getCapSize(this.endCap),s=this.points.length,l=2*s*2+o.vbsize+a.vbsize;this._fillVB=new Float32Array(l);var u=this._fillVB,c=this.fillThickness/2,h=this.points.length;this._buildLine(u,this.border?null:t,c);var d=2*h,p=2*(s-(this.closed?0:1));this._fillIB=new Float32Array(3*p+o.ibsize+a.ibsize);for(var f=this._fillIB,_=0;_0){var y=Earcut.earcut(r,null,2);this._startCapTriIndices=y,this._startCapContour=r}else this._startCapTriIndices=null,this._startCapContour=null;if(n.length>0){var m=Earcut.earcut(n,null,2);this._endCapContour=n,this._endCapTriIndices=m}else this._endCapContour=null,this._endCapTriIndices=null;var b=this._boundingMax.subtract(this._boundingMin);this._size.width=b.x,this._size.height=b.y},Object.defineProperty(i.prototype,"size",{get:function(){return null==this._size&&this._computeLines2D(),this._size},enumerable:!0,configurable:!0}),i.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new r(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new r(e.Shape2D.SHAPE2D_FILLPARTID)),t},i.prototype.applyActualScaleOnTransform=function(){return!0},i.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var r=t;this.border instanceof e.GradientColorBrush2D&&(r.boundingMin=this.boundingMin,r.boundingMax=this.boundingMax)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var r=t;this.fill instanceof e.GradientColorBrush2D&&(r.boundingMin=this.boundingMin,r.boundingMax=this.boundingMax)}return!0},i._prevA=e.Vector2.Zero(),i._prevB=e.Vector2.Zero(),i._curA=e.Vector2.Zero(),i._curB=e.Vector2.Zero(),i._miterTps=e.Vector2.Zero(),i._startDir=e.Vector2.Zero(),i._endDir=e.Vector2.Zero(),i._tpsV=e.Vector2.Zero(),i._noCap=0,i._roundCap=1,i._triangleCap=2,i._squareAnchorCap=3,i._roundAnchorCap=4,i._diamondAnchorCap=5,i._arrowCap=6,i._roundCapSubDiv=36,__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+1,(function(e){return i.pointsProperty=e}))],i.prototype,"points",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,(function(e){return i.fillThicknessProperty=e}))],i.prototype,"fillThickness",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+3,(function(e){return i.closedProperty=e}))],i.prototype,"closed",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+4,(function(e){return i.startCapProperty=e}))],i.prototype,"startCap",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+5,(function(e){return i.endCapProperty=e}))],i.prototype,"endCap",null),i=__decorate([e.className("Lines2D","BABYLON")],i)})(e.Shape2D);e.Lines2D=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._modelCache=new e.StringDictionary}return t.prototype.GetOrAddModelCache=function(e,t){return this._modelCache.getOrAddWithFactory(e,t)},t.prototype.DisposeModelRenderCache=function(e){return!!e.isDisposed&&(this._modelCache.remove(e.modelKey),!0)},t})();e.Canvas2DEngineBoundData=t;var r=(function(r){function n(i,o){var a=this;r.call(this,o),this.worldSpaceToNodeLocal=function(t){var r=a._worldSpaceNode;if(r){var n=r.getWorldMatrix().clone();n.invert();var i=e.Vector3.TransformCoordinates(t,n),o=new e.Vector2(i.x,i.y),s=a.actualSize;return o.x+=.5*s.width,o.y+=.5*s.height,o}},this.worldSpaceCacheChanged=function(){var t=a.worldSpaceCanvasNode,r=e.VertexData.ExtractFromMesh(t);r.uvs=new Float32Array(8);var n=t.material,i=a._renderableData._cacheTexture;n.diffuseTexture!==i&&(n.diffuseTexture=i,i.hasAlpha=!0);for(var o=a._renderableData._cacheNodeUVs,s=0;s<4;s++)r.uvs[2*s+0]=o[s].x,r.uvs[2*s+1]=o[s].y;r.applyToMesh(t)},this._notifDebugMode=!1,this.minPartCountToUseInstancedArray=5,this._mapCounter=0,this._drawCallsOpaqueCounter=new e.PerfCounter,this._drawCallsAlphaTestCounter=new e.PerfCounter,this._drawCallsTransparentCounter=new e.PerfCounter,this._groupRenderCounter=new e.PerfCounter,this._updateTransparentDataCounter=new e.PerfCounter,this._cachedGroupRenderCounter=new e.PerfCounter,this._updateCachedStateCounter=new e.PerfCounter,this._updateLayoutCounter=new e.PerfCounter,this._updatePositioningCounter=new e.PerfCounter,this._updateLocalTransformCounter=new e.PerfCounter,this._updateGlobalTransformCounter=new e.PerfCounter,this._boundingInfoRecomputeCounter=new e.PerfCounter,this._uid=null,this._cachedCanvasGroup=null,this._renderingGroupObserver=null,this._beforeRenderObserver=null,this._afterRenderObserver=null,this._profileInfoText=null,e.Prim2DBase._isCanvasInit=!1,o||(o={}),this._cachingStrategy!==n.CACHESTRATEGY_TOPLEVELGROUPS&&(this._background=new e.Rectangle2D({parent:this,id:"###CANVAS BACKGROUND###",size:o.size}),this._background.zOrder=1,this._background.isPickable=!1,this._background.origin=e.Vector2.Zero(),this._background.levelVisible=!1,null!=o.backgroundRoundRadius&&(this.backgroundRoundRadius=o.backgroundRoundRadius),null!=o.backgroundBorder&&("string"==typeof o.backgroundBorder?this.backgroundBorder=n.GetBrushFromString(o.backgroundBorder):this.backgroundBorder=o.backgroundBorder),null!=o.backgroundBorderThickNess&&(this.backgroundBorderThickness=o.backgroundBorderThickNess),null!=o.backgroundFill&&("string"==typeof o.backgroundFill?this.backgroundFill=n.GetBrushFromString(o.backgroundFill):this.backgroundFill=o.backgroundFill),this.propertyChanged.add((function(e,t){"size"===e.propertyName&&(a._background.size=a.size)}),e.Group2D.sizeProperty.flagId),this._background._patchHierarchy(this));var s=i.getEngine();this.__engineData=s.getOrAddExternalDataWithFactory("__BJSCANVAS2D__",(function(e){return new t})),this._primPointerInfo=new e.PrimitivePointerInfo,this._capturedPointers=new e.StringDictionary,this._pickStartingPosition=e.Vector2.Zero(),this._hierarchyLevelMaxSiblingCount=50,this._hierarchyDepth=0,this._zOrder=0,this._zMax=1,this._scene=i,this._engine=s,this._renderingSize=new e.Size(0,0),this._designSize=o.designSize||null,this._designUseHorizAxis=o.designUseHorizAxis===!0,this._trackedGroups=new Array,this._maxAdaptiveWorldSpaceCanvasSize=null,this._groupCacheMaps=new e.StringDictionary,this._patchHierarchy(this);var l=null==o.enableInteraction||o.enableInteraction;if(this._fitRenderingDevice=!o.size,o.size||(o.size=new e.Size(s.getRenderWidth(),s.getRenderHeight())),i.onDisposeObservable.add((function(e,t){a.dispose()})),this._isScreenSpace)if(o.renderingPhase){if(!o.renderingPhase.camera||null==o.renderingPhase.renderingGroupID)throw Error("You have to specify a valid camera and renderingGroup");this._renderingGroupObserver=this._scene.onRenderingGroupObservable.add((function(t,r){a._scene.activeCamera===o.renderingPhase.camera&&t.renderStage===e.RenderingGroupInfo.STAGE_POSTTRANSPARENT&&(a._engine.clear(null,!1,!0,!0),a._render())}),Math.pow(2,o.renderingPhase.renderingGroupID))}else this._afterRenderObserver=this._scene.onAfterRenderObservable.add((function(e,t){a._engine.clear(null,!1,!0,!0),a._render()}));else this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(e,t){a._render()}));this._supprtInstancedArray=null!==this._engine.getCaps().instancedArrays,this._setupInteraction(l),n._INSTANCES.push(this)}return __extends(n,r),Object.defineProperty(n.prototype,"drawCallsOpaqueCounter",{get:function(){return this._drawCallsOpaqueCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsAlphaTestCounter",{get:function(){return this._drawCallsAlphaTestCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsTransparentCounter",{get:function(){return this._drawCallsTransparentCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"groupRenderCounter",{get:function(){return this._groupRenderCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateTransparentDataCounter",{get:function(){return this._updateTransparentDataCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cachedGroupRenderCounter",{get:function(){return this._cachedGroupRenderCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateCachedStateCounter",{get:function(){return this._updateCachedStateCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateLayoutCounter",{get:function(){return this._updateLayoutCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updatePositioningCounter",{get:function(){return this._updatePositioningCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateLocalTransformCounter",{get:function(){return this._updateLocalTransformCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateGlobalTransformCounter",{get:function(){return this._updateGlobalTransformCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"boundingInfoRecomputeCounter",{get:function(){return this._boundingInfoRecomputeCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n,"instances",{get:function(){return n._INSTANCES},enumerable:!0,configurable:!0}),n.prototype._canvasPreInit=function(e){var t=null==e.cachingStrategy?n.CACHESTRATEGY_DONTCACHE:e.cachingStrategy;this._cachingStrategy=t,this._isScreenSpace=null==e.isScreenSpace||e.isScreenSpace},n.prototype._setupInteraction=function(e){var t=this;if(e!==this._interactionEnabled)if(this._interactionEnabled=e,this._isScreenSpace){if(!e)return void(this._scenePrePointerObserver&&(this.scene.onPrePointerObservable.remove(this._scenePrePointerObserver),this._scenePrePointerObserver=null));this._scenePrePointerObserver=this.scene.onPrePointerObservable.add((function(e,r){if(t.isVisible!==!1){var n=1/t.engine.getHardwareScalingLevel(),i=e.localPosition.multiplyByFloats(n,n);t._handlePointerEventForInteraction(e,i,r)}}))}else{var r=this.scene;e?(r.constantlyUpdateMeshUnderPointer=!0,this._scenePointerObserver=r.onPointerObservable.add((function(e,r){if(t.isVisible!==!1&&e.pickInfo.hit&&e.pickInfo.pickedMesh===t._worldSpaceNode&&t.worldSpaceToNodeLocal){var n=t.worldSpaceToNodeLocal(e.pickInfo.pickedPoint);t._handlePointerEventForInteraction(e,n,r)}}))):this._scenePointerObserver&&(this.scene.onPointerObservable.remove(this._scenePointerObserver),this._scenePointerObserver=null)}},n.prototype._setPointerCapture=function(t,r){if(this.isPointerCaptured(t))return!1;try{this.engine.getRenderingCanvas().setPointerCapture(t)}catch(n){}return this._primPointerInfo.updateRelatedTarget(r,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerGotCapture,null),this._capturedPointers.add(t.toString(),r),!0},n.prototype._releasePointerCapture=function(t,r){if(this._capturedPointers.get(t.toString())!==r)return!1;try{this.engine.getRenderingCanvas().releasePointerCapture(t)}catch(n){}return this._primPointerInfo.updateRelatedTarget(r,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerLostCapture,null),this._capturedPointers.remove(t.toString()),!0},n.prototype.isPointerCaptured=function(e){return this._capturedPointers.contains(e.toString())},n.prototype.getCapturedPrimitive=function(e){return 0===this._capturedPointers.count?null:this._capturedPointers.get(e.toString())},n.prototype._handlePointerEventForInteraction=function(t,r,n){if(!this.isDisposed&&this._updatePointerInfo(t,r)){var i=this.getCapturedPrimitive(this._primPointerInfo.pointerId);if(this._updateIntersectionList(this._primPointerInfo.canvasPointerPos,null!==i,!0),this._updateOverStatus(!0),this._actualOverPrimitive||i){var o=i||this._actualOverPrimitive.prim,a=i?this._primPointerInfo.canvasPointerPos.subtract(new e.Vector2(o.globalTransform.m[12],o.globalTransform.m[13])):this._actualOverPrimitive.intersectionLocation;this._primPointerInfo.updateRelatedTarget(o,a);var s=!1;t.type===e.PointerEventTypes.POINTERWHEEL?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMouseWheel,t):t.type===e.PointerEventTypes.POINTERMOVE?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMove,t):t.type===e.PointerEventTypes.POINTERDOWN?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerDown,t):t.type===e.PointerEventTypes.POINTERUP&&(s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerUp,t)),n.skipNextObservers=s}}},n.prototype._updatePointerInfo=function(t,r){var n=this.scale,i=this._primPointerInfo;i.cancelBubble=!1,i.canvasPointerPos||(i.canvasPointerPos=e.Vector2.Zero());var o=this._scene.cameraToUseForPointers||this._scene.activeCamera;if(!o||!o.viewport)return!1;var a=this._scene.getEngine();if(this._isScreenSpace){var s=o.viewport,l=s.toGlobal(a.getRenderWidth(),a.getRenderHeight()),u=r.x-l.x,c=r.y-l.y;i.canvasPointerPos.x=(u-this.actualPosition.x)/n,i.canvasPointerPos.y=(a.getRenderHeight()-c-this.actualPosition.y)/n}else i.canvasPointerPos.x=r.x/n,i.canvasPointerPos.y=r.y/n;if(i.mouseWheelDelta=0,t.type===e.PointerEventTypes.POINTERWHEEL){var h=t.event;h.wheelDelta?i.mouseWheelDelta=h.wheelDelta/(40*e.PrimitivePointerInfo.MouseWheelPrecision):h.detail&&(i.mouseWheelDelta=-h.detail/e.PrimitivePointerInfo.MouseWheelPrecision)}else{var d=t.event;i.ctrlKey=d.ctrlKey,i.altKey=d.altKey,i.shiftKey=d.shiftKey,i.metaKey=d.metaKey,i.button=d.button,i.buttons=d.buttons,i.pointerId=d.pointerId,i.width=d.width,i.height=d.height,i.presssure=d.pressure,i.tilt.x=d.tiltX,i.tilt.y=d.tiltY,i.isCaptured=null!==this.getCapturedPrimitive(d.pointerId)}return!0},n.prototype._updateIntersectionList=function(e,t,r){if(r||this.scene.getRenderId()!==this._intersectionRenderId){this._globalTransform||this.updateCachedStates(!0);var i=n._interInfo;i.pickPosition.x=e.x,i.pickPosition.y=e.y,i.findFirstOnly=!1,t||this.levelBoundingInfo.doesIntersect(i.pickPosition)?this.intersect(i):(i.intersectedPrimitives=new Array,i.topMostIntersectedPrimitive=null),this._previousIntersectionList=this._actualIntersectionList,this._actualIntersectionList=i.intersectedPrimitives,this._previousOverPrimitive=this._actualOverPrimitive,this._actualOverPrimitive=i.topMostIntersectedPrimitive;var o=null!=this._previousOverPrimitive?this._previousOverPrimitive.prim:null,a=null!=this._actualOverPrimitive?this._actualOverPrimitive.prim:null;o!==a&&this.onPropertyChanged("overPrim",this._previousOverPrimitive?this._previousOverPrimitive.prim:null,this._actualOverPrimitive?this._actualOverPrimitive.prim:null),this._intersectionRenderId=this.scene.getRenderId()}},n.prototype._updateOverStatus=function(t){if((t||this.scene.getRenderId()!==this._hoverStatusRenderId)&&this._previousIntersectionList&&this._actualIntersectionList){var r=this._previousOverPrimitive?this._previousOverPrimitive.prim:null,n=this._actualOverPrimitive?this._actualOverPrimitive.prim:null;if(r!==n){var i=this.getCapturedPrimitive(this._primPointerInfo.pointerId);(i&&i===r||!i&&r&&!r.isDisposed)&&(this._primPointerInfo.updateRelatedTarget(r,this._previousOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerOut,null)),(i&&i===n||!i&&n)&&(this._primPointerInfo.updateRelatedTarget(n,this._actualOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(n,e.PrimitivePointerInfo.PointerOver,null))}this._hoverStatusRenderId=this.scene.getRenderId()}},n.prototype._updatePrimPointerPos=function(e){if(this._primPointerInfo.isCaptured)this._primPointerInfo.primitivePointerPos=this._primPointerInfo.relatedTargetPointerPos;else for(var t=0,r=this._actualIntersectionList;te.ActionManager.LongPressDelay&&Math.abs(o._pickStartingPosition.x-a.pickPosition.x)-1&&n._INSTANCES.splice(e,1),!0},Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"engine",{get:function(){return this._engine},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderObservable",{get:function(){return this._renderObservable||(this._renderObservable=new e.Observable),this._renderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cachingStrategy",{get:function(){return this._cachingStrategy},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isScreenSpace",{get:function(){return this._isScreenSpace},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldSpaceCanvasNode",{get:function(){return this._worldSpaceNode},set:function(e){this._worldSpaceNode=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"supportInstancedArray",{get:function(){return this._supprtInstancedArray},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundFill",{get:function(){return this._background&&this._background.isVisible?this._background.fill:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.fill&&(this._background.fill=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundBorder",{get:function(){return this._background&&this._background.isVisible?this._background.border:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.border&&(this._background.border=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundBorderThickness",{get:function(){return this._background&&this._background.isVisible?this._background.borderThickness:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.borderThickness&&(this._background.borderThickness=e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundRoundRadius",{get:function(){return this._background&&this._background.isVisible?this._background.roundRadius:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.roundRadius&&(this._background.roundRadius=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"interactionEnabled",{get:function(){return this._interactionEnabled},set:function(e){this._setupInteraction(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fitRenderingDevice",{get:function(){return this._fitRenderingDevice},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"designSize",{get:function(){return this._designSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"designSizeUseHorizAxis",{get:function(){return this._designUseHorizAxis},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"overPrim",{get:function(){return this._actualOverPrimitive?this._actualOverPrimitive.prim:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"_engineData",{get:function(){return this.__engineData},enumerable:!0,configurable:!0}),n.prototype.createCanvasProfileInfoCanvas=function(){if(this._profilingCanvas)return this._profilingCanvas;var t=new i(this.scene,{id:"ProfileInfoCanvas",cachingStrategy:n.CACHESTRATEGY_DONTCACHE,children:[new e.Rectangle2D({id:"ProfileBorder",border:"#FFFFFFFF",borderThickness:2,roundRadius:5,fill:"#C04040C0",marginAlignment:"h: left, v: top",margin:"10",padding:"10",children:[new e.Text2D("Stats",{id:"ProfileInfoText",marginAlignment:"h: left, v: top",fontName:"12pt Lucida Console",fontSignedDistanceField:!0})]})]});return this._profileInfoText=t.findById("ProfileInfoText"),this._profilingCanvas=t,t},n.prototype.checkBackgroundAvailability=function(){if(this._cachingStrategy===n.CACHESTRATEGY_TOPLEVELGROUPS)throw Error("Can't use Canvas Background with the caching strategy TOPLEVELGROUPS")},n.prototype._initPerfMetrics=function(){this._drawCallsOpaqueCounter.fetchNewFrame(),this._drawCallsAlphaTestCounter.fetchNewFrame(),this._drawCallsTransparentCounter.fetchNewFrame(),this._groupRenderCounter.fetchNewFrame(),this._updateTransparentDataCounter.fetchNewFrame(),this._cachedGroupRenderCounter.fetchNewFrame(),this._updateCachedStateCounter.fetchNewFrame(),this._updateLayoutCounter.fetchNewFrame(),this._updatePositioningCounter.fetchNewFrame(),this._updateLocalTransformCounter.fetchNewFrame(),this._updateGlobalTransformCounter.fetchNewFrame(),this._boundingInfoRecomputeCounter.fetchNewFrame()},n.prototype._fetchPerfMetrics=function(){this._drawCallsOpaqueCounter.addCount(0,!0),this._drawCallsAlphaTestCounter.addCount(0,!0),this._drawCallsTransparentCounter.addCount(0,!0),this._groupRenderCounter.addCount(0,!0),this._updateTransparentDataCounter.addCount(0,!0),this._cachedGroupRenderCounter.addCount(0,!0),this._updateCachedStateCounter.addCount(0,!0),this._updateLayoutCounter.addCount(0,!0),this._updatePositioningCounter.addCount(0,!0),this._updateLocalTransformCounter.addCount(0,!0),this._updateGlobalTransformCounter.addCount(0,!0),this._boundingInfoRecomputeCounter.addCount(0,!0)},n.prototype._updateProfileCanvas=function(){if(null!=this._profileInfoText){var e=function(e){return(Math.round(100*e)/100).toString()},t="Draw Calls:\n"+(" - Opaque: "+e(this.drawCallsOpaqueCounter.current)+", (avg:"+e(this.drawCallsOpaqueCounter.lastSecAverage)+", t:"+e(this.drawCallsOpaqueCounter.total)+")\n")+(" - AlphaTest: "+e(this.drawCallsAlphaTestCounter.current)+", (avg:"+e(this.drawCallsAlphaTestCounter.lastSecAverage)+", t:"+e(this.drawCallsAlphaTestCounter.total)+")\n")+(" - Transparent: "+e(this.drawCallsTransparentCounter.current)+", (avg:"+e(this.drawCallsTransparentCounter.lastSecAverage)+", t:"+e(this.drawCallsTransparentCounter.total)+")\n")+("Group Render: "+this.groupRenderCounter.current+", (avg:"+e(this.groupRenderCounter.lastSecAverage)+", t:"+e(this.groupRenderCounter.total)+")\n")+("Update Transparent Data: "+this.updateTransparentDataCounter.current+", (avg:"+e(this.updateTransparentDataCounter.lastSecAverage)+", t:"+e(this.updateTransparentDataCounter.total)+")\n")+("Cached Group Render: "+this.cachedGroupRenderCounter.current+", (avg:"+e(this.cachedGroupRenderCounter.lastSecAverage)+", t:"+e(this.cachedGroupRenderCounter.total)+")\n")+("Update Cached States: "+this.updateCachedStateCounter.current+", (avg:"+e(this.updateCachedStateCounter.lastSecAverage)+", t:"+e(this.updateCachedStateCounter.total)+")\n")+(" - Update Layout: "+this.updateLayoutCounter.current+", (avg:"+e(this.updateLayoutCounter.lastSecAverage)+", t:"+e(this.updateLayoutCounter.total)+")\n")+(" - Update Positioning: "+this.updatePositioningCounter.current+", (avg:"+e(this.updatePositioningCounter.lastSecAverage)+", t:"+e(this.updatePositioningCounter.total)+")\n")+(" - Update Local Trans: "+this.updateLocalTransformCounter.current+", (avg:"+e(this.updateLocalTransformCounter.lastSecAverage)+", t:"+e(this.updateLocalTransformCounter.total)+")\n")+(" - Update Global Trans: "+this.updateGlobalTransformCounter.current+", (avg:"+e(this.updateGlobalTransformCounter.lastSecAverage)+", t:"+e(this.updateGlobalTransformCounter.total)+")\n")+(" - BoundingInfo Recompute: "+this.boundingInfoRecomputeCounter.current+", (avg:"+e(this.boundingInfoRecomputeCounter.lastSecAverage)+", t:"+e(this.boundingInfoRecomputeCounter.total)+")");this._profileInfoText.text=t}},n.prototype._addDrawCallCount=function(t,r){switch(r){case e.Render2DContext.RenderModeOpaque:return void this._drawCallsOpaqueCounter.addCount(t,!1);case e.Render2DContext.RenderModeAlphaTest:return void this._drawCallsAlphaTestCounter.addCount(t,!1);case e.Render2DContext.RenderModeTransparent:return void this._drawCallsTransparentCounter.addCount(t,!1)}},n.prototype._addGroupRenderCount=function(e){this._groupRenderCounter.addCount(e,!1)},n.prototype._addUpdateTransparentDataCount=function(e){this._updateTransparentDataCounter.addCount(e,!1)},n.prototype.addCachedGroupRenderCounter=function(e){this._cachedGroupRenderCounter.addCount(e,!1)},n.prototype.addUpdateCachedStateCounter=function(e){this._updateCachedStateCounter.addCount(e,!1)},n.prototype.addUpdateLayoutCounter=function(e){this._updateLayoutCounter.addCount(e,!1)},n.prototype.addUpdatePositioningCounter=function(e){this._updatePositioningCounter.addCount(e,!1)},n.prototype.addupdateLocalTransformCounter=function(e){this._updateLocalTransformCounter.addCount(e,!1)},n.prototype.addUpdateGlobalTransformCounter=function(e){this._updateGlobalTransformCounter.addCount(e,!1)},n.prototype._updateTrackedNodes=function(){var t=this.scene.cameraToUseForPointers||this.scene.activeCamera;t.getViewMatrix().multiplyToRef(t.getProjectionMatrix(),n._m);for(var r=this.engine.getRenderHeight(),i=t.viewport.toGlobal(this.engine.getRenderWidth(),r),o=0,a=this._trackedGroups;of,g=Math.max(p,f);g=g<256?256:Math.pow(2,Math.ceil(Math.log(g)/Math.log(2))),g=Math.min(g,this._maxAdaptiveWorldSpaceCanvasSize);var y=g/(_?this.size.width:this.size.height);if(y!==this.scale){var m=y;this._setRenderingScale(m)}}},n.prototype._updateCanvasState=function(t){if(t||this.scene.getRenderId()!==this._updateRenderId){var r=!1,n=this.engine.getRenderWidth();n!==this._renderingSize.width&&(r=!0),this._renderingSize.width=n;var i=this.engine.getRenderHeight();if(i!==this._renderingSize.height&&(r=!0),this._renderingSize.height=i,r&&this._fitRenderingDevice&&(this._actualSize=this._renderingSize.clone(),this._size=this._renderingSize.clone(),this._background&&(this._background.size=this.size),this._setLayoutDirty()),this._designSize){var o=void 0;o=this._designUseHorizAxis?this._renderingSize.width/this._designSize.width:this._renderingSize.height/this._designSize.height,this.size=this._designSize.clone(),this.actualSize=this._designSize.clone(),this.scale=o}var a=new e.PrepareRender2DContext;++this._globalTransformProcessStep,this.updateCachedStates(!1),this._prepareGroupRender(a),this._updateRenderId=this.scene.getRenderId()}},n.prototype._render=function(){this._initPerfMetrics(),this._renderObservable&&this._renderObservable.hasObservers()&&this._renderObservable.notifyObservers(this,n.RENDEROBSERVABLE_PRE),this._updateCanvasState(!1),this._updateTrackedNodes(),this.isVisible!==!1&&(this._isScreenSpace||this._updateAdaptiveSizeWorldCanvas(),this._updateCanvasState(!1),this._primPointerInfo.canvasPointerPos&&(this._updateIntersectionList(this._primPointerInfo.canvasPointerPos,!1,!1),this._updateOverStatus(!1)),this.engine.setState(!1),this._groupRender(),this._isScreenSpace||this._isFlagSet(e.SmartPropertyPrim.flagWorldCacheChanged)&&(this.worldSpaceCacheChanged(),this._clearFlags(e.SmartPropertyPrim.flagWorldCacheChanged)),this._cachingStrategy===n.CACHESTRATEGY_CANVAS&&this._cachedCanvasGroup&&this._cachedCanvasGroup._renderCachedCanvas(),this._fetchPerfMetrics(),this._updateProfileCanvas(),this._renderObservable&&this._renderObservable.hasObservers()&&this._renderObservable.notifyObservers(this,n.RENDEROBSERVABLE_POST))},n.prototype._allocateGroupCache=function(t,r,i,o,a){void 0===o&&(o=!1),void 0===a&&(a=1);var s,l=(o?"MipMap":"NoMipMap")+"_"+a,u=t._renderableData,c=u._noResizeOnScale,h=null==r;s=c?h?n._unS:t.parent.actualScale:t.actualScale;var d=t.actualSize;d=new e.Size(Math.ceil(d.width*s.x),Math.ceil(d.height*s.y));var p=d.clone();i&&(d.width=Math.max(i.width,d.width),d.height=Math.max(i.height,d.height));for(var f,_=this._groupCacheMaps.getOrAddWithFactory(l,(function(){return new Array})),g=null,y=0,m=_;yv.width||d.height>v.height)&&(v.width=Math.pow(2,Math.ceil(Math.log(d.width)/Math.log(2))),v.height=Math.pow(2,Math.ceil(Math.log(d.height)/Math.log(2))));var C="groupsMapChache"+this._mapCounter++ +"forCanvas"+this.id;f=new e.MapTexture(C,this._scene,v,o?e.Texture.TRILINEAR_SAMPLINGMODE:e.Texture.BILINEAR_SAMPLINGMODE,o),f.hasAlpha=!0,f.anisotropicFilteringLevel=4,_.splice(0,0,f);var P=f.allocateRect(d);g={node:P,texture:f}}if(t!==this||this._isScreenSpace){var P=g.node,O=void 0;if(this._cachingStrategy===n.CACHESTRATEGY_CANVAS?(this._cachedCanvasGroup&&this._cachedCanvasGroup.dispose(),this._cachedCanvasGroup=e.Group2D._createCachedCanvasGroup(this),O=new e.Sprite2D(f,{parent:this._cachedCanvasGroup,id:"__cachedCanvasSprite__",spriteSize:p,spriteLocation:P.pos}),O.zOrder=1,O.origin=e.Vector2.Zero()):(O=new e.Sprite2D(f,{parent:r,id:"__cachedSpriteOfGroup__"+t.id,x:t.actualPosition.x,y:t.actualPosition.y,spriteSize:p,spriteLocation:P.pos,dontInheritParentScale:!0}),O.origin=t.origin.clone(),O.addExternalData("__cachedGroup__",t),O.pointerEventObservable.add((function(e,r){null!==t.pointerEventObservable&&t.pointerEventObservable.notifyObservers(e,r.mask)})),g.sprite=O),O&&c){var D=h?t.actualScale:t.actualScale.divide(t.parent.actualScale);O.scaleX=D.x,O.scaleY=D.y}}return g},n.prototype._registerTrackedNode=function(t){t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)||(this._trackedGroups.push(t),t._setFlags(e.SmartPropertyPrim.flagTrackedGroup))},n.prototype._unregisterTrackedNode=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)){var r=this._trackedGroups.indexOf(t);r!==-1&&this._trackedGroups.splice(r,1),t._clearFlags(e.SmartPropertyPrim.flagTrackedGroup)}},n.GetSolidColorBrush=function(t){return n._solidColorBrushes.getOrAddWithFactory(t.toHexString(),(function(){return new e.SolidColorBrush2D(t.clone(),(!0))}))},n.GetSolidColorBrushFromHex=function(t){return n._solidColorBrushes.getOrAddWithFactory(t,(function(){return new e.SolidColorBrush2D(e.Color4.FromHexString(t),(!0))}))},n.GetGradientColorBrush=function(t,r,i,o,a){return void 0===i&&(i=e.Vector2.Zero()),void 0===o&&(o=0),void 0===a&&(a=1),n._gradientColorBrushes.getOrAddWithFactory(e.GradientColorBrush2D.BuildKey(t,r,i,o,a),(function(){return new e.GradientColorBrush2D(t,r,i,o,a,(!0))}))},n.GetBrushFromString=function(t){t=t.trim();var r=t.split(",");if(1===r.length){var i=null;if(0===t.indexOf("solid:"))i=t.substr(6).trim();else{if(0!==t.indexOf("#"))return null;i=t}return n.GetSolidColorBrushFromHex(i)}0===r[0].indexOf("gradient:")&&(r[0]=r[0].substr(9).trim());try{var o=e.Color4.FromHexString(r[0].trim()),a=e.Color4.FromHexString(r[1].trim()),s=e.Vector2.Zero();if(r.length>2){var l=r[2].trim();if("["!==l.charAt(0)||"]"!==l.charAt(l.length-1))return null;var u=l.indexOf(":"),c=parseFloat(l.substr(1,u)),h=parseFloat(l.substr(u+1,l.length-(u+1)));s=new e.Vector2(c,h)}var d=0;r.length>3&&(d=e.Tools.ToRadians(parseFloat(r[3].trim())));var p=1;return r.length>4&&(p=parseFloat(r[4].trim())),n.GetGradientColorBrush(o,a,s,d,p)}catch(f){return null}},n.CACHESTRATEGY_TOPLEVELGROUPS=1,n.CACHESTRATEGY_ALLGROUPS=2,n.CACHESTRATEGY_CANVAS=3,n.CACHESTRATEGY_DONTCACHE=4,n.RENDEROBSERVABLE_PRE=1,n.RENDEROBSERVABLE_POST=2,n._INSTANCES=[],n._zMinDelta=1/(Math.pow(2,24)-1),n._interInfo=new e.IntersectInfo2D,n._v=e.Vector3.Zero(),n._m=e.Matrix.Identity(),n._mI=e.Matrix.Identity(),n._groupTextureCacheSize=1024,n._solidColorBrushes=new e.StringDictionary,n._gradientColorBrushes=new e.StringDictionary,n=__decorate([e.className("Canvas2D","BABYLON")],n)})(e.Group2D);e.Canvas2D=r;var n=(function(t){function n(n,i,o){var a=this;e.Prim2DBase._isCanvasInit=!0;var s=o;if(s.isScreenSpace=!1,s.size=i.clone(),o.cachingStrategy=null==o.cachingStrategy?r.CACHESTRATEGY_CANVAS:o.cachingStrategy,o.cachingStrategy!==r.CACHESTRATEGY_CANVAS)throw new Error("Right now only the CACHESTRATEGY_CANVAS cache Strategy is supported for WorldSpace Canvas. More will come soon!");t.call(this,n,o),e.Prim2DBase._isCanvasInit=!1,this._renderableData._useMipMap=!0,this._renderableData._anisotropicLevel=8;var l=!o||null==o.customWorldSpaceNode;this._customWorldSpaceNode=!l;var u=o?o.id||null:null,c=this.engine.getCaps().maxRenderTextureSize,h=Math.min(c,1024);if(null==o.maxAdaptiveCanvasSize?this._maxAdaptiveWorldSpaceCanvasSize=h:this._maxAdaptiveWorldSpaceCanvasSize=Math.min(o.maxAdaptiveCanvasSize,c),l){var d=new e.WorldSpaceCanvas2DNode(u,n,this),p=e.VertexData.CreatePlane({width:i.width,height:i.height,sideOrientation:o&&o.sideOrientation||e.Mesh.DEFAULTSIDE}),f=new e.StandardMaterial(u+"_Material",n);this.applyCachedTexture(p,f),p.applyToMesh(d,!0),f.specularColor=new e.Color3(0,0,0),f.disableLighting=!0,f.useAlphaFromDiffuseTexture=!0,d.position=o&&o.worldPosition||e.Vector3.Zero(),d.rotationQuaternion=o&&o.worldRotation||e.Quaternion.Identity(),d.material=f,this._worldSpaceNode=d}else this._worldSpaceNode=o.customWorldSpaceNode,this.applyCachedTexture(null,null);this.propertyChanged.add((function(e,t){var r=a._worldSpaceNode;r&&(r.isVisible=e.newValue)}),e.Prim2DBase.isVisibleProperty.flagId)}return __extends(n,t),n.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&void(!this._customWorldSpaceNode&&this._worldSpaceNode&&(this._worldSpaceNode.dispose(),this._worldSpaceNode=null))},n=__decorate([e.className("WorldSpaceCanvas2D","BABYLON")],n)})(r);e.WorldSpaceCanvas2D=n;var i=(function(t){function r(r,n){e.Prim2DBase._isCanvasInit=!0,t.call(this,r,n)}return __extends(r,t),r=__decorate([e.className("ScreenSpaceCanvas2D","BABYLON")],r)})(r);e.ScreenSpaceCanvas2D=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,r,n){e.call(this,t,r),this._canvas=n}return __extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._canvas&&(this._canvas.dispose(),this._canvas=null)},t})(e.Mesh);e.WorldSpaceCanvas2DNode=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t,r){return function(){o.registerRenderingTemplate(e,t,r)}}var r=(function(){function t(e,t){if(!e)throw Error("At least an execute lambda must be given at Command creation time");this._canExecuteChanged=null,this._lastCanExecuteResult=null,this.execute=e,this.canExecute=t}return t.prototype.canExecute=function(e){var t=!0;return this._canExecute&&(t=this._canExecute(e)),t!==this._lastCanExecuteResult&&(this._canExecuteChanged&&this._canExecuteChanged.hasObservers()&&this._canExecuteChanged.notifyObservers(null),this._lastCanExecuteResult=t),t},t.prototype.execute=function(e){this._execute(e)},Object.defineProperty(t.prototype,"canExecuteChanged",{get:function(){return this._canExecuteChanged||(this._canExecuteChanged=new e.Observable),this._canExecuteChanged},enumerable:!0,configurable:!0}),t})();e.Command=r;var n=(function(t){function r(n){if(t.call(this),!n)throw Error("A settings object must be passed with at least either a parent or owner parameter");var i=e.Tools.getFullClassName(this);this._ownerWindow=null,this._parent=null,this._visualPlaceholder=null,this._visualTemplateRoot=null,this._visualChildrenPlaceholder=null,this._hierarchyDepth=0,this._renderingTemplateName=null!=n.templateName?n.templateName:o.DefaultTemplateName,this._style=null!=n.styleName?o.getStyle(i,n.styleName):null,this._flags=0,this._id=null!=n.id?n.id:null,this._uid=null,this._width=null!=n.width?n.width:null,this._height=null!=n.height?n.height:null,this._minWidth=null!=n.minWidth?n.minWidth:0,this._minHeight=null!=n.minHeight?n.minHeight:0,this._maxWidth=null!=n.maxWidth?n.maxWidth:Number.MAX_VALUE,this._maxHeight=null!=n.maxHeight?n.maxHeight:Number.MAX_VALUE,this._margin=null,this._padding=null,this._marginAlignment=null,this._setFlags(r.flagIsVisible|r.flagIsEnabled),n.marginTop&&this.margin.setTop(n.marginTop),n.marginLeft&&this.margin.setLeft(n.marginLeft),n.marginRight&&this.margin.setRight(n.marginRight),n.marginBottom&&this.margin.setBottom(n.marginBottom),n.margin&&("string"==typeof n.margin?this.margin.fromString(n.margin):this.margin.fromUniformPixels(n.margin)),n.marginHAlignment&&(this.marginAlignment.horizontal=n.marginHAlignment),n.marginVAlignment&&(this.marginAlignment.vertical=n.marginVAlignment),n.marginAlignment&&this.marginAlignment.fromString(n.marginAlignment),n.paddingTop&&this.padding.setTop(n.paddingTop),n.paddingLeft&&this.padding.setLeft(n.paddingLeft),n.paddingRight&&this.padding.setRight(n.paddingRight),n.paddingBottom&&this.padding.setBottom(n.paddingBottom),n.padding&&this.padding.fromString(n.padding),n.paddingHAlignment&&(this.paddingAlignment.horizontal=n.paddingHAlignment),n.paddingVAlignment&&(this.paddingAlignment.vertical=n.paddingVAlignment),n.paddingAlignment&&this.paddingAlignment.fromString(n.paddingAlignment),null!=n.parent&&(this._parent=n.parent,this._hierarchyDepth=this._parent._hierarchyDepth+1)}return __extends(r,t),Object.defineProperty(r,"enabledState",{get:function(){return r._enableState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"disabledState",{get:function(){return r._disabledState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"mouseOverState",{get:function(){return r._mouseOverState},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return!this.isDisposed&&(this._renderingTemplate&&(this._renderingTemplate.detach(),this._renderingTemplate=null),t.prototype.dispose.call(this),this.animations.splice(0),!0)},r.prototype.getAnimatables=function(){return new Array},r.prototype.findById=function(e){if(this._id===e)return this;for(var t=this._getChildren(),r=0,n=t;r0){for(var e=this._UIElementVisualToBuildList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),t=0,r=e;t