{"version":3,"file":"extendCTBInitialData.mjs","sources":["../../../admin/src/middlewares/extendCTBInitialData.ts"],"sourcesContent":["import type { Middleware } from '@reduxjs/toolkit';\nimport type { Store } from '@strapi/admin/strapi-admin';\n\nconst extendCTBInitialDataMiddleware: () => Middleware<\n object,\n ReturnType\n> = () => {\n return () => (next) => (action) => {\n if (\n action.type === 'ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT' &&\n action.modalType === 'contentType'\n ) {\n const i18n = { localized: false };\n\n const pluginOptions = action.data.pluginOptions\n ? { ...action.data.pluginOptions, i18n }\n : { i18n };\n\n const data = { ...action.data, pluginOptions };\n\n if (action.actionType === 'create') {\n return next({ ...action, data });\n }\n\n // Override the action if the pluginOption config does not contain i18n\n // In this case we need to set the proper initialData shape\n if (!action.data.pluginOptions?.i18n?.localized) {\n return next({ ...action, data });\n }\n }\n\n // action is not the one we want to override\n return next(action);\n };\n};\n\nexport { extendCTBInitialDataMiddleware };\n"],"names":["extendCTBInitialDataMiddleware","next","action","type","modalType","i18n","localized","pluginOptions","data","actionType"],"mappings":"AAGA,MAAMA,8BAGF,GAAA,IAAA;IACF,OAAO,IAAM,CAACC,IAAAA,GAAS,CAACC,MAAAA,GAAAA;AACtB,gBAAA,IACEA,OAAOC,IAAI,KAAK,mDAChBD,MAAOE,CAAAA,SAAS,KAAK,aACrB,EAAA;AACA,oBAAA,MAAMC,IAAO,GAAA;wBAAEC,SAAW,EAAA;AAAM,qBAAA;AAEhC,oBAAA,MAAMC,aAAgBL,GAAAA,MAAAA,CAAOM,IAAI,CAACD,aAAa,GAC3C;wBAAE,GAAGL,MAAAA,CAAOM,IAAI,CAACD,aAAa;AAAEF,wBAAAA;qBAChC,GAAA;AAAEA,wBAAAA;AAAK,qBAAA;AAEX,oBAAA,MAAMG,IAAO,GAAA;AAAE,wBAAA,GAAGN,OAAOM,IAAI;AAAED,wBAAAA;AAAc,qBAAA;oBAE7C,IAAIL,MAAAA,CAAOO,UAAU,KAAK,QAAU,EAAA;AAClC,wBAAA,OAAOR,IAAK,CAAA;AAAE,4BAAA,GAAGC,MAAM;AAAEM,4BAAAA;AAAK,yBAAA,CAAA;AAChC;;;AAIA,oBAAA,IAAI,CAACN,MAAOM,CAAAA,IAAI,CAACD,aAAa,EAAEF,MAAMC,SAAW,EAAA;AAC/C,wBAAA,OAAOL,IAAK,CAAA;AAAE,4BAAA,GAAGC,MAAM;AAAEM,4BAAAA;AAAK,yBAAA,CAAA;AAChC;AACF;;AAGA,gBAAA,OAAOP,IAAKC,CAAAA,MAAAA,CAAAA;AACd,aAAA;AACF;;;;"}