import { r as registerInstance, g as getElement, h, d as Host } from './index-c0a4d8bd.js';

const pnFilterCheckboxCss = "pn-button-dropdown .pn-button-dropdown>pn-button>.pn-button{min-height:initial}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}@media screen and (max-width: 767px){.sr-only-mobile{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}}:host{display:inline-block;user-select:none}:host input{opacity:0;position:absolute}:host input[type=checkbox]+label.pn-checkbox{width:1.5em;min-width:1.5em;height:1.5em;min-height:1.5em;background:#fff;display:flex;justify-content:center;align-items:center;position:relative;border:0.1rem solid #969087;cursor:pointer;border-radius:0.4rem;cursor:pointer;transition-duration:220ms;transition-timing-function:cubic-bezier(0.79, 0.14, 0.15, 0.86);transition-property:border, background, box-shadow}:host input[type=checkbox]+label.pn-checkbox svg{width:80%;fill:none}:host input[type=checkbox]+label.pn-checkbox svg polyline{stroke:#fff;transform-origin:0 0;stroke-linecap:round;stroke-dasharray:23;stroke-dashoffset:23;transition-delay:none;transition:stroke-dashoffset 180ms cubic-bezier(0.79, 0.14, 0.15, 0.86)}:host input[type=checkbox]:hover+label.pn-checkbox{border:0.1rem solid #005d92;background:#e0f8ff}:host input[type=checkbox]:checked+label.pn-checkbox,:host input[type=checkbox]:indeterminate+label.pn-checkbox{background:#005d92;border:0.1rem solid #005d92}:host input[type=checkbox]:checked+label.pn-checkbox svg polyline,:host input[type=checkbox]:indeterminate+label.pn-checkbox svg polyline{transition-delay:220ms}:host input[type=checkbox]:checked+label.pn-checkbox svg polyline.checkmark-path{stroke-dashoffset:0}:host input[type=checkbox]:indeterminate+label.pn-checkbox svg polyline.indeterminate-path{stroke-dashoffset:0}:host input[type=checkbox]:focus+label.pn-checkbox,:host input[type=checkbox]:active+label.pn-checkbox{box-shadow:0 0 0 0.1rem white, 0 0 0 0.3rem #005d92}:host input[type=checkbox]:disabled+label.pn-checkbox{background-color:#d3cecb;border:0.1rem solid #969087;cursor:not-allowed}:host input[type=checkbox]:disabled+label.pn-checkbox svg polyline{stroke:#969087}:host input[type=checkbox]:disabled:checked+label.pn-checkbox{border:0.1rem solid transparent}:host input[type=checkbox]:disabled:active+label.pn-checkbox{box-shadow:none}";
const PnFilterCheckboxStyle0 = pnFilterCheckboxCss;

const PnFilterCheckbox = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.value = undefined;
        this.name = undefined;
        this.checkboxid = undefined;
        this.disabled = false;
        this.checked = false;
        this.indeterminate = false;
    }
    get hostElement() { return getElement(this); }
    handlechange() {
        this.indeterminate = false;
    }
    componentDidLoad() {
        this.checkAndSetIndeterminateState();
        this.bindEvents();
    }
    componentDidUpdate() {
        this.checkAndSetIndeterminateState();
    }
    bindEvents() {
        const labels = document.querySelectorAll('label[for="' + this.checkboxid + '"]');
        labels.forEach(label => {
            label.addEventListener('click', () => {
                this.hostElement.shadowRoot.querySelector('label').click();
            });
        });
        const checkboxInput = this.hostElement.shadowRoot.querySelector('input');
        checkboxInput.addEventListener('change', this.onCheckboxChange.bind(this, checkboxInput));
    }
    onCheckboxChange(checkboxInput) {
        let outsideInput = this.hostElement.querySelector('input.hidden-' + this.checkboxid);
        if (outsideInput) {
            outsideInput.value = checkboxInput.checked ? this.value : '';
            outsideInput.dispatchEvent(new CustomEvent('change', { detail: outsideInput }));
        }
    }
    checkAndSetIndeterminateState() {
        let checkbox = this.hostElement.querySelector(`#${this.checkboxid}`);
        if (checkbox) {
            checkbox.indeterminate = this.indeterminate;
        }
    }
    renderInputOutsideShadowRoot() {
        let input = this.hostElement.querySelector('input.hidden-' + this.checkboxid);
        if (!input) {
            input = this.hostElement.ownerDocument.createElement('input');
            input.type = 'hidden';
            input.classList.add('hidden-' + this.checkboxid);
            this.hostElement.appendChild(input);
        }
        input.name = this.name ?? this.checkboxid;
    }
    render() {
        this.renderInputOutsideShadowRoot();
        return (h(Host, { key: '6afb96d0039c6b469a1e0fcb1984130e5d07f6b2', checked: this.checked, id: this.checkboxid }, h("input", { key: '13cb1d151426ba8798e8dbc1ab3ba070df9f5f9c', type: "checkbox", id: this.checkboxid, value: this.value, name: this.name || this.checkboxid, disabled: this.disabled, checked: this.checked }), h("label", { key: '704d25d4ef31eceb09ec5961a4da7118b431587b', htmlFor: this.checkboxid, class: "pn-checkbox" }, h("svg", { key: '730506f1a3b0f2220017eb51093fba5b352e5809', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, h("polyline", { key: '138a8f0bcfc1f4b6ddb938a653ca4821e125a296', class: "checkmark-path", points: "4,12 9,17 20,6", "stroke-width": "3" }), h("polyline", { key: '08f0433c4f7a21040d4905b81c05f27e0ebd0542', class: "indeterminate-path", points: "4,12 20,12", "stroke-width": "3" })))));
    }
};
PnFilterCheckbox.style = PnFilterCheckboxStyle0;

export { PnFilterCheckbox as pn_filter_checkbox };

//# sourceMappingURL=pn-filter-checkbox.entry.js.map