slice-machine-ui 2.17.3-alpha.jp-field-type.2 → 2.17.3-alpha.jp-logout.3

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 (49) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/{x3WrmvfcfrojFCzvx-d16 → IuHy5xX4O7OS7pw5BhQtD}/_buildManifest.js +1 -1
  3. package/out/_next/static/chunks/{248-a2a655660e3f09b0.js → 248-ce52121d4f52fee1.js} +1 -1
  4. package/out/_next/static/chunks/{34-8d9d9b2944824750.js → 34-7d7a907d79f9279b.js} +1 -1
  5. package/out/_next/static/chunks/{489-feb8133b2c5a7773.js → 489-70cd522d13c732e7.js} +1 -1
  6. package/out/_next/static/chunks/630-ee074347f93761a9.js +1 -0
  7. package/out/_next/static/chunks/{647-4379a741c8d85d9e.js → 647-740ad5d8c2da5010.js} +1 -1
  8. package/out/_next/static/chunks/{04ad993f.d7f986af0f739cc9.js → 7c1bce44.7757952f8fa3a45d.js} +1 -1
  9. package/out/_next/static/chunks/{907-445266211c48b1a5.js → 907-ec265d505f89358d.js} +1 -1
  10. package/out/_next/static/chunks/pages/{_app-e96528d5f32fa118.js → _app-655a32ee37d0a72e.js} +7 -7
  11. package/out/_next/static/chunks/pages/{changelog-3663cafded70979e.js → changelog-64a61af8248660c4.js} +1 -1
  12. package/out/_next/static/chunks/pages/{changes-dda121066bd037bc.js → changes-1eee1278e11e37fe.js} +1 -1
  13. package/out/_next/static/chunks/pages/{labs-a7ead234825f32c0.js → labs-044341a257fe1f55.js} +1 -1
  14. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-b127d948a17968d3.js → simulator-760b1b0acfc25361.js} +1 -1
  15. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-29476d3554e484bb.js → [variation]-63a0b554bb376d8b.js} +1 -1
  16. package/out/_next/static/chunks/pages/{slices-742b0e644563ac91.js → slices-7d9503c44b707717.js} +1 -1
  17. package/out/_next/static/chunks/webpack-9ab76e21d6198b49.js +1 -0
  18. package/out/changelog.html +1 -1
  19. package/out/changes.html +1 -1
  20. package/out/custom-types/[customTypeId].html +1 -1
  21. package/out/custom-types.html +1 -1
  22. package/out/index.html +1 -1
  23. package/out/labs.html +1 -1
  24. package/out/page-types/[pageTypeId].html +1 -1
  25. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  26. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  27. package/out/slices.html +1 -1
  28. package/package.json +6 -6
  29. package/src/apiClient.ts +1 -1
  30. package/src/domain/fields.ts +17 -49
  31. package/src/features/auth/LogoutButton.tsx +32 -0
  32. package/src/features/environments/useActiveEnvironment.ts +9 -1
  33. package/src/features/environments/useEnvironments.ts +8 -1
  34. package/src/legacy/components/ItemHeader/index.tsx +3 -6
  35. package/src/legacy/components/ListItem/Header.tsx +12 -19
  36. package/src/legacy/components/ListItem/index.tsx +0 -1
  37. package/src/legacy/components/LoginModal/index.tsx +8 -2
  38. package/src/legacy/components/Navigation/SideNavEnvironmentSelector/SideNavEnvironmentSelector.tsx +3 -0
  39. package/src/legacy/lib/builders/common/EditModal/index.jsx +10 -4
  40. package/src/legacy/lib/models/common/widgets/Group/createGroupWidget.ts +1 -2
  41. package/src/legacy/lib/models/common/widgets/Widget.ts +1 -2
  42. package/src/modules/auth.ts +3 -0
  43. package/src/modules/availableCustomTypes/index.ts +12 -1
  44. package/src/modules/slices/index.ts +10 -1
  45. package/src/modules/useSliceMachineActions.ts +4 -1
  46. package/src/modules/userContext/index.ts +8 -0
  47. package/out/_next/static/chunks/630-aa87af9c8b0807f7.js +0 -1
  48. package/out/_next/static/chunks/webpack-e0c07a2fe4908d81.js +0 -1
  49. /package/out/_next/static/{x3WrmvfcfrojFCzvx-d16 → IuHy5xX4O7OS7pw5BhQtD}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{77630:function(e,t,n){n.d(t,{AK:function(){return v},E3:function(){return p},EN:function(){return f},F$:function(){return x},H8:function(){return C},HO:function(){return h},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return I},eK:function(){return S},gR:function(){return b},j5:function(){return a},mf:function(){return m},vB:function(){return y},xS:function(){return j},y6:function(){return i}});var r=n(98863),o=n(88866);function i(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function s(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function a(e){var t;let[n,r]=null!==(t=s(e))&&void 0!==t?t:[];return Object.entries(null!=r?r:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function c(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function u(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===o.SlicesFieldType})}function d(e,t){if(function(e,t){var n;let r=u(e,t),[o,i]=null!=r?r:[];return null!==(n=null==i?void 0:i.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let r=l(e),i=r.findIndex(e=>{let[n]=e;return n===t}),s=r.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===o.SlicesFieldType)}),a=i;do n="slices".concat(0!==a?a.toString():""),a++;while(s.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:o.SlicesFieldType,fieldset:"Slice Zone"}}}}}function p(e,t){let n=e.json[t];if(void 0===n)return e;let i=Object.keys(n).find(e=>n[e].type===o.SlicesFieldType);if(void 0===i)return e;let l=(0,r.ud)(n,i);return{...e,json:{...e.json,[t]:l}}}function f(e){var t,n;let{customType:i,sectionId:l,sliceId:s}=e,a=i.json[l];if(void 0===a)return i;let c=Object.keys(a).find(e=>a[e].type===o.SlicesFieldType);if(void 0===c)return i;let u=a[c];if(u.type!==o.SlicesFieldType)return i;let d=(0,r.ud)(null!==(n=null===(t=u.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},s);return{...i,json:{...i.json,[l]:{...a,[c]:{...u,config:{...u.config,choices:d}}}}}}function m(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=d(t,e)}return t}function y(e,t){return{...e,json:{...e.json,[t]:{}}}}function x(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function h(e,t,n){if(t===n)return e;let r=Object.keys(e.json).reduce((r,o)=>(o===t?r[n]=e.json[o]:r[o]=e.json[o],r),{});return{...e,json:r}}function j(e){let{customType:t,sectionId:n,newField:r,newFieldId:i}=e,l=t.json[n],s=u(t,n),a={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),[i]:r};if(void 0!==s){let[e,t]=s;a[e]=t}return T({customType:t,sectionId:n,updatedSection:a})}function v(e){let{customType:t,sectionId:n,fieldId:o}=e,i=(0,r.ud)(t.json[n],o);return T({customType:t,sectionId:n,updatedSection:i})}function g(e){let{customType:t,sectionId:n,previousFieldId:r,newFieldId:o,newField:i}=e,l=w({fields:t.json[n],previousFieldId:r,newFieldId:o,newField:i});return T({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:r,destinationIndex:i}=e,l=t.json[n],s=u(t,n),a=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),c="page"===t.format&&t.repeatable,d=Object.fromEntries(Object.entries(a).filter(e=>{let[t,n]=e;return"UID"!==n.type})),p=function(e){let{fields:t,sourceIndex:n,destinationIndex:r}=e,o=Object.entries(t),[i]=o.splice(n,1);return o.splice(r,0,i),Object.fromEntries(o)}({fields:c?d:a,sourceIndex:r,destinationIndex:i});if(void 0!==s){let[e,t]=s;p[e]=t}let f=Object.entries(p),m=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});m&&f.unshift(m);let y=Object.fromEntries(f);return T({customType:t,sectionId:n,updatedSection:c?y:p})}function C(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:j({customType:t,sectionId:r,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function S(e,t){var n,r;let[o]=null!==(n=s(t))&&void 0!==n?n:[],[i,l]=null!==(r=a(t))&&void 0!==r?r:[];if(!l||void 0===i||void 0===o)return t;let c=w({fields:t.json[o],previousFieldId:i,newFieldId:i,newField:{...l,config:{...l.config,label:e}}});return T({customType:t,sectionId:o,updatedSection:c})}function T(e){let{customType:t,sectionId:n,updatedSection:r}=e;return{...t,json:{...t.json,[n]:r}}}function w(e){let{fields:t,previousFieldId:n,newFieldId:r,newField:o}=e;return Object.entries(t).reduce((e,t)=>{let[i,l]=t;return i===n?e[r]=o:i!==r&&(e[i]=l),e},{})}function I(e){let{id:t,label:n,repeatable:r,format:o}=e,i=!1===r&&"page"===o?{...O,...R}:!1===r?k:"page"===o?{...N,...R}:F;return{format:o,id:t,json:i,label:n,repeatable:r,status:!0}}let k={Main:{}},O={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},F={Main:{uid:{type:"UID",config:{label:"UID"}}}},N={Main:{...F.Main,...O.Main}},R={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}}},60867:function(e,t,n){n.d(t,{_:function(){return N}});var r=n(52322),o=n(14226),i=n(5632),l=n(2784),s=n(65186),a=n(59326),c=n(75289),u=n(88932),d=n(80148),p=n(98564);async function f(e){let{customType:t,onSuccess:n}=e,r=p.$[t.format];try{let{errors:e}=await d.managerClient.customTypes.deleteCustomType({id:t.id});if(e.length>0)throw e;n(),u.Am.success("".concat(r.name({start:!0,plural:!1})," deleted"))}catch(t){let e="Internal Error: ".concat(r.name({start:!0,plural:!1})," could not be deleted");console.error(e,t),u.Am.error(e)}}var m=n(33986),y=n(30527),x=n(55862),h=n(54597);let j=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=p.$[o],[j,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,h.Z)(),b=async()=>{v(!0),await f({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:C}=(0,a.B7)();return(0,r.jsx)(x.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:()=>i(),children:(0,r.jsx)(y.Z,{bodySx:{p:0,bg:"white",position:"relative",height:"100%",padding:16},footerSx:{position:"sticky",bottom:0,p:0},sx:{border:"none",overflow:"hidden"},borderFooter:!0,Header:(0,r.jsxs)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))}},children:[(0,r.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,r.jsx)(s.$vK,{size:20,color:null===(t=C.colors)||void 0===t?void 0:t.greyIcon}),(0,r.jsxs)(c.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:["Delete"," ",d.name({start:!1,plural:!1})]})]}),(0,r.jsx)(c.x8,{type:"button",onClick:()=>i()})]}),Footer:()=>(0,r.jsxs)(c.kC,{sx:{justifyContent:"flex-end",height:64,alignItems:"center",paddingRight:16,borderTop:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.darkBorders))},backgroundColor:"gray"},children:[(0,r.jsx)(m.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(m.z,{label:"Delete",variant:"danger",isLoading:j,onClick:()=>void b(),sx:{minHeight:39,minWidth:78}})]}),children:(0,r.jsxs)("div",{children:["This action will immediately make the following change:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Delete the"," ",(0,r.jsxs)(c.xv,{sx:{fontWeight:"bold"},children:["customtypes/",null==n?void 0:n.id,"/"]})," ","directory."]})}),"The next time you push your changes to Prismic, the following change will happen:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Remove the"," ",d.name({start:!1,plural:!1})," and any associated Documents from your repository."]})})]})})})};var v=n(56580);async function g(e){let{model:t,newLabel:n,onSuccess:r}=e,o=p.$[t.format];try{let e={...t,label:n},{errors:i}=await d.managerClient.customTypes.renameCustomType({model:e});if(i.length>0)throw i;r(e),u.Am.success("".concat(o.name({start:!0,plural:!1})," renamed"))}catch(t){let e="Internal Error: ".concat(o.name({start:!0,plural:!1})," could not be renamed");console.error(e,t),u.Am.error(e)}}var b=n(68968),C=n(78254),S=n(59532),T=n(46999);let w=e=>{var t,n;let{isChangesLocal:o,customType:i,format:s,onClose:a,setLocalCustomType:u}=e,d=null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"",f=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:m}=(0,h.Z)(),{syncChanges:y}=(0,b.g)(),[x,j]=(0,l.useState)(!1),w=async e=>{j(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{m(e),y()}}),j(!1),a()},{customTypeLabels:I}=(0,v.v9)(e=>({customTypeLabels:(0,C.YS)(e)})),k=p.$[s];return(0,r.jsx)(S.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(f),buttonLabel:"Rename",close:a,onSubmit:e=>void w(e),initialValues:{customTypeName:d},isLoading:x,content:{title:"Rename a ".concat(k.name({start:!1,plural:!1}))},validate:e=>{let{customTypeName:t}=e,n={};return t&&t.length||(n.customTypeName="Cannot be empty."),void 0!=n.customTypeName&&I.includes(t)&&d!==t&&(n.customTypeName="".concat(k.name({start:!0,plural:!1})," name is already taken.")),["update","insert"].includes(t.toLowerCase())&&(n.customTypeName='Name "'.concat(t,'" is reserved for Slice Machine use.')),Object.keys(n).length>0?n:void 0},children:e=>{let{errors:t}=e;return(0,r.jsx)(c.xu,{children:(0,r.jsx)(T.W,{name:"customTypeName",label:"".concat(k.name({start:!0,plural:!1})," Name"),placeholder:"A display name for the ".concat(k.name({start:!1,plural:!1})),error:t.customTypeName,testId:"custom-type-name-input"})})}})};var I=n(94160),k=n(77630);async function O(e,t){let n=p.$[e.format];try{let r=(0,k.mf)(e),{errors:o}=await (0,I.KA)({customType:r});if(o.length>0)throw o;t(r),u.Am.success("".concat(n.name({start:!0,plural:!1})," converted to page type"))}catch(t){let e="Internal Error: ".concat(n.name({start:!0,plural:!1})," not converted to page type");console.error(e,t),u.Am.error(e)}}var F=n(59294);let N=e=>{let{format:t,customType:n,isChangesLocal:s,setLocalCustomType:a}=e,c=(0,i.useRouter)(),{saveCustomTypeSuccess:u}=(0,h.Z)(),[d,p]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[y,x]=(0,l.useState)(!1),v=async()=>{x(!0),await O(n,u);let e=F.cd.custom.getBuilderPagePathname(n.id);if(c.asPath===e){let e=F.cd.page.getBuilderPagePathname(n.id);c.replace(e),x(!1)}else x(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.ar,{children:[(0,r.jsx)(o.av,{disabled:y,children:(0,r.jsx)(o.aZ,{color:"grey","data-testid":"editDropdown",hiddenLabel:"Custom type actions",icon:"moreVert",loading:y,variant:"solid"})}),(0,r.jsxs)(o.as,{align:"end",children:[(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"edit"}),onSelect:()=>{m(!0)},children:"Rename"}),"custom"===t&&!s&&(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"driveFileMove"}),onSelect:()=>void v(),children:"Convert to page type"}),(0,r.jsx)(o.at,{color:"tomato",startIcon:(0,r.jsx)(o.aX,{name:"delete"}),onSelect:()=>{p(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(j,{format:t,customType:n,onClose:()=>p(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):p(!1)}}):null,f?(0,r.jsx)(w,{format:t,customType:n,isChangesLocal:s,onClose:()=>m(!1),setLocalCustomType:a}):null]})}},50477:function(e,t,n){n.d(t,{NG:function(){return a},xU:function(){return l}});var r=n(18566),o=n(2784),i=n(80148);function l(e){let t=(0,o.useCallback)(t=>(0,r.VA)(s,[e],t),[e]);return{customTypes:(0,r.QT)(s,[e]),updateCustomTypes:t}}async function s(e){let{errors:t,models:n}=await i.managerClient.customTypes.readAllCustomTypes(e?{format:e}:void 0);if(t.length>0)throw t;return n.map(e=>{let{model:t}=e;return t})}function a(e){(0,r.gw)(s,[]),(0,r.gw)(s,[e])}},33986:function(e,t,n){n.d(t,{z:function(){return a}});var r=n(52322),o=n(2784),i=n(75289);let l=(e,t)=>e?"".concat(e,"-").concat(t):"",s=e=>{switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},a=(0,o.forwardRef)((e,t)=>{let{label:n,Icon:o,type:a,form:c,isLoading:u=!1,disabled:d=!1,onClick:p,sx:f={},iconSize:m=16,iconFill:y,variant:x="primary",...h}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...f,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:p,variant:x,...h,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:m,color:s(x),"data-testid":l(h["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:m,fill:y,"data-testid":l(h["data-testid"],"icon")}),n]})})})},46999:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(52322),o=n(63397);n(2784);var i=n(75289);let l=e=>{let{name:t,label:n,placeholder:l,error:s,testId:a,onChange:c}=e;return(0,r.jsxs)(i.xu,{mb:3,children:[(0,r.jsx)(i.__,{htmlFor:t,mb:2,children:n}),(0,r.jsx)(o.gN,{name:t,type:"text",placeholder:l,as:i.II,autoComplete:"off",...c?{onChange:c}:null,...a?{"data-testid":a}:null}),s?(0,r.jsx)(i.xv,{"data-testid":a?"".concat(a,"-error"):"input-error",sx:{color:"error",mt:1},children:s}):null]})}},59532:function(e,t,n){var r=n(52322),o=n(63397),i=n(37149),l=n.n(i),s=n(75289),a=n(33986),c=n(55862),u=n(30527);function d(e){let{children:t}=e,n=(0,u.W)();return(0,r.jsx)(s.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}t.Z=function(e){let{children:t,close:n,isOpen:i,formId:p,validate:f,onSubmit:m,widthInPx:y,initialValues:x,content:{title:h},cardProps:j,omitFooter:v=!1,isLoading:g=!1,buttonLabel:b="Save",testId:C,actionMessage:S}=e;return l().setAppElement("#__next"),(0,r.jsx)(c.Z,{isOpen:i,shouldCloseOnOverlayClick:!0,onRequestClose:n,contentLabel:h,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:x,validate:e=>f?f(e):void 0,onSubmit:e=>{m(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x}=e;return(0,r.jsx)(o.l0,{id:p,...null!=C?{"data-testid":C}:null,children:(0,r.jsx)(u.Z,{borderFooter:!0,footerSx:{p:3,position:"sticky",bottom:0,background:"gray"},bodySx:{px:4,py:4},sx:{border:"none"},...j,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:h}),(0,r.jsx)(s.x8,{type:"button",onClick:n})]}),Footer:v?null:(0,r.jsxs)(s.kC,{sx:{alignItems:"space-between"},children:[(0,r.jsx)(s.kC,{sx:{fontSize:"14px",alignItems:"center"},children:"function"==typeof S?S(e):S}),(0,r.jsxs)(s.kC,{sx:{ml:"auto"},children:[(0,r.jsx)(s.zx,{mr:2,type:"button",onClick:n,variant:"secondary",disabled:l||g,children:"Cancel"}),(0,r.jsx)(a.z,{label:b,form:p,type:"submit",disabled:!i||l||g,isLoading:l||g,sx:{fontWeight:"400",paddingBlock:"8px",paddingInline:"16px",fontSize:"14px",borderRadius:"4px"}})]})]}),children:t({isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x})})})}})})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{77630:function(e,t,n){n.d(t,{AK:function(){return v},E3:function(){return p},EN:function(){return f},F$:function(){return x},H8:function(){return C},HO:function(){return h},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return I},eK:function(){return S},gR:function(){return b},j5:function(){return a},mf:function(){return m},vB:function(){return y},xS:function(){return j},y6:function(){return i}});var r=n(98863),o=n(88866);function i(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function s(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function a(e){var t;let[n,r]=null!==(t=s(e))&&void 0!==t?t:[];return Object.entries(null!=r?r:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function c(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function u(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===o.SlicesFieldType})}function d(e,t){if(function(e,t){var n;let r=u(e,t),[o,i]=null!=r?r:[];return null!==(n=null==i?void 0:i.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let r=l(e),i=r.findIndex(e=>{let[n]=e;return n===t}),s=r.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===o.SlicesFieldType)}),a=i;do n="slices".concat(0!==a?a.toString():""),a++;while(s.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:o.SlicesFieldType,fieldset:"Slice Zone"}}}}}function p(e,t){let n=e.json[t];if(void 0===n)return e;let i=Object.keys(n).find(e=>n[e].type===o.SlicesFieldType);if(void 0===i)return e;let l=(0,r.ud)(n,i);return{...e,json:{...e.json,[t]:l}}}function f(e){var t,n;let{customType:i,sectionId:l,sliceId:s}=e,a=i.json[l];if(void 0===a)return i;let c=Object.keys(a).find(e=>a[e].type===o.SlicesFieldType);if(void 0===c)return i;let u=a[c];if(u.type!==o.SlicesFieldType)return i;let d=(0,r.ud)(null!==(n=null===(t=u.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},s);return{...i,json:{...i.json,[l]:{...a,[c]:{...u,config:{...u.config,choices:d}}}}}}function m(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=d(t,e)}return t}function y(e,t){return{...e,json:{...e.json,[t]:{}}}}function x(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function h(e,t,n){if(t===n)return e;let r=Object.keys(e.json).reduce((r,o)=>(o===t?r[n]=e.json[o]:r[o]=e.json[o],r),{});return{...e,json:r}}function j(e){let{customType:t,sectionId:n,newField:r,newFieldId:i}=e,l=t.json[n],s=u(t,n),a={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),[i]:r};if(void 0!==s){let[e,t]=s;a[e]=t}return T({customType:t,sectionId:n,updatedSection:a})}function v(e){let{customType:t,sectionId:n,fieldId:o}=e,i=(0,r.ud)(t.json[n],o);return T({customType:t,sectionId:n,updatedSection:i})}function g(e){let{customType:t,sectionId:n,previousFieldId:r,newFieldId:o,newField:i}=e,l=w({fields:t.json[n],previousFieldId:r,newFieldId:o,newField:i});return T({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:r,destinationIndex:i}=e,l=t.json[n],s=u(t,n),a=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),c="page"===t.format&&t.repeatable,d=Object.fromEntries(Object.entries(a).filter(e=>{let[t,n]=e;return"UID"!==n.type})),p=function(e){let{fields:t,sourceIndex:n,destinationIndex:r}=e,o=Object.entries(t),[i]=o.splice(n,1);return o.splice(r,0,i),Object.fromEntries(o)}({fields:c?d:a,sourceIndex:r,destinationIndex:i});if(void 0!==s){let[e,t]=s;p[e]=t}let f=Object.entries(p),m=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});m&&f.unshift(m);let y=Object.fromEntries(f);return T({customType:t,sectionId:n,updatedSection:c?y:p})}function C(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:j({customType:t,sectionId:r,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function S(e,t){var n,r;let[o]=null!==(n=s(t))&&void 0!==n?n:[],[i,l]=null!==(r=a(t))&&void 0!==r?r:[];if(!l||void 0===i||void 0===o)return t;let c=w({fields:t.json[o],previousFieldId:i,newFieldId:i,newField:{...l,config:{...l.config,label:e}}});return T({customType:t,sectionId:o,updatedSection:c})}function T(e){let{customType:t,sectionId:n,updatedSection:r}=e;return{...t,json:{...t.json,[n]:r}}}function w(e){let{fields:t,previousFieldId:n,newFieldId:r,newField:o}=e;return Object.entries(t).reduce((e,t)=>{let[i,l]=t;return i===n?e[r]=o:i!==r&&(e[i]=l),e},{})}function I(e){let{id:t,label:n,repeatable:r,format:o}=e,i=!1===r&&"page"===o?{...O,...R}:!1===r?k:"page"===o?{...N,...R}:F;return{format:o,id:t,json:i,label:n,repeatable:r,status:!0}}let k={Main:{}},O={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},F={Main:{uid:{type:"UID",config:{label:"UID"}}}},N={Main:{...F.Main,...O.Main}},R={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}}},60867:function(e,t,n){n.d(t,{_:function(){return N}});var r=n(52322),o=n(62079),i=n(5632),l=n(2784),s=n(65186),a=n(59326),c=n(75289),u=n(88932),d=n(80148),p=n(98564);async function f(e){let{customType:t,onSuccess:n}=e,r=p.$[t.format];try{let{errors:e}=await d.managerClient.customTypes.deleteCustomType({id:t.id});if(e.length>0)throw e;n(),u.Am.success("".concat(r.name({start:!0,plural:!1})," deleted"))}catch(t){let e="Internal Error: ".concat(r.name({start:!0,plural:!1})," could not be deleted");console.error(e,t),u.Am.error(e)}}var m=n(33986),y=n(30527),x=n(55862),h=n(54597);let j=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=p.$[o],[j,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,h.Z)(),b=async()=>{v(!0),await f({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:C}=(0,a.B7)();return(0,r.jsx)(x.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:()=>i(),children:(0,r.jsx)(y.Z,{bodySx:{p:0,bg:"white",position:"relative",height:"100%",padding:16},footerSx:{position:"sticky",bottom:0,p:0},sx:{border:"none",overflow:"hidden"},borderFooter:!0,Header:(0,r.jsxs)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))}},children:[(0,r.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,r.jsx)(s.$vK,{size:20,color:null===(t=C.colors)||void 0===t?void 0:t.greyIcon}),(0,r.jsxs)(c.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:["Delete"," ",d.name({start:!1,plural:!1})]})]}),(0,r.jsx)(c.x8,{type:"button",onClick:()=>i()})]}),Footer:()=>(0,r.jsxs)(c.kC,{sx:{justifyContent:"flex-end",height:64,alignItems:"center",paddingRight:16,borderTop:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.darkBorders))},backgroundColor:"gray"},children:[(0,r.jsx)(m.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(m.z,{label:"Delete",variant:"danger",isLoading:j,onClick:()=>void b(),sx:{minHeight:39,minWidth:78}})]}),children:(0,r.jsxs)("div",{children:["This action will immediately make the following change:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Delete the"," ",(0,r.jsxs)(c.xv,{sx:{fontWeight:"bold"},children:["customtypes/",null==n?void 0:n.id,"/"]})," ","directory."]})}),"The next time you push your changes to Prismic, the following change will happen:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Remove the"," ",d.name({start:!1,plural:!1})," and any associated Documents from your repository."]})})]})})})};var v=n(56580);async function g(e){let{model:t,newLabel:n,onSuccess:r}=e,o=p.$[t.format];try{let e={...t,label:n},{errors:i}=await d.managerClient.customTypes.renameCustomType({model:e});if(i.length>0)throw i;r(e),u.Am.success("".concat(o.name({start:!0,plural:!1})," renamed"))}catch(t){let e="Internal Error: ".concat(o.name({start:!0,plural:!1})," could not be renamed");console.error(e,t),u.Am.error(e)}}var b=n(68968),C=n(78254),S=n(59532),T=n(46999);let w=e=>{var t,n;let{isChangesLocal:o,customType:i,format:s,onClose:a,setLocalCustomType:u}=e,d=null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"",f=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:m}=(0,h.Z)(),{syncChanges:y}=(0,b.g)(),[x,j]=(0,l.useState)(!1),w=async e=>{j(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{m(e),y()}}),j(!1),a()},{customTypeLabels:I}=(0,v.v9)(e=>({customTypeLabels:(0,C.YS)(e)})),k=p.$[s];return(0,r.jsx)(S.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(f),buttonLabel:"Rename",close:a,onSubmit:e=>void w(e),initialValues:{customTypeName:d},isLoading:x,content:{title:"Rename a ".concat(k.name({start:!1,plural:!1}))},validate:e=>{let{customTypeName:t}=e,n={};return t&&t.length||(n.customTypeName="Cannot be empty."),void 0!=n.customTypeName&&I.includes(t)&&d!==t&&(n.customTypeName="".concat(k.name({start:!0,plural:!1})," name is already taken.")),["update","insert"].includes(t.toLowerCase())&&(n.customTypeName='Name "'.concat(t,'" is reserved for Slice Machine use.')),Object.keys(n).length>0?n:void 0},children:e=>{let{errors:t}=e;return(0,r.jsx)(c.xu,{children:(0,r.jsx)(T.W,{name:"customTypeName",label:"".concat(k.name({start:!0,plural:!1})," Name"),placeholder:"A display name for the ".concat(k.name({start:!1,plural:!1})),error:t.customTypeName,testId:"custom-type-name-input"})})}})};var I=n(94160),k=n(77630);async function O(e,t){let n=p.$[e.format];try{let r=(0,k.mf)(e),{errors:o}=await (0,I.KA)({customType:r});if(o.length>0)throw o;t(r),u.Am.success("".concat(n.name({start:!0,plural:!1})," converted to page type"))}catch(t){let e="Internal Error: ".concat(n.name({start:!0,plural:!1})," not converted to page type");console.error(e,t),u.Am.error(e)}}var F=n(59294);let N=e=>{let{format:t,customType:n,isChangesLocal:s,setLocalCustomType:a}=e,c=(0,i.useRouter)(),{saveCustomTypeSuccess:u}=(0,h.Z)(),[d,p]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[y,x]=(0,l.useState)(!1),v=async()=>{x(!0),await O(n,u);let e=F.cd.custom.getBuilderPagePathname(n.id);if(c.asPath===e){let e=F.cd.page.getBuilderPagePathname(n.id);c.replace(e),x(!1)}else x(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.ar,{children:[(0,r.jsx)(o.av,{disabled:y,children:(0,r.jsx)(o.aZ,{color:"grey","data-testid":"editDropdown",hiddenLabel:"Custom type actions",icon:"moreVert",loading:y,variant:"solid"})}),(0,r.jsxs)(o.as,{align:"end",children:[(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"edit"}),onSelect:()=>{m(!0)},children:"Rename"}),"custom"===t&&!s&&(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"driveFileMove"}),onSelect:()=>void v(),children:"Convert to page type"}),(0,r.jsx)(o.at,{color:"tomato",startIcon:(0,r.jsx)(o.aX,{name:"delete"}),onSelect:()=>{p(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(j,{format:t,customType:n,onClose:()=>p(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):p(!1)}}):null,f?(0,r.jsx)(w,{format:t,customType:n,isChangesLocal:s,onClose:()=>m(!1),setLocalCustomType:a}):null]})}},50477:function(e,t,n){n.d(t,{NG:function(){return a},xU:function(){return l}});var r=n(18566),o=n(2784),i=n(80148);function l(e){let t=(0,o.useCallback)(t=>(0,r.VA)(s,[e],t),[e]);return{customTypes:(0,r.QT)(s,[e]),updateCustomTypes:t}}async function s(e){let{errors:t,models:n}=await i.managerClient.customTypes.readAllCustomTypes(e?{format:e}:void 0);if(t.length>0)throw t;return n.map(e=>{let{model:t}=e;return t})}function a(e){(0,r.gw)(s,[]),(0,r.gw)(s,[e])}},33986:function(e,t,n){n.d(t,{z:function(){return a}});var r=n(52322),o=n(2784),i=n(75289);let l=(e,t)=>e?"".concat(e,"-").concat(t):"",s=e=>{switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},a=(0,o.forwardRef)((e,t)=>{let{label:n,Icon:o,type:a,form:c,isLoading:u=!1,disabled:d=!1,onClick:p,sx:f={},iconSize:m=16,iconFill:y,variant:x="primary",...h}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...f,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:p,variant:x,...h,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:m,color:s(x),"data-testid":l(h["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:m,fill:y,"data-testid":l(h["data-testid"],"icon")}),n]})})})},46999:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(52322),o=n(63397);n(2784);var i=n(75289);let l=e=>{let{name:t,label:n,placeholder:l,error:s,testId:a,onChange:c}=e;return(0,r.jsxs)(i.xu,{mb:3,children:[(0,r.jsx)(i.__,{htmlFor:t,mb:2,children:n}),(0,r.jsx)(o.gN,{name:t,type:"text",placeholder:l,as:i.II,autoComplete:"off",...c?{onChange:c}:null,...a?{"data-testid":a}:null}),s?(0,r.jsx)(i.xv,{"data-testid":a?"".concat(a,"-error"):"input-error",sx:{color:"error",mt:1},children:s}):null]})}},59532:function(e,t,n){var r=n(52322),o=n(63397),i=n(37149),l=n.n(i),s=n(75289),a=n(33986),c=n(55862),u=n(30527);function d(e){let{children:t}=e,n=(0,u.W)();return(0,r.jsx)(s.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}t.Z=function(e){let{children:t,close:n,isOpen:i,formId:p,validate:f,onSubmit:m,widthInPx:y,initialValues:x,content:{title:h},cardProps:j,omitFooter:v=!1,isLoading:g=!1,buttonLabel:b="Save",testId:C,actionMessage:S}=e;return l().setAppElement("#__next"),(0,r.jsx)(c.Z,{isOpen:i,shouldCloseOnOverlayClick:!0,onRequestClose:n,contentLabel:h,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:x,validate:e=>f?f(e):void 0,onSubmit:e=>{m(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x}=e;return(0,r.jsx)(o.l0,{id:p,...null!=C?{"data-testid":C}:null,children:(0,r.jsx)(u.Z,{borderFooter:!0,footerSx:{p:3,position:"sticky",bottom:0,background:"gray"},bodySx:{px:4,py:4},sx:{border:"none"},...j,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:h}),(0,r.jsx)(s.x8,{type:"button",onClick:n})]}),Footer:v?null:(0,r.jsxs)(s.kC,{sx:{alignItems:"space-between"},children:[(0,r.jsx)(s.kC,{sx:{fontSize:"14px",alignItems:"center"},children:"function"==typeof S?S(e):S}),(0,r.jsxs)(s.kC,{sx:{ml:"auto"},children:[(0,r.jsx)(s.zx,{mr:2,type:"button",onClick:n,variant:"secondary",disabled:l||g,children:"Cancel"}),(0,r.jsx)(a.z,{label:b,form:p,type:"submit",disabled:!i||l||g,isLoading:l||g,sx:{fontWeight:"400",paddingBlock:"8px",paddingInline:"16px",fontSize:"14px",borderRadius:"4px"}})]})]}),children:t({isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x})})})}})})}}}]);