@strapi/admin 4.12.1 → 4.12.2

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.
Files changed (66) hide show
  1. package/admin/src/content-manager/pages/EditSettingsView/index.js +1 -1
  2. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +7 -2
  3. package/admin/src/content-manager/pages/ListView/index.js +7 -1
  4. package/admin/src/hooks/index.js +0 -3
  5. package/admin/src/hooks/useAdminRolePermissions/__mocks__/index.js +5 -0
  6. package/admin/src/hooks/useAdminRolePermissions/index.js +34 -0
  7. package/admin/src/hooks/useAdminRoles/__mocks__/index.js +5 -0
  8. package/admin/src/hooks/useAdminRoles/index.js +40 -0
  9. package/admin/src/pages/InstalledPluginsPage/Plugins.js +2 -2
  10. package/admin/src/pages/InstalledPluginsPage/hooks/usePlugins/index.js +29 -0
  11. package/admin/src/pages/MarketplacePage/hooks/useFetchMarketplacePlugins/index.js +44 -0
  12. package/admin/src/pages/MarketplacePage/hooks/useFetchMarketplaceProviders/index.js +44 -0
  13. package/admin/src/pages/MarketplacePage/utils/useMarketplaceData.js +2 -2
  14. package/admin/src/pages/SettingsPage/pages/Roles/CreatePage/index.js +24 -9
  15. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/RoleForm/index.js +1 -0
  16. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/index.js +34 -20
  17. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +31 -84
  18. package/admin/src/pages/SettingsPage/pages/Roles/hooks/useAdminRolePermissionLayout/index.js +23 -0
  19. package/admin/src/translations/en.json +1 -1
  20. package/build/1049.f76cb14b.chunk.js +1 -0
  21. package/build/{2225.0e4f8c77.chunk.js → 2225.c6244756.chunk.js} +1 -1
  22. package/build/{Admin-authenticatedApp.8dfbc48d.chunk.js → Admin-authenticatedApp.3c585a0d.chunk.js} +2 -2
  23. package/build/{Admin_marketplace.f0b87fce.chunk.js → Admin_marketplace.dde9c148.chunk.js} +6 -6
  24. package/build/Admin_pluginsPage.bbe79434.chunk.js +6 -0
  25. package/build/{Admin_profilePage.ca82c67b.chunk.js → Admin_profilePage.192edc52.chunk.js} +1 -1
  26. package/build/{Admin_settingsPage.50c867bf.chunk.js → Admin_settingsPage.97cb9d41.chunk.js} +1 -1
  27. package/build/admin-app.91898385.chunk.js +36 -0
  28. package/build/admin-edit-roles-page.6d567273.chunk.js +267 -0
  29. package/build/admin-roles-list.23ddff26.chunk.js +22 -0
  30. package/build/content-manager.2af15f57.chunk.js +1099 -0
  31. package/build/content-type-builder.40534de5.chunk.js +170 -0
  32. package/build/{en-json.01456e61.chunk.js → en-json.08c05fcf.chunk.js} +1 -1
  33. package/build/index.html +1 -1
  34. package/build/{main.1f8cc299.js → main.f13fc96c.js} +204 -204
  35. package/build/{runtime~main.80a43c16.js → runtime~main.2902859a.js} +2 -2
  36. package/build/sso-settings-page.12b6d8ae.chunk.js +1 -0
  37. package/build/transfer-tokens-list-page.22147d2c.chunk.js +16 -0
  38. package/build/{upload.77d8a64c.chunk.js → upload.37488080.chunk.js} +3 -3
  39. package/ee/admin/pages/SettingsPage/pages/SingleSignOn/index.js +15 -24
  40. package/index.js +2 -0
  41. package/package.json +8 -8
  42. package/scripts/build.js +1 -0
  43. package/server/controllers/role.js +9 -1
  44. package/server/services/role.js +3 -2
  45. package/webpack.config.js +2 -1
  46. package/admin/src/hooks/marketplace/useFetchMarketplacePlugins/index.js +0 -44
  47. package/admin/src/hooks/marketplace/useFetchMarketplaceProviders/index.js +0 -44
  48. package/admin/src/hooks/useFetchEnabledPlugins/index.js +0 -24
  49. package/admin/src/hooks/useFetchEnabledPlugins/utils/api.js +0 -10
  50. package/admin/src/hooks/useFetchPermissionsLayout/index.js +0 -42
  51. package/admin/src/hooks/useFetchPermissionsLayout/reducer.js +0 -35
  52. package/admin/src/hooks/useFetchRole/index.js +0 -68
  53. package/admin/src/hooks/useFetchRole/reducer.js +0 -33
  54. package/admin/src/hooks/useRolesList/index.js +0 -58
  55. package/admin/src/hooks/useRolesList/init.js +0 -5
  56. package/admin/src/hooks/useRolesList/reducer.js +0 -31
  57. package/build/1049.c3d082e9.chunk.js +0 -1
  58. package/build/Admin_pluginsPage.8728ff6e.chunk.js +0 -6
  59. package/build/admin-app.041dcd81.chunk.js +0 -36
  60. package/build/admin-edit-roles-page.a49b9f4f.chunk.js +0 -267
  61. package/build/admin-roles-list.0c129e98.chunk.js +0 -23
  62. package/build/content-manager.098eb004.chunk.js +0 -1099
  63. package/build/content-type-builder.64f4d6ac.chunk.js +0 -170
  64. package/build/sso-settings-page.81152e62.chunk.js +0 -1
  65. package/build/transfer-tokens-list-page.692eee77.chunk.js +0 -16
  66. /package/admin/src/{hooks/marketplace → pages/MarketplacePage}/constants.js +0 -0
