import*as ComponentHelpers from"../../components/helpers/helpers.js";import*as LitHtml from"../../lit-html/lit-html.js";import*as Input from"../input/input.js";import settingCheckboxStyles from"./settingCheckbox.css.js";import{SettingDeprecationWarning}from"./SettingDeprecationWarning.js";export class SettingCheckbox extends HTMLElement{static litTagName=LitHtml.literal`setting-checkbox`;#t=this.attachShadow({mode:"open"});#e;#i=!1;#s;connectedCallback(){this.#t.adoptedStyleSheets=[Input.checkboxStyles,settingCheckboxStyles]}set data(t){this.#s&&this.#e&&this.#e.removeChangeListener(this.#s.listener),this.#e=t.setting,this.#i=Boolean(t.disabled),this.#s=this.#e.addChangeListener((()=>{this.#n()})),this.#n()}#o(){if(this.#e?.deprecation)return LitHtml.html`<${SettingDeprecationWarning.litTagName} .data=${this.#e.deprecation}></${SettingDeprecationWarning.litTagName}>`}#n(){if(!this.#e)throw new Error('No "Setting" object provided for rendering');const t=this.#o();LitHtml.render(LitHtml.html`
      <p>
        <label>
          <input type="checkbox" .checked=${this.#e.get()} ?disabled=${this.#i||this.#e.disabled()} @change=${this.#r} aria-label=${this.#e.title()} /> ${this.#e.title()}${t}
        </label>
      </p>`,this.#t,{host:this})}#r(t){this.#e?.set(t.target.checked)}}ComponentHelpers.CustomElements.defineComponent("setting-checkbox",SettingCheckbox);