import{__awaiter,__generator}from"tslib";import{L as Logger,H as registerInstance,f as defaultConfig,Q as raf,K as rOnLoad,M as h,N as Host,O as getElement}from"./index-CklISCW5.js";import{_ as __decorate,a as __metadata}from"./tslib.es6-dfXERft2.js";import{B as BEM}from"./bem-ByiN-QjD.js";import{L as ListenToConfig}from"./config.decorator-vXcNSbMQ.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;width:4rem}bal-spinner svg,.bal-spinner svg{-webkit-transform:unset !important;transform:unset !important}.bal-spinner--small{width:2rem}.bal-spinner--circle{margin:auto;border-width:.25rem;border-style:solid;border-color:var(--bal-color-grey);border-radius:50%;border-top-color:var(--bal-color-primary);width:1.5rem;height:1.5rem}.bal-spinner--circle.bal-spinner--small{width:1.125rem;height:1.125rem;border-width:.2rem}.bal-spinner--circle.bal-spinner--animated{-webkit-animation:spinner 1.6s linear infinite;animation:spinner 1.6s linear infinite}.bal-spinner--circle.bal-spinner--color-white{border-color:var(--bal-color-white);border-top-color:var(--bal-color-primary)}@-webkit-keyframes spinner{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes spinner{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}";var Spinner=function(){function e(e){var t=this;registerInstance(this,e);this.animated=defaultConfig.animated;this.inverted=false;this.deactivated=false;this.color="blue";this.small=false;this.variation="logo";this.animate=function(){return __awaiter(t,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){switch(t.label){case 0:if(!this.animated){this.destroy();return[2]}return[4,this.load()];case 1:t.sent();if(this.currentRaf!==undefined){cancelAnimationFrame(this.currentRaf)}if(this.shouldAnimate()){this.destroy();this.currentRaf=raf((function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){if(this.animationFunction){this.animationFunction(this.el,this.getColor())}return[2]}))}))}))}return[2]}}))}))};this.destroy=function(){if(t.animationItem&&t.animationItem.destroy){t.animationItem.destroy()}t.el.innerHTML=""};this.shouldAnimate=function(){if(t.variation!=="logo"){return false}if(typeof window==="undefined"){return false}if(t.animationFunction===undefined){return false}return!t.deactivated};this.load=function(){return __awaiter(t,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){return[2,new Promise((function(t,r){if(e.animationFunction){return t()}else{rOnLoad((function(){return __awaiter(e,void 0,void 0,(function(){var e=this;return __generator(this,(function(i){import("./bal-spinner.animation-Bv2Ow6xu.js").then((function(r){e.animationFunction=r.animate;t()})).catch(r);return[2]}))}))}))}}))]}))}))}}e.prototype.createLogger=function(e){this.log=e};e.prototype.deactivatedWatcher=function(e,t){if(e!==t){if(this.deactivated){this.destroy()}else{this.animate()}}};e.prototype.variationWatcher=function(e,t){if(e!==t){if(this.variation==="circle"){this.destroy()}else{this.animate()}}};e.prototype.componentDidLoad=function(){if(this.variation==="logo"){this.animate()}else{this.destroy()}};e.prototype.disconnectedCallback=function(){if(this.el&&!this.el.isConnected){this.destroy()}};e.prototype.configChanged=function(e){this.animated=e.animated;if(e.animated===false){this.destroy()}};e.prototype.getColor=function(){return this.inverted||this.color==="white"?"#ffffff":"#151f6d"};e.prototype.render=function(){var e=BEM.block("spinner");return h(Host,{key:"61330569cf09ee4964ef809792f354d060419b62",class:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e.class()),e.modifier("circle").class(this.variation==="circle")),e.modifier("small").class(this.small)),e.modifier("animated").class(this.animated)),e.modifier("color-".concat(this.color)).class(this.variation==="circle")),role:"progressbar","aria-hidden":"true"})};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{deactivated:["deactivatedWatcher"],variation:["variationWatcher"]}},enumerable:false,configurable:true});return e}();__decorate([Logger("bal-spinner"),__metadata("design:type",Function),__metadata("design:paramtypes",[Function]),__metadata("design:returntype",void 0)],Spinner.prototype,"createLogger",null);__decorate([ListenToConfig(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],Spinner.prototype,"configChanged",null);Spinner.style=balSpinnerCss;export{Spinner as bal_spinner};