/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { g as x, c as w } from "../../chunks/runtime.js";
import { classes as k } from "@arcgis/toolkit/dom";
import { watch as l } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as $, nothing as a, safeClassMap as p } from "@arcgis/lumina";
import { css as B, html as i } from "lit";
import { g as I } from "../../chunks/globalCss.js";
import { g as _ } from "../../chunks/component-utils.js";
function A(t) {
  return t.portalItem?.type === "Web Scene" || t.referenceLayers.some((e) => e.type === "scene");
}
function C(t) {
  return !!t?.portalItem?.tags?.some((e) => e.toLowerCase() === "beta") || !!t?.portalItem?.categories?.includes("/Categories/Status/Beta");
}
const z = B`@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}.empty-message{padding:12px 15px;animation:.5s ease-in-out esri-fade-in}.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}.item:hover{background-color:var(--calcite-color-foreground-3);border-color:var(--calcite-color-background-inverse)}.item:hover .item-title{color:var(--calcite-color-text-1)}.item:focus{outline:none}.is-error{opacity:var(--calcite-opacity-light);background-color:var(--calcite-color-transparent)!important;border-color:var(--calcite-color-transparent)!important;cursor:auto}.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}.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}.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}.is-selected,.is-selected:hover,.is-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}.is-selected .item-title,.item.is-selected:hover .item-title,.item.is-selected:focus .item-title{color:var(--calcite-color-text-1);font-weight:var(--calcite-font-weight-medium)}.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}.item-tags{flex-direction:row;gap:var(--calcite-spacing-base);display:flex}.item-tags calcite-chip{--calcite-font-size--2: var(--calcite-font-size--3);cursor:inherit}@supports (object-fit: cover){.item-thumbnail{object-fit:cover}}@container (width>=200px) and (width <= 300px){.item{align-items:center}.item:not(.is-selected,:hover){border-color:var(--calcite-color-transparent)}}@container (width>=200px) and (width <= 278px){.item-thumbnail{aspect-ratio:1;width:80px;min-width:80px;object-position:left}}@container (width<200px) or (width>=350px){.item{text-align:center;flex-flow:column wrap}.item:not(.is-selected,:hover){border-color:var(--calcite-color-border-1)}.item-thumbnail{border-block-end:1px solid var(--calcite-color-border-1);border-inline-end:none;width:100%;min-width:0;height:auto}.item-content{height:32px;padding-block:var(--calcite-spacing-xxs);padding-inline:var(--calcite-spacing-xs);position:relative}.item-tags{position:absolute;inset-block-end:45px;inset-inline-end:5px}}`;
class S 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 = z;
  }
  loaded() {
    this.manager.onLifecycle(() => [
      l(() => this.item.state, (e) => {
        this._itemState = e;
      }, { sync: !0 }),
      l(() => this.viewModel.activeBasemap, (e) => {
        this._isActive = this.item.basemap.id === e?.id, this._isActive && (_(this)?.focus(), this.el.scrollIntoView({ block: "nearest" }));
      }, { initial: !0, sync: !0 })
    ]);
  }
  render() {
    const { item: e, itemIndex: o, viewModel: m, messages: d } = this;
    if (!e.basemap)
      return null;
    const f = e.basemap.thumbnailUrl || x("./assets/basemap-gallery/images/basemap-toggle-64.svg"), s = e.basemap.title, u = e.basemap.portalItem?.snippet, g = e.error?.message || u || s, { state: b, activeBasemapIndex: n } = this.viewModel, h = this.disabled || b === "disabled", r = n === o, y = r || n === -1 && o === 0 ? 0 : -1, v = {
      "is-selected": r,
      "is-error": e.state === "error"
    }, c = `basemapgallery-item-${e.uid}`;
    return i`<div .ariaChecked=${r} .ariaDisabled=${h} aria-labelledby=${c ?? a} class=${p(k("item", v))} role=radio tabindex=${y ?? a} title=${g ?? a} @click=${() => {
      e.state === "ready" && (m.activeBasemap = e.basemap);
    }}><img alt class="item-thumbnail" src=${f ?? a}><div class="item-content"><div class="item-title"><span id=${c ?? a}>${s}</span></div>${A(e.basemap) ? Y(e.basemap, d) : null}</div>${e.state !== "loading" ? null : i`<calcite-scrim><span aria-hidden=true class=${p(I.loaderAnimation)} role=presentation></span></calcite-scrim>`}</div>`;
  }
}
function Y(t, e) {
  return i`<div class="item-tags">${D(e)}${C(t) ? M(e) : null}</div>`;
}
function D(t) {
  return i`<calcite-chip scale=s .label=${t.tag3D}>${t.tag3D}</calcite-chip>`;
}
function M(t) {
  return i`<calcite-chip appearance=outline-fill scale=s .label=${t.tagBeta}>${t.tagBeta}</calcite-chip>`;
}
w("arcgis-basemap-gallery-item", S);
export {
  S as ArcgisBasemapGalleryItem
};
