@payloadcms/ui 3.40.0-canary.4 → 3.40.0-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,6 +67,11 @@ export const buildColumnState = args => {
67
67
  const fAccessor = f.accessor ?? ('name' in f ? f.name : undefined);
68
68
  return fAccessor === accessor;
69
69
  });
70
+ const hasCustomCell = serverField?.admin && 'components' in serverField.admin && serverField.admin.components && 'Cell' in serverField.admin.components && serverField.admin.components.Cell;
71
+ if (serverField && serverField.type === 'group' && !hasCustomCell) {
72
+ return acc // skip any group without a custom cell
73
+ ;
74
+ }
70
75
  const columnPreference = columnPreferences?.find(preference => clientField && 'name' in clientField && preference.accessor === accessor);
71
76
  const isActive = isColumnActive({
72
77
  accessor,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderServerComponent","SortColumn","filterFields","isColumnActive","renderCell","sortFieldMap","buildColumnState","args","beforeRows","clientFields","collectionSlug","columnPreferences","columns","customCellProps","dataType","docs","enableLinkedCell","enableRowSelections","i18n","payload","serverFields","sortColumnProps","useAsTitle","sortedFieldMap","keepPresentationalFields","moveSubFieldsToTop","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","activeColumnsIndices","sorted","reduce","acc","clientField","colIndex","accessor","undefined","serverField","find","f","fAccessor","columnPreference","preference","isActive","includes","push","CustomLabel","CustomLabelToRender","admin","components","Label","clientProps","customLabelServerProps","Component","importMap","serverProps","fieldAffectsDataSubFields","type","label","labelWithPrefix","dotAccessor","replace","Heading","_jsx","disable","column","active","renderedCells","map","doc","rowIndex","relationTo","columnIndex","value","isLinkedColumn"],"sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientComponentProps,\n ClientField,\n CollectionSlug,\n Column,\n DefaultCellComponentProps,\n Document,\n Field,\n ListPreferences,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n} from 'payload'\n\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../../../elements/SortColumn/index.js'\n\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { filterFields } from './filterFields.js'\nimport { isColumnActive } from './isColumnActive.js'\nimport { renderCell } from './renderCell.js'\nimport { sortFieldMap } from './sortFieldMap.js'\n\nexport type BuildColumnStateArgs = {\n beforeRows?: Column[]\n clientFields: ClientField[]\n columnPreferences: ListPreferences['columns']\n columns?: ListPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n enableLinkedCell?: boolean\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n serverFields: Field[]\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n} & (\n | {\n collectionSlug: CollectionSlug\n dataType: 'monomorphic'\n docs: PaginatedDocs['docs']\n }\n | {\n collectionSlug?: undefined\n dataType: 'polymorphic'\n docs: {\n relationTo: CollectionSlug\n value: Document\n }[]\n }\n)\n\nexport const buildColumnState = (args: BuildColumnStateArgs): Column[] => {\n const {\n beforeRows,\n clientFields,\n collectionSlug,\n columnPreferences,\n columns,\n customCellProps,\n dataType,\n docs,\n enableLinkedCell = true,\n enableRowSelections,\n i18n,\n payload,\n serverFields,\n sortColumnProps,\n useAsTitle,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(filterFields(clientFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(filterFields(serverFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columnPreferences || columns\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columnPreferences`\n sortedFieldMap = sortFieldMap<ClientField>(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap<Field>(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, clientField, colIndex) => {\n if (fieldIsHiddenOrDisabled(clientField) && !fieldIsID(clientField)) {\n return acc\n }\n\n const accessor =\n (clientField as any).accessor ?? ('name' in clientField ? clientField.name : undefined)\n\n const serverField = _sortedFieldMap.find((f) => {\n const fAccessor = (f as any).accessor ?? ('name' in f ? f.name : undefined)\n return fAccessor === accessor\n })\n\n const columnPreference = columnPreferences?.find(\n (preference) => clientField && 'name' in clientField && preference.accessor === accessor,\n )\n\n const isActive = isColumnActive({\n accessor,\n activeColumnsIndices,\n columnPreference,\n columns,\n })\n\n if (isActive && !activeColumnsIndices.includes(colIndex)) {\n activeColumnsIndices.push(colIndex)\n }\n\n let CustomLabel = undefined\n\n if (dataType === 'monomorphic') {\n const CustomLabelToRender =\n serverField &&\n 'admin' in serverField &&\n 'components' in serverField.admin &&\n 'Label' in serverField.admin.components &&\n serverField.admin.components.Label !== undefined // let it return `null`\n ? serverField.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field: clientField,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField,\n collectionSlug,\n field: serverField,\n i18n,\n payload,\n }\n\n CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n }\n\n const fieldAffectsDataSubFields =\n clientField &&\n clientField.type &&\n (clientField.type === 'array' ||\n clientField.type === 'group' ||\n clientField.type === 'blocks')\n\n const label =\n clientField && 'labelWithPrefix' in clientField && clientField.labelWithPrefix !== undefined\n ? clientField.labelWithPrefix\n : 'label' in clientField\n ? clientField.label\n : undefined\n\n // Convert accessor to dot notation specifically for SortColumn sorting behavior\n const dotAccessor = accessor?.replace(/-/g, '.')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(clientField) || undefined}\n Label={CustomLabel}\n label={label as StaticLabel}\n name={dotAccessor}\n {...(sortColumnProps || {})}\n />\n )\n\n const column: Column = {\n accessor,\n active: isActive,\n CustomLabel,\n field: clientField,\n Heading,\n renderedCells: isActive\n ? docs.map((doc, rowIndex) => {\n return renderCell({\n clientField,\n collectionSlug: dataType === 'monomorphic' ? collectionSlug : doc.relationTo,\n columnIndex: colIndex,\n customCellProps,\n doc: dataType === 'monomorphic' ? doc : doc.value,\n enableRowSelections,\n i18n,\n isLinkedColumn: enableLinkedCell && colIndex === activeColumnsIndices[0],\n payload,\n rowIndex,\n serverField,\n })\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n return sorted\n}\n"],"mappings":";AAiBA,SACEA,uBAAuB,EACvBC,SAAS,EACTC,yBAAyB,EACzBC,qBAAqB,QAChB;AACP,OAAOC,KAAA,MAAW;AAIlB,SAASC,qBAAqB,QAAQ;AACtC,SACEC,UAAU,QAEL;AACP,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,QAAQ;AAgC7B,OAAO,MAAMC,gBAAA,GAAoBC,IAAA;EAC/B,MAAM;IACJC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,iBAAiB;IACjBC,OAAO;IACPC,eAAe;IACfC,QAAQ;IACRC,IAAI;IACJC,gBAAA,GAAmB,IAAI;IACvBC,mBAAmB;IACnBC,IAAI;IACJC,OAAO;IACPC,YAAY;IACZC,eAAe;IACfC;EAAU,CACX,GAAGf,IAAA;EAEJ;EACA,IAAIgB,cAAA,GAAiBzB,qBAAA,CAAsBI,YAAA,CAAaO,YAAA,GAAe;IACrES,IAAA;IACAM,wBAAA,EAA0B;IAC1BC,kBAAA,EAAoB;EACtB;EAEA,IAAIC,eAAA,GAAkB5B,qBAAA,CAAsBI,YAAA,CAAakB,YAAA,GAAe;IACtEF,IAAA;IACAM,wBAAA,EAA0B;IAC1BC,kBAAA,EAAoB;EACtB,EAAc;EAAA;EAEd;EACA;EACA;EACA,MAAME,YAAA,GAAeJ,cAAA,EAAgBK,SAAA,CAAWC,KAAA,IAAUjC,SAAA,CAAUiC,KAAA;EAEpE,IAAIF,YAAA,GAAe,CAAC,GAAG;IACrB,MAAMG,OAAA,GAAUP,cAAA,CAAeQ,MAAM,CAACJ,YAAA,EAAc,EAAE,CAAC,EAAE;IACzDJ,cAAA,CAAeS,OAAO,CAACF,OAAA;EACzB;EAEA,MAAMG,oBAAA,GAAuBX,UAAA,GACzBC,cAAA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czB,QAAA,EAAU0B,OAAA,CAAQ,MAAM;IAE5C,MAAMC,OAAA,gBACJC,IAAA,CAACtE,UAAA;MACCuE,OAAA,EAASR,yBAAA,IAA6BnE,yBAAA,CAA0B4C,WAAA,KAAgBG,SAAA;MAChFc,KAAA,EAAOJ,WAAA;MACPY,KAAA,EAAOA,KAAA;MACPhC,IAAA,EAAMkC,WAAA;MACL,IAAI/C,eAAA,IAAmB,CAAC,CAAC;;IAI9B,MAAMoD,MAAA,GAAiB;MACrB9B,QAAA;MACA+B,MAAA,EAAQvB,QAAA;MACRG,WAAA;MACAzB,KAAA,EAAOY,WAAA;MACP6B,OAAA;MACAK,aAAA,EAAexB,QAAA,GACXpC,IAAA,CAAK6D,GAAG,CAAC,CAACC,GAAA,EAAKC,QAAA;QACb,OAAO1E,UAAA,CAAW;UAChBqC,WAAA;UACA/B,cAAA,EAAgBI,QAAA,KAAa,gBAAgBJ,cAAA,GAAiBmE,GAAA,CAAIE,UAAU;UAC5EC,WAAA,EAAatC,QAAA;UACb7B,eAAA;UACAgE,GAAA,EAAK/D,QAAA,KAAa,gBAAgB+D,GAAA,GAAMA,GAAA,CAAII,KAAK;UACjDhE,mBAAA;UACAC,IAAA;UACAgE,cAAA,EAAgBlE,gBAAA,IAAoB0B,QAAA,KAAaL,oBAAoB,CAAC,EAAE;UACxElB,OAAA;UACA2D,QAAA;UACAjC;QACF;MACF,KACA;IACN;IAEAL,GAAA,CAAIa,IAAI,CAACoB,MAAA;IAET,OAAOjC,GAAA;EACT,GAAG,EAAE;EAEL,IAAIhC,UAAA,EAAY;IACd8B,MAAA,CAAON,OAAO,IAAIxB,UAAA;EACpB;EAEA,OAAO8B,MAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderServerComponent","SortColumn","filterFields","isColumnActive","renderCell","sortFieldMap","buildColumnState","args","beforeRows","clientFields","collectionSlug","columnPreferences","columns","customCellProps","dataType","docs","enableLinkedCell","enableRowSelections","i18n","payload","serverFields","sortColumnProps","useAsTitle","sortedFieldMap","keepPresentationalFields","moveSubFieldsToTop","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","activeColumnsIndices","sorted","reduce","acc","clientField","colIndex","accessor","undefined","serverField","find","f","fAccessor","hasCustomCell","admin","components","Cell","type","columnPreference","preference","isActive","includes","push","CustomLabel","CustomLabelToRender","Label","clientProps","customLabelServerProps","Component","importMap","serverProps","fieldAffectsDataSubFields","label","labelWithPrefix","dotAccessor","replace","Heading","_jsx","disable","column","active","renderedCells","map","doc","rowIndex","relationTo","columnIndex","value","isLinkedColumn"],"sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientComponentProps,\n ClientField,\n CollectionSlug,\n Column,\n DefaultCellComponentProps,\n Document,\n Field,\n ListPreferences,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n} from 'payload'\n\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../../../elements/SortColumn/index.js'\n\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { filterFields } from './filterFields.js'\nimport { isColumnActive } from './isColumnActive.js'\nimport { renderCell } from './renderCell.js'\nimport { sortFieldMap } from './sortFieldMap.js'\n\nexport type BuildColumnStateArgs = {\n beforeRows?: Column[]\n clientFields: ClientField[]\n columnPreferences: ListPreferences['columns']\n columns?: ListPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n enableLinkedCell?: boolean\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n serverFields: Field[]\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n} & (\n | {\n collectionSlug: CollectionSlug\n dataType: 'monomorphic'\n docs: PaginatedDocs['docs']\n }\n | {\n collectionSlug?: undefined\n dataType: 'polymorphic'\n docs: {\n relationTo: CollectionSlug\n value: Document\n }[]\n }\n)\n\nexport const buildColumnState = (args: BuildColumnStateArgs): Column[] => {\n const {\n beforeRows,\n clientFields,\n collectionSlug,\n columnPreferences,\n columns,\n customCellProps,\n dataType,\n docs,\n enableLinkedCell = true,\n enableRowSelections,\n i18n,\n payload,\n serverFields,\n sortColumnProps,\n useAsTitle,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(filterFields(clientFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(filterFields(serverFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columnPreferences || columns\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columnPreferences`\n sortedFieldMap = sortFieldMap<ClientField>(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap<Field>(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, clientField, colIndex) => {\n if (fieldIsHiddenOrDisabled(clientField) && !fieldIsID(clientField)) {\n return acc\n }\n\n const accessor =\n (clientField as any).accessor ?? ('name' in clientField ? clientField.name : undefined)\n\n const serverField = _sortedFieldMap.find((f) => {\n const fAccessor = (f as any).accessor ?? ('name' in f ? f.name : undefined)\n return fAccessor === accessor\n })\n\n const hasCustomCell =\n serverField?.admin &&\n 'components' in serverField.admin &&\n serverField.admin.components &&\n 'Cell' in serverField.admin.components &&\n serverField.admin.components.Cell\n\n if (serverField && serverField.type === 'group' && !hasCustomCell) {\n return acc // skip any group without a custom cell\n }\n\n const columnPreference = columnPreferences?.find(\n (preference) => clientField && 'name' in clientField && preference.accessor === accessor,\n )\n\n const isActive = isColumnActive({\n accessor,\n activeColumnsIndices,\n columnPreference,\n columns,\n })\n\n if (isActive && !activeColumnsIndices.includes(colIndex)) {\n activeColumnsIndices.push(colIndex)\n }\n\n let CustomLabel = undefined\n\n if (dataType === 'monomorphic') {\n const CustomLabelToRender =\n serverField &&\n 'admin' in serverField &&\n 'components' in serverField.admin &&\n 'Label' in serverField.admin.components &&\n serverField.admin.components.Label !== undefined // let it return `null`\n ? serverField.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field: clientField,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField,\n collectionSlug,\n field: serverField,\n i18n,\n payload,\n }\n\n CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n }\n\n const fieldAffectsDataSubFields =\n clientField &&\n clientField.type &&\n (clientField.type === 'array' ||\n clientField.type === 'group' ||\n clientField.type === 'blocks')\n\n const label =\n clientField && 'labelWithPrefix' in clientField && clientField.labelWithPrefix !== undefined\n ? clientField.labelWithPrefix\n : 'label' in clientField\n ? clientField.label\n : undefined\n\n // Convert accessor to dot notation specifically for SortColumn sorting behavior\n const dotAccessor = accessor?.replace(/-/g, '.')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(clientField) || undefined}\n Label={CustomLabel}\n label={label as StaticLabel}\n name={dotAccessor}\n {...(sortColumnProps || {})}\n />\n )\n\n const column: Column = {\n accessor,\n active: isActive,\n CustomLabel,\n field: clientField,\n Heading,\n renderedCells: isActive\n ? docs.map((doc, rowIndex) => {\n return renderCell({\n clientField,\n collectionSlug: dataType === 'monomorphic' ? collectionSlug : doc.relationTo,\n columnIndex: colIndex,\n customCellProps,\n doc: dataType === 'monomorphic' ? doc : doc.value,\n enableRowSelections,\n i18n,\n isLinkedColumn: enableLinkedCell && colIndex === activeColumnsIndices[0],\n payload,\n rowIndex,\n serverField,\n })\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n return sorted\n}\n"],"mappings":";AAiBA,SACEA,uBAAuB,EACvBC,SAAS,EACTC,yBAAyB,EACzBC,qBAAqB,QAChB;AACP,OAAOC,KAAA,MAAW;AAIlB,SAASC,qBAAqB,QAAQ;AACtC,SACEC,UAAU,QAEL;AACP,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,QAAQ;AAgC7B,OAAO,MAAMC,gBAAA,GAAoBC,IAAA;EAC/B,MAAM;IACJC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,iBAAiB;IACjBC,OAAO;IACPC,eAAe;IACfC,QAAQ;IAC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