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/components/ticketBooking/miniRedux.tsx
var miniRedux_exports = {};
__export(miniRedux_exports, {
  Provider: () => Provider,
  createStore: () => createStore,
  useStore: () => useStore
});
module.exports = __toCommonJS(miniRedux_exports);
var import_react = require("react");
var Store = class {
  state;
  listeners;
  constructor(initialState) {
    this.state = initialState;
    this.listeners = /* @__PURE__ */ new Set();
  }
  getState() {
    return this.state;
  }
  setState(partialState, callback) {
    if (typeof partialState === "function") {
      Object.assign(this.state, partialState(this.state));
    } else {
      Object.assign(this.state, partialState);
    }
    this.notify();
    if (callback) {
      callback(this.state);
    }
  }
  subscribe(listener) {
    this.listeners.add(listener);
    return () => {
      this.listeners.delete(listener);
    };
  }
  notify() {
    for (const listener of this.listeners) {
      listener();
    }
  }
  // 添加获取最新状态的方法
  getLatestState() {
    return this.state;
  }
};
var StoreContext = (0, import_react.createContext)(null);
function Provider({
  store,
  children
}) {
  return /* @__PURE__ */ React.createElement(StoreContext.Provider, { value: store }, children);
}
function createStore(initialState) {
  return new Store(initialState);
}
function useStore() {
  const store = (0, import_react.useContext)(StoreContext);
  if (!store) {
    throw new Error("useStore must be used within a Provider");
  }
  const stateRef = (0, import_react.useRef)(store.getState());
  const [, forceUpdate] = (0, import_react.useState)({});
  (0, import_react.useEffect)(() => {
    const unsubscribe = store.subscribe(() => {
      stateRef.current = store.getState();
      forceUpdate({});
    });
    return unsubscribe;
  }, [store]);
  return [stateRef.current, store.setState.bind(store)];
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Provider,
  createStore,
  useStore
});
