import { g as x, c as w } from "../../chunks/runtime.js";
import { classes as k } from "@arcgis/toolkit/dom";
import { watch as m } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as $, nothing as r, safeClassMap as i } from "@arcgis/lumina";
import { css as I, html as o } from "lit";
import { g as B } from "../../chunks/globalCss.js";
import { c as t } from "../../chunks/basemap-gallery-resources.js";
import { g as C } from "../../chunks/component-utils.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
function A(a) {
  return a.portalItem?.type === "Web Scene" || a.referenceLayers.some((e) => e.type === "scene");
}
function z(a) {
  return !!a?.portalItem?.tags?.some((e) => e.toLowerCase() === "beta");
}
const T = I`@keyframes esri-basemap-slide{0%{opacity:0;margin-top:0;margin-left:0}75%{opacity:0;margin-top:0;margin-left:0}to{opacity:1;margin-top:5px;margin-left:5px}}@keyframes esri-docking-animation{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes popup-intro-animation-down{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translate(0)}}@keyframes popup-intro-animation-up{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translate(0)}}@supports (-ms-ime-align: auto){.esri-slider__anchor:focus{outline:1px dotted #000}}@keyframes esri-spinner--start-animation{0%{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}@keyframes esri-spinner--finish-animation{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0)}}@keyframes esri-spinner--rotate-animation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@media (prefers-reduced-motion){.esri-utility-network-trace__reset-prompt{animation:none!important}}@media (prefers-reduced-motion){.esri-popup--aligned-top-center,.esri-popup--aligned-top-left,.esri-popup--aligned-top-right,.esri-popup--aligned-bottom-center,.esri-popup--aligned-bottom-left,.esri-popup--aligned-bottom-right,.esri-popup--is-docked{animation:none!important}}@media (prefers-reduced-motion: reduce){.esri-fov-overlay{animation:none!important}}@keyframes esri-fade-in-down{0%{opacity:0;transform:translateY(-5px)}25%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translate(0)}}@keyframes esri-fade-in-up{0%{opacity:0;transform:translateY(5px)}25%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translate(0)}}@keyframes esri-fade-in{0%{opacity:0}25%{opacity:0}to{opacity:1}}@keyframes esri-fade-in-scale{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes looping-progresss-bar-ani{0%{width:0;left:0}20%{width:20%;left:0}80%{width:20%;left:80%}to{width:0;left:100%}}@keyframes esri-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes panel-advance{0%{opacity:0;transform:translate(50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-retreat{0%{opacity:0;transform:translate(-50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-advance--rtl{0%{opacity:0;transform:translate(-50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes panel-retreat--rtl{0%{opacity:0;transform:translate(50px) scale(.99)}to{opacity:1;transform:translate(0) scale(1)}}:host{container-type:inline-size}.basemap-gallery__empty-message{padding:12px 15px;animation:.5s ease-in-out esri-fade-in}.basemap-gallery__item{box-sizing:border-box;cursor:pointer;border:1px solid var(--calcite-color-background);flex-direction:row;width:100%;transition:background-color .25s ease-in-out,border-color .25s ease-in-out;animation:.5s ease-in-out esri-fade-in;display:flex;position:relative}.basemap-gallery__item:hover{background-color:var(--calcite-color-foreground-3);border-color:var(--calcite-color-background-inverse)}.basemap-gallery__item:hover .basemap-gallery__item-title{color:var(--calcite-color-text-1)}.basemap-gallery__item:focus{outline:none}.basemap-gallery__item--error{opacity:var(--calcite-opacity-light);background-color:var(--calcite-color-transparent)!important;border-color:var(--calcite-color-transparent)!important;cursor:auto}.basemap-gallery__item-thumbnail{aspect-ratio:1.5;border-inline-end:1px solid var(--calcite-color-border-1);flex-shrink:0;width:120px;min-width:120px;transition:background-color .25s ease-in-out,border-color .25s ease-in-out}.basemap-gallery__item-title{color:var(--calcite-color-text-3);justify-content:flex-start;align-items:center;width:100%;height:100%;font-size:var(--calcite-font-size-sm);transition:color .25s ease-in-out,font-weight .25s ease-in-out;display:flex}.basemap-gallery__item-title span{text-align:start;text-overflow:ellipsis;word-wrap:break-word;word-break:break-word;hyphens:auto;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;width:100%;display:-webkit-box;overflow:hidden}.basemap-gallery__item--selected,.basemap-gallery__item--selected:hover,.basemap-gallery__item--selected:focus{cursor:auto;background-color:color-mix(in srgb,var(--calcite-color-brand-underline),70% transparent);border-color:var(--calcite-color-status-info)!important}.basemap-gallery__item--selected .basemap-gallery__item-title,.basemap-gallery__item.basemap-gallery__item--selected:hover .basemap-gallery__item-title,.basemap-gallery__item.basemap-gallery__item--selected:focus .basemap-gallery__item-title{color:var(--calcite-color-text-1);font-weight:var(--calcite-font-weight-medium)}.basemap-gallery__item-content{flex-direction:column;gap:var(--calcite-spacing-md);min-width:0;padding-block:var(--calcite-spacing-base);padding-inline:var(--calcite-spacing-md);display:flex}.basemap-gallery__item-tags-container{flex-direction:row;gap:var(--calcite-spacing-base);display:flex}.basemap-gallery__item-tags-container calcite-chip{--calcite-font-size--2: var(--calcite-font-size--3);cursor:inherit}@supports (object-fit: cover){.basemap-gallery__item-thumbnail{object-fit:cover}}@container (width>=200px) and (width <= 300px){.basemap-gallery__item{align-items:center}.basemap-gallery__item:not(.basemap-gallery__item--selected,:hover){border-color:var(--calcite-color-transparent)}}@container (width>=200px) and (width <= 278px){.basemap-gallery__item-thumbnail{aspect-ratio:1;width:80px;min-width:80px}}@container (width<200px) or (width>=350px){.basemap-gallery__item{text-align:center;flex-flow:column wrap}.basemap-gallery__item:not(.basemap-gallery .basemap-gallery__item--selected,:hover){border-color:var(--calcite-color-border-1)}.basemap-gallery__item-thumbnail{border-block-end:1px solid var(--calcite-color-border-1);border-inline-end:none;width:100%;min-width:0;height:auto}.basemap-gallery__item-content{height:32px;padding-block:var(--calcite-spacing-xxs);padding-inline:var(--calcite-spacing-xs);position:relative}.basemap-gallery__item-tags-container{position:absolute;inset-block-end:45px;inset-inline-end:5px}}`;
class Y extends $ {
  constructor() {
    super(...arguments), this._itemState = "loading", this._isActive = !1;
  }
  static {
    this.properties = { _itemState: 16, _isActive: 16, disabled: 5, item: 0, itemIndex: 9, viewModel: 0, messages: 0 };
  }
  static {
    this.styles = T;
  }
  loaded() {
    this.manager.onLifecycle(() => [
      m(() => this.item.state, (e) => {
        this._itemState = e;
      }, { sync: !0 }),
      m(() => this.viewModel.activeBasemap, (e) => {
        this._isActive = this.item.basemap.id === e?.id, this._isActive && (C(this)?.focus(), this.el.scrollIntoView({ block: "nearest" }));
      }, { initial: !0, sync: !0 })
    ]);
  }
  render() {
    const { item: e, itemIndex: l, viewModel: d, messages: g } = this;
    if (!e.basemap)
      return null;
    const b = e.basemap.thumbnailUrl || x("./assets/basemap-gallery/images/basemap-toggle-64.svg"), n = e.basemap.title, f = e.basemap.portalItem?.snippet, y = e.error?.message || f || n, { state: u, activeBasemapIndex: c } = this.viewModel, _ = this.disabled || u === "disabled", s = c === l, h = s || c === -1 && l === 0 ? 0 : -1, v = {
      [t.selectedItem]: s,
      [t.itemError]: e.state === "error"
    }, p = `basemapgallery-item-${e.uid}`;
    return o`<div .ariaChecked=${s} .ariaDisabled=${_} aria-labelledby=${p ?? r} class=${i(k(t.item, v))} role=radio tabindex=${h ?? r} title=${y ?? r} @click=${() => {
      e.state === "ready" && (d.activeBasemap = e.basemap);
    }}><img alt class=${i(t.itemThumbnail)} src=${b ?? r}><div class=${i(t.itemContent)}><div class=${i(t.itemTitle)}><span id=${p ?? r}>${n}</span></div>${A(e.basemap) ? D(e.basemap, g) : null}</div>${e.state !== "loading" ? null : o`<calcite-scrim><span aria-hidden=true class=${i(B.loaderAnimation)} role=presentation></span></calcite-scrim>`}</div>`;
  }
}
function D(a, e) {
  return o`<div class=${i(t.itemTagsContainer)}>${M(e)}${z(a) ? S(e) : null}</div>`;
}
function M(a) {
  return o`<calcite-chip scale=s .label=${a.tag3D}>${a.tag3D}</calcite-chip>`;
}
function S(a) {
  return o`<calcite-chip appearance=outline-fill scale=s .label=${a.tagBeta}>${a.tagBeta}</calcite-chip>`;
}
w("arcgis-basemap-gallery-item", Y);
export {
  Y as ArcgisBasemapGalleryItem
};
