var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
  if (from && typeof from == "object" || typeof from == "function")
    for (let key of __getOwnPropNames(from))
      !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var MonthPicker_exports = {};
__export(MonthPicker_exports, {
  MONTH: () => MONTH,
  MonthPicker: () => MonthPicker
});
module.exports = __toCommonJS(MonthPicker_exports);
var import_jsx_runtime = require("react/jsx-runtime"), import_icons_ui = require("@truststack/icons-ui"), import_react = require("react"), import_react_native = require("react-native"), import_tamagui = require("tamagui"), import_DatePickerProvider = require("./DatePickerProvider"), import_Dialog = require("./Dialog"), import_Grid = require("./Grid"), import_Icon = require("./Icon"), import_IconButton = require("./IconButton"), import_Sheet = require("./Sheet"), import_typography = require("./typography"), MONTH = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December"
];
function MonthPicker(param) {
  var { value, year, ...props } = param, [open, setOpen] = (0, import_react.useState)(!1), [selectedMonth, setSelectedMonth] = (0, import_react.useState)(), { onDateSelect } = (0, import_DatePickerProvider.useDatepickerContext)();
  return (0, import_react.useEffect)(function() {
    selectedMonth && onDateSelect(new Date(year, MONTH.indexOf(selectedMonth)));
  }, [
    selectedMonth
  ]), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.Dialog, {
    allowFlip: !0,
    open,
    onOpenChange: setOpen,
    children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Pressable, {
        onPress: function() {
          setOpen(!0);
        },
        style: {
          flexGrow: 1
        },
        children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
          gap: 4,
          alignItems: "center",
          justifyContent: "center",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Icon.Icon, {
              size: 14,
              Icon: import_icons_ui.ChevronDown
            }),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_typography.Body, {
              textAlign: "center",
              children: value
            })
          ]
        })
      }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Adapt, {
        when: "sm",
        platform: "touch",
        children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Sheet.Sheet, {
          modal: !0,
          snapPoints: [
            40
          ],
          dismissOnSnapToBottom: !0,
          moveOnKeyboardChange: !0,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Sheet.Sheet.Overlay, {}),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Sheet.Sheet.Handle, {}),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Sheet.Sheet.Frame, {
              children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Sheet.SheetContent, {
                children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Adapt.Contents, {})
              })
            })
          ]
        })
      }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.Dialog.Portal, {
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.Dialog.Overlay, {}, "month-picker-overlay"),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.Dialog.Content, {
            width: 360,
            marginTop: 12,
            backgroundColor: "$surfaceContainerHigh",
            borderRadius: "$shape.corner_l",
            padding: "$spacing.margin_compact",
            borderColor: "$color.outline",
            borderWidth: "$border.outline",
            children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.Grid, {
              width: "100%",
              children: MONTH.map(function(month, index) {
                return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.Grid.Item, {
                  compact: 4,
                  exp: 4,
                  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonthButton, {
                    onPress: function() {
                      setOpen(!1), setSelectedMonth(month);
                    },
                    hoverStyle: {
                      col: "$onSurfaceVariant"
                    },
                    col: "$onSurface",
                    selected: month == value,
                    ...props,
                    children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonthText, {
                      children: month
                    })
                  })
                }, `month-${index}`);
              })
            })
          }, "month-picker-content")
        ]
      }, "month-picker-portal")
    ]
  });
}
var MonthButton = (0, import_tamagui.styled)(import_IconButton.IconButton, {
  name: "MonthButton",
  bc: "transparent",
  m: 4,
  mb: 4,
  w: 100,
  hoverStyle: {
    col: "$onSurfaceVariant"
  },
  variants: {
    selected: {
      true: {
        backgroundColor: "$outlineVariant"
      }
    }
  }
}), MonthText = (0, import_tamagui.styled)(import_tamagui.Text, {
  name: "MonthText",
  bc: "transparent",
  variants: {
    selected: {
      true: {
        color: "$onTertiary"
      }
    }
  }
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  MONTH,
  MonthPicker
});
//# sourceMappingURL=MonthPicker.js.map
