text: import{wrap as e}from"../../../@polymer/polymer/lib/utils/wrap.js";import*as t from"../../../@polymer/polymer/lib/utils/async.js";window.MaterialProgressBehaviorImpl={properties:{barHeight:{type:Number,value:22,observer:"_refresh"},animated:{type:Boolean,value:!1,reflectToAttribute:!0},legendLabel:{type:String,value:"",observer:"_refresh"},bars:{type:Array,value:()=>[],notify:!0,readOnly:!0},sum:{type:Number,value:0,notify:!0,readOnly:!0,reflectToAttribute:!0},_legendItems:{type:Array,value:()=>[],readOnly:!0},_legendNeeded:{type:Boolean,value:!1,compute:"_computeLegendNeeded(_legendItems)",readOnly:!0}},listeners:{"dom-mutation":"refresh"},refresh(){if(this._attached){this._computeSumAndBars();var e,t,a,s,i=!1,r=600/(this.bars.length-1);if(this.splice("_legendItems",0,this._legendItems.length),this.legendLabel&&this.push("_legendItems",{label:this.legendLabel}),this.bars)for(e=this.bars.length-1,t=this._barWithValueCount-1;e>=0;e--)a=this.bars[e],s=this._getBarMeta(a),this.toggleClass("visible",s.value>0,a),this.toggleClass("last",s.value>0&&!i,a),a.style.width=this.bars.length>0?this._getWidthForBar(s.value,this.sum,this._maxBarValue,this.barHeight):"0px",a.style.zIndex=this.bars.length-e,s.value>0&&(i=!0,this._initialized||this._playFirstAnimation(a,t,r),t--),s.legend&&(s.value>0||s.legendAlwaysVisible)&&this.splice("_legendItems",1,0,{label:s.legend,color:window.getComputedStyle(a).backgroundColor});this._oldBarHeight&&this._oldBarHeight===this.barHeight||(this.customStyle["--material-progress-bar-height"]=this.barHeight+"px",this.updateStyles(),this._oldBarHeight=this.barHeight),this._initialized=i}},ready(){super.ready(),this._mutationOptions={childList:!0,subtree:!0,attributes:!0,characterData:!1,attributeFilter:["data-value","data-legend","data-legend-always-visible"]},this._mutationFilter=function(e){return this._mutationIsChildList(e,this.shadowRoot.querySelector("#barsContainer"))||this._mutationIsChildAttributes(e,this.shadowRoot.querySelector("#barsContainer"))}},connectedCallback(){super.connectedCallback(),this._attached=!0,this._refresh()},_refresh(){this.debounce("refresh",this.refresh,10)},getDistributedNodes:t=>"slot"===t.localName?e(t).assignedNodes({flatten:!0}):[],_computeSumAndBars(){var e=0,t=0,a=0,s=0,i=[],r=this.getDistributedNodes(this.shadowRoot.querySelector("#content"));return r&&r.forEach((function(r){r.classList&&r.classList.contains("bar")&&r.hasAttribute("data-value")&&(i.push(r),t=this._getBarMeta(r).value,e+=t,a+=t>0?1:0,s=Math.max(s,t))}),this),this._setBars(i),this._setSum(e),this._maxBarValue=s,this._barWithValueCount=a,e},_getBarMeta(e){var t,a={value:0,legend:void 0};return e&&e.getAttribute&&(t=Number(e.getAttribute("data-value")),a.value=isNaN(t)?0:Math.max(0,t),a.legend=e.getAttribute("data-legend"),a.legendAlwaysVisible=e.hasAttribute("data-legend-always-visible")),a},_getWidthForBar:(e,t,a,s)=>"0px",_playFirstAnimation(e,t,a){this.toggleClass("entry",!0,e)},_computeLegendNeeded:e=>e&&e.length>0},window.MaterialProgressBehavior=[window.MaterialProgressBehaviorImpl];