import { __esDecorate, __runInitializers } from "tslib";
import { html, nothing } from 'lit';
import { queryAsync, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { when } from 'lit/directives/when.js';
import CheckedElement from './CheckedElement.js';
import { check, checkIndeterminate } from '../../icons/Icons.js';
import { ripple } from '../../effects/rippleDirective.js';
import '../../ripple/ui-ripple.js';
let CheckboxElement = (() => {
    let _classSuper = CheckedElement;
    let _ripple_decorators;
    let _ripple_initializers = [];
    let _ripple_extraInitializers = [];
    let _showRipple_decorators;
    let _showRipple_initializers = [];
    let _showRipple_extraInitializers = [];
    return class CheckboxElement extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _ripple_decorators = [queryAsync('ui-ripple')];
            _showRipple_decorators = [state()];
            __esDecorate(this, null, _ripple_decorators, { kind: "accessor", name: "ripple", static: false, private: false, access: { has: obj => "ripple" in obj, get: obj => obj.ripple, set: (obj, value) => { obj.ripple = value; } }, metadata: _metadata }, _ripple_initializers, _ripple_extraInitializers);
            __esDecorate(this, null, _showRipple_decorators, { kind: "accessor", name: "showRipple", static: false, private: false, access: { has: obj => "showRipple" in obj, get: obj => obj.showRipple, set: (obj, value) => { obj.showRipple = value; } }, metadata: _metadata }, _showRipple_initializers, _showRipple_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        get _icon() {
            const { indeterminate, checked } = this;
            if (indeterminate) {
                return checkIndeterminate;
            }
            if (checked) {
                return check;
            }
            return nothing;
        }
        #ripple_accessor_storage = __runInitializers(this, _ripple_initializers, void 0);
        get ripple() { return this.#ripple_accessor_storage; }
        set ripple(value) { this.#ripple_accessor_storage = value; }
        #showRipple_accessor_storage = (__runInitializers(this, _ripple_extraInitializers), __runInitializers(this, _showRipple_initializers, false));
        get showRipple() { return this.#showRipple_accessor_storage; }
        set showRipple(value) { this.#showRipple_accessor_storage = value; }
        getRipple = (__runInitializers(this, _showRipple_extraInitializers), () => {
            this.showRipple = true;
            return this.ripple;
        });
        async handleFocus() {
            const _ripple = await this.getRipple();
            _ripple?.beginFocus();
        }
        async handleBlur() {
            const _ripple = await this.getRipple();
            _ripple?.endFocus();
        }
        async handleKeyDown(e) {
            super.handleKeyDown(e);
            if (['Space'].includes(e.code)) {
                const _ripple = await this.getRipple();
                _ripple?.beginPress();
            }
        }
        async handleKeyUp(e) {
            super.handleKeyUp(e);
            if (['Space'].includes(e.code)) {
                const _ripple = await this.getRipple();
                _ripple?.endPress();
            }
        }
        render() {
            const { pressed = false } = this;
            const containerClasses = classMap({
                surface: true,
                pressed,
            });
            return html `
      <div class="${containerClasses}" ${ripple(this.getRipple)}>
        <div class="container"></div>
        <div class="state"></div>
        ${when(this.showRipple, this.renderRipple)}
        <div class="icon">${this._icon}</div>
      </div>
    `;
        }
        renderRipple = () => {
            const { disabled } = this;
            return html `<ui-ripple class="ripple" unbounded ?disabled="${disabled}"></ui-ripple>`;
        };
    };
})();
export default CheckboxElement;
//# sourceMappingURL=CheckboxElement.js.map