import { r as registerInstance, h, H as Host, g as getElement } from './index-CjTHbolG.js';
import { A as AirDatepicker, l as localeEn } from './en-bsV5YfOZ.js';
import { V as VerdocsToast } from './Toast-D97GxsI-.js';
import './_commonjsHelpers-BFTU3MAI.js';

const verdocsDateInputCss = () => `verdocs-text-input{font-family:"Inter", "Barlow", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 0 10px 0;display:block}verdocs-text-input .input-element{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid #707ae5;border-radius:4px;background:#ffffff;color:#000;width:100%;font-size:16px;height:34px;padding:0 9px;outline:none}verdocs-text-input .input-element:disabled{cursor:not-allowed;background:#aeb4bf;border:1px solid #33364b}verdocs-text-input .input-element::-webkit-input-placeholder{color:#aaaaaa;opacity:1}verdocs-text-input .input-element::-moz-placeholder{color:#aaaaaa;opacity:1}verdocs-text-input .input-element:-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-text-input .input-element::-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-text-input .input-element::placeholder{color:#aaaaaa;opacity:1}verdocs-text-input .input-element:focus{outline:1px solid #7d88ff}verdocs-text-input .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0}verdocs-text-input .required{color:red;margin-left:2px;display:inline-block}verdocs-text-input [data-lastpass-icon-root]{display:none !important}verdocs-text-input .input-container{position:relative}verdocs-text-input .clear{top:7px;right:5px;width:18px;height:18px;fill:#cccccc;position:absolute}verdocs-text-input .clear:hover{fill:#720101;cursor:pointer}verdocs-text-input .copy{top:7px;right:5px;width:18px;height:18px;fill:#cccccc;position:absolute}verdocs-text-input .copy:hover{fill:#654dcb;cursor:pointer}verdocs-text-input .toggle-pw{top:5px;right:7px;width:18px;height:18px;stroke:#cccccc;position:absolute}verdocs-text-input .toggle-pw:hover{fill:#654dcb;cursor:pointer}verdocs-text-input.clearable .input-element,verdocs-text-input.copyable .input-element{padding-right:32px}`;

const VerdocsDateInput = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.picker = null;
        /**
         * The initial value for the input field.
         */
        this.value = '';
        /**
         * The label for the field.
         */
        this.label = '';
        /**
         * The placeholder for the field.
         */
        this.placeholder = '';
        /**
         * If supplied, a help icon will be displayed to provide the user more information.
         */
        this.helpText = '';
        /**
         * Should the field be disabled?
         */
        this.disabled = false;
        /**
         * Should the field be required?
         */
        this.required = false;
        this.showingPw = false;
        this.focused = false;
        this.containerId = `verdocs-date-input-${Math.random().toString(36).substring(2, 11)}`;
    }
    async focusField() {
        var _a;
        // Our input field is fake, so we fake the flash too
        this.focused = true;
        (_a = this.picker) === null || _a === void 0 ? void 0 : _a.show();
        setTimeout(() => {
            this.focused = false;
        }, 500);
    }
    componentDidLoad() {
        this.picker = new AirDatepicker(`#${this.containerId}`, {
            locale: localeEn,
            isMobile: true,
            autoClose: true,
            onShow: () => (this.focused = true),
            onHide: () => (this.focused = false),
            onSelect: ({ date, formattedDate }) => {
                const event = new CustomEvent('input', { detail: { date, formattedDate } });
                this.hostEl.dispatchEvent(event);
            },
        });
    }
    copyToClipboard() {
        this.inputEl.select();
        navigator.clipboard
            .writeText(this.value)
            .then(() => VerdocsToast('Copied!'))
            .catch(e => console.log('Error copying to clipboard', e));
    }
    render() {
        return (h(Host, { key: 'a71872f25c3fbfdb8837f546340edd2324f141f9', class: `input-field` }, h("label", { key: '68b0b363d48c045f6a6124467c81e3c8af7f6321' }, this.label && (h("div", { key: '6cfe44246b5776315772da522b27482c362df563', class: "input-label" }, this.label + ':', this.required && h("span", { key: '9c02382715b89aa7c8f1c4efd6e9e1e54cec6692', class: "required" }, "*"))), h("div", { key: '56e31da5bc7c6206a9f1045ad6317f6b95ca2206', class: "input-container" }, h("input", { key: 'bdca818f5c8df445d9e63c6597cc75d0634096f1', type: "text", value: this.value, required: this.required, class: "input-element", "data-lpignore": "true", id: this.containerId, disabled: this.disabled, placeholder: this.placeholder,
            // onBlur={(e: any) => this.blur?.emit(e.target.value)}
            ref: el => (this.inputEl = el), onInput: (e) => (this.value = e.target.value) })), this.helpText && h("verdocs-help-icon", { key: '712354ce917bb818033fa6cd95dc2bf50daf678f', text: this.helpText }))));
    }
    get hostEl() { return getElement(this); }
};
VerdocsDateInput.style = verdocsDateInputCss();

export { VerdocsDateInput as verdocs_date_input };
//# sourceMappingURL=verdocs-date-input.entry.js.map

//# sourceMappingURL=verdocs-date-input.entry.js.map