{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import type { FieldState, AnyRegularField } from \"./types\";\nimport type { GroupField } from \"./group\";\nimport type { SliceZone } from \"./sliceZone\";\nimport type { ContentRelationshipField } from \"./contentRelationship\";\nimport type { LinkToMediaField } from \"./linkToMedia\";\n\n/**\n * Link Types\n */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const;\n\n/**\n * For link fields that haven't been filled\n *\n * @typeParam Type - The type of link.\n */\nexport type EmptyLinkField<\n\tType extends typeof LinkType[keyof typeof LinkType] = typeof LinkType.Any,\n> = {\n\tlink_type: Type | string;\n};\n\n/**\n * Link that points to external website\n */\nexport interface FilledLinkToWebField {\n\tlink_type: typeof LinkType.Web;\n\turl: string;\n\ttarget?: string;\n}\n\n/**\n * Link Field\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n *   GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any>\n\t:\n\t\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>\n\t\t\t| FilledLinkToWebField\n\t\t\t| LinkToMediaField<State>;\n"],"names":[],"mappings":";;AASO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}