import { useMemo as b } from "react";
import { useEnvironment as d, useModuleDictionary as L } from "@m4l/core";
import { useAreasStore as u } from "../../../../../../../hooks/useAreas/index.js";
import { shallow as y } from "zustand/shallow";
import { ICONS as c } from "../../../../../../../icons.js";
import { getAreasDictionary as m, AREAS_DICCTIONARY as p } from "../../../../../../../dictionary.js";
const v = ({
  windowId: t,
  areaId: o,
  emergeType: _
}) => {
  const { host_static_assets: n, environment_assets: i } = d(), { getLabel: a } = L(), r = u(
    (e) => {
      const s = o ? e.hashAreas[o] : void 0;
      return s && s.currentBreakpoint && s.layouts && s.layouts[s.currentBreakpoint] && s.layouts[s.currentBreakpoint].find(
        ($) => $.i === t
      )?.colapsed || !1;
    },
    y
  ), l = u(
    (e) => o ? e.hashAreas[o]?.maximizedId : void 0,
    y
  ), { maximizeLayout: f, normalizeLayouts: A, colapseLayoutItem: g, unColapseLayoutItem: h } = u((e) => e.areaActions);
  return b(() => {
    const e = [];
    return _ === "layout" && (e.push({
      place: "right",
      key: "collapseToggle",
      iconUrl: r ? `${n}/${i}/frontend/components/areas/assets/icons/${c.UNCOLLPASE}` : `${n}/${i}/frontend/components/areas/assets/icons/${c.COLLAPSE}`,
      label: a(r ? m(p.label_uncollapse_window) : m(p.label_collapse_window)),
      tooltipProps: {
        placement: "bottom-end"
      },
      /**
       * Acción de collapse/expand.
       */
      onClick: () => {
        o && (r ? h(o, t) : g(o, t));
      },
      disabled: l !== void 0,
      color: "warning",
      className: "collapse-toggle window-actions"
    }), e.push({
      place: "right",
      key: "maximize",
      iconUrl: l ? `${n}/${i}/frontend/components/areas/assets/icons/${c.NORMALIZE}` : `${n}/${i}/frontend/components/areas/assets/icons/${c.MAXIMIZE}`,
      label: a(l ? m(p.label_minimize_window) : m(p.label_maximize_window)),
      tooltipProps: {
        placement: "bottom-end"
      },
      /**
       * Acción de maximize/normalize.
       */
      onClick: () => {
        o && (l ? A(o) : f(o, t));
      },
      disabled: !1,
      color: "info",
      className: "expand-toggle window-actions"
    })), e;
  }, [
    r,
    l,
    n,
    i,
    a,
    o,
    t,
    g,
    h,
    A,
    f
  ]);
};
export {
  v as useRightActions
};
