{"version":3,"file":"mutativeMethods-CwDMtUNs.cjs","names":["mutativeMethods: {\n  update: typeof update;\n}"],"sources":["../src/mutative/mutativeMethods.ts"],"sourcesContent":["import type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { type Path, type Value } from '@lib/path';\nimport { create, type Draft } from 'mutative';\n\nexport type Mutation<T> = (draft: Draft<T>) => void;\n\nfunction update<T>(this: Store<T>, mutation: Mutation<T>): void;\n\nfunction update<T, const P>(\n  this: Store<T>,\n  path: Constrain<P, Path<T>>,\n  mutation: Mutation<Value<T, P>>,\n): void;\n\nfunction update<T, const TPath>(\n  this: Store<T>,\n  ...args:\n    | [recipe: Mutation<T>]\n    | [path: Constrain<TPath, Path<T>>, mutation: Mutation<Value<T, TPath>>]\n) {\n  if (args.length === 1) {\n    const [mutation] = args;\n\n    this.set((value) => {\n      const result = create(value, (draft) => {\n        mutation(draft);\n      });\n      return result;\n    });\n  } else {\n    const [path, mutation] = args;\n\n    this.set(path, (value) => {\n      const result = create(value, (draft) => {\n        mutation(draft);\n      });\n      return result;\n    });\n  }\n}\n\nexport const mutativeMethods: {\n  update: typeof update;\n} = {\n  update,\n};\n"],"mappings":";;;AAeA,SAAS,OAEP,GAAG,MAGH;AACA,KAAI,KAAK,WAAW,GAAG;EACrB,MAAM,CAAC,YAAY;AAEnB,OAAK,KAAK,UAAU;AAIlB,+BAHsB,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;QACG;EACL,MAAM,CAAC,MAAM,YAAY;AAEzB,OAAK,IAAI,OAAO,UAAU;AAIxB,+BAHsB,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;;;AAIN,MAAaA,kBAET,EACF,QACD"}