import { r as registerInstance, c as createEvent, h, H as Host } from './index-b1696fed.js';
import { m as messageId, P as PdsLabel, a as assignDescription } from './pds-label-62469596.js';
import { b as danger } from './index-56752d25.js';

const baseCss = ":where(*:not(slot),*:not(slot)::before,*:not(slot)::after){-webkit-box-sizing:border-box;box-sizing:border-box}:where(*:not(slot)){margin:0}:where(img,picture,video,canvas,svg){display:block;max-width:100%}:where(input,button,textarea,select){font:inherit}:where(p,h1,h2,h3,h4,h5,h6){overflow-wrap:break-word}:where(a:not([href]):not([class])){color:currentColor;text-decoration:none}:where(a:not([href]):not([class]):hover){color:currentColor;text-decoration:none}:where(ul[role=list],ol[role=list]){list-style:none}:where(table){border-collapse:collapse;border-spacing:0}:where(*:not(slot)){font:var(--pine-typography-body-md-default);letter-spacing:var(--pine-letter-spacing-body-md)}:where(h1,h2,h3,h4,h5,h6){font-family:var(--pine-font-family-heading);color:var(--pine-color-grey-950)}:where(h1){font:var(--pine-typography-heading-h1);letter-spacing:var(--pine-letter-spacing-heading-h1)}:where(h2){font:var(--pine-typography-heading-h2);letter-spacing:var(--pine-letter-spacing-heading-h2)}:where(h3){font:var(--pine-typography-heading-h3);letter-spacing:var(--pine-letter-spacing-heading-h3)}:where(h4){font:var(--pine-typography-heading-h4);letter-spacing:var(--pine-letter-spacing-heading-h4)}:where(h5){font:var(--pine-typography-heading-h5);letter-spacing:var(--pine-letter-spacing-heading-h5)}:where(h6){font:var(--pine-typography-heading-h6);letter-spacing:var(--pine-letter-spacing-heading-h6)}:where(div,label,p,span){color:var(--pine-color-text-default)}:where(code,kbd,pre,samp){font-family:monospace}:where([role=button]){cursor:pointer}:where(:focus){outline:0}:where(:focus-visible){outline:var(--pine-border-width-thick) solid var(--pine-color-purple-500)}:where([hidden]){display:none !important}";
const PdsCheckboxStyle0 = baseCss;

const pdsCheckboxCss = ":host{--border-default:var(--pine-border-interactive-default);--border-hover:var(--pine-border-interactive-hover);--border-radius:var(--pine-border-radius-050);--box-shadow-focus:0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-purple-300);--box-shadow-focus-invalid:0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-red-200);--color-background:var(--pine-color-white);--color-background-disabled:var(--pine-color-grey-100);--color-background-hover:var(--pine-color-grey-100);--color-background-checked:var(--pine-color-purple-500);--color-background-checked-hover:var(--pine-color-purple-600);--color-border-disabled:var(--pine-color-grey-300);--color-border-icon:var(--pine-color-white);--color-disabled:var(--pine-color-grey-300);--color-invalid:var(--pine-color-red-500);--color-invalid-hover:var(--pine-color-red-600);--color-text-disabled:var(--pine-color-grey-500);--color-text-message:var(--pine-color-grey-700);--sizing-input:var(--pine-font-size-116);-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap}:host(.is-invalid) input{border-color:var(--color-invalid)}:host(.is-invalid) input:checked{background:var(--color-invalid)}:host(.is-invalid) input:checked:hover{background:var(--color-invalid-hover);border-color:var(--color-invalid-hover)}:host(.is-invalid) input:focus-visible{-webkit-box-shadow:var(--box-shadow-focus-invalid);box-shadow:var(--box-shadow-focus-invalid);outline:none}:host(.is-invalid) label,:host(.is-invalid) .pds-checkbox__message--error{color:var(--color-invalid)}:host(.is-indeterminate) input{background:var(--color-background-checked);border-color:var(--color-background-checked)}:host(.is-indeterminate) input:hover{background:var(--color-background-checked-hover);border-color:var(--color-background-checked-hover)}:host(.is-indeterminate) input::after{border:1px solid var(--color-border-icon);border-bottom:0;border-left:0;border-top:0;content:\"\";display:block;height:7px;left:50%;position:absolute;top:50%;-webkit-transform:rotate(90deg) translate3d(-103%, 32%, 0);transform:rotate(90deg) translate3d(-103%, 32%, 0);width:4px}input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--color-background);border:var(--border-default);border-radius:var(--border-radius);height:var(--sizing-input);margin:0;position:relative;width:var(--sizing-input)}input:hover{background:var(--color-background-hover);border:var(--border-hover)}input:checked{background:var(--color-background-checked);border-color:var(--color-background-checked)}input:checked:hover{background:var(--color-background-checked-hover);border-color:var(--color-background-checked-hover)}input:checked::after{border:1px solid var(--color-border-icon);border-left:0;border-top:0;content:\"\";display:block;height:7px;left:50%;position:absolute;top:50%;-webkit-transform:rotate(43deg) translate3d(-110%, -30%, 0);transform:rotate(43deg) translate3d(-110%, -30%, 0);width:4px}input:disabled{background:var(--color-background-disabled);border-color:var(--color-disabled);cursor:not-allowed}input:disabled:checked{background:var(--color-disabled);border-color:var(--color-disabled)}input:disabled:checked::after{border-color:var(--color-border-disabled)}input:disabled+label{color:var(--color-text-disabled);cursor:not-allowed}input:disabled~.pds-checkbox__message{color:var(--color-text-disabled)}input:focus-visible{-webkit-box-shadow:var(--box-shadow-focus);box-shadow:var(--box-shadow-focus);outline:none}label{font-weight:var(--pine-font-weight-body-medium);-webkit-margin-start:10px;margin-inline-start:10px}.visually-hidden{border:0;clip:rect(0 0 0 0);-webkit-clip-path:polygon(0 0, 0 0, 0 0);clip-path:polygon(0 0, 0 0, 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.pds-checkbox__message{color:var(--color-text-message);-webkit-margin-before:6px;margin-block-start:6px;-webkit-margin-start:26px;margin-inline-start:26px;width:100%}.pds-checkbox__message--error{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;font-size:var(--pine-font-size-085);gap:var(--pine-spacing-050)}";
const PdsCheckboxStyle1 = pdsCheckboxCss;

