import { Host, h } from "@stencil/core";
import { Locale } from "../../../common/locale";
import { mapCommentsToActionListModel } from "./helpers/mapCommentsToActionListModel";
const CSS_BUNDLES = [
    // Use only the bundles that are needed for this component.
    "resets/box-sizing",
    "components/button",
    "components/list-box",
    "utils/layout",
    "utils/spacing"
];
export class GxIdeTeamDevSelectRecentComment {
    constructor() {
        this.selectedComment = null;
        this.commentSelectionChangedHandler = (event) => {
            if (event.detail.length > 0) {
                this.selectedComment = event.detail[0].item.id;
            }
        };
        this.confirmCallbackHandle = async () => {
            await this.confirmCallback(this.selectedComment);
        };
        this.cancelCallbackHandle = async () => {
            await this.cancelCallback();
        };
        this.comments = undefined;
        this.commentsActionList = [];
        this.confirmCallback = undefined;
        this.cancelCallback = undefined;
    }
    async componentWillLoad() {
        this._componentLocale = await Locale.getComponentStrings(this.el);
        this.commentsActionList = mapCommentsToActionListModel(this.comments);
    }
    render() {
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("section", { class: "section" }, h("div", { class: "main" }, h("ch-action-list-render", { class: "list-box recent-comments-list", selection: "single", model: this.commentsActionList, onSelectedItemsChange: this.commentSelectionChangedHandler })), h("footer", { class: "footer dialog-footer-with-border spacing-body-block-end spacing-body-inline" }, h("div", { class: "buttons-spacer" }, h("button", { class: "button-secondary", id: "button-cancel", onClick: this.cancelCallbackHandle, part: "button-cancel" }, this._componentLocale.cancelButton), h("button", { class: "button-primary", id: "button-confirm", onClick: this.confirmCallbackHandle, part: "button-confirm" }, this._componentLocale.confirmButton))))));
    }
    static get is() { return "gx-ide-team-dev-select-recent-comment"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["select-recent-comment.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["select-recent-comment.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/team-dev-select-recent-comment"]; }
    static get properties() {
        return {
            "comments": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Recent comments list"
                }
            },
            "confirmCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "confirmCallback",
                    "resolved": "(comment: string) => Promise<void>",
                    "references": {
                        "confirmCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/team-dev/select-recent-comment/select-recent-comment.tsx",
                            "id": "src/components/team-dev/select-recent-comment/select-recent-comment.tsx::confirmCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user confirms selection"
                }
            },
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "cancelCallback",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "cancelCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/team-dev/select-recent-comment/select-recent-comment.tsx",
                            "id": "src/components/team-dev/select-recent-comment/select-recent-comment.tsx::cancelCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when user cancel selection"
                }
            }
        };
    }
    static get states() {
        return {
            "commentsActionList": {}
        };
    }
    static get events() {
        return [{
                "method": "componentDidRenderFirstTime",
                "name": "componentDidRenderFirstTime",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "description",
                            "text": "Gets fired when the component has rendered for the first time."
                        }],
                    "text": ""
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=select-recent-comment.js.map
