'use strict';

var index = require('./index-Be9PlTB7.js');
var en = require('./en-DyXpAt1T.js');
var Toast = require('./Toast-CFBM1R4z.js');
require('./_commonjsHelpers-BJu3ubxk.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) {
        index.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 en.AirDatepicker(`#${this.containerId}`, {
            locale: en.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(() => Toast.VerdocsToast('Copied!'))
            .catch(e => console.log('Error copying to clipboard', e));
    }
    render() {
        return (index.h(index.Host, { key: 'cc88f2d255889798b44d1b4a378df4825dad2864', class: `input-field` }, index.h("label", { key: '54efdeecf84a03dbb649ecc2eec048bc54cc76a1' }, this.label && (index.h("div", { key: '9d276e51d188ed7b80b987b3e91ab5afc040bfb5', class: "input-label" }, this.label + ':', this.required && index.h("span", { key: '66f64bfe62f167af288bf7ae6df0c97d872425ce', class: "required" }, "*"))), index.h("div", { key: '57ec4d6abb6738e8c6aaf71c80c5657ca6597fcc', class: "input-container" }, index.h("input", { key: '9e1a8b80b378a273a244ff17ef0ede94688f27bf', 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 && index.h("verdocs-help-icon", { key: '7b7468b7db8c613c31c52fa21cfcd824b84afbd6', text: this.helpText }))));
    }
    get hostEl() { return index.getElement(this); }
};
VerdocsDateInput.style = verdocsDateInputCss;

exports.verdocs_date_input = VerdocsDateInput;
//# sourceMappingURL=verdocs-date-input.entry.cjs.js.map

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