import { useMemo as p } from "react";
import { useAreasStore as s } from "../../../../../../../hooks/useAreas/index.js";
import { PANEL_DEFAULT_HEIGHT as a, PANEL_DEFAULT_WIDTH as d, PANEL_SIDES as h } from "../helpers/panelRuntime.js";
const f = (i) => {
  const o = s((n) => {
    const r = n.hashAreas[i];
    return r ? r.panelItemsIds.map((e) => {
      const t = n.hashWindows[e];
      if (t?.emergeType === "panel")
        return {
          windowId: e,
          side: t.panelProps.side,
          pinned: !!t.panelProps.pinned,
          width: t.panelProps.width ?? d,
          height: t.panelProps.height ?? a,
          maxWidth: t.panelProps.maxWidth,
          maxHeight: t.panelProps.maxHeight
        };
    }).filter((e) => e !== void 0) : [];
  });
  return p(() => h.reduce(
    (n, r) => (n.pinned[r] = o.filter(
      (e) => e.side === r && e.pinned
    ), n.overlay[r] = o.filter(
      (e) => e.side === r && !e.pinned
    ), n),
    {
      pinned: {
        top: [],
        left: [],
        right: [],
        bottom: []
      },
      overlay: {
        top: [],
        left: [],
        right: [],
        bottom: []
      }
    }
  ), [o]);
};
export {
  f as usePanelsByArea
};
