import { useState as y, useCallback as o, useMemo as M } from "react";
const S = 0.25, f = 4, e = 0.15, i = 50, c = { scale: 1, x: 0, y: 0 }, O = () => {
  const [t, n] = y(c), r = o(() => {
    n((s) => ({
      ...s,
      scale: Math.min(s.scale + e, f)
    }));
  }, []), l = o(() => {
    n((s) => ({
      ...s,
      scale: Math.max(s.scale - e, S)
    }));
  }, []), m = o(() => {
    n(c);
  }, []), x = o((s, u) => {
    n((a) => ({
      ...a,
      x: a.x + s,
      y: a.y + u
    }));
  }, []);
  return {
    style: M(
      () => ({
        transform: `translate(${t.x}px, ${t.y}px) scale(${t.scale})`,
        transformOrigin: "center center",
        transition: "transform 0.15s ease-out"
      }),
      [t.scale, t.x, t.y]
    ),
    zoomIn: r,
    zoomOut: l,
    reset: m,
    pan: x,
    panStep: i
  };
};
export {
  O as usePanZoom
};
