var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _GxIdeCommentsViewer_componentLocale, _GxIdeCommentsViewer_renderCommentItem, _GxIdeCommentsViewer_renderFooter, _GxIdeCommentsViewer_closeHandler;
import { Host, h } from "@stencil/core";
import { formatDate } from "../../../common/helpers";
import { Locale } from "../../../common/locale";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/form--full",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "chameleon/scrollbar"
];
export class GxIdeCommentsViewer {
    constructor() {
        _GxIdeCommentsViewer_componentLocale.set(this, void 0);
        _GxIdeCommentsViewer_renderCommentItem.set(this, (commentData) => {
            return (h("div", { class: "comment-item" }, h("header", null, h("span", { class: "body-semi-bold-s comment-title" }, formatDate(new Date(commentData.date)), " - ", commentData.user)), h("p", { class: "body-regular-m" }, commentData.comment)));
        });
        _GxIdeCommentsViewer_renderFooter.set(this, () => {
            return (h("footer", { class: "control-footer-with-border spacing-body" }, h("div", { class: "buttons-spacer" }, h("button", { class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeCommentsViewer_closeHandler, "f") }, __classPrivateFieldGet(this, _GxIdeCommentsViewer_componentLocale, "f").buttons.close))));
        });
        _GxIdeCommentsViewer_closeHandler.set(this, async () => {
            await this.closeCallback();
        });
        this.commentsData = [];
        this.closeCallback = undefined;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeCommentsViewer_componentLocale, await Locale.getComponentStrings(this.el), "f");
    }
    render() {
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("div", { class: "spacing-body comments-container scrollable" }, h("ul", { class: "comments-list" }, this.commentsData.map((comment, idx) => (h("li", { class: "row" }, __classPrivateFieldGet(this, _GxIdeCommentsViewer_renderCommentItem, "f").call(this, comment), idx < this.commentsData.length - 1 && h("hr", { class: "divider" })))))), __classPrivateFieldGet(this, _GxIdeCommentsViewer_renderFooter, "f").call(this)));
    }
    static get is() { return "gx-ide-comments-viewer"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["comments-viewer.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["comments-viewer.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/comments-viewer"]; }
    static get properties() {
        return {
            "commentsData": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "CommentData[]",
                    "resolved": "CommentData[]",
                    "references": {
                        "CommentData": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/_helpers/comments-viewer/comments-viewer.tsx",
                            "id": "src/components/_helpers/comments-viewer/comments-viewer.tsx::CommentData"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Comments data to display"
                },
                "defaultValue": "[]"
            },
            "closeCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback to be executed when the user closes the viewer"
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
_GxIdeCommentsViewer_componentLocale = new WeakMap(), _GxIdeCommentsViewer_renderCommentItem = new WeakMap(), _GxIdeCommentsViewer_renderFooter = new WeakMap(), _GxIdeCommentsViewer_closeHandler = new WeakMap();
//# sourceMappingURL=comments-viewer.js.map
