<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var __createBinding = (this &amp;&amp; this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this &amp;&amp; this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this &amp;&amp; this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod &amp;&amp; mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i &lt; k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
    return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "./utilites/telemetry/telemetry", "esri/Graphic", "esri/core/Handles", "./utilites/lookupLayerUtils", "./utilites/esriWidgetUtils", "esri/core/reactiveUtils", "./components/DisplayLookupResults", "./components/Header", "./components/MapPanel", "./utilites/themeUtils", "TemplatesCommonLib/baseClasses/support/domHelper", "TemplatesCommonLib/baseClasses/support/itemUtils", "./ConfigurationSettings", "./components/DetailPanel", "./components/LookupGraphics", "esri/core/promiseUtils", "esri/geometry/support/jsonUtils", "./components/FilterPanel", "esri/layers/ElevationLayer", "esri/geometry/Point", "TemplatesCommonLib/structuralFunctionality/a11yUtils", "./utilites/utils", "./utilites/themeUtils", "esri/layers/RouteLayer", "TemplatesCommonLib/functionality/highlight", "TemplatesCommonLib/structuralFunctionality/t9nUtils", "ArcGISHTMLSanitizer", "TemplatesCommonLib/functionality/securityUtils", "esri/widgets/Expand", "./utilites/layerListUtils", "esri/widgets/LayerList", "./components/RefineResults", "./components/SearchPanel", "esri/intl", "TemplatesCommonLib/structuralFunctionality/language-switcher/support/utils"], function (require, exports, telemetry_1, Graphic_1, Handles_1, lookupLayerUtils_1, esriWidgetUtils_1, reactiveUtils_1, DisplayLookupResults_1, Header_1, MapPanel_1, themeUtils_1, domHelper_1, itemUtils_1, ConfigurationSettings_1, DetailPanel_1, LookupGraphics_1, promiseUtils_1, jsonUtils_1, FilterPanel_1, ElevationLayer_1, Point_1, a11yUtils_1, utils_1, themeUtils_2, RouteLayer_1, highlight_1, t9nUtils_1, ArcGISHTMLSanitizer_1, securityUtils_1, Expand_1, layerListUtils_1, LayerList_1, RefineResults_1, SearchPanel_1, intl_1, utils_2) {
    "use strict";
    telemetry_1 = __importDefault(telemetry_1);
    Graphic_1 = __importDefault(Graphic_1);
    Handles_1 = __importDefault(Handles_1);
    DisplayLookupResults_1 = __importDefault(DisplayLookupResults_1);
    Header_1 = __importDefault(Header_1);
    MapPanel_1 = __importDefault(MapPanel_1);
    ConfigurationSettings_1 = __importDefault(ConfigurationSettings_1);
    DetailPanel_1 = __importDefault(DetailPanel_1);
    LookupGraphics_1 = __importDefault(LookupGraphics_1);
    FilterPanel_1 = __importDefault(FilterPanel_1);
    ElevationLayer_1 = __importDefault(ElevationLayer_1);
    Point_1 = __importDefault(Point_1);
    RouteLayer_1 = __importDefault(RouteLayer_1);
    ArcGISHTMLSanitizer_1 = __importDefault(ArcGISHTMLSanitizer_1);
    Expand_1 = __importDefault(Expand_1);
    LayerList_1 = __importDefault(LayerList_1);
    RefineResults_1 = __importDefault(RefineResults_1);
    SearchPanel_1 = __importDefault(SearchPanel_1);
    const CSS = {
        loading: "configurable-application--loading"
    };
    class LocationApp {
        constructor() {
            this._appConfig = null;
            this.telemetry = null;
            this.searchWidget = null;
            this.mapPanel = null;
            this._detailPanel = null;
            this._mapButton = null;
            this._handles = new Handles_1.default();
            this._defaultViewRotation = 0;
            this._results = null;
            this._filterPanel = null;
            this._refineResultsPanel = null;
            this._sketchTool = null;
            //----------------------------------
            //  ApplicationBase
            //----------------------------------
            this.base = null;
            this._telemetry = null;
        }
        //--------------------------------------------------------------------------
        //
        //  Public Methods
        //
        //--------------------------------------------------------------------------
        init(base) {
            if (!base) {
                console.error("ApplicationBase is not defined");
                return;
            }
            (0, promiseUtils_1.eachAlways)([
                (0, t9nUtils_1.handleT9N)("nearby", "nearby", "nearby/app/t9n/common"),
                (0, t9nUtils_1.handleT9N)("instant", "instant", "instant/../t9n/common")
            ]).then((results) =&gt; {
                const [appBundle, bundle] = results;
                base.config.bundle = bundle?.value;
                base.config.appBundle = appBundle?.value;
                // Update loading message
                const loadingLabel = document.getElementById("loaderMessage");
                if (loadingLabel)
                    loadingLabel.innerHTML = appBundle?.value?.load?.label;
                (0, utils_1.handleBufferProps)(base);
                this._updateMapVisibility(base.config);
                this.base = base;
                this.sanitizeValues();
                this._createApp();
            });
        }
        sanitizeValues() {
            const { config } = this.base;
            const sanitizer = (0, securityUtils_1.createSanitizerInstance)(ArcGISHTMLSanitizer_1.default);
            const { appBundle, resultsPanelPreText, resultsPanelPostText } = config;
            appBundle.tools.searchThisLocation = sanitizer.sanitize(appBundle.tools.searchThisLocation);
            appBundle.tools.clearLocation = sanitizer.sanitize(appBundle.tools.clearLocation);
            config.resultsPanelPreText = sanitizer.sanitize(resultsPanelPreText);
            config.resultsPanelPostText = sanitizer.sanitize(resultsPanelPostText);
        }
        _createApp() {
            const { config, results } = this.base;
            config.helperServices = { ...this.base.portal.helperServices };
            if (config?.exportPDF) {
                config.exportToPDF = config.exportPDF;
            }
            const { webMapItems } = results;
            this._appConfig = new ConfigurationSettings_1.default(config);
            this._appConfig.base = this.base;
            (0, themeUtils_1.updateThemeConfig)(config);
            (0, a11yUtils_1.setupLiveRegion)();
            (0, utils_1.handleSearchTypeConfig)(this._appConfig);
            this.createTelemetry();
            // Workaround to issue where slider range is undefined
            if (this._appConfig?.sliderRange === undefined || this._appConfig?.sliderRange === null) {
                this._appConfig.sliderRange = {
                    default: 1,
                    minimum: 0,
                    maximum: 2
                };
            }
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.enableBufferSearch, () =&gt; {
                    (0, utils_1.handleSearchTypeConfig)(this._appConfig);
                    const { singleLocationPolygons, enableBufferSearch } = this._appConfig;
                    enableBufferSearch &amp;&amp; !singleLocationPolygons
                        ? document.body.classList.add("buffer")
                        : document.body.classList.remove("buffer");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.hideMap, () =&gt; {
                    this._updateMapVisibility(this._appConfig);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.applyCustomTheme, () =&gt; {
                    const { customTheme } = this._appConfig;
                    if (!customTheme) {
                        (0, themeUtils_2.handleOldConfig)(this._appConfig, this?.base?.portal);
                    }
                    const sharedThemeProps = this?.base?.portal?.portalProperties?.sharedTheme;
                    if (customTheme?.applySharedTheme &amp;&amp; !customTheme?.logo &amp;&amp; sharedThemeProps?.logo?.small) {
                        customTheme.logo = sharedThemeProps.logo.small;
                    }
                    this._cleanUpResults();
                    this.handleThemeUpdates();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.customCSS, () =&gt; {
                    const { customTheme } = this._appConfig;
                    if (!customTheme) {
                        (0, themeUtils_2.handleOldConfig)(this._appConfig, this?.base?.portal);
                    }
                    const sharedThemeProps = this?.base?.portal?.portalProperties?.sharedTheme;
                    if (customTheme?.applySharedTheme &amp;&amp; !customTheme?.logo &amp;&amp; sharedThemeProps?.logo?.small) {
                        customTheme.logo = sharedThemeProps.logo.small;
                    }
                    this._cleanUpResults();
                    this.handleThemeUpdates();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.applySharedTheme, () =&gt; {
                    const { customTheme } = this._appConfig;
                    if (!customTheme) {
                        (0, themeUtils_2.handleOldConfig)(this._appConfig, this?.base?.portal);
                    }
                    const sharedThemeProps = this?.base?.portal?.portalProperties?.sharedTheme;
                    if (customTheme?.applySharedTheme &amp;&amp; !customTheme?.logo &amp;&amp; sharedThemeProps?.logo?.small) {
                        customTheme.logo = sharedThemeProps.logo.small;
                    }
                    this._cleanUpResults();
                    this.handleThemeUpdates();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.customTheme, () =&gt; {
                    const { customTheme } = this._appConfig;
                    if (!customTheme) {
                        (0, themeUtils_2.handleOldConfig)(this._appConfig, this?.base?.portal);
                    }
                    const sharedThemeProps = this?.base?.portal?.portalProperties?.sharedTheme;
                    if (customTheme?.applySharedTheme &amp;&amp; !customTheme?.logo &amp;&amp; sharedThemeProps?.logo?.small) {
                        customTheme.logo = sharedThemeProps.logo.small;
                    }
                    this._cleanUpResults();
                    this.handleThemeUpdates();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.theme, () =&gt; {
                    const { customTheme } = this._appConfig;
                    if (!customTheme) {
                        (0, themeUtils_2.handleOldConfig)(this._appConfig, this?.base?.portal);
                    }
                    const sharedThemeProps = this?.base?.portal?.portalProperties?.sharedTheme;
                    if (customTheme?.applySharedTheme &amp;&amp; !customTheme?.logo &amp;&amp; sharedThemeProps?.logo?.small) {
                        customTheme.logo = sharedThemeProps.logo.small;
                    }
                    this._cleanUpResults();
                    this.handleThemeUpdates();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.panelSize, () =&gt; {
                    // update panel size
                    const { panelSize } = this._appConfig;
                    (0, utils_1.updatePanelSize)(panelSize);
                }, { initial: true })
            ], "configuration");
            // Get web map
            const allItems = webMapItems.map((item) =&gt; {
                return item;
            });
            let validWebMapItems = [];
            allItems.forEach((response) =&gt; {
                if (response?.error) {
                    return;
                }
                validWebMapItems.push(response.value);
            });
            const item = validWebMapItems[0];
            if (!item) {
                console.error("Could not load an item to display");
                // show error page
                document.location.href = `../../shared/unavailable/index.html?appid=${this.base.config?.appid ?? null}`;
                return;
            }
            // Set the title to the app value if it exists
            let { title } = this._appConfig;
            if (!title) {
                title = this?.base?.results?.applicationItem?.value?.title
                    ? this?.base?.results?.applicationItem?.value?.title
                    : (0, itemUtils_1.getItemTitle)(item);
            }
            this._appConfig.title = title;
            (0, domHelper_1.setPageTitle)(title);
            this._createMap(item);
        }
        async _createMap(item) {
            this.mapPanel = await new MapPanel_1.default({
                item,
                config: this._appConfig,
                base: this.base,
                container: "mapPanel"
            });
            const panelHandle = this.mapPanel.watch("view", () =&gt; {
                const { title } = this._appConfig;
                panelHandle.remove();
                if (!title) {
                    this._appConfig.title = item.title || null;
                }
                this.view = this.mapPanel.view;
                const popupView = this.view;
                popupView.popupEnabled = false;
                // apply padding to the view if its mobile
                const maxMedia = window.matchMedia("(max-width:859px)");
                //  updateViewPadding(this.view, maxMedia.matches);
                maxMedia.onchange = (e) =&gt; {
                    // updateViewPadding(this.view, maxMedia.matches);
                };
                this._defaultViewRotation = this.view.rotation || 0;
                this._handles.add([
                    (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.highlightColor, () =&gt; {
                        if (!this.view)
                            return;
                        const { highlightColor, highlightHaloColor, enableHighlightColor, enableHighlightHaloColor } = this._appConfig;
                        const highlightConfig = {
                            enableHighlightColor,
                            highlightColor,
                            enableHighlightHaloColor,
                            highlightHaloColor
                        };
                        (0, highlight_1.handleHighlightColors)(highlightConfig, this.view);
                    }, { initial: true }),
                    (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.highlightHaloColor, () =&gt; {
                        if (!this.view)
                            return;
                        const { highlightColor, highlightHaloColor, enableHighlightColor, enableHighlightHaloColor } = this._appConfig;
                        const highlightConfig = {
                            enableHighlightColor,
                            highlightColor,
                            enableHighlightHaloColor,
                            highlightHaloColor
                        };
                        (0, highlight_1.handleHighlightColors)(highlightConfig, this.view);
                    }, { initial: true }),
                    (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.enableHighlightColor, () =&gt; {
                        if (!this.view)
                            return;
                        const { highlightColor, highlightHaloColor, enableHighlightColor, enableHighlightHaloColor } = this._appConfig;
                        const highlightConfig = {
                            enableHighlightColor,
                            highlightColor,
                            enableHighlightHaloColor,
                            highlightHaloColor
                        };
                        (0, highlight_1.handleHighlightColors)(highlightConfig, this.view);
                    }, { initial: true }),
                    (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.enableHighlightHaloColor, () =&gt; {
                        if (!this.view)
                            return;
                        const { highlightColor, highlightHaloColor, enableHighlightColor, enableHighlightHaloColor } = this._appConfig;
                        const highlightConfig = {
                            enableHighlightColor,
                            highlightColor,
                            enableHighlightHaloColor,
                            highlightHaloColor
                        };
                        (0, highlight_1.handleHighlightColors)(highlightConfig, this.view);
                    }, { initial: true })
                ]);
                // watch properties that determine how results are displayed
                this._handles.add([
                    (0, reactiveUtils_1.watch)(() =&gt; [
                        this._appConfig?.searchUnits,
                        this._appConfig?.includeDistance,
                        this._appConfig?.interactiveResults,
                        this._appConfig?.groupResultsByLayer,
                        this._appConfig?.enableSearchScale,
                        this._appConfig?.searchScale
                    ], () =&gt; {
                        if (this._results) {
                            const copyResults = this._results;
                            this._cleanUpResults();
                            this._displayResults(copyResults);
                        }
                    }),
                    (0, reactiveUtils_1.watch)(() =&gt; [this?._appConfig?.mapArea, this?._appConfig?.mapAreaConfig], () =&gt; {
                        if (this._appConfig?.mapArea === true &amp;&amp; this._appConfig.mapAreaConfig) {
                            if (this._appConfig.mapAreaConfig != null) {
                                const viewPointToUse = {
                                    ...this._appConfig.mapAreaConfig,
                                    targetGeometry: Point_1.default.fromJSON(this._appConfig.mapAreaConfig.targetGeometry)
                                };
                                const searchParams = new URL(window.location.href)?.searchParams;
                                const center = searchParams?.get("center");
                                const level = searchParams?.get("level");
                                if (center &amp;&amp; level)
                                    return;
                                this?.view.when(() =&gt; {
                                    this.view.goTo(viewPointToUse.targetGeometry).then(() =&gt; {
                                        this.view.scale = viewPointToUse.scale;
                                        this.view.rotation = viewPointToUse.rotation;
                                    });
                                });
                            }
                        }
                        else if (this._appConfig?.mapArea === false &amp;&amp; this._initialExtent) {
                            // if mapArea is false, reset to initial extent
                            this?.view.when(() =&gt; {
                                this.view
                                    .goTo(this._initialExtent)
                                    .then(() =&gt; {
                                    this.view.scale = this._initialScale;
                                    this.view.rotation = this._initialRotation;
                                })
                                    .catch();
                            });
                        }
                    }, { initial: true }),
                    (0, reactiveUtils_1.watch)(() =&gt; [this?._appConfig?.extentSelector, this?._appConfig?.extentSelectorConfig, this?._appConfig?.mapArea], () =&gt; {
                        // IGNORE INITIAL EXTENT IF SEARCH PARAMS ARE PRESENT
                        const searchParams = new URL(window.location.href)?.searchParams;
                        const center = searchParams?.get("center");
                        const zoom = searchParams?.get("level");
                        if (this._appConfig?.extentSelector &amp;&amp;
                            this._appConfig.extentSelectorConfig &amp;&amp;
                            this?._appConfig?.mapArea) {
                            const constraints = this._appConfig?.extentSelectorConfig?.constraints || null;
                            const geometry = constraints?.geometry;
                            if (geometry) {
                                const extent = (0, jsonUtils_1.fromJSON)(geometry);
                                if (extent &amp;&amp; (extent?.type === "extent" || extent?.type === "polygon")) {
                                    constraints.geometry = extent;
                                    if (!center &amp;&amp; !zoom) {
                                        const goToProps = (0, lookupLayerUtils_1.createGoToProps)(extent, this._appConfig);
                                        this.view.goTo(goToProps, { animate: false }).catch(() =&gt; { });
                                    }
                                }
                                else {
                                    constraints.geometry = null;
                                }
                            }
                            constraints.minScale = +constraints.minScale;
                            constraints.maxScale = +constraints.maxScale;
                            this.view.constraints = constraints;
                            this._setMapViewRotation();
                        }
                        else {
                            if (this._initialExtent) {
                                if (!center &amp;&amp; !zoom) {
                                    this.view.goTo(this._initialExtent, { animate: false }).catch(() =&gt; { });
                                }
                            }
                        }
                    }, {
                        initial: true
                    })
                ], "configuration");
                if (this?.view?.popup)
                    this.view.popup.actions = null;
                document.body.classList.remove(CSS.loading);
                this._appConfig.defaultZoom = this.view.zoom;
                this.view.when(() =&gt; {
                    this._initialRotation = this?.view.rotation || 0;
                    this._initialExtent = this?.view.extent.clone();
                    this._initialScale = this?.view.scale;
                    (0, itemUtils_1.setImageryLayerHighlightOptions)(this.view);
                    // Handle hiding layers
                    if (this?._appConfig?.hiddenLayers) {
                        (0, itemUtils_1.setHiddenLayers)(this._appConfig?.hiddenLayers, this.view);
                    }
                    this._addWidgets();
                    this._addHeader(item);
                    (0, intl_1.onLocaleChange)(async (e) =&gt; {
                        const t9nData = await (0, utils_2.convertT9nToConfigData)(e?.detail?.data, this?._appConfig?.base);
                        Object.keys(t9nData).forEach((key) =&gt; this?._appConfig?.set(key, t9nData[key]));
                        this._appConfig.appBundle = await (0, intl_1.fetchMessageBundle)("nearby/app/t9n/common");
                        this._appConfig.bundle = await (0, intl_1.fetchMessageBundle)("instant/../t9n/common");
                    });
                    // watch for option/cmd + m key
                    document.addEventListener("keydown", (e) =&gt; {
                        if (e?.altKey &amp;&amp; e?.code === "KeyM") {
                            this?.view?.focus();
                        }
                    });
                    document.addEventListener("selectedLanguageUpdated", async (e) =&gt; {
                        // Update the results so any arcade-generated popups update
                        if (this._results) {
                            const copyResults = this._results;
                            this._cleanUpResults();
                            this._displayResults(copyResults);
                        }
                    });
                });
            });
        }
        _addHeader(item) {
            const container = document.createElement("div");
            container.id = "infoPanel";
            this._detailPanel = new DetailPanel_1.default({
                config: this._appConfig,
                view: this.view,
                mapPanel: this.mapPanel,
                portal: item?.portal,
                container
            });
            this._detailPanel.on("location", () =&gt; {
                if (this.searchWidget?.viewModel)
                    this.searchWidget.viewModel.searchNearby();
            });
            const headerWidget = new Header_1.default({
                config: this._appConfig,
                detailPanel: this._detailPanel,
                portal: this.base.portal,
                view: this.view,
                container: "header"
            });
            // move container
            const wrapper = document.getElementById("sidePanel");
            const panelContainer = this._detailPanel?.container;
            (0, reactiveUtils_1.watch)(() =&gt; [this._appConfig?.infoAsModal, this._appConfig?.showIntroduction], () =&gt; {
                if (this._appConfig.infoAsModal &amp;&amp; this._appConfig?.showIntroduction) {
                    // add to body
                    document.body.append(panelContainer);
                }
                else if (!this._appConfig?.infoAsModal &amp;&amp; this._appConfig?.showIntroduction) {
                    // add to side panel
                    wrapper?.append(panelContainer);
                }
            }, { initial: true });
            (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.showIntroduction, () =&gt; {
                const { showIntroduction } = this._appConfig;
                // When showIntroduction is false hide detail panel otherwise open
                // results are cleared
                !showIntroduction ? this?._detailPanel?.hidePanel() : this?._detailPanel?.showPanel();
            }, { initial: true });
            (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.header, () =&gt; {
                const { header, showIntroduction, infoButtonPosition, infoAsModal } = this._appConfig;
                const mapButton = this.view.ui.find("map-info-button");
                if (header &amp;&amp; mapButton) {
                    // If header is disabled but intro is enabled add intro to the main map
                    // remove the map button
                    this?.view?.ui?.remove(mapButton);
                }
                else if (!header &amp;&amp; showIntroduction &amp;&amp; !mapButton) {
                    // add the map button to the view
                    const infoButton = headerWidget?.createInfoButton();
                    if (!infoButton)
                        return;
                    infoButton.id = "map-info-button";
                    this.view.ui.add(infoButton, infoButtonPosition);
                    if (!infoAsModal)
                        this._detailPanel.showPanel();
                }
            }, { initial: true });
            (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.infoButtonPosition, () =&gt; {
                const { infoButtonPosition } = this._appConfig;
                const mapButton = this.view.ui.find("map-info-button");
                this.view.ui.move(mapButton, infoButtonPosition);
            }, { initial: true });
        }
        async _addWidgets() {
            // Add esri widgets to the app (legend, home etc)
            const props = {
                view: this.view,
                config: this._appConfig,
                portal: this.base.portal
            };
            (0, esriWidgetUtils_1.addMapComponents)(props);
            this._setupFeatureSearch();
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; [
                    this._appConfig?.layerList,
                    this._appConfig.layerListAddZoom,
                    this._appConfig.layerListLegend,
                    this._appConfig?.layerListOpenAtStart,
                    this._appConfig?.layerListPosition,
                    this._appConfig?.visibilityIcon
                ], () =&gt; {
                    this.addLayerList(this._appConfig, this.view, this._appConfig.bundle);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.locateWidget, () =&gt; {
                    this.addLocate(this.view, this._appConfig, "locateWidget");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.locateWidgetPosition, () =&gt; {
                    this.addLocate(this.view, this._appConfig, "locateWidgetPosition");
                }, { initial: true })
            ], "configuration");
        }
        async addLocate(view, config, propertyName) {
            const { locateWidget, locateWidgetPosition } = config;
            const Locate = await new Promise((resolve_1, reject_1) =&gt; { require(["esri/widgets/Locate"], resolve_1, reject_1); }).then(__importStar);
            const node = (0, utils_1._findNode)("esri-locate");
            if (!locateWidget) {
                if (node)
                    view.ui.remove(node);
                return;
            }
            if (node &amp;&amp; !locateWidget)
                view.ui.remove(node);
            if (propertyName === "locateWidgetPosition" &amp;&amp; node) {
                view.ui.move(node, locateWidgetPosition);
            }
            else if (propertyName === "locateWidget") {
                const locationWidget = new Locate.default({
                    view,
                    popupEnabled: false,
                    graphic: null
                });
                locationWidget.on("locate", (location) =&gt; {
                    // clear existing then search
                    this._cleanUpResults();
                    if (location?.position?.coords) {
                        this._searchByGeometry(new Point_1.default(location.position.coords));
                    }
                });
                view.ui.add(locationWidget, locateWidgetPosition);
            }
        }
        async _setupFeatureSearch() {
            // Create the panel that contains the slider
            const container = document.getElementById("distanceOptions");
            // Get url param if applied
            if (this?.base?.config?.sliderDistance &amp;&amp; this._appConfig?.enableBufferSearch) {
                if (this._appConfig?.sliderRange?.default &gt;= 0)
                    this._appConfig.sliderRange["default"] = this.base.config.sliderDistance;
            }
            this._refineResultsPanel = new RefineResults_1.default({
                config: this._appConfig,
                container
            });
            this._filterPanel = new FilterPanel_1.default({
                config: this._appConfig,
                view: this.view,
                container: document.getElementById("filterPanel")
            });
            const searchContainer = document.getElementById("searchPanel");
            const searchPanel = new SearchPanel_1.default({
                config: this._appConfig,
                view: this.view,
                portal: this?.base?.portal,
                filterPanel: this._filterPanel,
                container: searchContainer
            });
            (0, reactiveUtils_1.when)(() =&gt; searchPanel?.state, () =&gt; {
                if (searchPanel?.state !== "ready") {
                    return;
                }
                this.searchWidget = searchPanel.searchWidget;
                if (this?.lookupResults)
                    this.lookupResults.searchWidget = this.searchWidget;
                this.searchWidget.on("search-clear", () =&gt; {
                    this._cleanUpResults();
                    container.classList.remove("hide-search-btn");
                    if (this._appConfig.enableBufferSearch) {
                        this._mapButton?.classList.add("hide");
                    }
                    // Remove find url param
                    this._updateUrlParam();
                    this._searchFeature = null;
                });
                this.searchWidget.on("search-complete", async (results) =&gt; {
                    this._cleanUpResults();
                    if (results.numResults &gt; 0) {
                        // Hide the search extent button on initial load if results are found
                        if (!this?._appConfig?.enableBufferSearch)
                            this._hideExtentSearchButton();
                        container.classList.add("hide-search-btn");
                        this._displayResults(results);
                        const handle = (0, reactiveUtils_1.watch)(() =&gt; this?.lookupResults?.accordion?.featureResults, (r) =&gt; {
                            if (this?._appConfig?.storeLocationsConsent &amp;&amp; this?._telemetry) {
                                // log the search location if storelocation is enabled
                                const attribute = results?.searchTerm || this?.searchWidget?.searchTerm;
                                this._telemetry?.logEvent({
                                    category: "Dataset",
                                    action: "search",
                                    label: "search",
                                    attribute,
                                    details: r?.length &gt; 0 ? "true" : "false"
                                });
                            }
                            this.searchWidget.blur();
                            handle.remove();
                            if (r?.length &gt; 0) {
                                setTimeout(() =&gt; {
                                    (0, utils_1.removeFocus)();
                                    const elements = document.getElementsByClassName("feature-group-container");
                                    if (elements[0]) {
                                        (0, utils_1.setFieldFocus)(elements[0]);
                                    }
                                }, 500);
                            }
                            else {
                                this.searchWidget.focus();
                            }
                        });
                    }
                    else {
                        this.lookupResults.addNotice();
                    }
                });
                this.view.on("click", async (e) =&gt; {
                    if (this?.view?.popup) {
                        const v = this.view;
                        v.closePopup();
                    }
                    if (document?.body?.classList?.contains("mobile-view-expand"))
                        return;
                    if (document?.body?.classList?.contains("activate-measure"))
                        return;
                    if (this?._appConfig?.noMapClick) {
                        this.view.popupEnabled = true;
                        return;
                    }
                    const point = e.mapPoint;
                    this._searchByGeometry(point);
                });
                this._handles.add((0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.enableBufferSearch, () =&gt; {
                    (0, utils_1.handleSearchTypeConfig)(this._appConfig);
                    this._addMapButton();
                }, { initial: true }), "configuration");
                const { select, level, center, enableBufferSearch } = this._appConfig;
                if (select &amp;&amp; level &amp;&amp; center) {
                    let location = center.split(";");
                    if (location?.length === 0) {
                        location = center.split(",");
                    }
                    if (location?.length &gt; 1) {
                        const point = new Point_1.default({
                            longitude: location[0],
                            latitude: location[1]
                        });
                        enableBufferSearch ? this._searchByGeometry(point) : this._searchThisExtent(point);
                    }
                }
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.showAll, () =&gt; {
                    const { showAll, enableBufferSearch } = this._appConfig;
                    if (showAll &amp;&amp; !enableBufferSearch) {
                        this._searchThisExtent(this?.view?.extent?.center);
                    }
                }, { initial: true, once: true });
            }, { initial: true });
            (0, reactiveUtils_1.whenOnce)(() =&gt; this._filterPanel?.filterList !== undefined).then(() =&gt; {
                this._filterPanel?.filterList?.addEventListener("filterUpdate", (e) =&gt; {
                    this._updateSearchGeometry();
                    if (!this._searchFeature)
                        return;
                    this._generateSearchResults();
                });
                this._filterPanel?.filterList?.addEventListener("filterListReset", () =&gt; {
                    if (this?._filterPanel) {
                        this._filterPanel.filterCount = 0;
                    }
                    this._updateUrlParam(true);
                    this._updateSearchGeometry();
                    if (!this._searchFeature)
                        return;
                    this._generateSearchResults();
                });
            });
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.enableFilter, (value) =&gt; {
                    this?._filterPanel?.update("enableFilter", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.filterConfig, (value) =&gt; {
                    this?._filterPanel?.update("filterConfig", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.expandFilters, (value) =&gt; {
                    this?._filterPanel?.update("expandFilters", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.theme, (value) =&gt; {
                    this?._filterPanel?.update("theme", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.filter, (value) =&gt; {
                    this?._refineResultsPanel?.updateSliderProps("filter", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.sliderRange, (value) =&gt; {
                    this?._refineResultsPanel?.updateSliderProps("sliderRange", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.searchUnits, (value) =&gt; {
                    this?._refineResultsPanel?.updateSliderProps("searchUnits", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.precision, (value) =&gt; {
                    this?._refineResultsPanel?.updateSliderProps("precision", value);
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.inputsEnabled, (value) =&gt; {
                    this?._refineResultsPanel?.updateSliderProps("inputsEnabled", value);
                }, { initial: true })
            ], "configuration");
            this?._refineResultsPanel.watch("value", (value) =&gt; {
                this._cleanUpResults();
                if (value)
                    this._appConfig.sliderRange["default"] = value;
                if (!this._searchFeature)
                    return;
                this._generateSearchResults();
                this._updateUrlParam();
            });
            const lookupGraphics = new LookupGraphics_1.default({
                view: this.view,
                config: this._appConfig
            });
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.drawBuffer, () =&gt; {
                    lookupGraphics.updateGraphics("drawBuffer");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinLabelSize, (value) =&gt; {
                    lookupGraphics.updateGraphics("mapPinLabelSize");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinLabel, () =&gt; {
                    lookupGraphics.updateGraphics("mapPinLabel");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinLabelColor, () =&gt; {
                    lookupGraphics.updateGraphics("mapPinLabelColor");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinColor, () =&gt; {
                    lookupGraphics.updateGraphics("mapPinColor");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinSize, () =&gt; {
                    lookupGraphics.updateGraphics("mapPinSize");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPinIcon, () =&gt; {
                    lookupGraphics.updateGraphics("mapPinIcon");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.mapPin, () =&gt; {
                    lookupGraphics.updateGraphics("mapPin");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.bufferTransparency, () =&gt; {
                    lookupGraphics.updateGraphics("bufferTransparency");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.enableBufferColor, () =&gt; {
                    lookupGraphics.updateGraphics("enableBufferColor");
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.bufferColor, () =&gt; {
                    lookupGraphics.updateGraphics("bufferColor");
                }, { initial: true })
            ], "configuration");
            this.lookupResults = new DisplayLookupResults_1.default({
                lookupGraphics,
                config: this._appConfig,
                view: this.view,
                mapPanel: this.mapPanel,
                portal: this.base?.portal,
                container: "resultsPanel"
            });
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; [this._appConfig?.lookupLayers, this._appConfig.hideLayers], async () =&gt; {
                    let parsedLayers = this._appConfig.lookupLayers?.layers ? this._appConfig.lookupLayers.layers : null;
                    let updatedLayers = [];
                    if (!Array.isArray(parsedLayers) || !parsedLayers.length) {
                        updatedLayers = parsedLayers = null;
                    }
                    else {
                        // Remove any dups from LookupLayers
                        updatedLayers = parsedLayers?.filter((thing, index) =&gt; {
                            const _thing = JSON.stringify(thing);
                            return (index ===
                                parsedLayers.findIndex((obj) =&gt; {
                                    return JSON.stringify(obj) === _thing;
                                }));
                        });
                    }
                    const lookupLayers = await (0, lookupLayerUtils_1.getLookupLayers)({
                        view: this.view,
                        lookupLayers: updatedLayers,
                        hideFeaturesOnLoad: this._appConfig.hideLayers
                    });
                    this.lookupResults.lookupLayers = lookupLayers;
                    this._refreshResults();
                }, { initial: true })
            ], "configuration");
            // Wait for view model
            this._handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.showDirections, () =&gt; {
                    if (this._appConfig.showDirections &amp;&amp; !this.lookupResults?.directions) {
                        this._createDirections();
                        if (this._results) {
                            // refresh the results to show directions
                            this._displayResults(this._results);
                        }
                    }
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.useDirectionsApp, () =&gt; {
                    if (this._appConfig.showDirections &amp;&amp; !this.lookupResults?.directions) {
                        this._createDirections();
                        if (this._results) {
                            // refresh the results to show directions
                            this._displayResults(this._results);
                        }
                    }
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.shareSelected, () =&gt; {
                    if (this._appConfig.shareSelected) {
                        this._refreshResults();
                    }
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.applyLayerEffects, () =&gt; {
                    this._refreshResults();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.presetLayerEffects, () =&gt; {
                    this._refreshResults();
                }, { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this?._appConfig?.showElevationProfile, (value) =&gt; {
                    if (!value &amp;&amp; this?.lookupResults?.elevationProfile) {
                        if (this.lookupResults.elevationProfile?.input) {
                            this.lookupResults.elevationProfile.input = null;
                        }
                        this.lookupResults.elevationProfile = null;
                    }
                    else {
                        this._createElevationProfile();
                    }
                    this._refreshResults();
                }, { initial: true })
            ], "configuration");
            // this._cleanUpHandles();
        }
        _updateSearchGeometry() {
            const copySearch = this._searchFeature?.clone();
            this._cleanUpResults(false);
            if (copySearch) {
                this._searchFeature = copySearch;
            }
        }
        _refreshResults() {
            if (this._results) {
                // refresh the results
                this._displayResults(this._results);
            }
        }
        async addLayerList(config, view, commonMessages) {
            const { layerList, layerListPosition, layerListOpenAtStart, visibilityIcon } = config;
            const uniqueId = "esri-layerListExpand";
            const node = view.ui.find(uniqueId);
            if (!layerList) {
                view.ui.remove(node);
                return;
            }
            const group = (0, utils_1.getPosition)(layerListPosition);
            const tip = this.base.config.appBundle.tools.layerListExpand;
            if (node) {
                node.expandTooltip = tip;
                node.collapseTooltip = tip;
                node.expanded = layerListOpenAtStart;
                view.ui.move(node, layerListPosition);
                const ll = node?.content;
                if (ll) {
                    ll.visibilityAppearance = visibilityIcon;
                }
            }
            else {
                const content = new LayerList_1.default({
                    view,
                    dragEnabled: true,
                    visibilityAppearance: visibilityIcon,
                    visibleElements: {
                        errors: true,
                        filter: true
                    },
                    listItemCreatedFunction: (e) =&gt; {
                        (0, layerListUtils_1.addItems)(e?.item, config);
                        (0, reactiveUtils_1.watch)(() =&gt; [e?.item?.visible, !e?.item?.visible], () =&gt; {
                            if (this._appConfig?.layerList) {
                                this._refreshResults();
                            }
                        });
                    }
                });
                await content?.when();
                content?.on("trigger-action", (e) =&gt; {
                    (0, layerListUtils_1.handleListActions)(e, view);
                });
                (0, reactiveUtils_1.watch)(() =&gt; [config?.layerListAddZoom, config?.layerListLegend], () =&gt; {
                    content?.operationalItems?.forEach((item) =&gt; {
                        item?.actionsSections?.removeAll();
                        if (item?.panel)
                            item.panel = null;
                    });
                    content?.operationalItems?.forEach((item) =&gt; {
                        (0, layerListUtils_1.addItems)(item, config);
                    });
                }, { initial: true });
                const layerListExpand = new Expand_1.default({
                    id: uniqueId,
                    content,
                    expanded: layerListOpenAtStart,
                    expandTooltip: tip,
                    collapseTooltip: tip,
                    group,
                    mode: "floating",
                    view
                });
                view.ui.add(layerListExpand, layerListPosition);
                t9nUtils_1.autoUpdatedStrings.add({
                    obj: layerListExpand,
                    property: "collapseTooltip",
                    bundleName: "nearby/app/t9n/common",
                    key: "tools.layerListExpand"
                });
                t9nUtils_1.autoUpdatedStrings.add({
                    obj: layerListExpand,
                    property: "expandTooltip",
                    bundleName: "nearby/app/t9n/common",
                    key: "tools.layerListExpand"
                });
            }
        }
        async _createDirections() {
            if (this.lookupResults.directions)
                return;
            if (!this._appConfig.useDirectionsApp) {
                const portalItem = this.base?.results?.applicationItem?.value;
                const appProxies = portalItem?.applicationProxies ? portalItem.applicationProxies : null;
                appProxies &amp;&amp;
                    appProxies.forEach((proxy) =&gt; {
                        const { url } = this.base.config.helperServices.route;
                        if (proxy.sourceUrl === url) {
                            this.base.config.helperServices.route.url = proxy.proxyUrl;
                        }
                    });
                const { url } = this.base.config.helperServices.route;
                const { directionsUnit, searchUnits } = this._appConfig;
                const Directions = await new Promise((resolve_2, reject_2) =&gt; { require(["esri/widgets/Directions"], resolve_2, reject_2); }).then(__importStar);
                const container = document.createElement("div");
                container.setAttribute("role", "dialog");
                container.setAttribute("tabindex", "0");
                container.id = "directionsDialog";
                const routeLayer = new RouteLayer_1.default({
                    url
                });
                this.view.map.add(routeLayer);
                const directionsProps = {
                    layer: routeLayer,
                    unit: directionsUnit,
                    container
                };
                if (directionsProps?.units === undefined &amp;&amp; searchUnits !== undefined) {
                    directionsProps.units = searchUnits;
                }
                const directions = new Directions.default(directionsProps);
                this.lookupResults.directions = directions;
                // add directions to the view's popup
                (0, reactiveUtils_1.when)(() =&gt; directions?.viewModel !== undefined, () =&gt; {
                    directions.view = this.view;
                    directions.viewModel.routeParameters.returnDirections = true;
                    directions.viewModel.load().catch((e) =&gt; {
                        if (e &amp;&amp; e.message) {
                            console.log("Problem loading directions:", e.message);
                        }
                    });
                });
                (0, reactiveUtils_1.watch)(() =&gt; this._appConfig?.directionsUnit, () =&gt; {
                    if (directions?.unit)
                        directions.unit = this?._appConfig?.directionsUnit;
                }, {
                    initial: true
                });
            }
            (0, reactiveUtils_1.when)(() =&gt; this.lookupResults?.directionsReady === true, () =&gt; {
                if (this._results)
                    this._displayResults(this._results);
            }, { initial: true, once: true });
        }
        async _createElevationProfile() {
            if (!this.lookupResults.elevationProfile &amp;&amp; this._appConfig.showElevationProfile) {
                const ElevationProfile = await new Promise((resolve_3, reject_3) =&gt; { require(["esri/widgets/ElevationProfile"], resolve_3, reject_3); }).then(__importStar);
                const epWidget = new ElevationProfile.default({
                    view: this.view,
                    visibleElements: {
                        clearButton: false,
                        sketchButton: false,
                        selectButton: false
                    }
                });
                this.lookupResults.elevationProfile = epWidget;
            }
            if (this?.view?.map?.ground &amp;&amp; this._appConfig.showElevationProfile) {
                if (this.view.map.ground?.layers?.length === 0) {
                    const url = this.base?.config?.helperServices?.defaultElevationLayers?.length &gt; 0 &amp;&amp;
                        this.base?.config?.helperServices?.defaultElevationLayers[0]?.url
                        ? this.base?.config?.helperServices?.defaultElevationLayers[0]?.url
                        : "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
                    this.view.map.ground.layers.add(new ElevationLayer_1.default({
                        url
                    }));
                }
            }
        }
        async _displayResults(results) {
            if (this._appConfig.enableBufferSearch) {
                this._mapButton?.classList.remove("hide");
            }
            this._results = results;
            // Get search geometry and add address location to the map
            const searchProps = {
                config: this.base.config,
                view: this.view,
                results
            };
            const feature = await (0, lookupLayerUtils_1.getSearchGeometry)(searchProps);
            this._searchFeature = feature;
            this._generateSearchResults();
        }
        _getSelectedAccordionItem(results, point) {
            if (this.lookupResults.accordion) {
                this.lookupResults.accordion.findAccordionItem(results, point);
            }
        }
        async _generateSearchResults() {
            const location = this._searchFeature ? this._searchFeature : null;
            if (location &amp;&amp; !this._appConfig.infoAsModal)
                this._detailPanel?.hidePanel();
            this.lookupResults?.queryFeatures(location);
            this._updateUrlParam();
        }
        _cleanUpResults(removeGraphics = true) {
            // Clear the lookup results displayed in the side panel
            const updatedView = this.view;
            updatedView?.closePopup();
            this?.lookupResults?.clearResults(removeGraphics);
            document.body.classList.add("no-results");
            document?.body?.classList.remove("mobile-view-expand");
            this._results = null;
            if (this?.lookupResults?.notice) {
                this.lookupResults.notice.dismissNotice();
            }
            // Show the detail panel again if its not a modal window and not small screen size
            const isMobileSize = window?.matchMedia("(max-width: 859px)");
            // Don't show the info panel if the filter panel is visible
            const isFilterPanelClosed = this?._filterPanel?.container?.classList?.contains("hide")
                ? true
                : false;
            if (!this?._appConfig?.infoAsModal &amp;&amp; !isMobileSize.matches &amp;&amp; isFilterPanelClosed) {
                this?._detailPanel?.showPanel();
            }
            if (this?._appConfig?.hideMap) {
                this?._detailPanel?.showPanel();
            }
        }
        _updateUrlParam(filterEnabled = false) {
            if ("URLSearchParams" in window) {
                const params = new URLSearchParams(document.location.search);
                let index = 0;
                this?.searchWidget?.results?.some((result) =&gt; {
                    if (result?.results?.length &gt; 0) {
                        index = result.sourceIndex;
                        return true;
                    }
                    else {
                        return false;
                    }
                });
                const searchTerm = this?.searchWidget?.searchTerm ? encodeURIComponent(this.searchWidget.searchTerm) : null;
                if (searchTerm) {
                    if (this.searchWidget.activeSource &amp;&amp; this?.searchWidget?.activeSourceIndex !== null) {
                        params.set("findSource", this.searchWidget.activeSourceIndex.toString());
                    }
                    else {
                        params.delete("findSource");
                    }
                    params.set("find", encodeURIComponent(this.searchWidget.searchTerm));
                    if (!this._appConfig?.enableBufferSearch)
                        params.set("level", this?.view?.zoom?.toString());
                }
                else {
                    params.delete("level");
                    params.delete("find");
                    params.delete("findSource");
                }
                // Apply slider filter
                if (this._appConfig?.sliderRange?.default &gt;= 0 &amp;&amp; this._appConfig?.enableBufferSearch) {
                    params.set("sliderDistance", this._appConfig.sliderRange["default"]);
                }
                else {
                    params.delete("sliderDistance");
                }
                if (filterEnabled) {
                    params.delete("filter");
                }
                if (params &amp;&amp; params.toString()) {
                    window.history.replaceState({}, "", `${location.pathname}?${params} `);
                }
                else {
                    window.history.replaceState({}, "", `${location.pathname} `);
                }
            }
        }
        handleThemeUpdates() {
            const { theme, customCSS } = this._appConfig;
            if (theme) {
                const style = document.getElementById("esri-stylesheet");
                style.href =
                    style.href.indexOf("light") !== -1 ? style.href.replace(/light/g, theme) : style.href.replace(/dark/g, theme);
                // add light/dark class
                document.body.classList.add(theme === "light" ? "light" : "dark");
                document.body.classList.remove(theme === "light" ? "dark" : "light");
                const themeToRemove = theme === "light" ? "calcite-mode-dark" : "calcite-mode-light";
                const themeToAdd = themeToRemove === "calcite-mode-light" ? "calcite-mode-dark" : "calcite-mode-light";
                document.body.classList.add(themeToAdd);
                document.body.classList.remove(themeToRemove);
                this.view?.when(() =&gt; {
                    const uiDiv = document.getElementsByClassName("esri-ui")[0];
                    uiDiv?.classList.add(themeToAdd);
                    uiDiv?.classList.remove(themeToRemove);
                });
            }
            const sharedTheme = (0, themeUtils_1.createSharedTheme)(this._appConfig, this?.base?.portal);
            (0, themeUtils_1.handleSharedTheme)(sharedTheme, this._appConfig);
            (0, themeUtils_1.handleFontStyles)(this._appConfig);
            if (customCSS) {
                (0, themeUtils_1.createAndAppendStyles)(customCSS);
            }
        }
        async createTelemetry() {
            // add alert to container
            const { portal } = this.base;
            const appName = `${this.base.config?.telemetry?.name}${this.base.config?.appid}`;
            const telemTS = new telemetry_1.default({
                portal,
                config: this._appConfig,
                messages: {
                    optIn: this._appConfig?.bundle?.analyticsOptIn
                },
                appName
            });
            (0, reactiveUtils_1.whenOnce)(() =&gt; telemTS?.instance !== undefined).then(() =&gt; {
                if (telemTS?.instance) {
                    this._telemetry = telemTS.instance;
                    this._telemetry?.logPageView(`${window.location.pathname}${window.location.search}`);
                }
            });
        }
        async _searchByGeometry(point) {
            const { enableBufferSearch } = this._appConfig;
            if (this.lookupResults.empty &amp;&amp; enableBufferSearch) {
                // If there is a layer search source of type point get the feature and send search field attribute to
                // search widget
                let hasSearchPointFeatureLayer = false;
                let searchLayer = null;
                let activeSource = null;
                this._searchFeature = new Graphic_1.default({ geometry: point });
                if (this?.searchWidget?.activeSource?.hasOwnProperty("layer")) {
                    activeSource = this.searchWidget.activeSource;
                    searchLayer = activeSource?.layer;
                    if (searchLayer?.geometryType === "point") {
                        hasSearchPointFeatureLayer = true;
                    }
                }
                if (!hasSearchPointFeatureLayer) {
                    this.searchWidget.search(point);
                }
                else if (hasSearchPointFeatureLayer &amp;&amp; searchLayer) {
                    this.view.hitTest(this.view.toScreen(point), { include: [searchLayer] }).then((r) =&gt; {
                        const graphicHits = r.results?.filter((hitResult) =&gt; hitResult.type === "graphic");
                        if (graphicHits?.length &gt; 0) {
                            const graphic = graphicHits[0]?.graphic;
                            // when search all is enabled let's check for an search source before doing the search
                            let searchSource = activeSource;
                            let searchIndex = null;
                            const searchAllEnabled = this.searchWidget.searchAllEnabled;
                            if (searchAllEnabled &amp;&amp; graphicHits?.length &gt; 0) {
                                this.searchWidget.allSources?.forEach((source, i) =&gt; {
                                    if (source?.hasOwnProperty("layer")) {
                                        const s = source;
                                        if (s?.layer?.id === graphic?.layer?.id) {
                                            searchSource = s;
                                            searchIndex = i;
                                        }
                                    }
                                });
                            }
                            if (searchIndex != null) {
                                // The result is using a layer that has a corresponding search layer setup
                                // so let's make that the active source
                                this.searchWidget.activeSourceIndex = searchIndex;
                            }
                            this.searchWidget.search(graphic?.attributes[searchSource?.searchFields[0]]).then(() =&gt; {
                                //reset index to all sources if it was set
                                if (searchIndex != null) {
                                    this.searchWidget.activeSourceIndex = -1;
                                }
                            });
                        }
                        else {
                            this?.searchWidget?.search(this?._searchFeature?.geometry ?? point);
                        }
                    });
                }
            }
            else {
                // Results exist and user is clicking
                // on the map point. We'll find the feature
                // then show the result in list
                const screenPoint = this.view.toScreen(point);
                const results = await this.view.hitTest(screenPoint);
                this._getSelectedAccordionItem(results, point);
            }
            if (this._appConfig.enableBufferSearch) {
                this._mapButton?.classList.remove("hide");
            }
        }
        _addMapButton() {
            // add clear search button to map view
            if (this._mapButton) {
                this.view.ui.remove(this._mapButton);
                this._mapButton = null;
            }
            this._mapButton = document.createElement("calcite-button");
            this._mapButton.id = "mapSearchButton";
            this._mapButton.classList.add("clear-btn");
            if (this._appConfig.enableBufferSearch) {
                this._mapButton.innerHTML = this.base.config.appBundle.tools.clearLocation;
                t9nUtils_1.autoUpdatedStrings.add({
                    obj: this._mapButton,
                    property: "innerHTML",
                    bundleName: "nearby/app/t9n/common",
                    key: "tools.clearLocation"
                });
                this._mapButton.classList.add("hide");
                this._mapButton.addEventListener("click", () =&gt; {
                    this._mapButton.classList.add("hide");
                    this.searchWidget &amp;&amp; this.searchWidget.clear();
                });
            }
            else {
                // add a "search here button"
                this._mapButton.innerHTML = this.base.config.appBundle.tools.searchThisLocation;
                t9nUtils_1.autoUpdatedStrings.add({
                    obj: this._mapButton,
                    property: "innerHTML",
                    bundleName: "nearby/app/t9n/common",
                    key: "tools.searchThisLocation"
                });
                this._mapButton.addEventListener("click", () =&gt; {
                    const centroid = this?.view?.center;
                    this._searchThisExtent(centroid);
                });
            }
            this.view.ui.add(this._mapButton, "manual");
        }
        _searchThisExtent(point) {
            if (!point)
                return;
            // kick off new search using this extent
            this?.searchWidget &amp;&amp; this?.searchWidget.clear();
            const searchHandle = this?.searchWidget.on("search-clear", () =&gt; {
                searchHandle.remove();
                this._mapButton.classList.remove("hide");
            });
            this._appConfig.shouldZoom = false;
            this.searchWidget.search(point);
            this._searchFeature = new Graphic_1.default({ geometry: point });
            // hide the button until the extent changes
            this._hideExtentSearchButton();
        }
        _hideExtentSearchButton() {
            if (this?._appConfig?.enableBufferSearch)
                return;
            (0, reactiveUtils_1.once)(() =&gt; this?.view?.navigating).then(() =&gt; {
                this?._mapButton?.classList.remove("hide");
            });
            (0, reactiveUtils_1.once)(() =&gt; this?.view?.interacting).then(() =&gt; {
                this?._mapButton?.classList.remove("hide");
            });
            (0, reactiveUtils_1.once)(() =&gt; this?.view?.scale).then(() =&gt; {
                this?._mapButton?.classList.remove("hide");
            });
            this?._mapButton?.classList.add("hide");
        }
        _updateMapVisibility(config) {
            // Hide the map when it is configured to display
            // without a map option
            const hide = config.hideMap;
            const hideMapClass = "no-map";
            const mapClassList = document.body.classList;
            hide ? mapClassList.add(hideMapClass) : mapClassList.remove(hideMapClass);
        }
        _cleanUpHandles() {
            // Remove configuration handles after load
            // if the app isn't within the config experience.
            if (!this._appConfig.withinConfigurationExperience) {
                this._handles.remove("configuration");
            }
        }
        _setMapViewRotation() {
            const view = this.view;
            const mapRotation = this._appConfig?.extentSelectorConfig?.mapRotation ?? this._defaultViewRotation ?? null;
            if (!view?.constraints?.rotationEnabled) {
                // if rotation is disabled
                view.constraints.rotationEnabled = true; // set rotation to enabled
                view.rotation = mapRotation; // set rotation value
                view.constraints.rotationEnabled = false; // set rotation back to disabled
            }
            else {
                if (view)
                    view.rotation = mapRotation;
            }
        }
    }
    return LocationApp;
});
</pre></body></html>