const PdsCheckbox = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pdsCheckboxChange = createEvent(this, "pdsCheckboxChange", 7);
        this.pdsCheckboxInput = createEvent(this, "pdsCheckboxInput", 7);
        this.handleCheckboxChange = (e) => {
            if (this.disabled) {
                return;
            }
            const target = e.target;
            this.checked = target.checked;
            this.pdsCheckboxChange.emit({
                checked: target.checked,
                value: this.value
            });
        };
        this.handleInput = () => {
            this.pdsCheckboxInput.emit({
                checked: this.checked,
                value: this.value
            });
        };
        this.checked = false;
        this.componentId = undefined;
        this.disabled = undefined;
        this.errorMessage = undefined;
        this.helperMessage = undefined;
        this.indeterminate = undefined;
        this.invalid = undefined;
        this.label = undefined;
        this.labelHidden = undefined;
        this.name = undefined;
        this.required = undefined;
        this.value = undefined;
    }
    updateIndeterminate() {
        this.indeterminate = undefined;
    }
    classNames() {
        const classNames = [];
        if (this.invalid) {
            classNames.push('is-invalid');
        }
        if (this.indeterminate) {
            classNames.push('is-indeterminate');
        }
        if (this.disabled) {
            classNames.push('is-disabled');
        }
        return classNames.join('  ');
    }
    render() {
        return (h(Host, { key: '20ec5fff75ed7c8e1fa203377da84533a24b359f', class: this.classNames() }, h("input", { key: '640f30df7addcfb3ec9fc850a32283b5d7e9d096', type: "checkbox", "aria-describedby": assignDescription(this.componentId, this.invalid, this.helperMessage), "aria-invalid": this.invalid ? "true" : undefined, id: this.componentId, indeterminate: this.indeterminate, name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onChange: this.handleCheckboxChange, onInput: this.handleInput }), h(PdsLabel, { key: '8aa6d71f86bba517fd5b697b7a4c91a2002f29ba', htmlFor: this.componentId, text: this.label, classNames: this.labelHidden ? 'visually-hidden' : '' }), this.helperMessage &&
            h("div", { key: '3b683e51e76c802e77022e6544b05305e8fbaa2f', class: 'pds-checkbox__message', id: messageId(this.componentId, 'helper') }, this.helperMessage), this.errorMessage &&
            h("div", { key: '8da70a6935cf8c419d2f1ffa36ae21a843823b11', class: `pds-checkbox__message pds-checkbox__message--error`, id: messageId(this.componentId, 'error'), "aria-live": "assertive" }, h("pds-icon", { key: '9fa9b8662cce3319ccff5bc8bce90b364f310d7b', icon: danger, size: "small" }), this.errorMessage)));
    }
    static get watchers() { return {
        "checked": ["updateIndeterminate"]
    }; }
};
PdsCheckbox.style = PdsCheckboxStyle0 + PdsCheckboxStyle1;

export { PdsCheckbox as pds_checkbox };

//# sourceMappingURL=pds-checkbox.entry.js.map