import{__decorate as t,__classPrivateFieldGet as e,__classPrivateFieldSet as s}from"../../_virtual/_tslib.js";import'./../../external/@lit/reactive-element/reactive-element.js';import{html as i}from'./../../external/lit-html/lit-html.js';import{LitElement as n}from'./../../external/lit-element/lit-element.js';import{customElement as o}from'./../../external/@lit/reactive-element/decorators/custom-element.js';import{property as l}from'./../../external/@lit/reactive-element/decorators/property.js';import{state as r}from'./../../external/@lit/reactive-element/decorators/state.js';import{query as a}from'./../../external/@lit/reactive-element/decorators/query.js';import{queryAssignedElements as h}from'./../../external/@lit/reactive-element/decorators/query-assigned-elements.js';import{queryAssignedNodes as d}from'./../../external/@lit/reactive-element/decorators/query-assigned-nodes.js';import{ifDefined as p}from'./../../external/lit-html/directives/if-defined.js';import{classMap as c}from'./../../external/lit-html/directives/class-map.js';import{debounce as m}from"../../common/helpers/events.js";import{BUTTON_TYPES as u,BUTTON_KINDS as f,BUTTON_SIZES as y,BUTTON_ICON_POSITION as g}from"./defs.js";import v from"./button.scss.js";var k,_,b,E,M,w,$,O,S,W,C,j,P,R,A,I;let q=class extends n{constructor(){super(...arguments),k.set(this,this.attachInternals()),_.set(this,""),b.set(this,u.BUTTON),E.set(this,f.PRIMARY_APP),M.set(this,""),w.set(this,y.MEDIUM),$.set(this,g.CENTER),O.set(this,!1),S.set(this,!1),W.set(this,!1),C.set(this,""),j.set(this,""),P.set(this,void 0),R.set(this,void 0),A.set(this,void 0),I.set(this,void 0)}get internals(){return e(this,k,"f")}set internals(t){s(this,k,t,"f")}get description(){return e(this,_,"f")}set description(t){s(this,_,t,"f")}get type(){return e(this,b,"f")}set type(t){s(this,b,t,"f")}get kind(){return e(this,E,"f")}set kind(t){s(this,E,t,"f")}get href(){return e(this,M,"f")}set href(t){s(this,M,t,"f")}get size(){return e(this,w,"f")}set size(t){s(this,w,t,"f")}get iconPosition(){return e(this,$,"f")}set iconPosition(t){s(this,$,t,"f")}get iconOnly(){return e(this,O,"f")}set iconOnly(t){s(this,O,t,"f")}get disabled(){return e(this,S,"f")}set disabled(t){s(this,S,t,"f")}get destructive(){return e(this,W,"f")}set destructive(t){s(this,W,t,"f")}get value(){return e(this,C,"f")}set value(t){s(this,C,t,"f")}get name(){return e(this,j,"f")}set name(t){s(this,j,t,"f")}get formmethod(){return e(this,P,"f")}set formmethod(t){s(this,P,t,"f")}get _slottedEls(){return e(this,R,"f")}set _slottedEls(t){s(this,R,t,"f")}get _iconEls(){return e(this,A,"f")}set _iconEls(t){s(this,A,t,"f")}get _btnEl(){return e(this,I,"f")}set _btnEl(t){s(this,I,t,"f")}render(){var t,e;const s={[f.PRIMARY_APP]:"primary-app",[f.PRIMARY_WEB]:"primary-web",[f.SECONDARY]:"secondary",[f.TERTIARY]:"tertiary"}[this.kind],n={button:!0,[`kd-btn--${s}${this.destructive?"-destructive":""}`]:!0,[`kd-btn--${s}`]:!this.destructive,"kd-btn--large":this.size===y.LARGE,"kd-btn--small":this.size===y.SMALL,"kd-btn--medium":this.size===y.MEDIUM,[`kd-btn--icon-${this.iconPosition}`]:!!this.iconPosition&&!this.iconOnly,"kd-btn--icon-center":(null===(t=this._iconEls)||void 0===t?void 0:t.length)&&this.iconOnly,"icon-only":(null===(e=this._iconEls)||void 0===e?void 0:e.length)&&this.iconOnly};return i`
      ${this.href&&""!==this.href?i`
            <a
              class=${c(n)}
              href=${this.href}
              ?disabled=${this.disabled}
              aria-label=${p(this.description)}
              title=${p(this.description)}
              @click=${t=>this.handleClick(t)}
            >
              <span>
                <slot @slotchange=${()=>this._handleSlotChange()}></slot>
                <slot
                  name="icon"
                  @slotchange=${()=>this._handleSlotChange()}
                ></slot>
              </span>
            </a>
          `:i`
            <button
              class=${c(n)}
              type=${this.type}
              ?disabled=${this.disabled}
              aria-label=${p(this.description)}
              title=${p(this.description)}
              name=${p(this.name)}
              value=${p(this.value)}
              formmethod=${p(this.formmethod)}
              @click=${t=>this.handleClick(t)}
            >
              <span>
                <slot @slotchange=${()=>this._handleSlotChange()}></slot>
                <slot
                  name="icon"
                  @slotchange=${()=>this._handleSlotChange()}
                ></slot>
              </span>
            </button>
          `}
    `}handleClick(t){this.internals.form&&("submit"===this.type?this.internals.form.requestSubmit():"reset"===this.type&&this.internals.form.reset());const e=new CustomEvent("on-click",{detail:{origEvent:t}});this.dispatchEvent(e)}_testIconOnly(){var t;if(!(null===(t=this._iconEls)||void 0===t?void 0:t.length))return!1;return!this._slottedEls.filter((t=>""!==t.textContent.trim())).filter((t=>!t.tagName||t.offsetParent)).length}_handleSlotChange(){this.iconOnly=this._testIconOnly(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",m((()=>{this.iconOnly=this._testIconOnly()})))}disconnectedCallback(){window.removeEventListener("resize",m((()=>{this.iconOnly=this._testIconOnly()}))),super.disconnectedCallback()}};k=new WeakMap,_=new WeakMap,b=new WeakMap,E=new WeakMap,M=new WeakMap,w=new WeakMap,$=new WeakMap,O=new WeakMap,S=new WeakMap,W=new WeakMap,C=new WeakMap,j=new WeakMap,P=new WeakMap,R=new WeakMap,A=new WeakMap,I=new WeakMap,q.styles=[v],q.shadowRootOptions={...n.shadowRootOptions,delegatesFocus:!0},q.formAssociated=!0,t([r()],q.prototype,"internals",null),t([l({type:String})],q.prototype,"description",null),t([l({type:String})],q.prototype,"type",null),t([l({type:String})],q.prototype,"kind",null),t([l({type:String})],q.prototype,"href",null),t([l({type:String})],q.prototype,"size",null),t([l({type:String})],q.prototype,"iconPosition",null),t([r()],q.prototype,"iconOnly",null),t([l({type:Boolean,reflect:!0})],q.prototype,"disabled",null),t([l({type:Boolean,reflect:!0})],q.prototype,"destructive",null),t([l({type:String})],q.prototype,"value",null),t([l({type:String})],q.prototype,"name",null),t([l({type:String})],q.prototype,"formmethod",null),t([d()],q.prototype,"_slottedEls",null),t([h({slot:"icon"})],q.prototype,"_iconEls",null),t([a(".button")],q.prototype,"_btnEl",null),q=t([o("kd-button")],q);export{q as Button};
//# sourceMappingURL=button.js.map
