import { h } from '@stencil/core';
import dndod from './dndod';
export class Dialog {
    constructor() {
        this.index = 0;
        this.confirmLabel = 'Ok';
        this.cancelLabel = 'Cancel';
        this.continueLabel = 'Yes';
        this.allowClose = true;
    }
    // todo: add cancel + continue handlers
    getOptions() {
        return {
            confirmLabel: this.confirmLabel,
            cancelLabel: this.cancelLabel,
            continueLabel: this.continueLabel,
            allowClose: this.allowClose,
            disableCloseBtn: !this.allowClose,
            enableHTML: true,
            hostElement: this.host
        };
    }
    async popup(options = {}) {
        options = Object.assign(options, this.getOptions());
        dndod.popup(options);
    }
    async notice(msg = "", options = {}) {
        options = Object.assign(options, this.getOptions());
        dndod.notice(msg, options);
    }
    async alert(msg = "", options = {}) {
        options = Object.assign(options, this.getOptions());
        dndod.alert(msg, options);
    }
    ;
    async confirm(msg = "", calllback = this.dialogConfirmHandler, options = {}) {
        options = Object.assign(options, this.getOptions());
        dndod.confirm(msg, calllback, options);
    }
    async setConfirmHandler(callBackHandler) {
        this.dialogConfirmHandler = callBackHandler;
    }
    dialogConfirmHandler() {
        if (this && this.dialogConfirmCallback) {
            this.dialogConfirmCallback();
        }
    }
    // componentDidLoad() {
    //     this.postrender()
    // }
    //
    // componentDidUpdate() {
    //     this.postrender()
    // }
    //
    // postrender() {
    //     Array.from(document.querySelectorAll('.dndod-custom-btn-wrapper')).forEach((wrapper) => {
    //         let buttons = Array.from(wrapper.querySelectorAll('button'))
    //
    //         // Now do something with my button
    //     });
    //     // document.getElementsByClassName('dndod-custom-btn-wrapper');
    //
    // }
    render() {
        return (h("div", null));
    }
    static get is() { return "ema-dialog"; }
    static get originalStyleUrls() { return {
        "$": ["dialog.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["dialog.css"]
    }; }
    static get properties() { return {
        "confirmLabel": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "confirm-label",
            "reflect": false,
            "defaultValue": "'Ok'"
        },
        "cancelLabel": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "cancel-label",
            "reflect": false,
            "defaultValue": "'Cancel'"
        },
        "continueLabel": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "continue-label",
            "reflect": false,
            "defaultValue": "'Yes'"
        },
        "allowClose": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "allow-close",
            "reflect": false,
            "defaultValue": "true"
        }
    }; }
    static get states() { return {
        "index": {}
    }; }
    static get methods() { return {
        "popup": {
            "complexType": {
                "signature": "(options?: {}) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "notice": {
            "complexType": {
                "signature": "(msg?: string, options?: {}) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "alert": {
            "complexType": {
                "signature": "(msg?: string, options?: {}) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "confirm": {
            "complexType": {
                "signature": "(msg?: string, calllback?: () => void, options?: {}) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "setConfirmHandler": {
            "complexType": {
                "signature": "(callBackHandler: any) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        }
    }; }
    static get elementRef() { return "host"; }
}
