import { dY as L, w as i, aH as V, dZ as A, V as m, a5 as f, d_ as E, aG as z, U as F, H as g, I as N, d$ as P, e0 as H, e1 as h, _ as d, y as Y, e2 as U, e3 as y, e4 as B, e5 as x, e6 as M, e7 as X, e8 as j, ah as v, e9 as T, a4 as O, cs as W, ai as Z, ct as q, dX as G, ea as J, ak as S, X as _, eb as K, ec as Q, e as $, d as ee } from "./56c67d3b.js";
import { ContextContainerComp as D } from "./40fca083.js";
import { ListView as te } from "./4fe224ad.js";
import { listPropertyView as ne } from "./270283bf.js";
import "react";
import "react-dom";
const ie = {
  noOfRows: L(J),
  // FIXME: migrate "noOfRows" to "data"
  noOfColumns: i(S, 1),
  itemIndexName: i(_, "i"),
  itemDataName: i(_, "currentItem"),
  dynamicHeight: V,
  heightUnitOfRow: i(S, 1),
  container: D,
  autoHeight: V,
  showVerticalScrollbar: i(m, !1),
  showHorizontalScrollbar: i(m, !1),
  horizontalGridCells: A,
  scrollbars: i(m, !1),
  showBorder: m,
  pagination: i(K, {
    pageSize: "6"
  }),
  style: f(E, "style"),
  animationStyle: f(z, "animationStyle"),
  horizontal: i(m, !1),
  minHorizontalWidth: i(Q, "100px")
}, oe = new F(ie, () => /* @__PURE__ */ g(N, {})).setPropertyViewFn(() => /* @__PURE__ */ g(N, {})).build();
class ae extends oe {
  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 = P({
      inEventContext: !0
    }, () => super.reduce(e));
    if (e.type === H.UPDATE_NODES_V2) {
      const {
        itemCount: c
      } = h(n.children.noOfRows.getView()), r = n.children.pagination.getView(), p = r.total || c, s = (r.current - 1) * r.pageSize;
      s >= p && r.current > 1 ? setTimeout(() => n.children.pagination.children.pageNo.dispatchChangeValueAction(1)) : String(s) !== this.children.container.getSelection() && setTimeout(() => n.children.container.dispatch(D.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(), c = this.children.itemDataName.getView(), r = this.children.noOfRows.exposingNode(), p = this.children.container, s = d(d.range(0, e)).toPairs().fromPairs().mapValues((a) => {
      let l = p.getCachedComp(String(a)) ?? p.getOriginalComp();
      const R = Y(l.getComp().getCompTree()), w = d(R).mapKeys((o) => o.children.name.getView()).mapValues((o) => o.children.comp.exposingNode()).value(), b = {
        [n]: U(a),
        [c]: y(r, (o) => typeof o == "number" ? {} : o[a])
      }, k = new B(x(w), b);
      return M(this, "exposing_row_" + a, [k, r, w, n, c], (o, C) => o[1] === C[1] && X(o.slice(2), C.slice(2), 3))[0];
    }).value(), I = y(x(s), (a) => d.range(0, e).map((l) => a[l]));
    return M(this, "exposing_data", [I, s], (a, l) => j(a[1], l[1]))[0];
  }
}
const re = ee(ae, (t) => /* @__PURE__ */ g(te, {
  comp: t
})), se = ne("listView");
let u = $(re, (t) => /* @__PURE__ */ g(se, {
  comp: t
}));
u = v(u, [
  new T("items", (t) => ({
    data: t.itemsNode()
  }), (t) => t.data, O("listView.itemsDesc")),
  W({
    name: "data",
    desc: O("listView.dataDesc"),
    depKeys: ["noOfRows"],
    func: (t) => {
      const {
        data: e
      } = h(t.noOfRows);
      return e;
    }
  }),
  new T("pageNo", (t) => ({
    index: t.children.pagination.children.pageNo.exposingNode()
  }), (t) => t.index, "Page Number"),
  Z
]);
const ue = 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 we(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: G([{
      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 {
  ue as ListViewComp,
  ae as ListViewImplComp,
  we as defaultListViewData
};
