{"version":3,"file":"formatComponentConfigurationEditLayout.mjs","sources":["../../../admin/src/pages/formatComponentConfigurationEditLayout.ts"],"sourcesContent":["import { ComponentsDictionary } from '../hooks/useContentTypeSchema';\nimport { EditLayout, convertEditLayoutToFieldLayouts } from '../hooks/useDocumentLayout';\nimport { normalizeComponentConfigurationLayout } from '../utils/layouts/normalizeContentManagerLayout';\n\nimport type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';\nimport type { Schema } from '../hooks/useDocument';\n\n/**\n * Formats API configuration + schemas into the shape expected by the component\n * \"Configure the view\" form. Matches the ListView / content-type path: nested\n * `convertEditLayoutToFieldLayouts` calls must receive component configuration\n * and full component schemas so `getMainField` can resolve fields inside nested\n * component attributes (see #25509).\n */\nconst formatComponentConfigurationEditLayout = (\n data: FindComponentConfiguration.Response['data'],\n {\n schema,\n components,\n schemas = [],\n }: { schema?: Component; components: ComponentsDictionary; schemas?: Schema[] }\n): EditLayout => {\n const normalizedData = normalizeComponentConfigurationLayout(data, {\n schema,\n components,\n schemas,\n });\n\n const editAttributes = convertEditLayoutToFieldLayouts(\n normalizedData.component.layouts.edit,\n schema?.attributes,\n normalizedData.component.metadatas,\n { configurations: normalizedData.components, schemas: components },\n schemas\n );\n\n const componentEditAttributes = Object.entries(normalizedData.components).reduce<\n EditLayout['components']\n >((acc, [uid, configuration]) => {\n const componentSchema = components[uid];\n if (!componentSchema) {\n return acc;\n }\n\n acc[uid] = {\n layout: convertEditLayoutToFieldLayouts(\n configuration.layouts.edit,\n componentSchema.attributes,\n configuration.metadatas,\n { configurations: normalizedData.components, schemas: components },\n schemas\n ),\n settings: {\n ...configuration.settings,\n icon: componentSchema.info.icon,\n displayName: componentSchema.info.displayName,\n },\n };\n return acc;\n }, {});\n\n const editMetadatas = Object.entries(normalizedData.component.metadatas).reduce<\n EditLayout['metadatas']\n >((acc, [attribute, metadata]) => {\n return {\n ...acc,\n [attribute]: metadata.edit,\n };\n }, {});\n\n return {\n layout: [editAttributes],\n components: componentEditAttributes,\n metadatas: editMetadatas,\n options: {\n ...schema?.options,\n ...schema?.pluginOptions,\n },\n settings: {\n ...normalizedData.component.settings,\n displayName: schema?.info.displayName,\n },\n };\n};\n\nexport { formatComponentConfigurationEditLayout };\n"],"names":["formatComponentConfigurationEditLayout","data","schema","components","schemas","normalizedData","normalizeComponentConfigurationLayout","editAttributes","convertEditLayoutToFieldLayouts","component","layouts","edit","attributes","metadatas","configurations","componentEditAttributes","Object","entries","reduce","acc","uid","configuration","componentSchema","layout","settings","icon","info","displayName","editMetadatas","attribute","metadata","options","pluginOptions"],"mappings":";;;AAOA;;;;;;IAOA,MAAMA,sCAAAA,GAAyC,CAC7CC,IAAAA,EACA,EACEC,MAAM,EACNC,UAAU,EACVC,OAAAA,GAAU,EAAE,EACiE,GAAA;IAE/E,MAAMC,cAAAA,GAAiBC,sCAAsCL,IAAAA,EAAM;AACjEC,QAAAA,MAAAA;AACAC,QAAAA,UAAAA;AACAC,QAAAA;AACF,KAAA,CAAA;AAEA,IAAA,MAAMG,cAAAA,GAAiBC,+BAAAA,CACrBH,cAAAA,CAAeI,SAAS,CAACC,OAAO,CAACC,IAAI,EACrCT,QAAQU,UAAAA,EACRP,cAAAA,CAAeI,SAAS,CAACI,SAAS,EAClC;AAAEC,QAAAA,cAAAA,EAAgBT,eAAeF,UAAU;QAAEC,OAAAA,EAASD;KAAW,EACjEC,OAAAA,CAAAA;AAGF,IAAA,MAAMW,uBAAAA,GAA0BC,MAAAA,CAAOC,OAAO,CAACZ,cAAAA,CAAeF,UAAU,CAAA,CAAEe,MAAM,CAE9E,CAACC,GAAAA,EAAK,CAACC,KAAKC,aAAAA,CAAc,GAAA;QAC1B,MAAMC,eAAAA,GAAkBnB,UAAU,CAACiB,GAAAA,CAAI;AACvC,QAAA,IAAI,CAACE,eAAAA,EAAiB;YACpB,OAAOH,GAAAA;AACT,QAAA;QAEAA,GAAG,CAACC,IAAI,GAAG;YACTG,MAAAA,EAAQf,+BAAAA,CACNa,aAAAA,C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