import * as c from "react";
import { arrayIncludes as b } from "./index-utils11.js";
import h from "./index-useControlled2.js";
function S({
  onChange: r,
  onViewChange: l,
  openTo: a,
  view: x,
  views: e
}) {
  var u, d;
  const [o, f] = h({
    name: "Picker",
    state: "view",
    controlled: x,
    default: a && b(e, a) ? a : e[0]
  }), O = (u = e[e.indexOf(o) - 1]) != null ? u : null, n = (d = e[e.indexOf(o) + 1]) != null ? d : null, i = c.useCallback((t) => {
    f(t), l && l(t);
  }, [f, l]), s = c.useCallback(() => {
    n && i(n);
  }, [n, i]);
  return {
    handleChangeAndOpenNext: c.useCallback((t, p) => {
      const m = p === "finish";
      r(t, m && n ? "partial" : p), m && s();
    }, [n, r, s]),
    nextView: n,
    previousView: O,
    openNext: s,
    openView: o,
    setOpenView: i
  };
}
export {
  S as useViews
};
