/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../core/maybe","../core/promiseUtils","../core/reactiveUtils","../core/accessorSupport/decorators/aliasOf","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/subclass","./Widget","./Spinner/SpinnerViewModel","./support/widgetUtils","./support/jsxFactory"],(function(i,e,t,o,s,n,r,a,c,l,p,h,d,u,v){"use strict";const _={base:"esri-spinner",spinnerStart:"esri-spinner--start",spinnerFinish:"esri-spinner--finish"};let f=function(e){function n(i,t){var o;return(o=e.call(this,i,t)||this)._animationDelay=500,o._animationPromise=null,o.location=null,o.view=null,o.viewModel=new d,o.visible=!1,o}i._inheritsLoose(n,e);var r=n.prototype;return r.initialize=function(){this.own([s.watch((()=>this.visible),(i=>this._visibleChange(i)))])},r.destroy=function(){this._animationPromise=null},r.show=function(i){const{location:e,promise:t}=i;e&&(this.viewModel.location=e),this.visible=!0;const o=()=>this.hide();t&&t.catch((()=>{})).then(o)},r.hide=function(){this.visible=!1},r.render=function(){const{visible:i}=this,{screenLocation:e}=this.viewModel,t=!!e,o=i&&t,s=!i&&t,n={[_.spinnerStart]:o,[_.spinnerFinish]:s},r=this._getPositionStyles();return v.tsx("div",{class:this.classes(_.base,n),styles:r})},r._visibleChange=function(i){if(i)return void(this.viewModel.screenLocationEnabled=!0);const e=o.after(this._animationDelay);this._animationPromise=e,e.catch((()=>{})).then((()=>{this._animationPromise===e&&(this.viewModel.screenLocationEnabled=!1,this._animationPromise=null)}))},r._getPositionStyles=function(){const{screenLocation:i,view:e}=this.viewModel;if(t.isNone(e)||t.isNone(i))return{};const{padding:o}=e;return{left:i.x-o.left+"px",top:i.y-o.top+"px"}},n}(h);e.__decorate([n.aliasOf("viewModel.location")],f.prototype,"location",void 0),e.__decorate([n.aliasOf("viewModel.view")],f.prototype,"view",void 0),e.__decorate([l.property({type:d})],f.prototype,"viewModel",void 0),e.__decorate([n.aliasOf("viewModel.visible")],f.prototype,"visible",void 0),f=e.__decorate([p.subclass("esri.widgets.Spinner")],f);return f}));
