/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as r } from "../../chunks/runtime.js";
import { css as s, svg as c, html as a } from "lit";
import { LitElement as l, createEvent as o, safeStyleMap as h } from "@arcgis/lumina";
import { getApplicationClipboard as n } from "@arcgis/core/applications/Components/clipboard.js";
import { u as g } from "../../chunks/useT9n.js";
import { g as p, a as m } from "../../chunks/clipoardSymbolHelper.js";
import * as d from "@arcgis/toolkit/log";
import v from "@arcgis/core/Graphic.js";
import { u as f } from "../../chunks/useView.js";
const u = s`.flex{display:flex}.flex-row{flex-direction:row}.justify-center{justify-content:center}.text-center{text-align:center}`;
class y extends l {
  constructor() {
    super(...arguments), this._messages = g(), this._hoverHightlightHandle = null, this.maxShowCount = 100, this.hideTooltips = !1, this.view = f(this), this.arcgisReady = o();
  }
  static {
    this.properties = { clipboard: 32, maxShowCount: 9, hideTooltips: 5, view: 0, referenceElement: 1 };
  }
  static {
    this.styles = u;
  }
  get clipboard() {
    return n();
  }
  _removeClipboardItem(t) {
    try {
      this._clearHighlightSelectedGraphic();
      const e = this.clipboard.items.filter((i) => i !== t);
      this.clipboard.setData(e.toArray());
    } catch {
      d.log("error", this, "Failed removing clipboard item");
    }
  }
  _highlightSelectedGraphicOnMap(t) {
    if (this._clearHighlightSelectedGraphic(), !t.graphic?.geometry || !this.view)
      return;
    const e = new v({
      geometry: t.graphic.geometry,
      symbol: p(t.graphic.geometry.type)
    });
    this.view.graphics.add(e), this._hoverHightlightHandle = {
      remove: () => {
        this.view.graphics.remove(e);
      }
    };
  }
  _clearHighlightSelectedGraphic() {
    this._hoverHightlightHandle && this._hoverHightlightHandle.remove(), this._hoverHightlightHandle = null;
  }
  render() {
    const t = this.clipboard.items.slice(0, 100);
    return t.length === 0 ? a`<div class="pad-contents"><div class="flex flex-row justify-center"><svg xmlns=http://www.w3.org/2000/svg height=92 width=92 style=${h({ strokeWidth: "0.1px", fill: "var(--calcite-color-text-2)" })} viewBox="0 0 64 64">${c`<path d="M21 18h-1v-3h1zm24-3h-1v3h1zm0 5h-1v3h1zm-24 0h-1v3h1zm9.84 13.71l.3.954 3.02-.954-.3-.953zm-6.04 1.908l.3.953 3.02-.953-.3-.953zm-3.8 1.2V35h-1v3.182l2.08-.657-.3-.953zM21 30h-1v3h1zm0-5h-1v3h1zm27.816 5.896l-4.746.015 2.294 4.575-3.071 1.535-2.358-4.668-2.835 3.886V23.036zm-6.04-.78l3.607-.012-7.483-5.49v9.17l2.16-2.96 2.587 5.126 1.643-.821zM60.9 10.874v41.25a1.777 1.777 0 0 1-1.775 1.775H4.875A1.777 1.777 0 0 1 3.1 52.125v-41.25A1.777 1.777 0 0 1 4.875 9.1h54.25a1.777 1.777 0 0 1 1.775 1.775zm-.8 24.54l-24.2 7.641V53.1h23.225a.976.976 0 0 0 .975-.975zm0-24.54a.976.976 0 0 0-.975-.975H45V13h-1V9.9H21V13h-1V9.9H4.875a.976.976 0 0 0-.975.975V32.1H18v.8H3.9v19.225a.976.976 0 0 0 .975.975H35.1V35.51l.8-.252v6.96l24.2-7.643z" />`}</svg></div><p class="text-center">${this._messages.noClipboardData ?? ""}</p></div>` : a`${t.length !== this.clipboard.items.length ? a`<calcite-notice scale=s><div slot=message>${this._messages.tooManyClipboardItems ?? ""}</div></calcite-notice>` : ""}<calcite-list .label=${this._messages.clipboardContents ?? ""}>${t.map((e) => e.type === "feature" && e.layer ? a`<calcite-list-item @pointerenter=${(i) => {
      this._highlightSelectedGraphicOnMap(e), i.target.classList.add("hovering");
    }} @pointerleave=${(i) => {
      i.target.classList.remove("hovering"), this._clearHighlightSelectedGraphic();
    }}><arcgis-feature-title slot=content .graphic=${e.graphic} .layer=${e.layer}></arcgis-feature-title><arcgis-feature-image width-in-pixels=16 height-in-pixels=16 use-true-shape slot=content-start .graphic=${e.graphic} .layer=${e.layer}></arcgis-feature-image><calcite-action slot=actions-end icon=x @click=${() => {
      this._removeClipboardItem(e);
    }} .text=${this._messages.removeClipboardItem ?? ""}></calcite-action></calcite-list-item>` : e.type === "feature" && !e.layer && e.graphic?.geometry ? a`<calcite-list-item @pointerenter=${(i) => {
      this._highlightSelectedGraphicOnMap(e), i.target.classList.add("hovering");
    }} @pointerleave=${(i) => {
      i.target.classList.remove("hovering"), this._clearHighlightSelectedGraphic();
    }}><arcgis-feature-image width-in-pixels=16 height-in-pixels=16 use-true-shape .actualSymbol=${m(e.graphic.geometry.type)} slot=content-start .graphic=${e.graphic}></arcgis-feature-image><span slot=content>${this._messages.clipboardDataItem ?? ""}</span><calcite-action slot=actions-end icon=x @click=${() => {
      this._removeClipboardItem(e);
    }} .text=${this._messages.removeClipboardItem ?? ""}></calcite-action></calcite-list-item>` : a`<calcite-list-item><calcite-icon slot=content-start scale=s icon=file-data></calcite-icon><span slot=content>${this._messages.clipboardDataItem ?? ""}</span><calcite-action slot=actions-end icon=trash @click=${() => {
      this._removeClipboardItem(e);
    }} .text=${this._messages.removeClipboardItem ?? ""}></calcite-action></calcite-list-item>`)}</calcite-list>`;
  }
}
r("arcgis-clipboard", y);
export {
  y as ArcgisClipboard
};
