import { jsx as r } from "react/jsx-runtime";
import { useState as e, useId as V, useMemo as T } from "react";
import { P as w, f as D, g as E, T as G, h as b } from "../ToolbarLayout.module-cbc8e216.js";
import { DarkModeProvider as k } from "../contexts/DarkModeContext.js";
import { ViewMode as x, ScrollMode as F, SelectionMode as y } from "../utils/types.js";
import { RotateProvider as _ } from "../contexts/RotationContext.js";
import { LayerProvider as z } from "../contexts/LayerContext.js";
import { ZoomProvider as A } from "../contexts/ZoomContext.js";
import { ViewModeProvider as N } from "../contexts/ViewModeContext.js";
import { ScrollModeProvider as Z } from "../contexts/ScrollModeContext.js";
import { VirtualScrollProvider as j } from "../contexts/VirtualScrollContext.js";
import { VirtualGridProvider as H } from "../contexts/VirtualGridContext.js";
import { SelectionModeProvider as O } from "../contexts/SelectionModeContext.js";
import { InitialStateProvider as Q } from "../contexts/InitialStateContext.js";
import { FullScreenProvider as U } from "../contexts/FullScreenContext.js";
import { FileInputProvider as W } from "../contexts/FileInputContext.js";
import { DropFileZoneProvider as X } from "../contexts/DropFileZoneContext.js";
import { LayoutContainerContext as $ } from "../contexts/LayoutContainerContext.js";
import { DimensionPagesProvider as q } from "../contexts/DimensionPagesContext.js";
import { LocalizationProvider as B } from "../contexts/LocalizationContext.js";
import { HighlightProvider as J } from "../contexts/HighlightContext.js";
import { useWatermark as K } from "../utils/hooks/useWatermark.js";
import { DownloadProvider as Y } from "../contexts/DownloadContext.js";
import { SmoothScrollProvider as rr } from "../contexts/SmoothScrollContext.js";
import { ElementPageProvider as er } from "../contexts/ElementPageContext.js";
import { PagesRotateProvider as or } from "../contexts/PagesRotateContext.js";
import { GlobalCurrentPageProvider as ir } from "../contexts/GlobalCurrentPage.js";
const br = (n) => {
  const {
    children: l,
    darkMode: d = !1,
    onDarkModeChange: m,
    initialRotation: a = 0,
    textLayer: c = !0,
    initialPage: P = 1,
    initialViewMode: h = x.SINGLE_PAGE,
    initialThumbnailsVisible: f = !1,
    initialSearch: p,
    initialScale: s,
    initialScrollMode: v = F.VERTICAL_SCROLLING,
    locale: u = "en_US",
    localization: S,
    downloadFilename: g
  } = n, [M, R] = e(null), [o, C] = e(null), [L, I] = e(null), i = V(), t = T(() => `rp-instance-${i.replace(/:/g, "-")}`, [i]);
  return K(t), /* @__PURE__ */ r(
    Q,
    {
      instanceId: t,
      initialScale: s,
      initialPage: P,
      initialScrollMode: v,
      initialRotation: a,
      initialViewMode: h,
      children: /* @__PURE__ */ r(rr, { children: /* @__PURE__ */ r(B, { locale: u, localization: S, children: /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(Z, { children: /* @__PURE__ */ r(O, { initialSelectionMode: y.TEXT, children: /* @__PURE__ */ r(_, { children: /* @__PURE__ */ r(or, { children: /* @__PURE__ */ r(z, { textLayer: c, children: /* @__PURE__ */ r(
        $.Provider,
        {
          value: {
            container: M,
            contentRef: o,
            pagesRef: L,
            setContainer: R,
            setContentRef: C,
            setPagesRef: I
          },
          children: /* @__PURE__ */ r(ir, { children: /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(q, { children: /* @__PURE__ */ r(w, { children: /* @__PURE__ */ r(
            k,
            {
              darkMode: d,
              onDarkModeChange: m,
              children: /* @__PURE__ */ r(D, { initialSearch: p, children: /* @__PURE__ */ r(J, { children: /* @__PURE__ */ r(er, { children: /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
                G,
                {
                  initialThumbnailsVisible: f,
                  children: /* @__PURE__ */ r(X, { children: /* @__PURE__ */ r(U, { elementRef: o, children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
                    Y,
                    {
                      downloadFilename: g,
                      children: /* @__PURE__ */ r(W, { children: l })
                    }
                  ) }) }) })
                }
              ) }) }) }) })
            }
          ) }) }) }) })
        }
      ) }) }) }) }) }) }) }) }) }) })
    }
  );
};
export {
  br as RPController
};
