"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./query-assigned-elements-8EurZY45.js"),r=require("./property-DYTC_2-m.js"),t=require("./tslib.es6-CHeFCc6E.js"),b=require("./mwc-icon-button.css-BzElD_JI.js"),h=require("./ripple-handlers-C7an-EE1.js"),f=require("./aria-property-Dl2ZKBbP.js"),m=require("./state-C3HoXfoa.js"),v=require("./event-options-DD382x85.js"),_=require("./query-Dv2F3m_t.js"),y=require("./class-map-DTzB8z-1.js"),u=require("./if-defined-CZCqOAYs.js");/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */class o extends i.s{constructor(){super(...arguments),this.disabled=!1,this.onIcon="",this.offIcon="",this.on=!1,this.shouldRenderRipple=!1,this.rippleHandlers=new h.RippleHandlers(()=>(this.shouldRenderRipple=!0,this.ripple))}handleClick(){this.on=!this.on,this.dispatchEvent(new CustomEvent("icon-button-toggle-change",{detail:{isOn:this.on},bubbles:!0}))}click(){this.mdcRoot.focus(),this.mdcRoot.click()}focus(){this.rippleHandlers.startFocus(),this.mdcRoot.focus()}blur(){this.rippleHandlers.endFocus(),this.mdcRoot.blur()}renderRipple(){return this.shouldRenderRipple?i.x`
            <mwc-ripple
                .disabled="${this.disabled}"
                unbounded>
            </mwc-ripple>`:""}render(){const e={"mdc-icon-button--on":this.on},n=this.ariaLabelOn!==void 0&&this.ariaLabelOff!==void 0,l=n?void 0:this.on,s=n?this.on?this.ariaLabelOn:this.ariaLabelOff:this.ariaLabel;return i.x`<button
          class="mdc-icon-button mdc-icon-button--display-flex ${y.o(e)}"
          aria-pressed="${u.l(l)}"
          aria-label="${u.l(s)}"
          @click="${this.handleClick}"
          ?disabled="${this.disabled}"
          @focus="${this.handleRippleFocus}"
          @blur="${this.handleRippleBlur}"
          @mousedown="${this.handleRippleMouseDown}"
          @mouseenter="${this.handleRippleMouseEnter}"
          @mouseleave="${this.handleRippleMouseLeave}"
          @touchstart="${this.handleRippleTouchStart}"
          @touchend="${this.handleRippleDeactivate}"
          @touchcancel="${this.handleRippleDeactivate}"
        >${this.renderRipple()}
        <span class="mdc-icon-button__icon"
          ><slot name="offIcon"
            ><i class="material-icons">${this.offIcon}</i
          ></slot
        ></span>
        <span class="mdc-icon-button__icon mdc-icon-button__icon--on"
          ><slot name="onIcon"
            ><i class="material-icons">${this.onIcon}</i
          ></slot
        ></span>
      </button>`}handleRippleMouseDown(e){const n=()=>{window.removeEventListener("mouseup",n),this.handleRippleDeactivate()};window.addEventListener("mouseup",n),this.rippleHandlers.startPress(e)}handleRippleTouchStart(e){this.rippleHandlers.startPress(e)}handleRippleDeactivate(){this.rippleHandlers.endPress()}handleRippleMouseEnter(){this.rippleHandlers.startHover()}handleRippleMouseLeave(){this.rippleHandlers.endHover()}handleRippleFocus(){this.rippleHandlers.startFocus()}handleRippleBlur(){this.rippleHandlers.endFocus()}}t.__decorate([_.i(".mdc-icon-button")],o.prototype,"mdcRoot",void 0);t.__decorate([f.ariaProperty,r.n({type:String,attribute:"aria-label"})],o.prototype,"ariaLabel",void 0);t.__decorate([r.n({type:Boolean,reflect:!0})],o.prototype,"disabled",void 0);t.__decorate([r.n({type:String})],o.prototype,"onIcon",void 0);t.__decorate([r.n({type:String})],o.prototype,"offIcon",void 0);t.__decorate([r.n({type:String})],o.prototype,"ariaLabelOn",void 0);t.__decorate([r.n({type:String})],o.prototype,"ariaLabelOff",void 0);t.__decorate([r.n({type:Boolean,reflect:!0})],o.prototype,"on",void 0);t.__decorate([h.e("mwc-ripple")],o.prototype,"ripple",void 0);t.__decorate([m.t()],o.prototype,"shouldRenderRipple",void 0);t.__decorate([v.e({passive:!0})],o.prototype,"handleRippleMouseDown",null);t.__decorate([v.e({passive:!0})],o.prototype,"handleRippleTouchStart",null);/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */let c=class extends o{};c.styles=[b.styles];c=t.__decorate([i.e("mwc-icon-button-toggle")],c);const R=':host{--mdc-icon-button-size: calc(48px + var(--cv-density-mode, 0) * var(--cv-density-interval, 4px));border-radius:50%;color:var(--cv-theme-on-surface-variant)}:host([disabled]){background-color:transparent}:host([on]){--mdc-ripple-color: var(--cv-theme-on-surface);background-color:var(--cv-theme-secondary-container);color:var(--cv-theme-on-secondary-container)}:host([on]) .material-icons{font-variation-settings:"FILL" 1}';var I=Object.defineProperty,O=Object.getOwnPropertyDescriptor,g=(a,e,n,l)=>{for(var s=l>1?void 0:l?O(e,n):e,p=a.length-1,d;p>=0;p--)(d=a[p])&&(s=(l?d(e,n,s):d(s))||s);return l&&s&&I(e,n,s),s};exports.CovalentIconButtonToggle=class extends c{constructor(){super(...arguments),this.toggledOn=!1}update(e){e.has("toggledOn")&&this.toggledOn!==this.on&&(this.on=this.toggledOn),e.has("on")&&this.toggledOn!==this.on&&(this.toggledOn=this.on),super.update(e)}renderRipple(){return this.shouldRenderRipple?i.x` <mwc-ripple
          .disabled="${this.disabled}"
          .activated="${this.toggledOn}"
          unbounded
        >
        </mwc-ripple>`:""}};exports.CovalentIconButtonToggle.styles=[...c.styles,i.i`
      ${i.r(R)}
    `];g([r.n({type:Boolean,reflect:!0})],exports.CovalentIconButtonToggle.prototype,"toggledOn",2);exports.CovalentIconButtonToggle=g([i.e("cv-icon-button-toggle")],exports.CovalentIconButtonToggle);const $=exports.CovalentIconButtonToggle;exports.default=$;
