import { dO as S, dP as k, w as a, cn as V, ba as f, cv as N, bv as g, bB as A, dQ as E, dR as P, U as F, V as d, bh as y, dS as Y, L as U, dT as h, c1 as p, y as z, dU as B, dV as x, dW as v, dX as T, dY as M, dZ as H, d_ as X, bn as W, d$ as O, a0 as b, bX as j, bG as Z, bY as q, dA as Q, e as G, d as J } from "./684d2f28.js";
import { PaginationControl as K } from "./ff81ee95.js";
import { ContextContainerComp as _ } from "./5d871440.js";
import { ListView as $ } from "./8e08bc47.js";
import { listPropertyView as ee } from "./7a0eefbc.js";
import "react";
import "react-dom";
const te = {
  noOfRows: S(k),
  // FIXME: migrate "noOfRows" to "data"
  noOfColumns: a(V, 1),
  itemIndexName: a(f, "i"),
  itemDataName: a(f, "currentItem"),
  dynamicHeight: N,
  heightUnitOfRow: a(V, 1),
  container: _,
  autoHeight: N,
  scrollbars: a(g, !1),
  showBorder: g,
  pagination: a(K, {
    pageSize: "6"
  }),
  style: A(E),
  horizontal: a(g, !1),
  minHorizontalWidth: a(P, "100px")
}, ne = new F(te, () => /* @__PURE__ */ d(y, {})).setPropertyViewFn(() => /* @__PURE__ */ d(y, {})).build();
class ie extends ne {
  getOriginalContainer() {
    return this.children.container.getSelectedComp().getComp();
  }
  realSimpleContainer(e) {
    return this.getOriginalContainer().realSimpleContainer(e);
  }
  getCompTree() {
    return this.getOriginalContainer().getCompTree();
  }
  findContainer(e) {
    return this.getOriginalContainer().findContainer(e);
  }
  getPasteValue(e) {
    return {
      ...this.toJsonValue(),
      container: this.getOriginalContainer().getPasteValue(e)
    };
  }
  autoHeight() {
    return this.children.autoHeight.getView();
  }
  reduce(e) {
    let n = Y({
      inEventContext: !0
    }, () => super.reduce(e));
    if (e.type === U.UPDATE_NODES_V2) {
      const {
        itemCount: l
      } = h(n.children.noOfRows.getView()), r = n.children.pagination.getView(), c = r.total || l, s = (r.current - 1) * r.pageSize;
      s >= c && r.current > 1 ? setTimeout(() => n.children.pagination.children.pageNo.dispatchChangeValueAction(1)) : String(s) !== this.children.container.getSelection() && setTimeout(() => n.children.container.dispatch(_.setSelectionAction(String(s))));
    }
    return n;
  }
  /** expose the data from inner comps */
  itemsNode() {
    const {
      itemCount: e
    } = h(this.children.noOfRows.getView()), n = this.children.itemIndexName.getView(), l = this.children.itemDataName.getView(), r = this.children.noOfRows.exposingNode(), c = this.children.container, s = p(p.range(0, e)).toPairs().fromPairs().mapValues((o) => {
      let m = c.getCachedComp(String(o)) ?? c.getOriginalComp();
      const R = z(m.getComp().getCompTree()), w = p(R).mapKeys((i) => i.children.name.getView()).mapValues((i) => i.children.comp.exposingNode()).value(), I = {
        [n]: B(o),
        [l]: x(r, (i) => typeof i == "number" ? {} : i[o])
      }, L = new v(T(w), I);
      return M(this, "exposing_row_" + o, [L, r, w, n, l], (i, C) => i[1] === C[1] && H(i.slice(2), C.slice(2), 3))[0];
    }).value(), D = x(T(s), (o) => p.range(0, e).map((m) => o[m]));
    return M(this, "exposing_data", [D, s], (o, m) => X(o[1], m[1]))[0];
  }
}
const oe = J(ie, (t) => /* @__PURE__ */ d($, {
  comp: t
})), ae = ee("listView");
let u = G(oe, (t) => /* @__PURE__ */ d(ae, {
  comp: t
}));
u = W(u, [
  new O("items", (t) => ({
    data: t.itemsNode()
  }), (t) => t.data, b("listView.itemsDesc")),
  j({
    name: "data",
    desc: b("listView.dataDesc"),
    depKeys: ["noOfRows"],
    func: (t) => {
      const {
        data: e
      } = h(t.noOfRows);
      return e;
    }
  }),
  new O("pageNo", (t) => ({
    index: t.children.pagination.children.pageNo.exposingNode()
  }), (t) => t.index, "Page Number"),
  Z
]);
const he = q(u, [{
  method: {
    name: "setPage",
    description: "",
    params: [{
      name: "page",
      type: "number"
    }]
  },
  execute: (t, e) => {
    const n = e[0];
    n && n > 0 && t.children.pagination.children.pageNo.dispatchChangeValueAction(n);
  }
}]);
function ue(t, e) {
  return {
    noOfRows: `[
  {
    "rate": "9.2",
    "title": "The Shawshank Redemption",
    "url": "https://www.imdb.com/title/tt0111161/",
    "cover": "https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UY67_CR0,0,45,67_AL_.jpg"
  },
  {
    "rate": "9.2",
    "title": "The Godfather",
    "url": "https://www.imdb.com/title/tt0068646/",
    "cover": "https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UY67_CR1,0,45,67_AL_.jpg"
  },
  {
    "rate": "9.0",
    "title": "The Dark Knight",
    "url": "https://www.imdb.com/title/tt0468569/",
    "cover": "https://m.media-amazon.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_UY67_CR0,0,45,67_AL_.jpg"
  }
]`,
    container: Q([{
      item: {
        compType: "image",
        name: e.genItemName("image"),
        comp: {
          src: "{{currentItem.cover}}",
          autoHeight: "fixed"
        }
      },
      layoutItem: {
        i: "",
        w: 6,
        h: 14,
        x: 0,
        y: 0
      }
    }, {
      item: {
        compType: "link",
        name: e.genItemName("link"),
        comp: {
          text: "{{i+1}}. {{currentItem.title}}",
          onEvent: [{
            name: "click",
            handler: {
              compType: "goToURL",
              comp: {
                url: "{{currentItem.url}}",
                inNewTab: !0
              },
              condition: "",
              slowdown: "debounce",
              delay: ""
            }
          }]
        }
      },
      layoutItem: {
        i: "",
        h: 5,
        w: 17,
        x: 7,
        y: 0
      }
    }, {
      item: {
        compType: "rating",
        name: e.genItemName("rating"),
        comp: {
          defaultValue: "{{currentItem.rate / 2}}",
          max: "5",
          label: {
            text: "",
            width: "33",
            widthUnit: "%",
            position: "row",
            align: "right"
          },
          allowHalf: !0,
          disabled: !0
        }
      },
      layoutItem: {
        i: "",
        h: 5,
        w: 17,
        x: 7,
        y: 9
      }
    }])
  };
}
export {
  he as ListViewComp,
  ie as ListViewImplComp,
  ue as defaultListViewData
};
