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IAAG,IACM,EAAiB,MAE1B,GAAA,CAAI,QACe,IAAb,GACF,EAAiB,GAAK,SACf,EAAiB,OACxB,EAAiB,QAAS,IAE1B,EAAiB,GAAK,EACtB,EAAiB,OAAS,IAE5B,EAAI,WAAW,YAAY,EAC7B,GAEJ,CACF,CACF,CACA,SAAS,iBAAiB,EAAa,EAAQ,GAC7C,MAA2B,kBAAhB,EACF,EACE,MAAM,QAAQ,GAChB,EAAY,SAAS,GACI,mBAAhB,GACT,EAAY,EAAQ,EAG/B","file":"/npm/@pinia/testing@1.0.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@pinia/testing@1.0.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n  if (from && typeof from === \"object\" || typeof from === \"function\") {\n    for (let key of __getOwnPropNames(from))\n      if (!__hasOwnProp.call(to, key) && key !== except)\n        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n  }\n  return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n  createTestingPinia: () => createTestingPinia\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// src/testing.ts\nvar import_vue = require(\"vue\");\nvar import_pinia = require(\"pinia\");\nfunction createTestingPinia({\n  initialState = {},\n  plugins = [],\n  stubActions = true,\n  stubPatch = false,\n  stubReset = false,\n  fakeApp = false,\n  createSpy: _createSpy\n} = {}) {\n  const pinia = (0, import_pinia.createPinia)();\n  pinia._p.push(({ store }) => {\n    if (initialState[store.$id]) {\n      mergeReactiveObjects(store.$state, initialState[store.$id]);\n    }\n  });\n  plugins.forEach((plugin) => pinia._p.push(plugin));\n  pinia._p.push(WritableComputed);\n  const createSpy = _createSpy || // @ts-ignore\n  typeof jest !== \"undefined\" && jest.fn || typeof vi !== \"undefined\" && vi.fn;\n  if (!createSpy) {\n    throw new Error(\n      \"[@pinia/testing]: You must configure the `createSpy` option. See https://pinia.vuejs.org/cookbook/testing.html#Specifying-the-createSpy-function\"\n    );\n  } else if (typeof createSpy !== \"function\" || // When users pass vi.fn() instead of vi.fn\n  // https://github.com/vuejs/pinia/issues/2896\n  \"mockReturnValue\" in createSpy) {\n    throw new Error(\n      \"[@pinia/testing]: Invalid `createSpy` option. See https://pinia.vuejs.org/cookbook/testing.html#Specifying-the-createSpy-function\"\n    );\n  }\n  pinia._p.push(({ store, options }) => {\n    Object.keys(options.actions).forEach((action) => {\n      if (action === \"$reset\") return;\n      store[action] = shouldStubAction(stubActions, action, store) ? createSpy() : createSpy(store[action]);\n    });\n    store.$patch = stubPatch ? createSpy() : createSpy(store.$patch);\n    store.$reset = stubReset ? createSpy() : createSpy(store.$reset);\n  });\n  if (fakeApp) {\n    const app = (0, import_vue.createApp)({});\n    app.use(pinia);\n  }\n  pinia._testing = true;\n  (0, import_pinia.setActivePinia)(pinia);\n  Object.defineProperty(pinia, \"app\", {\n    configurable: true,\n    enumerable: true,\n    get() {\n      return this._a;\n    }\n  });\n  return pinia;\n}\nfunction mergeReactiveObjects(target, patchToApply) {\n  for (const key in patchToApply) {\n    if (!patchToApply.hasOwnProperty(key)) continue;\n    const subPatch = patchToApply[key];\n    const targetValue = target[key];\n    if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !(0, import_vue.isRef)(subPatch) && !(0, import_vue.isReactive)(subPatch)) {\n      target[key] = mergeReactiveObjects(targetValue, subPatch);\n    } else {\n      target[key] = //\n      subPatch;\n    }\n  }\n  return target;\n}\nfunction isPlainObject(o) {\n  return o && typeof o === \"object\" && Object.prototype.toString.call(o) === \"[object Object]\" && typeof o.toJSON !== \"function\";\n}\nfunction isComputed(v) {\n  return !!v && (0, import_vue.isRef)(v) && \"effect\" in v;\n}\nfunction WritableComputed({ store }) {\n  const rawStore = (0, import_vue.toRaw)(store);\n  for (const key in rawStore) {\n    const originalComputed = rawStore[key];\n    if (isComputed(originalComputed)) {\n      const originalFn = originalComputed.fn;\n      const overriddenFn = () => (\n        // @ts-expect-error: internal cached value\n        originalComputed._value\n      );\n      rawStore[key] = (0, import_vue.computed)({\n        get() {\n          return originalComputed.value;\n        },\n        set(newValue) {\n          if (newValue === void 0) {\n            originalComputed.fn = originalFn;\n            delete originalComputed._value;\n            originalComputed._dirty = true;\n          } else {\n            originalComputed.fn = overriddenFn;\n            originalComputed._value = newValue;\n          }\n          (0, import_vue.triggerRef)(originalComputed);\n        }\n      });\n    }\n  }\n}\nfunction shouldStubAction(stubActions, action, store) {\n  if (typeof stubActions === \"boolean\") {\n    return stubActions;\n  } else if (Array.isArray(stubActions)) {\n    return stubActions.includes(action);\n  } else if (typeof stubActions === \"function\") {\n    return stubActions(action, store);\n  }\n  return false;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n  createTestingPinia\n});\n"]}