"use client";
import { useContext as f, useCallback as u } from "react";
import { GanttContext as d } from "../components/Gantt/GanttContext.js";
import { getScaleDates as D } from "../utils/getScaleDates.js";
import { getInitialScrollOffset as z } from "../utils/getInitialScrollOffset.js";
import { DragStepOptions as C } from "../constants/DragStepOptions.js";
import { GanttDimensionsSettings as b } from "../constants/DimensionsSettings.js";
const k = () => {
  const { setScaleDates: r, wrapRef: s, settings: t, setSettings: o, currentDate: e } = f(d);
  return { calculate: u(
    (a) => {
      const {
        stepWidth: i,
        itemsCount: S,
        scaleStepItems: g,
        secondsInPixel: l,
        unitOfTime: p
      } = b[a], n = D(e, S, p), c = z(
        a,
        n,
        e
      ), m = C[t.dragStepSize].seconds / l;
      o({
        stepWidth: i,
        initialScrollOffset: c,
        scaleStepItems: g,
        secondsInPixel: l,
        dimension: a,
        dragStepSize: t.dragStepSize,
        gridSize: m,
        draggable: t.draggable
      }), r(n), s.current?.scrollTo({ left: c });
    },
    [
      e,
      r,
      o,
      t.dragStepSize,
      t.draggable,
      s
    ]
  ) };
};
export {
  k as useGanttCalculate
};
