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

const verdocsDateInputCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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: '467efdebf394aca2734bce2755e10b84638fe5a4', class: `input-field` }, h("label", { key: '8dc6200b52f0d97f7360c3856056eb5d85c6d299' }, this.label && (h("div", { key: '006018a6ec21a7780b78686feecf09f50357a871', class: "input-label" }, this.label + ':', this.required && h("span", { key: '44882599b166ed99a3f3abb3276f03cf7c3702cc', class: "required" }, "*"))), h("div", { key: '390990d7c2e9132949e7af69fcd464f95b275b21', class: "input-container" }, h("input", { key: '4324380a6c31b299f0f1ef0081043d8fe404e448', 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: 'ddd928e400e4fe83d0ffb2e6fc34eddff488fad1', 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