UNPKG

@arcgis/map-components

Version:
557 lines (556 loc) • 37.9 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { c as D } from "../../chunks/runtime.js"; import { css as U, html as o } from "lit"; import { ref as w } from "lit/directives/ref.js"; import { keyed as F } from "lit/directives/keyed.js"; import C from "@arcgis/core/webmap/Bookmark.js"; import T from "@arcgis/core/core/Collection.js"; import v from "@arcgis/core/core/Error.js"; import A from "@arcgis/core/webdoc/support/SlideThumbnail.js"; import O from "@arcgis/core/Viewpoint.js"; import "@arcgis/core/WebMap.js"; import { LitElement as z, createEvent as B, nothing as x, safeClassMap as L } from "@arcgis/lumina"; import { H as N } from "../../chunks/heading.js"; import V from "@arcgis/core/core/Accessor.js"; import { property as p, subclass as R } from "@arcgis/core/core/accessorSupport/decorators.js"; import { isHTTPSProtocol as f, isDataProtocol as y } from "@arcgis/core/core/urlUtils.js"; import { c as P } from "../../chunks/goTo.js"; import { classes as q } from "@arcgis/toolkit/dom"; import { formatDate as S, convertDateFormatToIntlOptions as I } from "@arcgis/core/intl.js"; import { generateGuid as Z } from "@arcgis/toolkit/string"; import { s as j } from "../../chunks/sr.js"; import { usePropertyChange as H } from "@arcgis/lumina/controllers"; import { u as M } from "../../chunks/useT9n.js"; import { u as G } from "../../chunks/useView.js"; import { watch as $ } from "@arcgis/core/core/reactiveUtils.js"; var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, g = (s, e, t, i) => { for (var r = i > 1 ? void 0 : i ? K(e, t) : e, a = s.length - 1, n; a >= 0; a--) (n = s[a]) && (r = (i ? n(e, t, r) : n(r)) || r); return i && r && J(e, t, r), r; }; let u = class extends V { constructor(s) { super(s); } get editedBookmark() { const { bookmark: s } = this; return s ? this._get("editedBookmark") || s.clone() : null; } get customUrl() { if (this._customUrl) return this._customUrl; const s = this.editedBookmark?.thumbnail?.url ?? ""; return s ?? (f(s) ? s : null); } set customUrl(s) { this._customUrl = s; } get screenshotUrl() { if (this._screenshotUrl) return this._screenshotUrl; const s = this.editedBookmark?.thumbnail?.url ?? ""; return s ?? (y(s) ? s : null); } set screenshotUrl(s) { this._screenshotUrl = s; } get state() { return this._get("state"); } set state(s) { this.validationState = void 0, this.creatingBookmark = void 0, this._set("state", s); } get thumbnailState() { if (this._thumbnailState) return this._thumbnailState; const s = this.editedBookmark?.thumbnail?.url; return s ? f(s) ? "url" : "screenshot" : "none"; } set thumbnailState(s) { this._thumbnailState = s; } }; g([ p() ], u.prototype, "bookmark", 2); g([ p({ readOnly: !0 }) ], u.prototype, "editedBookmark", 1); g([ p() ], u.prototype, "_customUrl", 2); g([ p() ], u.prototype, "customUrl", 1); g([ p() ], u.prototype, "_screenshotUrl", 2); g([ p() ], u.prototype, "screenshotUrl", 1); g([ p() ], u.prototype, "state", 1); g([ p() ], u.prototype, "_thumbnailState", 2); g([ p() ], u.prototype, "thumbnailState", 1); g([ p() ], u.prototype, "validationState", 2); g([ p() ], u.prototype, "creatingBookmark", 2); u = g([ R("UserState") ], u); const Q = U`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden}:host{display:flex}.root{display:flex;flex:1 1 auto;overflow:hidden auto;transition:max-height .25s ease-in-out}:host([closed]) .root{display:none}.empty{display:flex;flex-flow:column wrap;align-items:center;padding:var(--calcite-spacing-md) var(--calcite-spacing-lg);text-align:center;color:var(--calcite-color-text-1)}.root .arcgis-widget__content--empty{background-color:var(--calcite-color-foreground-2)}.root calcite-flow-item[loading]{min-height:150px}.loader{margin-inline-end:0}.filter-no-results{padding:var(--calcite-spacing-md) var(--calcite-spacing-lg)}.bookmark-image-container{display:flex;position:relative;margin:0;margin-inline-start:var(--calcite-spacing-xs);min-width:16px;min-height:16px}.bookmark-image-container .bookmark-image{max-width:64px;overflow:hidden}.drag-enabled .bookmark-image-container{margin-inline-start:0}.no-bookmarks-heading{margin:0;margin-block-start:var(--calcite-spacing-md);font-size:var(--calcite-font-size-md);line-height:var(--calcite-font-line-height-relative-tight);font-weight:var(--calcite-font-weight-regular)}.authoring{display:flex;flex-direction:column}.authoring-image-container{display:flex;align-items:middle;justify-content:center;margin-block-end:var(--calcite-spacing-md);margin-inline-end:var(--calcite-spacing-lg);background-image:repeating-conic-gradient(#ccc 0% 25%,#fff 0% 50%);background-position:0 0,10px 10px;background-size:20px 20px;background-color:#fff;width:128px;height:128px;text-align:center}.authoring-image-container .bookmark-image{max-width:128px;max-height:128px}.form{display:flex;height:100%}.form-content{padding-block:var(--calcite-spacing-md);padding-inline:var(--calcite-spacing-lg)}.authoring-refresh-thumbnail-button{margin-block-end:var(--calcite-spacing-md)}.bookmark-content-label{color:var(--calcite-color-text-1);font-size:var(--calcite-font-size-sm);line-height:var(--calcite-font-line-height-relative-normal)}.bookmark-content calcite-table{margin-inline-start:-.25rem}.bookmark-content calcite-table,.bookmark-content calcite-table-row{--calcite-table-border-color: transparent;--calcite-color-text-1: var(--calcite-color-text-3);--calcite-table-row-background-color: transparent;pointer-events:none}`, W = T.ofType(C), X = { width: 128, height: 128, format: "png" }, E = { takeScreenshot: !0, captureViewpoint: !0, captureRotation: !0, captureScale: !0, captureTimeExtent: !0 }; class Y extends z { constructor() { super(...arguments), this._bookmarks = null, this._defaultCreateOptions = { ...E }, this._defaultEditOptions = { ...E }, this._defaultBookmarks = new W(), this._guid = Z(), this._addInputNode = null, this._editInputNode = null, this._urlEditInputNode = null, this._lastDragDetail = null, this.messages = M({}), this._storeEditFlowItemNode = (e) => { this._editFlowItemEl = e; }, this._storeRootFlowItem = (e) => { this._rootFlowItemEl = e; }, this._storeAddFlowItemNode = (e) => { this._addFlowItemEl = e; }, this._updateTimeExtentLayout = (e) => { const t = e[0]?.contentRect.width; this._useStackedTimeExtentRows = (t ?? 0) < 300; }, this._activeBookmark = null, this._userState = null, this._userCreatingBookmark = !1, this.editIncludeTimeExtent = !1, this._useStackedTimeExtentRows = !1, this.view = G(this), this.icon = "bookmark", this.closed = !1, this.disabled = !1, this.dragEnabled = !1, this.filterPlaceholder = "", this.filterText = "", this.headingLevel = 2, this.showAddBookmarkButton = !1, this.showCloseButton = !1, this.showCollapseButton = !1, this.showEditBookmarkButton = !1, this.showFilter = !1, this.showHeading = !1, this.hideThumbnail = !1, this.hideTime = !1, this.timeDisabled = !1, this.autoDestroyDisabled = !1, this.state = this._state, this.arcgisBookmarkEdit = B(), this.arcgisBookmarkSelect = B(), this.arcgisPropertyChange = H()("state"), this.arcgisReady = B(), this.arcgisClose = B(); } static { this.properties = { _bookmarkSelectedMessage: 16, _activeBookmark: 16, _userState: 16, _userStateValue: 16, _userValidationState: 16, _userThumbnailState: 16, _userCreatingBookmark: 16, editIncludeTimeExtent: 16, _useStackedTimeExtentRows: 16, _state: 16, view: 0, referenceElement: 1, icon: 1, closed: 7, defaultCreateOptions: 0, defaultEditOptions: 0, bookmarks: [1, { type: T }], disabled: 5, dragEnabled: 5, filterPlaceholder: 1, filterText: 1, headingLevel: 9, goToOverride: 0, showAddBookmarkButton: 5, showCloseButton: 5, showCollapseButton: 5, showEditBookmarkButton: 5, showFilter: 5, showHeading: 5, hideThumbnail: 5, hideTime: 5, timeDisabled: 5, autoDestroyDisabled: 5, messageOverrides: 0, label: 1, state: 32 }; } static { this.styles = [Q, j]; } get _state() { const { view: e } = this; return e && !e.ready ? "loading" : "ready"; } get defaultCreateOptions() { return this._defaultCreateOptions; } set defaultCreateOptions(e) { this._defaultCreateOptions = { ...E, ...e }; } get defaultEditOptions() { return this._defaultEditOptions; } set defaultEditOptions(e) { this._defaultEditOptions = { ...E, ...e }; } get bookmarks() { return this._bookmarks ?? this.view?.map?.bookmarks ?? this._defaultBookmarks; } set bookmarks(e) { this._bookmarks = T.isCollection(e) ? e : new T(e); } async destroy() { await this.manager.destroy(), this._activeBookmark = null; } goTo(e) { const { view: t } = this; if (!t) throw new v("go-to:invalid-view", "Cannot go to a bookmark without a view"); const i = e?.viewpoint; if (!i) throw new v("go-to:invalid-bookmark", "Cannot go to a bookmark that does not contain a 'viewpoint'.", { bookmark: e }); this._activeBookmark = e; const r = P({ target: i }, t, this.goToOverride), a = e?.timeExtent; return !this.timeDisabled && a && (t.timeExtent = a), this.arcgisBookmarkSelect.emit({ bookmark: e }), this._bookmarkSelectedMessage = this.messages?.bookmarkSelected?.replace("{bookmarkName}", e.name), r.catch(() => { }).then(() => this._activeBookmark = null), r; } connectedCallback() { super.connectedCallback(), this._resizeObserver = new ResizeObserver(this._updateTimeExtentLayout), this._resizeObserver.observe(this.el); } loaded() { this.manager.onLifecycle(() => [ $(() => this._userState?.state, (e) => this._userStateValue = e, { initial: !0 }), $(() => this._userState?.validationState, (e) => this._userValidationState = e, { initial: !0 }), $(() => this._userState?.thumbnailState, (e) => this._userThumbnailState = e, { initial: !0 }), $(() => this._userState?.creatingBookmark, (e) => this._userCreatingBookmark = !!e, { initial: !0 }) ]); } disconnectedCallback() { this._resizeObserver?.disconnect(), this._resizeObserver = void 0, super.disconnectedCallback(); } async _createBookmark(e) { const { view: t, defaultCreateOptions: i } = this; if (!t) throw new v("create-bookmark:invalid-view", "Cannot create a bookmark without a view."); const { takeScreenshot: r, screenshotSettings: a, captureViewpoint: n, captureRotation: c, captureScale: d, captureTimeExtent: m } = { ...i, ...e }, l = r ? await this._createThumbnail(a) : void 0, h = !this.timeDisabled && m && t.timeExtent != null ? t.timeExtent.clone() : void 0; return new C({ ...l && { thumbnail: l }, ...m && { timeExtent: h }, ...n && { viewpoint: this._createViewpoint({ view: t, captureScale: d, captureRotation: c }) } }); } async _editBookmark(e, t) { if (!e) return e; const { view: i, defaultEditOptions: r } = this; if (!i) throw new v("edit-bookmark:invalid-view", "Cannot edit a bookmark without a view."); const { takeScreenshot: a, screenshotSettings: n, captureViewpoint: c, captureRotation: d, captureScale: m, captureTimeExtent: l } = { ...r, ...t }, h = a ? await this._createThumbnail(n) : void 0; return h && (e.thumbnail = h), c && (e.viewpoint = this._createViewpoint({ view: i, captureScale: m, captureRotation: d })), l && i.timeExtent != null && (e.timeExtent = i.timeExtent.clone()), this.arcgisBookmarkEdit.emit({ bookmark: e }), e; } async _createThumbnail(e) { const { view: t } = this; if (!t) throw new v("bookmark:invalid-view", "Cannot create slide thumbnail without a view"); const i = await t.takeScreenshot({ ...X, ...e }); return new A({ url: i.dataUrl }); } _createViewpoint({ view: e, captureRotation: t, captureScale: i }) { const r = e.viewpoint?.clone(); return new O({ targetGeometry: e.extent?.clone(), rotation: (t ? r?.rotation : null) ?? 0, scale: (i ? r?.scale : null) ?? 0 }); } _handleClose() { this.closed = !0, this.arcgisClose.emit(); } startAddBookmark() { this._userState = new u({ state: "add" }), requestAnimationFrame(() => { this._addFlowItemEl?.setFocus(); }); } _clearState() { this._userState = null; } _getTimeExtentStrings(e) { const { hideTime: t } = this, { timeExtent: i } = e; if (!i) return {}; const { start: r, end: a } = i, n = a != null && r?.getTime() !== a.getTime(), c = r ? this._formatDate(r) : "", d = r && !t ? this._formatTime(r) : ""; if (!n) return { startDate: c, startTime: d }; const m = this._formatDate(a), l = t ? "" : this._formatTime(a); return { startDate: c, startTime: d, endDate: m, endTime: l }; } _handleUrlEditInputChange() { const { _userState: e, _urlEditInputNode: t } = this, i = t?.value; if (!e?.editedBookmark || !i) return; e.validationState = void 0, y(e.editedBookmark.thumbnail?.url ?? "") && (e.screenshotUrl = e.editedBookmark.thumbnail?.url); const r = { url: i }; f(r.url) && (e.customUrl = i, e.editedBookmark.thumbnail = r); } _getBookmarkTitle(e) { return (e?.name || this.messages.untitled) ?? ""; } _formatDate(e) { if (!e) return ""; const t = this.view, i = t && "timeZone" in t ? t.timeZone : "system"; return S(e, { ...I("short-date"), timeZone: i }); } _formatTime(e) { if (!e) return ""; const t = this.view, i = t && "timeZone" in t ? t.timeZone : "system"; return S(e, { ...I("long-time"), timeZone: i }); } _onCalciteListOrderChange(e) { const { _lastDragDetail: t, bookmarks: i } = this, { toEl: r, fromEl: a, dragEl: n, newIndex: c } = e; if (!i.length) return; const d = t?.newIndex === c && t?.dragEl === n && t?.toEl === r && t?.fromEl === a; if (!a || !r || d) return; this._lastDragDetail = e; const m = Array.from(a.children).filter((l) => l?.matches("calcite-list-item")).map((l) => l.value); i.sort((l, h) => { const k = m.indexOf(l.uid), b = m.indexOf(h.uid); return k > b ? 1 : k < b ? -1 : 0; }); } _endAddBookmark() { this._clearState(), this._focusRootFlowItem(); } _showEditBookmarkForm(e) { e && (this.editIncludeTimeExtent = !!e.timeExtent, this._userState = new u({ bookmark: e, state: "edit" }), requestAnimationFrame(() => { this._editFlowItemEl?.setFocus(); }), this.goTo(e)); } async _createNewScreenshotUrl() { return (await this._createBookmark()).thumbnail?.url ?? null; } _storeCurrentUrl() { const { _userState: e } = this, t = e?.editedBookmark?.thumbnail?.url; t && (f(t) ? e.customUrl = t : y(t) && (e.screenshotUrl = t)); } async _handleThumbnailTypeSelect(e) { const { _userState: t } = this; if (!t) return; const { screenshotUrl: i, customUrl: r, editedBookmark: a } = t, n = e === "screenshot" ? i ?? await this._createNewScreenshotUrl() : e === "url" && r ? r : null; this._storeCurrentUrl(), a && n && (a.thumbnail = { url: n }), t.validationState = void 0, t.thumbnailState = e; } _focusRootFlowItem() { requestAnimationFrame(() => { this._rootFlowItemEl?.setFocus(); }); } _closeEditBookmarkForm() { this._clearState(), this._focusRootFlowItem(); } _addBookmarkSubmitClick(e) { e.preventDefault(), this._addBookmarkSubmit(); } async _addBookmarkSubmit() { const { _addInputNode: e, _userState: t, bookmarks: i } = this; if (!t) return; const r = e ? e.value.trim() : null; if (!r) { t.validationState = "name-required"; return; } t.creatingBookmark = !0; const a = await this._createBookmark(); a.name = r, i.add(a), this._endAddBookmark(); } async _editBookmarkAndClose(e, t) { const { defaultEditOptions: i } = this; await this._editBookmark(e, { ...i, ...t }), this._closeEditBookmarkForm(); } _editBookmarkSubmit(e) { e.preventDefault(); const { _userState: t, _editInputNode: i, editIncludeTimeExtent: r, _urlEditInputNode: a } = this; if (!t?.bookmark || !t.editedBookmark) return; t.validationState = void 0, t.customUrl = void 0, t.screenshotUrl = void 0; const n = i?.value.trim(); if (!n) { t.validationState = "name-required"; return; } if (t.bookmark.name = n, t.bookmark.thumbnail = t.editedBookmark.thumbnail, r || (t.bookmark.timeExtent = null), t.thumbnailState === "url" && a) { const d = { url: a.value }; if (!f(d.url)) { t.validationState = "absolute-url-required"; return; } t.bookmark.thumbnail = d; } else t.thumbnailState === "none" && (t.bookmark.thumbnail = null); this._editBookmarkAndClose(t.bookmark, { takeScreenshot: !1, captureTimeExtent: r }); } _storeEditInput(e) { this._editInputNode = e; } _storeAddInput(e) { this._addInputNode = e; } _storeUrlEditInput(e) { this._urlEditInputNode = e; } _deleteBookmark(e) { this._closeEditBookmarkForm(), e && (this.bookmarks.remove(e), e.destroy()); } _goToBookmark(e) { this._clearState(), this.goTo(e); } async _updateThumbnail() { const { _userState: e } = this; e && (e.validationState = void 0, await this._editBookmark(e.editedBookmark, { takeScreenshot: !0, captureViewpoint: !1, captureRotation: !1, captureScale: !1, captureTimeExtent: !1 })); } _handleCalciteListDragEnd(e) { const { fromEl: t, dragEl: i, oldIndex: r } = e; r == null || !t || !i || t.insertBefore(i, t.children[r]); } render() { return o`<div class="root"><div class="sr-only" aria-live=polite>${this._bookmarkSelectedMessage}</div>${this._renderBookmarksContainer()}</div>`; } _renderNoBookmarksContainer(e) { const { messages: t, _state: i } = this; return !e.length && i !== "loading" ? o`<div class="empty"><calcite-icon .icon=${this.icon} scale=l></calcite-icon>${N({ class: "no-bookmarks-heading", level: this.headingLevel, children: t.noBookmarksHeading })}<p class="no-bookmarks-description">${t.noBookmarksDescription}</p></div>` : null; } _renderEditBookmarkFlowItems() { const e = this._userStateValue === "edit", t = this._userState?.editedBookmark; return !t || !e ? [] : this._renderEditingBookmark(t); } _renderBookmarkItems(e) { return e ? e.toArray().map((t) => this._renderBookmark(t)) : []; } _renderBookmarksContainer() { const { _state: e, bookmarks: t, dragEnabled: i, messages: r, disabled: a, filterPlaceholder: n, filterText: c, closed: d, headingLevel: m } = this, l = t.filter((_) => _ != null), k = l.length ? o`<calcite-list class="list" display-mode=flat .dragEnabled=${i} .filterEnabled=${this.showFilter} .filterPlaceholder=${n} .filterProps=${["label", "description", "metadata"]} .filterText=${c} .group=${`bookmarks-${this._guid}`} .label=${r.componentLabel ?? ""} selection-appearance=border selection-mode=none @calciteListDragEnd=${(_) => this._handleCalciteListDragEnd(_.detail)} @calciteListFilter=${(_) => this.filterText = _.currentTarget?.filterText ?? ""} @calciteListOrderChange=${(_) => this._onCalciteListOrderChange(_.detail)}>${this._renderBookmarkItems(l)}${this.showFilter ? o`<div class="filter-no-results" slot=filter-no-results><calcite-notice kind=info open width=full><div slot=message>${r.noBookmarksHeading}</div>;</calcite-notice></div>` : null}</calcite-list>` : null, b = [ o`<calcite-flow-item .closable=${this.showCloseButton} .closed=${d} .collapsible=${this.showCollapseButton} .disabled=${a} .heading=${this.showHeading ? r.componentLabel : void 0} .headingLevel=${m} .loading=${e === "loading"} .selected=${!this._userStateValue} @calciteFlowItemClose=${this._handleClose} ${w(this._storeRootFlowItem)}>${this._renderNoBookmarksContainer(l)}${k}${this._renderAddBookmarkButton()}</calcite-flow-item>`, this._renderAddingBookmark(), this._renderEditBookmarkFlowItems() ]; return d ? null : o`<calcite-flow>${b}</calcite-flow>`; } _renderAddBookmarkButton() { const { messages: e, disabled: t, view: i, _state: r } = this, a = this._userCreatingBookmark; return i && r !== "loading" && this.showAddBookmarkButton ? o`<calcite-fab appearance=outline-fill class="add-bookmark-button" .disabled=${t || a} icon=plus kind=neutral .loading=${a} @click=${this.startAddBookmark} slot=fab .text=${e.addBookmark} text-enabled title=${e.addBookmark ?? x}></calcite-fab>` : null; } _renderEditContainer(e) { const { messages: t } = this, i = `${t.edit} ${this._getBookmarkTitle(e)}`; return this.showEditBookmarkButton ? o`<calcite-action icon=pencil @click=${() => this._showEditBookmarkForm(e)} slot=actions-end .text=${i} title=${i ?? x}></calcite-action>` : null; } _renderBookmarkImage(e, t) { return t ? o`<img alt class="bookmark-image" src=${e.thumbnail?.url ?? x}>` : null; } _renderBookmarkTimeSwitch(e) { const { messages: t, view: i } = this, { timeExtent: r } = e; return i?.timeExtent ?? r ? o`<calcite-label layout=inline-space-between>${t.includeTimeExtent}<calcite-switch .checked=${!!r} @calciteSwitchChange=${(a) => { this.editIncludeTimeExtent = a.currentTarget.checked; }}></calcite-switch></calcite-label>` : null; } _renderEditBookmarkTimeExtent(e) { return this.editIncludeTimeExtent ? this._renderBookmarkTimeExtent(e) : null; } _renderTimeExtentDescription(e) { const { startDate: t, startTime: i, endDate: r, endTime: a } = this._getTimeExtentStrings(e); if (!t) return ""; const n = `${t} ${i}`, c = `${r} ${a}`; return r ? `${n} - ${c}` : n; } _renderBookmarkTimeExtent(e, t = !1) { const { messages: i } = this, { startDate: r, startTime: a, endDate: n, endTime: c } = this._getTimeExtentStrings(e), d = this._useStackedTimeExtentRows && !!n, m = (h, k, b) => o`<calcite-table-cell title=${b ?? "" ?? x}>${h} ${k ? [o`<br>`, k] : null}</calcite-table-cell>`, l = []; return r && l.push({ heading: i.startDate, date: r, time: a }), n && l.push({ heading: i.endDate, date: n, time: c }), r ? o`<calcite-table .caption=${i.timeExtent ?? ""} scale=s>${d ? l.map((h) => o`<calcite-table-row>${t ? null : o`<calcite-table-header .heading=${h.heading}></calcite-table-header>`}${m(h.date, h.time, h.heading)}</calcite-table-row>`) : [ t ? null : o`<calcite-table-row slot=table-header><calcite-table-header .heading=${i.startDate}></calcite-table-header>${n ? o`<calcite-table-header .heading=${i.endDate}></calcite-table-header>` : null}</calcite-table-row>`, o`<calcite-table-row>${m(r, a, i.startDate)}${n ? m(n, c, i.endDate) : null}</calcite-table-row>` ]}</calcite-table>` : null; } _renderBookmarkActiveScrim(e, t) { return this._activeBookmark === e && t ? o`<calcite-scrim loading></calcite-scrim>` : null; } _renderBookmarkActiveLoader(e, t) { return this._activeBookmark === e && !t ? o`<calcite-loader class="loader" inline .label=${this.messages.loading ?? ""}></calcite-loader>` : null; } _renderBookmarkImageIcon(e, t) { return this._activeBookmark !== e && !t ? o`<calcite-icon icon=bookmark scale=s></calcite-icon>` : null; } _renderBookmarkThumbnail(e) { const t = !this.hideThumbnail && !!e.thumbnail?.url; return o`<div class="bookmark-image-container" slot=content-start>${this._renderBookmarkActiveScrim(e, t)}${this._renderBookmarkImage(e, t)}${this._renderBookmarkActiveLoader(e, t)}${this._renderBookmarkImageIcon(e, t)}</div>`; } _renderBookmark(e) { return F(e.uid, o`<calcite-list-item class=${L(q({ "drag-enabled": this.dragEnabled }))} .description=${this._renderTimeExtentDescription(e)} .label=${this._getBookmarkTitle(e)} .value=${e.uid} @calciteListItemSelect=${() => this._goToBookmark(e)}>${this._renderBookmarkThumbnail(e)}${this._renderBookmarkContent(e)}${this._renderEditContainer(e)}</calcite-list-item>`); } _renderBookmarkContent(e) { return o`<div class="bookmark-content" slot=content><span class="bookmark-content-label">${this._getBookmarkTitle(e)}</span>${this._renderBookmarkTimeExtent(e, !0)}</div>`; } _renderEditingBookmarkName(e) { const { messages: t } = this, i = this._userValidationState === "name-required"; return o`<calcite-label>${t.title}<calcite-input class="edit-bookmark-input" name=bookmark-name .placeholder=${t.titlePlaceholder} required type=text .value=${e.name} ${w(this._storeEditInput)}></calcite-input>${i ? o`<calcite-input-message icon=exclamation-mark-triangle status=invalid>${t.invalidTitle}</calcite-input-message>` : null}</calcite-label>`; } _renderEditingBookmarkActions() { const { messages: e, _userState: t } = this, i = t?.bookmark; return [ o`<calcite-button appearance=transparent kind=danger @click=${() => this._deleteBookmark(i)} slot=footer type=button width=full>${e.delete}</calcite-button>`, o`<calcite-button appearance=outline @click=${this._closeEditBookmarkForm} slot=footer type=button width=full>${e.cancel}</calcite-button>`, o`<calcite-button slot=footer type=submit width=full>${e.save}</calcite-button>` ]; } _renderEditingTimeExtent(e) { const { view: t } = this, { timeExtent: i } = e; return !this.timeDisabled && (t?.timeExtent ?? i) ? o`<div>${this._renderBookmarkTimeSwitch(e)}${this._renderEditBookmarkTimeExtent(e)}</div>` : null; } _renderEditingBookmarkImage(e) { const { _userThumbnailState: t } = this, i = e.thumbnail?.url ?? "", r = f(i) ? t === "url" : y(i) ? t === "screenshot" : null; if (r) return this._renderBookmarkImage(e, r); } _renderEditingThumbnail(e) { const { _userThumbnailState: t, hideThumbnail: i } = this; return !i && t !== "none" ? o`<div class="authoring-image-container">${this._renderEditingBookmarkImage(e)}</div>` : null; } _renderUpdateThumbnailButton() { const { hideThumbnail: e, messages: t, _userThumbnailState: i } = this; return !e && i === "screenshot" ? o`<calcite-button appearance=outline class="authoring-refresh-thumbnail-button" icon-start=refresh kind=neutral @click=${() => { this._updateThumbnail(); }} width=full>${t.updateThumbnail}</calcite-button>` : null; } _renderEditingBookmarkUrlInput(e) { const { messages: t, _userValidationState: i, _userThumbnailState: r } = this, a = e.thumbnail?.url ?? "", n = f(a) ? a : void 0, c = a && i === "absolute-url-required"; return r === "url" ? o`<calcite-label><calcite-input name=bookmark-thumbnail-url pattern=https://.* .placeholder=${t ? `https://<${t.imageUrlPlaceholder}>` : void 0} required title=${t.imageUrlTooltip ?? x} type=text .value=${n} @calciteInputChange=${this._handleUrlEditInputChange} @calciteInputInput=${this._handleUrlEditInputChange} ${w(this._storeUrlEditInput)}></calcite-input>${c ? o`<calcite-input-message icon=exclamation-mark-triangle status=invalid>${t.invalidImageUrl}</calcite-input-message>` : null}</calcite-label>` : null; } _renderThumbnailSelector() { const { hideThumbnail: e, messages: t, _userThumbnailState: i } = this; return e ? null : o`<calcite-label>${t.thumbnail}<calcite-chip-group .label=${t.thumbnail ?? ""} selection-mode=single-persist @calciteChipGroupSelect=${(r) => this._handleThumbnailTypeSelect(r.currentTarget.selectedItems[0].value)}><calcite-chip .label=${t.screenshot ?? ""} .selected=${i === "screenshot"} value=screenshot>${t.screenshot}</calcite-chip><calcite-chip .label=${t.url ?? ""} .selected=${i === "url"} value=url>${t.url}</calcite-chip><calcite-chip .label=${t.none ?? ""} .selected=${i === "none"} value=none>${t.none}</calcite-chip></calcite-chip-group></calcite-label>`; } _renderEditingBookmark(e) { const { disabled: t, messages: i, headingLevel: r } = this; return e ? o`<form class="form" @submit=${this._editBookmarkSubmit}><calcite-flow-item .disabled=${t} .heading=${i.edit ?? ""} .headingLevel=${r} .selected=${this._userStateValue === "edit"} @calciteFlowItemBack=${(a) => { a.preventDefault(), this._closeEditBookmarkForm(); }} ${w(this._storeEditFlowItemNode)}><div class="form-content"><div class="authoring">${this._renderEditingBookmarkName(e)}${this._renderThumbnailSelector()}${this._renderEditingThumbnail(e)}${this._renderEditingBookmarkUrlInput(e)}${this._renderUpdateThumbnailButton()}${this._renderEditingTimeExtent(e)}</div></div>${this._renderEditingBookmarkActions()}</calcite-flow-item></form>` : null; } _renderAddingBookmarkName() { const { messages: e } = this, t = this._userValidationState === "name-required"; return o`<calcite-label>${e.title}<calcite-input class="add-bookmark-input" name=bookmark-name .placeholder=${e.titlePlaceholder} required type=text value ${w(this._storeAddInput)}></calcite-input>${t ? o`<calcite-input-message icon=exclamation-mark-triangle status=invalid>${e.invalidTitle}</calcite-input-message>` : null}</calcite-label>`; } _renderAddingBookmarkActions() { const { messages: e } = this; return [ o`<calcite-button appearance=outline @click=${this._endAddBookmark} slot=footer type=button width=full>${e.cancel}</calcite-button>`, o`<calcite-button slot=footer type=submit width=full>${e.add}</calcite-button>` ]; } _renderAddingBookmark() { const { disabled: e, messages: t, headingLevel: i, _userStateValue: r } = this; return r === "add" ? o`<form class="form" @submit=${this._addBookmarkSubmitClick}><calcite-flow-item .disabled=${e} .heading=${t.addBookmark} .headingLevel=${i} selected @calciteFlowItemBack=${(a) => { a.preventDefault(), this._endAddBookmark(); }} ${w(this._storeAddFlowItemNode)}><div class="form-content">${this._renderAddingBookmarkName()}</div>${this._renderAddingBookmarkActions()}</calcite-flow-item></form>` : null; } } D("arcgis-bookmarks", Y); export { Y as ArcgisBookmarks };