import{j as e,K as c,Q as f,ge as T,ej as P,h as o,i as l,g as p,cD as M,o as x,b as v,a4 as k}from"./app-BgLa5dit.js";import{u as L}from"./BTbeLL99.chunk.js";import{M as C}from"./DwzYo0zp.chunk.js";import{M as N}from"./CyA7a1Az.chunk.js";import{M as h,a as d}from"./DJkz-8BP.chunk.js";import{M as R}from"./DkfLu2gt.chunk.js";import"./9Z7K2s6J.chunk.js";import"./Cu2-dDll.chunk.js";import"./Bs6fQ2wT.chunk.js";import"./BUT90D7O.chunk.js";import"./DyuQzTEw.chunk.js";import"./DDfKZ_ng.chunk.js";import"./lZO4aq5x.chunk.js";import"./C8_78Eqq.chunk.js";import"./CwUNbMbl.chunk.js";const _="_dropdownBtn_1ld2d_1",D={dropdownBtn:_};function b(n){return e.jsx("div",{className:"w-100 d-flex justify-content-center",children:e.jsxs(c,{className:"px-2",children:[e.jsx(c.Toggle,{variant:"outline-dark",className:`w-100 ${D.dropdownBtn}`,children:e.jsx(f,{svg:T})}),h.renderInPortal(e.jsx(c.Menu,{children:n.actions.map(t=>e.jsx(c.Item,{className:t.className,onClick:t.onClick,children:t.label},t.label))}))]})})}const j=P();function y(n,t,s){const r=n.map(a=>j.accessor(a.name,{header:()=>e.jsx(d,{data:a.name,readonly:a.name==="id",appLink:a.name!=="id"&&{application:l.MARKETING_APP,action:o.Marketing.DELETE_FIELD,args:[t,a.name,s]}}),cell:i=>e.jsx(d,{data:i.getValue(),clampLevel:2,readonly:a.name==="id",appLink:{application:l.MARKETING_APP,action:o.Marketing.EDIT_CATALOG,args:[t,i.getValue(),i.table.getRowModel().rows[Number(i.row.id)].original.id,a.name,a.type,s]}})}));return r.push(j.accessor(a=>a,{id:"actions",header:()=>e.jsx(d,{data:"action",readonly:!0,appLink:null}),cell:a=>{const i=[{label:"Delete Item",onClick:()=>{const m={application:l.MARKETING_APP,action:o.Marketing.DELETE_ITEM,args:[t,a.table.getRowModel().rows[Number(a.row.id)].original.id,s]};p.trigger(m)}}];return e.jsx("div",{className:"p-1",children:e.jsx(b,{actions:i})})}})),r}function B({catalogName:n,region:t}){return e.jsxs("div",{className:"d-flex flex-row justify-content-between align-items-center",children:[e.jsx("h3",{children:n}),e.jsxs("div",{className:"d-flex flex-row align-items-center gap-2",children:[e.jsx(M,{variant:"dark",onClick:()=>{const s={application:l.MARKETING_APP,action:o.Marketing.CREATE_FIELDS,args:[n,t]};p.trigger(s)},children:"Create Field"}),e.jsx(M,{variant:"dark",onClick:()=>{const s={application:l.MARKETING_APP,action:o.Marketing.CREATE_ITEMS,args:[n,t]};p.trigger(s)},children:"Create Item"})]})]})}function V(n,t){return n.map(s=>t.reduce((r,a)=>(r[a.name]=s[a.name],r),{}))}function Z({catalogName:n,region:t}){var u;const s=x(C.getCatalog(n,t)),r=x(C.getCatalogItems(n,t)),{hasPermissions:a}=v(),i=a(k.MarketingContactUploadAll),m=a(k.MarketingCatalogManagement),w=i&&m;if(L({title:"Catalog Management"}),!s.hasCompleted||!r.hasCompleted)return e.jsx(e.Fragment,{});const g=(u=s.data)==null?void 0:u.fields,E=y(g,n,t),A=V(r.data,g),I=h.getLeftNavItems(w,o.Marketing.INDEX);return e.jsx(N,{leftNavItems:I,children:e.jsxs("div",{className:"p-4 d-flex flex-column gap-4",children:[e.jsx(B,{catalogName:n,region:t}),e.jsx(R,{data:A,columns:E})]})})}export{Z as ViewCatalogView};
//# sourceMappingURL=4HnJEmoz.chunk.js.map
