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 _GxIdeLaunchpadApi_instances, _GxIdeLaunchpadApi_handleApiClick, _GxIdeLaunchpadApi_renderSwaggerUI;
import { Host, h } from "@stencil/core";
import SwaggerUI from "swagger-ui-dist/swagger-ui-es-bundle.js";
export class GxIdeLaunchpadApi {
    constructor() {
        _GxIdeLaunchpadApi_instances.add(this);
        this.data = undefined;
        this.onObjectSelected = undefined;
    }
    componentDidLoad() {
        __classPrivateFieldGet(this, _GxIdeLaunchpadApi_instances, "m", _GxIdeLaunchpadApi_renderSwaggerUI).call(this);
    }
    onDataChanged() {
        // Only re-render when data actually changes
        __classPrivateFieldGet(this, _GxIdeLaunchpadApi_instances, "m", _GxIdeLaunchpadApi_renderSwaggerUI).call(this);
    }
    render() {
        return (h(Host, null, h("div", { id: "swagger-ui", ref: el => (this.swaggerContainer = el), onClick: __classPrivateFieldGet(this, _GxIdeLaunchpadApi_instances, "m", _GxIdeLaunchpadApi_handleApiClick), style: { cursor: "pointer" } })));
    }
    static get is() { return "gx-ide-launchpad-api"; }
    static get originalStyleUrls() {
        return {
            "$": ["launchpad-api.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["launchpad-api.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/launchpad-api"]; }
    static get properties() {
        return {
            "data": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ApiData",
                    "resolved": "ApiData",
                    "references": {
                        "ApiData": {
                            "location": "global",
                            "id": "global::ApiData"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Data for the individual API (url and spec)"
                }
            },
            "onObjectSelected": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ObjectSelectedCallback",
                    "resolved": "(event: ObjectSelectedEvent) => void",
                    "references": {
                        "ObjectSelectedCallback": {
                            "location": "global",
                            "id": "global::ObjectSelectedCallback"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Callback function for object selection (passed from parent)"
                }
            }
        };
    }
    static get events() {
        return [{
                "method": "copyToClipboard",
                "name": "copyToClipboard",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Event emitted when copying to clipboard"
                },
                "complexType": {
                    "original": "{ url: string }",
                    "resolved": "{ url: string; }",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "data",
                "methodName": "onDataChanged"
            }];
    }
}
_GxIdeLaunchpadApi_instances = new WeakSet(), _GxIdeLaunchpadApi_handleApiClick = function _GxIdeLaunchpadApi_handleApiClick() {
    if (this.onObjectSelected && this.data.key) {
        // Send the full key object as string in format "type|id"
        const keyString = `${this.data.key.type}|${this.data.key.id}`;
        this.onObjectSelected({ detail: { key: keyString } });
    }
    else if (this.onObjectSelected && this.data.url) {
        // If no key, use URL as identifier
        this.onObjectSelected({ detail: { key: this.data.url } });
    }
}, _GxIdeLaunchpadApi_renderSwaggerUI = function _GxIdeLaunchpadApi_renderSwaggerUI() {
    SwaggerUI({
        spec: this.data.spec,
        dom_id: "#swagger-ui",
        domNode: this.swaggerContainer,
        layout: "BaseLayout"
    });
};
//# sourceMappingURL=launchpad-api.js.map
