<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
    return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "TemplatesCommonLib/structuralFunctionality/t9nUtils", "../ui/FeatureTable"], function (require, exports, t9nUtils_1, FeatureTable_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.addLegendToLayerList = addLegendToLayerList;
    exports.addZoomToLayerList = addZoomToLayerList;
    exports.addTableToLayerList = addTableToLayerList;
    exports.addItems = addItems;
    exports.actionExists = actionExists;
    exports.getAction = getAction;
    exports.handleListActions = handleListActions;
    FeatureTable_1 = __importDefault(FeatureTable_1);
    function addLegendToLayerList(item) {
        if (item?.layer?.legendEnabled === false)
            return;
        // add content for individual items
        item.panel = {
            content: "legend",
            open: false
        };
    }
    function addZoomToLayerList(item, title) {
        const found = actionExists(item, "zoom");
        if (found)
            return;
        const section = {
            title,
            className: "esri-icon-zoom-in-magnifying-glass",
            id: "zoom"
        };
        item.actionsSections.push([section]);
        const obj = getAction(item, "zoom");
        if (obj !== null || obj !== undefined) {
            t9nUtils_1.autoUpdatedStrings.add({
                obj,
                property: "title",
                bundleName: "sidebar/app/t9n/common",
                key: "tools.zoom"
            });
        }
    }
    function addTableToLayerList(item, title) {
        const found = actionExists(item, "feature-table");
        if (found)
            return;
        const section = {
            title,
            className: "esri-icon-table",
            id: "feature-table"
        };
        item.actionsSections.push([section]);
        const obj = getAction(item, "feature-table");
        if (obj !== null || obj !== undefined) {
            t9nUtils_1.autoUpdatedStrings.add({
                obj,
                property: "title",
                bundleName: "sidebar/app/t9n/common",
                key: "tools.table"
            });
        }
    }
    function addItems(item, config) {
        const { appBundle, bundle, layerListLegend, layerListAddTable, layerListAddZoom } = config;
        if (item?.layer?.type === "group")
            return;
        if (layerListLegend)
            addLegendToLayerList(item);
        if (layerListAddZoom)
            addZoomToLayerList(item, appBundle.tools.zoom);
        if (layerListAddTable)
            addTableToLayerList(item, bundle.tools.table);
    }
    function actionExists(item, id) {
        return item?.actionsSections?.some((action) =&gt; {
            return action?.items?.some((subAction) =&gt; {
                if (subAction?.id === id) {
                    return true;
                }
            });
        });
    }
    function getAction(item, id) {
        let val;
        const found = item?.actionsSections?.some((action) =&gt; {
            return action?.items?.some((subAction) =&gt; {
                if (subAction?.id === id) {
                    val = subAction;
                    return true;
                }
            });
        });
        if (found) {
            return val;
        }
    }
    async function handleListActions(e, config, view) {
        const { action, item } = e;
        switch (action?.id) {
            case "zoom":
                if (item?.layer) {
                    item?.layer?.queryExtent().then((response) =&gt; {
                        if (response?.extent)
                            view.goTo(response.extent).catch();
                    });
                }
                break;
            default:
            case "feature-table":
                const container = document.createElement("div");
                container.classList.add("hide");
                const layer = item?.layer;
                if (!layer)
                    return;
                let table = document.getElementById(`${layer.id}-table`);
                if (!table) {
                    table = new FeatureTable_1.default({ config, view, layer, container });
                    // Get other components in bottom panel and close them if open
                    const components = [...view.ui.getComponents("bottom-right"), ...view.ui.getComponents("bottom-left")];
                    components.forEach((component) =&gt; {
                        if (component.expanded) {
                            component.expanded = false;
                        }
                    });
                    if (table)
                        view.ui.add(table, "manual");
                    table.watch("dismissed", () =&gt; {
                        if (table.dismissed) {
                            table.removeTable();
                        }
                    });
                    table.addTable();
                }
                else {
                    table.classList.remove("hide");
                }
                break;
        }
    }
});
</pre></body></html>