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/hooks/useResponsive.ts
var useResponsive_exports = {};
__export(useResponsive_exports, {
  configResponsive: () => configResponsive,
  default: () => useResponsive
});
module.exports = __toCommonJS(useResponsive_exports);
var import_react = require("react");
var import_utils = require("../utils");
var subscribers = /* @__PURE__ */ new Set();
var info;
var responsiveConfig = {
  phone: 0,
  ipad: 800,
  pc: 1080
};
function handleResize() {
  const oldInfo = info;
  calculate();
  if (oldInfo === info) return;
  for (const subscriber of subscribers) {
    subscriber();
  }
}
var listening = false;
function calculate() {
  const width = window.innerWidth;
  const newInfo = {};
  let shouldUpdate = false;
  for (const key of Object.keys(responsiveConfig)) {
    newInfo[key] = width >= responsiveConfig[key];
    if (newInfo[key] !== info[key]) {
      shouldUpdate = true;
    }
  }
  if (shouldUpdate) {
    info = newInfo;
  }
}
function configResponsive(config) {
  responsiveConfig = config;
  if (info) calculate();
}
function useResponsive() {
  if (import_utils.isBrowser && !listening) {
    info = {};
    calculate();
    window.addEventListener("resize", handleResize);
    listening = true;
  }
  const [state, setState] = (0, import_react.useState)(info);
  (0, import_react.useEffect)(() => {
    if (!import_utils.isBrowser) return;
    if (!listening) {
      window.addEventListener("resize", handleResize);
    }
    const subscriber = () => {
      setState(info);
    };
    subscribers.add(subscriber);
    return () => {
      subscribers.delete(subscriber);
      if (subscribers.size === 0) {
        window.removeEventListener("resize", handleResize);
        listening = false;
      }
    };
  }, []);
  const current = (0, import_react.useMemo)(() => {
    if (state == null ? void 0 : state.pc) {
      return "pc";
    }
    if (state == null ? void 0 : state.ipad) {
      return "ipad";
    }
    return "phone";
  }, [state]);
  return current;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  configResponsive
});
