import*as e from"lit/decorators.js";var t,s,i={3773(e,t,s){s.d(t,{A:()=>i});var i,r=s(2900),o=s(7704),n=s(9609),a=s(4084),l=s(2927),d=s(8899),h=s(3517),p=s(2577),m=s(1156),c=s(2297),u=function(e,t,s,i){var r,o=arguments.length,n=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,s,n):r(t,s))||n);return o>3&&n&&Object.defineProperty(t,s,n),n};!function(e){let t=class extends((0,o.yC)(l.LitElement)){constructor(){super(...arguments),this._disabled=!1,this._now=0,this.min=0,this.max=100,this.hideValue=!1,this.text=0,this.label="slider",this.step=0,this.dragging=!1}get now(){return this._now}set now(e){const t=this._now;e<this.min||e>this.max?console.warn("Please select correct value"):(this._now=Math.round(e),this.requestUpdate("now",t))}get disabled(){return this._disabled}set disabled(e){const t=this._disabled;this._disabled=e,this.setAttribute("aria-disabled",`${e}`),this.tabIndex=e?-1:0,this.requestUpdate("disabled",t)}get pointerPosition(){const e=this.max-this.min;return(this.now-this.min)/e*100}get isRtl(){return"rtl"===getComputedStyle(this).direction}calculateHandlePosition(e){const{width:t,left:s}=this.getBoundingClientRect(),{clientX:i}=e;let r=(i-s)/t;return this.isRtl&&(r=1-r),this.min+(this.max-this.min)*r}moveSliderTo(e){this.disabled||(e>this.max?this.now=this.max:e<this.min?this.now=this.min:this.now=e)}trackMouseEvent(){if(!this.currentMouseEvent||!this.dragging)return;const e=this.calculateHandlePosition(this.currentMouseEvent),t=this.now;this.moveSliderTo(e),this.notifyChanging(t,this.now),requestAnimationFrame(()=>{this.trackMouseEvent()})}ticksTemplate(){const{min:e,max:t,step:s}=this,i=Math.round((t-e)/s),r=new Array(i+1).fill(0,0,i+1).map((t,i)=>e+i*s).filter(s=>s>=e&&s<=t);return l.html`
        <div class="md-slider__hashlabel">${(0,p.repeat)(r,e=>l.html` <div class="tick">${e}</div> `)}</div>
      `}displayValueTemplate(){return l.html` <span class="md-slider__value"> ${this.now} </span> `}notifyChanges(){this.dispatchEvent(new CustomEvent("slider-change",{bubbles:!0,composed:!0,detail:{value:this.now}}))}notifyChanging(e,t){e!==t&&this.dispatchEvent(new CustomEvent("slider-changing",{bubbles:!0,composed:!0,detail:{oldValue:e,newValue:t}}))}handleMouseDown(e){if(e.preventDefault(),this.disabled)return;const t=e=>{this.currentMouseEvent=e},s=e=>{this.focus(),this.currentMouseEvent=e,document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),requestAnimationFrame(()=>{this.dragging=!1,this.notifyChanges()})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s),this.focus(),this.dragging=!0,this.currentMouseEvent=e,requestAnimationFrame(()=>{this.trackMouseEvent()})}handleKeyDown(e){const{code:t}=e,s=this.now;switch(t){case r.Uz.ArrowLeft:this.moveSliderTo(this.now+(this.isRtl?1:-1));break;case r.Uz.ArrowRight:this.moveSliderTo(this.now+(this.isRtl?-1:1));break;case r.Uz.ArrowDown:this.moveSliderTo(this.now-1);break;case r.Uz.ArrowUp:this.moveSliderTo(this.now+1);break;case r.Uz.Home:this.moveSliderTo(this.min);break;case r.Uz.End:this.moveSliderTo(this.max)}this.notifyChanging(s,this.now);const i=()=>{document.removeEventListener("keyup",i),this.notifyChanges()};document.addEventListener("keyup",i)}get sliderPointerStyleMap(){return{"inset-inline-start":`${this.pointerPosition}%`}}get sliderSelectionStyleMap(){return{"inset-inline-end":`calc(100% - ${this.pointerPosition}%)`}}static get styles(){return[a.A,c.A]}firstUpdated(e){super.firstUpdated(e),this.setAttribute("tabindex",this.disabled?"-1":"0")}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("mousedown",this.handleMouseDown)}render(){return l.html`
        <div class="md-slider">
          <span class="md-slider__bar"></span>
          <span class="md-slider__selection" style=${(0,m.styleMap)(this.sliderSelectionStyleMap)}></span>
          <span
            class="md-slider__pointer"
            role="slider"
            part="slider"
            aria-valuemin=${this.min}
            aria-valuemax=${this.max}
            aria-valuenow=${this.now}
            aria-label=${(0,h.ifDefined)(this.label)}
            style=${(0,m.styleMap)(this.sliderPointerStyleMap)}
          ></span>
          ${this.step?this.ticksTemplate():l.nothing} ${this.hideValue?l.nothing:this.displayValueTemplate()}
        </div>
      `}};u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"min",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"max",void 0),u([(0,d.property)({type:Boolean,attribute:"hide-value"})],t.prototype,"hideValue",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"now",null),u([(0,d.property)({type:Number})],t.prototype,"text",void 0),u([(0,d.property)({type:String})],t.prototype,"label",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"step",void 0),u([(0,d.property)({type:Boolean,reflect:!0})],t.prototype,"disabled",null),u([(0,d.state)()],t.prototype,"dragging",void 0),t=u([(0,n.w)("md-slider")],t),e.ELEMENT=t}(i||(i={}))},8899(t,s,i){var r,o;t.exports=(r={property:()=>e.property,state:()=>e.state},o={},i.d(o,r),o)}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var s=r[e]={exports:{}};return i[e](s,s.exports,o),s.exports}o.m=i,t=[],o.O=(e,s,i,r)=>{if(!s){var n=1/0;for(h=0;h<t.length;h++){for(var[s,i,r]=t[h],a=!0,l=0;l<s.length;l++)(!1&r||n>=r)&&Object.keys(o.O).every(e=>o.O[e](s[l]))?s.splice(l--,1):(a=!1,r<n&&(n=r));if(a){t.splice(h--,1);var d=i();void 0!==d&&(e=d)}}return e}r=r||0;for(var h=t.length;h>0&&t[h-1][2]>r;h--)t[h]=t[h-1];t[h]=[s,i,r]},o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{o as __webpack_require__};s={1280:0,1459:0,1756:0,4137:0,4613:0,6518:0,6994:0,8899:0,9375:0},o.C=e=>{var t,i,{__webpack_esm_ids__:r,__webpack_esm_modules__:n,__webpack_esm_runtime__:a}=e,l=0;for(t in n)o.o(n,t)&&(o.m[t]=n[t]);for(a&&a(o);l<r.length;l++)i=r[l],o.o(s,i)&&s[i]&&s[i][0](),s[r[l]]=0;o.O()},o.O.j=e=>0===s[e];import*as n from"../9609.js";o.C(n);import*as a from"../4084.js";o.C(a);import*as l from"../3517.js";o.C(l);import*as d from"../1156.js";o.C(d);import*as h from"../2364.js";o.C(h);import*as p from"../5308.js";o.C(p);import*as m from"../9938.js";o.C(m);import*as c from"../4781.js";o.C(c);import*as u from"../5201.js";o.C(u);import*as v from"../5584.js";o.C(v);import*as y from"../8227.js";o.C(y);import*as f from"../2900.js";o.C(f);import*as b from"../7704.js";o.C(b);import*as w from"../2577.js";o.C(w);import*as g from"../2297.js";o.C(g);var _=o.O(void 0,[9609,4084,3517,1156,2364,5308,9938,4781,5201,5584,8227,2900,7704,2577,2297],()=>o(3773));const C=(_=o.O(_)).A;export{C as Slider};