import z from "./index-objectWithoutPropertiesLoose.js";
import i from "./index-extends.js";
import * as p from "react";
import { useViews as B } from "./index-useViews.js";
import { ClockPicker as G } from "./index-ClockPicker.js";
import { CalendarPicker as J } from "./index-CalendarPicker.js";
import { KeyboardDateInput as Q } from "./index-KeyboardDateInput.js";
import { useIsLandscape as X } from "./index-useIsLandscape.js";
import { WrapperVariantContext as Y } from "./index-WrapperVariantContext.js";
import { useFocusManagement as Z } from "./index-useFocusManagement.js";
import { getCalendarOrClockPickerUtilityClass as ee } from "./index-calendarOrClockPickerClasses.js";
import { jsxs as v, jsx as t } from "react/jsx-runtime";
import oe from "./index-useThemeProps.js";
import { PickerViewRoot as ne } from "./index-PickerViewRoot.js";
import te from "./index-composeClasses.js";
import M from "./index-styled.js";
const re = ["autoFocus", "className", "parsedValue", "DateInputProps", "isMobileKeyboardViewOpen", "onDateChange", "onViewChange", "openTo", "orientation", "showToolbar", "toggleMobileKeyboardView", "ToolbarComponent", "toolbarFormat", "toolbarPlaceholder", "toolbarTitle", "views", "dateRangeIcon", "timeIcon", "hideTabs", "classes"], ie = (e) => {
  const {
    classes: o
  } = e;
  return te({
    root: ["root"],
    mobileKeyboardInputView: ["mobileKeyboardInputView"]
  }, ee, o);
}, ae = M("div", {
  name: "MuiCalendarOrClockPicker",
  slot: "MobileKeyboardInputView",
  overridesResolver: (e, o) => o.mobileKeyboardInputView
})({
  padding: "16px 24px"
}), se = M("div", {
  name: "MuiCalendarOrClockPicker",
  slot: "Root",
  overridesResolver: (e, o) => o.root
})(({
  ownerState: e
}) => i({
  display: "flex",
  flexDirection: "column"
}, e.isLandscape && {
  flexDirection: "row"
})), le = {
  fullWidth: !0
}, x = (e) => e === "year" || e === "month" || e === "day", O = (e) => e === "hours" || e === "minutes" || e === "seconds";
let K = !1;
function ye(e) {
  var o, d;
  const m = oe({
    props: e,
    name: "MuiCalendarOrClockPicker"
  }), {
    autoFocus: u,
    parsedValue: w,
    DateInputProps: F,
    isMobileKeyboardViewOpen: s,
    onDateChange: V,
    onViewChange: b,
    openTo: f,
    orientation: D,
    showToolbar: g,
    toggleMobileKeyboardView: h,
    ToolbarComponent: R = () => null,
    toolbarFormat: _,
    toolbarPlaceholder: N,
    toolbarTitle: L,
    views: r,
    dateRangeIcon: j,
    timeIcon: $,
    hideTabs: S
  } = m, a = z(m, re), P = (o = a.components) == null ? void 0 : o.Tabs, k = X(r, D), l = p.useContext(Y), T = ie(m), U = g ?? l !== "desktop", W = !S && typeof window < "u" && window.innerHeight > 667, y = p.useCallback((C, q) => {
    V(C, l, q);
  }, [V, l]), E = p.useCallback((C) => {
    s && h(), b && b(C);
  }, [s, b, h]);
  process.env.NODE_ENV !== "production" && !K && !r.includes(f) && (K = !0);
  const {
    openView: n,
    setOpenView: c,
    handleChangeAndOpenNext: I
  } = B({
    view: void 0,
    views: r,
    openTo: f,
    onChange: y,
    onViewChange: E
  }), {
    focusedView: A,
    setFocusedView: H
  } = Z({
    autoFocus: u,
    openView: n
  });
  return /* @__PURE__ */ v(se, {
    ownerState: {
      isLandscape: k
    },
    className: T.root,
    children: [U && /* @__PURE__ */ t(R, i({}, a, {
      views: r,
      isLandscape: k,
      parsedValue: w,
      onChange: y,
      setOpenView: c,
      openView: n,
      toolbarTitle: L,
      toolbarFormat: _,
      toolbarPlaceholder: N,
      isMobileKeyboardViewOpen: s,
      toggleMobileKeyboardView: h
    })), W && !!P && /* @__PURE__ */ t(P, i({
      dateRangeIcon: j,
      timeIcon: $,
      view: n,
      onChange: c
    }, (d = a.componentsProps) == null ? void 0 : d.tabs)), /* @__PURE__ */ t(ne, {
      children: s ? /* @__PURE__ */ t(ae, {
        className: T.mobileKeyboardInputView,
        children: /* @__PURE__ */ t(Q, i({}, F, {
          ignoreInvalidInputs: !0,
          disableOpenPicker: !0,
          TextFieldProps: le
        }))
      }) : /* @__PURE__ */ v(p.Fragment, {
        children: [x(n) && /* @__PURE__ */ t(J, i({
          autoFocus: u,
          date: w,
          onViewChange: c,
          onChange: I,
          view: n,
          views: r.filter(x),
          focusedView: A,
          onFocusedViewChange: H
        }, a)), O(n) && /* @__PURE__ */ t(G, i({}, a, {
          autoFocus: u,
          date: w,
          view: n,
          views: r.filter(O),
          onChange: I,
          onViewChange: c,
          showViewSwitcher: l === "desktop"
        }))]
      })
    })]
  });
}
export {
  ye as CalendarOrClockPicker,
  ae as MobileKeyboardInputView
};
