import{checkbox_styles_default as e}from"./chunk.QCTB77SK.js";import{defaultValue as t}from"./chunk.GI7VDIWX.js";import{FormControlController as i}from"./chunk.GZKNJ77J.js";import{SlIcon as s}from"./chunk.M4HIRIJ5.js";import{watch as o}from"./chunk.C7FWPEOY.js";import{ShoelaceElement as r}from"./chunk.Z7XDKKOD.js";import{__decorateClass as l}from"./chunk.6M63UXML.js";import{classMap as c}from"../../../../lit/directives/class-map.js";import{html as n}from"../../../../lit/index.js";import{ifDefined as h}from"../../../../lit/directives/if-defined.js";import{live as a}from"../../../../lit/directives/live.js";import{property as d,query as p,state as m}from"../../../../lit/decorators.js";var u=class extends r{constructor(){super(...arguments),this.formControlController=new i(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.hasFocus=!1,this.title="",this.name="",this.size="medium",this.disabled=!1,this.checked=!1,this.indeterminate=!1,this.defaultChecked=!1,this.form="",this.required=!1}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.emit("sl-change")}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleInput(){this.emit("sl-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){return n`
      <label
        part="base"
        class=${c({checkbox:!0,"checkbox--checked":this.checked,"checkbox--disabled":this.disabled,"checkbox--focused":this.hasFocus,"checkbox--indeterminate":this.indeterminate,"checkbox--small":"small"===this.size,"checkbox--medium":"medium"===this.size,"checkbox--large":"large"===this.size})}
      >
        <input
          class="checkbox__input"
          type="checkbox"
          title=${this.title}
          name=${this.name}
          value=${h(this.value)}
          .indeterminate=${a(this.indeterminate)}
          .checked=${a(this.checked)}
          .disabled=${this.disabled}
          .required=${this.required}
          aria-checked=${this.checked?"true":"false"}
          @click=${this.handleClick}
          @input=${this.handleInput}
          @invalid=${this.handleInvalid}
          @blur=${this.handleBlur}
          @focus=${this.handleFocus}
        />

        <span
          part="control${this.checked?" control--checked":""}${this.indeterminate?" control--indeterminate":""}"
          class="checkbox__control"
        >
          ${this.checked?n`
                <sl-icon part="checked-icon" class="checkbox__checked-icon" library="system" name="check"></sl-icon>
              `:""}
          ${!this.checked&&this.indeterminate?n`
                <sl-icon
                  part="indeterminate-icon"
                  class="checkbox__indeterminate-icon"
                  library="system"
                  name="indeterminate"
                ></sl-icon>
              `:""}
        </span>

        <div part="label" class="checkbox__label">
          <slot></slot>
        </div>
      </label>
    `}};u.styles=e,u.dependencies={"sl-icon":s},l([p('input[type="checkbox"]')],u.prototype,"input",2),l([m()],u.prototype,"hasFocus",2),l([d()],u.prototype,"title",2),l([d()],u.prototype,"name",2),l([d()],u.prototype,"value",2),l([d({reflect:!0})],u.prototype,"size",2),l([d({type:Boolean,reflect:!0})],u.prototype,"disabled",2),l([d({type:Boolean,reflect:!0})],u.prototype,"checked",2),l([d({type:Boolean,reflect:!0})],u.prototype,"indeterminate",2),l([t("checked")],u.prototype,"defaultChecked",2),l([d({reflect:!0})],u.prototype,"form",2),l([d({type:Boolean,reflect:!0})],u.prototype,"required",2),l([o("disabled",{waitUntilFirstUpdate:!0})],u.prototype,"handleDisabledChange",1),l([o(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],u.prototype,"handleStateChange",1);export{u as SlCheckbox};