import { useContext as C, useState as u, useEffect as T } from "react";
import { a0 as i, eF as I, bb as E, bv as D, w as V, ba as j, bL as P, bB as O, eG as S, v as p, U as B, V as o, P as a, bh as g, bi as d, bj as m, bg as w, bl as H, bn as F, bo as b, bG as M, cw as A, bE as G, ea as f, ca as U, cb as N, eH as R } from "./684d2f28.js";
import { timelineDate as X, TimelineDataTooltip as $ } from "./2722072c.js";
import { convertTimeLineData as q } from "./7ec02a7f.js";
import "react-dom";
const z = [A], J = [{
  label: i("timeLine.left"),
  value: "left"
}, {
  label: i("timeLine.right"),
  value: "right"
}, {
  label: i("timeLine.alternate"),
  value: "alternate"
}], K = {
  value: I(q, X),
  mode: E(J, "alternate"),
  reverse: D,
  pending: V(j, i("timeLine.defaultPending")),
  onEvent: P(z),
  style: O(S),
  clickedObject: p({
    title: ""
  }),
  clickedIndex: p(0)
}, Q = async (e) => {
  if (!e)
    return null;
  try {
    const r = (await import("./f92320e2.js").then((n) => n.A))[e];
    return r ? /* @__PURE__ */ o(r, {}) : null;
  } catch (l) {
    return console.error(`Error loading icon ${e}:`, l), null;
  }
}, W = (e) => {
  const {
    value: l,
    dispatch: r,
    style: n,
    mode: Y,
    reverse: Z,
    onEvent: y
  } = e, [L, x] = u([]);
  T(() => {
    (async () => {
      const c = await Promise.all(l.map((s) => s.dot ? Q(s.dot) : Promise.resolve(null)));
      x(c);
    })();
  }, [l]);
  const k = l.map((t, c) => ({
    key: c,
    color: t == null ? void 0 : t.color,
    dot: L[c] || "",
    label: /* @__PURE__ */ o("span", {
      style: {
        color: (t == null ? void 0 : t.labelColor) || (n == null ? void 0 : n.labelColor)
      },
      children: t == null ? void 0 : t.label
    }),
    children: /* @__PURE__ */ a(g, {
      children: [/* @__PURE__ */ o(G, {
        type: "link",
        onClick: (s) => {
          s.preventDefault(), r(f("clickedObject", t, !1)), r(f("clickedIndex", c, !1)), y("click");
        },
        style: {
          cursor: "pointer",
          color: (t == null ? void 0 : t.titleColor) || (n == null ? void 0 : n.titleColor)
        },
        children: /* @__PURE__ */ o("b", {
          children: t == null ? void 0 : t.title
        })
      }), /* @__PURE__ */ o("p", {
        style: {
          color: (t == null ? void 0 : t.subTitleColor) || (n == null ? void 0 : n.subTitleColor)
        },
        children: t == null ? void 0 : t.subTitle
      })]
    })
  }));
  return /* @__PURE__ */ o("div", {
    style: {
      margin: n.margin ?? "3px",
      padding: n.padding !== "3px" ? n.padding : "20px 10px 0px 10px",
      width: U(n.margin ?? "3px"),
      height: N(n.margin ?? "3px"),
      background: n.background,
      overflow: "auto",
      overflowX: "hidden",
      borderRadius: n.radius
    },
    children: /* @__PURE__ */ o(R, {
      mode: (e == null ? void 0 : e.mode) || "left",
      reverse: e == null ? void 0 : e.reverse,
      pending: (e == null ? void 0 : e.pending) && /* @__PURE__ */ o("span", {
        style: {
          color: n == null ? void 0 : n.titleColor
        },
        children: (e == null ? void 0 : e.pending) || ""
      }),
      items: k
    })
  });
};
let h = function() {
  return new B(K, (e, l) => /* @__PURE__ */ o(W, {
    ...e,
    dispatch: l
  })).setPropertyViewFn((e) => /* @__PURE__ */ a(g, {
    children: [/* @__PURE__ */ o(d, {
      name: m.basic,
      children: e.value.propertyView({
        label: i("timeLine.value"),
        tooltip: $,
        placeholder: "[]"
      })
    }), ["logic", "both"].includes(C(w).editorModeStatus) && /* @__PURE__ */ a(d, {
      name: m.interaction,
      children: [e.onEvent.getPropertyView(), H(e)]
    }), ["layout", "both"].includes(C(w).editorModeStatus) && /* @__PURE__ */ a(g, {
      children: [/* @__PURE__ */ a(d, {
        name: m.layout,
        children: [e.mode.propertyView({
          label: i("timeLine.mode"),
          tooltip: i("timeLine.modeTooltip")
        }), e.pending.propertyView({
          label: i("timeLine.pending"),
          tooltip: i("timeLine.pendingDescription")
        }), e.reverse.propertyView({
          label: i("timeLine.reverse")
        })]
      }), /* @__PURE__ */ o(d, {
        name: m.style,
        children: e.style.getPropertyView()
      })]
    })]
  })).build();
}();
h = class extends h {
  autoHeight() {
    return !1;
  }
};
const ie = F(h, [new b("value", i("timeLine.valueDesc")), new b("clickedObject", i("timeLine.clickedObjectDesc")), new b("clickedIndex", i("timeLine.clickedIndexDesc")), M]);
export {
  ie as TimeLineComp
};
