{"version":3,"file":"getCustomViewByRoute.js","names":["isPathMatchingRoute","getCustomViewByRoute","config","currentRoute","currentRouteWithAdmin","admin","components","views","routes","adminRoute","viewKey","replace","foundViewConfig","Object","entries","find","key","view","isMatching","exact","path","sensitive","strict","undefined","Component","viewConfig","payloadComponent"],"sources":["../../../src/views/Root/getCustomViewByRoute.ts"],"sourcesContent":["import type { AdminViewConfig, SanitizedConfig } from 'payload'\n\nimport type { ViewFromConfig } from './getRouteData.js'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nexport const getCustomViewByRoute = ({\n config,\n currentRoute: currentRouteWithAdmin,\n}: {\n config: SanitizedConfig\n currentRoute: string\n}): {\n view: ViewFromConfig\n viewConfig: AdminViewConfig\n viewKey: string\n} => {\n const {\n admin: {\n components: { views },\n },\n routes: { admin: adminRoute },\n } = config\n\n let viewKey: string\n\n const currentRoute =\n adminRoute === '/' ? currentRouteWithAdmin : currentRouteWithAdmin.replace(adminRoute, '')\n\n const foundViewConfig =\n (views &&\n typeof views === 'object' &&\n Object.entries(views).find(([key, view]) => {\n const isMatching = isPathMatchingRoute({\n currentRoute,\n exact: view.exact,\n path: view.path,\n sensitive: view.sensitive,\n strict: view.strict,\n })\n\n if (isMatching) {\n viewKey = key\n }\n\n return isMatching\n })?.[1]) ||\n undefined\n\n if (!foundViewConfig) {\n return {\n view: {\n Component: null,\n },\n viewConfig: null,\n viewKey: null,\n }\n }\n\n return {\n view: {\n payloadComponent: foundViewConfig.Component,\n },\n viewConfig: foundViewConfig,\n viewKey,\n }\n}\n"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,MAAM;EACNC,YAAA,EAAcC;AAAqB,CAIpC;EAKC,MAAM;IACJC,KAAA,EAAO;MACLC,UAAA,EAAY;QAAEC;MAAK;IAAE,CACtB;IACDC,MAAA,EAAQ;MAAEH,KAAA,EAAOI;IAAU;EAAE,CAC9B,GAAGP,MAAA;EAEJ,IAAIQ,OAAA;EAEJ,MAAMP,YAAA,GACJM,UAAA,KAAe,MAAML,qBAAA,GAAwBA,qBAAA,CAAsBO,OAAO,CAACF,UAAA,EAAY;EAEzF,MAAMG,eAAA,GACJL,KAAC,IACC,OAAOA,KAAA,KAAU,YACjBM,MAAA,CAAOC,OAAO,CAACP,KAAA,EAAOQ,IAAI,CAAC,CAAC,CAACC,GAAA,EAAKC,IAAA,CAAK;IACrC,MAAMC,UAAA,GAAalB,mBAAA,CAAoB;MACrCG,YAAA;MACAgB,KAAA,EAAOF,IAAA,CAAKE,KAAK;MACjBC,IAAA,EAAMH,IAAA,CAAKG,IAAI;MACfC,SAAA,EAAWJ,IAAA,CAAKI,SAAS;MACzBC,MAAA,EAAQL,IAAA,CAAKK;IACf;IAEA,IAAIJ,UAAA,EAAY;MACdR,OAAA,GAAUM,GAAA;IACZ;IAEA,OAAOE,UAAA;EACT,KAAK,EAAE,IACTK,SAAA;EAEF,IAAI,CAACX,eAAA,EAAiB;IACpB,OAAO;MACLK,IAAA,EAAM;QACJO,SAAA,EAAW;MACb;MACAC,UAAA,EAAY;MACZf,OAAA,EAAS;IACX;EACF;EAEA,OAAO;IACLO,IAAA,EAAM;MACJS,gBAAA,EAAkBd,eAAA,CAAgBY;IACpC;IACAC,UAAA,EAAYb,eAAA;IACZF;EACF;AACF","ignoreList":[]}