{"ast":null,"code":"\"use client\";\n\n// src/useMutation.ts\nimport * as React from \"react\";\nimport { MutationObserver, notifyManager } from \"@tanstack/query-core\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { noop, shouldThrowError } from \"./utils.js\";\nfunction useMutation(options, queryClient) {\n const client = useQueryClient(queryClient);\n const [observer] = React.useState(() => new MutationObserver(client, options));\n React.useEffect(() => {\n observer.setOptions(options);\n }, [observer, options]);\n const result = React.useSyncExternalStore(React.useCallback(onStoreChange => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n const mutate = React.useCallback((variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop);\n }, [observer]);\n if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {\n throw result.error;\n }\n return {\n ...result,\n mutate,\n mutateAsync: result.mutate\n };\n}\nexport { useMutation };","map":{"version":3,"names":["React","MutationObserver","notifyManager","useQueryClient","noop","shouldThrowError","useMutation","options","queryClient","client","observer","useState","useEffect","setOptions","result","useSyncExternalStore","useCallback","onStoreChange","subscribe","batchCalls","getCurrentResult","mutate","variables","mutateOptions","catch","error","throwOnError","mutateAsync"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@tanstack/react-query/src/useMutation.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { MutationObserver, notifyManager } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport { noop, shouldThrowError } from './utils'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { DefaultError, QueryClient } from '@tanstack/query-core'\n\n// HOOK\n\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseMutationOptions,\n queryClient?: QueryClient,\n): UseMutationResult {\n const client = useQueryClient(queryClient)\n\n const [observer] = React.useState(\n () =>\n new MutationObserver(\n client,\n options,\n ),\n )\n\n React.useEffect(() => {\n observer.setOptions(options)\n }, [observer, options])\n\n const result = React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n const mutate = React.useCallback<\n UseMutateFunction\n >(\n (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n },\n [observer],\n )\n\n if (\n result.error &&\n shouldThrowError(observer.options.throwOnError, [result.error])\n ) {\n throw result.error\n }\n\n return { ...result, mutate, mutateAsync: result.mutate }\n}\n"],"mappings":";;;AACA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAA,EAAkBC,aAAA,QAAqB;AAChD,SAASC,cAAA,QAAsB;AAC/B,SAASC,IAAA,EAAMC,gBAAA,QAAwB;AAUhC,SAASC,YAMdC,OAAA,EACAC,WAAA,EACwD;EACxD,MAAMC,MAAA,GAASN,cAAA,CAAeK,WAAW;EAEzC,MAAM,CAACE,QAAQ,IAAUV,KAAA,CAAAW,QAAA,CACvB,MACE,IAAIV,gBAAA,CACFQ,MAAA,EACAF,OACF,CACJ;EAEMP,KAAA,CAAAY,SAAA,CAAU,MAAM;IACpBF,QAAA,CAASG,UAAA,CAAWN,OAAO;EAC7B,GAAG,CAACG,QAAA,EAAUH,OAAO,CAAC;EAEtB,MAAMO,MAAA,GAAed,KAAA,CAAAe,oBAAA,CACbf,KAAA,CAAAgB,WAAA,CACHC,aAAA,IACCP,QAAA,CAASQ,SAAA,CAAUhB,aAAA,CAAciB,UAAA,CAAWF,aAAa,CAAC,GAC5D,CAACP,QAAQ,CACX,GACA,MAAMA,QAAA,CAASU,gBAAA,CAAiB,GAChC,MAAMV,QAAA,CAASU,gBAAA,CAAiB,CAClC;EAEA,MAAMC,MAAA,GAAerB,KAAA,CAAAgB,WAAA,CAGnB,CAACM,SAAA,EAAWC,aAAA,KAAkB;IAC5Bb,QAAA,CAASW,MAAA,CAAOC,SAAA,EAAWC,aAA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