import { h, Host } from "@stencil/core";
import { TooltipContentClass, TooltipSize, TooltipColors } from "./constants";
import { toBoolAttr } from "../../helpers/Dom/template";
export class GovTooltipContent {
    constructor() {
        /**
         * Style variation of the tooltip
         */
        this.color = TooltipColors.PRIMARY;
        /**
         * Tooltip’s size.
         */
        this.size = TooltipSize._M;
        /**
         * Tooltip is still visible.
         */
        this.persist = false;
        /**
         * Indicates display of tooltip content
         */
        this.isVisible = false;
        /**
         * Indicates display of tooltip content
         */
        this.parentId = null;
    }
    visibleContent(newValue) {
        clearTimeout(this.timeout);
        if (newValue === false) {
            this.timeout = setTimeout(() => {
                this.host.style.visibility = "hidden";
            }, 250);
        }
        else {
            this.host.style.visibility = "visible";
        }
    }
    hideContent() {
        this.isVisible = false;
        this.persist = false;
        const parentEl = document.getElementById(this.parentId);
        if (parentEl) {
            parentEl.hide().catch();
        }
    }
    render() {
        return (h(Host, { key: 'a826527fe9f7851ad25f700156d987c1b29f3adc', class: TooltipContentClass.root, role: "tooltip", hidden: !this.isVisible, "aria-hidden": !toBoolAttr(this.isVisible), "is-visible": this.isVisible }, h("slot", { key: 'd3891d8a3f3df7ee7f852db8485c7ecc2f61992c' }), this.persist ? (h("gov-button", { "on-gov-click": this.hideContent.bind(this), color: this.color, size: this.size, type: "base" }, h("gov-icon", { slot: "icon-start", name: "x-lg", type: "components" }))) : null));
    }
    static get is() { return "gov-tooltip-content"; }
    static get properties() {
        return {
            "color": {
                "type": "string",
                "attribute": "color",
                "mutable": false,
                "complexType": {
                    "original": "TooltipColorType",
                    "resolved": "\"neutral\" | \"primary\"",
                    "references": {
                        "TooltipColorType": {
                            "location": "import",
                            "path": "./constants",
                            "id": "../../../packages/core/src/components/gov-tooltip/constants.tsx::TooltipColorType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Style variation of the tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "TooltipColors.PRIMARY"
            },
            "size": {
                "type": "string",
                "attribute": "size",
                "mutable": false,
                "complexType": {
                    "original": "TooltipSizeType",
                    "resolved": "\"l\" | \"m\" | \"s\"",
                    "references": {
                        "TooltipSizeType": {
                            "location": "import",
                            "path": "./constants",
                            "id": "../../../packages/core/src/components/gov-tooltip/constants.tsx::TooltipSizeType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Tooltip\u2019s size."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "TooltipSize._M"
            },
            "persist": {
                "type": "boolean",
                "attribute": "persist",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Tooltip is still visible."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "isVisible": {
                "type": "boolean",
                "attribute": "is-visible",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indicates display of tooltip content"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "parentId": {
                "type": "string",
                "attribute": "parent-id",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indicates display of tooltip content"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "null"
            }
        };
    }
    static get elementRef() { return "host"; }
    static get watchers() {
        return [{
                "propName": "isVisible",
                "methodName": "visibleContent"
            }];
    }
}
//# sourceMappingURL=gov-tooltip-content.js.map
