import { x as A, i as he, E as ue } from "./lit-element.jLBm65_O.js";
import { C as He, n as d } from "./lib-cortex-element.CVMmyPMC.js";
import { r as L } from "./state.CSDxrqLd.js";
import { e as K } from "./query.BBf1UFkC.js";
import { E as De, b as ce, a as $e } from "./index.Cpamj0jB.js";
import { c as Te } from "./component.styles.CRO4Odto.js";
import { c as We } from "./custom-element.L4WJXn1j.js";
import { d as Oe } from "./debounce.DaHuiSGU.js";
import { L as Ae } from "./i18n.DK1uYlJT.js";
import { w as X } from "./watch.BCJD77bD.js";
import { e as j } from "./class-map.BiVq-cVR.js";
import { o as Be } from "./if-defined.BRoBj_Rp.js";
import { e as Me, i as je } from "./directive.oAbCiebi.js";
import { m as Ie } from "./directive-helpers.Dm4rc594.js";
import { o as _e } from "./style-map.llVFPd__.js";
import { n as P } from "./when.Dr1es41R.js";
import Ne from "../components/icon.js";
import Ze from "../components/popup.js";
import Ve from "../components/resize-observer.js";
import Pe from "../components/skeleton.js";
import Fe from "../components/space.js";
var Ue = /* @__PURE__ */ ((e) => (e.Bottom = "bottom", e.BottomCenter = "bottom-center", e.BottomLeft = "bottom-left", e.BottomRight = "bottom-right", e.CenterCenter = "center-center", e.CenterLeft = "center-left", e.CenterRight = "center-right", e.Left = "left", e.Right = "right", e.Top = "top", e.TopCenter = "top-center", e.TopLeft = "top-left", e.TopRight = "top-right", e))(Ue || {}), q = /* @__PURE__ */ ((e) => (e.Jump = "jump", e.None = "none", e.TextReveal = "text-reveal", e.Zoom = "zoom", e))(q || {}), pe = /* @__PURE__ */ ((e) => (e.PopOut = "pop-out", e.WithinBorders = "within-borders", e))(pe || {}), fe = /* @__PURE__ */ ((e) => (e.Fade = "fade", e.Slide = "slide", e))(fe || {}), se = /* @__PURE__ */ ((e) => (e.Auto = "auto", e.Fixed = "fixed", e))(se || {}), W = /* @__PURE__ */ ((e) => (e.Both = "both", e.Horizontal = "horizontal", e.Vertical = "vertical", e))(W || {}), Ye = Object.defineProperty, C = (e, t, r, h) => {
  for (var o = void 0, g = e.length - 1, u; g >= 0; g--)
    (u = e[g]) && (o = u(t, r, o) || o);
  return o && Ye(t, r, o), o;
};
class S extends He {
  constructor() {
    super(...arguments), this.hasEvent = !1, this.easing = De.Linear, this.highlightBorder = !1, this.highlightColorOverlay = !1, this.highlightDropShadow = !1, this.highlightBackground = !1, this.highlightOpacity = !1, this.effect = q.None, this.textRevealStyle = fe.Slide, this.zoomStyle = pe.WithinBorders, this.hasSlotContent = !1, this.isCustomSlot = !1, this.isHovering = !1;
  }
  get easeCSSVariable() {
    return ce[this.easing] || ce.linear;
  }
  getHighlighterClass() {
    return {
      highlighter: !0,
      [`highlighter--effect-${this.effect}`]: !0,
      [`highlighter--zoom-style-${this.zoomStyle}`]: !0,
      "highlighter--background": this.highlightBackground,
      "highlighter--border": this.highlightBorder,
      "highlighter--color-overlay": this.highlightColorOverlay,
      "highlighter--drop-shadow": this.highlightDropShadow,
      "highlighter--opacity": this.highlightOpacity
    };
  }
  /**
   * Check if the slot has actual content (not just whitespace).
   */
  handleSlotChange() {
    if (this.slotEl) {
      const t = this.slotEl.assignedElements({ flatten: !0 });
      this.hasSlotContent = t.length > 0, this.isCustomSlot = !t.some(
        (r) => r.hasAttribute("data-item-id")
      );
    } else
      this.hasSlotContent = this.childElementCount > 0, this.isCustomSlot = !0;
  }
}
C([
  K("slot")
], S.prototype, "slotEl");
C([
  d({ attribute: "has-event", reflect: !0, type: Boolean })
], S.prototype, "hasEvent");
C([
  d({ reflect: !0, type: String })
], S.prototype, "easing");
C([
  d({ attribute: "highlight-border", reflect: !0, type: Boolean })
], S.prototype, "highlightBorder");
C([
  d({
    attribute: "highlight-color-overlay",
    reflect: !0,
    type: Boolean
  })
], S.prototype, "highlightColorOverlay");
C([
  d({
    attribute: "highlight-drop-shadow",
    reflect: !0,
    type: Boolean
  })
], S.prototype, "highlightDropShadow");
C([
  d({ attribute: "highlight-background", reflect: !0, type: Boolean })
], S.prototype, "highlightBackground");
C([
  d({ attribute: "highlight-opacity", reflect: !0, type: Boolean })
], S.prototype, "highlightOpacity");
C([
  d({ attribute: "effect", reflect: !0, type: String })
], S.prototype, "effect");
C([
  d({
    attribute: "text-reveal-style",
    reflect: !0,
    type: String
  })
], S.prototype, "textRevealStyle");
C([
  d({
    attribute: "zoom-style",
    reflect: !0,
    type: String
  })
], S.prototype, "zoomStyle");
C([
  L()
], S.prototype, "hasSlotContent");
C([
  L()
], S.prototype, "isCustomSlot");
C([
  L()
], S.prototype, "isHovering");
var qe = Object.defineProperty, O = (e, t, r, h) => {
  for (var o = void 0, g = e.length - 1, u; g >= 0; g--)
    (u = e[g]) && (o = u(t, r, o) || o);
  return o && qe(t, r, o), o;
};
class D extends S {
  constructor() {
    super(), this.width = "", this.height = "", this.resizable = !1, this.heightMode = se.Fixed, this.resizeDirection = W.Both, this.noLimit = !1, this.parentContainer = null, this.isResizeActive = !1, this.isResizing = !1, this.resizeSize = {
      height: 0,
      width: 0
    }, this.maxWidth = 0, this.maxHeight = 0, this.minWidth = 0, this.minHeight = 0, this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
  }
  get ratio() {
    const t = this.clientWidth || 0, r = this.clientHeight || 0;
    return !t || !r ? 1 : t / r;
  }
  get keepRatio() {
    return this.heightMode === se.Auto;
  }
  get canResizeHorizontal() {
    return this.resizeDirection !== W.Vertical;
  }
  get canResizeVertical() {
    return this.resizeDirection !== W.Horizontal;
  }
  handleDocumentMouseDown(t) {
    const r = t.composedPath();
    this.containingElement && !r.includes(this.containingElement) && this.stopResizing();
  }
  startResizing() {
    !this.resizable || this.isResizeActive || (this.isResizeActive = !0, this.ownerDocument.addEventListener(
      "mousedown",
      this.handleDocumentMouseDown
    ));
  }
  stopResizing() {
    this.isResizeActive = !1, this.ownerDocument.removeEventListener(
      "mousedown",
      this.handleDocumentMouseDown
    );
  }
  handleResizeDragging(t, r = !1, h = !1) {
    t.preventDefault(), t.stopPropagation(), this.maxWidth = Number.parseInt(getComputedStyle(this).getPropertyValue("--max-width")) || this.parentContainer?.clientWidth || this.parentElement?.clientWidth || 1 / 0, this.maxHeight = Number.parseInt(
      getComputedStyle(this).getPropertyValue("--max-height")
    ) || 1 / 0, this.minWidth = Number.parseInt(getComputedStyle(this).getPropertyValue("--min-width")) || 40, this.minHeight = Number.parseInt(
      getComputedStyle(this).getPropertyValue("--min-height")
    ) || 40, this.isResizing = !0;
    const o = { x: t.pageX, y: t.pageY };
    let g = 0, u = 0;
    const x = {
      height: this.containingElement?.clientHeight || 0,
      width: this.containingElement?.clientWidth || 0
    };
    if (!this.noLimit && this.parentElement) {
      const $ = getComputedStyle(this.parentElement), p = $.getPropertyValue("padding-left").trim() || "0px", v = $.getPropertyValue("padding-right").trim() || "0px", B = Number(p.replace("px", "")), y = Number(v.replace("px", "")), H = getComputedStyle(this.parentElement).getPropertyValue("--padding").trim() || "0px", E = Number(H.replace("px", "")), ie = Math.max(
        B + y,
        E * 2
      );
      this.maxWidth = Math.max(this.maxWidth - ie, 0);
    }
    this.emit("cx-resize-start", {
      detail: {
        element: this,
        event: t
      }
    });
    const _ = ($) => {
      g = Number(x.width) + (r ? o.x - $.pageX : $.pageX - o.x), u = Number(x.height) + (h ? o.y - $.pageY : $.pageY - o.y), this.canResizeHorizontal || (g = Number(x.width)), this.canResizeVertical || (u = Number(x.height)), this.resizeDirection === W.Both && this.keepRatio && (u >= g / this.ratio && (u = g / this.ratio), g >= u * this.ratio && (g = u * this.ratio));
      let p = g, v = u;
      if (this.resizeDirection === W.Both && this.keepRatio) {
        const B = this.maxWidth ?? 1 / 0, y = this.maxHeight ?? 1 / 0;
        let H = Math.min(p, B), E = H / this.ratio;
        E > y && (E = y, H = E * this.ratio), p = H, v = E;
      } else
        p = this.maxWidth ? Math.min(p, this.maxWidth) : p, v = this.maxHeight ? Math.min(v, this.maxHeight) : v;
      this.resizeSize = {
        height: Math.round(v),
        width: Math.round(p)
      }, this.resizeDirection === W.Both && this.keepRatio ? (this.minHeight && this.resizeSize.height < this.minHeight && (this.resizeSize.height = this.minHeight, this.resizeSize.width = Math.round(this.minHeight * this.ratio)), this.minWidth && this.resizeSize.width < this.minWidth && (this.resizeSize.width = this.minWidth, this.resizeSize.height = Math.round(this.minWidth / this.ratio))) : (this.minHeight && this.resizeSize.height < this.minHeight && (this.resizeSize.height = this.minHeight), this.minWidth && this.resizeSize.width < this.minWidth && (this.resizeSize.width = this.minWidth));
    }, N = ($) => {
      if (g > 0 && u > 0) {
        let p = g, v = u;
        if (this.canResizeHorizontal || (p = Number(x.width)), this.canResizeVertical || (v = Number(x.height)), this.resizeDirection === W.Both && this.keepRatio) {
          const B = this.maxWidth ?? 1 / 0, y = this.maxHeight ?? 1 / 0;
          let H = Math.min(p, B), E = H / this.ratio;
          E > y && (E = y, H = E * this.ratio), p = H, v = E;
        } else
          p = this.maxWidth ? Math.min(p, this.maxWidth) : p, v = this.maxHeight ? Math.min(v, this.maxHeight) : v;
        this.resizeDirection === W.Both && this.keepRatio ? (this.minHeight && v < this.minHeight && (v = this.minHeight, p = Math.round(this.minHeight * this.ratio)), this.minWidth && p < this.minWidth && (p = this.minWidth, v = Math.round(this.minWidth / this.ratio))) : (this.minHeight && v < this.minHeight && (v = this.minHeight), this.minWidth && p < this.minWidth && (p = this.minWidth)), this.width = `${Math.round(p)}px`, this.height = `${Math.round(v)}px`, this.resizeSize = {
          height: 0,
          width: 0
        }, this.isResizing = !1;
      }
      this.emit("cx-resize-end", {
        detail: {
          element: this,
          event: $
        }
      }), this.ownerDocument.defaultView?.removeEventListener(
        "mousemove",
        _
      );
    };
    this.ownerDocument.defaultView?.addEventListener(
      "mousemove",
      _
    ), this.ownerDocument.defaultView?.addEventListener("mouseup", N, {
      once: !0
    });
  }
  handleResizeDraggingTopLeft(t) {
    this.handleResizeDragging(t, !0, !0);
  }
  handleResizeDraggingTopRight(t) {
    this.handleResizeDragging(t, !1, !0);
  }
  handleResizeDraggingBottomLeft(t) {
    this.handleResizeDragging(t, !0, !1);
  }
  handleResizeDraggingBottomRight(t) {
    this.handleResizeDragging(t, !1, !1);
  }
  handleResizeDraggingLeft(t) {
    this.handleResizeDragging(t, !0, !1);
  }
  handleResizeDraggingRight(t) {
    this.handleResizeDragging(t, !1, !1);
  }
  handleResizeDraggingTop(t) {
    this.handleResizeDragging(t, !1, !0);
  }
  handleResizeDraggingBottom(t) {
    this.handleResizeDragging(t, !1, !1);
  }
  renderResizer() {
    return this.resizeDirection === W.Horizontal ? A`<div class="resizer resizer--left" @mousedown=${this.handleResizeDraggingLeft}></div><div class="resizer resizer--right" @mousedown=${this.handleResizeDraggingRight}></div>` : this.resizeDirection === W.Vertical ? A`<div class="resizer resizer--top" @mousedown=${this.handleResizeDraggingTop}></div><div class="resizer resizer--bottom" @mousedown=${this.handleResizeDraggingBottom}></div>` : A`<div class="resizer resizer--top-left" @mousedown=${this.handleResizeDraggingTopLeft}></div><div class="resizer resizer--top-right" @mousedown=${this.handleResizeDraggingTopRight}></div><div class="resizer resizer--bottom-left" @mousedown=${this.handleResizeDraggingBottomLeft}></div><div class="resizer resizer--bottom-right" @mousedown=${this.handleResizeDraggingBottomRight}></div>`;
  }
}
O([
  K('[part="base"]')
], D.prototype, "containingElement");
O([
  d({ reflect: !0, type: String })
], D.prototype, "width");
O([
  d({ reflect: !0, type: String })
], D.prototype, "height");
O([
  d({ type: Boolean })
], D.prototype, "resizable");
O([
  d({ attribute: "height-mode", reflect: !0, type: String })
], D.prototype, "heightMode");
O([
  d({ attribute: "resize-direction", reflect: !0, type: String })
], D.prototype, "resizeDirection");
O([
  d({ attribute: "no-limit", reflect: !0, type: Boolean })
], D.prototype, "noLimit");
O([
  d({ attribute: !1, type: Object })
], D.prototype, "parentContainer");
O([
  L()
], D.prototype, "isResizeActive");
O([
  L()
], D.prototype, "isResizing");
O([
  L()
], D.prototype, "resizeSize");
const Xe = he`.resizer{background-color:var(--cx-color-primary);z-index:100;width:8px;height:8px;position:absolute}.resizer--top-left{top:calc(-1px - var(--border-width,0px));left:calc(-1px - var(--border-width,0px));cursor:nw-resize}.resizer--top-right{top:calc(-1px - var(--border-width,0px));right:calc(-1px - var(--border-width,0px));cursor:ne-resize}.resizer--bottom-left{bottom:calc(-1px - var(--border-width,0px));left:calc(-1px - var(--border-width,0px));cursor:sw-resize}.resizer--bottom-right{bottom:calc(-1px - var(--border-width,0px));right:calc(-1px - var(--border-width,0px));cursor:se-resize}.resizer--left{cursor:ew-resize;top:50%;left:0;transform:translateY(-50%)}.resizer--right{cursor:ew-resize;top:50%;right:0;transform:translateY(-50%)}.resizer--top{cursor:ns-resize;top:0;left:50%;transform:translate(-50%)}.resizer--bottom{cursor:ns-resize;bottom:0;left:50%;transform:translate(-50%)}`;
var Y = /* @__PURE__ */ ((e) => (e.Automatic = "automatic", e.Manual = "manual", e))(Y || {});
/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const Ke = Me(class extends je {
  constructor() {
    super(...arguments), this.key = ue;
  }
  render(e, t) {
    return this.key = e, t;
  }
  update(e, [t, r]) {
    return t !== this.key && (Ie(e), this.key = t), r;
  }
});
/*! medium-zoom 1.1.0 | MIT License | https://github.com/francoischalifour/medium-zoom */
var I = Object.assign || function(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t];
    for (var h in r)
      Object.prototype.hasOwnProperty.call(r, h) && (e[h] = r[h]);
  }
  return e;
}, ee = function(t) {
  return t.tagName === "IMG";
}, Je = function(t) {
  return NodeList.prototype.isPrototypeOf(t);
}, te = function(t) {
  return t && t.nodeType === 1;
}, me = function(t) {
  var r = t.currentSrc || t.src;
  return r.substr(-4).toLowerCase() === ".svg";
}, ge = function(t) {
  try {
    return Array.isArray(t) ? t.filter(ee) : Je(t) ? [].slice.call(t).filter(ee) : te(t) ? [t].filter(ee) : typeof t == "string" ? [].slice.call(document.querySelectorAll(t)).filter(ee) : [];
  } catch {
    throw new TypeError(`The provided selector is invalid.
Expects a CSS selector, a Node element, a NodeList or an array.
See: https://github.com/francoischalifour/medium-zoom`);
  }
}, Ge = function(t) {
  var r = document.createElement("div");
  return r.classList.add("medium-zoom-overlay"), r.style.background = t, r;
}, Qe = function(t) {
  var r = t.getBoundingClientRect(), h = r.top, o = r.left, g = r.width, u = r.height, x = t.cloneNode(), _ = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, N = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
  return x.removeAttribute("id"), x.style.position = "absolute", x.style.top = h + _ + "px", x.style.left = o + N + "px", x.style.width = g + "px", x.style.height = u + "px", x.style.transform = "", x;
}, F = function(t, r) {
  var h = I({
    bubbles: !1,
    cancelable: !1,
    detail: void 0
  }, r);
  if (typeof window.CustomEvent == "function")
    return new CustomEvent(t, h);
  var o = document.createEvent("CustomEvent");
  return o.initCustomEvent(t, h.bubbles, h.cancelable, h.detail), o;
}, et = function e(t) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, h = window.Promise || function(a) {
    function n() {
    }
    a(n, n);
  }, o = function(a) {
    var n = a.target;
    if (n === G) {
      y();
      return;
    }
    k.indexOf(n) !== -1 && H({ target: n });
  }, g = function() {
    if (!(Z || !i.original)) {
      var a = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
      Math.abs(le - a) > m.scrollOffset && setTimeout(y, 150);
    }
  }, u = function(a) {
    var n = a.key || a.keyCode;
    (n === "Escape" || n === "Esc" || n === 27) && y();
  }, x = function() {
    var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = a;
    if (a.background && (G.style.background = a.background), a.container && a.container instanceof Object && (n.container = I({}, m.container, a.container)), a.template) {
      var f = te(a.template) ? a.template : document.querySelector(a.template);
      n.template = f;
    }
    return m = I({}, m, n), k.forEach(function(z) {
      z.dispatchEvent(F("medium-zoom:update", {
        detail: { zoom: b }
      }));
    }), b;
  }, _ = function() {
    var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    return e(I({}, m, a));
  }, N = function() {
    for (var a = arguments.length, n = Array(a), f = 0; f < a; f++)
      n[f] = arguments[f];
    var z = n.reduce(function(s, R) {
      return [].concat(s, ge(R));
    }, []);
    return z.filter(function(s) {
      return k.indexOf(s) === -1;
    }).forEach(function(s) {
      k.push(s), s.classList.add("medium-zoom-image");
    }), J.forEach(function(s) {
      var R = s.type, T = s.listener, V = s.options;
      z.forEach(function(M) {
        M.addEventListener(R, T, V);
      });
    }), b;
  }, $ = function() {
    for (var a = arguments.length, n = Array(a), f = 0; f < a; f++)
      n[f] = arguments[f];
    i.zoomed && y();
    var z = n.length > 0 ? n.reduce(function(s, R) {
      return [].concat(s, ge(R));
    }, []) : k;
    return z.forEach(function(s) {
      s.classList.remove("medium-zoom-image"), s.dispatchEvent(F("medium-zoom:detach", {
        detail: { zoom: b }
      }));
    }), k = k.filter(function(s) {
      return z.indexOf(s) === -1;
    }), b;
  }, p = function(a, n) {
    var f = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
    return k.forEach(function(z) {
      z.addEventListener("medium-zoom:" + a, n, f);
    }), J.push({ type: "medium-zoom:" + a, listener: n, options: f }), b;
  }, v = function(a, n) {
    var f = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
    return k.forEach(function(z) {
      z.removeEventListener("medium-zoom:" + a, n, f);
    }), J = J.filter(function(z) {
      return !(z.type === "medium-zoom:" + a && z.listener.toString() === n.toString());
    }), b;
  }, B = function() {
    var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = a.target, f = function() {
      var s = {
        width: document.documentElement.clientWidth,
        height: document.documentElement.clientHeight,
        left: 0,
        top: 0,
        right: 0,
        bottom: 0
      }, R = void 0, T = void 0;
      if (m.container)
        if (m.container instanceof Object)
          s = I({}, s, m.container), R = s.width - s.left - s.right - m.margin * 2, T = s.height - s.top - s.bottom - m.margin * 2;
        else {
          var V = te(m.container) ? m.container : document.querySelector(m.container), M = V.getBoundingClientRect(), re = M.width, ze = M.height, ye = M.left, be = M.top;
          s = I({}, s, {
            width: re,
            height: ze,
            left: ye,
            top: be
          });
        }
      R = R || s.width - m.margin * 2, T = T || s.height - m.margin * 2;
      var U = i.zoomedHd || i.original, xe = me(U) ? R : U.naturalWidth || R, we = me(U) ? T : U.naturalHeight || T, Q = U.getBoundingClientRect(), Re = Q.top, Se = Q.left, oe = Q.width, ae = Q.height, Ce = Math.min(Math.max(oe, xe), R) / oe, Ee = Math.min(Math.max(ae, we), T) / ae, ne = Math.min(Ce, Ee), ke = (-Se + (R - oe) / 2 + m.margin + s.left) / ne, Le = (-Re + (T - ae) / 2 + m.margin + s.top) / ne, de = "scale(" + ne + ") translate3d(" + ke + "px, " + Le + "px, 0)";
      i.zoomed.style.transform = de, i.zoomedHd && (i.zoomedHd.style.transform = de);
    };
    return new h(function(z) {
      if (n && k.indexOf(n) === -1) {
        z(b);
        return;
      }
      var s = function re() {
        Z = !1, i.zoomed.removeEventListener("transitionend", re), i.original.dispatchEvent(F("medium-zoom:opened", {
          detail: { zoom: b }
        })), z(b);
      };
      if (i.zoomed) {
        z(b);
        return;
      }
      if (n)
        i.original = n;
      else if (k.length > 0) {
        var R = k;
        i.original = R[0];
      } else {
        z(b);
        return;
      }
      if (i.original.dispatchEvent(F("medium-zoom:open", {
        detail: { zoom: b }
      })), le = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, Z = !0, i.zoomed = Qe(i.original), document.body.appendChild(G), m.template) {
        var T = te(m.template) ? m.template : document.querySelector(m.template);
        i.template = document.createElement("div"), i.template.appendChild(T.content.cloneNode(!0)), document.body.appendChild(i.template);
      }
      if (i.original.parentElement && i.original.parentElement.tagName === "PICTURE" && i.original.currentSrc && (i.zoomed.src = i.original.currentSrc), document.body.appendChild(i.zoomed), window.requestAnimationFrame(function() {
        document.body.classList.add("medium-zoom--opened");
      }), i.original.classList.add("medium-zoom-image--hidden"), i.zoomed.classList.add("medium-zoom-image--opened"), i.zoomed.addEventListener("click", y), i.zoomed.addEventListener("transitionend", s), i.original.getAttribute("data-zoom-src")) {
        i.zoomedHd = i.zoomed.cloneNode(), i.zoomedHd.removeAttribute("srcset"), i.zoomedHd.removeAttribute("sizes"), i.zoomedHd.removeAttribute("loading"), i.zoomedHd.src = i.zoomed.getAttribute("data-zoom-src"), i.zoomedHd.onerror = function() {
          clearInterval(V), console.warn("Unable to reach the zoom image target " + i.zoomedHd.src), i.zoomedHd = null, f();
        };
        var V = setInterval(function() {
          i.zoomedHd.complete && (clearInterval(V), i.zoomedHd.classList.add("medium-zoom-image--opened"), i.zoomedHd.addEventListener("click", y), document.body.appendChild(i.zoomedHd), f());
        }, 10);
      } else if (i.original.hasAttribute("srcset")) {
        i.zoomedHd = i.zoomed.cloneNode(), i.zoomedHd.removeAttribute("sizes"), i.zoomedHd.removeAttribute("loading");
        var M = i.zoomedHd.addEventListener("load", function() {
          i.zoomedHd.removeEventListener("load", M), i.zoomedHd.classList.add("medium-zoom-image--opened"), i.zoomedHd.addEventListener("click", y), document.body.appendChild(i.zoomedHd), f();
        });
      } else
        f();
    });
  }, y = function() {
    return new h(function(a) {
      if (Z || !i.original) {
        a(b);
        return;
      }
      var n = function f() {
        i.original.classList.remove("medium-zoom-image--hidden"), document.body.removeChild(i.zoomed), i.zoomedHd && document.body.removeChild(i.zoomedHd), document.body.removeChild(G), i.zoomed.classList.remove("medium-zoom-image--opened"), i.template && document.body.removeChild(i.template), Z = !1, i.zoomed.removeEventListener("transitionend", f), i.original.dispatchEvent(F("medium-zoom:closed", {
          detail: { zoom: b }
        })), i.original = null, i.zoomed = null, i.zoomedHd = null, i.template = null, a(b);
      };
      Z = !0, document.body.classList.remove("medium-zoom--opened"), i.zoomed.style.transform = "", i.zoomedHd && (i.zoomedHd.style.transform = ""), i.template && (i.template.style.transition = "opacity 150ms", i.template.style.opacity = 0), i.original.dispatchEvent(F("medium-zoom:close", {
        detail: { zoom: b }
      })), i.zoomed.addEventListener("transitionend", n);
    });
  }, H = function() {
    var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = a.target;
    return i.original ? y() : B({ target: n });
  }, E = function() {
    return m;
  }, ie = function() {
    return k;
  }, ve = function() {
    return i.original;
  }, k = [], J = [], Z = !1, le = 0, m = r, i = {
    original: null,
    zoomed: null,
    zoomedHd: null,
    template: null
    // If the selector is omitted, it's replaced by the options
  };
  Object.prototype.toString.call(t) === "[object Object]" ? m = t : (t || typeof t == "string") && N(t), m = I({
    margin: 0,
    background: "#fff",
    scrollOffset: 40,
    container: null,
    template: null
  }, m);
  var G = Ge(m.background);
  document.addEventListener("click", o), document.addEventListener("keyup", u), document.addEventListener("scroll", g), window.addEventListener("resize", y);
  var b = {
    open: B,
    close: y,
    toggle: H,
    update: x,
    clone: _,
    attach: N,
    detach: $,
    on: p,
    off: v,
    getOptions: E,
    getImages: ie,
    getZoomedImage: ve
  };
  return b;
};
function tt(e, t) {
  t === void 0 && (t = {});
  var r = t.insertAt;
  if (!(typeof document > "u")) {
    var h = document.head || document.getElementsByTagName("head")[0], o = document.createElement("style");
    o.type = "text/css", r === "top" && h.firstChild ? h.insertBefore(o, h.firstChild) : h.appendChild(o), o.styleSheet ? o.styleSheet.cssText = e : o.appendChild(document.createTextNode(e));
  }
}
var it = ".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";
tt(it);
const rt = he`:host([effect=jump]) .container,:host([effect=text-reveal]) .container,:host([effect=zoom]) .container{overflow:initial}:host([effect=jump]) .highlighter{transition:all var(--transition-duration,.5s) var(--easing,linear), transform var(--transition-transform-duration,.5s) var(--easing,linear)}:host([effect=jump]) .highlighter:hover{transform:translateY(calc(var(--highlightable-item-effect-jump-distance,0) * -1))}.highlighter--effect-text-reveal,:host([effect=zoom]) .highlighter--zoom-style-within-borders{overflow:hidden}:host([effect=zoom][zoom-style=pop-out]) .highlighter:hover{z-index:3;animation:none}:host([effect=zoom][zoom-style=pop-out]) .highlighter:not(:hover){animation:drop-z var(--transition-transform-duration) forwards}@keyframes drop-z{0%{z-index:2}99%{z-index:2}to{z-index:0}}.highlighter--can-hover:hover:after,.highlighter--selected:after,.highlighter--color-overlay:after{content:"";pointer-events:none;width:100%;height:100%;transition:all var(--transition-duration,.5s) var(--easing,linear);position:absolute;top:0;left:0}.highlighter--can-hover:hover:after,.highlighter--selected:after{outline:2px solid var(--cx-color-primary)}.highlighter--border:hover .image{border-color:var(--highlightable-item-highlight-border-color,var(--cx-color-primary))}.highlighter--color-overlay:after{border-radius:var(--border-radius,none)}.highlighter--color-overlay:hover:after{background-color:var(--highlightable-item-highlight-color-overlay-color,transparent)}.highlighter--drop-shadow:hover .image{box-shadow:var(--highlightable-item-highlight-drop-shadow,none)}.highlighter--background:hover .highlightable-item{--content-background-color:var(--highlightable-item-highlight-background,transparent);--highlightable-item-background-color:var(--highlightable-item-highlight-background,transparent)}.highlighter--opacity{opacity:var(--highlightable-item-highlight-opacity,1)}:host([effect=zoom][zoom-style=within-borders]) .highlighter .image,:host([effect=zoom][zoom-style=pop-out]) .highlighter{transition:transform var(--transition-transform-duration,.5s) var(--easing,linear)}:host([effect=zoom][zoom-style=within-borders]) .highlighter:hover .image,:host([effect=zoom][zoom-style=pop-out]) .highlighter:hover{transform:scale(var(--highlightable-item-effect-zoom-scale,1))}.highlightable-item{transition:background-color var(--transition-duration,.5s) var(--easing,linear), border-color var(--transition-duration,.5s) var(--easing,linear), box-shadow var(--transition-duration,.5s) var(--easing,linear), opacity var(--transition-duration,.5s) var(--easing,linear), transform var(--transition-transform-duration,.5s) var(--easing,linear), visibility var(--transition-duration,.5s) var(--easing,linear)}`, ot = he`
  :host {
    --justify-content: flex-start;
    --border-radius: 0px;
    --border: 0px;
    --padding: 0px;
    --details-color: light-dark(
      var(--cx-color-neutral-1000),
      var(--cx-color-neutral-0)
    );
    --details-font-size: 16px;
    --details-letter-spacing: 0px;
    --details-line-height: 1.5;
    --details-text-align: left;
    --easing: ease-in-out;
    --header-text-align: left;
    --header-font-size: 24px;
    --header-line-height: 1.5;
    --header-letter-spacing: 0px;
    --header-color: light-dark(
      var(--cx-color-neutral-1000),
      var(--cx-color-neutral-0)
    );
    --content-background-color: light-dark(#00000070, #00000070);
    --content-margin: 0px;
    --content-min-height: 50px;
    --content-padding: 5px 10px 5px 10px;
    --content-width: 200px;
    --content-border: 0;
    --content-border-radius: 0px;
    --transition-duration: 0.5s;
    --image-min-width: 0px;
    --image-max-width: 1000px;
    --image-min-height: 0px;
    --image-max-height: 500px;
    --highlightable-item-highlight-border-color: var(--cx-color-primary);
    --highlightable-item-highlight-color-overlay-color: transparent;
    --highlightable-item-highlight-drop-shadow: 0 0 0 0
      light-dark(transparent, transparent);
    --highlightable-item-highlight-background: transparent;
    --highlightable-item-highlight-siblings-fade-out-opacity: 0.5;
    --highlightable-item-effect-zoom-scale: 1.1;
    --highlightable-item-effect-zoom-overflow: hidden;
    --highlightable-item-effect-text-reveal-distance: 30px;
    --highlightable-item-effect-jump-distance: 10px;
    --transition-transform-duration: 0.5s;

    display: flex;
    width: var(--width, 100%);
    height: var(--height, auto);
    max-height: 100%;
  }

  ${rt}

  :host([block]) {
    width: 100%;
  }

  :host([height-mode='auto']) {
    height: auto;
  }

  .container {
    container-name: asset-container;
    container-type: inline-size;
    padding: var(--padding, 0px);
    position: relative;
    width: 100%;
    max-height: 100%;
    border-color: var(--border-color, transparent);
    border-style: var(--border-style, solid);
    border-width: var(--border-width, 0px);
    overflow: hidden;
  }

  .container:has(.highlighter:focus-visible) {
    outline: var(--cx-focus-ring);
    outline-offset: var(--cx-focus-ring-offset);
  }

  .container--empty {
    height: var(--height, 300px);
    min-height: var(--min-height, 100%);
  }

  .container--empty::before {
    align-items: center;
    background-color: #000000;
    color: #ffffff;
    content: attr(data-empty-label);
    display: flex;
    font-family: var(--cx-font-sans);
    font-size: clamp(
      var(--cx-font-size-x-small),
      4cqw,
      var(--cx-font-size-large)
    );
    font-weight: var(--cx-font-weight-semibold);
    height: 100%;
    justify-content: center;
    line-height: 1;
    text-align: center;
    text-shadow: 0.05em 0.05em 0.1em #000;
    vertical-align: middle;
    width: 100%;
  }

  .container--empty.container--loading::before {
    content: '';
  }

  .container--resizing {
    outline: 2px dashed var(--cx-color-primary);
    user-select: none;
  }

  .highlighter {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .highlighter:focus-visible {
    outline: none;
  }

  .highlightable-item {
    background-color: var(--highlightable-item-background-color);
    display: flex;
    align-items: center;
    justify-content: var(--justify-content);
    width: 100%;
    height: 100%;
  }

  .highlightable-item--has-action {
    cursor: pointer;
  }

  .image {
    border-radius: var(--border-radius);
    border: var(--border) solid;
    display: block;
    transition: inherit;
  }

  .image--fill {
    object-fit: fill;
  }

  .image--contain {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
  }

  .image--cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
  }

  .image--none {
    object-fit: none;
  }

  .image--scale-down {
    object-fit: scale-down;
  }

  .image--hidden {
    display: none;
  }

  .image--can-zoom {
    cursor: zoom-in;
  }

  .image--has-action {
    cursor: pointer;
  }

  .image--contain.image--landscape {
    width: 100%;
    height: auto;
  }

  .image--contain.image--portrait {
    width: auto;
    height: 100%;
  }

  .popup-container::part(popup) {
    z-index: -1;
  }

  .zoom-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    opacity: 1;
  }

  .zoom-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: -1;
  }

  .zoom-image--hidden {
    opacity: 0;
  }

  .medium-zoom-image--hidden {
    opacity: 0;
  }

  .skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  .skeleton cx-skeleton {
    width: 100%;
    height: 100%;
    --border-radius: 0;
  }

  .fallback {
    position: relative;
  }

  .fallback cx-icon {
    --font-size: var(--cx-font-size-4x-large);
  }
`;
var at = Object.defineProperty, nt = Object.getOwnPropertyDescriptor, c = (e, t, r, h) => {
  for (var o = h > 1 ? void 0 : h ? nt(t, r) : t, g = e.length - 1, u; g >= 0; g--)
    (u = e[g]) && (o = (h ? u(t, r, o) : u(o)) || o);
  return h && o && at(t, r, o), o;
};
let l = class extends D {
  constructor() {
    super(...arguments), this.localize = new Ae(this), this._retryCount = 0, this._retryTimer = null, this.isLoaded = !1, this.isError = !1, this._retryIndex = 0, this.src = "", this.placeholder = "", this.alt = "", this.objectFit = $e.Fill, this.skeleton = !1, this.fallback = !1, this.canZoom = !1, this.loading = !1, this.block = !1, this.htmlLoading = "lazy", this.clickHandlerType = Y.Automatic, this.retryOnError = !1, this.maxRetries = 3, this.isZoomed = !1, this.imageRatio = 1, this.parsedAlt = "", this.parsedAltDarkMode = "", this.zoom = null, this.lastPatchedWidth = null;
  }
  get currentAltValue() {
    return this.alt;
  }
  get currentSrc() {
    return this.src;
  }
  get highlighterTabindex() {
    return this.hasZoomAction && this.clickHandlerType === Y.Automatic ? "0" : void 0;
  }
  get highlighterRole() {
    return this.hasZoomAction && this.clickHandlerType === Y.Automatic ? "button" : "img";
  }
  get highlighterClass() {
    return {
      "highlightable-item": !0,
      "highlightable-item--effect-text-reveal": this.effect === q.TextReveal,
      [`highlightable-item--text-reveal-style-${this.textRevealStyle}`]: !0
    };
  }
  get imageClass() {
    let e = "landscape", t = this.ratio;
    const r = this.width.endsWith("%") ? this.clientWidth : Number.parseFloat(this.width), h = this.isResizing ? this.resizeSize.width : r, o = this.isResizing ? this.resizeSize.height : Number.parseFloat(this.height);
    return h && o && (t = h / o), t > this.imageRatio && (e = "portrait"), {
      image: !0,
      [`image--${this.objectFit}`]: !0,
      [`image--${e}`]: !0,
      [`image--height-${this.heightMode}`]: !0,
      "image--can-zoom": this.canZoom,
      "image--has-action": this.hasZoomAction,
      "image--hidden": !this.currentSrc && !this.placeholder || this.isError && this.fallback
    };
  }
  /**
   * Whether the image have zoom action.
   */
  get hasZoomAction() {
    return this.canZoom;
  }
  runFirstUpdated() {
    this.theme = this.getTheme();
  }
  runConnectedCallback() {
    this.hasUpdated && this.requestUpdate("canZoom");
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.zoom && this.zoom.detach(), this.clearRetryTimer();
  }
  /**
   * Handle mouse enter event.
   */
  handleMouseEnter() {
    this.isHovering = !0;
  }
  /**
   * Handle mouse leave event.
   */
  handleMouseLeave() {
    this.isHovering = !1;
  }
  /**
   * If image is currently zoomed, close the zoom.
   */
  handleBlur() {
    this.isZoomed && this.zoom?.close();
  }
  handleKeyDown(e) {
    e.target === this.highlighterElement && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.highlighterElement.click());
  }
  async handleCanZoomChange() {
    await this.updateComplete, this.hasZoomAction ? this.initZoom() : (this.zoom?.detach(), this.zoom = null);
  }
  async handleObjectFitChange() {
    await this.updateComplete, this.requestUpdate();
  }
  handleSrcChange() {
    this.isLoaded = !1, this.isError = !1, this._retryCount = 0, this._retryIndex = 0, this.clearRetryTimer();
  }
  clearRetryTimer() {
    this._retryTimer !== null && (clearTimeout(this._retryTimer), this._retryTimer = null);
  }
  scheduleRetry() {
    const e = Math.min(1e3 * Math.pow(2, this._retryCount - 1), 1e4);
    this._retryTimer = setTimeout(() => {
      this._retryTimer = null, this._retryIndex += 1;
    }, e);
  }
  async initZoom() {
    this.zoomImageElement && !this.zoom && this.isLoaded && (this.zoom = et(this.zoomImageElement, {
      background: "light-dark(rgba(255, 255, 255, 0.8), rgba(0, 0, 0, 0.8))",
      margin: 0,
      scrollOffset: 0
    }), this.zoom.on("open", () => {
      this.emit("cx-image-zoom-open"), this.isZoomed = !0;
    }), this.zoom.on("close", () => {
      this.emit("cx-image-zoom-close"), this.isZoomed = !1;
    }));
  }
  handleLoad(e) {
    const t = e?.currentTarget ?? this.imageElement;
    if (!t)
      return;
    const { naturalHeight: r, naturalWidth: h } = t;
    this.imageRatio = h / r, this.isLoaded || (this.emit("cx-load"), this.isLoaded = !0, this.isError = !1);
  }
  handleError() {
    if (this.retryOnError && this._retryCount < this.maxRetries) {
      this._retryCount += 1, this.scheduleRetry();
      return;
    }
    this.emit("cx-error"), this.isLoaded = !0, this.isError = !0;
  }
  handleSizeChange() {
    const e = this.isResizing ? `${this.resizeSize.width}px` : this.width, t = this.isResizing ? `${this.resizeSize.height}px` : this.height;
    this.width || this.isResizing ? this.style.setProperty("--width", e) : this.style.removeProperty("--width"), this.height || this.isResizing ? this.style.setProperty("--height", t) : this.style.removeProperty("--height");
  }
  handleResize(e) {
    const { entries: t } = e.detail;
    for (const r of t)
      r.target === this.highlighterElement && this.width.endsWith("%") && !this.isResizing && Math.abs(r.contentRect.width - (this.lastPatchedWidth ?? 0)) > 1 && this.updateLastPatchedWidth(r.contentRect.width);
  }
  updateLastPatchedWidth(e) {
    this.lastPatchedWidth = e, this.requestUpdate();
  }
  /**
   * Support CMS5 click action for the image.
   */
  handleClickAction(e) {
    !(e.target instanceof HTMLElement) || this.clickHandlerType === Y.Manual || this.canZoom && this.openZoom();
  }
  updated(e) {
    super.updated(e), (e.has("width") || e.has("height") || e.has("resizeSize")) && this.handleSizeChange();
  }
  openZoom() {
    this.zoom && this.zoom.open();
  }
  renderContent() {
    const e = this.currentSrc, t = this.currentAltValue;
    return A`<div part="content" slot="anchor" class=${j(this.highlighterClass)}>${Ke(
      this._retryIndex,
      A`<img part="image" class=${j(this.imageClass)} src=${e || this.placeholder} alt=${t} aria-label=${t} crossorigin="anonymous" @load=${this.handleLoad} @error=${this.handleError} loading=${this.htmlLoading}>`
    )}</div>`;
  }
  render() {
    const e = this.hasZoomAction, t = this.currentAltValue, r = !this.currentSrc && !this.placeholder;
    return A`<div part="base" class=${j({
      container: !0,
      "container--empty": r,
      "container--loading": this.loading,
      "container--resizing": this.resizable && this.isResizeActive
    })} style=${_e({
      "--easing": this.easeCSSVariable
    })} data-empty-label=${this.localize.term("emptyImage")} @click=${this.startResizing} @keydown=${this.handleKeyDown}><cx-resize-observer @cx-resize=${this.handleResize}><div part="highlighter" tabindex=${Be(this.highlighterTabindex)} role=${this.highlighterRole} aria-label=${t} aria-roledescription=${this.localize.term("image")} class=${j(r ? {} : this.getHighlighterClass())} @click=${this.handleClickAction} @mouseenter=${this.handleMouseEnter} @mouseleave=${this.handleMouseLeave} @blur=${this.handleBlur}>${P(
      r,
      () => ue,
      () => P(
        this.effect === q.Jump || this.effect === q.Zoom,
        () => A`<cx-popup class="popup-container" strategy="absolute" active placement="center" sync="both">${this.renderContent()}</cx-popup>`,
        () => this.renderContent()
      )
    )}<div class="zoom-image-container">${P(
      e,
      () => A`<img part="zoom-image" class=${j({
        "zoom-image": !0,
        "zoom-image--hidden": !this.isZoomed
      })} src=${this.currentSrc || this.placeholder} alt="" aria-hidden="true" decoding="async" draggable="false" crossorigin="anonymous">`
    )}</div>${P(
      this.skeleton && !this.isLoaded && !this.isError || this.loading,
      () => A`<slot name="skeleton" part="skeleton"><div class=${j({
        skeleton: !0
      })}><cx-skeleton effect="sheen"></cx-skeleton></div></slot>`
    )}
          ${P(this.isError && this.fallback, () => A`<slot name="fallback" part="fallback"><cx-space class=${j({ fallback: !0 })} direction="column" align-items="center" justify-content="center"><cx-icon name="hide_image" part="fallback-icon"> </cx-icon></cx-space></slot>`)}</div></cx-resize-observer>${P(this.resizable && this.isResizeActive, () => this.renderResizer())}</div>`;
  }
};
l.styles = [Te, Xe, ot];
l.dependencies = {
  "cx-icon": Ne,
  "cx-popup": Ze,
  "cx-resize-observer": Ve,
  "cx-skeleton": Pe,
  "cx-space": Fe
};
c([
  K(".image")
], l.prototype, "imageElement", 2);
c([
  K(".zoom-image")
], l.prototype, "zoomImageElement", 2);
c([
  K(".highlighter")
], l.prototype, "highlighterElement", 2);
c([
  L()
], l.prototype, "isLoaded", 2);
c([
  L()
], l.prototype, "isError", 2);
c([
  L()
], l.prototype, "_retryIndex", 2);
c([
  d({ reflect: !0, type: String })
], l.prototype, "src", 2);
c([
  d({ reflect: !0, type: String })
], l.prototype, "placeholder", 2);
c([
  d({ reflect: !0, type: String })
], l.prototype, "alt", 2);
c([
  d({ attribute: "object-fit", reflect: !0 })
], l.prototype, "objectFit", 2);
c([
  d({ reflect: !0, type: Boolean })
], l.prototype, "skeleton", 2);
c([
  d({ reflect: !0, type: Boolean })
], l.prototype, "fallback", 2);
c([
  d({ attribute: "can-zoom", reflect: !0, type: Boolean })
], l.prototype, "canZoom", 2);
c([
  d({ reflect: !0, type: Boolean })
], l.prototype, "loading", 2);
c([
  d({ reflect: !0, type: Boolean })
], l.prototype, "block", 2);
c([
  d({ attribute: "html-loading", reflect: !0, type: String })
], l.prototype, "htmlLoading", 2);
c([
  d({ attribute: "click-handler-type", reflect: !0, type: String })
], l.prototype, "clickHandlerType", 2);
c([
  d({ attribute: "retry-on-error", type: Boolean })
], l.prototype, "retryOnError", 2);
c([
  d({ attribute: "max-retries", type: Number })
], l.prototype, "maxRetries", 2);
c([
  L()
], l.prototype, "isZoomed", 2);
c([
  L()
], l.prototype, "imageRatio", 2);
c([
  L()
], l.prototype, "parsedAlt", 2);
c([
  L()
], l.prototype, "parsedAltDarkMode", 2);
c([
  X("isLoaded"),
  X("canZoom", { waitUntilFirstUpdate: !0 })
], l.prototype, "handleCanZoomChange", 1);
c([
  X("objectFit", { waitUntilFirstUpdate: !0 })
], l.prototype, "handleObjectFitChange", 1);
c([
  X("src"),
  X("srcDarkMode")
], l.prototype, "handleSrcChange", 1);
c([
  Oe(100)
], l.prototype, "updateLastPatchedWidth", 1);
l = c([
  We("cx-image")
], l);
export {
  l as C,
  Ue as H,
  D as R,
  S as a,
  q as b,
  Y as c,
  fe as d,
  pe as e,
  se as f,
  Xe as r
};
