import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-CUAGH_8P.js';
import { verifySigner } from '@verdocs/js-sdk';
import { D as DefaultEndpoint } from './p-C_Xku1v2.js';
import { V as VerdocsToast } from './p-CyvDgtoV.js';
import { d as defineCustomElement$4 } from './p-CwklHveG.js';
import { d as defineCustomElement$3 } from './p-CO3KQG1e.js';
import { d as defineCustomElement$2 } from './p-BCKfiFng.js';
import { d as defineCustomElement$1 } from './p-764zY_TM.js';

const verdocsPasscodeDialogCss = "verdocs-passcode-dialog{font-family:\"Inter\", \"Barlow\", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-passcode-dialog div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-passcode-dialog .heading{width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}verdocs-passcode-dialog .heading .title{font-size:20px;font-weight:500}verdocs-passcode-dialog .step{color:#666;margin-left:6px}verdocs-passcode-dialog .help-box{padding:0;color:black;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;margin-bottom:20px}verdocs-passcode-dialog .help-details{gap:5px;display:-ms-flexbox;display:flex;margin-left:0;font-size:14px;-ms-flex-direction:column;flex-direction:column}verdocs-passcode-dialog .help-title{font-weight:600;margin-bottom:4px}verdocs-passcode-dialog .help-text{font-weight:400}verdocs-passcode-dialog .buttons{width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-passcode-dialog .buttons verdocs-button{margin-left:16px}";

const VerdocsPasscodeDialog = /*@__PURE__*/ proxyCustomElement(class VerdocsPasscodeDialog extends H {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.exit = createEvent(this, "exit");
        this.next = createEvent(this, "next");
        /**
         * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.
         */
        this.endpoint = DefaultEndpoint;
        this.response = '';
    }
    handleCancel() {
        this.exit.emit();
    }
    handleSubmit() {
        verifySigner(this.endpoint, { auth_method: 'passcode', code: this.response })
            .then(response => {
            console.log('Verification completed', response);
            this.next.emit({ response });
        })
            .catch(e => {
            VerdocsToast('Invalid passcode. Please try again.');
            console.log('Invalid code', e);
        });
        this.response = '';
    }
    render() {
        return (h(Host, { key: 'f611b89b6a936352f80d2032a571cd7e86daa2e9' }, h("verdocs-dialog", { key: '0997b0a07b87e3ca6f25979a461f0ba186fa0cf4', persistent: true, onExit: () => this.handleCancel() }, h("div", { key: 'd32ff440d13ed705a8311804fee910d714d08705', slot: "heading", class: "heading" }, h("div", { key: 'c5124f039fecd6bd695d369061da325bc10a97e6', class: "title" }, "Passcode Required")), h("div", { key: '2635315f3c53a957ae8aee32ce47dc04e7547a4a', slot: "content", class: "content" }, h("div", { key: '7ebdd819c026e2c968019996f2965d76058c019e', class: "help-box" }, h("div", { key: '7d6811fd11a47bdd8dfc03f628eb21f41fd697b6', class: "help-details" }, h("div", { key: 'aecfd4feaf6b0b669476b40b53b159a6a280dbd9', class: "help-text" }, "This document is protected by a passcode. Please enter it below to proceed. If you do not have one, please contact the sender."))), h("verdocs-text-input", { key: 'e53aad4fd9b05297383730c13d2db086444b8f84', id: "verdocs-passcode-input", value: this.response, onClick: e => e.stopPropagation(), placeholder: "Enter passcode...", onInput: (e) => (this.response = e.target.value) })), h("div", { key: 'f747484402b61c0b83efc5fdbde75b85afc2ada1', slot: "footer", class: "buttons footer" }, h("verdocs-button", { key: '16015a1a9be9fed6fc78485ea0a91ce19cdbe68d', label: "Cancel", variant: "outline", onClick: () => this.handleCancel() }), h("verdocs-button", { key: '2077f16df851706e1c80c4118b303f0ffdcc17dc', label: 'Submit', onClick: () => this.handleSubmit(), disabled: !this.response })))));
    }
    static get style() { return verdocsPasscodeDialogCss; }
}, [256, "verdocs-passcode-dialog", {
        "endpoint": [1040],
        "response": [32]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["verdocs-passcode-dialog", "verdocs-button", "verdocs-dialog", "verdocs-help-icon", "verdocs-text-input"];
    components.forEach(tagName => { switch (tagName) {
        case "verdocs-passcode-dialog":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, VerdocsPasscodeDialog);
            }
            break;
        case "verdocs-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "verdocs-dialog":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "verdocs-help-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "verdocs-text-input":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { VerdocsPasscodeDialog as V, defineCustomElement as d };
//# sourceMappingURL=p-D9jA0wbq.js.map

//# sourceMappingURL=p-D9jA0wbq.js.map