import { jsx as t, jsxs as p } from "@emotion/react/jsx-runtime";
import { PageNode as f } from "../../subcomponents/PageNode/index.js";
import { BaseProvider as P } from "@m4l/core";
import $ from "react";
import { FactoryRender as k } from "../FactoryRender/index.js";
const D = (g) => {
  const {
    data: r,
    id: i,
    unitSize: m,
    mainColor: y,
    countPages: c,
    HeaderGeneral: a,
    FooterGeneral: o,
    sourceData: d,
    templateData: s
  } = g, { children: e, key: u, ...h } = r || {};
  return /* @__PURE__ */ t(
    P,
    {
      value: {
        pageId: i,
        unitSize: m,
        mainColor: y,
        countPages: c,
        HeaderGeneral: a,
        FooterGeneral: o,
        templateData: s,
        sourceData: d
      },
      children: /* @__PURE__ */ p(f, { ...h, children: [
        Array.isArray(e) && e.length > 0 ? e.map((l, n) => /* @__PURE__ */ p($.Fragment, { children: [
          n === 0 && r.type === "page" && e[0].type !== "header" && a ? /* @__PURE__ */ t(a, { ancestor: r }, `${r.key}-header`) : null,
          /* @__PURE__ */ t(k, { data: l }, `${r.type}-${l.key}`),
          n === e.length - 1 && r.type === "page" && e[e.length - 1].type !== "footer" && o ? /* @__PURE__ */ t(o, { ancestor: r }, `${r.key}-footer`) : null
        ] }, `fragment-page-${n}`)) : null,
        typeof e == "string" ? e : null
      ] }, u)
    }
  );
};
export {
  D as PageRender
};
