<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
 *   Copyright (c) 2022 Esri
 *   All rights reserved.

 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at

 *   http://www.apache.org/licenses/LICENSE-2.0

 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
var __assign = (this &amp;&amp; this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i &lt; n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this &amp;&amp; this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 (mod) {
    if (mod &amp;&amp; mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" &amp;&amp; Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this &amp;&amp; this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this &amp;&amp; this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] &amp; 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" &amp;&amp; (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y &amp;&amp; (t = op[0] &amp; 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) &amp;&amp; t.call(y), 0) : y.next) &amp;&amp; !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] &amp; 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length &gt; 0 &amp;&amp; t[t.length - 1]) &amp;&amp; (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 &amp;&amp; (!t || (op[1] &gt; t[0] &amp;&amp; op[1] &lt; t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 &amp;&amp; _.label &lt; t[1]) { _.label = t[1]; t = op; break; }
                    if (t &amp;&amp; _.label &lt; t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] &amp; 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
    return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "esri/core/promiseUtils", "esri/widgets/Expand", "TemplatesCommonLib/functionality/basemapToggle", "esri/geometry/support/jsonUtils", "esri/core/watchUtils"], function (require, exports, promiseUtils_1, Expand_1, basemapToggle_1, jsonUtils_1, watchUtils_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.addShare = exports.addSearch = exports.addBookmarks = exports.addScaleBar = exports.addScreenshot = exports.addZoom = exports.addHome = exports.addLocate = exports.addOverlay = exports.addBasemap = void 0;
    Expand_1 = __importDefault(Expand_1);
    function addBasemap(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, basemapTogglePosition, basemapToggle, node, _a, originalBasemap, nextBasemap, BasemapToggle, bmToggle;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        basemapTogglePosition = config.basemapTogglePosition, basemapToggle = config.basemapToggle;
                        node = view.ui.find("basemapWidget");
                        return [4 /*yield*/, basemapToggle_1.getBasemaps(props)];
                    case 1:
                        _a = _b.sent(), originalBasemap = _a.originalBasemap, nextBasemap = _a.nextBasemap;
                        // If basemapToggle isn't enabled remove the widget if it exists and exit 
                        if (!basemapToggle) {
                            if (node) {
                                view.ui.remove(node);
                                node.destroy();
                            }
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["esri/widgets/BasemapToggle"], resolve_1, reject_1); }).then(__importStar)];
                    case 2:
                        BasemapToggle = _b.sent();
                        if (!BasemapToggle)
                            return [2 /*return*/];
                        // Move the basemap toggle widget if it exists 
                        if (propertyName === "basemapTogglePosition" &amp;&amp; node) {
                            view.ui.move(node, basemapTogglePosition);
                        }
                        // Add the basemap toggle widget if its enabled or if a different basemap was 
                        // specified
                        if (propertyName === "basemapToggle" &amp;&amp; !node) {
                            bmToggle = new BasemapToggle.default({
                                view: view,
                                nextBasemap: nextBasemap,
                                id: "basemapWidget"
                            });
                            basemapToggle_1.resetBasemapsInToggle(bmToggle, originalBasemap, nextBasemap);
                            view.ui.add(bmToggle, basemapTogglePosition);
                        }
                        else if (node &amp;&amp; (propertyName === "nextBasemap" || propertyName === "basemapSelector")) {
                            if (propertyName === "nextBasemap" || propertyName === "basemapSelector") {
                                basemapToggle_1.resetBasemapsInToggle(node, originalBasemap, nextBasemap);
                            }
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addBasemap = addBasemap;
    function _findNode(className) {
        var mainNodes = document.getElementsByClassName(className);
        var node = null;
        for (var j = 0; j &lt; mainNodes.length; j++) {
            node = mainNodes[j];
        }
        return node ? node : null;
    }
    function _getBasemap(id) {
        return __awaiter(this, void 0, void 0, function () {
            var Basemap, basemap;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(["esri/Basemap"], resolve_2, reject_2); }).then(__importStar)];
                    case 1:
                        Basemap = _a.sent();
                        if (!Basemap) {
                            return [2 /*return*/];
                        }
                        basemap = Basemap.default.fromId(id);
                        if (!!basemap) return [3 /*break*/, 3];
                        return [4 /*yield*/, new Basemap.default({
                                portalItem: {
                                    id: id
                                }
                            }).loadAll()];
                    case 2:
                        basemap = _a.sent();
                        _a.label = 3;
                    case 3: return [2 /*return*/, basemap];
                }
            });
        });
    }
    function addOverlay(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, disableScroll, node, ScrollOverlay, overlay;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, config = props.config;
                        disableScroll = config.disableScroll;
                        node = _findNode("scroll-overlay");
                        if (!!disableScroll) return [3 /*break*/, 1];
                        if (node)
                            view.ui.remove(node);
                        // update view nav 
                        view.navigation.mouseWheelZoomEnabled = true;
                        view.navigation.browserTouchPanEnabled = true;
                        return [2 /*return*/];
                    case 1: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(["../ui/ScrollOverlay"], resolve_3, reject_3); }).then(__importStar)];
                    case 2:
                        ScrollOverlay = _a.sent();
                        overlay = new ScrollOverlay.default(__assign(__assign({}, props), { container: document.createElement("div") }));
                        view.ui.add(overlay, "manual");
                        _a.label = 3;
                    case 3: return [2 /*return*/];
                }
            });
        });
    }
    exports.addOverlay = addOverlay;
    function addLocate(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, locateWidget, locateWidgetPosition, Locate, node;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        locateWidget = config.locateWidget, locateWidgetPosition = config.locateWidgetPosition;
                        return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['esri/widgets/Locate'], resolve_4, reject_4); }).then(__importStar)];
                    case 1:
                        Locate = _a.sent();
                        node = _findNode("esri-locate");
                        if (!locateWidget) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*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") {
                            view.ui.add(new Locate.default({ view: view }), locateWidgetPosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addLocate = addLocate;
    function addHome(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, home, homePosition, node, Home;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        home = config.home, homePosition = config.homePosition;
                        node = _findNode("esri-home");
                        if (!home) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(["esri/widgets/Home"], resolve_5, reject_5); }).then(__importStar)];
                    case 1:
                        Home = _a.sent();
                        if (node &amp;&amp; !home)
                            view.ui.remove(node);
                        if (propertyName === "homePosition" &amp;&amp; node) {
                            view.ui.move(node, homePosition);
                        }
                        else if (propertyName === "home") {
                            view.ui.add(new Home.default({ view: view }), homePosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addHome = addHome;
    function addZoom(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, mapZoom, mapZoomPosition, node, Zoom;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        mapZoom = config.mapZoom, mapZoomPosition = config.mapZoomPosition;
                        node = _findNode("esri-zoom");
                        if (!mapZoom) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        if (node &amp;&amp; !mapZoom)
                            view.ui.remove(node);
                        return [4 /*yield*/, new Promise(function (resolve_6, reject_6) { require(["esri/widgets/Zoom"], resolve_6, reject_6); }).then(__importStar)];
                    case 1:
                        Zoom = _a.sent();
                        if (propertyName === "mapZoomPosition" &amp;&amp; node) {
                            view.ui.move(node, mapZoomPosition);
                        }
                        else if (propertyName === "mapZoom" &amp;&amp; !node) {
                            view.ui.add(new Zoom.default({ view: view }), mapZoomPosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addZoom = addZoom;
    function addScreenshot(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, screenshot, screenshotPosition, legendPanel, popupPanel, popupHover, node, Screenshot, group, content, tip, screenshotExpand;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        screenshot = config.screenshot, screenshotPosition = config.screenshotPosition, legendPanel = config.legendPanel, popupPanel = config.popupPanel, popupHover = config.popupHover;
                        node = view.ui.find("screenshotExpand");
                        if (!screenshot) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, new Promise(function (resolve_7, reject_7) { require(["Components/Screenshot/Screenshot"], resolve_7, reject_7); }).then(__importStar)];
                    case 1:
                        Screenshot = _a.sent();
                        group = _getPosition(screenshotPosition);
                        if (propertyName === "screenshotPosition" &amp;&amp; node) {
                            view.ui.move(node, screenshotPosition);
                            node.group = group;
                        }
                        else if (propertyName === "screenshot") {
                            content = new Screenshot.default({
                                view: view,
                                enableLegendOption: legendPanel ? true : false,
                                enablePopupOption: (popupPanel || popupHover) ? false : true,
                                includeLayoutOption: (popupPanel || popupHover) ? false : true,
                                includePopupInScreenshot: false,
                                includeLegendInScreenshot: legendPanel ? true : false
                            });
                            tip = "" + config.bundle.tools.screenshot;
                            screenshotExpand = new Expand_1.default({
                                id: "screenshotExpand",
                                content: content,
                                group: group,
                                mode: "floating",
                                expandTooltip: tip,
                                collapseTooltip: tip,
                                view: view
                            });
                            view.ui.add(screenshotExpand, screenshotPosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addScreenshot = addScreenshot;
    function addScaleBar(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, portal, config, propertyName, scalebar, scalebarPosition, node, ScaleBar;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        view = props.view, portal = props.portal, config = props.config, propertyName = props.propertyName;
                        scalebar = config.scalebar, scalebarPosition = config.scalebarPosition;
                        node = _findNode("esri-scale-bar");
                        if (!scalebar) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, new Promise(function (resolve_8, reject_8) { require(["esri/widgets/ScaleBar"], resolve_8, reject_8); }).then(__importStar)];
                    case 1:
                        ScaleBar = _a.sent();
                        if (propertyName === "scalebarPosition" &amp;&amp; node) {
                            view.ui.move(node, scalebarPosition);
                        }
                        else if (propertyName === "scalebar") {
                            view.ui.add(new ScaleBar.default({
                                view: view,
                                unit: (portal === null || portal === void 0 ? void 0 : portal.units) === "metric" ? portal === null || portal === void 0 ? void 0 : portal.units : "non-metric"
                            }), scalebarPosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addScaleBar = addScaleBar;
    function addBookmarks(props) {
        var _a;
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, bookmarks, bookmarksPosition, bookmarkThumbnail, node, map, mapContainsBookmarks, modules, _b, Bookmarks, Expand, group, content, tip, bookmarksExpand, bm;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        bookmarks = config.bookmarks, bookmarksPosition = config.bookmarksPosition, bookmarkThumbnail = config.bookmarkThumbnail;
                        node = view.ui.find("bookmarksExpand");
                        map = view.map;
                        mapContainsBookmarks = ((_a = map === null || map === void 0 ? void 0 : map.bookmarks) === null || _a === void 0 ? void 0 : _a.length) &gt; 0 ? true : false;
                        if (!bookmarks || !mapContainsBookmarks) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, promiseUtils_1.eachAlways([new Promise(function (resolve_9, reject_9) { require(["esri/widgets/Bookmarks"], resolve_9, reject_9); }).then(__importStar), new Promise(function (resolve_10, reject_10) { require(["esri/widgets/Expand"], resolve_10, reject_10); }).then(__importStar)])];
                    case 1:
                        modules = _c.sent();
                        _b = modules.map(function (module) { return module.value; }), Bookmarks = _b[0], Expand = _b[1];
                        group = _getPosition(bookmarksPosition);
                        if (propertyName === "bookmarksPosition" &amp;&amp; node) {
                            view.ui.move(node, bookmarksPosition);
                            node.group = group;
                        }
                        else if (propertyName === "bookmarks") {
                            content = new Bookmarks.default({
                                view: view,
                                viewModel: {
                                    view: view,
                                    abilities: { time: false }
                                },
                                visibleElements: {
                                    thumbnail: bookmarkThumbnail === false ? false : true
                                }
                            });
                            tip = "" + config.bundle.tools.bookmarks;
                            bookmarksExpand = new Expand.default({
                                id: "bookmarksExpand",
                                content: content,
                                group: group,
                                mode: "floating",
                                expandTooltip: tip,
                                collapseTooltip: tip,
                                view: view
                            });
                            view.ui.add(bookmarksExpand, bookmarksPosition);
                        }
                        else if (propertyName === "bookmarkThumbnail" &amp;&amp; node) {
                            bm = node.content;
                            if (bm === null || bm === void 0 ? void 0 : bm.visibleElements)
                                bm.visibleElements = { thumbnail: bookmarkThumbnail };
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addBookmarks = addBookmarks;
    function addSearch(props) {
        var _a;
        return __awaiter(this, void 0, void 0, function () {
            var view, portal, config, propertyName, search, popupHover, popupPanel, searchPosition, searchOpenAtStart, extentSelector, extentSelectorConfig, searchConfiguration, node, modules, _b, Search, FeatureLayer, Expand, group, sources, extent_1, geometry, content_1, tip, searchExpand;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        view = props.view, portal = props.portal, config = props.config, propertyName = props.propertyName;
                        search = config.search, popupHover = config.popupHover, popupPanel = config.popupPanel, searchPosition = config.searchPosition, searchOpenAtStart = config.searchOpenAtStart, extentSelector = config.extentSelector, extentSelectorConfig = config.extentSelectorConfig;
                        searchConfiguration = config.searchConfiguration;
                        node = view.ui.find("searchExpand");
                        if (!search) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, promiseUtils_1.eachAlways([new Promise(function (resolve_11, reject_11) { require(["esri/widgets/Search"], resolve_11, reject_11); }).then(__importStar), new Promise(function (resolve_12, reject_12) { require(["esri/layers/FeatureLayer"], resolve_12, reject_12); }).then(__importStar), new Promise(function (resolve_13, reject_13) { require(["esri/widgets/Expand"], resolve_13, reject_13); }).then(__importStar)])];
                    case 1:
                        modules = _c.sent();
                        _b = modules.map(function (module) { return module.value; }), Search = _b[0], FeatureLayer = _b[1], Expand = _b[2];
                        if (!Search || !FeatureLayer || !Expand)
                            return [2 /*return*/];
                        group = _getPosition(searchPosition);
                        if (propertyName === "searchPosition" &amp;&amp; node) {
                            // move the node if it exists we have to type as any here 
                            // due to a doc issue with move once index is doc'd remove 
                            view.ui.move(node, searchPosition);
                            node.group = group;
                        }
                        else if (propertyName === "searchOpenAtStart" &amp;&amp; node) {
                            node.expanded = searchOpenAtStart;
                        }
                        else if (propertyName === "search" || (propertyName === "extentSelector" &amp;&amp; node) || (node &amp;&amp; propertyName === "extentSelector") || (propertyName === "searchConfiguration" &amp;&amp; node)) {
                            if (node)
                                view.ui.remove(node);
                            sources = searchConfiguration === null || searchConfiguration === void 0 ? void 0 : searchConfiguration.sources;
                            if (sources) {
                                extent_1 = null;
                                if (extentSelector) {
                                    geometry = ((_a = extentSelectorConfig === null || extentSelectorConfig === void 0 ? void 0 : extentSelectorConfig.constraints) === null || _a === void 0 ? void 0 : _a.geometry) || null;
                                    if (geometry) {
                                        extent_1 = jsonUtils_1.fromJSON(geometry);
                                    }
                                }
                                sources.forEach(function (source) {
                                    var _a, _b, _c;
                                    var sourceLayer = null;
                                    if ((_a = source === null || source === void 0 ? void 0 : source.layer) === null || _a === void 0 ? void 0 : _a.id)
                                        sourceLayer = view.map.findLayerById(source.layer.id);
                                    if (!sourceLayer &amp;&amp; ((_b = source === null || source === void 0 ? void 0 : source.layer) === null || _b === void 0 ? void 0 : _b.url)) {
                                        sourceLayer = new FeatureLayer.default((_c = source === null || source === void 0 ? void 0 : source.layer) === null || _c === void 0 ? void 0 : _c.url);
                                    }
                                    source.outFields = ["*"];
                                    source.layer = sourceLayer;
                                    if (extent_1 &amp;&amp; ((extent_1 === null || extent_1 === void 0 ? void 0 : extent_1.type) === "extent" || (extent_1 === null || extent_1 === void 0 ? void 0 : extent_1.type) === "polygon")) {
                                        source.filter = {
                                            geometry: extent_1
                                        };
                                    }
                                    else {
                                        source.filter = null;
                                    }
                                });
                            }
                            if (searchConfiguration === undefined || searchConfiguration === null) {
                                searchConfiguration = {
                                    includeDefaultSources: true
                                };
                            }
                            content_1 = new Search.default(__assign({ view: view,
                                portal: portal }, searchConfiguration));
                            content_1.on("search-complete", function () {
                                if (content_1.popupEnabled) {
                                    // Handle setting focus on popup and then back 
                                    // to search box 
                                    if (popupHover)
                                        view.popup.autoOpenEnabled = true;
                                    watchUtils_1.whenTrueOnce(view.popup.viewModel, "active", function () {
                                        view.popup.focus();
                                        watchUtils_1.whenFalseOnce(view.popup, "visible", function () {
                                            content_1.focus();
                                            if (popupHover)
                                                view.popup.autoOpenEnabled = false;
                                        });
                                    });
                                }
                                if (popupPanel) {
                                    var clickHandler_1 = view.on("click", function () {
                                        clickHandler_1.remove();
                                        if (content_1.searchTerm) {
                                            content_1.clear();
                                        }
                                        ;
                                    });
                                }
                            });
                            tip = "" + config.bundle.tools.search;
                            searchExpand = new Expand.default({
                                expanded: searchOpenAtStart,
                                id: "searchExpand",
                                content: content_1,
                                group: group,
                                collapseTooltip: tip,
                                expandTooltip: tip,
                                mode: "floating",
                                view: view
                            });
                            view.ui.add(searchExpand, searchPosition);
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addSearch = addSearch;
    function addShare(props) {
        return __awaiter(this, void 0, void 0, function () {
            var view, config, propertyName, share, shareIncludeSocial, header, theme, node, modules, _a, Share, ShareFeatures, shareFeatures, container, shareWidget, container;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        view = props.view, config = props.config, propertyName = props.propertyName;
                        share = config.share, shareIncludeSocial = config.shareIncludeSocial, header = config.header, theme = config.theme;
                        node = view.ui.find("shareMap");
                        // Remove the widget if share isdisabled or if header is enabled
                        if (!share || (header &amp;&amp; node)) {
                            if (node)
                                view.ui.remove(node);
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, promiseUtils_1.eachAlways([new Promise(function (resolve_14, reject_14) { require(["../ui/Share/Share"], resolve_14, reject_14); }).then(__importStar), new Promise(function (resolve_15, reject_15) { require(["../ui/Share/Share/ShareFeatures"], resolve_15, reject_15); }).then(__importStar)])];
                    case 1:
                        modules = _b.sent();
                        _a = modules.map(function (module) { return module.value; }), Share = _a[0], ShareFeatures = _a[1];
                        if (!Share &amp;&amp; !ShareFeatures)
                            return [2 /*return*/];
                        // Only add sharing to view if header is false 
                        if ((propertyName === "share" || propertyName === "header") &amp;&amp; !header &amp;&amp; !node) {
                            shareFeatures = new ShareFeatures.default({
                                copyToClipboard: true,
                                embedMap: false,
                                shareServices: shareIncludeSocial
                            });
                            container = document.createElement("div");
                            container.classList.add("esri-map-share");
                            container.classList.add(theme);
                            container.id = "shareMap";
                            shareWidget = new Share.default({
                                config: config,
                                view: view,
                                shareFeatures: shareFeatures,
                                theme: theme,
                                container: container,
                                isDefault: true
                            });
                            if (!view.ui.find("shareMap")) {
                                view.ui.add(shareWidget, "top-right");
                            }
                        }
                        else if (propertyName === "shareIncludeSocial" &amp;&amp; node) {
                            node.shareFeatures.shareServices = shareIncludeSocial;
                        }
                        else if (propertyName === "theme") {
                            // Change view theme 
                            if (node)
                                node.theme = theme;
                            container = document.getElementsByClassName("esri-map-share");
                            if ((container === null || container === void 0 ? void 0 : container.length) &gt; 0) {
                                container[0].classList.remove(theme === "dark" ? "light" : "dark");
                                container[0].classList.add(theme);
                            }
                        }
                        return [2 /*return*/];
                }
            });
        });
    }
    exports.addShare = addShare;
    function _getPosition(position) {
        // object or string 
        var groupName = null;
        if (typeof position === "string") {
            groupName = position;
        }
        else if (position === null || position === void 0 ? void 0 : position.position) {
            groupName = position.position;
        }
        return groupName;
    }
});
</pre></body></html>