{"version":3,"sources":["/home/renatorib/p/publissue/packages/api/dist/__chunks/L72B3EIR.cjs","../../src/lib/graphql.ts"],"names":["typeWithMap","fragment","_map","map","input","simplify","unmask","i","f","useFragment","type","operationWithMap","document","operation","asNode","node","name"],"mappings":"AAAA,sHAA6B,6CAAmC,SCgBhDA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACA,CAKA,SAASC,CAAAA,CAAIC,CAAAA,CAAuB,CAClC,OAAOA,CAAAA,CAAQC,4BAAAA,CAASH,CAAKE,CAAK,CAAC,CAAA,CAAI,IACzC,CAKA,SAASE,CAAAA,CAAOF,CAAAA,CAAuD,CACrE,OAAKA,CAAAA,CAGD,KAAA,CAAM,OAAA,CAAQA,CAAK,CAAA,CACdA,CAAAA,CAAM,MAAA,CAAQG,CAAAA,EAAMA,CAAAA,EAAK,IAAI,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAML,CAAAA,CAAIM,4BAAAA,CAAYR,CAAUO,CAAC,CAAC,CAAC,CAAA,CAEzEL,CAAAA,CAAIM,4BAAAA,CAAYR,CAAUG,CAAK,CAAC,CAAA,CAL9B,IAMX,CAEA,OAAO,MAAA,CAAO,MAAA,CAAOH,CAAAA,CAAU,CAC7B,SAAA,CAAW,CAAA,CAAA,CACX,GAAA,CAAAE,CAAAA,CACA,MAAA,CAAAG,CAAAA,CACA,OAAA,CAAkBH,CAAAA,EAA4CH,CAAAA,CAAYC,CAAAA,CAAUE,CAAG,CACzF,CAAC,CACH,CAEO,SAASO,CAAAA,CAAwBT,CAAAA,CAAkD,CACxF,OAAOD,CAAAA,CAAYC,CAAAA,CAAWG,CAAAA,EAAUC,4BAAAA,CAAc,CAAC,CACzD,CAGO,SAASM,CAAAA,CACdC,CAAAA,CACAT,CAAAA,CACA,CACA,OAAO,MAAA,CAAO,MAAA,CAAOS,CAAAA,CAAU,CAC7B,cAAA,CAAgB,CAAA,CAAA,CAChB,GAAA,CAAAT,CAAAA,CACA,OAAA,CAAkBA,CAAAA,EAChBQ,CAAAA,CAAiBC,CAAAA,CAAWR,CAAAA,EAAkBC,4BAAAA,CAASF,CAAIC,CAAK,CAAC,CAAC,CACtE,CAAC,CACH,CAEO,SAASS,CAAAA,CAA6BD,CAAAA,CAAkD,CAC7F,OAAOD,CAAAA,CAAiBC,CAAAA,CAAWR,CAAAA,EAAUC,4BAAAA,CAAc,CAAC,CAC9D,CAEO,IAAMS,CAAAA,CAAS,CAA+DC,CAAAA,CAASC,CAAAA,CAAAA,EAC5FD,CAAAA,CAAAA,0EAAAA","file":"/home/renatorib/p/publissue/packages/api/dist/__chunks/L72B3EIR.cjs","sourcesContent":[null,"import { FragmentType, useFragment } from \"../__generated__/codegen\";\nimport { TypedDocumentString } from \"../__generated__/codegen/graphql\";\nimport { Flatten, Simplify, simplify } from \"./types\";\n\nexport * from \"../__generated__/codegen\";\nexport * from \"../__generated__/codegen/graphql\";\n\nexport type VariablesOf<T> = T extends TypedDocumentString<any, infer V> ? V : never;\nexport type ResultOf<T> = T extends TypedDocumentString<infer R, any> ? R : never;\n\nexport type OperationString<Result, Variables, Out> = ReturnType<typeof operationWithMap<Result, Variables, Out>>;\nexport type TypeString<Result, Variables, Out> = ReturnType<typeof typeWithMap<Result, Variables, Out>>;\n\ntype Edge<T> = { node: T; cursor: string };\n\n// To be used with fragments\nexport function typeWithMap<Result, Variables, Out>(\n  fragment: TypedDocumentString<Result, Variables>,\n  _map: (input: Result) => Out,\n) {\n  type MaskedResult = FragmentType<TypedDocumentString<Result, any>>;\n\n  function map(input: Result): Simplify<Out>;\n  function map(input?: Result | null): Simplify<Out> | null;\n  function map(input?: Result | null) {\n    return input ? simplify(_map(input)) : null;\n  }\n\n  function unmask(input: MaskedResult): Simplify<Out>;\n  function unmask(input?: MaskedResult | null): Simplify<Out> | null;\n  function unmask(input?: (MaskedResult | null)[] | null): Simplify<Out>[];\n  function unmask(input?: MaskedResult | (MaskedResult | null)[] | null) {\n    if (!input) {\n      return null;\n    }\n    if (Array.isArray(input)) {\n      return input.filter((i) => i != null).map((f) => map(useFragment(fragment, f)));\n    }\n    return map(useFragment(fragment, input));\n  }\n\n  return Object.assign(fragment, {\n    __is_type: true as const,\n    map,\n    unmask,\n    withMap: <MapOut>(map: (input: Flatten<Result>) => MapOut) => typeWithMap(fragment, map),\n  });\n}\n\nexport function type<Result, Variables>(fragment: TypedDocumentString<Result, Variables>) {\n  return typeWithMap(fragment, (input) => simplify(input));\n}\n\n// To be used with queries and mutations\nexport function operationWithMap<Result, Variables, Out>(\n  document: TypedDocumentString<Result, Variables>,\n  map: (input: Result) => Out,\n) {\n  return Object.assign(document, {\n    __is_operation: true as const,\n    map,\n    withMap: <MapOut>(map: (input: Flatten<Result>) => MapOut) =>\n      operationWithMap(document, (input: Result) => simplify(map(input))),\n  });\n}\n\nexport function operation<Result, Variables>(document: TypedDocumentString<Result, Variables>) {\n  return operationWithMap(document, (input) => simplify(input));\n}\n\nexport const asNode = <T extends { __typename?: string }, N extends T[\"__typename\"]>(node: T, name: N) =>\n  node as Extract<T, { __typename?: N }>;\n"]}