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: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__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: true }), mod);

// src/plus/pisellReservation/hooks/useReservationResponsiveVariant.ts
var useReservationResponsiveVariant_exports = {};
__export(useReservationResponsiveVariant_exports, {
  PISELL_RESERVATION_PHONE_MAX_WIDTH: () => PISELL_RESERVATION_PHONE_MAX_WIDTH,
  default: () => useReservationResponsiveVariant_default,
  useReservationResponsiveVariant: () => useReservationResponsiveVariant
});
module.exports = __toCommonJS(useReservationResponsiveVariant_exports);
var import_react = require("react");
var PISELL_RESERVATION_PHONE_MAX_WIDTH = 768;
function readPhoneByWidth() {
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
    return false;
  }
  return window.matchMedia(
    `(max-width: ${PISELL_RESERVATION_PHONE_MAX_WIDTH}px)`
  ).matches;
}
function useReservationResponsiveVariant(forced) {
  const [isPhone, setIsPhone] = (0, import_react.useState)(() => readPhoneByWidth());
  (0, import_react.useEffect)(() => {
    var _a;
    if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
      return void 0;
    }
    const mql = window.matchMedia(
      `(max-width: ${PISELL_RESERVATION_PHONE_MAX_WIDTH}px)`
    );
    const handle = (event) => {
      setIsPhone(Boolean(event.matches));
    };
    handle(mql);
    if (typeof mql.addEventListener === "function") {
      mql.addEventListener(
        "change",
        handle
      );
      return () => {
        mql.removeEventListener(
          "change",
          handle
        );
      };
    }
    const legacy = mql;
    (_a = legacy.addListener) == null ? void 0 : _a.call(legacy, handle);
    return () => {
      var _a2;
      (_a2 = legacy.removeListener) == null ? void 0 : _a2.call(legacy, handle);
    };
  }, []);
  if (typeof forced === "string" && forced.length > 0) {
    return forced;
  }
  return isPhone ? "phone" : "desktop";
}
var useReservationResponsiveVariant_default = useReservationResponsiveVariant;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PISELL_RESERVATION_PHONE_MAX_WIDTH,
  useReservationResponsiveVariant
});
