import { useMemo as k } from "react";
import { useEnvironment as C, useModuleDictionary as v } from "@m4l/core";
import { useAreasStore as f } from "../../../../../../../hooks/useAreas/index.js";
import { shallow as d } from "zustand/shallow";
import { ICONS as u } from "../../../../../../../icons.js";
import { getAreasDictionary as a, AREAS_DICCTIONARY as c } from "../../../../../../../dictionary.js";
const S = ({
  windowId: e,
  areaId: o,
  emergeType: g
}) => {
  const { host_static_assets: t, environment_assets: i } = C(), { getLabel: l } = v(), h = `${t}/${i}/frontend/components/data_grid/assets/icons/pin.svg`, _ = `${t}/${i}/frontend/components/data_grid/assets/icons/pin-off.svg`, p = f(
    (n) => {
      const s = o ? n.hashAreas[o] : void 0;
      return s && s.currentBreakpoint && s.layouts && s.layouts[s.currentBreakpoint] && s.layouts[s.currentBreakpoint].find(
        (P) => P.i === e
      )?.colapsed || !1;
    },
    d
  ), r = f(
    (n) => o ? n.hashAreas[o]?.maximizedId : void 0,
    d
  ), m = f(
    (n) => {
      const s = n.hashWindows[e];
      return s?.emergeType === "panel" ? !!s.panelProps.pinned : !1;
    },
    d
  ), { maximizeLayout: b, normalizeLayouts: $, colapseLayoutItem: A, unColapseLayoutItem: y, setPanelPinned: L } = f((n) => n.areaActions);
  return k(() => {
    const n = [];
    return g === "layout" && (n.push({
      place: "right",
      key: "collapseToggle",
      iconUrl: p ? `${t}/${i}/frontend/components/areas/assets/icons/${u.UNCOLLPASE}` : `${t}/${i}/frontend/components/areas/assets/icons/${u.COLLAPSE}`,
      label: l(p ? a(c.label_uncollapse_window) : a(c.label_collapse_window)),
      tooltipProps: {
        placement: "bottom-end"
      },
      /**
       * Toggle the collapsed state for the current layout window.
       */
      onClick: () => {
        o && (p ? y(o, e) : A(o, e));
      },
      disabled: r !== void 0,
      color: "warning",
      className: "collapse-toggle window-actions"
    }), n.push({
      place: "right",
      key: "maximize",
      iconUrl: r ? `${t}/${i}/frontend/components/areas/assets/icons/${u.NORMALIZE}` : `${t}/${i}/frontend/components/areas/assets/icons/${u.MAXIMIZE}`,
      label: l(r ? a(c.label_minimize_window) : a(c.label_maximize_window)),
      tooltipProps: {
        placement: "bottom-end"
      },
      /**
       * Toggle the maximized state for the current layout window.
       */
      onClick: () => {
        o && (r ? $(o) : b(o, e));
      },
      disabled: !1,
      color: "info",
      className: "expand-toggle window-actions"
    })), g === "panel" && o && n.push({
      place: "right",
      key: "pinToggle",
      iconUrl: m ? _ : h,
      label: l(m ? a(c.label_unpin_panel) : a(c.label_pin_panel)),
      tooltipProps: {
        placement: "bottom-end"
      },
      /**
       * Toggle whether the current panel stays docked in the area flow.
       */
      onClick: () => {
        L(o, e, !m);
      },
      disabled: !1,
      color: "info",
      className: "pin-toggle window-actions"
    }), n;
  }, [
    p,
    r,
    m,
    t,
    i,
    h,
    _,
    l,
    o,
    e,
    A,
    y,
    $,
    b,
    L,
    g
  ]);
};
export {
  S as useRightActions
};