@@ -1,1099 +0,0 @@
1
- (self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[994],{2046:function(Qo,ct,l){"use strict";l.r(ct),l.d(ct,{App:function(){return ts},default:function(){return Vp}});var e=l(32735),Te=l(27649),De=l(82055),tt=l(96709),f=l(19565),Mt=l(98978),dt=l.n(Mt),Ge=l(74758),Y=l(67879),ae=l(15062),re=l(53038),Tt=l(17379),We=l(30305),Ot=(0,e.createContext)(),Ae=l(7921),ut=l(24381),ke=l(60216),n=l.n(ke),nt=l(47533),Pt=(0,e.createContext)(),Yo=l(75430),ne=l(69242),E=l(69997),le=l(41415),Qe=l(17e3),q=l(72850),P=l(87933),z=l(49372),Oe=l(15335),be=l(5803),Fe=l(68465),Ce=l(84967),Nt=l(9026),ot=l(29439),$e=l(66456),on=l(99381),we=l.n(on),Xo=l(89793),Pe=l.n(Xo),rn=l(23940),rt=l.n(rn),Be=l(20108),mt=l(20716),ge=l(14708),pt=l(19406),Ke=l(68625),ns=l(33795),$=l.n(ns);const Jo=e.createContext();function an({attributes:t,buttonData:o,children:r,goTo:a,layout:s,metadatas:c,moveItem:i,moveRow:d,onAddData:m,relationsLayout:u,removeField:p,selectedItemName:y,setEditFieldToSelect:h,...g}){return e.createElement(Jo.Provider,{value:{attributes:t,buttonData:o,goTo:a,layout:s,metadatas:c,moveItem:i,moveRow:d,onAddData:m,relationsLayout:u,removeField:p,selectedItemName:y,setEditFieldToSelect:h,...g}},r)}an.defaultProps={attributes:{},buttonData:[],goTo(){},layout:[],metadatas:{},moveItem(){},moveRow(){},onAddData(){},relationsLayout:[],removeField(){},selectedItemName:null,setEditFieldToSelect(){}},an.propTypes={attributes:n().object,buttonData:n().array,children:n().node.isRequired,goTo:n().func,layout:n().array,metadatas:n().object,moveItem:n().func,moveRow:n().func,onAddData:n().func,relationsLayout:n().array,removeField:n().func,selectedItemName:n().string,setEditFieldToSelect:n().func};function at(){return e.useContext(Jo)}const os=[{action:"plugin::content-type-builder.read",subject:null}];var rs=()=>{const{trackUsage:t}=(0,f.rS)(),{formatMessage:o}=(0,Y.Z)(),{slug:r,modifiedData:a,isContentTypeView:s}=at(),c=s?"content-types":"components",i=`/plugins/content-type-builder/${c==="content-types"?c:"component-categories"}`,d=$()(a,"category",""),m=c==="content-types"?r:`${d}/${r}`,u=()=>{t("willEditEditLayout")};return r==="strapi::administrator"?null:e.createElement(f.jW,{permissions:os},e.createElement(f.Qj,{to:`${i}/${m}`,onClick:u,size:"S",startIcon:e.createElement(Ke.Z,null),variant:"secondary"},o({id:(0,Ae.Z)(`edit-settings-view.link-to-ctb.${c}`),defaultMessage:"Edit the content type"})))},Ye=l(47081),jt=l(74506),It=l(51968),U=l(8471),Re=l(50563),Ve=l(4038),sn=l(45112);const _o=({componentUid:t})=>{const{componentLayouts:o}=at(),{formatMessage:r}=(0,Y.Z)(),a=$()(o,[t],{}),s=$()(a,["layouts","edit"],[]);return e.createElement(q.x,{padding:3},s.map((c,i)=>e.createElement(Oe.r,{gap:4,key:i},c.map(d=>e.createElement(be.P,{key:d.name,col:d.size},e.createElement(q.x,{paddingTop:2},e.createElement(P.k,{alignItems:"center",background:"neutral0",paddingLeft:3,paddingRight:3,height:`${32/16}rem`,hasRadius:!0,borderColor:"neutral200"},e.createElement(z.Z,{textColor:"neutral800"},d.name))))))),e.createElement(q.x,{paddingTop:2},e.createElement(f.rU,{startIcon:e.createElement(sn.Z,null),to:`/content-manager/components/${t}/configurations/edit`},r({id:(0,Ae.Z)("components.FieldItem.linkToComponentLayout"),defaultMessage:"Set the component's layout"}))))};_o.propTypes={componentUid:n().string.isRequired};var as=_o,gt=l(14911),ft=l(99140),ss=l(55805),is=l(31206),ls=l(97075),cs=l(14949),ds=l(8482),us=l(65261),ms=l(55877),ps=l(84298),ln=l(73906),gs=l(37272),fs=l(67121),hs=l(39869),er=l(35635),ys=l(26366),Es=l(98464),bs=l(2362),vs=l(89992),Cs=l(10473),Rs=l(95971),Ms=l(72536),Ts=l(68312),tr=l(80601),nr=l(74464),Ds=l(70809),Os=l(98148),Ps=l(81424),Is=l(69317),xs=l(25789),Zs=l(77359),ks=l(50416),Ls=l(20015),Ss=l(20276),As=l(82068),Fs=l(41645),$s=l(61294),ws=l(65943),Bs=l(8606),Ns=l(7961),js=l(92967),or=l(18070),Ws=l(54894),zs=l(30285),Us=l(96011),Vs=l(47041),qs=l(60625),rr=l(5644),Hs=l(78150),Gs=l(63717),Qs=l(24609),Ks=l(86543),Ys=l(62864),Xs=l(92989),Js=l(49886),_s=l(47052),ei=l(50694),ti=l(81875),ni=l(92323),cn=l(49844),oi=l(11631),ri=l(9254),ar=l(2669),ai=l(18709),si=l(20258),sr=l(43231),ii=l(45147),li=l(23154),ci=l(26253),di=l(79634),ui=l(32548),mi=l(99482),pi=l(45323),gi=l(76994),fi=l(88777),hi=l(95703),yi=l(8981),Ei=l(7733),bi=l(10168),vi=l(25449),Ci=l(83900),Ri=l(32645),Mi=l(78429),Ti=l(9882),ir=l(11417),Di=l(39698),Oi=l(92168),Pi=l(69621),Ii=l(2438),xi=l(92254),Zi=l(2287),ki=l(29685),lr=l(65663),dn=l(44647),Li=l(5502),Si=l(31047),Ai=l(93307),Fi=l(78055),$i=l(51239),wi=l(6792),Bi=l(75156),Ni=l(80683),ji=l(2689),Wi=l(40202),zi=l(36919),Ui=l(75444),Vi=l(92003),qi=l(4511),Hi=l(2847),cr=l(83139),Gi=l(53779),Qi=l(72890),Ki=l(84411),Yi=l(37193),Xi=l(74831),Ji=l(99221),_i=l(34119),un=l(99283),el=l(21371),tl=l(70727),nl=l(42213),ol=l(8611),rl=l(20448),al=l(73165);const dr={alien:ss.Z,apps:is.Z,archive:ls.Z,arrowDown:cs.Z,arrowLeft:ot.Z,arrowRight:ds.Z,arrowUp:us.Z,attachment:ms.Z,bell:ps.Z,bold:ln.Z,book:gs.Z,briefcase:fs.Z,brush:hs.Z,bulletList:er.Z,calendar:ys.Z,car:Es.Z,cast:bs.Z,chartBubble:vs.Z,chartCircle:Cs.Z,chartPie:Rs.Z,check:$e.Z,clock:Ms.Z,cloud:Ts.Z,code:tr.Z,cog:sn.Z,collapse:nr.Z,command:Ds.Z,connector:Os.Z,crop:Ps.Z,crown:Is.Z,cube:xs.Z,cup:Zs.Z,cursor:ks.Z,dashboard:Ls.Z,database:Ss.Z,discuss:As.Z,doctor:Fs.Z,earth:$s.Z,emotionHappy:ws.Z,emotionUnhappy:Bs.Z,envelop:Ns.Z,exit:js.Z,expand:or.Z,eye:Ws.Z,feather:zs.Z,file:Us.Z,fileError:Vs.Z,filePdf:qs.Z,filter:rr.Z,folder:Hs.Z,gate:Gs.Z,gift:Qs.Z,globe:Ks.Z,grid:Ys.Z,handHeart:Xs.Z,hashtag:Js.Z,headphone:_s.Z,heart:ei.Z,house:ti.Z,information:ni.Z,italic:cn.Z,key:oi.Z,landscape:ri.Z,layer:ar.Z,layout:ai.Z,lightbulb:si.Z,link:sr.Z,lock:ii.Z,magic:li.Z,manyToMany:ci.Z,manyToOne:di.Z,manyWays:ui.Z,medium:mi.Z,message:pi.Z,microphone:gi.Z,monitor:fi.Z,moon:hi.Z,music:yi.Z,oneToMany:Ei.Z,oneToOne:bi.Z,oneWay:vi.Z,paint:Ci.Z,paintBrush:Ri.Z,paperPlane:Mi.Z,pencil:Ke.Z,phone:Ti.Z,picture:ir.Z,pin:Di.Z,pinMap:Oi.Z,plane:Pi.Z,play:Ii.Z,plus:pt.Z,priceTag:xi.Z,puzzle:Zi.Z,question:ki.Z,quote:lr.Z,refresh:dn.Z,repeat:Li.Z,restaurant:Si.Z,rocket:Ai.Z,rotate:Fi.Z,scissors:$i.Z,search:wi.Z,seed:Bi.Z,server:Ni.Z,shield:ji.Z,shirt:Wi.Z,shoppingCart:zi.Z,slideshow:Ui.Z,stack:Vi.Z,star:qi.Z,store:Hi.Z,strikeThrough:cr.Z,sun:Gi.Z,television:Qi.Z,thumbDown:Ki.Z,thumbUp:Yi.Z,train:Xi.Z,twitter:Ji.Z,typhoon:_i.Z,underline:un.Z,user:el.Z,volumeMute:tl.Z,volumeUp:nl.Z,walk:ol.Z,wheelchair:rl.Z,write:al.Z};function xt({showBackground:t=!0,size:o="M",icon:r}){return e.createElement(P.k,{alignItems:"center",background:t?"neutral200":null,justifyContent:"center",size:o,showBackground:t,height:o==="S"?5:8,width:o==="S"?5:8,color:"neutral600",borderRadius:t?"50%":0},e.createElement(ft.J,{as:dr[r]||dr.cube,height:o==="S"?3:5,width:o==="S"?3:5}))}xt.defaultProps={showBackground:!0,size:"M",icon:"Cube"},xt.propTypes={showBackground:n().bool,size:n().string,icon:n().string};const sl=(0,U.ZP)(P.k)`
2
- text-decoration: none;
3
-
4
- &:focus,
5
- &:hover {
6
- ${({theme:t})=>`
7
- background-color: ${t.colors.primary100};
8
- border-color: ${t.colors.primary200};
9
-
10
- ${z.Z} {
11
- color: ${t.colors.primary600};
12
- }
13
- `}
14
-
15
- /* > ComponentIcon */
16
- > div:first-child {
17
- background: ${({theme:t})=>t.colors.primary200};
18
- color: ${({theme:t})=>t.colors.primary600};
19
-
20
- svg {
21
- path {
22
- fill: ${({theme:t})=>t.colors.primary600};
23
- }
24
- }
25
- }
26
- }
27
- `,ur=({components:t})=>{const{componentLayouts:o}=at();return e.createElement(P.k,{gap:2,overflow:"scroll hidden",padding:3},t.map(r=>e.createElement(sl,{hasRadius:!0,background:"neutral0",justifyContent:"center",alignItems:"center",height:`${84/16}rem`,minWidth:`${140/16}rem`,key:r,padding:2,direction:"column",borderColor:"neutral200",as:gt.rU,to:`/content-manager/components/${r}/configurations/edit`},e.createElement(xt,{icon:o?.[r]?.info?.icon}),e.createElement(q.x,{paddingTop:1},e.createElement(z.Z,{fontSize:1,textColor:"neutral600",fontWeight:"bold"},o?.[r]?.info?.displayName??"")))))};ur.propTypes={components:n().arrayOf(n().string).isRequired};var il=ur;const mr=(0,U.ZP)(Re.h)`
28
- background-color: transparent;
29
- path {
30
- fill: ${({theme:t})=>t.colors.neutral600};
31
- }
32
- `,mn=({attribute:t,onEditField:o,onDeleteField:r,children:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(q.x,{overflow:"hidden",width:"100%"},e.createElement(P.k,{paddingLeft:3,alignItems:"center",justifyContent:"space-between"},e.createElement(z.Z,{fontWeight:"semiBold",textColor:"neutral800",ellipsis:!0},a),e.createElement(P.k,null,e.createElement(mr,{label:s({id:(0,E.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:a}),onClick:o,icon:e.createElement(Ke.Z,null),noBorder:!0}),e.createElement(mr,{label:s({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:a}),"data-testid":"delete-field",onClick:r,icon:e.createElement(Ve.Z,null),noBorder:!0}))),t?.type==="component"&&e.createElement(as,{componentUid:t.component}),t?.type==="dynamiczone"&&e.createElement(il,{components:t.components}))};mn.defaultProps={attribute:void 0},mn.propTypes={attribute:n().shape({components:n().array,component:n().string,type:n().string}),onEditField:n().func.isRequired,onDeleteField:n().func.isRequired,children:n().string.isRequired};var ll=mn;const cl=(0,U.ZP)(P.k)`
33
- position: relative;
34
- ${({isFirst:t,isLast:o,hasHorizontalPadding:r})=>t?`
35
- padding-right: 4px;
36
- `:o?`
37
- padding-left: 4px;
38
- `:r?`
39
- padding: 0 4px;
40
- `:""}
41
- ${({showRightCarret:t,showLeftCarret:o,theme:r})=>t?`
42
- &:after {
43
- content: '';
44
- position: absolute;
45
- right: -1px;
46
- background-color: ${r.colors.primary600};
47
- width: 2px;
48
- height: 100%;
49
- align-self: stretch;
50
- z-index: 1;
51
- }
52
- `:o?`
53
- &:before {
54
- content: '';
55
- position: absolute;
56
- left: -1px;
57
- background-color: ${r.colors.primary600};
58
- width: 2px;
59
- height: 100%;
60
- align-self: stretch;
61
- z-index: 1;
62
- }
63
- `:""};
64
- `,dl=(0,U.ZP)(Ye.Z)`
65
- height: ${12/16}rem;
66
- width: ${12/16}rem;
67
- path {
68
- fill: ${({theme:t})=>t.colors.neutral600};
69
- }
70
- `,ul=(0,U.ZP)(P.k)`
71
- display: ${({dragStart:t})=>t?"none":"flex"};
72
- opacity: ${({isDragging:t,isFullSize:o,isHidden:r})=>t&&!o?.2:t&&o||r?0:1};
73
- `,ml=(0,U.ZP)(P.k)`
74
- cursor: all-scroll;
75
- border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
76
- `,pn=({attribute:t,children:o,index:r,lastIndex:a,moveItem:s,moveRow:c,name:i,onDeleteField:d,onEditField:m,rowIndex:u,size:p})=>{const[y,h]=(0,e.useState)(!1),g=i==="_TEMP_",{setIsDraggingSibling:b}=at(),R=p===12,x=(0,e.useRef)(null),C=(0,e.useRef)(null),[{clientOffset:M,isOver:Z},W]=(0,jt.useDrop)({accept:E._Q.EDIT_FIELD,hover(L,S){if(!C.current||L.size!==12)return;const v=S.getItem().index,V=r,G=S.getItem().rowIndex,K=u;if(v===V&&G===K)return;const k=C.current.getBoundingClientRect(),j=(k.bottom-k.top)/2,ue=S.getClientOffset().y-k.top;G<K&&ue<j||G>K&&ue>j||(c(G,K),L.rowIndex=K,L.itemIndex=V)},drop(L,S){if(!C.current)return;const v=S.getItem().index,V=r,G=S.getItem().rowIndex,K=u;if(L.size===12||v===V&&G===K)return;const k=C.current.getBoundingClientRect();if(Math.abs(S.getClientOffset().x-k.left)>k.width/1.8){s(v,V+1,G,K),L.itemIndex=V+1,L.rowIndex=K;return}s(v,V,G,K),L.itemIndex=V,L.rowIndex=K},collect:L=>({canDrop:L.canDrop(),clientOffset:L.getClientOffset(),isOver:L.isOver(),isOverCurrent:L.isOver({shallow:!0}),itemType:L.getItemType()})}),[{isDragging:T,getItem:O},B,w]=(0,jt.useDrag)({type:E._Q.EDIT_FIELD,item(){return b(!0),{index:r,labelField:o,rowIndex:u,name:i,size:p}},canDrag(){return i!=="_TEMP_"},collect:L=>({isDragging:L.isDragging(),getItem:L.getItem()}),end(){b(!1)}});(0,e.useEffect)(()=>{w((0,It.rX)(),{captureDraggingState:!0})},[w]);const I={dragRef:B(x),dropRef:W(C)};let N=!1,A=!1;if(C.current&&M){const L=C.current.getBoundingClientRect();N=Z&&O.size!==12&&Math.abs(M.x-L.left)<L.width/2,A=Z&&O.size!==12&&Math.abs(M.x-L.left)>L.width/2,i==="_TEMP_"&&(N=Z&&O.size!==12,A=!1)}const F=()=>t&&R?`${74/16}rem`:`${32/16}rem`,H=r===0&&!R,Q=r===a&&!R,X=r!==0&&!R;return e.createElement(be.P,{col:p},e.createElement(cl,{ref:I.dropRef,showLeftCarret:N,showRightCarret:A,isFirst:H,isLast:Q,hasHorizontalPadding:X,onDrag:()=>{R&&!y&&h(!0)},onDragEnd:()=>{R&&h(!1)}},y&&R&&e.createElement(q.x,{width:"100%",height:"2px",background:"primary600"}),e.createElement(ul,{width:R&&y?0:"100%",borderColor:"neutral150",hasRadius:!0,background:"neutral100",minHeight:F(),alignItems:"stretch",isDragging:T,dragStart:y,isFullSize:R,isHidden:g},e.createElement(ml,{as:"span",type:"button",ref:I.dragRef,onClick:L=>L.stopPropagation(),alignItems:"center",paddingLeft:3,paddingRight:3,tabIndex:-1},e.createElement(dl,null)),!g&&e.createElement(ll,{attribute:t,onEditField:m,onDeleteField:d},o))))};pn.defaultProps={attribute:void 0},pn.propTypes={attribute:n().shape({components:n().array,component:n().string,type:n().string}),children:n().string.isRequired,index:n().number.isRequired,moveItem:n().func.isRequired,moveRow:n().func.isRequired,name:n().string.isRequired,onDeleteField:n().func.isRequired,onEditField:n().func.isRequired,rowIndex:n().number.isRequired,lastIndex:n().number.isRequired,size:n().number.isRequired};var pl=pn;const pr=({rowItem:t,onRemoveField:o,rowId:r,rowIndex:a,index:s,lastIndex:c})=>{const{setEditFieldToSelect:i,attributes:d,modifiedData:m,moveRow:u,moveItem:p}=at(),y=$()(d,[t.name],{}),h=$()(m,["metadatas",t.name,"edit","label"],"");return e.createElement(pl,{onEditField:()=>i(t.name),onDeleteField:()=>o(r,s),attribute:y,index:s,lastIndex:c,rowIndex:a,name:t.name,size:t.size,moveRow:u,moveItem:p},h||t.name)};pr.propTypes={index:n().number.isRequired,lastIndex:n().number.isRequired,onRemoveField:n().func.isRequired,rowId:n().number.isRequired,rowIndex:n().number.isRequired,rowItem:n().object.isRequired};var gl=pr;const gr=({row:t,onRemoveField:o,rowIndex:r})=>e.createElement(Oe.r,null,t.rowContent.map((a,s)=>e.createElement(gl,{key:a.name,rowItem:a,index:s,rowId:t.rowId,onRemoveField:o,rowIndex:r,lastIndex:t.rowContent.length-1})));gr.propTypes={onRemoveField:n().func.isRequired,row:n().object.isRequired,rowIndex:n().number.isRequired};var fl=gr;const fr=({editLayout:t,fields:o,onRemoveField:r,onAddField:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(P.k,{justifyContent:"space-between"},e.createElement("div",null,e.createElement(q.x,null,e.createElement(z.Z,{fontWeight:"bold"},s({id:(0,E.OB)("containers.ListPage.displayedFields"),defaultMessage:"Displayed fields"}))),e.createElement(q.x,null,e.createElement(z.Z,{variant:"pi",textColor:"neutral600"},s({id:"containers.SettingPage.editSettings.description",defaultMessage:"Drag & drop the fields to build the layout"})))),e.createElement(rs,null)),e.createElement(q.x,{padding:4,hasRadius:!0,borderStyle:"dashed",borderWidth:"1px",borderColor:"neutral300"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},t.map((c,i)=>e.createElement(fl,{key:c.rowId,row:c,rowIndex:i,onRemoveField:r})),e.createElement(ge.fC,null,e.createElement(ge.xz,{startIcon:e.createElement(pt.Z,null),endIcon:null,disabled:o.length===0,fullWidth:!0,variant:"secondary"},s({id:(0,E.OB)("containers.SettingPage.add.field"),defaultMessage:"Insert another field"})),e.createElement(ge.VY,null,o.map(c=>e.createElement(ge.ck,{key:c,onSelect:()=>a(c)},c)))))))};fr.propTypes={editLayout:n().array.isRequired,fields:n().array.isRequired,onAddField:n().func.isRequired,onRemoveField:n().func.isRequired};var hl=fr,gn=l(85025),fn=l(55225),hn=l(31600),yn=l(11406),Zt=l(32031),yl=l(73779),Wt=l(88675),El=l(22348),hr=l(7184),En=l(43475),bl=l(82512),bn=l(83218),vl=l(872),Cl=l(17757),Rl=l(1176),Ml=l(15431);const yr={biginteger:e.createElement(Zt.Z,null),boolean:e.createElement(yl.Z,null),date:e.createElement(Wt.Z,null),datetime:e.createElement(Wt.Z,null),decimal:e.createElement(Zt.Z,null),email:e.createElement(El.Z,null),enum:e.createElement(hr.Z,null),enumeration:e.createElement(hr.Z,null),file:e.createElement(En.Z,null),files:e.createElement(En.Z,null),float:e.createElement(Zt.Z,null),integer:e.createElement(Zt.Z,null),media:e.createElement(En.Z,null),number:e.createElement(Zt.Z,null),relation:e.createElement(bl.Z,null),string:e.createElement(bn.Z,null),text:e.createElement(bn.Z,null),richtext:e.createElement(bn.Z,null),time:e.createElement(Wt.Z,null),timestamp:e.createElement(Wt.Z,null),json:e.createElement(vl.Z,null),uid:e.createElement(Cl.Z,null),component:e.createElement(Rl.Z,null),dynamiczone:e.createElement(Ml.Z,null)},vn=({type:t,customFieldUid:o})=>{const r=(0,f.mZ)();let a=yr[t];if(o){const c=r.get(o).icon;c&&(a=e.createElement(q.x,{marginRight:3,width:7,height:6},e.createElement(c,null)))}return yr[t]?a:null};vn.defaultProps={customFieldUid:null},vn.propTypes={type:n().string.isRequired,customFieldUid:n().string};var Er=vn,Tl=t=>t.reduce((o,r)=>{const a=r?.attributes??{},s=Object.keys(a).filter(c=>!["boolean","component","dynamiczone","json","media","password","relation","text","richtext"].includes(a?.[c]?.type??""));return o[r.uid]=s,o},{}),br=t=>{let o;switch(t){case"description":case"label":case"placeholder":o="text";break;case"mainField":o="select";break;case"editable":o="bool";break;default:o=""}const r=t==="mainField"?(0,E.OB)("containers.SettingPage.editSettings.entry.title"):(0,E.OB)(`form.Input.${t}`);return{type:o,label:{id:r}}},Cn=l(10369),kt=l(71842);const Rn=({type:t,options:o,onChange:r,value:a,name:s,...c})=>{const{formatMessage:i}=(0,Y.Z)();switch(t){case"text":return e.createElement(Cn.o,{onChange:r,value:a,name:s,...c});case"bool":return e.createElement(kt.s,{onChange:d=>{r({target:{name:s,value:d.target.checked}})},checked:a,name:s,onLabel:i({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"On"}),offLabel:i({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"Off"}),...c});case"select":return e.createElement(Fe.P,{value:a,name:s,onChange:d=>r({target:{name:s,value:d}}),...c},o.map(d=>e.createElement(Ce.W,{key:d,value:d},d)));default:return null}};Rn.defaultProps={options:void 0},Rn.propTypes={type:n().string.isRequired,options:n().arrayOf(n().string),onChange:n().func.isRequired,value:n().oneOfType([n().string,n().bool]).isRequired,name:n().string.isRequired};var Dl=Rn;const Ol=[[4,"33%"],[6,"50%"],[8,"66%"],[12,"100%"]],vr=({onMetaChange:t,onSizeChange:o})=>{const{formatMessage:r}=(0,Y.Z)(),{modifiedData:a,selectedField:s,attributes:c,fieldForm:i}=at(),d=(0,e.useMemo)(mt.Vo,[]),{schemas:m}=(0,ae.v9)(C=>d(C),ae.wU),u=(0,ae.v9)(mt.Jg),p=(0,e.useMemo)(()=>{if(!s)return[];const C=$()(a,["metadatas",s,"edit"],{});return Object.keys(C).filter(M=>M!=="visible")},[s,a]),y=(0,e.useMemo)(()=>Tl(m),[m]),h=(0,e.useCallback)(C=>{if(C!=="relation"&&C!=="component")return[];const M=C==="component"?"component":"targetModel",Z=$()(a,["attributes",s,M],"");return $()(y,[Z],[])},[s,y,a]),g=p.map(C=>{const M=$()(c,[s,"type"]);return["component","dynamiczone"].includes(M)&&!["label","description"].includes(C)||M==="component"&&C!=="label"||["media","json","boolean"].includes(M)&&C==="placeholder"||C==="step"?null:e.createElement(be.P,{col:6,key:C},e.createElement(Dl,{type:br(C).type,hint:C==="mainField"?r({id:(0,Ae.Z)("containers.SettingPage.editSettings.relation-field.description")}):"",label:r({id:$()(br(C),"label.id","app.utils.defaultMessage")}),name:C,onChange:t,value:$()(i,["metadata",C],""),options:h(M)}))}),{type:b,customField:R}=c[s],{isResizable:x}=u[R]??u[b];return e.createElement(e.Fragment,null,g,x&&e.createElement(be.P,{col:6,key:"size"},e.createElement(Fe.P,{value:i?.size,name:"size",onChange:C=>{o({name:s,value:C})},label:r({id:(0,Ae.Z)("containers.SettingPage.editSettings.size.label"),defaultMessage:"Size"})},Ol.map(([C,M])=>e.createElement(Ce.W,{key:C,value:C},M)))))};vr.propTypes={onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired};var Pl=vr;const Il=(0,U.ZP)(P.k)`
77
- svg {
78
- width: ${32/16}rem;
79
- height: ${24/16}rem;
80
- margin-right: ${({theme:t})=>t.spaces[3]};
81
- }
82
- `,Mn=({onToggle:t,onMetaChange:o,onSizeChange:r,onSubmit:a,type:s,customFieldUid:c})=>{const{selectedField:i}=at(),{formatMessage:d}=(0,Y.Z)(),m=()=>s==="timestamp"?"date":["decimal","float","integer","biginter"].includes(s)?"number":s;return e.createElement(gn.P,{onClose:t,labelledBy:"title"},e.createElement("form",{onSubmit:a},e.createElement(fn.x,null,e.createElement(Il,null,e.createElement(Er,{type:m(),customFieldUid:c}),e.createElement(z.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,E.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:rt()(i)})))),e.createElement(hn.f,null,e.createElement(Oe.r,{gap:4},e.createElement(Pl,{onMetaChange:o,onSizeChange:r}))),e.createElement(yn.m,{startActions:e.createElement(le.z,{onClick:t,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(le.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};Mn.defaultProps={customFieldUid:null},Mn.propTypes={customFieldUid:n().string,onSubmit:n().func.isRequired,onToggle:n().func.isRequired,onMetaChange:n().func.isRequired,onSizeChange:n().func.isRequired,type:n().string.isRequired};var xl=Mn,Zl=l(3040),oe=l.n(Zl);const Tn=t=>t.reduce((o,r)=>o+r.size,0),kl=t=>t.reduce((o,r,a)=>{const s={rowId:a,rowContent:r};return o.concat(s)},[]),ht=t=>t.reduce((o,r)=>{let a=[];const s=r.rowContent.reduce((d,m)=>{const u=Tn(d);return m.name==="_TEMP_"||(u+m.size<=12?d.push(m):a.push(m)),d},[]),c=o.length===0?0:Math.max.apply(Math,o.map(d=>d.rowId))+1,i=Tn(s);if(i<12&&s.push({name:"_TEMP_",size:12-i}),o.push({rowId:c,rowContent:s}),a.length>0){const d=Tn(a);d<12&&a.push({name:"_TEMP_",size:12-d}),o.push({rowId:c+1,rowContent:a}),a=[]}return o},[]).filter(o=>o.rowContent.length>0).filter(o=>o.rowContent.length===1?o.rowContent[0].name!=="_TEMP_":!0),Ll=t=>t.reduce((o,r)=>{const a=r.rowContent.filter(s=>s.name!=="_TEMP_");return o.concat([a])},[]),Sl=(t,o=[])=>o.reduce((r,{rowContent:a})=>{const s=a.find(c=>c.name===t)?.size??null;return s&&(r=s),r},null),Al=(t,o,r=[])=>r.map(a=>(a.rowContent=a.rowContent.map(s=>s.name===t?{...s,size:o}:s),a));var Fl=(t,o,r)=>{let a=we()(o);return oe()(a,["layouts","edit"],ht(kl(o.layouts.edit))),{...t,initialData:a,modifiedData:a,componentLayouts:r}},Dn=l(97889);const Cr=6,On={fieldForm:{},componentLayouts:{},metaToEdit:"",initialData:{},metaForm:{},modifiedData:{}};var $l=(t=On,o)=>(0,Dn.ZP)(t,r=>{const a=["modifiedData","layouts","edit"];switch(o.type){case"MOVE_ROW":{const s=$()(t,a,[]),{fromIndex:c,toIndex:i}=o;oe()(r,a,(0,E.W3)(s,c,i));break}case"ON_ADD_FIELD":{const s=we()(t),c=$()(s,["modifiedData","attributes",o.name],{}),i=o.fieldSizes[c?.customField]?.default??o.fieldSizes[c?.type]?.default??Cr,d=$()(s,a,[]).length,m=[...a,d-1,"rowContent"],u=$()(s,m,[]);let p=$()(s,a,[]);Array.isArray(u)?oe()(p,[d>0?d-1:0,"rowContent"],[...u,{name:o.name,size:i}]):oe()(p,[d>0?d-1:0,"rowContent"],[{name:o.name,size:i}]);const y=ht(p);oe()(r,a,y);break}case"ON_CHANGE":{oe()(r,["modifiedData",...o.keys],o.value);break}case"ON_CHANGE_META":{oe()(r,["metaForm","metadata",...o.keys],o.value);break}case"ON_CHANGE_SIZE":{oe()(r,["metaForm","size"],o.value);break}case"ON_RESET":{r.modifiedData=t.initialData;break}case"REMOVE_FIELD":{const s=$()(t,[...a,o.rowIndex,"rowContent"],[]);let c=we()(t);if(s.length===1||s.length===2&&$()(s,[1,"name"],"")==="_TEMP_"){const d=$()(t,a,[]);oe()(c,a,d.filter((m,u)=>o.rowIndex!==u))}else oe()(c,[...a,o.rowIndex,"rowContent"],s.filter((d,m)=>m!==o.fieldIndex));const i=ht($()(c,a,[]));oe()(r,a,i);break}case"REORDER_DIFF_ROW":{const s=$()(t,[...a,o.dragRowIndex,"rowContent"],[]),c=$()(t,[...a,o.hoverRowIndex,"rowContent"],[]),i=$()(t,[...a,o.dragRowIndex,"rowContent",o.dragIndex],{}),d=[...c,i];let m=we()(t);oe()(m,[...a,o.dragRowIndex,"rowContent"],s.filter((p,y)=>o.dragIndex!==y)),oe()(m,[...a,o.hoverRowIndex,"rowContent"],(0,E.W3)(d,d.length-1,o.hoverIndex));const u=ht($()(m,a,[]));oe()(r,a,u);break}case"REORDER_ROW":{const s=we()(t),c=$()(s,[...a,o.dragRowIndex,"rowContent"],[]);oe()(s,[...a,o.dragRowIndex,"rowContent"],(0,E.W3)(c,o.dragIndex,o.hoverIndex));const i=ht($()(s,a,[]));oe()(r,a,i);break}case"SET_FIELD_TO_EDIT":{r.metaToEdit=o.name,r.metaForm={metadata:$()(t,["modifiedData","metadatas",o.name,"edit"],{}),size:Sl(o.name,t.modifiedData?.layouts?.edit)??Cr};break}case"SUBMIT_META_FORM":{oe()(r,["modifiedData","metadatas",t.metaToEdit,"edit"],t.metaForm.metadata);const s=we()($()(t,a,[])),c=Al(t.metaToEdit,t.metaForm.size,s);c.length>0&&oe()(r,a,ht(c));break}case"SUBMIT_SUCCEEDED":{r.initialData=t.modifiedData;break}case"UNSET_FIELD_TO_EDIT":{r.metaToEdit="",r.metaForm={};break}default:return r}});const Pn=({mainLayout:t,components:o,isContentTypeView:r,slug:a,updateLayout:s})=>{const[c,i]=(0,e.useReducer)($l,On,()=>Fl(On,t,o)),[d,m]=(0,e.useState)(!1),{trackUsage:u}=(0,f.rS)(),p=(0,f.lm)(),{goBack:y}=(0,re.k6)(),[h,g]=(0,e.useState)(!1),[b,R]=(0,e.useState)(!1),{componentLayouts:x,initialData:C,modifiedData:M,metaToEdit:Z,metaForm:W}=c,{formatMessage:T}=(0,Y.Z)(),O=t.info.displayName,B=M?.attributes??{},w=(0,ae.v9)(mt.Jg),{put:I}=(0,f.kY)(),N=Object.keys(B).filter(D=>{const ee=B?.[D]?.type??"";return!["dynamiczone","json","text","relation","component","boolean","media","password","richtext","timestamp"].includes(ee)&&!!ee}),A=M.layouts.edit,F=A.flatMap(D=>D.rowContent),H=Object.keys(M.attributes).filter(D=>(M?.metadatas?.[D]?.edit?.visible??!1)===!0).filter(D=>F.findIndex(ee=>ee.name===D)===-1).sort(),Q=({target:{name:D,value:ee}})=>{i({type:"ON_CHANGE",keys:D.split("."),value:ee})},X=()=>{g(D=>!D)},L=()=>{R(D=>!D)},S=({target:{name:D,value:ee}})=>{i({type:"ON_CHANGE_META",keys:D.split("."),value:ee})},v=({name:D,value:ee})=>{i({type:"ON_CHANGE_SIZE",name:D,value:ee})},V=D=>{D.preventDefault(),i({type:"SUBMIT_META_FORM"}),X()},G=D=>{D.preventDefault(),L()},K=(0,Be.useMutation)(D=>I(r?`/content-manager/content-types/${a}/configuration`:`components/${a}/configuration`,D),{onSuccess({data:D}){s&&s(D.data),i({type:"SUBMIT_SUCCEEDED"}),L(),u("didEditEditSettings")},onError(){p({type:"warning",message:{id:"notification.error"}})}}),{isLoading:k}=K,j=()=>{const{layouts:D,metadatas:ee,settings:pe}=we()(M);K.mutate({layouts:{...D,edit:Ll(D.edit)},metadatas:ee,settings:pe})},te=(D,ee)=>{i({type:"MOVE_RELATION",fromIndex:D,toIndex:ee})},ue=(D,ee)=>{i({type:"MOVE_FIELD",fromIndex:D,toIndex:ee})},fe=(D,ee,pe,Ie)=>{i(pe===Ie?{type:"REORDER_ROW",dragRowIndex:pe,dragIndex:D,hoverIndex:ee}:{type:"REORDER_DIFF_ROW",dragIndex:D,hoverIndex:ee,dragRowIndex:pe,hoverRowIndex:Ie})},ye=(D,ee)=>{i({type:"MOVE_ROW",fromIndex:D,toIndex:ee})};return e.createElement(an,{isContentTypeView:r,attributes:B,modifiedData:M,slug:a,componentLayouts:x,selectedField:Z,fieldForm:W,onMoveRelation:te,onMoveField:ue,moveRow:ye,moveItem:fe,setEditFieldToSelect:D=>{i({type:"SET_FIELD_TO_EDIT",name:D}),X()},isDraggingSibling:d,setIsDraggingSibling:m},e.createElement(Te.o,null,e.createElement("form",{onSubmit:G},e.createElement(De.T,{title:T({id:(0,E.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:`Configure the view - ${rt()(O)}`},{name:rt()(O)}),subtitle:T({id:(0,E.OB)("components.SettingsViewWrapper.pluginHeader.description.edit-settings"),defaultMessage:"Customize how the edit view will look like."}),navigationAction:e.createElement(f.rU,{startIcon:e.createElement(ot.Z,null),onClick:D=>{D.preventDefault(),y()},to:"/"},T({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(le.z,{disabled:Pe()(C,M),startIcon:e.createElement($e.Z,null),type:"submit"},T({id:"global.save",defaultMessage:"Save"}))}),e.createElement(Qe.D,null,e.createElement(q.x,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(z.Z,{variant:"delta",as:"h2"},T({id:(0,E.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(Oe.r,null,e.createElement(be.P,{col:6,s:12},e.createElement(Fe.P,{label:T({id:(0,E.OB)("containers.SettingPage.editSettings.entry.title"),defaultMessage:"Entry title"}),hint:T({id:(0,E.OB)("containers.SettingPage.editSettings.entry.title.description"),defaultMessage:"Set the display field of your entry"}),onChange:D=>{Q({target:{name:"settings.mainField",value:D===""?null:D}})},value:M.settings.mainField},N.map(D=>e.createElement(Ce.W,{key:D,value:D},D))))),e.createElement(q.x,{paddingTop:2,paddingBottom:2},e.createElement(Nt.i,null)),e.createElement(z.Z,{variant:"delta",as:"h3"},T({id:(0,E.OB)("containers.SettingPage.view"),defaultMessage:"View"})),e.createElement(hl,{attributes:B,editLayout:A,fields:H,onAddField:D=>{i({type:"ON_ADD_FIELD",name:D,fieldSizes:w})},onRemoveField:(D,ee)=>{i({type:"REMOVE_FIELD",rowIndex:D,fieldIndex:ee})}})))),e.createElement(f.QH,{bodyText:{id:(0,E.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement($e.Z,null),isConfirmButtonLoading:k,isOpen:b,onToggleDialog:L,onConfirm:j,variantRightButton:"success-light"})),h&&e.createElement(xl,{onSubmit:V,onToggle:X,onMetaChange:S,onSizeChange:v,type:B?.[Z]?.type??"",customFieldUid:B?.[Z]?.customField??""})))};Pn.defaultProps={isContentTypeView:!1,updateLayout:null},Pn.propTypes={components:n().object.isRequired,isContentTypeView:n().bool,mainLayout:n().shape({attributes:n().object.isRequired,info:n().object.isRequired,layouts:n().shape({list:n().array.isRequired,edit:n().array.isRequired}).isRequired,metadatas:n().object.isRequired,options:n().object.isRequired}).isRequired,slug:n().string.isRequired,updateLayout:n().func};var In=Pn,zt=l(66941),Rr=l(40582);const wl=()=>({type:Rr.c}),Bl=(t,o)=>({type:Rr.O,layout:t,query:o});var xn=l(9592),Nl=l(76402),jl=()=>(0,e.useContext)(Nl.ux),Mr=t=>{const{getAdminInjectedComponents:o}=jl(),[r,a,s]=t.split(".");return o(r,a,s)};const Tr=({area:t,...o})=>Mr(t).map(a=>e.createElement(a.Component,{key:a.name,...o}));Tr.propTypes={area:n().string.isRequired};var Ut=Tr,ze=l(84306),Xe=l(46491);const Vt=()=>({type:Xe.ZA}),Zn=t=>({type:Xe.Id,data:t}),kn=(t,o=!1)=>({type:Xe.TP,rawQuery:t,isSingleType:o}),Dr=()=>({type:Xe.c2}),Or=(t,o)=>({type:Xe.w7,componentsDataStructure:t,contentTypeDataStructure:o}),me=t=>({type:Xe.d0,status:t}),Je=t=>({type:Xe.t9,data:t}),Wl=()=>({type:Xe.tE});var Ln=t=>t["content-manager_editViewCrudReducer"];const Sn=({allLayoutData:t,children:o,slug:r,id:a,origin:s})=>{const c=(0,Be.useQueryClient)(),i=(0,f.lm)(),{setCurrentStep:d}=(0,f.c1)(),{trackUsage:m}=(0,f.rS)(),{push:u,replace:p}=(0,re.k6)(),[{query:y,rawQuery:h}]=(0,f.Kx)(),g=(0,ae.I0)(),{componentsDataStructure:b,contentTypeDataStructure:R,data:x,isLoading:C,status:M}=(0,ae.v9)(Ln),Z=(0,ne.Ky)(r),{formatAPIError:W}=(0,f.So)(E.OB),T=(0,e.useRef)(!0),O=(0,e.useRef)(m),B=(0,e.useRef)(t),w=(0,f.kY)(),{put:I,post:N,del:A}=w,F=a===null,H=F&&!s?null:`/content-manager/collection-types/${r}/${s||a}`,Q=(0,e.useCallback)(k=>{const j=(0,E.kc)(k,B.current.contentType,B.current.components);return(0,f.dU)(j,B.current.contentType,B.current.components)},[]);(0,e.useEffect)(()=>{const k=Object.keys(t.components).reduce((ue,fe)=>{const ye=(0,E.Di)($()(t,["components",fe,"attributes"],{}),t.components);return ue[fe]=(0,f.dU)(ye,t.components[fe],t.components),ue},{}),j=(0,E.Di)(t.contentType.attributes,t.components),te=(0,f.dU)(j,t.contentType,t.components);g(Or(k,te))},[t,g]),(0,e.useEffect)(()=>()=>{g(Dr())},[g]),(0,e.useEffect)(()=>{const j=ze.default.CancelToken.source(),te=async fe=>{g(Vt());try{const{data:ye}=await w.get(H,{cancelToken:fe.token});g(Zn(Q(ye)))}catch(ye){if(ze.default.isCancel(ye))return;const D=$()(ye,"response.status",null);if(D===404){u(Z);return}D===403&&(i({type:"info",message:{id:(0,E.OB)("permissions.not-allowed.update")}}),u(Z))}},ue=async()=>{g(Vt()),g(kn(h))};return T.current?(H?te(j):ue(),()=>{j.cancel("Operation canceled by the user.")}):()=>{}},[w,Q,u,H,g,h,Z,i]);const X=(0,e.useCallback)(k=>{i({type:"warning",message:W(k)})},[i,W]),L=(0,e.useCallback)(async k=>{try{O.current("willDeleteEntry",k);const{data:j}=await A(`/content-manager/collection-types/${r}/${a}`);return i({type:"success",message:{id:(0,E.OB)("success.record.delete")}}),O.current("didDeleteEntry",k),p(Z),Promise.resolve(j)}catch(j){return O.current("didNotDeleteEntry",{error:j,...k}),Promise.reject(j)}},[a,r,i,A,Z,p]),S=(0,e.useCallback)(async(k,j)=>{const te=typeof s=="string",ue=te?`/content-manager/collection-types/${r}/clone/${s}`:`/content-manager/collection-types/${r}`;try{g(me("submit-pending"));const{id:fe,...ye}=k,{data:D}=await N(ue,te?ye:k,{params:y});return O.current("didCreateEntry",j),i({type:"success",message:{id:(0,E.OB)("success.record.save")}}),d("contentManager.success"),c.invalidateQueries(["relation"]),g(Je(Q(D))),g(me("resolved")),p(`/content-manager/collectionType/${r}/${D.id}${h}`),Promise.resolve(D)}catch(fe){return X(fe),O.current("didNotCreateEntry",{error:fe,trackerProperty:j}),g(me("resolved")),Promise.reject(fe)}},[s,Q,X,p,r,g,y,i,d,c,N,h]),v=(0,e.useCallback)(async()=>{try{O.current("willCheckDraftRelations");const k=`/content-manager/collection-types/${r}/${a}/actions/countDraftRelations`;g(me("draft-relation-check-pending"));const j=await w.get(k);return O.current("didCheckDraftRelations"),g(me("resolved")),j.data.data}catch(k){return X(k),g(me("resolved")),Promise.reject(k)}},[X,a,r,g,w]),V=(0,e.useCallback)(async()=>{try{O.current("willPublishEntry");const k=`/content-manager/collection-types/${r}/${a}/actions/publish`;g(me("publish-pending"));const{data:j}=await N(k);return O.current("didPublishEntry"),g(Je(Q(j))),g(me("resolved")),i({type:"success",message:{id:(0,E.OB)("success.record.publish")}}),Promise.resolve(j)}catch(k){return X(k),g(me("resolved")),Promise.reject(k)}},[Q,X,a,r,g,i,N]),G=(0,e.useCallback)(async(k,j)=>{const te=`/content-manager/collection-types/${r}/${a}`;try{O.current("willEditEntry",j),g(me("submit-pending"));const{data:ue}=await I(te,k);return O.current("didEditEntry",{trackerProperty:j}),i({type:"success",message:{id:(0,E.OB)("success.record.save")}}),c.invalidateQueries(["relation"]),g(Je(Q(ue))),g(me("resolved")),Promise.resolve(ue)}catch(ue){return O.current("didNotEditEntry",{error:ue,trackerProperty:j}),X(ue),g(me("resolved")),Promise.reject(ue)}},[Q,X,r,a,g,i,c,I]),K=(0,e.useCallback)(async()=>{const k=`/content-manager/collection-types/${r}/${a}/actions/unpublish`;g(me("unpublish-pending"));try{O.current("willUnpublishEntry");const{data:j}=await N(k);return O.current("didUnpublishEntry"),i({type:"success",message:{id:(0,E.OB)("success.record.unpublish")}}),g(Je(Q(j))),g(me("resolved")),Promise.resolve(j)}catch(j){return g(me("resolved")),X(j),Promise.reject(j)}},[Q,X,a,r,g,i,N]);return o({componentsDataStructure:b,contentTypeDataStructure:R,data:x,isCreatingEntry:F,isLoadingForData:C,onDelete:L,onPost:S,onPublish:V,onDraftRelationCheck:v,onPut:G,onUnpublish:K,status:M,redirectionLink:Z})};Sn.defaultProps={id:null,origin:null},Sn.propTypes={allLayoutData:n().exact({components:n().object.isRequired,contentType:n().shape({apiID:n().string.isRequired,attributes:n().object.isRequired,info:n().object.isRequired,isDisplayed:n().bool.isRequired,kind:n().string.isRequired,layouts:n().object.isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,pluginOptions:n().object,settings:n().object.isRequired,uid:n().string.isRequired}).isRequired}).isRequired,children:n().func.isRequired,id:n().string,origin:n().string,slug:n().string.isRequired};var zl=(0,e.memo)(Sn,Pe()),_e=l(3685),An=l(69783),Pr=l(86308);const Fn=({hasError:t,isDisabled:o,isOpen:r,children:a,onClick:s})=>e.createElement(Ul,{type:"button",onClick:s,disabled:o,hasError:t,background:"neutral0",paddingTop:3,paddingBottom:3,paddingLeft:4,paddingRight:4,style:{cursor:o?"not-allowed":"pointer"}},e.createElement(P.k,{as:"span",gap:2},e.createElement($n,{"aria-hidden":!0,$isOpen:r,$hasError:t&&!r}),e.createElement(z.Z,{variant:"pi",fontWeight:"bold",textColor:t&&!r?"danger600":"neutral500"},a))),$n=(0,U.ZP)(Pr.Z)`
83
- height: ${({theme:t})=>t.spaces[6]};
84
- width: ${({theme:t})=>t.spaces[6]};
85
- transform: ${({$isOpen:t})=>t?"rotate(45deg)":"rotate(0deg)"};
86
- > circle {
87
- fill: ${({theme:t,$hasError:o})=>o?t.colors.danger200:t.colors.neutral150};
88
- }
89
- > path {
90
- fill: ${({theme:t,$hasError:o})=>o?t.colors.danger600:t.colors.neutral600};
91
- }
92
- `,Ul=(0,U.ZP)(An.Y)`
93
- border-radius: 26px;
94
- border-color: ${({theme:t})=>t.colors.neutral150};
95
- box-shadow: ${({theme:t})=>t.shadows.filterShadow};
96
-
97
- &:hover {
98
- ${z.Z} {
99
- color: ${({theme:t})=>t.colors.primary600};
100
- }
101
-
102
- ${$n} {
103
- > circle {
104
- fill: ${({theme:t})=>t.colors.primary600};
105
- }
106
- > path {
107
- fill: ${({theme:t})=>t.colors.neutral100};
108
- }
109
- }
110
- }
111
- &:active {
112
- ${z.Z} {
113
- color: ${({theme:t})=>t.colors.primary600};
114
- }
115
- ${$n} {
116
- > circle {
117
- fill: ${({theme:t})=>t.colors.primary600};
118
- }
119
- > path {
120
- fill: ${({theme:t})=>t.colors.neutral100};
121
- }
122
- }
123
- }
124
- `;Fn.defaultProps={hasError:!1,isDisabled:!1,isOpen:!1},Fn.propTypes={children:n().node.isRequired,hasError:n().bool,isDisabled:n().bool,isOpen:n().bool,onClick:n().func.isRequired};var Ir=l(861),wn=l(83828),Bn=l(61762),Nn=l(89966);const jn=({category:t,components:o,variant:r,isOpen:a,onAddComponent:s,onToggle:c})=>{const{formatMessage:i}=(0,Y.Z)(),d=()=>{c(t)};return e.createElement(wn.U,{expanded:a,onToggle:d,size:"S"},e.createElement(Bn.B,{variant:r,title:i({id:t,defaultMessage:t}),togglePosition:"left"}),e.createElement(Nn.v,null,e.createElement(q.x,{paddingTop:4,paddingBottom:4,paddingLeft:3,paddingRight:3},e.createElement(Vl,null,o.map(({componentUid:m,info:{displayName:u,icon:p}})=>e.createElement(ql,{key:m,as:"button",type:"button",background:"neutral100",justifyContent:"center",onClick:s(m),hasRadius:!0,height:(0,f.Q1)(84),shrink:0,borderColor:"neutral200"},e.createElement(P.k,{direction:"column",gap:1,alignItems:"center",justifyContent:"center"},e.createElement(xt,{icon:p}),e.createElement(z.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral600"},i({id:u,defaultMessage:u})))))))))},Vl=U.ZP.div`
125
- display: grid;
126
- grid-template-columns: repeat(auto-fit, ${140/16}rem);
127
- grid-gap: ${({theme:t})=>t.spaces[1]};
128
- `,ql=(0,U.ZP)(P.k)`
129
- &:focus,
130
- &:hover {
131
- border: 1px solid ${({theme:t})=>t.colors.primary200};
132
- background: ${({theme:t})=>t.colors.primary100};
133
-
134
- ${z.Z} {
135
- color: ${({theme:t})=>t.colors.primary600};
136
- }
137
-
138
- /* > Flex > ComponentIcon */
139
- > div > div:first-child {
140
- background: ${({theme:t})=>t.colors.primary200};
141
- color: ${({theme:t})=>t.colors.primary600};
142
- }
143
- }
144
- `;jn.defaultProps={components:[],isOpen:!1,variant:"primary"},jn.propTypes={category:n().string.isRequired,components:n().array,isOpen:n().bool,onAddComponent:n().func.isRequired,onToggle:n().func.isRequired,variant:n().oneOf(["primary","secondary"])};const Wn=({dynamicComponentsByCategory:t,isOpen:o,onClickAddComponent:r})=>{const{formatMessage:a}=(0,Y.Z)(),[s,c]=(0,e.useState)("");(0,e.useEffect)(()=>{const m=Object.keys(t);o&&m.length>0&&c(m[0])},[o,t]);const i=m=>()=>{r(m),c("")},d=m=>{c(u=>u===m?"":m)};return o?e.createElement(q.x,{paddingTop:6,paddingBottom:6,paddingLeft:5,paddingRight:5,background:"neutral0",shadow:"tableShadow",borderColor:"neutral150",hasRadius:!0},e.createElement(P.k,{justifyContent:"center"},e.createElement(z.Z,{fontWeight:"bold",textColor:"neutral600"},a({id:(0,E.OB)("components.DynamicZone.ComponentPicker-label"),defaultMessage:"Pick one component"}))),e.createElement(q.x,{paddingTop:2},e.createElement(Ir.k,{attributeName:"data-strapi-accordion-toggle"},Object.entries(t).map(([m,u],p)=>e.createElement(jn,{key:m,category:m,components:u,onAddComponent:i,isOpen:m===s,onToggle:d,variant:p%2===1?"primary":"secondary"}))))):null};Wn.defaultProps={dynamicComponentsByCategory:{},isOpen:!1},Wn.propTypes={dynamicComponentsByCategory:n().shape({components:n().arrayOf(n().shape({componentUid:n().string.isRequired,info:n().object}))}),isOpen:n().bool,onClickAddComponent:n().func.isRequired};var xr=l(91647),zn=l(49825),Hl=l(61868),Gl=l.n(Hl);const Ql=U.ZP.span`
145
- > svg {
146
- width: ${(0,f.Q1)(24)};
147
- height: ${(0,f.Q1)(24)};
148
- > circle {
149
- fill: ${({theme:t})=>t.colors.primary200};
150
- }
151
- > path {
152
- fill: ${({theme:t})=>t.colors.primary600};
153
- }
154
- }
155
- `,Un=({error:t,isReadOnly:o,onClick:r})=>{const{formatMessage:a}=(0,Y.Z)();return e.createElement(e.Fragment,null,e.createElement(q.x,{as:"button",background:"neutral100",borderColor:t?"danger600":"neutral200",disabled:o,hasRadius:!0,onClick:r,paddingTop:9,paddingBottom:9,type:"button"},e.createElement(P.k,{direction:"column",gap:2},e.createElement(P.k,{justifyContent:"center",style:{cursor:o?"not-allowed":"inherit"}},e.createElement(Ql,null,e.createElement(Pr.Z,null))),e.createElement(P.k,{justifyContent:"center"},e.createElement(z.Z,{textColor:"primary600",variant:"pi",fontWeight:"bold"},a({id:(0,E.OB)("components.empty-repeatable"),defaultMessage:"No entry yet. Click on the button below to add one."}))))),t?.id&&e.createElement(z.Z,{textColor:"danger600",variant:"pi"},a(t,{...t.values})))};Un.defaultProps={error:void 0,isReadOnly:!1},Un.propTypes={error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),isReadOnly:n().bool,onClick:n().func.isRequired};var Zr=Un;const Lt=new Map;var Vn=(t=[])=>{const[o,r]=(0,e.useState)(Object.fromEntries(Lt)),a=t.filter(m=>!Lt.get(m)),[s,c]=(0,e.useState)(()=>!!a.length),i=(0,f.mZ)();(0,e.useEffect)(()=>{const m=p=>{r(p),c(!1)},u=async(p,y)=>{const h=await Promise.all(y);p.forEach((g,b)=>{Lt.set(g,h[b].default)}),m(Object.fromEntries(Lt))};if(a.length>0){c(!0);const p=a.reduce((y,h)=>{const g=i.get(h);return g&&y.push(g.components.Input()),y},[]);p.length>0&&u(a,p)}},[a,i]);const d=(0,e.useCallback)(()=>{Lt.clear(),r({})},[]);return{isLazyLoading:s,lazyComponentStore:o,cleanup:d}},Kl=l(9086),Yl=l.n(Kl),Xl=l(88708),St=l.n(Xl),qn=l(38705),At=l(69932),Jl=l(27169),kr=l(99097),_l=l(63642);const ec=(0,U.ZP)(_l.E)`
156
- svg {
157
- height: 1rem;
158
- width: 1rem;
159
- path {
160
- fill: ${({theme:t})=>t.colors.neutral400};
161
- }
162
- }
163
-
164
- svg:hover {
165
- path {
166
- fill: ${({theme:t})=>t.colors.primary600};
167
- }
168
- }
169
- `,Lr=(0,U.ZP)(P.k)`
170
- svg {
171
- height: ${12/16}rem;
172
- width: ${12/16}rem;
173
-
174
- path {
175
- fill: ${({theme:t,available:o})=>o?t.colors.success600:t.colors.danger600};
176
- }
177
- }
178
- `,tc=(0,U.F4)`
179
- from {
180
- transform: rotate(0deg);
181
- }
182
- to {
183
- transform: rotate(359deg);
184
- }
185
- `,nc=(0,U.ZP)(P.k)`
186
- animation: ${tc} 2s infinite linear;
187
- `;var oc=/^[A-Za-z0-9-_.~]*$/;const Hn=({attribute:t,contentTypeUID:o,hint:r,disabled:a,error:s,intlLabel:c,labelAction:i,name:d,onChange:m,value:u,placeholder:p,required:y})=>{const{modifiedData:h,initialData:g,layout:b}=(0,f.Wq)(),[R,x]=(0,e.useState)(!1),[C,M]=(0,e.useState)(null),Z=(0,kr.Z)(u,300),W=(0,e.useRef)(),T=(0,f.lm)(),{formatAPIError:O}=(0,f.So)(),B=g[d],{formatMessage:w}=(0,Y.Z)(),I=b?.options?.timestamps??0,N=!g[I],A=(0,kr.Z)(h[t.targetField],300),[F,H]=(0,e.useState)(!1),[Q,X]=(0,e.useState)(null),{post:L}=(0,f.kY)(),S=c.id?w({id:c.id,defaultMessage:c.defaultMessage},{...c.values}):d,v=p?w({id:p.id,defaultMessage:p.defaultMessage},{...p.values}):"";W.current=async(j=!1)=>{x(!0);try{const{data:{data:te}}=await L("/content-manager/uid/generate",{contentTypeUID:o,field:d,data:h});m({target:{name:d,value:te,type:"text"}},j),x(!1)}catch(te){x(!1),T({type:"warning",message:O(te)})}};const V=async()=>{if(u){x(!0);try{const{data:j}=await L("/content-manager/uid/check-availability",{contentTypeUID:o,field:d,value:u?u.trim():""});x(!1),M(j)}catch(j){x(!1),T({type:"warning",message:O(j)})}}};(0,e.useEffect)(()=>{!u&&t.required&&W.current(!0)},[t.required,W,u]),(0,e.useEffect)(()=>{Z?.trim().match(oc)&&Z!==B&&V(),Z||M(null)},[B,Z]),(0,e.useEffect)(()=>{let j;return C?.isAvailable&&(j=setTimeout(()=>{M(null)},4e3)),()=>{j&&clearTimeout(j)}},[C]),(0,e.useEffect)(()=>{!F&&N&&A&&h[t.targetField]&&!u&&W.current(!0)},[A,F,N]);const G=()=>{X(w({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}))},K=()=>{X(null)},k=j=>{j.target.value&&N&&H(!0),m(j)};return e.createElement(Cn.o,{disabled:a,error:s,endAction:e.createElement(P.k,{position:"relative",gap:1},C&&!Q&&e.createElement(Lr,{alignItems:"center",gap:1,justifyContent:"flex-end",available:!!C?.isAvailable,"data-not-here-outer":!0,position:"absolute",pointerEvents:"none",right:6,width:"100px"},C?.isAvailable?e.createElement(qn.Z,null):e.createElement(At.Z,null),e.createElement(z.Z,{textColor:C.isAvailable?"success600":"danger600",variant:"pi"},w(C.isAvailable?{id:"content-manager.components.uid.available",defaultMessage:"Available"}:{id:"content-manager.components.uid.unavailable",defaultMessage:"Unavailable"}))),!a&&e.createElement(e.Fragment,null,Q&&e.createElement(Lr,{alignItems:"center",justifyContent:"flex-end",gap:1},e.createElement(z.Z,{textColor:"primary600",variant:"pi"},Q)),e.createElement(ec,{onClick:()=>W.current(),label:w({id:"content-manager.components.uid.regenerate",defaultMessage:"Regenerate"}),onMouseEnter:G,onMouseLeave:K},R?e.createElement(nc,{"data-testid":"loading-wrapper"},e.createElement(Jl.Z,null)):e.createElement(dn.Z,null)))),hint:r,label:S,labelAction:i,name:d,onChange:k,placeholder:v,value:u||"",required:y})};Hn.propTypes={attribute:n().shape({targetField:n().string,required:n().bool}).isRequired,contentTypeUID:n().string.isRequired,disabled:n().bool,error:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,onChange:n().func.isRequired,value:n().string,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,hint:n().oneOfType([n().string,n().array])},Hn.defaultProps={disabled:!1,error:void 0,labelAction:void 0,placeholder:void 0,value:"",required:!1,hint:""};var rc=Hn,ac=l(88423),sc=l.n(ac);function ic(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var lc=ic;const cc=(t=[],o=[])=>{const r=t.reduce((s,c)=>o.find(i=>i.id===c.id)?s:[...s,c.id],[]),a=o.reduce((s,c)=>t.find(i=>i.id===c.id)?s:[...s,c.id],[]);return[r,a]},st={DRAFT:"draft",PUBLISHED:"published"},Gn=5,dc=10;function uc(t,o){return`/content-manager/collectionType/${t}/${o??""}`}const Qn=(t,{shouldAddLink:o,mainFieldName:r,targetModel:a})=>{const s={...t};return o&&(s.href=uc(a,s.id)),s.publicationState=!1,s?.publishedAt!==void 0&&(s.publicationState=s.publishedAt?st.PUBLISHED:st.DRAFT),s.mainField=s[r],s},mc=(t,{shouldAddLink:o=!1,mainFieldName:r,targetModel:a}={})=>[...t].map(s=>Qn(s,{shouldAddLink:o,mainFieldName:r,targetModel:a})),pc=(t,{mainFieldName:o})=>{const{data:r}=t,{pages:a=[]}=r??{};return{...t,data:a.map(s=>s?.results.map(c=>Qn(c,{mainFieldName:o}))).filter(Boolean).flat()}};function gc({componentUid:t,isUserAllowedToEditField:o,isUserAllowedToReadField:r,name:a,queryInfos:s}){const{isCreatingEntry:c,createActionAllowedFields:i,readActionAllowedFields:d,updateActionAllowedFields:m,slug:u,modifiedData:p}=(0,f.Wq)(),{params:y}=(0,re.$B)("/content-manager/collectionType/:collectionType/create/clone/:origin")??{},{origin:h}=y??{},g=(0,e.useMemo)(()=>o===!0?!0:(c?i:m).includes(a),[c,i,a,o,m]),b=(0,e.useMemo)(()=>r?!0:(c?[]:d).includes(a),[c,r,a,d]),R=a.split(".");let x;t&&(x=$()(p,R.slice(0,-1))?.id);const C=h||p.id,M=(0,e.useMemo)(()=>c&&!h?null:t?x?`/content-manager/relations/${t}/${x}/${R.at(-1)}`:null:`/content-manager/relations/${u}/${C}/${a.split(".").at(-1)}`,[c,h,t,u,C,a,x,R]),Z=(0,e.useMemo)(()=>t?`/content-manager/relations/${t}/${a.split(".").at(-1)}`:`/content-manager/relations/${u}/${a.split(".").at(-1)}`,[t,u,a]);return{entityId:C,componentId:x,isComponentRelation:Boolean(t),queryInfos:{...s,endpoints:{search:Z,relation:M}},isCloningEntry:Boolean(h),isCreatingEntry:c,isFieldAllowed:g,isFieldReadable:b}}var fc=gc;const hc=(t,{relation:o,search:r})=>{const[a,s]=(0,e.useState)({}),[c,i]=(0,e.useState)(0),{get:d}=(0,f.kY)(),m=async({pageParam:T=1})=>{try{const{data:O}=await d(o?.endpoint,{params:{...o.pageParams??{},page:T}});return i(T),O}catch{return null}},u=async({pageParam:T=1})=>{try{const{data:O}=await d(r.endpoint,{params:{...r.pageParams??{},...a,page:T}});return O}catch{return null}},{onLoad:p,normalizeArguments:y={}}=o,h=(0,Be.useInfiniteQuery)(["relation",...t],m,{cacheTime:0,enabled:o.enabled,getNextPageParam(T){const O=!T?.pagination;if(!(!T||O||T?.pagination.page>=T?.pagination.pageCount))return T.pagination.page+1},select:T=>({...T,pages:T.pages.map(O=>{if(!O)return O;const{data:B,results:w,pagination:I}=O,N=!!B;let A=[];return N?A=[B]:w&&(A=[...w].reverse()),{pagination:I,results:A}})})}),{pageGoal:g}=o,{status:b,data:R,fetchNextPage:x,hasNextPage:C}=h;(0,e.useEffect)(()=>{g>c&&C&&b==="success"&&x({pageParam:c+1})},[g,c,x,C,b]);const M=(0,f.W6)(p);(0,e.useEffect)(()=>{if(b==="success"&&R&&R.pages?.at(-1)?.results&&M){const T=mc(R.pages.at(-1).results,y);M(T)}},[b,M,R]);const Z=(0,Be.useInfiniteQuery)(["relation",...t,"search",JSON.stringify(a)],u,{enabled:Object.keys(a).length>0,getNextPageParam(T){if(!(!T?.pagination||T.pagination.page>=T.pagination.pageCount))return T.pagination.page+1}});return{relations:h,search:Z,searchFor:(T,O={})=>{s({...O,_q:T})}}},Sr=(t,o)=>r=>{const a=r.split(".");return a.reduce((s,c,i)=>{const d=$()(t,s),m=$()(o,[...a.slice(0,i),c,"__temp_key__"]);if(Array.isArray(d)&&typeof m=="number"){const u=d.findIndex(p=>p.__temp_key__===m);return s.push(u.toString()),s}return s.push(c),s},[])};var yc=l(50428),Ec=l(21428),Ar=l(7563),Ft=l(63919),Kn=l(41234),qt=l(35331),bc=l(41044),Fr=l(90333);const vc=U.ZP.div`
188
- flex-shrink: 0;
189
- width: ${(0,f.Q1)(6)};
190
- height: ${(0,f.Q1)(6)};
191
- margin-right: ${({theme:t})=>t.spaces[2]};
192
- background-color: ${({theme:t,isDraft:o})=>t.colors[o?"secondary600":"success600"]};
193
- border-radius: 50%;
194
- `,Yn=({publicationState:t,mainField:o,id:r})=>{const{formatMessage:a}=(0,Y.Z)(),s=(o??r).toString();if(t){const c=t==="draft",i={id:(0,E.OB)("components.Select.draft-info-title"),defaultMessage:"State: Draft"},d={id:(0,E.OB)("components.Select.publish-info-title"),defaultMessage:"State: Published"},m=a(c?i:d);return e.createElement(Fr.O,{value:r,textValue:s},e.createElement(P.k,null,e.createElement(vc,{title:m,isDraft:c}),e.createElement(z.Z,{ellipsis:!0},s)))}return e.createElement(Fr.O,{value:r,textValue:s},s)};Yn.defaultProps={mainField:void 0,publicationState:void 0},Yn.propTypes={id:n().number.isRequired,mainField:n().oneOfType([n().string,n().number]),publicationState:n().oneOfType([n().string,n().bool])};var $r=l(77622);const Ht=50,yt=4,wr=(0,U.ZP)(P.k)`
195
- width: 100%;
196
- /* Used to prevent endAction to be pushed out of container */
197
- min-width: 0;
198
-
199
- & > div[role='button'] {
200
- cursor: all-scroll;
201
- }
202
- `,Br=(0,U.ZP)(P.k)`
203
- width: 100%;
204
- /* Used to prevent endAction to be pushed out of container */
205
- min-width: 0;
206
- `,Xn=({ariaDescribedBy:t,children:o,displayValue:r,canDrag:a,disabled:s,endAction:c,iconButtonAriaLabel:i,style:d,id:m,index:u,name:p,onCancel:y,onDropItem:h,onGrabItem:g,status:b,updatePositionOfRelation:R,...x})=>{const[{handlerId:C,isDragging:M,handleKeyDown:Z},W,T,O,B]=(0,$r.Y)(a&&!s,{type:`${E._Q.RELATION}_${p}`,index:u,item:{displayedValue:r,status:b,id:m},onGrabItem:g,onDropItem:h,onCancel:y,onMoveItem:R,dropSensitivity:"immediate"}),w=(0,E.FE)(W,O);return(0,e.useEffect)(()=>{B((0,It.rX)())},[B]),e.createElement(q.x,{style:d,as:"li",ref:T,"aria-describedby":t,cursor:a?"all-scroll":"default"},M?e.createElement(Cc,null):e.createElement(P.k,{paddingTop:2,paddingBottom:2,paddingLeft:a?2:4,paddingRight:4,hasRadius:!0,borderSize:1,borderColor:"neutral200",background:s?"neutral150":"neutral0",justifyContent:"space-between",ref:a?w:void 0,"data-handler-id":C,...x},e.createElement(wr,{gap:1},a?e.createElement(Re.h,{forwardedAs:"div",role:"button",tabIndex:0,"aria-label":i,noBorder:!0,onKeyDown:Z,disabled:s},e.createElement(Ye.Z,null)):null,e.createElement(Br,{justifyContent:"space-between"},o)),c&&e.createElement(q.x,{paddingLeft:4},c)))},Cc=()=>e.createElement(q.x,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderStyle:"dashed",borderColor:"primary600",borderWidth:"1px",background:"primary100",height:`calc(100% - ${yt}px)`});Xn.defaultProps={ariaDescribedBy:"",canDrag:!1,displayValue:"",disabled:!1,endAction:void 0,onCancel:void 0,onDropItem:void 0,onGrabItem:void 0,style:void 0,status:void 0,updatePositionOfRelation:void 0},Xn.propTypes={ariaDescribedBy:n().string,canDrag:n().bool,children:n().node.isRequired,displayValue:n().string,disabled:n().bool,endAction:n().node,iconButtonAriaLabel:n().string.isRequired,id:n().number.isRequired,index:n().number.isRequired,name:n().string.isRequired,onCancel:n().func,onDropItem:n().func,onGrabItem:n().func,status:n().string,style:n().shape({height:n().number,left:n().number,position:n().string,right:n().number,width:n().string}),updatePositionOfRelation:n().func};const Rc=(0,U.ZP)(q.x)`
207
- position: relative;
208
- overflow: hidden;
209
- flex: 1;
210
-
211
- &:before,
212
- &:after {
213
- position: absolute;
214
- width: 100%;
215
- height: 4px;
216
- z-index: 1;
217
- }
218
-
219
- &:before {
220
- /* TODO: as for DS Table component we would need this to be handled by the DS theme */
221
- content: '';
222
- background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
223
- top: 0;
224
- opacity: ${({overflowDirection:t})=>t==="top-bottom"||t==="top"?1:0};
225
- transition: opacity 0.2s ease-in-out;
226
- }
227
-
228
- &:after {
229
- /* TODO: as for DS Table component we would need this to be handled by the DS theme */
230
- content: '';
231
- background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
232
- bottom: 0;
233
- opacity: ${({overflowDirection:t})=>t==="top-bottom"||t==="bottom"?1:0};
234
- transition: opacity 0.2s ease-in-out;
235
- }
236
- `,Jn=({children:t,overflow:o,...r})=>e.createElement(Rc,{overflowDirection:o,...r},t);Jn.defaultProps={overflow:""},Jn.propTypes={children:n().node.isRequired,overflow:n().oneOf(["top-bottom","bottom","top",""])};const Nr=(0,U.ZP)(yc.r)`
237
- display: block;
238
-
239
- > span {
240
- white-space: nowrap;
241
- overflow: hidden;
242
- text-overflow: ellipsis;
243
- display: block;
244
- }
245
- `,jr=U.ZP.button`
246
- svg path {
247
- fill: ${({theme:t,disabled:o})=>o?t.colors.neutral600:t.colors.neutral500};
248
- }
249
-
250
- &:hover svg path,
251
- &:focus svg path {
252
- fill: ${({theme:t,disabled:o})=>!o&&t.colors.neutral600};
253
- }
254
- `,_n=({canReorder:t,description:o,disabled:r,error:a,iconButtonAriaLabel:s,id:c,name:i,numberOfRelationsToDisplay:d,label:m,labelAction:u,labelLoadMore:p,labelDisconnectRelation:y,listAriaDescription:h,liveText:g,loadingMessage:b,onCancel:R,onDropItem:x,onGrabItem:C,noRelationsMessage:M,onRelationConnect:Z,onRelationLoadMore:W,onRelationDisconnect:T,onRelationReorder:O,onSearchNextPage:B,onSearch:w,placeholder:I,publicationStateTranslations:N,required:A,relations:F,searchResults:H,size:Q})=>{const[X,L]=(0,e.useState)(""),[S,v]=(0,e.useState)(""),V=(0,e.useRef)(),G=(0,e.useRef)(),{data:K}=H,k=F.data,j=k.length??0,te=(0,e.useMemo)(()=>j>d?Math.min(j,d)*(Ht+yt)+Ht/2:Math.min(j,d)*(Ht+yt),[j,d]),ue=!!p&&F.hasNextPage,fe=(0,e.useMemo)(()=>K.flat().filter(Boolean).map(ce=>({...ce,value:ce.id,label:ce.mainField})),[K]);(0,e.useEffect)(()=>{if(j<=d)return v("");const ce=je=>{const Ze=je.target.parentNode.scrollHeight,He=je.target.scrollHeight-je.target.scrollTop;return je.target.scrollTop===0?v("bottom"):v(He===Ze?"top":"top-bottom")},xe=G?.current;return!F.isLoading&&k.length>0&&xe&&G.current.addEventListener("scroll",ce),()=>{xe&&xe.removeEventListener("scroll",ce)}},[F,k,d,j]);const ye=ce=>{ce&&w()},D=(ce,xe)=>{O&&ce>=0&&ce<k.length&&O(xe,ce)},ee=(0,ne.zH)(k.length),pe=(0,e.useRef)(),Ie=()=>{pe.current="loadMore",W()};(0,e.useEffect)(()=>{pe.current==="onChange"&&L(""),pe.current==="onChange"&&k.length!==ee?(V.current.scrollToItem(k.length,"end"),pe.current=void 0):pe.current==="loadMore"&&k.length!==ee&&(V.current.scrollToItem(0,"start"),pe.current=void 0)},[ee,k]);const Ue=`${i}-item-instructions`;return e.createElement(P.k,{gap:3,justifyContent:"space-between",alignItems:"end",wrap:"wrap"},e.createElement(P.k,{direction:"column",alignItems:"stretch",basis:Q<=6?"100%":"70%",gap:2},e.createElement(Ec.hQ,{autocomplete:"list",error:a,name:i,hint:o,id:c,required:A,label:m,labelAction:u,disabled:r,placeholder:I,hasMoreItems:H.hasNextPage,loading:H.isLoading,onOpenChange:ye,noOptionsMessage:()=>M,loadingMessage:b,onLoadMore:()=>{B()},textValue:X,onChange:ce=>{ce&&(Z(fe.find(xe=>xe.id===ce)),pe.current="onChange")},onTextValueChange:ce=>{L(ce)},onInputChange:ce=>{w(ce.currentTarget.value)}},fe.map(ce=>e.createElement(Yn,{key:ce.id,...ce}))),ue&&e.createElement(Ar.A,{disabled:F.isLoading||F.isFetchingNextPage,onClick:Ie,loading:F.isLoading||F.isFetchingNextPage,startIcon:e.createElement(dn.Z,null)},p)),k.length>0&&e.createElement(Jn,{overflow:S},e.createElement(_e.T,{id:Ue},h),e.createElement(_e.T,{"aria-live":"assertive"},g),e.createElement(bc.t7,{height:te,ref:V,outerRef:G,itemCount:j,itemSize:Ht+yt,itemData:{name:i,ariaDescribedBy:Ue,canDrag:t,disabled:r,handleCancel:R,handleDropItem:x,handleGrabItem:C,iconButtonAriaLabel:s,labelDisconnectRelation:y,onRelationDisconnect:T,publicationStateTranslations:N,relations:k,updatePositionOfRelation:D},itemKey:ce=>`${k[ce].mainField}_${k[ce].id}`,innerElementType:"ol"},eo)))},Mc=n().shape({data:n().arrayOf(n().shape({href:n().string,id:n().number.isRequired,publicationState:n().oneOfType([n().string,n().bool]),mainField:n().oneOfType([n().string,n().number])})),hasNextPage:n().bool,isFetchingNextPage:n().bool.isRequired,isLoading:n().bool.isRequired,isSuccess:n().bool.isRequired}),Tc=n().shape({data:n().arrayOf(n().shape({id:n().number.isRequired,href:n().string,mainField:n().oneOfType([n().string,n().number]),publicationState:n().oneOfType([n().string,n().bool])})),hasNextPage:n().bool,isLoading:n().bool.isRequired,isSuccess:n().bool.isRequired});_n.defaultProps={canReorder:!1,description:void 0,disabled:!1,error:void 0,labelAction:null,labelLoadMore:null,liveText:void 0,onCancel:void 0,onDropItem:void 0,onGrabItem:void 0,required:!1,relations:{data:[]},searchResults:{data:[]}},_n.propTypes={error:n().string,canReorder:n().bool,description:n().string,disabled:n().bool,iconButtonAriaLabel:n().string.isRequired,id:n().string.isRequired,label:n().string.isRequired,labelAction:n().element,labelLoadMore:n().string,labelDisconnectRelation:n().string.isRequired,listAriaDescription:n().string.isRequired,liveText:n().string,loadingMessage:n().string.isRequired,name:n().string.isRequired,noRelationsMessage:n().string.isRequired,numberOfRelationsToDisplay:n().number.isRequired,onCancel:n().func,onDropItem:n().func,onGrabItem:n().func,onRelationConnect:n().func.isRequired,onRelationDisconnect:n().func.isRequired,onRelationLoadMore:n().func.isRequired,onRelationReorder:n().func.isRequired,onSearch:n().func.isRequired,onSearchNextPage:n().func.isRequired,placeholder:n().string.isRequired,publicationStateTranslations:n().shape({draft:n().string.isRequired,published:n().string.isRequired}).isRequired,required:n().bool,searchResults:Tc,size:n().number.isRequired,relations:Mc};const eo=({data:t,index:o,style:r})=>{const{ariaDescribedBy:a,canDrag:s,disabled:c,handleCancel:i,handleDropItem:d,handleGrabItem:m,iconButtonAriaLabel:u,name:p,labelDisconnectRelation:y,onRelationDisconnect:h,publicationStateTranslations:g,relations:b,updatePositionOfRelation:R}=t,{publicationState:x,href:C,mainField:M,id:Z}=b[o],W=x==="draft"?"secondary":"success";return e.createElement(Xn,{ariaDescribedBy:a,canDrag:s,disabled:c,displayValue:String(M??Z),iconButtonAriaLabel:u,id:Z,index:o,name:p,endAction:e.createElement(jr,{"data-testid":`remove-relation-${Z}`,disabled:c,type:"button",onClick:()=>h(b[o]),"aria-label":y},e.createElement(ft.J,{width:"12px",as:qt.Z})),onCancel:i,onDropItem:d,onGrabItem:m,status:x||void 0,style:{...r,bottom:r.bottom??0+yt,height:r.height??0-yt},updatePositionOfRelation:R},e.createElement(q.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(Ft.u,{description:M??`${Z}`},C?e.createElement(Nr,{to:C},M??Z):e.createElement(z.Z,{textColor:c?"neutral600":"primary600",ellipsis:!0},M??Z))),x&&e.createElement(Kn.q,{variant:W,showBullet:!1,size:"S"},e.createElement(z.Z,{fontWeight:"bold",textColor:`${W}700`},g[x])))};eo.defaultProps={data:{}},eo.propTypes={data:n().shape({ariaDescribedBy:n().string.isRequired,canDrag:n().bool.isRequired,disabled:n().bool.isRequired,handleCancel:n().func,handleDropItem:n().func,handleGrabItem:n().func,iconButtonAriaLabel:n().string.isRequired,labelDisconnectRelation:n().string.isRequired,name:n().string.isRequired,onRelationDisconnect:n().func.isRequired,publicationStateTranslations:n().shape({draft:n().string.isRequired,published:n().string.isRequired}).isRequired,relations:n().arrayOf(n().shape({href:n().string,id:n().number.isRequired,publicationState:n().oneOfType([n().string,n().bool]),mainField:n().oneOfType([n().string,n().number])})),updatePositionOfRelation:n().func.isRequired}),index:n().number.isRequired,style:n().object.isRequired};var Dc=_n;const to=({error:t,entityId:o,componentId:r,isComponentRelation:a,editable:s,description:c,intlLabel:i,isCreatingEntry:d,isCloningEntry:m,isFieldAllowed:u,isFieldReadable:p,labelAction:y,mainField:h,name:g,queryInfos:{endpoints:b,defaultParams:R,shouldDisplayRelationLink:x},placeholder:C,required:M,relationType:Z,size:W,targetModel:T})=>{const[O,B]=(0,e.useState)(""),{formatMessage:w}=(0,Y.Z)(),{slug:I,initialData:N,modifiedData:A,relationConnect:F,relationDisconnect:H,relationLoad:Q,relationReorder:X}=(0,f.Wq)(),L=g.split("."),S=Sr(N,A)(g),v=$()(A,g,[]),V=Math.ceil($()(N,g,[]).length/Gn),{relations:G,search:K,searchFor:k}=hc([I,S.join("."),A.id,R],{relation:{enabled:!!b.relation,endpoint:b.relation,pageGoal:V,pageParams:{...R,pageSize:Gn},onLoad(he){Q({target:{initialDataPath:["initialData",...S],modifiedDataPath:["modifiedData",...L],value:he}})},normalizeArguments:{mainFieldName:h.name,shouldAddLink:x,targetModel:T}},search:{endpoint:b.search,pageParams:{...R,entityId:d||m?void 0:a?r:o,pageSize:dc}}}),j=(0,e.useMemo)(()=>Z.toLowerCase().includes("morph"),[Z]),te=["oneWay","oneToOne","manyToOne","oneToManyMorph","oneToOneMorph"].includes(Z),ue=(0,e.useMemo)(()=>j?!0:d?!s:!u&&p||!s,[j,d,s,u,p]),fe=he=>{const Me=Qn(he,{mainFieldName:h.name,shouldAddLink:x,targetModel:T});F({name:g,value:Me,toOneRelation:te})},ye=he=>{H({name:g,id:he.id})},D=()=>{G.fetchNextPage()},ee=(he="")=>{const[Me,et]=cc(v,$()(N,g));k(he,{idsToInclude:et,idsToOmit:Me})},pe=()=>{K.fetchNextPage()},Ie=he=>`${he+1} of ${v.length}`,Ue=(he,Me)=>{const et=v[he];B(w({id:(0,E.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:et.mainField??et.id,position:Ie(Me)})),X({name:g,newIndex:Me,oldIndex:he})},ce=he=>{const Me=v[he];B(w({id:(0,E.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:Me.mainField??Me.id,position:Ie(he)}))},xe=he=>{const Me=v[he];B(w({id:(0,E.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:Me.mainField??Me.id,position:Ie(he)}))},je=he=>{const Me=v[he];B(w({id:(0,E.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:Me.mainField??Me.id}))};if(!u&&d||!d&&!u&&!p)return e.createElement(f.X0,{name:g,intlLabel:i,labelAction:y});const Ze=v.length,He=($()(N,S)??[]).length,Rt=G.data?.pages[0]?.pagination?.total??0,it=!G.data&&Ze===He?Ze:Ze-He+Rt;return e.createElement(Dc,{error:t,canReorder:!te,description:c,disabled:ue,iconButtonAriaLabel:w({id:(0,E.OB)("components.RelationInput.icon-button-aria-label"),defaultMessage:"Drag"}),id:g,label:`${w({id:i.id,defaultMessage:i.defaultMessage})} ${it>0?`(${it})`:""}`,labelAction:y,labelLoadMore:!d||m?w({id:(0,E.OB)("relation.loadMore"),defaultMessage:"Load More"}):null,labelDisconnectRelation:w({id:(0,E.OB)("relation.disconnect"),defaultMessage:"Remove"}),listAriaDescription:w({id:(0,E.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"}),listHeight:320,liveText:O,loadingMessage:w({id:(0,E.OB)("relation.isLoading"),defaultMessage:"Relations are loading"}),name:g,noRelationsMessage:w({id:(0,E.OB)("relation.notAvailable"),defaultMessage:"No relations available"}),numberOfRelationsToDisplay:Gn,onDropItem:xe,onGrabItem:ce,onCancel:je,onRelationConnect:fe,onRelationDisconnect:ye,onRelationLoadMore:D,onRelationReorder:Ue,onSearch:he=>ee(he),onSearchNextPage:()=>pe(),placeholder:w(C||{id:(0,E.OB)("relation.add"),defaultMessage:"Add relation"}),publicationStateTranslations:{[st.DRAFT]:w({id:(0,E.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[st.PUBLISHED]:w({id:(0,E.OB)("relation.publicationState.published"),defaultMessage:"Published"})},relations:sc()({...G,data:v},"data","hasNextPage","isFetchingNextPage","isLoading","isSuccess"),required:M,searchResults:pc(K,{mainFieldName:h.name}),size:W})};to.defaultProps={componentId:void 0,entityId:void 0,editable:!0,error:void 0,description:"",labelAction:null,isComponentRelation:!1,isFieldAllowed:!0,placeholder:null,required:!1},to.propTypes={componentId:n().number,entityId:n().number,editable:n().bool,error:n().string,description:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,isCloningEntry:n().bool.isRequired,isCreatingEntry:n().bool.isRequired,isComponentRelation:n().bool,isFieldAllowed:n().bool,isFieldReadable:n().bool.isRequired,mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired}).isRequired,name:n().string.isRequired,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,relationType:n().string.isRequired,size:n().number.isRequired,targetModel:n().string.isRequired,queryInfos:n().shape({defaultParams:n().shape({locale:n().string}),endpoints:n().shape({relation:n().string,search:n().string.isRequired}).isRequired,shouldDisplayRelationLink:n().bool.isRequired}).isRequired};const Oc=(0,e.memo)(to);var Pc=lc(Oc,fc);const no=({id:t,error:o,name:r,hint:a})=>a.length===0||o?null:e.createElement(z.Z,{as:"p",variant:"pi",id:`${t||r}-hint`,textColor:"neutral600"},a);no.defaultProps={id:void 0,error:void 0,hint:""},no.propTypes={hint:n().oneOfType([n().string,n().array]),error:n().string,id:n().string,name:n().string.isRequired};var Ic=no,xc=l(87702),oo=l.n(xc),ro=l(59845),Zc=l(88591),kc=l.n(Zc),Lc=l(20871),Sc=l.n(Lc),Ac=l(48375),Wr=l.n(Ac),Fc=l(31089),$c=l.n(Fc),wc=l(16043),Bc=l.n(wc),Nc=l(5109),jc=l.n(Nc),Wc=l(47955),zc=l.n(Wc),Uc=l(95706),Vc=l.n(Uc),qc=l(6658),Hc=l.n(qc),Gc=l(36407),Qc=l.n(Gc);(async()=>{await l.e(7347).then(l.bind(l,74194))})();const Et=new(kc())({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,highlight(t,o){if(o&&o!=="auto"&&(0,ro.getLanguage)(o))return'<pre class="hljs language-'+Et.utils.escapeHtml(o.toLowerCase())+'"><code>'+(0,ro.highlight)(o,t,!0).value+"</code></pre>";if(o==="auto"){const r=(0,ro.highlightAuto)(t);return'<pre class="hljs language-'+Et.utils.escapeHtml(r.language)+'"><code>'+r.value+"</code></pre>"}return'<pre class="hljs"><code>'+Et.utils.escapeHtml(t)+"</code></pre>"}}).use(Sc()).use(Wr(),"warning").use(Wr(),"tip").use($c()).use(Bc()).use(jc()).use(zc()).use(Vc()).use(Hc()).use(Qc());Et.renderer.rules.footnote_ref=(t,o,r,a,s)=>'<sup class="footnote-ref"><span>'+s.rules.footnote_caption(t,o,r,a,s)+"</span></sup>",Et.renderer.rules.footnote_anchor=()=>' <span class="footnote-backref">\u21A9\uFE0E</span>';var Kc=Et,Yc=l(13993),zr=l.n(Yc);const Xc={...zr().defaults,allowedTags:!1,allowedAttributes:{"*":["href","align","alt","center","width","height","type","controls","target"],img:["src","alt"],source:["src","type"]}};var Jc=t=>zr()(t,Xc),_c=U.ZP.div`
255
- position: absolute;
256
- top: 0;
257
- width: 100%;
258
- height: 100%;
259
- overflow: auto;
260
- padding: ${({theme:t})=>`${t.spaces[3]} ${t.spaces[4]}`};
261
- font-size: ${14/16}rem;
262
- background-color: ${({theme:t})=>t.colors.neutral0};
263
- color: ${({theme:t})=>t.colors.neutral800};
264
- line-height: ${({theme:t})=>t.lineHeights[6]};
265
-
266
- h1,
267
- h2,
268
- h3,
269
- h4,
270
- h5,
271
- h6 {
272
- margin-block-start: ${({theme:t})=>t.spaces[2]};
273
- margin-block-end: ${({theme:t})=>t.spaces[2]};
274
- }
275
-
276
- p {
277
- margin-bottom: ${({theme:t})=>t.spaces[2]};
278
- }
279
-
280
- h1 {
281
- font-size: ${36/16}rem;
282
- font-weight: 600;
283
- }
284
-
285
- h2 {
286
- font-size: ${30/16}rem;
287
- font-weight: 500;
288
- }
289
-
290
- h3 {
291
- font-size: ${24/16}rem;
292
- font-weight: 500;
293
- }
294
-
295
- h4 {
296
- font-size: ${20/16}rem;
297
- font-weight: 500;
298
- }
299
-
300
- strong {
301
- font-weight: 800;
302
- }
303
-
304
- em {
305
- font-style: italic;
306
- }
307
-
308
- blockquote {
309
- margin-top: ${({theme:t})=>t.spaces[8]};
310
- margin-bottom: ${({theme:t})=>t.spaces[7]};
311
- font-size: ${14/16}rem;
312
- font-weight: 400;
313
- border-left: 4px solid ${({theme:t})=>t.colors.neutral150};
314
- font-style: italic;
315
- padding: ${({theme:t})=>t.spaces[2]} ${({theme:t})=>t.spaces[5]};
316
- }
317
-
318
- img {
319
- max-width: 100%;
320
- }
321
-
322
- table {
323
- thead {
324
- background: ${({theme:t})=>t.colors.neutral150};
325
-
326
- th {
327
- padding: ${({theme:t})=>t.spaces[4]};
328
- }
329
- }
330
- tr {
331
- border: 1px solid ${({theme:t})=>t.colors.neutral200};
332
- }
333
- th,
334
- td {
335
- padding: ${({theme:t})=>t.spaces[4]};
336
- border: 1px solid ${({theme:t})=>t.colors.neutral200};
337
- border-bottom: 0;
338
- border-top: 0;
339
- }
340
- }
341
-
342
- pre,
343
- code {
344
- font-size: ${14/16}rem;
345
- border-radius: 4px;
346
- /*
347
- Hard coded since the color is the same between themes,
348
- theme.colors.neutral800 changes between themes.
349
-
350
- Matches the color of the JSON Input component.
351
- */
352
- background-color: #32324d;
353
- max-width: 100%;
354
- overflow: auto;
355
- padding: ${({theme:t})=>t.spaces[2]};
356
- }
357
-
358
- /* Inline code */
359
- p,
360
- pre,
361
- td {
362
- > code {
363
- color: #839496;
364
- }
365
- }
366
-
367
- ol {
368
- list-style-type: decimal;
369
- margin-block-start: ${({theme:t})=>t.spaces[4]};
370
- margin-block-end: ${({theme:t})=>t.spaces[4]};
371
- margin-inline-start: 0px;
372
- margin-inline-end: 0px;
373
- padding-inline-start: ${({theme:t})=>t.spaces[4]};
374
-
375
- ol,
376
- ul {
377
- margin-block-start: 0px;
378
- margin-block-end: 0px;
379
- }
380
- }
381
-
382
- ul {
383
- list-style-type: disc;
384
- margin-block-start: ${({theme:t})=>t.spaces[4]};
385
- margin-block-end: ${({theme:t})=>t.spaces[4]};
386
- margin-inline-start: 0px;
387
- margin-inline-end: 0px;
388
- padding-inline-start: ${({theme:t})=>t.spaces[4]};
389
-
390
- ul,
391
- ol {
392
- margin-block-start: 0px;
393
- margin-block-end: 0px;
394
- }
395
- }
396
- `;const ao=({data:t})=>{const o=(0,e.useMemo)(()=>Jc(Kc.render(t.replaceAll("\\n",`
397
- `)||"")),[t]);return e.createElement(_c,null,e.createElement("div",{dangerouslySetInnerHTML:{__html:o}}))};ao.defaultProps={data:""},ao.propTypes={data:n().string};var Ur=(0,e.memo)(ao);const ed=U.ZP.div`
398
- cursor: ${({disabled:t})=>t?"not-allowed !important":"auto"};
399
- height: 100%;
400
- /* BASICS */
401
- .CodeMirror-placeholder {
402
- color: ${({theme:t})=>t.colors.neutral600} !important;
403
- }
404
-
405
- .CodeMirror {
406
- /* Set height, width, borders, and global font properties here */
407
- font-size: ${14/16}rem;
408
- height: ${({isExpandMode:t})=>t?"100%":"290px"};
409
- color: ${({theme:t})=>t.colors.neutral800};
410
- direction: ltr;
411
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
412
- 'Open Sans', 'Helvetica Neue', sans-serif;
413
- }
414
-
415
- /* PADDING */
416
-
417
- .CodeMirror-lines {
418
- padding: ${({theme:t})=>`${t.spaces[3]} ${t.spaces[4]}`};
419
- /* Vertical padding around content */
420
- }
421
-
422
- .CodeMirror-scrollbar-filler,
423
- .CodeMirror-gutter-filler {
424
- /* The little square between H and V scrollbars */
425
- background-color: ${({theme:t})=>`${t.colors.neutral0}`};
426
- }
427
-
428
- /* GUTTER */
429
-
430
- .CodeMirror-gutters {
431
- border-right: 1px solid #ddd;
432
- background-color: #f7f7f7;
433
- white-space: nowrap;
434
- }
435
- .CodeMirror-linenumbers {
436
- }
437
- .CodeMirror-linenumber {
438
- padding: 0 3px 0 5px;
439
- min-width: 20px;
440
- text-align: right;
441
- color: #999;
442
- white-space: nowrap;
443
- }
444
-
445
- .CodeMirror-guttermarker {
446
- color: black;
447
- }
448
- .CodeMirror-guttermarker-subtle {
449
- color: #999;
450
- }
451
-
452
- /* CURSOR */
453
-
454
- .CodeMirror-cursor {
455
- border-left: 1px solid black;
456
- border-right: none;
457
- width: 0;
458
- }
459
- /* Shown when moving in bi-directional text */
460
- .CodeMirror div.CodeMirror-secondarycursor {
461
- border-left: 1px solid silver;
462
- }
463
- .cm-fat-cursor .CodeMirror-cursor {
464
- width: auto;
465
- border: 0 !important;
466
- background: #7e7;
467
- }
468
- .cm-fat-cursor div.CodeMirror-cursors {
469
- /* z-index: 1; */
470
- }
471
-
472
- .cm-fat-cursor-mark {
473
- background-color: rgba(20, 255, 20, 0.5);
474
- -webkit-animation: blink 1.06s steps(1) infinite;
475
- -moz-animation: blink 1.06s steps(1) infinite;
476
- animation: blink 1.06s steps(1) infinite;
477
- }
478
- .cm-animate-fat-cursor {
479
- width: auto;
480
- border: 0;
481
- -webkit-animation: blink 1.06s steps(1) infinite;
482
- -moz-animation: blink 1.06s steps(1) infinite;
483
- animation: blink 1.06s steps(1) infinite;
484
- background-color: #7e7;
485
- }
486
-
487
- /* Can style cursor different in overwrite (non-insert) mode */
488
- .CodeMirror-overwrite .CodeMirror-cursor {
489
- }
490
-
491
- .cm-tab {
492
- display: inline-block;
493
- text-decoration: inherit;
494
- }
495
-
496
- .CodeMirror-rulers {
497
- position: absolute;
498
- left: 0;
499
- right: 0;
500
- top: -50px;
501
- bottom: 0;
502
- overflow: hidden;
503
- }
504
- .CodeMirror-ruler {
505
- border-left: 1px solid #ccc;
506
- top: 0;
507
- bottom: 0;
508
- position: absolute;
509
- }
510
-
511
- /* DEFAULT THEME */
512
-
513
- .cm-header,
514
- .cm-strong {
515
- font-weight: bold;
516
- }
517
- .cm-em {
518
- font-style: italic;
519
- }
520
- .cm-link {
521
- text-decoration: underline;
522
- }
523
- .cm-strikethrough {
524
- text-decoration: line-through;
525
- }
526
-
527
- .CodeMirror-composing {
528
- border-bottom: 2px solid;
529
- }
530
-
531
- /* Default styles for common addons */
532
-
533
- div.CodeMirror span.CodeMirror-matchingbracket {
534
- color: #0b0;
535
- }
536
- div.CodeMirror span.CodeMirror-nonmatchingbracket {
537
- color: #a22;
538
- }
539
- .CodeMirror-matchingtag {
540
- background: rgba(255, 150, 0, 0.3);
541
- }
542
- .CodeMirror-activeline-background {
543
- background: #e8f2ff;
544
- }
545
-
546
- /* STOP */
547
-
548
- /* The rest of this file contains styles related to the mechanics of
549
- the editor. You probably shouldn't touch them. */
550
-
551
- .CodeMirror {
552
- position: relative;
553
- overflow: hidden;
554
- background: ${({theme:t})=>`${t.colors.neutral0}`};
555
- }
556
-
557
- .CodeMirror-scroll {
558
- overflow: scroll !important; /* Things will break if this is overridden */
559
- /* 50px is the magic margin used to hide the element's real scrollbars */
560
- /* See overflow: hidden in .CodeMirror */
561
- margin-bottom: -50px;
562
- margin-right: -50px;
563
- padding-bottom: 50px;
564
- height: 100%;
565
- outline: none; /* Prevent dragging from highlighting the element */
566
- position: relative;
567
- }
568
- .CodeMirror-sizer {
569
- position: relative;
570
- border-right: 50px solid transparent;
571
- }
572
-
573
- /* The fake, visible scrollbars. Used to force redraw during scrolling
574
- before actual scrolling happens, thus preventing shaking and
575
- flickering artifacts. */
576
- .CodeMirror-vscrollbar,
577
- .CodeMirror-hscrollbar,
578
- .CodeMirror-scrollbar-filler,
579
- .CodeMirror-gutter-filler {
580
- position: absolute;
581
- z-index: 1;
582
- display: none;
583
- outline: none;
584
- }
585
-
586
- .CodeMirror-vscrollbar {
587
- right: 0;
588
- top: 0;
589
- overflow-x: hidden;
590
- overflow-y: scroll;
591
- }
592
- .CodeMirror-hscrollbar {
593
- bottom: 0;
594
- left: 0;
595
- overflow-y: hidden;
596
- overflow-x: scroll;
597
- }
598
- .CodeMirror-scrollbar-filler {
599
- right: 0;
600
- bottom: 0;
601
- }
602
-
603
- .CodeMirror-lines {
604
- cursor: text;
605
- min-height: 1px; /* prevents collapsing before first draw */
606
- }
607
- /* Reset some styles that the rest of the page might have set */
608
- .CodeMirror pre.CodeMirror-line,
609
- .CodeMirror pre.CodeMirror-line-like {
610
- -moz-border-radius: 0;
611
- -webkit-border-radius: 0;
612
- border-radius: 0;
613
- border-width: 0;
614
- background: transparent;
615
- font-family: inherit;
616
- font-size: inherit;
617
- margin: 0;
618
- white-space: pre;
619
- word-wrap: normal;
620
- line-height: 1.5;
621
- color: inherit;
622
- /* z-index: 2; */
623
- position: relative;
624
- overflow: visible;
625
- -webkit-tap-highlight-color: transparent;
626
- -webkit-font-variant-ligatures: contextual;
627
- font-variant-ligatures: contextual;
628
- }
629
-
630
- .CodeMirror pre.CodeMirror-line-like {
631
- z-index: 2;
632
- }
633
-
634
- .CodeMirror-wrap pre.CodeMirror-line,
635
- .CodeMirror-wrap pre.CodeMirror-line-like {
636
- word-wrap: break-word;
637
- white-space: pre-wrap;
638
- word-break: normal;
639
- }
640
-
641
- .CodeMirror-linebackground {
642
- position: absolute;
643
- left: 0;
644
- right: 0;
645
- top: 0;
646
- bottom: 0;
647
- z-index: 0;
648
- }
649
-
650
- .CodeMirror-linewidget {
651
- position: relative;
652
- /* z-index: 2; */
653
- padding: 0.1px; /* Force widget margins to stay inside of the container */
654
- }
655
-
656
- .CodeMirror-widget {
657
- }
658
-
659
- .CodeMirror-rtl pre {
660
- direction: rtl;
661
- }
662
-
663
- .CodeMirror-code {
664
- outline: none;
665
- }
666
-
667
- /* Force content-box sizing for the elements where we expect it */
668
- .CodeMirror-scroll,
669
- .CodeMirror-sizer,
670
- .CodeMirror-gutter,
671
- .CodeMirror-gutters,
672
- .CodeMirror-linenumber {
673
- -moz-box-sizing: content-box;
674
- box-sizing: content-box;
675
- }
676
-
677
- .CodeMirror-measure {
678
- position: absolute;
679
- width: 100%;
680
- height: 0;
681
- overflow: hidden;
682
- visibility: hidden;
683
- }
684
-
685
- .CodeMirror-cursor {
686
- position: absolute;
687
- pointer-events: none;
688
- border-color: ${({theme:t})=>`${t.colors.neutral800}`};
689
- }
690
- .CodeMirror-measure pre {
691
- position: static;
692
- }
693
-
694
- div.CodeMirror-cursors {
695
- visibility: hidden;
696
- position: relative;
697
- + div {
698
- z-index: 0 !important;
699
- }
700
- }
701
-
702
- div.CodeMirror-dragcursors {
703
- visibility: visible;
704
- }
705
-
706
- .CodeMirror-focused div.CodeMirror-cursors {
707
- visibility: visible;
708
- }
709
-
710
- .CodeMirror-selected {
711
- background: ${({theme:t})=>t.colors.neutral200};
712
- /* z-index: -10; */
713
- }
714
- .CodeMirror-crosshair {
715
- cursor: crosshair;
716
- }
717
-
718
- /* Used to force a border model for a node */
719
- .cm-force-border {
720
- padding-right: 0.1px;
721
- }
722
-
723
- /* See issue #2901 */
724
- .cm-tab-wrap-hack:after {
725
- content: '';
726
- }
727
-
728
- /* Help users use markselection to safely style text background */
729
- span.CodeMirror-selectedtext {
730
- background: none;
731
- }
732
-
733
- span {
734
- color: ${({theme:t})=>t.colors.neutral800} !important;
735
- }
736
- `;var Gt=/^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,td=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,nd=/[*+-]\s/;function od(t){if(t.getOption("disableInput"))return oo().Pass;for(var o=t.listSelections(),r=[],a=0;a<o.length;a++){var s=o[a].head,c=t.getStateAfter(s.line),i=c.list!==!1,d=c.quote!==0,m=t.getLine(s.line),u=Gt.exec(m),p=/^\s*$/.test(m.slice(0,s.ch));if(!o[a].empty()||!i&&!d||!u||p){t.execCommand("newlineAndIndent");return}if(td.test(m)){var y=d&&/>\s*$/.test(m),h=!/>\s*$/.test(m);(y||h)&&t.replaceRange("",{line:s.line,ch:0},{line:s.line,ch:s.ch+1}),r[a]=`
737
- `}else{var g=u[1],b=u[5],R=!(nd.test(u[2])||u[2].indexOf(">")>=0),x=R?parseInt(u[3],10)+1+u[4]:u[2].replace("x"," ");r[a]=`
738
- `+g+x+b,R&&rd(t,s)}}t.replaceSelections(r)}function rd(t,o){var r=o.line,a=0,s=0,c=Gt.exec(t.getLine(r)),i=c[1];do{a+=1;var d=r+a,m=t.getLine(d),u=Gt.exec(m);if(u){var p=u[1],y=parseInt(c[3],10)+a-s,h=parseInt(u[3],10),g=h;if(i===p&&!isNaN(h))y===h&&(g=h+1),y>h&&(g=y+1),t.replaceRange(m.replace(Gt,p+g+u[4]+u[5]),{line:d,ch:0},{line:d,ch:m.length});else{if(i.length>p.length||i.length<p.length&&a===1)return;s+=1}}}while(u)}var ad=od;const Le=(0,U.ZP)(Re.h)`
739
- padding: ${({theme:t})=>t.spaces[2]};
740
- /* Trick to prevent the outline from overflowing because of the general outline-offset */
741
- outline-offset: -2px !important;
742
-
743
- svg {
744
- width: ${18/16}rem;
745
- height: ${18/16}rem;
746
- }
747
- `,sd=(0,U.ZP)(Le)`
748
- svg {
749
- width: ${8/16}rem;
750
- height: ${8/16}rem;
751
- }
752
- `,Vr=(0,U.ZP)(Re.o)`
753
- margin-left: ${({theme:t})=>t.spaces[4]};
754
- `,qr=(0,U.ZP)(Re.h)`
755
- margin: ${({theme:t})=>`0 ${t.spaces[2]}`};
756
- padding: ${({theme:t})=>t.spaces[2]};
757
-
758
- svg {
759
- width: ${18/16}rem;
760
- height: ${18/16}rem;
761
- }
762
- `,id=(0,U.ZP)(Re.o)`
763
- margin-right: ${({theme:t})=>`${t.spaces[2]}`};
764
- `,ld=U.ZP.div`
765
- position: relative;
766
- height: calc(100% - 48px);
767
- `,cd=(0,U.ZP)(An.Y)`
768
- background-color: transparent;
769
- border: none;
770
- align-items: center;
771
-
772
- svg {
773
- margin-left: ${({theme:t})=>`${t.spaces[2]}`};
774
- path {
775
- fill: ${({theme:t})=>t.colors.neutral700};
776
- width: ${12/16}rem;
777
- height: ${12/16}rem;
778
- }
779
- }
780
- `;var dg=l(27217);const so=({disabled:t,editorRef:o,error:r,isPreviewMode:a,isExpandMode:s,name:c,onChange:i,placeholder:d,textareaRef:m,value:u})=>{const p=(0,e.useRef)(i);return(0,e.useEffect)(()=>{o.current=oo().fromTextArea(m.current,{lineWrapping:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList",Tab:!1,"Shift-Tab":!1},readOnly:!1,smartIndent:!1,placeholder:d,spellcheck:!0,inputStyle:"contenteditable"}),oo().commands.newlineAndIndentContinueMarkdownList=ad,o.current.on("change",y=>{p.current({target:{name:c,value:y.getValue(),type:"wysiwyg"}})})},[o,m,c,d]),(0,e.useEffect)(()=>{u&&!o.current.hasFocus()&&o.current.setValue(u)},[o,u]),(0,e.useEffect)(()=>{a||t?o.current.setOption("readOnly","nocursor"):o.current.setOption("readOnly",!1)},[t,a,o]),(0,e.useEffect)(()=>{r?o.current.setOption("screenReaderLabel",r):o.current.setOption("screenReaderLabel","Editor")},[o,r]),e.createElement(ld,null,e.createElement(ed,{isExpandMode:s,disabled:t||a},e.createElement("textarea",{ref:m})),a&&e.createElement(Ur,{data:u}))};so.defaultProps={disabled:!1,error:void 0,isPreviewMode:!1,isExpandMode:!1,placeholder:"",value:""},so.propTypes={disabled:n().bool,editorRef:n().shape({current:n().any}).isRequired,error:n().string,isPreviewMode:n().bool,isExpandMode:n().bool,name:n().string.isRequired,onChange:n().func.isRequired,placeholder:n().string,textareaRef:n().shape({current:n().any}).isRequired,value:n().string};var dd=so,ud=l(71933),md=l(67563);const pd=(t,o)=>`${t}${Math.floor(o*255).toString(16).padStart(2,0)}`,gd=(0,U.ZP)(P.k)`
781
- background: ${({theme:t})=>pd(t.colors.neutral800,.2)};
782
- `,fd=(0,U.ZP)(q.x)`
783
- border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
784
- `,hd=(0,U.ZP)(An.Y)`
785
- background-color: transparent;
786
- border: none;
787
- align-items: center;
788
-
789
- svg {
790
- margin-left: ${({theme:t})=>`${t.spaces[2]}`};
791
-
792
- path {
793
- fill: ${({theme:t})=>t.colors.neutral700};
794
- width: ${12/16}rem;
795
- height: ${12/16}rem;
796
- }
797
- }
798
- `,io=({children:t,isExpandMode:o,error:r,previewContent:a,onCollapse:s})=>{const{formatMessage:c}=(0,Y.Z)();return(0,f.F5)(o),o?e.createElement(ud.h,{role:"dialog","aria-modal":!1},e.createElement(md.i,{onEscape:s},e.createElement(gd,{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:4,justifyContent:"center",onClick:s},e.createElement(q.x,{background:"neutral0",hasRadius:!0,shadow:"popupShadow",overflow:"hidden",width:"70%",height:"70%",onClick:i=>i.stopPropagation()},e.createElement(P.k,{height:"100%",alignItems:"flex-start"},e.createElement(fd,{flex:"1",height:"100%"},t),e.createElement(P.k,{alignItems:"start",direction:"column",flex:1,height:"100%",width:"100%"},e.createElement(P.k,{height:(0,f.Q1)(48),background:"neutral100",justifyContent:"flex-end",shrink:0,width:"100%"},e.createElement(hd,{onClick:s},e.createElement(z.Z,null,c({id:"components.Wysiwyg.collapse",defaultMessage:"Collapse"})),e.createElement(nr.Z,null))),e.createElement(q.x,{position:"relative",height:"100%",width:"100%"},e.createElement(Ur,{data:a})))))))):e.createElement(q.x,{borderColor:r?"danger600":"neutral200",borderStyle:"solid",borderWidth:"1px",hasRadius:!0},t)};io.defaultProps={error:void 0,previewContent:""},io.propTypes={children:n().node.isRequired,error:n().string,isExpandMode:n().bool.isRequired,previewContent:n().string,onCollapse:n().func.isRequired};const Hr=(t,o)=>{let r;switch(t){case"Strikethrough":r=`~~${o}~~`;break;case"Bold":r=`**${o}**`;break;case"Italic":r=`_${o}_`;break;case"Underline":r=`<u>${o}</u>`;break;case"Code":r=`\`\`\`
799
- ${o}
800
- \`\`\``;break;case"Link":r=`[${o}](link)`;break;case"Quote":r=`>${o}`;break;default:r=o}return r},Gr=t=>{let o,r={start:t.length,end:0};switch(t){case"Strikethrough":o=`~~${t}~~`,r.end=2;break;case"Bold":o=`**${t}**`,r.end=2;break;case"Italic":o=`_${t}_`,r.end=1;break;case"alt":o=`[${t}]()`,r.end=3;break;case"Underline":o=`<u>${t}</u>`,r.end=4;break;case"Code":o=`\`\`\`
801
- ${t}
802
- \`\`\``,r.end=3;break;case"Link":o=`[${t}](link)`,r.end=7;break;case"Quote":o=`>${t}`,r.end=0;break;default:o=""}return{editedText:o,selection:r}},Qr=t=>{let o;switch(t){case"BulletList":o="- ";break;case"NumberList":o="1. ";break;case"h1":o="# ";break;case"h2":o="## ";break;case"h3":o="### ";break;case"h4":o="#### ";break;case"h5":o="##### ";break;case"h6":o="###### ";break;default:return""}return o},Kr=(t,o)=>{const r=t.current.getSelection();let a;if(r){const s=Hr(o,r);t.current.replaceSelection(s),t.current.focus()}else{a=Gr(o),t.current.replaceSelection(a.editedText),t.current.focus();const{line:s,ch:c}=t.current.getCursor(),i=c-a.selection.end,d=c-a.selection.end-a.selection.start;t.current.setSelection({line:s,ch:d},{line:s,ch:i})}},yd=(t,o)=>{const r=t.current.getDoc(),a=o==="BulletList"?"- ":"1. ";if(r.somethingSelected()){const s=r.listSelections();let c=null;t.current.operation(function(){s.forEach(function(i){const d=[i.head.line,i.anchor.line].sort();c==null&&(c=r.getLine(d[0]).startsWith(a));for(let m=d[0];m<=d[1];m++)if(c)r.getLine(m).startsWith(a)&&r.replaceRange("",{line:m,ch:0},{line:m,ch:a.length});else{const u=o==="BulletList"?"- ":`${m+1}. `;r.replaceRange(u,{line:m,ch:0})}})})}else{let{line:s}=r.getCursor();const c=Qr(o),i=t.current.getLine(s),d=c+i;t.current.setSelection({line:s,ch:0},{line:s,ch:i.length}),t.current.replaceSelection(d)}t.current.focus()},Ed=(t,o)=>{let{line:r}=t.current.getCursor();const a=Qr(o),s=t.current.getLine(r),c=s.replace(/#{1,6}\s/g,"").trim(),i=a+c;t.current.setSelection({line:r,ch:0},{line:r,ch:s.length}),t.current.replaceSelection(i),setTimeout(()=>{const d=t.current.getLine(r).length;t.current.focus(),t.current.setCursor({line:r,ch:d})},0)},bd=(t,o)=>{let{line:r,ch:a}=t.current.getCursor();o.forEach((s,c)=>{let i=t.current.getLine(r).length;t.current.setCursor({line:r,ch:i}),(c>0||c===0&&a!==0)&&(i=t.current.getLine(r).length,t.current.setCursor({line:r,ch:i}),r++,t.current.replaceSelection(`
803
- `)),s.mime.includes("image")?t.current.replaceSelection(`![${s.alt}](${s.url})`):t.current.replaceSelection(`[${s.alt}](${s.url})`)}),setTimeout(()=>t.current.focus(),0)},vd=(t,o,r,a,s)=>{const c=Hr(o,s),i=t.current.getRange({line:r+1,ch:0},{line:1/0,ch:1/0});if(t.current.replaceRange("",{line:r+1,ch:0},{line:1/0,ch:1/0}),t.current.replaceSelection(""),t.current.setCursor({line:r,ch:a}),t.current.replaceSelection(`
804
- `),t.current.replaceSelection(c),o==="Code"){let{line:d}=t.current.getCursor();t.current.setCursor({line:d-1,ch:s.length})}t.current.replaceRange(i,{line:r+4,ch:0},{line:1/0,ch:1/0}),t.current.focus()},Cd=(t,o,r,a)=>{const s=Gr(o),c=t.current.getRange({line:r+1,ch:0},{line:1/0,ch:1/0});if(t.current.replaceRange("",{line:r+1,ch:0},{line:1/0,ch:1/0}),t.current.setCursor({line:r,ch:a}),t.current.replaceSelection(`
805
- `),t.current.replaceSelection(s.editedText),o==="Code")r+=2,t.current.setSelection({line:r,ch:0},{line:r,ch:4});else{r+=1;let{ch:i}=t.current.getCursor(),d=i-s.selection.end,m=i-s.selection.end-s.selection.start;t.current.setSelection({line:r,ch:m},{line:r,ch:d})}t.current.replaceRange(c,{line:r+2,ch:0},{line:1/0,ch:1/0}),t.current.focus()},Rd=(t,o)=>{const r=t.current.getSelection();let{line:a}=t.current.getCursor(),s=t.current.getLine(a).length;r?vd(t,o,a,s,r):Cd(t,o,a,s)},lo=({onToggleExpand:t})=>{const{formatMessage:o}=(0,Y.Z)();return e.createElement(q.x,{padding:2,background:"neutral100",hasRadius:!0},e.createElement(P.k,{justifyContent:"flex-end",alignItems:"flex-end"},e.createElement(cd,{id:"expand",onClick:t},e.createElement(z.Z,null,o({id:"components.WysiwygBottomControls.fullscreen",defaultMessage:"Expand"})),e.createElement(or.Z,null))))};lo.defaultProps={onToggleExpand(){}},lo.propTypes={onToggleExpand:n().func};var Md=lo,Td=l(5383),Dd=l(20063);const co=({disabled:t,editorRef:o,isExpandMode:r,isPreviewMode:a,onActionClick:s,onToggleMediaLib:c,onTogglePreviewMode:i})=>{const[d,m]=(0,e.useState)(!1),{formatMessage:u}=(0,Y.Z)(),p=u({id:"components.Wysiwyg.selectOptions.title",defaultMessage:"Add a title"}),y=(0,e.useRef)(),h=()=>{m(g=>!g)};return t||a?e.createElement(P.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(Yr,null,e.createElement(Fe.P,{disabled:!0,placeholder:p,size:"S",label:p},e.createElement(Ce.W,{value:"h1"},"h1"),e.createElement(Ce.W,{value:"h2"},"h2"),e.createElement(Ce.W,{value:"h3"},"h3"),e.createElement(Ce.W,{value:"h4"},"h4"),e.createElement(Ce.W,{value:"h5"},"h5"),e.createElement(Ce.W,{value:"h6"},"h6")),e.createElement(Vr,null,e.createElement(Le,{disabled:!0,id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(ln.Z,null)}),e.createElement(Le,{disabled:!0,id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(cn.Z,null)}),e.createElement(Le,{disabled:!0,id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(un.Z,null)})),e.createElement(qr,{disabled:!0,id:"more",label:"More",icon:e.createElement(zn.Z,null)})),!r&&e.createElement(le.z,{onClick:i,variant:"tertiary",id:"preview"},u({id:"components.Wysiwyg.ToggleMode.markdown-mode",defaultMessage:"Markdown mode"}))):e.createElement(P.k,{padding:2,background:"neutral100",justifyContent:"space-between"},e.createElement(Yr,null,e.createElement(Fe.P,{placeholder:p,label:p,size:"S",onChange:g=>s(g,o)},e.createElement(Ce.W,{value:"h1"},"h1"),e.createElement(Ce.W,{value:"h2"},"h2"),e.createElement(Ce.W,{value:"h3"},"h3"),e.createElement(Ce.W,{value:"h4"},"h4"),e.createElement(Ce.W,{value:"h5"},"h5"),e.createElement(Ce.W,{value:"h6"},"h6")),e.createElement(Vr,null,e.createElement(Le,{onClick:()=>s("Bold",o),id:"Bold",label:"Bold",name:"Bold",icon:e.createElement(ln.Z,null)}),e.createElement(Le,{onClick:()=>s("Italic",o),id:"Italic",label:"Italic",name:"Italic",icon:e.createElement(cn.Z,null)}),e.createElement(Le,{onClick:()=>s("Underline",o),id:"Underline",label:"Underline",name:"Underline",icon:e.createElement(un.Z,null)})),e.createElement(qr,{ref:y,onClick:h,id:"more",label:"More",icon:e.createElement(zn.Z,null)}),d&&e.createElement(Td.J2,{onDismiss:h,centered:!0,source:y,spacing:4,id:"popover"},e.createElement(P.k,null,e.createElement(id,null,e.createElement(Le,{onClick:()=>s("Strikethrough",o,h),id:"Strikethrough",label:"Strikethrough",name:"Strikethrough",icon:e.createElement(cr.Z,null)}),e.createElement(Le,{onClick:()=>s("BulletList",o,h),id:"BulletList",label:"BulletList",name:"BulletList",icon:e.createElement(er.Z,null)}),e.createElement(Le,{onClick:()=>s("NumberList",o,h),id:"NumberList",label:"NumberList",name:"NumberList",icon:e.createElement(Dd.Z,null)})),e.createElement(Re.o,null,e.createElement(Le,{onClick:()=>s("Code",o,h),id:"Code",label:"Code",name:"Code",icon:e.createElement(tr.Z,null)}),e.createElement(Le,{onClick:()=>{h(),c()},id:"Image",label:"Image",name:"Image",icon:e.createElement(ir.Z,null)}),e.createElement(sd,{onClick:()=>s("Link",o,h),id:"Link",label:"Link",name:"Link",icon:e.createElement(sr.Z,null)}),e.createElement(Le,{onClick:()=>s("Quote",o,h),id:"Quote",label:"Quote",name:"Quote",icon:e.createElement(lr.Z,null)}))))),i&&e.createElement(le.z,{onClick:i,variant:"tertiary",id:"preview"},u({id:"components.Wysiwyg.ToggleMode.preview-mode",defaultMessage:"Preview mode"})))};co.defaultProps={isPreviewMode:!1,onActionClick(){},onToggleMediaLib(){},onTogglePreviewMode:void 0},co.propTypes={disabled:n().bool.isRequired,editorRef:n().shape({current:n().any}).isRequired,isExpandMode:n().bool.isRequired,isPreviewMode:n().bool,onActionClick:n().func,onToggleMediaLib:n().func,onTogglePreviewMode:n().func};var Od=co;const Yr=(0,U.ZP)(P.k)`
806
- /* Hide the label, every input needs a label. */
807
- label {
808
- border: 0;
809
- clip: rect(0 0 0 0);
810
- height: 1px;
811
- margin: -1px;
812
- overflow: hidden;
813
- padding: 0;
814
- position: absolute;
815
- width: 1px;
816
- }
817
- `,Pd=(0,U.ZP)(q.x)`
818
- svg path {
819
- fill: ${({theme:t})=>t.colors.neutral500};
820
- }
821
- `,Id=(0,U.ZP)(z.Z)`
822
- line-height: 0;
823
- `,uo=({hint:t,disabled:o,error:r,intlLabel:a,labelAction:s,name:c,onChange:i,placeholder:d,value:m,required:u})=>{const{formatMessage:p}=(0,Y.Z)(),y=(0,e.useRef)(null),h=(0,e.useRef)(null),[g,b]=(0,e.useState)(!1),[R,x]=(0,e.useState)(!1),[C,M]=(0,e.useState)(!1),{components:Z}=(0,f.yX)(),W=Z["media-library"],T=()=>x(F=>!F),O=()=>b(F=>!F),B=()=>{b(!1),M(F=>!F)},w=(F,H,Q)=>{switch(F){case"Link":case"Strikethrough":{Kr(H,F),Q();break}case"Code":case"Quote":{Rd(H,F),Q();break}case"Bold":case"Italic":case"Underline":{Kr(H,F);break}case"BulletList":case"NumberList":{yd(H,F),Q();break}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{Ed(H,F);break}default:}},I=F=>{const H=F.map(Q=>({alt:Q.alternativeText||Q.name,url:(0,f.CR)(Q.url),mime:Q.mime}));bd(h,H),x(!1)},N=d?p({id:d.id,defaultMessage:d.defaultMessage},{...d.values}):"",A=a.id?p({id:a.id,defaultMessage:a.defaultMessage},{...a.values}):c;return e.createElement(e.Fragment,null,e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:1},e.createElement(P.k,{gap:1},e.createElement(z.Z,{variant:"pi",fontWeight:"bold",textColor:"neutral800"},A,u&&e.createElement(Id,{textColor:"danger600"},"*")),s&&e.createElement(Pd,{paddingLeft:1},s)),e.createElement(io,{isExpandMode:C,error:r,previewContent:m,onCollapse:B},e.createElement(Od,{isExpandMode:C,editorRef:h,isPreviewMode:g,onActionClick:w,onToggleMediaLib:T,onTogglePreviewMode:C?void 0:O,disabled:o}),e.createElement(dd,{disabled:o,isExpandMode:C,editorRef:h,error:r,isPreviewMode:g,name:c,onChange:i,placeholder:N,textareaRef:y,value:m}),!C&&e.createElement(Md,{onToggleExpand:B})),e.createElement(Ic,{hint:t,name:c,error:r})),r&&e.createElement(q.x,{paddingTop:1},e.createElement(z.Z,{variant:"pi",textColor:"danger600","data-strapi-field-error":!0},r)),R&&e.createElement(W,{onClose:T,onSelectAssets:I}))};uo.defaultProps={disabled:!1,error:"",labelAction:void 0,placeholder:null,required:!1,value:"",hint:""},uo.propTypes={hint:n().oneOfType([n().string,n().array]),disabled:n().bool,error:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,onChange:n().func.isRequired,placeholder:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),required:n().bool,value:n().string};var xd=uo;function Zd(t,o){return r=>{const a=o(r.keys);return e.createElement(t,{...r,...a})}}var kd=Zd,Ld=(t,o=!1)=>[{metadatas:{intlLabel:{id:"components.InputSelect.option.placeholder",defaultMessage:"Choose here"},disabled:o,hidden:o},key:"__enum_option_null",value:""},...t.map(r=>({metadatas:{intlLabel:{id:r,defaultMessage:r},hidden:!1,disabled:!1},key:r,value:r}))],Sd=l(59578),Ad=l.n(Sd),Fd=(t="")=>{switch(Ad()(t)){case"boolean":return"bool";case"biginteger":return"text";case"decimal":case"float":case"integer":return"number";case"date":case"datetime":case"time":return t;case"email":return"email";case"enumeration":return"select";case"password":return"password";case"string":return"text";case"text":return"textarea";case"media":case"file":case"files":return"media";case"json":return"json";case"wysiwyg":case"WYSIWYG":case"richtext":return"wysiwyg";case"uid":return"uid";default:return t||"text"}};function $d(t){const{createActionAllowedFields:o,formErrors:r,isCreatingEntry:a,modifiedData:s,onChange:c,readActionAllowedFields:i,shouldNotRunValidations:d,updateActionAllowedFields:m}=(0,f.Wq)(),u=(0,e.useMemo)(()=>a?o:m,[a,o,m]),p=(0,e.useMemo)(()=>a?[]:i,[a,i]),y=$()(s,t,null);return{allowedFields:u,formErrors:r,isCreatingEntry:a,onChange:c,readableFields:p,shouldNotRunValidations:d,value:y}}var wd=$d,Xr=["type","model","via","collection","default","plugin","enum","regex","pluginOptions"];function mo({allowedFields:t,componentUid:o,fieldSchema:r,formErrors:a,isCreatingEntry:s,keys:c,labelAction:i,metadatas:d,onChange:m,readableFields:u,shouldNotRunValidations:p,queryInfos:y,value:h,size:g,customFieldInputs:b}){const{fields:R}=(0,f.yX)(),{formatMessage:x}=(0,Y.Z)(),{contentType:C}=(0,ne.PL)(),M=(0,e.useMemo)(()=>!$()(d,"editable",!0),[d]),{type:Z,customField:W}=r,T=$()(a,[c],null),O=(0,e.useMemo)(()=>(0,E.Ts)(c),[c]),B=(0,e.useMemo)(()=>{const k=Yl()(r,p?[...Xr,"required","minLength"]:Xr),j=r.regex||null;if(j){const te=new RegExp(j);te&&(k.regex=te)}return k},[r,p]),w=(0,e.useMemo)(()=>$()(B,["required"],!1),[B]),I=(0,e.useMemo)(()=>{const k=$()(C,["attributes"],{});return $()(k,[O[0],"type"],null)==="dynamiczone"},[C,O]),N=Fd(Z),A=Z==="media"&&!h?[]:h,F=(0,e.useMemo)(()=>{const k=O.join(".");if(t.includes(k))return!0;if(I)return t.includes(O[0]);if(O.length>1){const te=St()(O,O.length-1).join(".");return t.includes(te)}return!1},[t,O,I]),H=(0,e.useMemo)(()=>{const k=O.join(".");if(u.includes(k))return!0;if(I)return u.includes(O[0]);if(O.length>1){const te=St()(O,O.length-1).join(".");return u.includes(te)}return!1},[u,O,I]),Q=(0,e.useMemo)(()=>H||F,[F,H]),X=(0,e.useMemo)(()=>s?M:H&&!F?!0:M,[M,s,F,H]),L=(0,e.useMemo)(()=>Ld(r.enum||[],w),[r,w]),{label:S,description:v,placeholder:V,visible:G}=d;if(G===!1)return null;if(!Q)return e.createElement(f.X0,{description:v?{id:v,defaultMessage:v}:null,intlLabel:{id:S,defaultMessage:S},labelAction:i,error:T&&x(T),name:c,required:w});if(Z==="relation")return e.createElement(Pc,{...d,...r,componentUid:o,description:d.description?x({id:d.description,defaultMessage:d.description}):void 0,intlLabel:{id:d.label,defaultMessage:d.label},labelAction:i,isUserAllowedToEditField:F,isUserAllowedToReadField:H,name:c,placeholder:d.placeholder?{id:d.placeholder,defaultMessage:d.placeholder}:null,queryInfos:y,size:g,value:h,error:T&&x(T)});const K={uid:rc,media:R.media,wysiwyg:xd,...R,...b};return e.createElement(f.jm,{attribute:r,autoComplete:"new-password",intlLabel:{id:S,defaultMessage:S},isNullable:N==="bool"&&[null,void 0].includes(r.default),description:v?{id:v,defaultMessage:v}:null,disabled:X,error:T,labelAction:i,contentTypeUID:C.uid,customInputs:K,multiple:r.multiple||!1,name:c,onChange:m,options:L,placeholder:V?{id:V,defaultMessage:V}:null,required:r.required||!1,step:Bd(Z),type:W||N,value:A,withDefaultValue:!1})}mo.defaultProps={componentUid:void 0,formErrors:{},labelAction:void 0,size:void 0,value:null,queryInfos:{},customFieldInputs:{}},mo.propTypes={allowedFields:n().array.isRequired,componentUid:n().string,fieldSchema:n().object.isRequired,formErrors:n().object,keys:n().string.isRequired,isCreatingEntry:n().bool.isRequired,labelAction:n().element,metadatas:n().object.isRequired,onChange:n().func.isRequired,readableFields:n().array.isRequired,size:n().number,shouldNotRunValidations:n().bool.isRequired,value:n().any,queryInfos:n().shape({containsKey:n().string,defaultParams:n().object,endPoint:n().string}),customFieldInputs:n().object};const Bd=t=>{switch(t){case"float":case"decimal":return .01;default:return 1}},Nd=(0,e.memo)(mo,Pe());var po=kd(Nd,wd);const go=({componentUid:t,isFromDynamicZone:o,isNested:r,name:a})=>{const{getComponentLayout:s}=(0,ne.PL)(),i=(0,e.useMemo)(()=>s(t),[t,s]).layouts.edit,{lazyComponentStore:d}=Vn();return e.createElement(q.x,{background:o?"":"neutral100",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,hasRadius:r,borderColor:r?"neutral200":""},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},i.map((m,u)=>e.createElement(Oe.r,{gap:4,key:u},m.map(({name:p,size:y,metadatas:h,fieldSchema:g,queryInfos:b})=>{const R=g.type==="component",x=`${a}.${p}`;if(R){const C=g.component;return e.createElement(be.P,{col:y,s:12,xs:12,key:p},e.createElement(Qt,{componentUid:C,intlLabel:{id:h.label,defaultMessage:h.label},isNested:!0,isRepeatable:g.repeatable,max:g.max,min:g.min,name:x,required:g.required||!1}))}return e.createElement(be.P,{col:y,key:p,s:12,xs:12},e.createElement(po,{componentUid:t,keys:x,fieldSchema:g,metadatas:h,queryInfos:b,size:y,customFieldInputs:d}))})))))};go.defaultProps={isFromDynamicZone:!1,isNested:!1},go.propTypes={componentUid:n().string.isRequired,isFromDynamicZone:n().bool,isNested:n().bool,name:n().string.isRequired};var jd=go;const Wd=(0,U.ZP)(q.x)`
824
- overflow: hidden;
825
- border-bottom: 1px solid ${({theme:t})=>t.colors.neutral200};
826
- border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
827
- border-left: 1px solid ${({theme:t})=>t.colors.neutral200};
828
- border-radius: 0 0 ${({theme:t})=>t.borderRadius} ${({theme:t})=>t.borderRadius};
829
- `,zd=(0,U.ZP)(q.x)`
830
- border-bottom: none;
831
-
832
- /* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
833
- & > div > div {
834
- border: 1px solid ${({theme:t})=>t.colors.neutral200};
835
- border-top-color: transparent;
836
- }
837
-
838
- /* the top accordion _does_ need a border though */
839
- & > div:first-child > div {
840
- border-top: 1px solid ${({theme:t})=>t.colors.neutral200};
841
- }
842
-
843
- /* Reset all the border-radius' */
844
- & > div > div,
845
- & > div > div > div {
846
- border-radius: unset;
847
- }
848
-
849
- /* Give the border radius back to the first accordion */
850
- & > div:first-child > div,
851
- & > div:first-child > div > div {
852
- border-radius: ${({theme:t})=>t.borderRadius} ${({theme:t})=>t.borderRadius} 0 0;
853
- }
854
-
855
- & > div > div[data-strapi-expanded='true'] {
856
- border: 1px solid ${({theme:t})=>t.colors.primary600};
857
- }
858
- `,fo=({children:t,error:o})=>{const{formatMessage:r}=(0,Y.Z)();return e.createElement(Ir.k,{attributeName:"data-strapi-accordion-toggle"},t,o&&e.createElement(q.x,{paddingTop:1},e.createElement(z.Z,{variant:"pi",textColor:"danger600"},r({id:o.id,defaultMessage:o.defaultMessage},{...o.values}))))};fo.defaultProps={error:void 0},fo.propTypes={children:n().node.isRequired,error:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object})};var Ud=l(41119),Jr=l.n(Ud);const Vd=U.ZP.span`
859
- display: block;
860
- background-color: ${({theme:t})=>t.colors.primary100};
861
- outline: 1px dashed ${({theme:t})=>t.colors.primary500};
862
- outline-offset: -1px;
863
- padding: ${({theme:t})=>t.spaces[6]};
864
- `;var qd=()=>e.createElement(Vd,{padding:6,background:"primary100"});const Hd=(0,U.ZP)(Re.h)`
865
- background-color: transparent;
866
-
867
- svg {
868
- path {
869
- fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:t.colors.neutral600};
870
- }
871
- }
872
-
873
- &:hover {
874
- svg {
875
- path {
876
- fill: ${({theme:t})=>t.colors.primary600};
877
- }
878
- }
879
- }
880
- `,Gd=(0,U.ZP)(P.k)`
881
- & .drag-handle {
882
- background: unset;
883
-
884
- svg {
885
- path {
886
- fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:void 0};
887
- }
888
- }
889
-
890
- &:hover {
891
- svg {
892
- path {
893
- /* keeps the hover style of the accordion */
894
- fill: ${({theme:t})=>t.colors.primary600};
895
- }
896
- }
897
- }
898
- }
899
- `,ho=({componentFieldName:t,componentUid:o,fields:r,index:a,isOpen:s,isReadOnly:c,mainField:i,moveComponentField:d,onClickToggle:m,toggleCollapses:u,onGrabItem:p,onDropItem:y,onCancel:h})=>{const{modifiedData:g,removeRepeatableField:b,triggerFormValidation:R}=(0,f.Wq)(),x=Jr()($()(g,[...t.split("."),i],"")),C=(0,e.useRef)(null),{formatMessage:M}=(0,Y.Z)(),Z=t.split(".").slice(0,-1).join("."),[{handlerId:W,isDragging:T,handleKeyDown:O},B,w,I,N]=(0,$r.Y)(!c,{type:`${E._Q.COMPONENT}_${Z}`,index:a,item:{displayedValue:x},onMoveItem:d,onStart(){u()},onEnd(){R()},onGrabItem:p,onDropItem:y,onCancel:h});(0,e.useEffect)(()=>{N((0,It.rX)(),{captureDraggingState:!1})},[N,a]);const A=(0,E.FE)(C,I),F=(0,E.FE)(B,w),{lazyComponentStore:H}=Vn();return e.createElement(q.x,{ref:F},T?e.createElement(qd,null):e.createElement(wn.U,{expanded:s,onToggle:m,id:t,size:"S"},e.createElement(Bn.B,{action:c?null:e.createElement(Gd,{gap:0,expanded:s},e.createElement(Hd,{expanded:s,noBorder:!0,onClick:()=>{b(t),u()},label:M({id:(0,E.OB)("containers.Edit.delete"),defaultMessage:"Delete"}),icon:e.createElement(Ve.Z,null)}),e.createElement(Re.h,{className:"drag-handle",ref:A,forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:Q=>Q.stopPropagation(),"data-handler-id":W,label:M({id:(0,E.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:O},e.createElement(Ye.Z,null))),title:x,togglePosition:"left"}),e.createElement(Nn.v,null,e.createElement(P.k,{direction:"column",alignItems:"stretch",background:"neutral100",padding:6,gap:6},r.map((Q,X)=>e.createElement(Oe.r,{gap:4,key:X},Q.map(({name:L,fieldSchema:S,metadatas:v,queryInfos:V,size:G})=>{const K=S.type==="component",k=`${t}.${L}`;if(K){const j=S.component;return e.createElement(be.P,{col:G,s:12,xs:12,key:L},e.createElement(Qt,{componentUid:j,intlLabel:{id:v.label,defaultMessage:v.label},isRepeatable:S.repeatable,isNested:!0,name:k,max:S.max,min:S.min,required:S.required}))}return e.createElement(be.P,{key:k,col:G,s:12,xs:12},e.createElement(po,{componentUid:o,fieldSchema:S,keys:k,metadatas:v,queryInfos:V,size:G,customFieldInputs:H}))})))))))};ho.defaultProps={componentUid:void 0,fields:[],isReadOnly:!1,isOpen:!1,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0,toggleCollapses(){}},ho.propTypes={componentFieldName:n().string.isRequired,componentUid:n().string,fields:n().array,index:n().number.isRequired,isOpen:n().bool,isReadOnly:n().bool,mainField:n().string.isRequired,moveComponentField:n().func.isRequired,onGrabItem:n().func,onDropItem:n().func,onCancel:n().func,onClickToggle:n().func.isRequired,toggleCollapses:n().func};var Qd=(0,e.memo)(ho);function Kd(t,o={}){return Object.keys(o).filter(r=>r.startsWith(t)).map(r=>r.split(".").slice(0,t.split(".").length+1).join("."))}const Yd=(0,U.ZP)(Ar.A)`
900
- height: 100%;
901
- width: 100%;
902
- border-radius: 0 0 4px 4px;
903
- display: flex;
904
- justify-content: center;
905
- span {
906
- font-weight: 600;
907
- font-size: 14px;
908
- }
909
- `,yo=({componentUid:t,componentValue:o,componentValueLength:r,isReadOnly:a,max:s,min:c,name:i})=>{const{addRepeatableComponentToField:d,formErrors:m,moveComponentField:u}=(0,f.Wq)(),p=(0,f.lm)(),{formatMessage:y}=(0,Y.Z)(),[h,g]=(0,e.useState)(""),[b,R]=(0,e.useState)(""),{getComponentLayout:x,components:C}=(0,ne.PL)(),M=(0,e.useMemo)(()=>x(t),[t,x]),Z=(0,e.useMemo)(()=>(0,E.Uo)(o||[])+1,[o]),W=Kd(i,m),T=c-r,O=$()(m,i,{id:""}).id.includes("min"),B=()=>{g("")},w=()=>{a||(r<s?(d(i,M,C,O),g(Z)):r>=s&&p({type:"info",message:{id:(0,E.OB)("components.notification.info.maximum-requirement")}}))},I=(v,V)=>{R(y({id:(0,E.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${i}.${V}`,position:F(v)})),u({name:i,newIndex:v,currentIndex:V})},N=$()(M,["settings","mainField"],"id"),A=v=>()=>{g(h===v?"":v)},F=v=>`${v+1} of ${r}`,H=v=>{R(y({id:(0,E.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${i}.${v}`}))},Q=v=>{R(y({id:(0,E.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:`${i}.${v}`,position:F(v)}))},X=v=>{R(y({id:(0,E.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${i}.${v}`,position:F(v)}))};let L=m[i];if(O?L={id:(0,E.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}",values:{number:T}}:W.some(v=>v.split(".").length>1)&&!O&&(L={id:(0,E.OB)("components.RepeatableComponent.error-message"),defaultMessage:"The component(s) contain error(s)"}),r===0)return e.createElement(Zr,{error:L,isReadOnly:a,onClick:w});const S=`${i}-item-instructions`;return e.createElement(q.x,{hasRadius:!0},e.createElement(_e.T,{id:S},y({id:(0,E.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(_e.T,{"aria-live":"assertive"},b),e.createElement(fo,{error:L,ariaDescribedBy:S},e.createElement(zd,{"aria-describedby":S},o.map(({__temp_key__:v},V)=>e.createElement(Qd,{componentFieldName:`${i}.${V}`,componentUid:t,fields:M.layouts.edit,key:v,index:V,isOpen:h===v,isReadOnly:a,mainField:N,moveComponentField:I,onClickToggle:A(v),toggleCollapses:B,onCancel:H,onDropItem:X,onGrabItem:Q}))),e.createElement(Wd,null,e.createElement(P.k,{justifyContent:"center",height:"48px",background:"neutral0"},e.createElement(Yd,{disabled:a,onClick:w,startIcon:e.createElement(pt.Z,null)},y({id:(0,E.OB)("containers.EditView.add.new-entry"),defaultMessage:"Add an entry"}))))))};yo.defaultProps={componentValue:null,componentValueLength:0,isReadOnly:!1,max:1/0,min:0},yo.propTypes={componentUid:n().string.isRequired,componentValue:n().oneOfType([n().array,n().object]),componentValueLength:n().number,isReadOnly:n().bool,max:n().number,min:n().number,name:n().string.isRequired};var Xd=(0,e.memo)(yo);const Jd=(0,U.ZP)(q.x)`
910
- svg path {
911
- fill: ${({theme:t})=>t.colors.neutral500};
912
- }
913
- `,Eo=({intlLabel:t,id:o,labelAction:r,name:a,numberOfEntries:s,showNumberOfEntries:c,required:i})=>{const{formatMessage:d}=(0,Y.Z)(),m=t?.id?d(t):a;return e.createElement(q.x,{paddingBottom:1},e.createElement(P.k,null,e.createElement(z.Z,{textColor:"neutral800",htmlFor:o||a,variant:"pi",fontWeight:"bold",as:"label"},m,c&&e.createElement(e.Fragment,null,"\xA0(",s,")"),i&&e.createElement(z.Z,{textColor:"danger600"},"*")),r&&e.createElement(Jd,{paddingLeft:1},r)))};Eo.defaultProps={id:void 0,labelAction:void 0,numberOfEntries:0,required:!1,showNumberOfEntries:!1},Eo.propTypes={id:n().string,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}).isRequired,labelAction:n().element,name:n().string.isRequired,numberOfEntries:n().number,required:n().bool,showNumberOfEntries:n().bool};var _d=Eo;function eu(t,o){return r=>{const a=o(r);return e.createElement(t,{...r,...a})}}var tu=eu;function nu({isFromDynamicZone:t,name:o}){const{addNonRepeatableComponentToField:r,createActionAllowedFields:a,isCreatingEntry:s,modifiedData:c,removeComponentFromField:i,readActionAllowedFields:d,updateActionAllowedFields:m,formErrors:u}=(0,f.Wq)(),{contentType:p}=(0,ne.PL)(),y=(0,e.useMemo)(()=>{const M=$()(p,["attributes"],{});return Object.keys(M).filter(W=>$()(M,[W,"type"],"")==="dynamiczone")},[p]),h=(0,e.useMemo)(()=>s?a:m,[s,a,m]),g=$()(c,o,null),b=(0,e.useMemo)(()=>(0,E.Ts)(o),[o]),R=(0,e.useMemo)(()=>t&&s||h.filter(W=>W===b[0]).length>0?!0:h.map(W=>W.split(".")).filter(W=>W.length<b.length?!1:St()(W,b.length).join(".")===b.join(".")).length>0,[t,s,h,b]),x=(0,e.useMemo)(()=>t||y.includes(b[0])?!0:(s?[]:d).map(W=>W.split(".")).filter(W=>W.length<b.length?!1:St()(W,b.length).join(".")===b.join(".")).length>0,[t,y,b,s,d]),C=(0,e.useMemo)(()=>s||R?!1:x,[R,x,s]);return{addNonRepeatableComponentToField:r,formErrors:u,hasChildrenAllowedFields:R,hasChildrenReadableFields:x,isCreatingEntry:s,isReadOnly:C,removeComponentFromField:i,componentValue:g}}var ou=nu;const bo=({addNonRepeatableComponentToField:t,componentUid:o,intlLabel:r,isCreatingEntry:a,isFromDynamicZone:s,isRepeatable:c,isNested:i,labelAction:d,max:m,min:u,name:p,hasChildrenAllowedFields:y,hasChildrenReadableFields:h,isReadOnly:g,componentValue:b,removeComponentFromField:R,required:x})=>{const{formatMessage:C}=(0,Y.Z)(),M=Gl()(b),Z=b!==null||s,W=!c&&Z&&!s&&y,{getComponentLayout:T,components:O}=(0,ne.PL)(),B=(0,e.useMemo)(()=>T(o),[o,T]);if(!y&&a)return e.createElement(f.X0,{labelAction:d,intlLabel:r,name:p});if(!y&&!a&&!h)return e.createElement(f.X0,{labelAction:d,intlLabel:r,name:p});const w=()=>{t(p,B,O)};return e.createElement(q.x,null,e.createElement(P.k,{justifyContent:"space-between"},r&&e.createElement(_d,{intlLabel:r,labelAction:d,name:p,numberOfEntries:M,showNumberOfEntries:c,required:x}),W&&e.createElement(Re.h,{label:C({id:(0,E.OB)("components.reset-entry"),defaultMessage:"Reset Entry"}),icon:e.createElement(Ve.Z,null),noBorder:!0,onClick:()=>{R(p,o)}})),e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:1},!c&&!Z&&e.createElement(Zr,{isReadOnly:g,onClick:w}),!c&&Z&&e.createElement(jd,{componentUid:o,isFromDynamicZone:s,isNested:i,name:p}),c&&e.createElement(Xd,{componentValue:b,componentValueLength:M,componentUid:o,isReadOnly:g,max:m,min:u,name:p})))};bo.defaultProps={componentValue:null,hasChildrenAllowedFields:!1,hasChildrenReadableFields:!1,intlLabel:void 0,isFromDynamicZone:!1,isReadOnly:!1,isRepeatable:!1,isNested:!1,labelAction:void 0,max:1/0,min:-1/0,required:!1},bo.propTypes={addNonRepeatableComponentToField:n().func.isRequired,componentUid:n().string.isRequired,componentValue:n().oneOfType([n().object,n().array]),hasChildrenAllowedFields:n().bool,hasChildrenReadableFields:n().bool,isCreatingEntry:n().bool.isRequired,isFromDynamicZone:n().bool,isReadOnly:n().bool,isRepeatable:n().bool,isNested:n().bool,intlLabel:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired,values:n().object}),labelAction:n().element,max:n().number,min:n().number,name:n().string.isRequired,removeComponentFromField:n().func.isRequired,required:n().bool};const ru=(0,e.memo)(bo,Pe());var Qt=tu(ru,ou);const vo=({componentUid:t,formErrors:o,index:r,isFieldAllowed:a,name:s,onRemoveComponentClick:c,onMoveComponent:i,onGrabItem:d,onDropItem:m,onCancel:u,dynamicComponentsByCategory:p,onAddComponent:y})=>{const[h,g]=(0,e.useState)(!0),{formatMessage:b}=(0,Y.Z)(),{getComponentLayout:R}=(0,ne.PL)(),{modifiedData:x}=(0,f.Wq)(),{icon:C,friendlyName:M,mainValue:Z}=(0,e.useMemo)(()=>{const L=R(t),{info:{icon:S,displayName:v}}=L,V=$()(L,["settings","mainField"],"id"),G=$()(x,[s,r,V])??"",K=V==="id"?"":String(G).trim(),k=K.length>0?` - ${K}`:K;return{friendlyName:v,icon:S,mainValue:k}},[t,R,x,s,r]),W=Object.keys(o).filter(L=>{const S=L.split(".");return`${S[0]}.${S[1]}`==`${s}.${r}`});let T;W.length>0&&(T=b({id:(0,E.OB)("components.DynamicZone.error-message"),defaultMessage:"The component contains error(s)"}));const O=()=>{g(L=>!L)},[{handlerId:B,isDragging:w,handleKeyDown:I},N,A,F,H]=(0,ne.Y9)(a,{type:`${E._Q.DYNAMIC_ZONE}_${s}`,index:r,item:{displayedValue:`${M}${Z}`,icon:C},onMoveItem:i,onGrabItem:d,onDropItem:m,onCancel:u});(0,e.useEffect)(()=>{H((0,It.rX)(),{captureDraggingState:!1})},[H,r]);const Q=(0,E.FE)(N,A),X=a?e.createElement(au,{gap:0,expanded:h},e.createElement(su,{noBorder:!0,label:b({id:(0,E.OB)("components.DynamicZone.delete-label"),defaultMessage:"Delete {name}"},{name:M}),onClick:c},e.createElement(Ve.Z,null)),e.createElement(Re.h,{forwardedAs:"div",role:"button",noBorder:!0,tabIndex:0,onClick:L=>L.stopPropagation(),"data-handler-id":B,ref:F,label:b({id:(0,E.OB)("components.DragHandle-label"),defaultMessage:"Drag"}),onKeyDown:I},e.createElement(Ye.Z,null)),e.createElement(ge.fC,null,e.createElement(ge.xz,{size:"S",endIcon:void 0,paddingLeft:2,paddingRight:2},e.createElement(zn.Z,{"aria-hidden":!0,focusable:!1}),e.createElement(_e.T,{as:"span"},b({id:(0,E.OB)("components.DynamicZone.more-actions"),defaultMessage:"More actions"}))),e.createElement(ge.VY,null,e.createElement(ge.rl,null,e.createElement(ge.fF,null,b({id:(0,E.OB)("components.DynamicZone.add-item-above"),defaultMessage:"Add component above"})),e.createElement(ge.tu,null,Object.entries(p).map(([L,S])=>e.createElement(e.Fragment,{key:L},e.createElement(ge.__,null,L),S.map(({componentUid:v,info:{displayName:V}})=>e.createElement(xr.sN,{key:v,onSelect:()=>y(v,r)},V)))))),e.createElement(ge.rl,null,e.createElement(ge.fF,null,b({id:(0,E.OB)("components.DynamicZone.add-item-below"),defaultMessage:"Add component below"})),e.createElement(ge.tu,null,Object.entries(p).map(([L,S])=>e.createElement(e.Fragment,{key:L},e.createElement(ge.__,null,L),S.map(({componentUid:v,info:{displayName:V}})=>e.createElement(xr.sN,{key:v,onSelect:()=>y(v,r+1)},V))))))))):null;return e.createElement(uu,{as:"li",width:"100%"},e.createElement(P.k,{justifyContent:"center"},e.createElement(cu,{background:"neutral200"})),e.createElement(iu,{ref:Q,hasRadius:!0},w?e.createElement(du,{padding:6,background:"primary100"}):e.createElement(wn.U,{expanded:h,onToggle:O,size:"S",error:T},e.createElement(Bn.B,{startIcon:e.createElement(xt,{icon:C,showBackground:!1,size:"S"}),action:X,title:`${M}${Z}`,togglePosition:"left"}),e.createElement(Nn.v,null,e.createElement(lu,{background:"neutral0"},e.createElement(Qt,{componentUid:t,icon:C,name:`${s}.${r}`,isFromDynamicZone:!0}))))))},au=(0,U.ZP)(P.k)`
914
- /*
915
- we need to remove the background from the button but we can't
916
- wrap the element in styled because it breaks the forwardedAs which
917
- we need for drag handler to work on firefox
918
- */
919
- div[role='button'] {
920
- background: transparent;
921
- }
922
- `,su=(0,U.ZP)(Re.h)`
923
- background-color: transparent;
924
-
925
- svg path {
926
- fill: ${({theme:t,expanded:o})=>o?t.colors.primary600:t.colors.neutral600};
927
- }
928
- `,iu=(0,U.ZP)(q.x)`
929
- > div:first-child {
930
- box-shadow: ${({theme:t})=>t.shadows.tableShadow};
931
- }
932
- `,lu=(0,U.ZP)(q.x)`
933
- border-radius: 0 0 ${({theme:t})=>t.spaces[1]} ${({theme:t})=>t.spaces[1]};
934
- `,cu=(0,U.ZP)(q.x)`
935
- width: ${({theme:t})=>t.spaces[2]};
936
- height: ${({theme:t})=>t.spaces[4]};
937
- `,du=U.ZP.span`
938
- display: block;
939
- background-color: ${({theme:t})=>t.colors.primary100};
940
- outline: 1px dashed ${({theme:t})=>t.colors.primary500};
941
- outline-offset: -1px;
942
- padding: ${({theme:t})=>t.spaces[6]};
943
- `,uu=(0,U.ZP)(q.x)`
944
- list-style: none;
945
- padding: 0;
946
- margin: 0;
947
- `;vo.defaultProps={dynamicComponentsByCategory:{},formErrors:{},index:0,isFieldAllowed:!0,onAddComponent:void 0,onGrabItem:void 0,onDropItem:void 0,onCancel:void 0},vo.propTypes={componentUid:n().string.isRequired,dynamicComponentsByCategory:n().shape({components:n().arrayOf(n().shape({componentUid:n().string.isRequired,info:n().object}))}),formErrors:n().object,index:n().number,isFieldAllowed:n().bool,name:n().string.isRequired,onAddComponent:n().func,onGrabItem:n().func,onDropItem:n().func,onCancel:n().func,onMoveComponent:n().func.isRequired,onRemoveComponentClick:n().func.isRequired};const Co=({label:t,labelAction:o,name:r,numberOfComponents:a,required:s,intlDescription:c})=>{const{formatMessage:i}=(0,Y.Z)(),d=i({id:t||r,defaultMessage:t||r});return e.createElement(P.k,{justifyContent:"center"},e.createElement(q.x,{paddingTop:3,paddingBottom:3,paddingRight:4,paddingLeft:4,borderRadius:26,background:"neutral0",shadow:"filterShadow",color:"neutral500"},e.createElement(P.k,{direction:"column",justifyContent:"center"},e.createElement(P.k,{maxWidth:(0,f.Q1)(356)},e.createElement(z.Z,{variant:"pi",textColor:"neutral600",fontWeight:"bold",ellipsis:!0},d,"\xA0"),e.createElement(z.Z,{variant:"pi",textColor:"neutral600",fontWeight:"bold"},"(",a,")"),s&&e.createElement(z.Z,{textColor:"danger600"},"*"),o&&e.createElement(q.x,{paddingLeft:1},o)),c&&e.createElement(q.x,{paddingTop:1,maxWidth:(0,f.Q1)(356)},e.createElement(z.Z,{variant:"pi",textColor:"neutral600",ellipsis:!0},i(c))))))};Co.defaultProps={intlDescription:void 0,label:"",labelAction:void 0,numberOfComponents:0,required:!1},Co.propTypes={intlDescription:n().shape({id:n().string.isRequired,defaultMessage:n().string.isRequired}),label:n().string,labelAction:n().element,name:n().string.isRequired,numberOfComponents:n().number,required:n().bool};const Ro=({name:t,labelAction:o,fieldSchema:r,metadatas:a})=>{const{max:s=1/0,min:c=-1/0,components:i=[],required:d=!1}=r,[m,u]=(0,e.useState)(!1),[p,y]=(0,e.useState)(""),{addComponentToDynamicZone:h,createActionAllowedFields:g,isCreatingEntry:b,formErrors:R,modifiedData:x,moveComponentField:C,removeComponentFromDynamicZone:M,readActionAllowedFields:Z,updateActionAllowedFields:W}=(0,f.Wq)(),T=(0,e.useMemo)(()=>(x?.[t]??[]).map(D=>({componentUid:D.__component,id:D.id??D.__temp_key__})),[x,t]),{getComponentLayout:O,components:B}=(0,ne.PL)(),w=(0,e.useMemo)(()=>i.reduce((D,ee)=>{const{category:pe,info:Ie,attributes:Ue}=O(ee),ce={componentUid:ee,info:Ie,attributes:Ue};return D[pe]||(D[pe]=[]),D[pe]=[...D[pe],ce],D},{}),[i,O]),{formatMessage:I}=(0,Y.Z)(),N=(0,f.lm)(),A=(0,e.useMemo)(()=>(b?g:W).includes(t),[t,b,g,W]),F=(0,e.useMemo)(()=>(b?[]:Z).includes(t),[t,b,Z]),H=T.length,Q=a.description?{id:a.description,defaultMessage:a.description}:null,X=R[t],L=c-H,S=!!X,v=(D,ee)=>{u(!1);const pe=O(D);h(t,pe,B,S,ee)},V=()=>{H<s?u(D=>!D):N({type:"info",message:{id:(0,E.OB)("components.notification.info.maximum-requirement")}})},G=(D,ee)=>{y(I({id:(0,E.OB)("dnd.reorder"),defaultMessage:"{item}, moved. New position in list: {position}."},{item:`${t}.${ee}`,position:K(D)})),C({name:t,newIndex:D,currentIndex:ee})},K=D=>`${D+1} of ${T.length}`,k=D=>{y(I({id:(0,E.OB)("dnd.cancel-item"),defaultMessage:"{item}, dropped. Re-order cancelled."},{item:`${t}.${D}`}))},j=D=>{y(I({id:(0,E.OB)("dnd.grab-item"),defaultMessage:"{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel."},{item:`${t}.${D}`,position:K(D)}))},te=D=>{y(I({id:(0,E.OB)("dnd.drop-item"),defaultMessage:"{item}, dropped. Final position in list: {position}."},{item:`${t}.${D}`,position:K(D)}))},ue=(D,ee)=>()=>{M(D,ee)},fe=()=>m?I({id:"app.utils.close-label",defaultMessage:"Close"}):S&&X.id.includes("max")?I({id:"components.Input.error.validation.max",defaultMessage:"The value is too high."}):S&&X.id.includes("min")?I({id:(0,E.OB)("components.DynamicZone.missing-components"),defaultMessage:"There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"},{number:L}):I({id:(0,E.OB)("components.DynamicZone.add-component"),defaultMessage:"Add a component to {componentName}"},{componentName:a.label||t});if(!A&&(b||!F&&!b))return e.createElement(f.X0,{description:Q,intlLabel:{id:a.label,defaultMessage:a.label},labelAction:o,name:t});const ye=`${t}-item-instructions`;return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},H>0&&e.createElement(q.x,null,e.createElement(Co,{intlDescription:Q,label:a.label,labelAction:o,name:t,numberOfComponents:H,required:d}),e.createElement(_e.T,{id:ye},I({id:(0,E.OB)("dnd.instructions"),defaultMessage:"Press spacebar to grab and re-order"})),e.createElement(_e.T,{"aria-live":"assertive"},p),e.createElement("ol",{"aria-describedby":ye},T.map(({componentUid:D,id:ee},pe)=>e.createElement(vo,{componentUid:D,formErrors:R,key:`${D}-${ee}`,index:pe,isFieldAllowed:A,name:t,onMoveComponent:G,onRemoveComponentClick:ue(t,pe),onCancel:k,onDropItem:te,onGrabItem:j,onAddComponent:v,dynamicComponentsByCategory:w})))),e.createElement(P.k,{justifyContent:"center"},e.createElement(Fn,{hasError:S,isDisabled:!A,isOpen:m,onClick:V},fe())),e.createElement(Wn,{dynamicComponentsByCategory:w,isOpen:m,onClickAddComponent:v}))};Ro.defaultProps={fieldSchema:{},labelAction:null},Ro.propTypes={fieldSchema:n().shape({components:n().array,max:n().number,min:n().number,required:n().bool}),labelAction:n().element,metadatas:n().shape({description:n().string,label:n().string}).isRequired,name:n().string.isRequired};var mu=l(86834),Ne=l.n(mu),_r=l(12788),Mo=l(99526),pu=l(10268),ea=l.n(pu),gu=l(56236),fu=l.n(gu),hu=l(77236),yu=l.n(hu),Eu=l(85973),bu=l.n(Eu);const vu=({browserState:t,serverState:o},r,a)=>{const s=o,c=t,i=(u,p)=>$()(u,["attributes",p,"type"],""),d=(u,p)=>$()(u,["attributes",...p],""),m=(u,p,y,h)=>Object.keys(u).reduce((g,b)=>{const R=h?`${h}.${b}`:b,x=i(y,b),C=$()(u,b),M=$()(p,b),Z=d(y,[b,"component"]),W=d(y,[b,"repeatable"]);let T;switch(x){case"json":T=JSON.parse(C);break;case"time":{T=C,C&&C.split(":").length<3&&(T=`${C}:00`);break}case"media":d(y,[b,"multiple"])===!0?T=C?C.filter(O=>!(O instanceof File)):null:T=$()(C,0)instanceof File?null:$()(C,"id",null);break;case"component":W?T=C&&C.map((O,B)=>m(O,(M??[])[B],a[Z],`${R}.${B}`)):T=C&&m(C,M,a[Z],R);break;case"relation":{const O=Sr(s,c)(R).join(".");let B=$()(s,O,[]);const w=C.reduce((N,A,F,H)=>{const Q=B.find(L=>L.id===A.id),X=H[F+1];if(!Q||Q.__temp_key__!==A.__temp_key__){const L=X?{before:X.id}:{end:!0};return[...N,{id:A.id,position:L}]}return N},[]);T={disconnect:B.reduce((N,A)=>C.find(F=>F.id===A.id)?N:[...N,{id:A.id}],[]),connect:w.reverse()};break}case"dynamiczone":T=C.map((O,B)=>m(O,(M??[])[B],a[O.__component],`${R}.${B}`));break;default:T=Cu(C,"id")}return g[b]=T,g},{});return m(t,o,r,"")},Cu=(t,o)=>yu()(t)?t.map(r=>r[o]?r[o]:r):bu()(t)?t[o]:t;var Ru=vu;const Kt=(t,o=()=>!1,r=void 0)=>{const a=(s,c,{ignoreFalseyValues:i=!1,path:d=[],parent:m=c}={})=>Object.entries(c).reduce((u,[p,y])=>{if(i&&(u==null||u[p]===void 0||u[p]===null))return u;if(o(y,{path:[...d,p],parent:m})&&(u[p]=typeof r=="function"?r(u[p],{path:[...d,p],parent:u}):r),y.type==="component"){const h=t[y.component].attributes;!y.repeatable&&u[p]&&typeof u[p]=="object"?u[p]=a(u[p],h,{ignoreFalseyValues:i,path:[...d,p],parent:c[p]}):y.repeatable&&Array.isArray(u[p])&&(u[p]=u[p].map((g,b)=>a(g,h,{ignoreFalseyValues:i,path:[...d,p,b],parent:c[p]})))}else y.type==="dynamiczone"&&Array.isArray(u[p])&&(u[p]=u[p].map((h,g)=>{const b=t[h.__component].attributes;return a(h,b,{ignoreFalseyValues:i,path:[...d,p,g],parent:c[p]})}));return u},{...s});return a};var ta=(t,o,r,a)=>{const s=t.slice();return s.splice(o,1),s.splice(r,0,a),s};const Mu={componentsDataStructure:{},contentTypeDataStructure:{},formErrors:{},initialData:{},modifiedData:null,shouldCheckErrors:!1,modifiedDZName:null,publishConfirmation:{show:!1,draftCount:0}};var Tu=(t,o)=>(0,Dn.ZP)(t,r=>{switch(o.type){case"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD":{const{componentLayoutData:a,allComponents:s}=o,c={...t.componentsDataStructure[a.uid]},d=Kt(s,m=>m.type==="relation",[])(c,a.attributes);oe()(r,["modifiedData",...o.keys],d);break}case"ADD_COMPONENT_TO_DYNAMIC_ZONE":case"ADD_REPEATABLE_COMPONENT_TO_FIELD":{const{keys:a,allComponents:s,componentLayoutData:c,shouldCheckErrors:i,position:d=void 0}=o;i&&(r.shouldCheckErrors=!t.shouldCheckErrors),o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"&&(r.modifiedDZName=a[0]);const m=[...$()(t,["modifiedData",...a],[])];let u=d;u===void 0?u=m.length:u<0&&(u=0);const p=o.type==="ADD_COMPONENT_TO_DYNAMIC_ZONE"?{...t.componentsDataStructure[c.uid],__component:c.uid,__temp_key__:(0,E.Uo)(m)+1}:{...t.componentsDataStructure[c.uid],__temp_key__:(0,E.Uo)(m)+1},h=Kt(s,g=>g.type==="relation",[])(p,c.attributes);m.splice(u,0,h),oe()(r,["modifiedData",...a],m);break}case"LOAD_RELATION":{const{initialDataPath:a,modifiedDataPath:s,value:c}=o,i=$()(t,a),d=$()(t,s),m=i?c.filter(y=>!i.some(h=>h.id===y.id)):c,u=(0,Mo.zJ)(null,d[0]?.__temp_key__,m.length),p=m.map((y,h)=>({...y,__temp_key__:u[h]}));oe()(r,a,ea()([...p,...i],"id")),oe()(r,s,ea()([...p,...d],"id"));break}case"CONNECT_RELATION":{const a=["modifiedData",...o.keys],{value:s,toOneRelation:c}=o;if(c)oe()(r,a,[s]);else{const i=$()(t,a),[d]=(0,Mo.zJ)(i.at(-1)?.__temp_key__,null,1),m=[...i,{...s,__temp_key__:d}];oe()(r,a,m)}break}case"DISCONNECT_RELATION":{const a=["modifiedData",...o.keys],{id:s}=o,i=$()(t,[...a]).filter(d=>d.id!==s);oe()(r,a,i);break}case"MOVE_COMPONENT_FIELD":case"REORDER_RELATION":{const{oldIndex:a,newIndex:s,keys:c}=o,i=["modifiedData",...c],d=$()(t,[...i]),m=d[a],u=[...d];if(o.type==="REORDER_RELATION"){const p=a>s?d[s-1]?.__temp_key__:d[s]?.__temp_key__,y=a>s?d[s]?.__temp_key__:d[s+1]?.__temp_key__,[h]=(0,Mo.zJ)(p,y,1);u.splice(a,1),u.splice(s,0,{...m,__temp_key__:h})}else u.splice(a,1),u.splice(s,0,m);oe()(r,i,u);break}case"INIT_FORM":{const{initialValues:a,components:s={},attributes:c={},setModifiedDataOnly:i}=o,d=we()(a),u=Kt(s,h=>h.type==="relation",(h,{path:g})=>t.modifiedData?.id===d.id&&$()(t.modifiedData,g)?$()(t.modifiedData,g):[])(d,c),y=Kt(s,h=>h.type==="dynamiczone"||h.type==="component"&&!h.repeatable,h=>Array.isArray(h)?h.map((g,b)=>({...g,__temp_key__:b})):{...h,__temp_key__:0})(u,c,{ignoreFalseyValues:!0});i||(r.initialData=y),r.modifiedData=y,r.formErrors={},r.modifiedDZName=null,r.shouldCheckErrors=!1;break}case"MOVE_COMPONENT_UP":case"MOVE_COMPONENT_DOWN":{const{currentIndex:a,dynamicZoneName:s,shouldCheckErrors:c}=o;c&&(r.shouldCheckErrors=!t.shouldCheckErrors);const i=t.modifiedData[s],d=o.type==="MOVE_COMPONENT_UP"?a-1:a+1,m=t.modifiedData[s][a],u=ta(i,a,d,m);oe()(r,["modifiedData",o.dynamicZoneName],u);break}case"MOVE_FIELD":{const a=$()(t,["modifiedData",...o.keys],[]).slice(),s=$()(t,["modifiedData",...o.keys,o.dragIndex]),c=ta(a,o.dragIndex,o.overIndex,s);oe()(r,["modifiedData",...o.keys],c);break}case"ON_CHANGE":{const[a]=o.keys;if(o.shouldSetInitialValue&&oe()(r,["initialData",...o.keys],o.value),o.keys.length===2&&$()(t,["modifiedData",a])===null){oe()(r,["modifiedData",a],{[o.keys[1]]:o.value});break}oe()(r,["modifiedData",...o.keys],o.value);break}case"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE":{o.shouldCheckErrors&&(r.shouldCheckErrors=!t.shouldCheckErrors),r.modifiedData[o.dynamicZoneName].splice(o.index,1);break}case"REMOVE_COMPONENT_FROM_FIELD":{const a=["modifiedData",...o.keys];oe()(r,a,null);break}case"REMOVE_PASSWORD_FIELD":{fu()(r,["modifiedData",...o.keys]);break}case"REMOVE_REPEATABLE_FIELD":{const a=o.keys.length-1,s=["modifiedData",...St()(o.keys,a)];Object.keys(t.formErrors).length>0&&(r.shouldCheckErrors=!t.shouldCheckErrors);const i=$()(t,s).slice();i.splice(parseInt(o.keys[a],10),1),oe()(r,s,i);break}case"SET_DEFAULT_DATA_STRUCTURES":{r.componentsDataStructure=o.componentsDataStructure,r.contentTypeDataStructure=o.contentTypeDataStructure;break}case"SET_FORM_ERRORS":{r.modifiedDZName=null,r.formErrors=o.errors;break}case"TRIGGER_FORM_VALIDATION":{Object.keys(t.formErrors).length>0&&(r.shouldCheckErrors=!t.shouldCheckErrors);break}case"SET_PUBLISH_CONFIRMATION":{r.publishConfirmation={...o.publishConfirmation};break}case"RESET_PUBLISH_CONFIRMATION":{r.publishConfirmation={...t.publishConfirmation,show:!1};break}default:return r}});const To=({allLayoutData:t,allowedActions:{canRead:o,canUpdate:r},children:a,componentsDataStructure:s,contentTypeDataStructure:c,createActionAllowedFields:i,from:d,initialValues:m,isCreatingEntry:u,isLoadingForData:p,isSingleType:y,onPost:h,onPublish:g,onDraftRelationCheck:b,onPut:R,onUnpublish:x,readActionAllowedFields:C,redirectToPreviousPage:M,slug:Z,status:W,updateActionAllowedFields:T})=>{const[O,B]=e.useState(!1),[w,I]=(0,e.useReducer)(Tu,Mu),{formErrors:N,initialData:A,modifiedData:F,modifiedDZName:H,shouldCheckErrors:Q,publishConfirmation:X}=w,{setModifiedDataOnly:L}=(0,ae.v9)(Ln),S=(0,ae.I0)(),v=(0,f.lm)(),{lockApp:V,unlockApp:G}=(0,f.o1)(),K=$()(t,["contentType"],{}),k=(0,e.useMemo)(()=>$()(K,["options","draftAndPublish"],!1),[K]),j=(0,e.useMemo)(()=>k&&!A.publishedAt,[k,A.publishedAt]),{trackUsage:te}=(0,f.rS)(),{formatMessage:ue}=(0,Y.Z)(),fe=(0,e.useRef)(te),ye=(0,e.useMemo)(()=>p||u?!1:o===!1&&r===!1,[p,u,o,r]);(0,e.useEffect)(()=>{W==="resolved"?G():V()},[V,G,W]),(0,e.useEffect)(()=>{p||He()},[Q]),(0,e.useEffect)(()=>{const _=Object.keys(N);if(_.length>0){const J=_[0],ie=document.getElementById(J);ie&&ie.focus()}},[N]),(0,e.useEffect)(()=>{ye&&v({type:"info",message:{id:(0,E.OB)("permissions.not-allowed.update")}})},[ye,v]),(0,e.useEffect)(()=>{I({type:"SET_DEFAULT_DATA_STRUCTURES",componentsDataStructure:s,contentTypeDataStructure:c})},[s,c]);const{components:D}=t,ee=(0,ne.zH)(m);(0,e.useEffect)(()=>{m&&K?.attributes&&!Pe()(ee,m)&&(I({type:"INIT_FORM",initialValues:m,components:D,attributes:K.attributes,setModifiedDataOnly:L}),L&&S(Wl()))},[m,K,D,L,S,ee]);const pe=(0,e.useCallback)(_=>(J,ie,Se,lt=!1,Bt=void 0)=>{fe.current("didAddComponentToDynamicZone"),I({type:_,keys:J.split("."),position:Bt,componentLayoutData:ie,allComponents:Se,shouldCheckErrors:lt})},[]),Ie=pe("ADD_COMPONENT_TO_DYNAMIC_ZONE"),Ue=(0,e.useCallback)((_,J,ie)=>{I({type:"ADD_NON_REPEATABLE_COMPONENT_TO_FIELD",keys:_.split("."),componentLayoutData:J,allComponents:ie})},[]),ce=(0,e.useCallback)(({name:_,value:J,toOneRelation:ie})=>{I({type:"CONNECT_RELATION",keys:_.split("."),value:J,toOneRelation:ie})},[]),xe=(0,e.useCallback)(({target:{initialDataPath:_,modifiedDataPath:J,value:ie,modifiedDataOnly:Se}})=>{I({type:"LOAD_RELATION",modifiedDataPath:J,initialDataPath:_,value:ie,modifiedDataOnly:Se})},[]),je=pe("ADD_REPEATABLE_COMPONENT_TO_FIELD"),Ze=(0,e.useMemo)(()=>{const _={isCreatingEntry:u,isDraft:j,isFromComponent:!1};return(0,E.Ex)(K,{components:t.components||{}},_)},[t.components,K,u,j]),He=(0,e.useCallback)(async(_={})=>{let J={};const ie=we()(F);Ne()(ie)||oe()(ie,_.path,_.value);try{await Ze.validate(ie,{abortEarly:!1})}catch(Se){J=(0,f.CJ)(Se),H&&(J=Object.keys(J).reduce((lt,Bt)=>(Bt.split(".")[0]!==H&&(lt[Bt]=J[Bt]),lt),{}))}I({type:"SET_FORM_ERRORS",errors:J})},[H,F,Ze]),Rt=(0,e.useCallback)(({target:{name:_,value:J,type:ie}},Se=!1)=>{let lt=J;if(["text","textarea","string","email","uid","select","select-one","number"].includes(ie)&&!J&&J!==0&&(lt=null),ie==="password"&&!J){I({type:"REMOVE_PASSWORD_FIELD",keys:_.split(".")});return}I({type:"ON_CHANGE",keys:_.split("."),value:lt,shouldSetInitialValue:Se})},[]),it=(0,e.useCallback)((_,J)=>Ru({browserState:_,serverState:J},K,t.components),[t.components,K]),he=(0,e.useMemo)(()=>k?j?{status:"draft"}:{}:{},[k,j]),Me=(0,e.useCallback)(async _=>(_.preventDefault(),I({type:"RESET_PUBLISH_CONFIRMATION"})),[]),et=(0,e.useCallback)(async _=>{_.preventDefault();let J={};try{await Ze.validate(F,{abortEarly:!1})}catch(ie){J=(0,f.CJ)(ie)}try{if(Ne()(J)){const ie=it(F,A);(0,_r.flushSync)(()=>{B(!0)}),u?await h(ie,he):await R(ie,he),B(!1)}}catch(ie){B(!1),J={...J,...(0,f.nn)(ie,{getTrad:E.OB})}}I({type:"SET_FORM_ERRORS",errors:J})},[it,u,F,A,h,R,he,Ze]),se=(0,e.useCallback)(async()=>{const _=(0,E.Ex)(K,{components:$()(t,"components",{})},{isCreatingEntry:u,isDraft:!1,isFromComponent:!1}),J=await b();if(!X.show&&J>0){I({type:"SET_PUBLISH_CONFIRMATION",publishConfirmation:{show:!0,draftCount:J}});return}I({type:"RESET_PUBLISH_CONFIRMATION"});let ie={};try{await _.validate(F,{abortEarly:!1})}catch(Se){ie=(0,f.CJ)(Se)}try{Ne()(ie)&&((0,_r.flushSync)(()=>{B(!0)}),await g(),B(!1))}catch(Se){B(!1),ie={...ie,...(0,f.nn)(Se,{getTrad:E.OB})}}I({type:"SET_FORM_ERRORS",errors:ie})},[t,K,u,F,X.show,g,b]),de=(0,e.useCallback)(_=>{const J=Object.keys(N).some(Se=>Se.split(".")[0]===_);return!Ne()(N)&&J},[N]),Ee=(0,e.useCallback)((_,J)=>{fe.current("changeComponentsOrder"),I({type:"MOVE_COMPONENT_DOWN",dynamicZoneName:_,currentIndex:J,shouldCheckErrors:de(_)})},[de]),ve=(0,e.useCallback)((_,J)=>{fe.current("changeComponentsOrder"),I({type:"MOVE_COMPONENT_UP",dynamicZoneName:_,currentIndex:J,shouldCheckErrors:de(_)})},[de]),wt=(0,e.useCallback)(({name:_,newIndex:J,currentIndex:ie})=>{I({type:"MOVE_COMPONENT_FIELD",keys:_.split("."),newIndex:J,oldIndex:ie})},[]),qp=(0,e.useCallback)(({name:_,id:J})=>{I({type:"DISCONNECT_RELATION",keys:_.split("."),id:J})},[]),Hp=(0,e.useCallback)(({name:_,oldIndex:J,newIndex:ie})=>{I({type:"REORDER_RELATION",keys:_.split("."),oldIndex:J,newIndex:ie})},[]),Gp=(0,e.useCallback)((_,J)=>{fe.current("removeComponentFromDynamicZone"),I({type:"REMOVE_COMPONENT_FROM_DYNAMIC_ZONE",dynamicZoneName:_,index:J,shouldCheckErrors:de(_)})},[de]),Qp=(0,e.useCallback)((_,J)=>{I({type:"REMOVE_COMPONENT_FROM_FIELD",keys:_.split("."),componentUid:J})},[]),Kp=(0,e.useCallback)((_,J)=>{I({type:"REMOVE_REPEATABLE_FIELD",keys:_.split("."),componentUid:J})},[]),Yp=(0,e.useCallback)(()=>{I({type:"TRIGGER_FORM_VALIDATION"})},[]);return ye?e.createElement(re.l_,{to:d}):F?e.createElement(f.W1.Provider,{value:{addComponentToDynamicZone:Ie,addNonRepeatableComponentToField:Ue,addRepeatableComponentToField:je,allLayoutData:t,checkFormErrors:He,createActionAllowedFields:i,formErrors:N,hasDraftAndPublish:k,initialData:A,isCreatingEntry:u,isSingleType:y,shouldNotRunValidations:j,status:W,layout:K,modifiedData:F,moveComponentField:wt,moveComponentDown:Ee,moveComponentUp:ve,onChange:Rt,onPublish:se,onUnpublish:x,readActionAllowedFields:C,redirectToPreviousPage:M,removeComponentFromDynamicZone:Gp,removeComponentFromField:Qp,removeRepeatableField:Kp,relationConnect:ce,relationDisconnect:qp,relationLoad:xe,relationReorder:Hp,slug:Z,triggerFormValidation:Yp,updateActionAllowedFields:T,onPublishPromptDismissal:Me,publishConfirmation:X}},p||!u&&!A.id?e.createElement(Te.o,{"aria-busy":"true"},e.createElement(f.dO,null)):e.createElement(e.Fragment,null,O?null:e.createElement(re.NL,{when:!Pe()(F,A),message:ue({id:"global.prompt.unsaved"})}),e.createElement("form",{noValidate:!0,onSubmit:et},a))):null};To.defaultProps={from:"/",initialValues:null,redirectToPreviousPage(){}},To.propTypes={allLayoutData:n().object.isRequired,allowedActions:n().object.isRequired,children:n().node.isRequired,componentsDataStructure:n().object.isRequired,contentTypeDataStructure:n().object.isRequired,createActionAllowedFields:n().array.isRequired,from:n().string,initialValues:n().object,isCreatingEntry:n().bool.isRequired,isLoadingForData:n().bool.isRequired,isSingleType:n().bool.isRequired,onPost:n().func.isRequired,onPublish:n().func.isRequired,onDraftRelationCheck:n().func.isRequired,onPut:n().func.isRequired,onUnpublish:n().func.isRequired,readActionAllowedFields:n().array.isRequired,redirectToPreviousPage:n().func,slug:n().string.isRequired,status:n().string.isRequired,updateActionAllowedFields:n().array.isRequired};var Du=To;const Ou=(t={})=>Object.values(t).reduce((o,r)=>Object.assign(o,r),{});var na=(t={})=>{const{plugins:o,_q:r,...a}={...t,...Ou(t.plugins)};return r&&(a._q=encodeURIComponent(r)),a};const oa=({allLayoutData:t,children:o,slug:r})=>{const a=(0,Be.useQueryClient)(),{trackUsage:s}=(0,f.rS)(),{push:c}=(0,re.k6)(),{setCurrentStep:i}=(0,f.c1)(),d=(0,e.useRef)(s),[m,u]=(0,e.useState)(!0),[{query:p,rawQuery:y}]=(0,f.Kx)(),h=(0,e.useMemo)(()=>na(p),[p]),g=(0,f.lm)(),b=(0,ae.I0)(),{formatAPIError:R}=(0,f.So)(E.OB),x=(0,f.kY)(),{post:C,put:M,del:Z}=x,{componentsDataStructure:W,contentTypeDataStructure:T,data:O,isLoading:B,status:w}=(0,ae.v9)(Ln),I=(0,e.useCallback)(S=>{const v=(0,E.kc)(S,t.contentType,t.components);return(0,f.dU)(v,t.contentType,t.components)},[t]);(0,e.useEffect)(()=>()=>{b(Dr())},[b]),(0,e.useEffect)(()=>{const S=Object.keys(t.components).reduce((G,K)=>{const k=(0,E.Di)($()(t,["components",K,"attributes"],{}),t.components);return G[K]=(0,f.dU)(k,t.components[K],t.components),G},{}),v=(0,E.Di)(t.contentType.attributes,t.components),V=(0,f.dU)(v,t.contentType,t.components);b(Or(S,V))},[t,b]),(0,e.useEffect)(()=>{const v=ze.default.CancelToken.source();return(async G=>{b(Vt()),u(!0);try{const{data:K}=await x.get(`/content-manager/single-types/${r}`,{cancelToken:G.token,params:h});b(Zn(I(K))),u(!1)}catch(K){if(ze.default.isCancel(K))return;const k=$()(K,"response.status",null);k===404&&b(kn(y,!0)),k===403&&(g({type:"info",message:{id:(0,E.OB)("permissions.not-allowed.update")}}),c("/"))}})(v),()=>v.cancel("Operation canceled by the user.")},[x,I,c,r,b,h,y,g]);const N=(0,e.useCallback)(S=>{g({type:"warning",message:R(S)})},[g,R]),A=(0,e.useCallback)(async S=>{try{d.current("willDeleteEntry",S);const{data:v}=await Z(`/content-manager/single-types/${r}`,{params:h});return g({type:"success",message:{id:(0,E.OB)("success.record.delete")}}),d.current("didDeleteEntry",S),u(!0),b(kn(y,!0)),Promise.resolve(v)}catch(v){return d.current("didNotDeleteEntry",{error:v,...S}),N(v),Promise.reject(v)}},[Z,r,h,g,b,y,N]),F=(0,e.useCallback)(async(S,v)=>{const V=`/content-manager/single-types/${r}`;try{b(me("submit-pending"));const{data:G}=await M(V,S,{params:p});return d.current("didCreateEntry",v),g({type:"success",message:{id:(0,E.OB)("success.record.save")}}),i("contentManager.success"),a.invalidateQueries(["relation"]),b(Je(I(G))),u(!1),b(me("resolved")),Promise.resolve(G)}catch(G){return d.current("didNotCreateEntry",{error:G,trackerProperty:v}),N(G),b(me("resolved")),Promise.reject(G)}},[M,I,N,r,b,p,g,i,a]),H=(0,e.useCallback)(async()=>{try{d.current("willCheckDraftRelations");const S=`/content-manager/single-types/${r}/actions/countDraftRelations`;b(me("draft-relation-check-pending"));const v=await x.get(S);return d.current("didCheckDraftRelations"),b(me("resolved")),v.data.data}catch(S){return N(S),b(me("resolved")),Promise.reject(S)}},[x,N,r,b]),Q=(0,e.useCallback)(async()=>{try{d.current("willPublishEntry");const S=`/content-manager/single-types/${r}/actions/publish`;b(me("publish-pending"));const{data:v}=await C(S,{},{params:h});return d.current("didPublishEntry"),g({type:"success",message:{id:(0,E.OB)("success.record.publish")}}),b(Je(I(v))),b(me("resolved")),Promise.resolve(v)}catch(S){return N(S),b(me("resolved")),Promise.reject(S)}},[r,b,C,h,g,I,N]),X=(0,e.useCallback)(async(S,v)=>{const V=`/content-manager/single-types/${r}`;try{d.current("willEditEntry",v),b(me("submit-pending"));const{data:G}=await M(V,S,{params:p});return g({type:"success",message:{id:(0,E.OB)("success.record.save")}}),d.current("didEditEntry",{trackerProperty:v}),a.invalidateQueries(["relation"]),b(Je(I(G))),b(me("resolved")),Promise.resolve(G)}catch(G){return N(G),d.current("didNotEditEntry",{error:G,trackerProperty:v}),b(me("resolved")),Promise.reject(G)}},[M,I,N,r,b,p,g,a]),L=(0,e.useCallback)(async()=>{const S=`/content-manager/single-types/${r}/actions/unpublish`;b(me("unpublish-pending"));try{d.current("willUnpublishEntry");const{data:v}=await C(S,{},{params:h});d.current("didUnpublishEntry"),g({type:"success",message:{id:(0,E.OB)("success.record.unpublish")}}),b(Je(I(v))),b(me("resolved"))}catch(v){b(me("resolved")),N(v)}},[r,b,C,h,g,I,N]);return o({componentsDataStructure:W,contentTypeDataStructure:T,data:O,isCreatingEntry:m,isLoadingForData:B,onDelete:A,onPost:F,onDraftRelationCheck:H,onPublish:Q,onPut:X,onUnpublish:L,redirectionLink:"/",status:w})};oa.propTypes={allLayoutData:n().shape({components:n().object.isRequired,contentType:n().object.isRequired}).isRequired,children:n().func.isRequired,slug:n().string.isRequired};var Pu=(0,e.memo)(oa);function Iu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var xu=Iu;function Zu(){const{hasDraftAndPublish:t,modifiedData:o}=(0,f.Wq)();let r={};return t&&(r=Ne()(o.publishedAt)?{status:"draft"}:{status:"published"}),{hasDraftAndPublish:t,trackerProperty:r}}var ku=Zu;const ra=({onDelete:t,trackerProperty:o})=>{const[r,a]=(0,e.useState)(!1),[s,c]=(0,e.useState)(!1),{formatMessage:i}=(0,Y.Z)(),{formatAPIError:d}=(0,f.So)(E.OB),m=(0,f.lm)(),u=()=>a(y=>!y),p=async()=>{try{c(!0),await t(o),c(!1),u()}catch(y){c(!1),u(),m({type:"warning",message:d(y)})}};return e.createElement(e.Fragment,null,e.createElement(le.z,{onClick:u,size:"S",startIcon:e.createElement(Ve.Z,null),variant:"danger-light"},i({id:(0,E.OB)("containers.Edit.delete-entry"),defaultMessage:"Delete this entry"})),e.createElement(f.QH,{isConfirmButtonLoading:s,isOpen:r,onConfirm:p,onToggleDialog:u}))};ra.propTypes={onDelete:n().func.isRequired,trackerProperty:n().object.isRequired};const Lu=(0,e.memo)(ra,Pe());var Su=xu(Lu,ku),Au=l(56243);function Fu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var $u=Fu;function wu(){const{initialData:t,hasDraftAndPublish:o}=(0,f.Wq)(),r=t.publishedAt!==void 0&&t.publishedAt!==null;return{hasDraftAndPublish:o,isPublished:r}}var Bu=wu;const Nu=(0,U.ZP)(Au.Z)`
948
- width: ${(0,f.Q1)(6)};
949
- height: ${(0,f.Q1)(6)};
950
- * {
951
- fill: ${({theme:t,$bulletColor:o})=>t.colors[o]};
952
- }
953
- `,aa=({hasDraftAndPublish:t,isPublished:o})=>{const{formatMessage:r}=(0,Y.Z)();if(!t)return null;const a={draft:{textColor:"secondary700",bulletColor:"secondary600",box:{background:"secondary100",borderColor:"secondary200"}},published:{textColor:"success700",bulletColor:"success600",box:{background:"success100",borderColor:"success200"}}},s=o?a.published:a.draft;return e.createElement(q.x,{hasRadius:!0,as:"aside",paddingTop:4,paddingBottom:4,paddingLeft:5,paddingRight:5,...s.box},e.createElement(q.x,{as:P.k},e.createElement(Nu,{$bulletColor:s.bulletColor}),e.createElement(q.x,{paddingLeft:3},e.createElement(z.Z,{textColor:s.textColor},r({id:(0,E.OB)("containers.Edit.information.editing"),defaultMessage:"Editing"}),"\xA0"),e.createElement(z.Z,{fontWeight:"bold",textColor:s.textColor},o&&r({id:(0,E.OB)("containers.Edit.information.publishedVersion"),defaultMessage:"published version"}),!o&&r({id:(0,E.OB)("containers.Edit.information.draftVersion"),defaultMessage:"draft version"})))))};aa.propTypes={hasDraftAndPublish:n().bool.isRequired,isPublished:n().bool.isRequired};var ju=$u(aa,Bu);const Do=({columns:t,customFieldInputs:o})=>e.createElement(Oe.r,{gap:4},t.map(({fieldSchema:r,labelAction:a,metadatas:s,name:c,size:i,queryInfos:d})=>{if(r.type==="component"){const{component:u,max:p,min:y,repeatable:h=!1,required:g=!1}=r;return e.createElement(be.P,{col:i,s:12,xs:12,key:u},e.createElement(Qt,{componentUid:u,labelAction:a,isRepeatable:h,intlLabel:{id:s.label,defaultMessage:s.label},max:p,min:y,name:c,required:g}))}return e.createElement(be.P,{col:i,key:c,s:12,xs:12},e.createElement(po,{size:i,fieldSchema:r,keys:c,labelAction:a,metadatas:s,queryInfos:d,customFieldInputs:o}))}));Do.defaultProps={customFieldInputs:{}},Do.propTypes={columns:n().array.isRequired,customFieldInputs:n().object};var Wu=Do,Yt=l(22342),Xt=l(96166),Jt=l(88693);function zu(t,o){return r=>{const a=o();return e.createElement(t,{...r,...a})}}var Uu=zu;function Vu(){const{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:c,modifiedData:i,onPublish:d,onUnpublish:m,publishConfirmation:u,onPublishPromptDismissal:p}=(0,f.Wq)();return{initialData:t,isCreatingEntry:o,isSingleType:r,status:a,layout:s,hasDraftAndPublish:c,modifiedData:i,onPublish:d,onUnpublish:m,publishConfirmation:u,onPublishPromptDismissal:p}}var qu=Vu;const sa=(0,U.ZP)(P.k)`
954
- text-align: center;
955
- `,ia=({allowedActions:{canUpdate:t,canCreate:o,canPublish:r},initialData:a,isCreatingEntry:s,isSingleType:c,hasDraftAndPublish:i,layout:d,modifiedData:m,onPublish:u,onUnpublish:p,status:y,publishConfirmation:{show:h,draftCount:g},onPublishPromptDismissal:b})=>{const{goBack:R}=(0,re.k6)(),[x,C]=(0,e.useState)(!1),{formatMessage:M}=(0,Y.Z)(),Z=$()(d,["settings","mainField"],"id"),W=$()(d,["info","displayName"],"NOT FOUND"),T=!Pe()(a,m)||s&&!Ne()(m);let B=M({id:(0,E.OB)("containers.Edit.pluginHeader.title.new"),defaultMessage:"Create an entry"});!s&&!c&&(B=a[Z]||W),c&&(B=W);let w=null;if(s&&o&&(w=e.createElement(P.k,{gap:2},i&&e.createElement(le.z,{disabled:!0,startIcon:e.createElement($e.Z,null),variant:"secondary"},M({id:"app.utils.publish",defaultMessage:"Publish"})),e.createElement(le.z,{disabled:!T,loading:y==="submit-pending",type:"submit"},M({id:(0,E.OB)("containers.Edit.submit"),defaultMessage:"Save"})))),!s&&t){const F=i&&r,H=!Ne()(a.publishedAt),Q=H?y==="unpublish-pending":y==="publish-pending",X=H?{id:"app.utils.unpublish",defaultMessage:"Unpublish"}:{id:"app.utils.publish",defaultMessage:"Publish"},L=H?()=>C(!0):()=>u();w=e.createElement(P.k,null,F&&e.createElement(le.z,{disabled:T,loading:Q,onClick:L,startIcon:e.createElement($e.Z,null),variant:"secondary"},M(X)),e.createElement(q.x,{paddingLeft:F?2:0},e.createElement(le.z,{disabled:!T,loading:y==="submit-pending",type:"submit"},M({id:(0,E.OB)("containers.Edit.submit"),defaultMessage:"Save"}))))}const I=()=>C(F=>!F),N=()=>{I(),p()},A=`${M({id:(0,E.OB)("api.id"),defaultMessage:"API ID "})} : ${d.apiID}`;return e.createElement(e.Fragment,null,e.createElement(De.T,{title:B.toString(),primaryAction:w,subtitle:A,navigationAction:e.createElement(f.rU,{startIcon:e.createElement(ot.Z,null),onClick:F=>{F.preventDefault(),R()},to:"/"},M({id:"global.back",defaultMessage:"Back"}))}),e.createElement(Yt.V,{onClose:I,title:"Confirmation",labelledBy:"confirmation",describedBy:"confirm-description",isOpen:x},e.createElement(Xt.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(P.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(z.Z,{id:"confirm-description"},M({id:(0,E.OB)("popUpWarning.warning.unpublish"),defaultMessage:"Unpublish this content will automatically change it to a draft."},{br:()=>e.createElement("br",null)}))),e.createElement(P.k,{justifyContent:"center",style:{textAlign:"center"}},e.createElement(z.Z,{id:"confirm-description"},M({id:(0,E.OB)("popUpWarning.warning.unpublish-question"),defaultMessage:"Are you sure you want to unpublish it?"}))))),e.createElement(Jt.c,{startAction:e.createElement(le.z,{onClick:I,variant:"tertiary"},M({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{variant:"danger-light",onClick:N},M({id:"components.popUpWarning.button.confirm",defaultMessage:"Confirm"}))})),e.createElement(Yt.V,{onClose:b,title:M({id:(0,E.OB)("popUpWarning.warning.has-draft-relations.title"),defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:h},e.createElement(Xt.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(sa,{justifyContent:"center"},e.createElement(z.Z,{id:"confirm-description"},g,M({id:(0,E.OB)("popUpwarning.warning.has-draft-relations.message"),defaultMessage:"<b>{count, plural, one { relation is} other { relations are}}</b> not published yet and might lead to unexpected behavior."},{b:F=>e.createElement(z.Z,{fontWeight:"bold"},F),count:g}))),e.createElement(sa,{justifyContent:"center"},e.createElement(z.Z,{id:"confirm-description"},M({id:(0,E.OB)("popUpWarning.warning.publish-question"),defaultMessage:"Do you still want to publish?"}))))),e.createElement(Jt.c,{startAction:e.createElement(le.z,{onClick:b,variant:"tertiary"},M({id:"components.popUpWarning.button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{variant:"success",onClick:u},M({id:(0,E.OB)("popUpwarning.warning.has-draft-relations.button-confirm"),defaultMessage:"Publish"}))})))};ia.propTypes={allowedActions:n().shape({canUpdate:n().bool.isRequired,canCreate:n().bool.isRequired,canPublish:n().bool.isRequired}).isRequired,initialData:n().object.isRequired,isCreatingEntry:n().bool.isRequired,isSingleType:n().bool.isRequired,status:n().string.isRequired,layout:n().object.isRequired,hasDraftAndPublish:n().bool.isRequired,modifiedData:n().object.isRequired,onPublish:n().func.isRequired,onUnpublish:n().func.isRequired,publishConfirmation:n().shape({show:n().bool.isRequired,draftCount:n().number.isRequired}).isRequired,onPublishPromptDismissal:n().func.isRequired};const Hu=(0,e.memo)(ia,Pe());var Gu=Uu(Hu,qu);const Qu=t=>(0,e.useEffect)(t,Ku),Ku=[];var Oo=l(98865);function Yu(){return e.createElement(Oo.d.Root,null,e.createElement(Oo.d.Title,null),e.createElement(Oo.d.Body,null))}var Po=l(98178),Xu=t=>{if(!t.layouts)return[];const o=t.layouts.edit,r=t.attributes,a=i=>$()(r,[i,"type"],"");let s=0;const c=[];return o.forEach(i=>{const d=i.some(({name:m})=>a(m)==="dynamiczone");c[s]||(c[s]=[]),d?(s=s===0&&Ne()(c[0])?0:s+1,c[s]||(c[s]=[]),c[s].push(i),s+=1):c[s].push(i)}),c.filter(i=>i.length>0)},Ju=t=>{if(!t)return[];const r=[...t.contentType.layouts.edit,...Object.values(t.components).flatMap(s=>s.layouts.edit)].flat().filter(s=>s.fieldSchema.customField).map(s=>s.fieldSchema.customField);return[...new Set(r)]},_u=l(3704),em=l.n(_u),tm=l(91815),nm=l.n(tm),om=(t,o)=>{const r=a=>{const s=(0,f.ZT)(t,[{action:`plugin::content-manager.explorer.${a}`,subject:o}]);return nm()(em()(s,"properties.fields"))};return{createActionAllowedFields:r("create"),readActionAllowedFields:r("read"),updateActionAllowedFields:r("update")}};const Io=t=>t["content-manager_editViewLayoutManager"].currentLayout,rm=(0,Po.P1)(Io,t=>Xu(t?.contentType??{})),am=(0,Po.P1)(Io,t=>Ju(t)),sm=[{action:"plugin::content-type-builder.read",subject:null}],xo=({allowedActions:t,isSingleType:o,goBack:r,slug:a,id:s,origin:c,userPermissions:i})=>{const{trackUsage:d}=(0,f.rS)(),{formatMessage:m}=(0,Y.Z)(),u=(0,ae.v9)(We._),p=(0,re.TH)(),y=(0,f.lm)(),h=(0,xn.c)(Yu,async()=>(await l.e(5483).then(l.bind(l,90978))).InformationBoxEE);Qu(()=>{p?.state&&"error"in p.state&&y({type:"warning",message:p.state.error,timeout:5e3})});const{layout:g,formattedContentTypeLayout:b,customFieldUids:R}=(0,ae.v9)(I=>({layout:Io(I),formattedContentTypeLayout:rm(I),customFieldUids:am(I)})),{isLazyLoading:x,lazyComponentStore:C}=Vn(R),{createActionAllowedFields:M,readActionAllowedFields:Z,updateActionAllowedFields:W}=om(i,a),T=o?u.contentManager.singleTypesConfigurations:u.contentManager.collectionTypesConfigurations,O=`/content-manager/${o?"singleType":"collectionType"}/${a}/configurations/edit`,B=o?Pu:zl,w=I=>I.every(N=>N.every(A=>A.fieldSchema.type==="dynamiczone"));return x?e.createElement(f.dO,null):h?e.createElement(B,{allLayoutData:g,slug:a,id:s,origin:c},({componentsDataStructure:I,contentTypeDataStructure:N,data:A,isCreatingEntry:F,isLoadingForData:H,onDelete:Q,onPost:X,onPublish:L,onDraftRelationCheck:S,onPut:v,onUnpublish:V,redirectionLink:G,status:K})=>e.createElement(Du,{allowedActions:t,allLayoutData:g,createActionAllowedFields:M,componentsDataStructure:I,contentTypeDataStructure:N,from:G,initialValues:A,isCreatingEntry:F,isLoadingForData:H,isSingleType:o,onPost:X,onPublish:L,onDraftRelationCheck:S,onPut:v,onUnpublish:V,readActionAllowedFields:Z,redirectToPreviousPage:r,slug:a,status:K,updateActionAllowedFields:W},e.createElement(Te.o,{"aria-busy":K!=="resolved"},e.createElement(Gu,{allowedActions:t}),e.createElement(Qe.D,null,e.createElement(Oe.r,{gap:4},e.createElement(be.P,{col:9,s:12},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},b.map((k,j)=>{if(w(k)){const{0:{0:{name:te,fieldSchema:ue,metadatas:fe,labelAction:ye}}}=k;return e.createElement(q.x,{key:j},e.createElement(Oe.r,{gap:4},e.createElement(be.P,{col:12,s:12,xs:12},e.createElement(Ro,{name:te,fieldSchema:ue,labelAction:ye,metadatas:fe}))))}return e.createElement(q.x,{key:j,hasRadius:!0,background:"neutral0",shadow:"tableShadow",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,borderColor:"neutral150"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:6},k.map((te,ue)=>e.createElement(Wu,{columns:te,customFieldInputs:C,key:ue}))))}))),e.createElement(be.P,{col:3,s:12},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(ju,null),e.createElement(q.x,{as:"aside","aria-labelledby":"additional-information",background:"neutral0",borderColor:"neutral150",hasRadius:!0,paddingBottom:4,paddingLeft:4,paddingRight:4,paddingTop:6,shadow:"tableShadow"},e.createElement(h,null),e.createElement(Ut,{area:"contentManager.editView.informations"})),e.createElement(q.x,{as:"aside","aria-labelledby":"links"},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(Ut,{area:"contentManager.editView.right-links",slug:a}),a!=="strapi::administrator"&&e.createElement(f.jW,{permissions:sm},e.createElement(f.Qj,{onClick:()=>{d("willEditEditLayout")},size:"S",startIcon:e.createElement(Ke.Z,null),style:{width:"100%"},to:`/plugins/content-type-builder/content-types/${a}`,variant:"secondary"},m({id:(0,E.OB)("link-to-ctb"),defaultMessage:"Edit the model"}))),e.createElement(f.jW,{permissions:T},e.createElement(f.Qj,{size:"S",startIcon:e.createElement(ar.Z,null),style:{width:"100%"},to:O,variant:"secondary"},m({id:"app.links.configure-view",defaultMessage:"Configure the view"}))),t.canDelete&&!F&&e.createElement(Su,{onDelete:Q})))))))))):null};xo.defaultProps={id:null,isSingleType:!1,origin:null,userPermissions:[]},xo.propTypes={allowedActions:n().shape({canRead:n().bool.isRequired,canUpdate:n().bool.isRequired,canCreate:n().bool.isRequired,canDelete:n().bool.isRequired}).isRequired,id:n().string,isSingleType:n().bool,goBack:n().func.isRequired,origin:n().string,slug:n().string.isRequired,userPermissions:n().array};var im=xo;const Zo=t=>{const o=(0,e.useMemo)(()=>(0,E.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,f.ss)(o,t.userPermissions);return r?e.createElement(f.dO,null):e.createElement(im,{...t,allowedActions:a})};Zo.defaultProps={permissions:[]},Zo.propTypes={permissions:n().array,slug:n().string.isRequired,userPermissions:n().array.isRequired};var lm=(0,e.memo)(Zo,Pe()),cm=l(53634);const la=({layout:t,...o})=>{const r=(0,ae.v9)(cm.Z),a=(0,ae.I0)(),[{query:s}]=(0,f.Kx)(),{runHookWaterfall:c}=(0,f.j1)(),i=(0,ne.r5)(s,o.slug,"editView");return(0,e.useEffect)(()=>{const d=c(zt.Eo,{layout:t,query:s});return a(Bl(d.layout,s)),()=>{a(wl())}},[t,a,s,c]),!r||!i?e.createElement(f.dO,null):e.createElement(lm,{...o,userPermissions:i})};la.propTypes={layout:n().shape({components:n().object.isRequired,contentType:n().shape({uid:n().string.isRequired,settings:n().object.isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,attributes:n().object.isRequired}).isRequired}).isRequired};var _t=la,ko=l(33348);const dm=(0,U.ZP)(P.k)`
956
- svg {
957
- width: ${32/16}rem;
958
- height: ${24/16}rem;
959
- margin-right: ${({theme:t})=>t.spaces[3]};
960
- }
961
- `,ca=({attributes:t,fieldForm:o,fieldToEdit:r,onCloseModal:a,onChangeEditLabel:s,onSubmit:c,type:i})=>{const{formatMessage:d}=(0,Y.Z)(),m=t[r].relationType;let u=!["media","relation"].includes(i);return["oneWay","oneToOne","manyToOne"].includes(m)&&(u=!0),e.createElement(gn.P,{onClose:a,labelledBy:"title"},e.createElement("form",{onSubmit:c},e.createElement(fn.x,null,e.createElement(dm,null,e.createElement(Er,{type:i}),e.createElement(z.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},d({id:(0,E.OB)("containers.ListSettingsView.modal-form.edit-label"),defaultMessage:"Edit {fieldName}"},{fieldName:rt()(r)})))),e.createElement(hn.f,null,e.createElement(Oe.r,{gap:4},e.createElement(be.P,{s:12,col:6},e.createElement(Cn.o,{id:"label-input",label:d({id:(0,E.OB)("form.Input.label"),defaultMessage:"Label"}),name:"label",onChange:p=>s(p),value:o.label,hint:d({id:(0,E.OB)("form.Input.label.inputDescription"),defaultMessage:"This value overrides the label displayed in the table's head"})})),u&&e.createElement(be.P,{s:12,col:6},e.createElement(kt.s,{"data-testid":"Enable sort on this field",checked:o.sortable,label:d({id:(0,E.OB)("form.Input.sort.field"),defaultMessage:"Enable sort on this field"}),name:"sortable",onChange:p=>s({target:{name:"sortable",value:p.target.checked}}),onLabel:d({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:d({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"})})))),e.createElement(yn.m,{startActions:e.createElement(le.z,{onClick:a,variant:"tertiary"},d({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(le.z,{type:"submit"},d({id:"global.finish",defaultMessage:"Finish"}))})))};ca.propTypes={attributes:n().objectOf(n().shape({relationType:n().string})).isRequired,fieldForm:n().shape({label:n().string,sortable:n().bool}).isRequired,fieldToEdit:n().string.isRequired,onChangeEditLabel:n().func.isRequired,onCloseModal:n().func.isRequired,onSubmit:n().func.isRequired,type:n().string.isRequired};const Lo=({modifiedData:t,onChange:o,sortOptions:r})=>{const{formatMessage:a}=(0,Y.Z)(),{settings:s,metadatas:c}=t;return e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(z.Z,{variant:"delta",as:"h2"},a({id:(0,E.OB)("containers.SettingPage.settings"),defaultMessage:"Settings"})),e.createElement(P.k,{justifyContent:"space-between",gap:4},e.createElement(q.x,{width:"100%"},e.createElement(kt.s,{label:a({id:(0,E.OB)("form.Input.search"),defaultMessage:"Enable search"}),onChange:i=>{o({target:{name:"settings.searchable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.searchable",checked:s.searchable})),e.createElement(q.x,{width:"100%"},e.createElement(kt.s,{label:a({id:(0,E.OB)("form.Input.filters"),defaultMessage:"Enable filters"}),onChange:i=>{o({target:{name:"settings.filterable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.filterable",checked:s.filterable})),e.createElement(q.x,{width:"100%"},e.createElement(kt.s,{label:a({id:(0,E.OB)("form.Input.bulkActions"),defaultMessage:"Enable bulk actions"}),onChange:i=>{o({target:{name:"settings.bulkable",value:i.target.checked}})},onLabel:a({id:"app.components.ToggleCheckbox.on-label",defaultMessage:"on"}),offLabel:a({id:"app.components.ToggleCheckbox.off-label",defaultMessage:"off"}),name:"settings.bulkable",checked:s.bulkable}))),e.createElement(Oe.r,{gap:4},e.createElement(be.P,{s:12,col:6},e.createElement(Fe.P,{label:a({id:(0,E.OB)("form.Input.pageEntries"),defaultMessage:"Entries per page"}),hint:a({id:(0,E.OB)("form.Input.pageEntries.inputDescription"),defaultMessage:"Note: You can override this value in the Collection Type settings page."}),onChange:i=>o({target:{name:"settings.pageSize",value:i}}),name:"settings.pageSize",value:t.settings.pageSize||""},[10,20,50,100].map(i=>e.createElement(Ce.W,{key:i,value:i},i)))),e.createElement(be.P,{s:12,col:3},e.createElement(Fe.P,{label:a({id:(0,E.OB)("form.Input.defaultSort"),defaultMessage:"Default sort attribute"}),onChange:i=>o({target:{name:"settings.defaultSortBy",value:i}}),name:"settings.defaultSortBy",value:t.settings.defaultSortBy||""},r.map(i=>e.createElement(Ce.W,{key:i,value:i},c[i].list.label||i)))),e.createElement(be.P,{s:12,col:3},e.createElement(Fe.P,{label:a({id:(0,E.OB)("form.Input.sort.order"),defaultMessage:"Default sort order"}),onChange:i=>o({target:{name:"settings.defaultSortOrder",value:i}}),name:"settings.defaultSortOrder",value:t.settings.defaultSortOrder||""},["ASC","DESC"].map(i=>e.createElement(Ce.W,{key:i,value:i},i))))))};Lo.defaultProps={modifiedData:{},sortOptions:[]},Lo.propTypes={modifiedData:n().object,onChange:n().func.isRequired,sortOptions:n().array};const So=(0,U.ZP)(P.k)`
962
- height: ${({theme:t})=>t.spaces[7]};
963
-
964
- &:last-child {
965
- padding: 0 ${({theme:t})=>t.spaces[3]};
966
- }
967
- `,um=(0,U.ZP)(So)`
968
- border-right: 1px solid
969
- ${({theme:t,isSibling:o})=>o?t.colors.neutral150:t.colors.primary200};
970
-
971
- svg {
972
- width: ${12/16}rem;
973
- height: ${12/16}rem;
974
- }
975
- `,mm=(0,U.ZP)(P.k)`
976
- border: 1px solid
977
- ${({theme:t,isSibling:o})=>o?t.colors.neutral150:t.colors.primary200};
978
-
979
- svg {
980
- width: ${10/16}rem;
981
- height: ${10/16}rem;
982
-
983
- path {
984
- fill: ${({theme:t,isSibling:o})=>o?void 0:t.colors.primary600};
985
- }
986
- }
987
- `,pm=(0,U.ZP)(z.Z)`
988
- max-width: ${72/16}rem;
989
- `;function $t({labelField:t,transparent:o,isSibling:r}){return e.createElement(mm,{background:r?"neutral100":"primary100",display:"inline-flex",gap:3,hasRadius:!0,justifyContent:"space-between",transparent:o,isSibling:r,"max-height":(0,f.Q1)(32),maxWidth:"min-content",opacity:o?0:1},e.createElement(P.k,{gap:3},e.createElement(um,{alignItems:"center",cursor:"all-scroll",padding:3},e.createElement(Ye.Z,null)),e.createElement(pm,{textColor:r?void 0:"primary600",fontWeight:"bold",ellipsis:!0},t)),e.createElement(P.k,null,e.createElement(So,{alignItems:"center"},e.createElement(Ke.Z,null)),e.createElement(So,{alignItems:"center"},e.createElement(qt.Z,null))))}$t.defaultProps={isSibling:!1,transparent:!1},$t.propTypes={isSibling:n().bool,labelField:n().string.isRequired,transparent:n().bool};const Ao=U.ZP.button`
990
- display: flex;
991
- align-items: center;
992
- height: ${({theme:t})=>t.spaces[7]};
993
-
994
- &:last-child {
995
- padding: 0 ${({theme:t})=>t.spaces[3]};
996
- }
997
- `,da=(0,U.ZP)(Ao)`
998
- padding: 0 ${({theme:t})=>t.spaces[3]};
999
- border-right: 1px solid ${({theme:t})=>t.colors.neutral150};
1000
- cursor: all-scroll;
1001
-
1002
- svg {
1003
- width: ${12/16}rem;
1004
- height: ${12/16}rem;
1005
- }
1006
- `,gm=(0,U.ZP)(P.k)`
1007
- max-height: ${32/16}rem;
1008
- cursor: pointer;
1009
-
1010
- svg {
1011
- width: ${10/16}rem;
1012
- height: ${10/16}rem;
1013
-
1014
- path {
1015
- fill: ${({theme:t})=>t.colors.neutral600};
1016
- }
1017
- }
1018
-
1019
- &:hover {
1020
- background-color: ${({theme:t})=>t.colors.primary100};
1021
- border-color: ${({theme:t})=>t.colors.primary200};
1022
-
1023
- svg {
1024
- path {
1025
- fill: ${({theme:t})=>t.colors.primary600};
1026
- }
1027
- }
1028
-
1029
- ${z.Z} {
1030
- color: ${({theme:t})=>t.colors.primary600};
1031
- }
1032
-
1033
- ${da} {
1034
- border-right: 1px solid ${({theme:t})=>t.colors.primary200};
1035
- }
1036
- }
1037
- `,fm=(0,U.ZP)(q.x)`
1038
- &:last-child {
1039
- padding-right: ${({theme:t})=>t.spaces[3]};
1040
- }
1041
- `,ua=({index:t,isDraggingSibling:o,labelField:r,onClickEditField:a,onMoveField:s,onRemoveField:c,name:i,setIsDraggingSibling:d})=>{const{formatMessage:m}=(0,Y.Z)(),u=(0,e.useRef)(null),p=(0,e.useRef)(null),[,y]=(0,e.useState)(!1),h=(0,e.useRef)(),g=()=>{h.current&&h.current.click()},[,b]=(0,jt.useDrop)({accept:E._Q.FIELD,hover(Z,W){if(!p.current)return;const T=Z.index,O=t;if(T===O)return;const B=p.current.getBoundingClientRect(),w=(B.right-B.left)/2,N=W.getClientOffset().x-B.left;T>O&&N>w||T<O&&N<w||(s(T,O),Z.index=O)}}),[{isDragging:R},x,C]=(0,jt.useDrag)({type:E._Q.FIELD,item(){return{index:t,labelField:r,name:i}},collect:Z=>({isDragging:Z.isDragging()}),end(){d(!1)}});(0,e.useEffect)(()=>{C((0,It.rX)(),{captureDraggingState:!1})},[C]),(0,e.useEffect)(()=>{R&&d(!0)},[R,d]),(0,e.useEffect)(()=>{o||y(Z=>!Z)},[o]);const M={dragRef:x(u),dropRef:b(p)};return e.createElement(fm,{ref:M?M.dropRef:null},R&&e.createElement($t,{transparent:!0,labelField:r}),!R&&o&&e.createElement($t,{isSibling:!0,labelField:r}),!R&&!o&&e.createElement(gm,{borderColor:"neutral150",background:"neutral100",hasRadius:!0,justifyContent:"space-between",onClick:g,isDragging:R},e.createElement(P.k,{gap:3},e.createElement(da,{as:"span","aria-label":m({id:(0,E.OB)("components.DraggableCard.move.field"),defaultMessage:"Move {item}"},{item:r}),onClick:Z=>Z.stopPropagation(),ref:M.dragRef,type:"button"},e.createElement(Ye.Z,null)),e.createElement(z.Z,{fontWeight:"bold"},r)),e.createElement(P.k,{paddingLeft:3},e.createElement(Ao,{ref:h,onClick:Z=>{Z.stopPropagation(),a(i)},"aria-label":m({id:(0,E.OB)("components.DraggableCard.edit.field"),defaultMessage:"Edit {item}"},{item:r}),type:"button"},e.createElement(Ke.Z,null)),e.createElement(Ao,{onClick:c,"data-testid":`delete-${i}`,"aria-label":m({id:(0,E.OB)("components.DraggableCard.delete.field"),defaultMessage:"Delete {item}"},{item:r}),type:"button"},e.createElement(qt.Z,null)))))};ua.propTypes={index:n().number.isRequired,isDraggingSibling:n().bool.isRequired,labelField:n().string.isRequired,name:n().string.isRequired,onClickEditField:n().func.isRequired,onMoveField:n().func.isRequired,onRemoveField:n().func.isRequired,setIsDraggingSibling:n().func.isRequired};var hm=ua;const ma=({displayedFields:t,listRemainingFields:o,metadatas:r,onAddField:a,onClickEditField:s,onMoveField:c,onRemoveField:i})=>{const{formatMessage:d}=(0,Y.Z)(),[m,u]=(0,e.useState)(!1),[p,y]=(0,e.useState)(null),h=(0,e.useRef)();function g(...R){y("add"),a(...R)}function b(...R){y("remove"),i(...R)}return(0,e.useEffect)(()=>{p==="add"&&h?.current&&(h.current.scrollLeft=h.current.scrollWidth)},[t,p]),e.createElement(P.k,{alignItems:"stretch",direction:"column",gap:4},e.createElement(z.Z,{variant:"delta",as:"h2"},d({id:(0,E.OB)("containers.SettingPage.view"),defaultMessage:"View"})),e.createElement(P.k,{padding:4,borderColor:"neutral300",borderStyle:"dashed",borderWidth:"1px",hasRadius:!0},e.createElement(q.x,{flex:"1",overflow:"scroll hidden",ref:h},e.createElement(P.k,{gap:3},t.map((R,x)=>e.createElement(hm,{key:R,index:x,isDraggingSibling:m,onMoveField:c,onClickEditField:s,onRemoveField:C=>b(C,x),name:R,labelField:r[R].list.label||R,setIsDraggingSibling:u})))),e.createElement(ge.fC,null,e.createElement(ge.xz,{paddingLeft:2,paddingRight:2,justifyContent:"center",endIcon:null,disabled:o.length<=0,variant:"tertiary"},e.createElement(_e.T,{as:"span"},d({id:(0,E.OB)("components.FieldSelect.label"),defaultMessage:"Add a field"})),e.createElement(pt.Z,{"aria-hidden":!0,focusable:!1,style:{position:"relative",top:2}})),e.createElement(ge.VY,null,o.map(R=>e.createElement(ge.ck,{key:R,onSelect:()=>g(R)},r[R].list.label||R))))))};ma.propTypes={displayedFields:ke.PropTypes.array.isRequired,listRemainingFields:ke.PropTypes.array.isRequired,metadatas:ke.PropTypes.objectOf(ke.PropTypes.shape({list:ke.PropTypes.shape({label:ke.PropTypes.string})})).isRequired,onAddField:ke.PropTypes.func.isRequired,onClickEditField:ke.PropTypes.func.isRequired,onMoveField:ke.PropTypes.func.isRequired,onRemoveField:ke.PropTypes.func.isRequired};const ym=["media","richtext","dynamiczone","relation","component","json"],Fo={fieldForm:{},fieldToEdit:"",initialData:{},modifiedData:{}};var Em=(t=Fo,o)=>(0,Dn.ZP)(t,r=>{const a=["modifiedData","layouts","list"];switch(o.type){case"ADD_FIELD":{const s=$()(t,a,[]);oe()(r,a,[...s,o.item]);break}case"MOVE_FIELD":{const s=$()(t,a,[]),{originalIndex:c,atIndex:i}=o;oe()(r,a,(0,E.W3)(s,c,i));break}case"ON_CHANGE":{oe()(r,["modifiedData",...o.keys.split(".")],o.value);break}case"ON_CHANGE_FIELD_METAS":{oe()(r,["fieldForm",o.name],o.value);break}case"REMOVE_FIELD":{const s=$()(t,a,[]);oe()(r,a,s.filter((c,i)=>o.index!==i));break}case"SET_FIELD_TO_EDIT":{const{fieldToEdit:s}=o;r.fieldToEdit=s,r.fieldForm.label=$()(r,["modifiedData","metadatas",s,"list","label"],""),r.fieldForm.sortable=$()(r,["modifiedData","metadatas",s,"list","sortable"],"");break}case"UNSET_FIELD_TO_EDIT":{r.fieldForm={},r.fieldToEdit="";break}case"SUBMIT_FIELD_FORM":{const s=["modifiedData","metadatas",t.fieldToEdit,"list"];oe()(r,[...s,"label"],t.fieldForm.label),oe()(r,[...s,"sortable"],t.fieldForm.sortable);break}default:return r}});const pa=({layout:t,slug:o})=>{const{put:r}=(0,f.kY)(),{formatMessage:a}=(0,Y.Z)(),{trackUsage:s}=(0,f.rS)(),c=(0,ne.fi)(),i=(0,f.lm)(),{refetchData:d}=(0,e.useContext)(Ot),[m,u]=(0,e.useState)(!1),p=()=>u(v=>!v),[{fieldToEdit:y,fieldForm:h,initialData:g,modifiedData:b},R]=(0,e.useReducer)(Em,Fo,()=>({...Fo,initialData:t,modifiedData:t})),x=Object.keys(h).length!==0,{attributes:C}=t,M=b.layouts.list,Z=()=>{const{settings:{pageSize:v,defaultSortBy:V,defaultSortOrder:G},kind:K,uid:k}=g,j=`${V}:${G}`,te=`${(0,ko.stringify)({page:1,pageSize:v,sort:j},{encode:!1})}${c?`&${c}`:""}`;return`/content-manager/${K}/${k}?${te}`},W=({target:{name:v,value:V}})=>{R({type:"ON_CHANGE",keys:v,value:v==="settings.pageSize"?parseInt(V,10):V})},{isLoading:T,mutate:O}=(0,Be.useMutation)(v=>r(`/content-manager/content-types/${o}/configuration`,v),{onSuccess(){s("didEditListSettings"),d()},onError(){i({type:"warning",message:{id:"notification.error"}})}}),B=async()=>{const{layouts:v,settings:V,metadatas:G}=b;O({layouts:v,settings:V,metadatas:G})},w=v=>{R({type:"ADD_FIELD",item:v})},I=(v,V)=>{v.stopPropagation(),M.length===1?i({type:"info",message:{id:(0,E.OB)("notification.info.minimumFields")}}):R({type:"REMOVE_FIELD",index:V})},N=v=>{v.preventDefault(),p(),s("willSaveContentTypeLayout")},A=v=>{R({type:"SET_FIELD_TO_EDIT",fieldToEdit:v})},F=()=>{R({type:"UNSET_FIELD_TO_EDIT"})},H=v=>{v.preventDefault(),R({type:"SUBMIT_FIELD_FORM"}),F()},Q=({target:{name:v,value:V}})=>{R({type:"ON_CHANGE_FIELD_METAS",name:v,value:V})},X=Object.entries(C).filter(([v,V])=>(0,E.ko)(V)&&!M.includes(v)).map(([v])=>v).sort(),L=Object.entries(C).filter(([,v])=>!ym.includes(v.type)).map(([v])=>v),S=(v,V)=>{R({type:"MOVE_FIELD",originalIndex:v,atIndex:V})};return e.createElement(tt.A,null,e.createElement(Te.o,{"aria-busy":T},e.createElement("form",{onSubmit:N},e.createElement(De.T,{navigationAction:e.createElement(f.rU,{startIcon:e.createElement(ot.Z,null),to:Z,id:"go-back"},a({id:"global.back",defaultMessage:"Back"})),primaryAction:e.createElement(le.z,{size:"S",startIcon:e.createElement($e.Z,null),disabled:Pe()(b,g),type:"submit"},a({id:"global.save",defaultMessage:"Save"})),subtitle:a({id:(0,E.OB)("components.SettingsViewWrapper.pluginHeader.description.list-settings"),defaultMessage:"Define the settings of the list view."}),title:a({id:(0,E.OB)("components.SettingsViewWrapper.pluginHeader.title"),defaultMessage:"Configure the view - {name}"},{name:rt()(b.info.displayName)})}),e.createElement(Qe.D,null,e.createElement(P.k,{alignItems:"stretch",background:"neutral0",direction:"column",gap:6,hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(Lo,{modifiedData:b,onChange:W,sortOptions:L}),e.createElement(Nt.i,null),e.createElement(ma,{listRemainingFields:X,displayedFields:M,onAddField:w,onClickEditField:A,onMoveField:S,onRemoveField:I,metadatas:b.metadatas}))),e.createElement(f.QH,{bodyText:{id:(0,E.OB)("popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement($e.Z,null),isConfirmButtonLoading:T,isOpen:m,onToggleDialog:p,onConfirm:B,variantRightButton:"success-light"})),x&&e.createElement(ca,{attributes:C,fieldForm:h,fieldToEdit:y,onChangeEditLabel:Q,onCloseModal:F,onSubmit:H,type:C?.[y]?.type??"text"})))};pa.propTypes={layout:n().shape({uid:n().string.isRequired,settings:n().shape({bulkable:n().bool,defaultSortBy:n().string,defaultSortOrder:n().string,filterable:n().bool,pageSize:n().number,searchable:n().bool}).isRequired,metadatas:n().object.isRequired,options:n().object.isRequired,attributes:n().objectOf(n().shape({type:n().string})).isRequired}).isRequired,slug:n().string.isRequired};var bm=pa,bt=l(93088);const vm=()=>({type:bt.ZA}),Cm=(t,o)=>({type:bt.Id,pagination:t,data:o}),Rm=()=>({type:bt.MP});function Mm(){return{type:bt.c2}}const Tm=({components:t,contentType:o})=>{const{layouts:r}=o;return{contentType:o,components:t,displayedHeaders:r.list,type:bt.Zz}},$o=t=>({type:bt.Rp,target:t});var wo=l(94638),ga=l(99223),fa=l(94547),qe=l(19786),Dm=l(12301),Om=l(59177),ha=l(6680);const ya=({displayedFilters:t})=>{const[o,r]=(0,e.useState)(!1),{formatMessage:a}=(0,Y.Z)(),s=(0,e.useRef)(),{trackUsage:c}=(0,f.rS)(),i=()=>{o||c("willFilterEntries"),r(d=>!d)};return e.createElement(e.Fragment,null,e.createElement(q.x,{paddingTop:1,paddingBottom:1},e.createElement(le.z,{variant:"tertiary",ref:s,startIcon:e.createElement(rr.Z,null),onClick:i,size:"S"},a({id:"app.utils.filters",defaultMessage:"Filters"})),o&&e.createElement(f.J5,{displayedFilters:t,isVisible:o,onToggle:i,source:s})),e.createElement(f.W$,{filtersSchema:t}))};ya.propTypes={displayedFilters:n().arrayOf(n().shape({name:n().string.isRequired,metadatas:n().shape({label:n().string}),fieldSchema:n().shape({type:n().string})})).isRequired};var Pm=ya;const Im=["json","component","media","richtext","dynamiczone","password"],xm=["createdAt","updatedAt"];var Zm=(t,o)=>{const{allPermissions:r}=(0,f.vn)(),a=(0,f.ZT)(r,[{action:"plugin::content-manager.explorer.read",subject:o}]),s=$()(a,["0","properties","fields"],[]);return Object.keys($()(t,["attributes"]),{}).filter(d=>{const m=$()(t,["attributes",d],{});return!(!m.type||Im.includes(m.type)||!s.includes(d)&&d!=="id"&&!xm.includes(d))}).sort()};const Ea=({contentType:t,slug:o,metadatas:r})=>{const{formatMessage:a}=(0,Y.Z)(),c=Zm(t,o).map(i=>{const d=t.attributes[i],{type:m,enum:u}=d,p={name:"didFilterEntries",properties:{useRelation:m==="relation"}},{mainField:y,label:h}=r[i].list;return{name:i,metadatas:{label:a({id:h,defaultMessage:h})},fieldSchema:{type:m,options:u,mainField:y},trackedEvent:p}});return e.createElement(Pm,{displayedFilters:c})};Ea.propTypes={contentType:n().object.isRequired,metadatas:n().object.isRequired,slug:n().string.isRequired};var km=Ea,Lm=l(82884),Sm=l(47765);const ba=({area:t,...o})=>{const r=Mr(t);return r?e.createElement("ul",null,r.map(a=>a.Component(o)?e.createElement(q.x,{key:a.name,padding:3,style:{textAlign:"center"}},e.createElement(a.Component,{...o})):null)):null};ba.propTypes={area:n().string.isRequired};var en=ba;const va=({isConfirmButtonLoading:t,isOpen:o,onToggleDialog:r,onConfirm:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(Yt.V,{onClose:r,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),labelledBy:"confirmation",describedBy:"confirm-description",isOpen:o},e.createElement(Xt.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(P.k,{justifyContent:"center"},e.createElement(z.Z,{id:"confirm-description"},s({id:"components.popUpWarning.message",defaultMessage:"Are you sure you want to delete this?"}))),e.createElement(P.k,null,e.createElement(en,{area:"contentManager.listView.deleteModalAdditionalInfos"})))),e.createElement(Jt.c,{startAction:e.createElement(le.z,{onClick:r,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:e.createElement(le.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Ve.Z,null),id:"confirm-delete",loading:t},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))}))};va.propTypes={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired};const Ca=t=>t.stopPropagation(),Ra=({rowId:t,index:o})=>{const{selectedEntries:r,onSelectRow:a}=(0,f.Sh)(),{formatMessage:s}=(0,Y.Z)(),c=r.findIndex(d=>d===t)!==-1,i=s({id:"app.component.table.select.one-entry",defaultMessage:"Select {target}"},{target:o+1});return e.createElement(qe.Td,{onClick:Ca},e.createElement(Lm.C,{"aria-label":i,checked:c,onChange:()=>{a({name:t,value:!c})}}))};Ra.propTypes={rowId:n().number.isRequired,index:n().number.isRequired};const Bo=({rowId:t,index:o,canCreate:r,canDelete:a,setIsConfirmDeleteRowOpen:s,handleCloneClick:c})=>{const{formatMessage:i}=(0,Y.Z)(),{trackUsage:d}=(0,f.rS)(),{setSelectedEntries:m}=(0,f.Sh)(),u=(0,ne.fi)(),{location:{pathname:p}}=(0,re.k6)(),y=i({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:o+1});return e.createElement(qe.Td,null,e.createElement(P.k,{gap:1,justifyContent:"end",onClick:Ca},e.createElement(Re.h,{forwardedAs:gt.rU,onClick:()=>{d("willEditEntryFromButton")},to:{pathname:`${p}/${t}`,state:{from:p},search:u},label:i({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:y}),noBorder:!0},e.createElement(Ke.Z,null)),r&&e.createElement(Re.h,{onClick:c(t),label:i({id:"app.component.table.duplicate",defaultMessage:"Duplicate {target}"},{target:y}),noBorder:!0},e.createElement(Sm.Z,null)),a&&e.createElement(Re.h,{onClick:()=>{d("willDeleteEntryFromList"),m([t]),s(!0)},label:i({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:y}),noBorder:!0},e.createElement(Ve.Z,null))))};Bo.defaultProps={canCreate:!1,canDelete:!1},Bo.propTypes={rowId:n().number.isRequired,index:n().number.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired,handleCloneClick:n().func.isRequired,canCreate:n().bool,canDelete:n().bool};const Ma=({children:t,onConfirmDelete:o,isConfirmDeleteRowOpen:r,setIsConfirmDeleteRowOpen:a})=>{const[s,c]=e.useState(!1),{selectedEntries:i,setSelectedEntries:d}=(0,f.Sh)(),m=async()=>{try{c(!0),await o(i[0]),a(!1),c(!1),d([])}catch{c(!1),a(!1)}};return e.createElement(f.iA.Body,null,t,e.createElement(va,{isConfirmButtonLoading:s,onConfirm:m,onToggleDialog:()=>a(!r),isOpen:r}))};Ma.propTypes={children:n().node.isRequired,onConfirmDelete:n().func.isRequired,isConfirmDeleteRowOpen:n().bool.isRequired,setIsConfirmDeleteRowOpen:n().func.isRequired};const tn={CheckboxDataCell:Ra,EntityActionsDataCell:Bo,Root:Ma};var Am=l(14090);const vt=()=>t=>t["content-manager_listView"]||Am.E,Fm=()=>(0,Po.P1)(vt(),t=>t),Ta=t=>{const{displayedHeaders:o}=t["content-manager_listView"];return o};var $m=Fm;const nn=({onToggleDialog:t,isOpen:o,dialogBody:r,endAction:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(Yt.V,{onClose:t,title:s({id:"app.components.ConfirmDialog.title",defaultMessage:"Confirmation"}),isOpen:o},e.createElement(Xt.a,{icon:e.createElement(At.Z,null)},e.createElement(P.k,{direction:"column",alignItems:"stretch",gap:2},r)),e.createElement(Jt.c,{startAction:e.createElement(le.z,{onClick:t,variant:"tertiary"},s({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endAction:a}))};nn.propTypes={isOpen:n().bool.isRequired,onToggleDialog:n().func.isRequired,dialogBody:n().node.isRequired,endAction:n().node.isRequired};const No={isConfirmButtonLoading:n().bool.isRequired,isOpen:n().bool.isRequired,onConfirm:n().func.isRequired,onToggleDialog:n().func.isRequired},wm=t=>e.createElement(z.Z,{fontWeight:"bold"},t),Da=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,Y.Z)(),{get:c}=(0,f.kY)(),{selectedEntries:i}=(0,f.Sh)(),d=(0,f.lm)(),{formatAPIError:m}=(0,f.So)(E.OB),{contentType:{uid:u}}=(0,ae.v9)(vt()),{data:p,isLoading:y,isError:h}=(0,Be.useQuery)(["content-manager","draft-relations",u,i],async()=>{const{data:{data:g}}=await c(`/content-manager/collection-types/${u}/actions/countManyEntriesDraftRelations`,{params:{ids:i}});return g},{enabled:i.length>0,onError(g){d({type:"warning",message:m(g)})}});return h?null:e.createElement(nn,{isOpen:t&&!y,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(z.Z,{id:"confirm-description",textAlign:"center"},p>0&&s({id:(0,E.OB)("popUpwarning.warning.bulk-has-draft-relations.message"),defaultMessage:"<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "},{b:wm,count:p,entities:i.length}),s({id:(0,E.OB)("popUpWarning.bodyMessage.contentType.publish.all"),defaultMessage:"Are you sure you want to publish these entries?"})),e.createElement(en,{area:"contentManager.listView.publishModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"secondary",startIcon:e.createElement($e.Z,null),loading:r},s({id:"app.utils.publish",defaultMessage:"Publish"}))})};Da.propTypes=No;var Oa=l(23866),Bm=l(88890),Nm=l(5074);const jm=(0,U.ZP)(z.Z)`
1042
- max-width: 300px;
1043
- `,jo=({validationErrors:t,isPublished:o})=>{const{formatMessage:r}=(0,Y.Z)();if(t){const a=Object.entries(t).map(([s,c])=>r({id:`${c.id}.withField`,defaultMessage:c.defaultMessage},{field:s})).join(" ");return e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"danger600",as:Bm.Z}),e.createElement(Ft.u,{description:a},e.createElement(jm,{textColor:"danger600",variant:"omega",fontWeight:"semiBold",ellipsis:!0},a)))}return o?e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"success600",as:qn.Z}),e.createElement(z.Z,{textColor:"success600",fontWeight:"bold"},r({id:"content-manager.bulk-publish.already-published",defaultMessage:"Already Published"}))):e.createElement(P.k,{gap:2},e.createElement(ft.J,{color:"success600",as:qn.Z}),e.createElement(z.Z,null,r({id:"app.utils.ready-to-publish",defaultMessage:"Ready to publish"})))};jo.defaultProps={validationErrors:void 0,isPublished:!1},jo.propTypes={validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})}),isPublished:n().bool};const Wo=({isPublishing:t,rowsToDisplay:o,entriesToPublish:r,validationErrors:a})=>{const{location:{pathname:s}}=(0,re.k6)(),{formatMessage:c}=(0,Y.Z)(),i=(0,ae.v9)(vt()),{mainField:d}=i.contentType.settings,m=d!=null&&d!=="id",u=p=>c({id:"content-manager.components.ListViewTable.row-line",defaultMessage:"item line {number}"},{number:p+1});return e.createElement(f.iA.Content,null,e.createElement(f.iA.Head,null,e.createElement(f.iA.HeaderCheckboxCell,null),e.createElement(f.iA.HeaderCell,{fieldSchemaType:"number",label:"id",name:"id"}),m&&e.createElement(f.iA.HeaderCell,{fieldSchemaType:"string",label:"name",name:"name"}),e.createElement(f.iA.HeaderCell,{fieldSchemaType:"string",label:"status",name:"status"})),e.createElement(f.iA.LoadingBody,null),e.createElement(f.iA.Body,null,o.map((p,y)=>e.createElement(fa.Tr,{key:p.id},e.createElement(tn.CheckboxDataCell,{rowId:p.id,index:y}),e.createElement(qe.Td,null,e.createElement(z.Z,null,p.id)),m&&e.createElement(qe.Td,null,e.createElement(z.Z,null,p[d])),e.createElement(qe.Td,null,t&&r.includes(p.id)?e.createElement(P.k,{gap:2},e.createElement(z.Z,null,c({id:"content-manager.success.record.publishing",defaultMessage:"Publishing..."})),e.createElement(Oa.a,{small:!0})):e.createElement(jo,{validationErrors:a[p.id],isPublished:p.publishedAt!==null})),e.createElement(qe.Td,null,e.createElement(Re.h,{forwardedAs:gt.rU,to:{pathname:`${s}/${p.id}`,state:{from:s}},label:c({id:"app.component.table.edit",defaultMessage:"Edit {target}"},{target:u(y)}),noBorder:!0,target:"_blank",marginLeft:"auto"},e.createElement(Ke.Z,null)))))))};Wo.defaultProps={isPublishing:!1,rowsToDisplay:[],entriesToPublish:[],validationErrors:{}},Wo.propTypes={isPublishing:n().bool,rowsToDisplay:n().arrayOf(n().object),entriesToPublish:n().arrayOf(n().number),validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})})};const Pa=t=>e.createElement(z.Z,{fontWeight:"bold"},t),zo=({toggleModal:t,refetchModalData:o,setEntriesToFetch:r,setSelectedListViewEntries:a,validationErrors:s})=>{const{formatMessage:c}=(0,Y.Z)(),{selectedEntries:i,rows:d,onSelectRow:m,isLoading:u,isFetching:p}=(0,f.Sh)(),[y,h]=e.useState(!1),[g,b]=e.useState([]),[R,x]=e.useState(0),C=d.filter(({id:A})=>i.includes(A)&&!s[A]).map(({id:A})=>A),{post:M}=(0,f.kY)(),Z=(0,f.lm)(),{contentType:W}=(0,ae.v9)(vt()),T=g.filter(({id:A})=>i.includes(A)&&s[A]).length,O=i.length-T,B=(0,Be.useMutation)(A=>M(`/content-manager/collection-types/${W.uid}/actions/bulkPublish`,A),{onSuccess(){const A=g.filter(H=>(C.includes(H.id)&&m({name:H.id,value:!1}),!C.includes(H.id)));b(A);const F=A.map(({id:H})=>H);r(F),a(F),A.length===0&&t(),Z({type:"success",message:{id:"content-manager.success.record.publish",defaultMessage:"Published"}})},onError(A){Z({type:"warning",message:(0,Nm.Z)(A)})}}),w=()=>h(A=>!A),I=async()=>{w();const{data:A}=await B.mutateAsync({ids:C});x(A.count)},N=()=>R?c({id:(0,E.OB)("containers.ListPage.selectedEntriesModal.publishedCount"),defaultMessage:"<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."},{publishedCount:R,withErrorsCount:T,b:Pa}):c({id:(0,E.OB)("containers.ListPage.selectedEntriesModal.selectedCount"),defaultMessage:"<b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."},{readyToPublishCount:O,withErrorsCount:T,b:Pa});return e.useEffect(()=>{d.length>0&&b(d)},[d]),e.createElement(gn.P,{onClose:t,labelledBy:"title"},e.createElement(fn.x,null,e.createElement(z.Z,{fontWeight:"bold",textColor:"neutral800",as:"h2",id:"title"},c({id:(0,E.OB)("containers.ListPage.selectedEntriesModal.title"),defaultMessage:"Publish entries"}))),e.createElement(hn.f,null,e.createElement(z.Z,null,N()),e.createElement(q.x,{marginTop:5},e.createElement(Wo,{isPublishing:B.isLoading,rowsToDisplay:g,entriesToPublish:C,validationErrors:s}))),e.createElement(yn.m,{startActions:e.createElement(le.z,{onClick:t,variant:"tertiary"},c({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(P.k,{gap:2},e.createElement(le.z,{onClick:o,variant:"tertiary",loading:p},c({id:"app.utils.refresh",defaultMessage:"Refresh"})),e.createElement(le.z,{onClick:w,disabled:i.length===0||i.length===T||u,loading:B.isLoading},c({id:"app.utils.publish",defaultMessage:"Publish"})))}),e.createElement(Da,{isOpen:y,onToggleDialog:w,isConfirmButtonLoading:B.isLoading,onConfirm:I}))};zo.defaultProps={validationErrors:{}},zo.propTypes={toggleModal:n().func.isRequired,refetchModalData:n().func.isRequired,setEntriesToFetch:n().func.isRequired,setSelectedListViewEntries:n().func.isRequired,validationErrors:n().shape({[n().string]:n().shape({id:n().string,defaultMessage:n().string})})};const Ia=({onToggle:t})=>{const{selectedEntries:o,setSelectedEntries:r}=(0,f.Sh)(),{contentType:a,components:s}=(0,ae.v9)(vt()),[c,i]=e.useState(o),[{query:{sort:d}}]=(0,f.Kx)(),m={page:1,pageSize:c.length,sort:d,filters:{id:{$in:c}}},{get:u}=(0,f.kY)(),{data:p,isLoading:y,isFetching:h,refetch:g}=(0,Be.useQuery)(["entries",a.uid,m],async()=>{const{data:b}=await u(`content-manager/collection-types/${a.uid}`,{params:m});if(b.results){const R=(0,E.Ex)(a,{components:s},{isDraft:!1}),x={};return{rows:b.results.map(M=>{try{return R.validateSync(M,{abortEarly:!1}),M}catch(Z){return x[M.id]=(0,f.CJ)(Z),M}}),validationErrors:x}}return{rows:[],validationErrors:{}}});return e.createElement(f.iA.Root,{rows:p?.rows,defaultSelectedEntries:o,colCount:4,isLoading:y,isFetching:h},e.createElement(zo,{setSelectedListViewEntries:r,setEntriesToFetch:i,toggleModal:t,refetchModalData:g,validationErrors:p?.validationErrors}))};Ia.propTypes={onToggle:n().func.isRequired};var Wm=Ia;const xa=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(nn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(z.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,E.OB)("popUpWarning.bodyMessage.contentType.unpublish.all"),defaultMessage:"Are you sure you want to unpublish these entries?"})),e.createElement(en,{area:"contentManager.listView.unpublishModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"secondary",startIcon:e.createElement($e.Z,null),loading:r},s({id:"app.utils.unpublish",defaultMessage:"Unpublish"}))})};xa.propTypes=No;const Za=({isOpen:t,onToggleDialog:o,isConfirmButtonLoading:r,onConfirm:a})=>{const{formatMessage:s}=(0,Y.Z)();return e.createElement(nn,{isOpen:t,onToggleDialog:o,dialogBody:e.createElement(e.Fragment,null,e.createElement(z.Z,{id:"confirm-description",textAlign:"center"},s({id:(0,E.OB)("popUpWarning.bodyMessage.contentType.delete.all"),defaultMessage:"Are you sure you want to delete these entries?"})),e.createElement(en,{area:"contentManager.listView.deleteModalAdditionalInfos"})),endAction:e.createElement(le.z,{onClick:a,variant:"danger-light",startIcon:e.createElement(Ve.Z,null),id:"confirm-delete",loading:r},s({id:"app.components.Button.confirm",defaultMessage:"Confirm"}))})};Za.propTypes=No;const Uo=({showPublish:t,showDelete:o,onConfirmDeleteAll:r,onConfirmUnpublishAll:a,refetchData:s})=>{const{formatMessage:c}=(0,Y.Z)(),{trackUsage:i}=(0,f.rS)(),{data:d}=(0,ae.v9)(vt()),{selectedEntries:m,setSelectedEntries:u}=(0,f.Sh)(),[p,y]=e.useState(!1),[h,g]=e.useState(!1),[b,R]=e.useState(null),x=d.filter(I=>m.includes(I.id)),C=t&&x.some(I=>!I.publishedAt),M=t&&x.some(I=>I.publishedAt),Z=()=>{b==="delete"?R(null):(R("delete"),i("willBulkDeleteEntries"))},W=()=>{b==="unpublish"?R(null):(R("unpublish"),i("willBulkUnpublishEntries"))},T=async(I,N)=>{try{y(!0),await I(m),y(!1),N(),u([])}catch{y(!1),N()}},O=()=>T(r,Z),B=()=>T(a,W),w=()=>{g(I=>(I&&s(),!I))};return e.createElement(e.Fragment,null,C&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"tertiary",onClick:w},c({id:"app.utils.publish",defaultMessage:"Publish"})),h&&e.createElement(Wm,{onToggle:w})),M&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"tertiary",onClick:W},c({id:"app.utils.unpublish",defaultMessage:"Unpublish"})),e.createElement(xa,{isOpen:b==="unpublish",onToggleDialog:W,isConfirmButtonLoading:p,onConfirm:B})),o&&e.createElement(e.Fragment,null,e.createElement(le.z,{variant:"danger-light",onClick:Z},c({id:"global.delete",defaultMessage:"Delete"})),e.createElement(Za,{isOpen:b==="delete",onToggleDialog:Z,isConfirmButtonLoading:p,onConfirm:O})))};Uo.defaultProps={showPublish:!1,showDelete:!1,onConfirmDeleteAll(){},onConfirmUnpublishAll(){},refetchData(){}},Uo.propTypes={showPublish:n().bool,showDelete:n().bool,onConfirmDeleteAll:n().func,onConfirmUnpublishAll:n().func,refetchData:n().func};var zm=Uo,Um=l(96315);const ka=({type:t,value:o})=>{const{formatDate:r,formatTime:a,formatNumber:s}=(0,Y.Z)();let c=o;if(t==="date"&&(c=r((0,Um.Z)(o),{dateStyle:"full"})),t==="datetime"&&(c=r(o,{dateStyle:"full",timeStyle:"short"})),t==="time"){const[i,d,m]=o.split(":"),u=new Date;u.setHours(i),u.setMinutes(d),u.setSeconds(m),c=a(u,{numeric:"auto",style:"short"})}return["float","decimal"].includes(t)&&(c=s(o,{maximumFractionDigits:20})),["integer","biginteger"].includes(t)&&(c=s(o,{maximumFractionDigits:0})),Jr()(c)};ka.propTypes={type:n().string.isRequired,value:n().any.isRequired};var Ct=ka,Vm=l(69033);const qm=(0,U.ZP)(P.k)`
1044
- position: relative;
1045
- border-radius: 50%;
1046
- width: 26px;
1047
- height: 26px;
1048
- border: 1px solid ${({theme:t})=>t.colors.neutral200};
1049
- background: ${({theme:t})=>t.colors.neutral150};
1050
- padding-left: 1px;
1051
-
1052
- span {
1053
- line-height: 0.6rem;
1054
- font-size: 0.6rem;
1055
- }
1056
- `,La=({children:t,...o})=>e.createElement(qm,{justifyContent:"center",alignItems:"center",as:"span",...o},e.createElement(z.Z,{variant:"sigma",textColor:"neutral600"},t));La.propTypes={children:n().string.isRequired};var Sa=La;const Vo=({url:t,mime:o,alternativeText:r,name:a,ext:s,formats:c})=>{const i=(0,f.CR)(t);if(o.includes("image")){const u=c?.thumbnail?.url||null,p=(0,f.CR)(u)||i;return e.createElement(Vm.q,{src:p,alt:r||a,preview:!0})}const d=(0,f.mD)(s),m=a.length>100?`${a.substring(0,100)}...`:a;return e.createElement(Ft.u,{description:m},e.createElement(Sa,null,d))};Vo.defaultProps={alternativeText:null,formats:null},Vo.propTypes={alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired};var Aa=Vo,Hm=l(25898);const Fa=({value:t})=>e.createElement(Hm.H,null,t.map((o,r)=>{const a=`${o.id}${r}`;if(r===3){const s=`+${t.length-3}`;return e.createElement(Sa,{key:a,preview:!1},s)}return r>3?null:e.createElement(Aa,{key:a,...o})}));Fa.propTypes={value:n().arrayOf(n().shape({alternativeText:n().string,ext:n().string.isRequired,formats:n().object,mime:n().string.isRequired,name:n().string.isRequired,url:n().string.isRequired})).isRequired};var Gm=Fa,$a=l(6518);const wa=({fieldSchema:t,metadatas:o,name:r,entityId:a,value:s,contentType:c})=>{const{formatMessage:i}=(0,Y.Z)(),{notifyStatus:d}=(0,wo.G)(),[m,u]=(0,e.useState)(!1),{get:p}=(0,f.kY)(),{data:y,status:h}=(0,Be.useQuery)([t.targetModel,a],async()=>{const{data:{results:g,pagination:b}}=await p(`/content-manager/relations/${c.uid}/${a}/${r.split(".")[0]}`);return{results:g,pagination:b}},{enabled:m,staleTime:0,select:g=>({...g,results:[...g.results].reverse()})});return(0,e.useEffect)(()=>{y&&d(i({id:(0,E.OB)("DynamicTable.relation-loaded"),defaultMessage:"Relations have been loaded"}))},[y,i,d]),e.createElement(ge.fC,{onOpenChange:g=>u(g)},e.createElement(Km,{onClick:g=>g.stopPropagation()},e.createElement(P.k,{gap:1,wrap:"nowrap"},e.createElement($a.C,null,s.count),i({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:s.count}))),e.createElement(ge.VY,null,h!=="success"&&e.createElement(ge.ck,{disabled:!0},e.createElement(Oa.a,{small:!0},i({id:(0,E.OB)("ListViewTable.relation-loading"),defaultMessage:"Relations are loading"}))),h==="success"&&e.createElement(e.Fragment,null,y?.results.map(g=>e.createElement(ge.ck,{key:g.id,disabled:!0},e.createElement(Qm,{ellipsis:!0},e.createElement(Ct,{type:o.mainField.schema.type,value:g[o.mainField.name]||g.id})))),y?.pagination.total>10&&e.createElement(ge.ck,{"aria-disabled":!0,"aria-label":i({id:(0,E.OB)("ListViewTable.relation-more"),defaultMessage:"This relation contains more entities than displayed"})},e.createElement(z.Z,null,"\u2026")))))};wa.propTypes={contentType:n().shape({uid:n().string.isRequired}).isRequired,fieldSchema:n().shape({relation:n().string,targetModel:n().string,type:n().string.isRequired}).isRequired,metadatas:n().shape({mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired})}).isRequired,name:n().string.isRequired,entityId:n().oneOfType([n().string,n().number]).isRequired,value:n().object.isRequired};const Qm=(0,U.ZP)(z.Z)`
1057
- max-width: 500px;
1058
- `,Km=(0,U.ZP)(ge.xz)`
1059
- svg {
1060
- width: ${6/16}rem;
1061
- height: ${4/16}rem;
1062
- }
1063
- `;var Ym=wa;const Xm=(0,U.ZP)(z.Z)`
1064
- max-width: 500px;
1065
- `,Ba=({metadatas:t,value:o})=>e.createElement(Xm,{textColor:"neutral800",ellipsis:!0},e.createElement(Ct,{type:t.mainField.schema.type,value:o[t.mainField.name]??o.id}));Ba.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string.isRequired,schema:n().shape({type:n().string.isRequired}).isRequired})}).isRequired,value:n().object.isRequired};var Jm=Ba;const _m=(0,U.ZP)(z.Z)`
1066
- max-width: 500px;
1067
- `,Na=({value:t,metadatas:o})=>{const{formatMessage:r}=(0,Y.Z)(),{mainField:{type:a,name:s}}=o;return e.createElement(ge.fC,null,e.createElement(ep,{onClick:c=>c.stopPropagation()},e.createElement($a.C,null,t.length)," ",r({id:"content-manager.containers.ListPage.items",defaultMessage:"{number, plural, =0 {items} one {item} other {items}}"},{number:t.length})),e.createElement(ge.VY,null,t.map(c=>e.createElement(ge.ck,{key:c.id,disabled:!0},e.createElement(_m,{ellipsis:!0},e.createElement(Ct,{type:a,value:c[s]||c.id}))))))};Na.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().array.isRequired};const ep=(0,U.ZP)(ge.xz)`
1068
- svg {
1069
- width: ${6/16}rem;
1070
- height: ${4/16}rem;
1071
- }
1072
- `;var tp=Na;const np=(0,U.ZP)(z.Z)`
1073
- max-width: 250px;
1074
- `,ja=({value:t,metadatas:o})=>{const{mainField:r}=o,a=t[r.name];return e.createElement(Ft.u,{label:a},e.createElement(np,{textColor:"neutral800",ellipsis:!0},e.createElement(Ct,{type:r.type,value:a})))};ja.propTypes={metadatas:n().shape({mainField:n().shape({name:n().string,type:n().string,value:n().string})}).isRequired,value:n().object.isRequired};var op=ja,rp=l(80022),Wa=l.n(rp),za=l(73347);function Ua(t){return["oneToOne","manyToOne","oneToOneMorph"].includes(t)}function ap(t,o,r,a){if(t==="component"){const{mainField:{name:s,type:c}}=r;if(a?.repeatable)return o.length>0;const i=o?.[s];return s==="id"&&![void 0,null].includes(i)?!0:(0,za.Z)(c)&&c!=="biginteger"&&s!=="id"?Wa()(i):!Ne()(i)}return t==="relation"?Ua(a.relation)?!Ne()(o):o?.count>0:(0,za.Z)(t)&&t!=="biginteger"?Wa()(o):t==="boolean"?o!==null:!Ne()(o)}const Va=(0,U.ZP)(z.Z)`
1075
- max-width: 300px;
1076
- `,qo=({content:t,fieldSchema:o,metadatas:r,name:a,rowId:s,contentType:c})=>{const{type:i}=o;if(!ap(i,t,r,o))return e.createElement(z.Z,{textColor:"neutral800"},"-");switch(i){case"media":return o.multiple?e.createElement(Gm,{value:t}):e.createElement(Aa,{...t});case"relation":return Ua(o.relation)?e.createElement(Jm,{metadatas:r,value:t}):e.createElement(Ym,{fieldSchema:o,metadatas:r,value:t,name:a,entityId:s,contentType:c});case"component":return o.repeatable===!0?e.createElement(tp,{value:t,metadatas:r}):e.createElement(op,{value:t,metadatas:r});case"string":return e.createElement(Ft.u,{description:t},e.createElement(Va,{ellipsis:!0,textColor:"neutral800"},e.createElement(Ct,{type:i,value:t})));default:return e.createElement(Va,{ellipsis:!0,textColor:"neutral800"},e.createElement(Ct,{type:i,value:t}))}};qo.defaultProps={content:void 0},qo.propTypes={content:n().any,contentType:n().shape({uid:n().string.isRequired}).isRequired,fieldSchema:n().shape({component:n().string,multiple:n().bool,type:n().string.isRequired,repeatable:n().bool,relation:n().string}).isRequired,metadatas:n().object.isRequired,name:n().string.isRequired,rowId:n().oneOfType([n().string,n().number]).isRequired};var sp=qo;const qa=({layout:t})=>{const o=(0,ae.I0)(),r=(0,ae.v9)(Ta),{trackUsage:a}=(0,f.rS)(),{formatMessage:s}=(0,Y.Z)(),c=ip(t.contentType.attributes).map(m=>{const u=t.contentType.metadatas[m].list;return{name:m,intlLabel:{id:u.label,defaultMessage:u.label}}}),i=r.map(({name:m})=>m),d=m=>{if(a("didChangeDisplayedFields"),m.length<i.length){const u=i.filter(p=>m.indexOf(p)===-1);o($o({name:u[0],value:!0}))}else{const u=m.filter(p=>i.indexOf(p)===-1);o($o({name:u[0],value:!1}))}};return e.createElement(q.x,{paddingTop:1,paddingBottom:1},e.createElement(Fe.P,{"aria-label":"change displayed fields",value:i,onChange:d,customizeContent:m=>s({id:(0,E.OB)("select.currently.selected"),defaultMessage:"{count} currently selected"},{count:m.length}),multi:!0,size:"S"},c.map(m=>e.createElement(Ce.W,{key:m.name,value:m.name},s({id:m.intlLabel.id||m.name,defaultMessage:m.intlLabel.defaultMessage||m.name})))))};qa.propTypes={layout:n().shape({contentType:n().shape({attributes:n().object.isRequired,metadatas:n().object.isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired}).isRequired}).isRequired};const ip=t=>Object.keys(t).reduce((r,a)=>{const s=t[a];return(0,E.ko)(s)&&r.push(a),r},[]).sort(),lp=(0,U.ZP)(q.x)`
1077
- svg {
1078
- path {
1079
- fill: ${({theme:t})=>t.colors.neutral900};
1080
- }
1081
- }
1082
- `,cp=null,dp=()=>null;function Ha({canCreate:t,canDelete:o,canRead:r,canPublish:a,data:s,getData:c,getDataSucceeded:i,isLoading:d,layout:m,pagination:u,slug:p}){const{total:y}=u,{contentType:h}=m,{info:g,options:b,metadatas:R,settings:{bulkable:x,filterable:C,searchable:M}}=h,[Z,W]=e.useState(!1),T=(0,f.lm)(),{trackUsage:O}=(0,f.rS)(),{refetchPermissions:B}=(0,f.vn)(),w=e.useRef(O),I=e.useRef(B),{notifyStatus:N}=(0,wo.G)(),{formatAPIError:A}=(0,f.So)(E.OB),F=(0,ae.v9)(We._);(0,f.go)();const[{query:H}]=(0,f.Kx)(),Q=e.useMemo(()=>na(H),[H]),X=(0,ko.stringify)({plugins:H.plugins},{encode:!1}),{pathname:L}=(0,re.TH)(),{push:S}=(0,re.k6)(),{formatMessage:v}=(0,Y.Z)(),V=(0,f.kY)(),G=b?.draftAndPublish??!1,K=b?.reviewWorkflows??!1,k=(0,xn.c)(cp,async()=>(await l.e(6158).then(l.bind(l,76158))).REVIEW_WORKFLOW_COLUMNS_EE,{enabled:!!b?.reviewWorkflows}),j=(0,xn.c)(dp,async()=>(await l.e(3984).then(l.bind(l,33984))).ReviewWorkflowsStageEE,{enabled:K}),{post:te,del:ue}=V,fe=(0,Be.useMutation)(se=>te(`/content-manager/collection-types/${h.uid}/actions/bulkUnpublish`,se),{onSuccess(){T({type:"success",message:{id:"content-manager.success.record.unpublish",defaultMessage:"Unpublished"}}),D(`/content-manager/collection-types/${p}`,{params:Q})},onError(se){T({type:"warning",message:A(se)})}}),ye=e.useRef(""),D=e.useCallback(async(se,de)=>{c();try{const{data:{results:Ee,pagination:ve}}=await V.get(se,de);N(v({id:(0,E.OB)("utils.data-loaded"),defaultMessage:"{number, plural, =1 {# entry has} other {# entries have}} successfully been loaded"},{number:ve.count})),i(ve,Ee)}catch(Ee){if(ze.default.isCancel(Ee))return;if((Ee?.response?.status??null)===403){await I.current(),T({type:"info",message:{id:(0,E.OB)("permissions.not-allowed.update")}}),S("/");return}T({type:"warning",message:{id:(0,E.OB)("error.model.fetch")}})}},[v,c,i,N,S,T,V]),ee=e.useCallback(async se=>{try{await te(`/content-manager/collection-types/${p}/actions/bulkDelete`,{ids:se}),D(`/content-manager/collection-types/${p}`,{params:Q}),w.current("didBulkDeleteEntries")}catch(de){T({type:"warning",message:A(de)})}},[p,T,A,te,D,Q]),pe=e.useCallback(async se=>{try{await ue(`/content-manager/collection-types/${p}/${se}`);const de=`/content-manager/collection-types/${p}`;D(de,{params:Q}),T({type:"success",message:{id:(0,E.OB)("success.record.delete")}})}catch(de){T({type:"warning",message:A(de)})}},[p,T,A,ue,D,Q]),Ie=se=>fe.mutateAsync({ids:se});e.useEffect(()=>{const de=ze.default.CancelToken.source(),Ee=r,ve=`/content-manager/collection-types/${p}`;return Ee&&ve.includes(ye.current)&&D(ve,{cancelToken:de.token,params:Q}),()=>{ye.current=p,de.cancel("Operation canceled by the user.")}},[r,c,p,Q,i,D]);const Ue=v({id:(0,E.OB)("header.name"),defaultMessage:"Content"}),ce=v({id:g.displayName,defaultMessage:g.displayName||Ue}),{runHookWaterfall:xe}=(0,f.j1)(),je=(0,ae.v9)(Ta),Ze=e.useMemo(()=>{const de=xe(zt.No,{displayedHeaders:je,layout:m}).displayedHeaders.map(Ee=>{const{metadatas:ve}=Ee;if(Ee.fieldSchema.type==="relation"){const wt=`${Ee.name}.${Ee.metadatas.mainField.name}`;return{...Ee,metadatas:{...ve,label:v({id:(0,E.OB)(`containers.ListPage.table-headers.${Ee.name}`),defaultMessage:ve.label})},name:wt}}return{...Ee,metadatas:{...ve,label:v({id:(0,E.OB)(`containers.ListPage.table-headers.${Ee.name}`),defaultMessage:ve.label})}}});return G&&de.push({key:"__published_at_temp_key__",name:"publishedAt",fieldSchema:{type:"custom"},metadatas:{label:v({id:(0,E.OB)("containers.ListPage.table-headers.publishedAt"),defaultMessage:"publishedAt"}),searchable:!1,sortable:!0}}),k&&(typeof k.metadatas.label!="string"&&(k.metadatas.label=v(k.metadatas.label)),de.push(k)),de},[xe,je,m,k,G,v]),He=r?v({id:(0,E.OB)("pages.ListView.header-subtitle"),defaultMessage:"{number, plural, =0 {# entries} one {# entry} other {# entries}} found"},{number:y}):null,Rt=se=>t?e.createElement(le.z,{...se,forwardedAs:gt.rU,onClick:()=>{const de=G?{status:"draft"}:{};w.current("willCreateEntry",de)},to:{pathname:`${L}/create`,search:H.plugins?X:""},startIcon:e.createElement(pt.Z,null),style:{textDecoration:"none"}},v({id:(0,E.OB)("HeaderLayout.button.label-add-entry"),defaultMessage:"Create new entry"})):null,it=se=>()=>{O("willEditEntryFromList"),S({pathname:`${L}/${se}`,state:{from:L},search:X})},he=se=>async()=>{try{const{data:de}=await te(`/content-manager/collection-types/${h.uid}/auto-clone/${se}?${X}`);"id"in de&&S({pathname:`${L}/${de.id}`,state:{from:L},search:X})}catch(de){de instanceof Om.d7&&S({pathname:`${L}/create/clone/${se}`,state:{from:L,error:A(de)},search:X})}},Me=Ze.length+2,et=()=>{D(`/content-manager/collection-types/${p}`,{params:Q})};return j?e.createElement(Te.o,{"aria-busy":d},e.createElement(De.T,{primaryAction:Rt(),subtitle:He,title:ce,navigationAction:e.createElement(f.rU,{startIcon:e.createElement(ot.Z,null),to:"/content-manager/"},v({id:"global.back",defaultMessage:"Back"}))}),!r&&e.createElement(ga.Z,{endActions:e.createElement(Ut,{area:"contentManager.listView.actions"})}),r&&e.createElement(ga.Z,{endActions:e.createElement(e.Fragment,null,e.createElement(Ut,{area:"contentManager.listView.actions"}),e.createElement(qa,{layout:m}),e.createElement(f.jW,{permissions:F.contentManager.collectionTypesConfigurations},e.createElement(lp,{paddingTop:1,paddingBottom:1},e.createElement(Re.h,{onClick:()=>{O("willEditListLayout")},forwardedAs:gt.rU,to:{pathname:`${p}/configurations/list`,search:X},icon:e.createElement(sn.Z,null),label:v({id:"app.links.configure-view",defaultMessage:"Configure the view"})})))),startActions:e.createElement(e.Fragment,null,M&&e.createElement(f.m,{label:v({id:"app.component.search.label",defaultMessage:"Search for {target}"},{target:ce}),placeholder:v({id:"global.search",defaultMessage:"Search"}),trackedEvent:"didSearch"}),C&&e.createElement(km,{contentType:h,slug:p,metadatas:R}))}),e.createElement(Qe.D,null,r?e.createElement(P.k,{gap:4,direction:"column",alignItems:"stretch"},e.createElement(f.iA.Root,{rows:s,isLoading:d,colCount:Me},e.createElement(f.iA.ActionBar,null,e.createElement(zm,{showPublish:a&&G,showDelete:o,onConfirmDeleteAll:ee,onConfirmUnpublishAll:Ie,refetchData:et})),e.createElement(f.iA.Content,null,e.createElement(f.iA.Head,null,e.createElement(f.iA.HeaderCheckboxCell,null),Ze.map(({fieldSchema:se,key:de,name:Ee,metadatas:ve})=>e.createElement(f.iA.HeaderCell,{key:de,name:Ee,fieldSchemaType:se.type,relationFieldName:ve.mainField?.name,isSortable:ve.sortable,label:ve.label})),e.createElement(f.iA.HeaderHiddenActionsCell,null)),e.createElement(f.iA.LoadingBody,null),e.createElement(f.iA.EmptyBody,{contentType:ce,aciton:Rt({variant:"secondary"})}),e.createElement(tn.Root,{onConfirmDelete:pe,isConfirmDeleteRowOpen:Z,setIsConfirmDeleteRowOpen:W},s.map((se,de)=>e.createElement(fa.Tr,{cursor:"pointer",key:s.id,onClick:it(se.id)},e.createElement(tn.CheckboxDataCell,{rowId:se.id,index:de}),Ze.map(({key:Ee,name:ve,...wt})=>G&&ve==="publishedAt"?e.createElement(qe.Td,{key:Ee},e.createElement(Kn.q,{width:"min-content",showBullet:!1,variant:se.publishedAt?"success":"secondary",size:"S"},e.createElement(z.Z,{fontWeight:"bold",textColor:`${se.publishedAt?"success":"secondary"}700`},v({id:(0,E.OB)(`containers.List.${se.publishedAt?"published":"draft"}`),defaultMessage:se.publishedAt?"Published":"Draft"})))):K&&ve==="strapi_stage"?e.createElement(qe.Td,{key:Ee},se.strapi_stage?e.createElement(j,{color:se.strapi_stage.color??Dm.W.colors.primary600,name:se.strapi_stage.name}):e.createElement(z.Z,{textColor:"neutral800"},"-")):e.createElement(qe.Td,{key:Ee},e.createElement(sp,{content:se[ve.split(".")[0]],name:ve,contentType:m.contentType,...wt,rowId:se.id}))),(o||a)&&x&&e.createElement(tn.EntityActionsDataCell,{rowId:se.id,index:de,setIsConfirmDeleteRowOpen:W,canCreate:t,canDelete:o,handleCloneClick:he})))))),e.createElement(P.k,{alignItems:"flex-end",justifyContent:"space-between"},e.createElement(f.v4,{trackedEvent:"willChangeNumberOfEntriesPerPage"}),e.createElement(f.tU,{pagination:{pageCount:u?.pageCount||1}}))):e.createElement(f.ZF,null))):null}Ha.propTypes={canCreate:n().bool.isRequired,canDelete:n().bool.isRequired,canRead:n().bool.isRequired,canPublish:n().bool.isRequired,data:n().array.isRequired,layout:n().exact({components:n().object.isRequired,contentType:n().shape({uid:n().string.isRequired,attributes:n().object.isRequired,metadatas:n().object.isRequired,info:n().shape({displayName:n().string.isRequired}).isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired}).isRequired}).isRequired,isLoading:n().bool.isRequired,getData:n().func.isRequired,getDataSucceeded:n().func.isRequired,pagination:n().shape({total:n().number.isRequired,pageCount:n().number}).isRequired,slug:n().string.isRequired};const up=$m();function mp(t){return(0,ha.bindActionCreators)({getData:vm,getDataSucceeded:Cm,onChangeListHeaders:$o,onResetListHeaders:Rm},t)}const pp=(0,ae.$j)(up,mp);var gp=(0,ha.compose)(pp)(e.memo(Ha,Pe()));const Ho=t=>{const o=(0,e.useMemo)(()=>(0,E.TA)(t.slug),[t.slug]),{isLoading:r,allowedActions:a}=(0,f.ss)(o,t.permissions);return r?e.createElement(f.dO,null):e.createElement(gp,{...t,...a})};Ho.defaultProps={permissions:[]},Ho.propTypes={permissions:n().array,slug:n().string.isRequired};var fp=(0,e.memo)(Ho,(t,o)=>{const r=(0,f.e5)(t,o);return Object.keys(r).filter(s=>s!=="state").length>0});const Ga=({layout:t,...o})=>{const r=(0,ae.I0)(),{replace:a}=(0,re.k6)(),[{query:s,rawQuery:c}]=(0,f.Kx)(),i=(0,ne.r5)(s,o.slug,"listView"),d=(0,ne.Ky)(o.slug);return(0,e.useEffect)(()=>{c||a(d)},[c,a,d]),(0,e.useEffect)(()=>{r(Tm(t))},[r,t]),(0,e.useEffect)(()=>()=>{r(Mm())},[r]),i?e.createElement(fp,{...o,layout:t,permissions:i}):null};Ga.propTypes={layout:n().exact({components:n().object.isRequired,contentType:n().shape({attributes:n().object.isRequired,metadatas:n().object.isRequired,layouts:n().shape({list:n().array.isRequired}).isRequired,options:n().object.isRequired,settings:n().object.isRequired,pluginOptions:n().object}).isRequired}).isRequired,slug:n().string.isRequired};var hp=Ga,yp=()=>e.createElement(q.x,{padding:8},e.createElement(f.Hn,null));const Qa=({match:{params:{slug:t},url:o}})=>{const r=(0,ae.v9)(We._),{isLoading:a,layout:s,updateLayout:c}=(0,ne.zE)(t),{rawContentTypeLayout:i,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let y={},h={};return s.contentType&&(y=(0,E.du)(s.contentType)),s.components&&(h=Object.keys(s.components).reduce((g,b)=>(g[b]=(0,E.du)(s.components[b]),g),{})),{rawContentTypeLayout:y,rawComponentsLayouts:h}},[s]);if((s?.contentType?.uid??null)!==t||a)return e.createElement(f.dO,null);const u=({location:{state:y},history:{goBack:h},match:{params:{id:g,origin:b}}},R)=>e.createElement(R,{slug:t,layout:s,state:y,goBack:h,id:g,origin:b}),p=[{path:"create/clone/:origin",comp:_t},{path:"create",comp:_t},{path:":id",comp:_t},{path:"",comp:hp}].map(({path:y,comp:h})=>e.createElement(re.AW,{key:y,path:`${o}/${y}`,render:g=>u(g,h)}));return e.createElement(nt.ErrorBoundary,{FallbackComponent:yp},e.createElement(Pt.Provider,{value:s},e.createElement(re.rs,null,e.createElement(re.AW,{path:`${o}/configurations/list`},e.createElement(f.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(bm,{layout:i,slug:t,updateLayout:c}))),e.createElement(re.AW,{path:`${o}/configurations/edit`},e.createElement(f.O4,{permissions:r.contentManager.collectionTypesConfigurations},e.createElement(In,{components:d,isContentTypeView:!0,mainLayout:i,slug:t,updateLayout:c}))),p)))};Qa.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var Ep=(0,e.memo)(Qa),Ka=l(4214);const bp=()=>{const[{isLoading:t,data:o},r]=(0,e.useReducer)(Ka.Z,Ka.q),a=(0,e.useMemo)(mt.Vo,[]),{schemas:s}=(0,ae.v9)(m=>a(m),ae.wU),c=(0,ae.v9)(We._),{uid:i}=(0,re.UO)(),{get:d}=(0,f.kY)();return(0,e.useEffect)(()=>{const u=ze.default.CancelToken.source();return(async y=>{try{r(Vt());const{data:{data:h}}=await d(`/content-manager/components/${i}/configuration`,{cancelToken:y.token});r(Zn((0,E.w8)(h,s,"component")))}catch(h){if(ze.default.isCancel(h))return;console.error(h)}})(u),()=>{u.cancel("Operation canceled by the user.")}},[i,s,d]),t?e.createElement(f.dO,null):e.createElement(f.O4,{permissions:c.contentManager.componentsConfigurations},e.createElement(In,{components:o.components,mainLayout:o.component,slug:i}))};var vp=(0,e.memo)(bp),Cp=l(9695),Rp=l(54725),Mp=()=>{const{formatMessage:t}=(0,Y.Z)();return(0,f.go)(),e.createElement(Te.o,null,e.createElement(De.T,{title:t({id:(0,E.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(Qe.D,null,e.createElement(Cp.x,{action:e.createElement(f.Qj,{variant:"secondary",startIcon:e.createElement(pt.Z,null),to:"/plugins/content-type-builder/content-types/create-content-type"},t({id:"app.components.HomePage.create",defaultMessage:"Create your first Content-type"})),content:t({id:"content-manager.pages.NoContentType.text",defaultMessage:"You don't have any content yet, we recommend you to create your first Content-Type."}),hasRadius:!0,icon:e.createElement(Rp.Z,{width:"10rem"}),shadow:"tableShadow"})))},Tp=()=>{const{formatMessage:t}=(0,Y.Z)();return(0,f.go)(),e.createElement(Te.o,null,e.createElement(De.T,{title:t({id:(0,E.OB)("header.name"),defaultMessage:"Content"})}),e.createElement(Qe.D,null,e.createElement(f.ZF,null)))};const Ya=({match:{params:{slug:t},url:o}})=>{const r=(0,ae.v9)(We._),{isLoading:a,layout:s,updateLayout:c}=(0,ne.zE)(t),{rawContentTypeLayout:i,rawComponentsLayouts:d}=(0,e.useMemo)(()=>{let m={},u={};return s.contentType&&(u=(0,E.du)(s.contentType)),s.components&&(m=Object.keys(s.components).reduce((p,y)=>(p[y]=(0,E.du)(s.components[y]),p),{})),{rawContentTypeLayout:u,rawComponentsLayouts:m}},[s]);return a?e.createElement(f.dO,null):e.createElement(Pt.Provider,{value:s},e.createElement(re.rs,null,e.createElement(re.AW,{path:`${o}/configurations/edit`},e.createElement(f.O4,{permissions:r.contentManager.singleTypesConfigurations},e.createElement(In,{components:d,isContentTypeView:!0,mainLayout:i,slug:t,updateLayout:c}))),e.createElement(re.AW,{path:o,render:({location:{state:m},history:{goBack:u}})=>e.createElement(_t,{layout:s,slug:t,isSingleType:!0,state:m,goBack:u})})))};Ya.propTypes={match:n().shape({url:n().string.isRequired,params:n().shape({slug:n().string.isRequired}).isRequired}).isRequired};var Dp=(0,e.memo)(Ya),Op=l(16899);const Pp=(0,U.ZP)(P.k)`
1083
- border-radius: 50%;
1084
-
1085
- svg {
1086
- height: ${6/16}rem;
1087
- width: ${11/16}rem;
1088
- > path {
1089
- fill: ${({theme:t})=>t.colors.neutral600};
1090
- }
1091
- }
1092
- `,Ip=U.ZP.button`
1093
- border: none;
1094
- background: transparent;
1095
- display: block;
1096
- width: 100%;
1097
- text-align: unset;
1098
- padding: 0;
1099
- `;function Xa({displayedValue:t}){return e.createElement(P.k,{background:"neutral0",borderColor:"neutral200",justifyContent:"space-between",gap:3,padding:3,width:(0,f.Q1)(300)},e.createElement(Ip,{type:"button"},e.createElement(P.k,{gap:6},e.createElement(Pp,{alignItems:"center",justifyContent:"center",background:"neutral200",height:(0,f.Q1)(32),width:(0,f.Q1)(32)},e.createElement(Op.Z,null)),e.createElement(P.k,{maxWidth:(0,f.Q1)(150)},e.createElement(z.Z,{textColor:"neutral700",ellipsis:!0},t)))),e.createElement(P.k,{gap:2},e.createElement(Re.h,{noBorder:!0},e.createElement(Ve.Z,null)),e.createElement(Re.h,{noBorder:!0},e.createElement(Ye.Z,null))))}Xa.propTypes={displayedValue:n().string.isRequired};const Ja=({status:t,displayedValue:o,width:r})=>{const{formatMessage:a}=(0,Y.Z)(),s={[st.DRAFT]:a({id:(0,E.OB)("relation.publicationState.draft"),defaultMessage:"Draft"}),[st.PUBLISHED]:a({id:(0,E.OB)("relation.publicationState.published"),defaultMessage:"Published"})},c=t===st.DRAFT?"secondary":"success";return e.createElement(q.x,{style:{width:r}},e.createElement(P.k,{paddingTop:2,paddingBottom:2,paddingLeft:2,paddingRight:4,hasRadius:!0,borderSize:1,background:"neutral0",borderColor:"neutral200",justifyContent:"space-between"},e.createElement(wr,{gap:1},e.createElement(Re.h,{noBorder:!0},e.createElement(Ye.Z,null)),e.createElement(Br,{maxWidth:"100%",justifyContent:"space-between"},e.createElement(q.x,{minWidth:0,paddingTop:1,paddingBottom:1,paddingRight:4},e.createElement(Nr,null,e.createElement(z.Z,{textColor:"primary600",ellipsis:!0},o))),t&&e.createElement(Kn.q,{variant:c,showBullet:!1,size:"S"},e.createElement(z.Z,{fontWeight:"bold",textColor:`${c}700`},s[t])))),e.createElement(q.x,{paddingLeft:4},e.createElement(jr,{type:"button"},e.createElement(ft.J,{width:"12px",as:qt.Z})))))};Ja.propTypes={status:n().string.isRequired,displayedValue:n().string.isRequired,width:n().number.isRequired};var xp=l(90700),Zp=l(78090),kp=l(77013),Lp=l(79318),Sp=l(66618),Ap=()=>{const[t,o]=(0,e.useState)(""),{formatMessage:r,locale:a}=(0,Y.Z)(),s=(0,e.useMemo)(mt.KQ,[]),{collectionTypeLinks:c,singleTypeLinks:i}=(0,ae.v9)(s,ae.wU),{startsWith:d}=(0,f.L0)(a,{sensitivity:"base"}),m=(0,f.Xe)(a,{sensitivity:"base"}),u=(0,e.useMemo)(()=>[{id:"collectionTypes",title:{id:(0,Ae.Z)("components.LeftMenu.collection-types"),defaultMessage:"Collection Types"},searchable:!0,links:c},{id:"singleTypes",title:{id:(0,Ae.Z)("components.LeftMenu.single-types"),defaultMessage:"Single Types"},searchable:!0,links:i}].map(g=>({...g,links:g.links.filter(b=>d(b.title,t)).sort((b,R)=>m.compare(b.title,R.title)).map(b=>({...b,title:r({id:b.title,defaultMessage:b.title})}))})),[c,t,i,d,r,m]),p=()=>{o("")},y=({target:{value:g}})=>{o(g)},h=r({id:(0,Ae.Z)("header.name"),defaultMessage:"Content"});return e.createElement(xp.m,{ariaLabel:h},e.createElement(Zp.p,{label:h,searchable:!0,value:t,onChange:y,onClear:p,searchLabel:r({id:"content-manager.components.LeftMenu.Search.label",defaultMessage:"Search for a content type"})}),e.createElement(kp.Z,null,u.map(g=>{const b=r({id:g.title.id,defaultMessage:g.title.defaultMessage},g.title.values);return e.createElement(Lp.D,{key:g.id,label:b,badgeLabel:g.links.length.toString()},g.links.map(R=>{const x=R.search?`?${R.search}`:"";return e.createElement(Sp.E,{as:gt.OL,key:R.uid,to:`${R.to}${x}`},R.title)}))})))},Go=l(70475);const Fp=()=>({type:Go.fn}),$p=()=>({type:Go.sZ}),wp=({authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,contentTypeSchemas:r,components:a,fieldSizes:s})=>({type:Go.IX,data:{authorizedCollectionTypeLinks:t,authorizedSingleTypeLinks:o,components:a,contentTypeSchemas:r,fieldSizes:s}});var _a=(t,o)=>o.map(({permissions:r})=>(0,f.qX)(t,r)),Bp=l(81346),Np=l.n(Bp);const es=(t,o,r=[])=>t.filter(a=>a.isDisplayed).map(a=>{const s=[{action:"plugin::content-manager.explorer.create",subject:a.uid},{action:"plugin::content-manager.explorer.read",subject:a.uid}],c=[{action:"plugin::content-manager.explorer.read",subject:a.uid}],i=o==="collectionTypes"?s:c,d=r.find(({uid:u})=>u===a.uid);let m=null;if(d){const u={page:1,pageSize:d.settings.pageSize,sort:`${d.settings.defaultSortBy}:${d.settings.defaultSortOrder}`};m=(0,ko.stringify)(u,{encode:!1})}return{permissions:i,search:m,kind:a.kind,title:a.info.displayName,to:`/content-manager/${a.kind}/${a.uid}`,uid:a.uid,name:a.uid,isDisplayed:a.isDisplayed}});var jp=(t,o)=>{const r=Object.entries(Np()(t,"kind")).map(([c,i])=>({name:c,links:i})),[a,s]=dt()(r,"name");return{collectionTypeSectionLinks:es(a?.links||[],"collectionTypes",o),singleTypeSectionLinks:es(s?.links??[],"singleTypes")}},Wp=async({models:t,userPermissions:o,toggleNotification:r})=>{const{get:a}=(0,f.tg)();try{const{data:{data:s}}=await a("/content-manager/content-types-settings"),{collectionTypeSectionLinks:c,singleTypeSectionLinks:i}=jp(t,s),d=await Promise.all(_a(o,c)),m=c.filter((y,h)=>d[h]),u=await Promise.all(_a(o,i)),p=i.filter((y,h)=>u[h]);return{authorizedCollectionTypeLinks:m,authorizedSingleTypeLinks:p}}catch(s){return console.error(s),r({type:"warning",message:{id:"notification.error"}}),{authorizedCollectionTypeLinks:[],authorizedSingleTypeLinks:[]}}},zp=()=>{const t=(0,ae.I0)(),o=(0,f.lm)(),r=(0,ae.v9)((0,mt.Yg)()),a=(0,e.useRef)(),{allPermissions:s}=(0,f.vn)(),{runHookWaterfall:c}=(0,f.j1)(),d=ze.default.CancelToken.source(),{notifyStatus:m}=(0,wo.G)(),{formatMessage:u}=(0,Y.Z)(),{get:p}=(0,f.kY)(),y=async()=>{t(Fp());try{const{data:{data:{components:h,contentTypes:g,fieldSizes:b}}}=await p("/content-manager/init",{cancelToken:d.token});m(u({id:(0,E.OB)("App.schemas.data-loaded"),defaultMessage:"The schemas have been successfully loaded."}));const R=await Wp({models:g,userPermissions:s,toggleNotification:o}),{ctLinks:x}=c(zt.LK,{ctLinks:R.authorizedCollectionTypeLinks,models:g}),{stLinks:C}=c(zt.dV,{stLinks:R.authorizedSingleTypeLinks,models:g}),M=wp({authorizedCollectionTypeLinks:x,authorizedSingleTypeLinks:C,contentTypeSchemas:g,components:h,fieldSizes:b});t(M)}catch(h){if(ze.default.isCancel(h))return;console.error(h),o({type:"warning",message:{id:"notification.error"}})}};return a.current=y,(0,e.useEffect)(()=>(a.current(),()=>{d.cancel("Operation canceled by the user."),t($p())}),[t,o]),{...r,refetchData:a.current}};function Up({type:t,item:o}){if([ut.Z.EDIT_FIELD,ut.Z.FIELD].includes(t))return e.createElement($t,{labelField:o.labelField});const[r]=t.split("_");switch(r){case ut.Z.COMPONENT:case ut.Z.DYNAMIC_ZONE:return e.createElement(Xa,{displayedValue:o.displayedValue});case ut.Z.RELATION:return e.createElement(Ja,{displayedValue:o.displayedValue,status:o.status,width:o.width});default:return null}}const ts=()=>{const t=(0,re.$B)("/content-manager/:kind/:uid"),{status:o,collectionTypeLinks:r,singleTypeLinks:a,models:s,refetchData:c}=zp(),i=dt()([...r,...a],g=>g.title.toLowerCase()),{pathname:d}=(0,re.TH)(),{formatMessage:m}=(0,Y.Z)(),{startSection:u}=(0,f.c1)(),p=(0,e.useRef)(u),y=(0,ae.v9)(We._);if((0,e.useEffect)(()=>{p.current&&p.current("contentManager")},[]),o==="loading")return e.createElement(Te.o,{"aria-busy":"true"},e.createElement(De.T,{title:m({id:(0,Ae.Z)("header.name"),defaultMessage:"Content"})}),e.createElement(f.dO,null));const h=s.filter(({isDisplayed:g})=>g);return i.length===0&&h.length>0&&d!=="/content-manager/403"?e.createElement(re.l_,{to:"/content-manager/403"}):h.length===0&&d!=="/content-manager/no-content-types"?e.createElement(re.l_,{to:"/content-manager/no-content-types"}):!t&&i.length>0?e.createElement(re.l_,{to:`${i[0].to}${i[0].search?`?${i[0].search}`:""}`}):e.createElement(tt.A,{sideNav:e.createElement(Ap,null)},e.createElement(Tt.r,{renderItem:Up}),e.createElement(Ot.Provider,{value:{refetchData:c}},e.createElement(re.rs,null,e.createElement(re.AW,{path:"/content-manager/components/:uid/configurations/edit"},e.createElement(f.O4,{permissions:y.contentManager.componentsConfigurations},e.createElement(vp,null))),e.createElement(re.AW,{path:"/content-manager/collectionType/:slug",component:Ep}),e.createElement(re.AW,{path:"/content-manager/singleType/:slug",component:Dp}),e.createElement(re.AW,{path:"/content-manager/403"},e.createElement(Tp,null)),e.createElement(re.AW,{path:"/content-manager/no-content-types"},e.createElement(Mp,null)),e.createElement(re.AW,{path:"",component:f.Hn}))))};function Vp(){const{formatMessage:t}=(0,Y.Z)();return e.createElement(e.Fragment,null,e.createElement(Ge.q,{title:t({id:(0,Ae.Z)("plugin.name"),defaultMessage:"Content Manager"})}),e.createElement(ts,null))}},98865:function(Qo,ct,l){"use strict";l.d(ct,{d:function(){return Yo}});var e=l(32735),Te=l(87933),De=l(49372),tt=l(72850),f=l(9026),Mt=l(19565),dt=l(60216),Ge=l.n(dt),Y=l(67879),ae=l(24388),re=l(69997);const Tt=60*1e3,We=Tt*60,Dt=We*24,Ot=Dt*30,Ae=Dt*365;var ke=ne=>ne<Tt?{unit:"second",value:-Math.round(ne/1e3)}:ne<We?{unit:"minute",value:-Math.round(ne/Tt)}:ne<Dt?{unit:"hour",value:-Math.round(ne/We)}:ne<Ot?{unit:"day",value:-Math.round(ne/Dt)}:ne<Ae?{unit:"month",value:-Math.round(ne/Ot)}:{unit:"year",value:-Math.round(ne/Ae)};const n=()=>{const{formatMessage:ne}=(0,Y.Z)();return e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2},e.createElement(De.Z,{variant:"sigma",textColor:"neutral600",id:"additional-information"},ne({id:(0,re.OB)("containers.Edit.information"),defaultMessage:"Information"})),e.createElement(tt.x,null,e.createElement(f.i,null)))},nt=({label:ne,value:E})=>e.createElement(Te.k,{justifyContent:"space-between"},e.createElement(De.Z,{as:"dt",fontWeight:"bold",textColor:"neutral800",variant:"pi"},ne),e.createElement(De.Z,{as:"dd",variant:"pi",textColor:"neutral600"},E));nt.propTypes={label:Ge().string.isRequired,value:Ge().string.isRequired};const Ko=()=>{const{formatMessage:ne,formatRelativeTime:E}=(0,Y.Z)(),{initialData:le,isCreatingEntry:Qe}=(0,Mt.Wq)(),q=(0,e.useRef)(Date.now()),P=(be,Fe)=>{const{firstname:Ce,lastname:Nt,username:ot}=le[Fe]??{},$e=Ce??"",on=Nt??"",we=ot??(0,ae.Pp)($e,on),Pe=(le[be]?new Date(le[be]).getTime():Date.now())-q.current,{unit:rn,value:rt}=ke(-Pe);return{at:E(rt,rn,{numeric:"auto"}),by:Qe?"-":we}},z=P("updatedAt","updatedBy"),Oe=P("createdAt","createdBy");return e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},e.createElement(nt,{label:ne({id:(0,re.OB)("containers.Edit.information.created"),defaultMessage:"Created"}),value:Oe.at}),e.createElement(nt,{label:ne({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:Oe.by})),e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:2,as:"dl"},e.createElement(nt,{label:ne({id:(0,re.OB)("containers.Edit.information.lastUpdate"),defaultMessage:"Last update"}),value:z.at}),e.createElement(nt,{label:ne({id:(0,re.OB)("containers.Edit.information.by"),defaultMessage:"By"}),value:z.by})))},Pt=({children:ne})=>e.createElement(Te.k,{direction:"column",alignItems:"stretch",gap:4},ne);Pt.propTypes={children:Ge().oneOfType([Ge().arrayOf(Ge().node),Ge().node]).isRequired};const Yo={Root:Pt,Title:n,Body:Ko}},99097:function(Qo,ct,l){"use strict";var e=l(32735);const Te=(De,tt)=>{const[f,Mt]=(0,e.useState)(De);return(0,e.useEffect)(()=>{const dt=setTimeout(()=>{Mt(De)},tt);return()=>{clearTimeout(dt)}},[De,tt]),f};ct.Z=Te},62433:function(){},15498:function(){},73353:function(){},12998:function(){},74492:function(){}}]);