import { useState } from "react";
import { useIsomorphicEffect } from "../use-isomorphic-effect/use-isomorphic-effect.mjs";
function useOrientation() {
  const [orientation, setOrientation] = useState({ angle: 0, type: "landscape-primary" });
  const handleOrientationChange = (event) => {
    const target = event.currentTarget;
    setOrientation({ angle: (target == null ? void 0 : target.angle) || 0, type: (target == null ? void 0 : target.type) || "landscape-primary" });
  };
  useIsomorphicEffect(() => {
    var _a;
    (_a = window.screen.orientation) == null ? void 0 : _a.addEventListener("change", handleOrientationChange);
    return () => {
      var _a2;
      return (_a2 = window.screen.orientation) == null ? void 0 : _a2.removeEventListener("change", handleOrientationChange);
    };
  }, []);
  return orientation;
}
export {
  useOrientation
};
