import { reactive as p, readonly as f, computed as b } from "vue";
function a(i, e) {
  return {
    get: () => typeof e == "function" ? e(i) : i[e],
    enumerable: !0,
    configurable: !0
  };
}
function S(i) {
  const e = p({ ...i }), s = /* @__PURE__ */ new Set();
  let o = !1;
  const c = {
    state: {},
    defineGetter: function(t, n) {
      return Object.defineProperty(this.state, t, a(e, n)), e[t] = b(() => n(f(e))), this;
    },
    updateState: function(t) {
      Object.assign(e, t), o = !0;
      for (const n of s)
        n({ ...this.state });
    },
    subscribe: function(t, n = { once: !1 }) {
      if (s.add(t), o && t({ ...this.state }), o && n.once) {
        s.delete(t);
        return;
      }
      return () => {
        s.delete(t);
      };
    },
    useReactiveState: function() {
      return f(e);
    },
    pipe: async function(t, ...n) {
      let u = await t({ ...this.state });
      for (const d of n)
        u = await d(u);
      return u;
    }
  };
  for (const r in e)
    Object.defineProperty(c.state, r, a(e, r));
  return c;
}
export {
  S as defineStore
};
//# sourceMappingURL=store.mjs.map
