import{__awaiter,__generator}from"tslib";import{r as registerInstance,h,g as getElement,H as Host}from"./index-a0453e17.js";import{l as raf,r as rIC}from"./helpers-008ae2b8.js";import{L as Logger}from"./log-f87572ce.js";import"./browser-216e7b03.js";import"./icons.constant-f579c326.js";var balSpinnerCss="bal-spinner,.bal-spinner{text-align:center;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-line-pack:center;align-content:center}bal-spinner svg,.bal-spinner svg{-webkit-transform:unset !important;transform:unset !important}";var __decorate=undefined&&undefined.__decorate||function(t,e,n,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)if(a=t[o])s=(r<3?a(s):r>3?a(e,n,s):a(e,n))||s;return r>3&&s&&Object.defineProperty(e,n,s),s};var Spinner=function(){function t(t){var e=this;registerInstance(this,t);this.animate=function(){return __awaiter(e,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){switch(e.label){case 0:return[4,this.load()];case 1:e.sent();if(this.currentRaf!==undefined){cancelAnimationFrame(this.currentRaf)}if(this.shouldAnimate()){this.destroy();this.currentRaf=raf((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){if(this.animationFunction){this.animationFunction(this.el,this.getColor())}return[2]}))}))}))}return[2]}}))}))};this.destroy=function(){if(e.animationItem&&e.animationItem.destroy){e.animationItem.destroy()}e.el.innerHTML=""};this.shouldAnimate=function(){if(typeof window==="undefined"){return false}if(e.animationFunction===undefined){return false}return!e.deactivated};this.load=function(){return __awaiter(e,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){return[2,new Promise((function(e,n){if(t.animationFunction){return e()}else{rIC((function(){return __awaiter(t,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){import("./bal-spinner.animation-09630cc2.js").then((function(n){t.animationFunction=n.animate;e()})).catch(n);return[2]}))}))}))}}))]}))}))};this.inverted=false;this.deactivated=false;this.color="blue";this.small=false}t.prototype.createLogger=function(t){this.log=t};t.prototype.deactivatedWatcher=function(t,e){if(t!==e){if(this.deactivated){this.destroy()}else{this.animate()}}};t.prototype.componentDidLoad=function(){this.animate()};t.prototype.disconnectedCallback=function(){if(this.el&&!this.el.isConnected){this.destroy()}};t.prototype.getColor=function(){return this.inverted||this.color==="white"?"#ffffff":"#151f6d"};t.prototype.render=function(){return h(Host,{role:"progressbar","aria-hidden":"true",style:{width:this.small?"32px":"64px"}})};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{deactivated:["deactivatedWatcher"]}},enumerable:false,configurable:true});return t}();__decorate([Logger("bal-spinner")],Spinner.prototype,"createLogger",null);Spinner.style={css:balSpinnerCss};export{Spinner as bal_spinner};