{"version":3,"file":"shared-Bco66qhk.mjs","names":["procedurePath: string","input: any","value: unknown"],"sources":["../src/app-dir/shared.ts"],"sourcesContent":["import type {\n CreateTRPCClientOptions,\n Resolver,\n TRPCClient,\n} from '@trpc/client';\nimport { getUntypedClient, TRPCUntypedClient } from '@trpc/client';\nimport type { inferProcedureOutput } from '@trpc/server';\nimport type {\n AnyClientTypes,\n AnyProcedure,\n AnyQueryProcedure,\n AnyRootTypes,\n AnyRouter,\n inferProcedureInput,\n inferTransformedProcedureOutput,\n ProtectedIntersection,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type UseProcedureRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyQueryProcedure\n ? Resolver<{\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput;\n errorShape: TRoot['errorShape'];\n transformer: TRoot['transformer'];\n }>\n : $Value extends RouterRecord\n ? UseProcedureRecord\n : never\n : never;\n};\n\nexport function createUseProxy(\n client: TRPCUntypedClient | TRPCClient,\n) {\n const untypedClient: TRPCUntypedClient =\n client instanceof TRPCUntypedClient ? client : getUntypedClient(client);\n\n return createRecursiveProxy<\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >((opts) => {\n const path = opts.path.join('.');\n\n return untypedClient.query(path, ...opts.args);\n });\n}\n\ntype NextAppRouterUse = {\n []>(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => [...TData],\n ): {\n [TKey in keyof TData]: Awaited;\n };\n >(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => TData,\n ): Awaited;\n};\ntype CreateTRPCNextAppRouterBase = {\n use: NextAppRouterUse;\n};\nexport type CreateTRPCNextAppRouter =\n ProtectedIntersection<\n CreateTRPCNextAppRouterBase,\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >;\n\n/**\n * @internal\n */\nexport interface CreateTRPCNextAppRouterOptions {\n config: () => CreateTRPCClientOptions;\n}\n\n/**\n * @internal\n */\nexport function generateCacheTag(procedurePath: string, input: any) {\n return input\n ? `${procedurePath}?input=${JSON.stringify(input)}`\n : procedurePath;\n}\n\nexport function isFormData(value: unknown): value is FormData {\n if (typeof FormData === 'undefined') {\n // FormData is not supported\n return false;\n }\n return value instanceof FormData;\n}\n\n/**\n * @internal\n */\nexport interface ActionHandlerDef {\n input?: any;\n output?: any;\n errorShape: any;\n}\n\n// ts-prune-ignore-next\n/**\n * @internal\n */\nexport type inferActionDef<\n TRoot extends AnyClientTypes,\n TProc extends AnyProcedure,\n> = {\n input: inferProcedureInput;\n output: inferProcedureOutput;\n errorShape: TRoot['errorShape'];\n};\n"],"mappings":";;;;;;;AAqGA,SAAgB,iBAAiBA,eAAuBC,OAAY;AAClE,QAAO,SACF,EAAE,cAAc,SAAS,KAAK,UAAU,MAAM,CAAC,IAChD;AACL;AAED,SAAgB,WAAWC,OAAmC;AAC5D,YAAW,aAAa,YAEtB,QAAO;AAET,QAAO,iBAAiB;AACzB"}