slice-machine-ui 2.17.3-beta.5 → 2.17.3-beta.7
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.
- package/out/404.html +1 -1
- package/out/_next/static/chunks/489-f1d584386a1ead7e.js +1 -0
- package/out/_next/static/chunks/907-590c914f55547b96.js +1 -0
- package/out/_next/static/chunks/pages/{_app-dfa3db63a1a925f5.js → _app-df4a4d1aaa9d7216.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-041985d94bb9649f.js → [customTypeId]-4024560ca59ad2be.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-338f685c0723043b.js → [pageTypeId]-0d2416da0958eb40.js} +1 -1
- package/out/_next/static/chunks/pages/slices-a0aa3bbe2cf1689c.js +1 -0
- package/out/_next/static/{xO65G45I4C_HBK2GwwCWX → i3RCInXoJzCEi4NnU8YGb}/_buildManifest.js +1 -1
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +9 -13
- package/src/features/environments/actions/getActiveEnvironment.ts +20 -5
- package/src/features/navigation/Navigation.tsx +3 -5
- package/src/legacy/components/AppLayout/index.tsx +34 -2
- package/src/legacy/components/Navigation/Environment.tsx +11 -3
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +9 -13
- package/src/pages/slices.tsx +9 -13
- package/out/_next/static/chunks/268-6a9214b97195af9c.js +0 -1
- package/out/_next/static/chunks/489-7e73874528df7603.js +0 -1
- package/out/_next/static/chunks/pages/slices-4a60cd5f2c71327e.js +0 -1
- package/src/features/builder/useAiSliceGenerationExperiment.ts +0 -8
- /package/out/_next/static/{xO65G45I4C_HBK2GwwCWX → i3RCInXoJzCEi4NnU8YGb}/_ssgManifest.js +0 -0
package/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/cc9b10286400c2b9.css" as="style"/><link rel="stylesheet" href="/_next/static/css/cc9b10286400c2b9.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-b3522fdebabf510a.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-c46f4dcf6e3174bd.js" defer=""></script><script src="/_next/static/chunks/pages/_app-
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/cc9b10286400c2b9.css" as="style"/><link rel="stylesheet" href="/_next/static/css/cc9b10286400c2b9.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-b3522fdebabf510a.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-c46f4dcf6e3174bd.js" defer=""></script><script src="/_next/static/chunks/pages/_app-df4a4d1aaa9d7216.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/i3RCInXoJzCEi4NnU8YGb/_buildManifest.js" defer=""></script><script src="/_next/static/i3RCInXoJzCEi4NnU8YGb/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"i3RCInXoJzCEi4NnU8YGb","runtimeConfig":{"sentryEnvironment":"beta"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[489],{19489:function(e,t,l){"use strict";l.d(t,{H:function(){return e6}});var n=l(52322),a=l(56803),i=l(97729),o=l.n(i),r=l(5632),s=l(2784),c=l(56580),d=l(43388),u=l(77630),m=l(23094),h=l(59294),p=l(51384),x=l(74217),v=l(94160),b=l(68968),y=l(23710),f=l(54597),g=l(98564);let j=(0,s.createContext)(void 0);function S(e){let{children:t,initialCustomType:l}=e,[a,i]=(0,s.useState)(l),o=(0,u.y6)(a),r=g.$[o],{actionQueueStatus:c,setNextAction:d}=(0,y.c)({errorMessage:r.autoSaveFailed}),{refreshState:m}=(0,f.Z)(),h=(0,x.R9)(m),{syncChanges:p}=(0,b.g)(),S=(0,s.useCallback)(e=>{let{customType:t,onSaveCallback:l,updateMeta:n}=e;i(t),d(async()=>{let{errors:e}=await (0,v.KA)({customType:t,updateMeta:n});if(e.length>0)throw e;h(await (0,v.y0)()),p(),null==l||l()})},[d,h,p]),I=(0,s.useMemo)(()=>({actionQueueStatus:c,customType:a,setCustomType:S}),[c,a,S]);return(0,n.jsx)(j.Provider,{value:I,children:"function"==typeof t?t(I):t})}function I(){let e=(0,s.useContext)(j);if(!e)throw Error("CustomTypeProvider not found");return e}var C=l(30195);function T(){var e;let[t,l]=(0,s.useState)(!1),{customType:i,setCustomType:o}=I(),[r,c]=null!==(e=(0,u.j5)(i))&&void 0!==e?e:[],d=c?(0,u.N3)(c):"",[m,h]=(0,s.useState)(null!=d?d:""),[p,v]=(0,s.useState)();(0,x.pQ)(t,()=>{t||(h(null!=d?d:""),v(void 0))});let b=(0,s.useCallback)(()=>(0,n.jsx)(a.aX,{name:c?"language":"add",size:"small",color:"grey11"}),[c]);return(0,n.jsxs)(a.ae,{open:t,onOpenChange:l,size:"small",trigger:(0,n.jsx)(a.E,{color:"grey",textColor:"placeholder",textWeight:"normal",renderStartIcon:b,sx:{marginInline:"auto"},children:c?d:"Add an UID"}),children:[(0,n.jsx)(a.al,{title:"Edit the UID label"}),(0,n.jsx)(a.aj,{children:(0,n.jsxs)(a.aJ,{onSubmit:function(){p||(o({customType:c?(0,u.eK)(m,i):(0,u.H8)(m,i)}),l(!1))},children:[(0,n.jsx)(a.D,{flexDirection:"column",padding:16,gap:4,children:(0,n.jsx)(a.aM,{type:"text",label:"Label *",placeholder:"UID",value:m,onValueChange:function(e){h(e),v(function(e){let t=D.safeParse(e,{errorMap:k});if(t.error)return t.error.errors[0].message}(e))},error:p,description:"A label for the UID"})}),(0,n.jsxs)(a.ah,{children:[(0,n.jsx)(a.ai,{size:"medium"}),(0,n.jsx)(a.af,{type:"submit",size:"medium",disabled:!!p,children:"Save"})]})]})})]})}let D=C.z.string().max(35).min(1),k=e=>{switch(e.code){case C.z.ZodIssueCode.too_big:return{message:"The label can't be longer than ".concat(e.maximum," characters")};case C.z.ZodIssueCode.too_small:return{message:"This field is required"};default:return{message:"Invalid value"}}};var w=l(94840),_=l(59532),L=l(63397),A=l(75289);let E=e=>{let{name:t,label:l,placeholder:a,error:i,...o}=e;return(0,n.jsxs)(A.xu,{mb:3,children:[(0,n.jsx)(A.__,{htmlFor:t,mb:2,children:l}),(0,n.jsx)(L.gN,{name:t,type:"text",placeholder:a,as:A.II,autoComplete:"off",...o}),i?(0,n.jsx)(A.xv,{sx:{color:"error",mt:1},children:i}):null]})};var N=e=>{let{isOpen:t,onSubmit:l,close:a,tabIds:i}=e;return(0,n.jsx)(_.Z,{isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,onSubmit:e=>{l(e),a()},initialValues:{id:""},validate:e=>{let{id:t}=e;return t?i.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Add Tab"},children:e=>{let{errors:t}=e;return(0,n.jsx)(E,{name:"id",label:"New Tab ID",placeholder:"A label for selecting the tab (i.e. not used in the API)",error:t.id})}})},M=e=>{let{isOpen:t,onSubmit:l,close:a}=e;return(0,n.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{l(e),a()},initialValues:{},content:{title:"Remove Tab"},children:()=>(0,n.jsxs)(A.xu,{sx:{px:4,py:4},children:[(0,n.jsx)(A.X6,{as:"h4",children:"Remove this tab?"}),(0,n.jsx)(A.xv,{as:"p",color:"textClear",sx:{mt:2},children:"This action cannot be undone."}),(0,n.jsx)(A.zx,{type:"button",variant:"buttons.actionDelete",sx:{mt:3},onClick:()=>{l({}),a()},children:"Yes, remove tab"})]})})},z=e=>{let{isOpen:t,onSubmit:l,close:a,tabIds:i,initialTabKey:o}=e;return(0,n.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{l(e),a()},initialValues:{id:o},validate:e=>{let{id:t}=e;return t?i.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Rename Tab"},children:e=>{let{errors:t,values:i,setFieldValue:o,isValid:r}=e;return(0,n.jsxs)(A.xu,{sx:{px:4,py:4},children:[(0,n.jsx)(E,{name:"id",label:"Rename Tab ID",placeholder:"A label for selecting the tab (i.e. not used in the API)",error:t.id,onBlur:e=>{i.id!==e.target.value&&o("id",e.target.value.trim())},onChange:e=>{o("id",e.target.value)}}),(0,n.jsx)(A.zx,{type:"button",sx:{mt:3,width:"100%"},disabled:!r,onClick:()=>{i.id&&i.id.length&&l({id:i.id.trim()}),a()},children:"Save"})]})}})},Z=l(28316),O=l(88932),P=l(35289),F=l(17378),K=l(45440),B=l(16086),R=l(358),U=l(5495),V=l(39302),X=l(3285),G=l(40141),Y=l(65077),q=l(63470),H=l(91589),Q=l(27213),W=l(31860);let $=e=>{let{openCreateSliceModal:t,openCreateSliceFromImageModal:l,openUpdateSliceZoneModal:i,openSlicesTemplatesModal:o,projectHasAvailableSlices:r,isSlicesTemplatesSupported:s}=e,c=(0,q.k)(),d=(0,Q.F)({menuType:"ActionList",sectionsNamingExperiment:c});return(0,n.jsxs)(a.s,{"data-testid":"slice-zone-blank-slate",sx:{width:648},children:[(0,n.jsx)(a.x,{lineColor:"purple9",backgroundColor:"purple5",name:"add",size:"large"}),(0,n.jsxs)(a.z,{size:"big",children:["Add ",(0,W._)(c.value)]}),(0,n.jsxs)(a.w,{children:[(0,W._)((0,W.f)(c.value))," are website sections that you can reuse on different pages with different content. Each on different pages with different content. Each"," ",c.value," has its own component in your code."]}),(0,n.jsx)(a.v,{children:(0,n.jsxs)(a.A,{children:[(0,n.jsx)(a.b,{renderStartIcon:()=>d.fromImage.BackgroundIcon,onClick:l,description:d.fromImage.description,children:d.fromImage.title}),(0,n.jsx)(a.b,{renderStartIcon:()=>d.fromScratch.BackgroundIcon,onClick:t,description:d.fromScratch.description,children:d.fromScratch.title}),s&&(0,n.jsx)(a.b,{renderStartIcon:()=>d.fromTemplate.BackgroundIcon,onClick:o,description:d.fromTemplate.description,children:d.fromTemplate.title}),r&&(0,n.jsx)(a.b,{renderStartIcon:()=>d.fromExisting.BackgroundIcon,onClick:i,description:d.fromExisting.description,children:d.fromExisting.title})]})})]})};var J=l(98250);function ee(e){let{customType:t,tabId:l,slices:n}=e,a={...t};return n.forEach(e=>{a={...a,tabs:a.tabs.map(t=>t.key===l&&t.sliceZone?{...t,sliceZone:{key:t.sliceZone.key,value:[{key:e.id,value:e},...t.sliceZone.value]}}:t)}}),v.Xe.track({event:"custom-type:slice-zone-updated",customTypeId:t.id}),a}var et=l(18566),el=l(80148);async function en(){try{let{templates:e,errors:t}=await el.managerClient.sliceTemplateLibrary.readLibrary({});if(t.length>0)throw t;return e.map(e=>({model:e.model,screenshots:Object.fromEntries(Object.entries(e.screenshots).map(e=>{let[t,l]=e;return[t,URL.createObjectURL(l)]}))}))}catch(e){return[]}}var ea=l(6256),ei=l(39204),eo=l(7723),er=l(33986),es=l(30527),ec=l(55862);let ed=e=>{let{deleteSliceZone:t,closeDeleteSliceZoneModal:l}=e;return(0,n.jsx)(ec.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:l,children:(0,n.jsx)(es.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,n.jsxs)(A.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,n.jsx)(A.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:"Do you really want to delete Slice Zone?"}),(0,n.jsx)(A.x8,{type:"button",onClick:l})]}),Footer:()=>(0,n.jsxs)(A.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,n.jsx)(er.z,{label:"Cancel",variant:"secondary",onClick:l,sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),(0,n.jsx)(er.z,{label:"Delete",variant:"danger",onClick:t,sx:{minHeight:39,minWidth:78}})]}),children:(0,n.jsx)(A.nv,{children:"You're about to delete Slice Zone."})})})};var eu=l(43776),em=l(62434),eh=l(63908),ep=l(63019),ex=l(65375),ev=l.n(ex);let eb=e=>{var t;let{isOpen:l,close:i,onSubmit:o,isLoading:r,slice:d,libraries:u}=e,{remoteSlices:m}=(0,c.v9)(e=>({remoteSlices:(0,eo.sT)(e)})),h={from:null===(t=u[0])||void 0===t?void 0:t.name,sliceName:(0,R.MP)(d.key)},[p,v]=(0,s.useState)(h),[b,y]=(0,s.useState)();function f(e){v(e),y((0,ep.h)(e,u,m))}return(0,x.pQ)(l,()=>{l||(v(h),y(void 0))}),(0,n.jsxs)(a.ae,{open:l,onOpenChange:e=>!e&&i(),size:{width:448,height:"auto"},children:[(0,n.jsx)(a.al,{title:"Upgrade slice"}),(0,n.jsx)(a.aj,{children:(0,n.jsx)(a.aJ,{onSubmit:function(){b&&Object.keys(b).length>0||o({libraryID:p.from,sliceID:p.sliceName})},children:(0,n.jsxs)(a.D,{flexDirection:"column",children:[(0,n.jsxs)(a.bn,{className:ev().scrollArea,children:[(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"This will create a new slice with the same fields. The new slice will replace the legacy slice in all of your types, and the existing slice content will be re-mapped to the new slice."}),(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"This will not migrate your component. You will need to do that manually."}),(0,n.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,n.jsx)(a.aM,{label:"Slice name *",placeholder:"Pascalised Slice API ID (e.g. ".concat((0,R.MP)(d.key),")"),error:null==b?void 0:b.sliceName,value:p.sliceName,onValueChange:e=>f({...p,sliceName:e.slice(0,30)}),"data-testid":"slice-name-input"}),(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"A display name for the slice"})]}),(0,n.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,n.jsx)("label",{className:ev().label,children:(0,n.jsx)(a.bL,{variant:"bold",children:"Slice library *"})}),(0,n.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"folder",flexContent:!0,value:p.from,onValueChange:e=>{e&&f({...p,from:e})},children:u.map(e=>(0,n.jsx)(a.bt,{value:e.name,children:e.name},e.name))}),(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"The library where we'll store your slice"})]})]}),(0,n.jsxs)(a.ah,{children:[(0,n.jsx)(a.ai,{size:"medium"}),(0,n.jsx)(a.af,{type:"submit",size:"medium",loading:r,disabled:b&&Object.keys(b).length>0,children:"Upgrade"})]})]})})})]})};var ey=l(96009),ef=l.n(ey);let eg=e=>{var t,l;let{isOpen:i,close:o,onSubmit:r,isLoading:c,slice:d,sliceName:u,libraries:m,localSharedSlices:h}=e,p={libraryID:null===(t=h[0])||void 0===t?void 0:t.from,sliceID:null===(l=h[0])||void 0===l?void 0:l.model.id,variationID:ef()(d.key),variationName:u},[v,b]=(0,s.useState)(!0),[y,f]=(0,s.useState)(p),[g,j]=(0,s.useState)({});function S(e){f(e),j(ej(e,m))}return(0,x.pQ)(i,()=>{i||(f(p),j({}))}),(0,n.jsxs)(a.ae,{open:i,onOpenChange:e=>!e&&o(),size:{width:448,height:"auto"},children:[(0,n.jsx)(a.al,{title:"Convert to slice variation"}),(0,n.jsx)(a.aj,{children:(0,n.jsx)(a.aJ,{onSubmit:function(){Object.keys(g).length>0||r(y)},children:(0,n.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,n.jsxs)(a.bn,{className:ev().scrollArea,children:[(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple slices that are similar, you can combine them as variations of the same slice."}),(0,n.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,n.jsxs)("label",{className:ev().label,children:[(0,n.jsx)(a.bL,{variant:"bold",children:"Target slice *"}),"string"==typeof g.libraryID?(0,n.jsx)(a.bL,{variant:"small",color:"tomato10",children:g.libraryID}):null,"string"==typeof g.sliceID?(0,n.jsx)(a.bL,{variant:"small",color:"tomato10",children:g.sliceID}):null]}),(0,n.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:"".concat(y.libraryID,"::").concat(y.sliceID),onValueChange:e=>{if(e){let[t,l]=e.split("::");S({...y,libraryID:t,sliceID:l})}},children:h.map(e=>(0,n.jsxs)(a.bt,{value:"".concat(e.from,"::").concat(e.model.id),children:[e.from," ",">"," ",e.model.name," (",e.model.id,")"]},"".concat(e.from,"::").concat(e.model.id)))}),(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"Choose the slice to which you would like to add this variation."})]}),(0,n.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,n.jsx)(a.aM,{label:"Variation name *",placeholder:u,error:g.variationName,value:y.variationName,onValueChange:e=>{let t={...y,variationName:e.slice(0,30)};v&&(t.variationID=ef()(t.variationName)),S(t)},"data-testid":"variation-name-input"})}),(0,n.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,n.jsx)(a.aM,{label:"ID *",placeholder:ef()(d.key),error:g.variationID,value:y.variationID,onValueChange:e=>{b(!1),S({...y,variationID:e.slice(0,30)})},"data-testid":"variation-id-input"})})]}),(0,n.jsxs)(a.ah,{children:[(0,n.jsx)(a.ai,{size:"medium"}),(0,n.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:Object.keys(g).length>0,children:"Convert"})]})]})})})]})},ej=(e,t)=>{let l={};e.libraryID||(l.libraryID="Cannot be empty.");let n=t.find(t=>t.path===e.libraryID);l.libraryID||n||(l.libraryID="Does not exist."),e.sliceID||(l.sliceID="Cannot be empty.");let a=null==n?void 0:n.components.find(t=>t.model.id===e.sliceID);if(l.sliceID||a||(l.sliceID="Does not exist."),e.variationName||(l.variationName="Cannot be empty."),e.variationID){var i;(null!==(i=null==a?void 0:a.model.variations.map(e=>e.id))&&void 0!==i?i:[]).includes(e.variationID)&&(l.variationID="Slice variation ID is already taken.")}else l.variationID="Cannot be empty.";return l},eS=e=>{var t,l;let{isOpen:i,close:o,onSubmit:r,isLoading:c,identicalSlices:d}=e,u=null!==(l=null===(t=d[0])||void 0===t?void 0:t.path)&&void 0!==l?l:"",[m,h]=(0,s.useState)(u),[p,v]=(0,s.useState)();return(0,x.pQ)(i,()=>{i||(h(u),v(void 0))}),(0,n.jsxs)(a.ae,{open:i,onOpenChange:e=>!e&&o(),size:{width:448,height:"auto"},children:[(0,n.jsx)(a.al,{title:"Merge with an existing slice"}),(0,n.jsx)(a.aj,{children:(0,n.jsx)(a.aJ,{onSubmit:function(){if(p)return;let[e,t,l]=m.split("::");r({libraryID:e,sliceID:t,variationID:l})},children:(0,n.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,n.jsxs)(a.bn,{className:ev().scrollArea,children:[(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple identical slices, you can merge them. All of your content will be remapped to the target slice."}),(0,n.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,n.jsxs)("label",{className:ev().label,children:[(0,n.jsx)(a.bL,{variant:"bold",children:"Target slice*"}),"string"==typeof p?(0,n.jsx)(a.bL,{variant:"small",color:"tomato10",children:p}):null]}),(0,n.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:m,onValueChange:function(e){h(e),e||v("Cannot be empty.")},children:d.map(e=>(0,n.jsx)(a.bt,{value:e.path,children:e.path.split("::").join(" > ")},e.path))}),(0,n.jsx)(a.bL,{variant:"normal",color:"grey11",children:"Choose a slice that you would like to merge this into."})]})]}),(0,n.jsxs)(a.ah,{children:[(0,n.jsx)(a.ai,{size:"medium"}),(0,n.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:!!p,children:"Merge"})]})]})})})]})},eI=e=>{var t;let{slice:l,path:i}=e,{refreshState:o}=(0,f.Z)(),[r,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(),{setCustomType:h}=I(),{libraries:p}=(0,c.v9)(e=>({libraries:(0,eo.Sd)(e)})),x="Slice"===l.value.type&&null!==(t=l.value.fieldset)&&void 0!==t?t:l.key,b=p.filter(e=>e.isLocal),y=b.map(e=>e.components).flat(),g=eC(l,x,y),j=async e=>{var t,n,a;if(!u)return;d(!0),v.Xe.track({event:"legacy-slice:converted",id:e.sliceID,variation:null!==(t=e.variationID)&&void 0!==t?t:"default",library:e.libraryID,conversionType:u});let{errors:r}=await el.managerClient.slices.convertLegacySliceToSharedSlice({model:l.value,src:{...i,sliceID:l.key},dest:{libraryID:e.libraryID,sliceID:e.sliceID,variationName:null!==(n=e.variationName)&&void 0!==n?n:"Default",variationID:null!==(a=e.variationID)&&void 0!==a?a:"default"}});if(r.length)throw console.error("Could not convert slice `".concat(x,"`"),r),O.Am.error("Could not convert slice `".concat(x,"`")),r;let{model:s,errors:c}=await el.managerClient.customTypes.readCustomType({id:i.customTypeID});if(c.length||!s){console.error("Could not refresh custom type view `".concat(i.customTypeID,"`"),c),O.Am.error("Could not refresh custom type view `".concat(i.customTypeID,"`"));return}switch(o(await (0,v.y0)()),d(!1),m(void 0),u){case"as_new_slice":O.Am.success("".concat(x," has been upgraded to a new slice ").concat(e.libraryID," > ").concat(e.sliceID));break;case"as_new_variation":O.Am.success("".concat(x," has been converted as a variation of ").concat(e.libraryID," > ").concat(e.sliceID));break;default:O.Am.success("".concat(x," has been merged with ").concat(e.libraryID," > ").concat(e.sliceID))}h({customType:s})},S={path:i,slice:l,sliceName:x,libraries:b,localSharedSlices:y,identicalSlices:g,close:()=>m(void 0),onSubmit:j,isLoading:r};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a.ar,{children:[(0,n.jsx)(a.av,{children:(0,n.jsx)(a.E,{"data-testid":"convert-legacy-slice",startIcon:"refresh",endIcon:"arrowDropDown",size:"medium",color:"grey",children:"Migrate legacy slice"})}),(0,n.jsxs)(a.as,{align:"start",children:[(0,n.jsx)(a.at,{startIcon:(0,n.jsx)(a.aX,{name:"folder",size:"large"}),description:"Use it with new types",onSelect:()=>m("as_new_slice"),children:"Upgrade slice"}),(0,n.jsx)(a.at,{startIcon:(0,n.jsx)(a.aX,{name:"viewDay",size:"large"}),description:"Add it to another slice",onSelect:()=>m("as_new_variation"),disabled:!y.length,children:"Convert to slice variation"}),(0,n.jsx)(a.at,{startIcon:(0,n.jsx)(a.aX,{name:"driveFileMove",size:"large"}),description:"Combine identical slices",onSelect:()=>m("merge_with_identical"),disabled:!g.length,children:"Merge with another slice"})]})]}),(0,n.jsx)(eb,{...S,isOpen:"as_new_slice"===u}),(0,n.jsx)(eg,{...S,isOpen:"as_new_variation"===u}),(0,n.jsx)(eS,{...S,isOpen:"merge_with_identical"===u})]})},eC=(e,t,l)=>(0,s.useMemo)(()=>{let n=[],a=(0,eh.ux)(e.value,t);for(let e of l)for(let t of e.model.variations){let l=(0,eh.ux)(t,e.model.name);a.primary===l.primary&&a.items===l.items&&n.push({libraryID:e.from,sliceID:e.model.id,variationID:t.id,path:"".concat(e.from,"::").concat(e.model.id,"::").concat(t.id)})}return n},[e,t,l]),eT=e=>{let{slice:t,path:l}=e,[i]=(0,eu.E)("legacySliceUpgrader"),o=i.enabled?"This Slice was created with the Legacy Builder. It needs to be converted first to be used within Slice Machine.":"This Slice was created with the Legacy Builder, and is incompatible with Slice Machine. You cannot edit, push, or delete it in Slice Machine. In order to proceed, manually remove the Slice from your type model. Then create a new Slice with the same fields using Slice Machine.";return(0,n.jsxs)(em.Zb,{children:[(0,n.jsx)(em.ZB,{component:"div",children:(0,n.jsx)(a.D,{alignItems:"center",justifyContent:"center",children:(0,n.jsx)(a.bL,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,n.jsxs)(em.T$,{children:[(0,n.jsx)(a.c3,{content:o,side:"bottom",children:(0,n.jsx)(a.m,{color:"purple",title:"Legacy Slice"})}),i.enabled?(0,n.jsx)(eI,{slice:t,path:l}):null]}),(0,n.jsx)(em.eW,{subtitle:"1 variation",title:(0,eh.Dj)(t.value)})]})};var eD=l(51507),ek=l(21151);let ew=e=>{let{slices:t,format:l,path:a,onRemoveSharedSlice:i}=e,o=t.some(e=>"SharedSlice"!==e.type),r=g.$[l],[c]=(0,eu.E)("legacySliceUpgrader");return(0,s.useEffect)(()=>{o&&(c.enabled?O.Am.info("This ".concat(r.name({start:!1,plural:!1})," contains legacy slices that can be upgraded.")):O.Am.warning("This ".concat(r.name({start:!1,plural:!1})," contains slices that are incompatible.")))},[o]),(0,n.jsx)(ek.Z,{elems:t,defineElementKey:e=>"SharedSlice"!==e.type?e.payload.key:e.payload.model.name,renderElem:e=>{if("SharedSlice"!==e.type){let t=e.payload;return(0,n.jsx)(eT,{slice:t,path:a})}{let t=e.payload;return(0,n.jsx)(eD.b,{action:{type:"remove",onRemove:()=>{i(t.model.id)}},mode:"navigation",slice:t,variant:"solid"})}},sx:{padding:"16px"}})};async function e_(e){try{let{templateIDs:t,localLibrariesNames:l,location:n,onSuccess:a}=e,{data:i,errors:o}=await el.managerClient.sliceTemplateLibrary.createSlices({templateIDs:t});if(o.length>0||void 0===i)throw o;i.sliceIDs.forEach((e,a)=>{v.Xe.track({event:"slice:created",id:e,name:e,library:l[0],location:n,mode:"template",sliceTemplate:t[a]})}),await a(i.sliceIDs)}catch(t){let e="Internal Error: Slice(s) not created";console.error(e,t),O.Am.error(e)}}var eL=l(26109),eA=e=>{let{availableSlices:t,values:l}=e;return(0,n.jsx)(L.F2,{name:"sliceKeys",render:e=>(0,n.jsx)(ek.Z,{gridTemplateMinPx:"200px",elems:t,defineElementKey:e=>"".concat(e.from,"-").concat(e.model.name),renderElem:t=>{let a=l.sliceKeys.includes(t.model.id);return(0,n.jsx)(eD.b,{action:{type:"checkbox"},mode:"selection",onSelectedChange:n=>{n?e.push(t.model.id):e.remove(l.sliceKeys.indexOf(t.model.id))},selected:a,slice:t,variant:"outlined"})}})})};let eE=e=>{let{formId:t,close:l,onSuccess:a,availableSlicesTemplates:i,localLibraries:o,location:r}=e,{createSliceSuccess:s}=(0,f.Z)(),c=(0,q.k)();return(0,n.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:l,onSubmit:e=>{let{sliceKeys:t}=e;e_({templateIDs:t,localLibrariesNames:o.map(e=>e.name),location:r,onSuccess:async e=>{s((await (0,v.y0)()).libraries),a(await Promise.all(e.map(async e=>(await el.managerClient.slices.readSlice({libraryID:o[0].name,sliceID:e})).model).filter(e=>void 0!==e)))}})},initialValues:{sliceKeys:[]},content:{title:"Use template ".concat((0,W._)(c.value))},validate:e=>{if(0===e.sliceKeys.length)return{sliceKeys:"Select at least one template to add"}},actionMessage:e=>{let{errors:t}=e;return void 0!==t.sliceKeys?(0,n.jsx)(A.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,n.jsx)(eA,{values:t,availableSlices:i.map(e=>({extension:"",fileName:"",from:"",href:"",pathToSlice:"",model:eL.id.toSM(e.model),screenshots:Object.entries(e.screenshots).reduce((e,t)=>({...e,[t[0]]:{url:t[1]}}),{})}))})}})};var eN=e=>{let{formId:t,close:l,onSubmit:a,availableSlices:i}=e,o=(0,q.k)();return(0,n.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:l,onSubmit:e=>{let{sliceKeys:t}=e;a(t.map(e=>{var t;return null===(t=i.find(t=>t.model.id===e))||void 0===t?void 0:t.model}).filter(e=>void 0!==e))},initialValues:{sliceKeys:[]},content:{title:"Select existing ".concat((0,W._)(o.value))},testId:"update-slices-modal",validate:e=>{if(0===e.sliceKeys.length)return{sliceKeys:"Select at least one slice to add"}},actionMessage:e=>{let{errors:t}=e;return void 0!==t.sliceKeys?(0,n.jsx)(A.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,n.jsx)(eA,{values:t,availableSlices:i})}})};let eM=(e,t)=>{let l=(t||[]).reduce((e,t)=>[...e,...t.components],[]),{slicesInSliceZone:n,notFound:a}=e.value.reduce((e,t)=>{let{key:n,value:a}=t;if("SharedSlice"===a.type){let t=l.find(e=>e.model.id===n);return t?{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"SharedSlice",payload:t}]}:{...e,notFound:[...e.notFound,{key:n}]}}return{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"Slice",payload:{key:n,value:a}}]}},{slicesInSliceZone:[],notFound:[]});return{availableSlices:l,slicesInSliceZone:n,notFound:a}};var ez=e=>{var t;let{customType:l,onCreateSliceZone:i,onDeleteSliceZone:o,onRemoveSharedSlice:r,sliceZone:d,tabId:u}=e,m=(0,et.QT)(en,[]),[h,p]=(0,s.useState)(!1),[x,b]=(0,s.useState)(!1),[y,g]=(0,s.useState)(!1),[j,S]=(0,s.useState)(!1),{remoteSlices:C,libraries:T}=(0,c.v9)(e=>({remoteSlices:(0,eo.sT)(e),libraries:(0,eo.Sd)(e),slices:(0,eo.xC)(e)})),{setCustomType:D}=I(),{completeStep:k}=(0,J.k)(),{openLoginModal:_}=(0,f.Z)(),L=(0,q.k)(),A=(0,Q.F)({menuType:"Dropdown",sectionsNamingExperiment:L}),E=T.filter(e=>e.isLocal),{availableSlices:N,slicesInSliceZone:M,notFound:z}=(0,s.useMemo)(()=>d?eM(d,T):{availableSlices:[],slicesInSliceZone:[],notFound:[]},[d,T]),[Z,F]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(null==z?void 0:z.length)&&z.forEach(e=>{let{key:t}=e;r(t)})},[z]);let K=M.filter(e=>"SharedSlice"===e.type).map(e=>e.payload),B=N.filter(e=>!K.some(t=>t.model.id===e.model.id)),R=()=>{b(!0)},U=()=>{g(!0)},V=async()=>{await el.managerClient.user.checkIsLoggedIn()?S(!0):_()},X=()=>{p(!0),v.Xe.track({event:"custom-type:open-add-from-templates",customTypeId:l.id,customTypeFormat:l.format})},G=()=>{b(!1)},er=()=>{g(!1)},es=()=>{S(!1)},ec=()=>{p(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P.Bu,{actions:d?(0,n.jsxs)(a.ar,{children:[(0,n.jsx)(a.av,{children:(0,n.jsx)(a.E,{color:"purple",startIcon:"add","data-testid":"add-new-slice-dropdown",children:"Add"})}),(0,n.jsxs)(a.as,{align:"end",children:[(0,n.jsx)(a.at,{renderStartIcon:()=>A.fromImage.BackgroundIcon,onSelect:()=>void V(),description:A.fromImage.description,children:A.fromImage.title}),(0,n.jsx)(a.at,{renderStartIcon:()=>A.fromScratch.BackgroundIcon,onSelect:U,description:A.fromScratch.description,children:A.fromScratch.title}),m.length>0?(0,n.jsx)(a.at,{onSelect:X,renderStartIcon:()=>A.fromTemplate.BackgroundIcon,description:A.fromTemplate.description,children:A.fromTemplate.title}):void 0,B.length>0?(0,n.jsx)(a.at,{onSelect:R,renderStartIcon:()=>A.fromExisting.BackgroundIcon,description:A.fromExisting.description,children:A.fromExisting.title}):void 0]})]}):void 0,toggle:"page"!==l.format||"Main"!==u?(0,n.jsx)(a.bC,{checked:!!d,onCheckedChange:e=>{e?i():F(!0)},size:"small","data-testid":"slice-zone-switch"}):void 0,children:(0,W._)((0,W.f)(L.value))}),d?M.length>0?(0,n.jsx)(Y.xR,{children:(0,n.jsx)(ew,{slices:M,format:l.format,path:{customTypeID:l.id,tabID:u,sliceZoneID:null!==(t=null==d?void 0:d.key)&&void 0!==t?t:""},onRemoveSharedSlice:r})}):(0,n.jsx)(a.D,{flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center",padding:{block:32},children:(0,n.jsx)($,{openUpdateSliceZoneModal:R,openCreateSliceModal:U,openCreateSliceFromImageModal:()=>void V(),openSlicesTemplatesModal:X,projectHasAvailableSlices:B.length>0,isSlicesTemplatesSupported:m.length>0})}):void 0,x&&(0,n.jsx)(eN,{formId:"tab-slicezone-form-".concat(u),availableSlices:B,onSubmit:e=>{let t=ee({customType:l,tabId:u,slices:e});D({customType:w.Dc.fromSM(t),onSaveCallback:()=>{O.Am.success("Slice(s) added to slice zone")}}),k("createSlice"),G()},close:G}),h&&(0,n.jsx)(eE,{formId:"tab-slicezone-form-".concat(u),availableSlicesTemplates:m,localLibraries:E,location:"".concat(l.format,"_type"),onSuccess:e=>{let t=ee({customType:l,tabId:u,slices:e});D({customType:w.Dc.fromSM(t),onSaveCallback:()=>{O.Am.success((0,n.jsx)(ei.GX,{message:"".concat((0,W.f)(L.value)," template(s) added to ").concat(L.value," zone and created at: "),path:"".concat(E[0].name,"/")}))}}),k("createSlice"),ec()},close:ec}),Z&&(0,n.jsx)(ed,{closeDeleteSliceZoneModal:()=>{F(!1)},deleteSliceZone:()=>{o(),F(!1)}}),(null==E?void 0:E.length)!==0&&y&&(0,n.jsx)(ea.c,{onSuccess:e=>{let t=ee({customType:l,tabId:u,slices:[e]});D({customType:w.Dc.fromSM(t),onSaveCallback:()=>{O.Am.success((0,n.jsx)(ei.GX,{message:"New ".concat(L.value," added to ").concat(L.value," zone and created at: "),path:"".concat(E[0].name,"/")}))}}),er()},localLibraries:E,location:"".concat(l.format,"_type"),remoteSlices:C,onClose:er}),(0,n.jsx)(H.S,{open:j,location:"".concat(l.format,"_type"),onSuccess:e=>{let{slices:t,library:a}=e,i=ee({customType:l,tabId:u,slices:t.map(e=>e.model)});D({customType:w.Dc.fromSM(i),onSaveCallback:()=>{O.Am.success((0,n.jsx)(ei.GX,{message:"".concat((0,W.f)(L.value),"(s) added to ").concat(L.value," zone and created at: "),path:a}))}}),es()},onClose:es})]})};let eZ=[K.C.UID,K.C.Image,K.C.Text,K.C.StructuredText,K.C.Link,K.C.Select,K.C.Boolean,K.C.Number,K.C.Color,K.C.Date,K.C.Table,K.C.Embed,K.C.Timestamp,K.C.GeoPoint,K.C.ContentRelationship,K.C.LinkToMedia,K.C.Group,K.C.NestedGroup];var eO=e=>{var t,l,i,o;let{tabId:r}=e,{customType:c,setCustomType:d}=I(),m=w.Dc.toSM(c),h=null===(t=m.tabs.find(e=>e.key===r))||void 0===t?void 0:t.sliceZone,p=null!==(i=null===(l=m.tabs.find(e=>e.key===r))||void 0===l?void 0:l.value)&&void 0!==i?i:[],x="page"===m.format&&m.repeatable?p.filter(e=>"uid"!==e.key):p,v=m.tabs.reduce((e,t)=>[...e,...t.value],[]),b=e=>{var t;let{apiId:l,value:n}=e,a=null===(t=n.config)||void 0===t?void 0:t.label;if((0,B.Ss)(K.C,n.type)||null==a)return;if("Range"===n.type||"IntegrationFields"===n.type||"Separator"===n.type)throw Error("Unsupported Field Type: ".concat(n.type));let i=K.C[n.type];try{i.schema.validateSync(n,{stripUnknown:!1})}catch(e){throw Error('Add field: Model is invalid for field "'.concat(n.type,'".'))}let o=w.L$.fromSM(n);d({customType:(0,u.xS)({customType:c,newField:o,newFieldId:l,sectionId:r}),onSaveCallback:()=>{O.Am.success("".concat("Group"===n.type?"Group":"Field"," added"))}}),(0,U.V)({id:l,field:o})},y=e=>{let{apiId:t,newKey:l,value:n,inGroupFieldAction:a,updateMeta:i}=e;if((0,B.Ss)(K.C,n.type))return;let o=w.L$.fromSM(n);d({customType:(0,u.L4)({customType:c,previousFieldId:t,newFieldId:l,newField:o,sectionId:r}),onSaveCallback:()=>{"add"===a&&O.Am.success("Field added")},updateMeta:i}),a||(0,V.Z)({previousId:t,id:l,field:o})};return(0,n.jsx)(F.S,{children:(0,n.jsx)(s.Suspense,{fallback:(0,n.jsx)(a.D,{padding:32,children:(0,n.jsx)(a.bg,{})}),children:(0,n.jsxs)(P.aV,{border:!1,style:{flexGrow:1},children:[(0,n.jsx)(G.Z,{zoneType:"customType",zoneTypeFormat:null!==(o=c.format)&&void 0!==o?o:"custom",tabId:r,title:"Static zone",dataTip:"",fields:x,poolOfFieldsToCheck:v,showHints:!0,EditModal:X.Z,widgetsArray:eZ,onDeleteItem:e=>{d({customType:(0,u.AK)({customType:c,fieldId:e,sectionId:r})})},onSave:e=>""===e.apiId?b({...e,apiId:e.newKey}):y(e),onDragEnd:e=>{if((0,B.uS)(e))return;let{source:t,destination:l}=e;if(!l)return;let n=(0,u.gR)({customType:c,sourceIndex:t.index,destinationIndex:l.index,sectionId:r});(0,Z.flushSync)(()=>d({customType:n}))},renderHintBase:e=>{let{item:t}=e;return"data".concat((0,R.Ti)(t.key))},renderFieldAccessor:e=>"data".concat((0,R.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:c.repeatable}),(0,n.jsx)(ez,{customType:m,tabId:r,sliceZone:h,onRemoveSharedSlice:e=>{d({customType:(0,u.EN)({customType:c,sectionId:r,sliceId:e})})},onCreateSliceZone:()=>{d({customType:(0,u.Tr)(c,r)})},onDeleteSliceZone:()=>{d({customType:(0,u.E3)(c,r)})}})]})})})};let eP=()=>{var e,t,l;let{customType:i,setCustomType:o}=I(),r=w.Dc.toSM(i),[c,d]=(0,s.useState)(null===(e=r.tabs[0])||void 0===e?void 0:e.key),[m,h]=(0,s.useState)(),p=(null===(l=r.tabs.find(e=>e.key===c))||void 0===l?void 0:null===(t=l.sliceZone)||void 0===t?void 0:t.value.length)===0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a.c9,{sx:p?{flexGrow:1}:void 0,children:["page"===i.format?(0,n.jsx)(a.ca,{title:i.repeatable?(0,n.jsx)(T,{}):void 0}):void 0,(0,n.jsxs)(a.cb,{onValueChange:d,value:c,children:[(0,n.jsx)(a.cd,{onAddNewTab:()=>{h({type:"CREATE_CUSTOM_TYPE_TAB"})},children:r.tabs.map(e=>(0,n.jsx)(a.ce,{menu:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.at,{onSelect:()=>{h({type:"UPDATE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,n.jsx)(a.aX,{name:"edit"}),children:"Rename"}),(0,n.jsx)(a.at,{color:"tomato",disabled:function(e){if(r.tabs.length<=1)return!0;let t=r.tabs.find(e=>e.value.find(e=>"uid"===e.key));return"page"===i.format&&i.repeatable&&(null==t?void 0:t.key)===e}(e.key),onSelect:()=>{h({type:"DELETE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,n.jsx)(a.aX,{name:"delete"}),children:"Remove"})]}),value:e.key,children:e.key},e.key))}),r.tabs.map(e=>(0,n.jsx)(a.cc,{value:e.key,children:(0,n.jsx)(eO,{tabId:e.key})},e.key))]})]}),(null==m?void 0:m.type)==="CREATE_CUSTOM_TYPE_TAB"?(0,n.jsx)(N,{close:()=>{h(void 0)},isOpen:!0,onSubmit:e=>{let{id:t}=e;o({customType:(0,u.vB)(i,t)}),d(t)},tabIds:r.tabs.map(e=>e.key.toLowerCase())}):void 0,(null==m?void 0:m.type)==="UPDATE_CUSTOM_TYPE_TAB"?(0,n.jsx)(z,{close:()=>{h(void 0)},initialTabKey:m.tabKey,isOpen:!0,onSubmit:e=>{let{id:t}=e;o({customType:(0,u.HO)(i,m.tabKey,t)}),c===m.tabKey&&d(t)},tabIds:r.tabs.filter(e=>e.key!==m.tabKey).map(e=>e.key.toLowerCase())}):void 0,(null==m?void 0:m.type)==="DELETE_CUSTOM_TYPE_TAB"?(0,n.jsx)(M,{close:()=>{h(void 0)},isOpen:!0,onSubmit:()=>{if(o({customType:(0,u.F$)(i,m.tabKey)}),c===m.tabKey){var e;let t=null===(e=r.tabs.find(e=>e.key!==m.tabKey))||void 0===e?void 0:e.key;void 0!==t&&d(t)}}}):void 0]})};var eF=l(16442),eK=l(78254),eB=l(60867),eR=l(9975),eU=l(34919),eV=l.n(eU);let eX=e=>{let{tabs:t,...l}=e;return(0,n.jsxs)(eR.fC,{...l,className:eV().root,defaultValue:t[0].label,orientation:"vertical",children:[(0,n.jsx)(eR.aV,{className:eV().list,"aria-label":"content tabs",children:t.map((e,t)=>{let{label:l}=e;return(0,n.jsx)(eR.xz,{className:eV().trigger,value:l,children:(0,n.jsx)(a.bL,{className:eV().triggerText,component:"span",color:"inherit",children:l})},"".concat(l,"-trig").concat(t+1))})}),t.map((e,t)=>{let{label:l,content:i}=e;return(0,n.jsx)(eR.VY,{className:eV().content,value:l,children:(0,n.jsx)(a.bn,{className:eV().scrollArea,children:i})},"".concat(l,"-content").concat(t+1))})]})};var eG=l(25661),eY=l(88241),eq=l(32554),eH=l(44621),eQ=l.n(eH);let eW=e=>{var t,l;let{inline:i,...o}=e,r=(0,eq.p)();if(!0===i)return(0,n.jsx)("code",{...o,className:eQ().inlineCode});let s=(()=>{var e,t,l,n,a;if((null===(t=o.node)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.meta)!==void 0){let e=null===(n=o.node)||void 0===n?void 0:null===(l=n.data)||void 0===l?void 0:l.meta;return{fileName:e.substring(1,e.length-1),language:null===(a=o.className)||void 0===a?void 0:a.split("-")[1]}}return null})(),c=null===(t=/language-(\w+)/.exec(null!==(l=o.className)&&void 0!==l?l:""))||void 0===t?void 0:t[1];return(0,n.jsx)(a.W,{...o,onCopy:()=>{v.Xe.track({event:"page-type:copy-snippet",framework:r})},language:c,code:String(o.children).replace(/\n$/,""),title:null==s?void 0:s.fileName})},e$=e=>{let{markdown:t}=e;return(0,n.jsx)(eG.D,{children:t,linkTarget:"_blank",remarkPlugins:[eY.Z],components:{code:e=>(0,n.jsx)(eW,{...e}),h1:e=>(0,n.jsx)(a.bL,{children:e.children,component:"h1",variant:"h1"}),h2:e=>(0,n.jsx)(a.bL,{children:e.children,component:"h2",variant:"h2"}),h3:e=>(0,n.jsx)(a.bL,{children:e.children,component:"h3",variant:"h3"}),h4:e=>(0,n.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),h5:e=>(0,n.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),p:e=>(0,n.jsx)(a.bL,{className:eQ().section,children:e.children,component:"p",variant:"normal"}),pre:e=>(0,n.jsx)(a.bL,{className:eQ().section,children:e.children,component:"pre",variant:"normal"})}})};async function eJ(e){let t=JSON.parse(e),{errors:l,documentation:n}=await el.managerClient.documentation.read({kind:t.kind,data:t.data});if(l.length>0)throw l;return n}var e0=l(65480),e1=l.n(e0);let e4=e=>{var t;let{model:l}=e,i=(0,eq.p)(),o=(t={kind:"PageSnippet",data:{model:l}},(0,et.QT)(eJ,[JSON.stringify(t)])),{completeStep:r}=(0,J.k)();return 0===o.length?null:(0,n.jsxs)(a.ae,{size:"small",trigger:(0,n.jsx)(a.E,{color:"grey",onClick:()=>{r("codePage"),v.Xe.track({event:"page-type:open-snippet",framework:i})},startIcon:"code",children:"Page snippet"}),children:[(0,n.jsx)(a.al,{icon:"code",title:"Page snippet"}),(0,n.jsx)("section",{className:e1().content,children:o.length>1?(0,n.jsx)(eX,{style:{flex:1},tabs:o.map((e,t)=>{let{label:l,content:a}=e;return{label:null!=l?l:"Tab ".concat(t+1),content:(0,n.jsx)(e$,{markdown:a})}})}):(0,n.jsx)(a.bn,{style:{flex:1,padding:16},children:(0,n.jsx)(e$,{markdown:o[0].content})})})]})},e3=e=>{let{model:t}=e;return(0,n.jsx)("div",{children:(0,n.jsx)(F.S,{children:(0,n.jsx)(s.Suspense,{fallback:(0,n.jsx)(a.E,{color:"grey",startIcon:"code",children:"Page snippet"}),children:(0,n.jsx)(e4,{model:t})})})})},e6=()=>{let e=(0,r.useRouter)(),{selectedCustomType:t}=(0,c.v9)(t=>({selectedCustomType:(0,eK.Jk)(t,(0,h.Ag)(e.query))}));return((0,s.useEffect)(()=>{t&&(0,eF.TG)(t)||e.replace("/")},[t,e]),t&&(0,eF.TG)(t))?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o(),{children:(0,n.jsxs)("title",{children:[t.local.label," - Slice Machine"]})}),(0,n.jsx)(e8,{customType:t.local})]}):(0,n.jsx)(p.LN,{})},e8=e=>{let{customType:t}=e;return null===t?(0,n.jsx)(p.LN,{}):(0,n.jsx)(p.LN,{children:(0,n.jsx)(S,{initialCustomType:w.Dc.fromSM(t),children:e=>{var l;let{actionQueueStatus:i,customType:o,setCustomType:r}=e,s=(0,u.y6)(o),c=h.cd[t.format],x=g.$[t.format];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(p.wd,{children:[(0,n.jsx)(p.Xq,{url:c.tablePagePathname}),(0,n.jsxs)(p.Cx,{children:[(0,n.jsx)(d.g,{children:x.name({start:!0,plural:!0})}),(0,n.jsx)(d.g,{active:!0,children:null!==(l=o.label)&&void 0!==l?l:o.id})]}),(0,n.jsxs)(p.K2,{children:[(0,n.jsx)(m.X,{status:i}),"page"===o.format?(0,n.jsx)(e3,{model:o}):void 0,(0,n.jsx)(eB._,{isChangesLocal:!0,format:s,customType:o,setLocalCustomType:r})]})]}),(0,n.jsx)(p.RN,{children:(0,n.jsx)(a.D,{flexDirection:"column",minWidth:0,children:(0,n.jsx)(eP,{})})})]})}})})}},43776:function(e,t,l){"use strict";l.d(t,{E:function(){return a}});var n=l(31470);function a(e){var t,l;let[a,i]=(0,n.f)(),o=async t=>{let l={...a,labs:{...a.labs}};t?l.labs[e]=t:e in l.labs&&delete l.labs[e],0===Object.keys(l.labs).length&&delete l.labs,await i(l)};return[{enabled:null!==(l=null==a?void 0:null===(t=a.labs)||void 0===t?void 0:t[e])&&void 0!==l&&l},o]}},31470:function(e,t,l){"use strict";l.d(t,{f:function(){return i}});var n=l(18566),a=l(80148);function i(){return[(0,n.QT)(o,[]),async e=>{await a.managerClient.project.writeSliceMachineConfig({config:e}),(0,n.VA)(o,[],e)}]}async function o(){return a.managerClient.project.getSliceMachineConfig()}},34919:function(e){e.exports={flex:"ContentTabs_flex__T21Oc",column:"ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",root:"ContentTabs_root__Gn3Zg ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",list:"ContentTabs_list__rAZtl ContentTabs_flex__T21Oc",trigger:"ContentTabs_trigger__cTyPN ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",triggerText:"ContentTabs_triggerText__p_ZBl",content:"ContentTabs_content__H1Stj ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",scrollArea:"ContentTabs_scrollArea__DuDcQ"}},65480:function(e){e.exports={content:"PageSnippetDialog_content__jIN6d"}},44621:function(e){e.exports={section:"MarkdownRenderer_section__uNS1M",inlineCode:"MarkdownRenderer_inlineCode__lmGTi"}},65375:function(e){e.exports={scrollArea:"ConvertLegacySliceButton_scrollArea__xf3vM",label:"ConvertLegacySliceButton_label__BK0Gd"}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{91589:function(e,t,a){a.d(t,{S:function(){return x}});var r=a(52322),n=a(56803),i=a(2784),l=a(88932),s=a(94160),c=a(34166),o=a(63470),u=a(98250),d=a(68968),m=a(80148),p=a(54597),g=a(31860),h=a(62434);function f(e){let{slice:t}=e,a="uploading"===t.status||"generating"===t.status,i="uploadError"===t.status||"generateError"===t.status,l="generateError"===t.status||"generating"===t.status||"success"===t.status;return(0,r.jsxs)(h.Zb,{disabled:a,children:[l?(0,r.jsx)(h.ZB,{src:t.thumbnailUrl}):(0,r.jsx)(h.ZB,{component:"div"}),(0,r.jsx)(h.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":return"close";case"success":return"check";default:return}}(t.status),title:"success"===t.status?t.model.name:t.image.name,subtitle:function(e){switch(e){case"uploading":return"Uploading...";case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"success":return"Generated"}}(t.status),error:i,action:i?(0,r.jsx)(n.E,{startIcon:"refresh",color:"grey",onClick:t.onRetry,children:"Retry"}):void 0})]})}function x(e){let{open:t,location:a,onSuccess:h,onClose:x}=e,[b,v]=(0,i.useState)([]),[C,I]=(0,i.useState)(!1),{syncChanges:k}=(0,d.g)(),{createSliceSuccess:A}=(0,p.Z)(),{completeStep:E}=(0,u.k)(),U=(0,o.k)(),N=(0,i.useRef)(crypto.randomUUID()),L=e=>{let{index:t,slice:a}=e;v(e=>e.map((e,r)=>r===t?a(e):e))},D=e=>{if(e.length>10){l.Am.error("You can only upload ".concat(10," images at a time."));return}v(e.map(e=>({status:"uploading",image:e}))),e.forEach((e,t)=>B({index:t,image:e}))},B=e=>{let{index:t,image:a}=e,r=N.current;L({index:t,slice:e=>({...e,status:"uploading"})}),j({image:a}).then(e=>{r===N.current&&F({index:t,imageUrl:e})},()=>{r===N.current&&L({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>B({index:t,image:a})})})})},_=function(e){let{open:t}=e,a=(0,i.useRef)([]);return(0,i.useEffect)(()=>{t&&(a.current=[],m.managerClient.slices.readAllSlices().then(e=>{a.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),a}({open:t}),F=e=>{let{index:t,imageUrl:a}=e,r=N.current;L({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:a})}),m.managerClient.customTypes.inferSlice({imageUrl:a}).then(e=>{let{slice:n,langSmithUrl:i}=e;r===N.current&&v(e=>e.map((r,l)=>l===t?{...r,status:"success",thumbnailUrl:a,model:function(e){let{existingSlices:t,newSlices:a,slice:r}=e,n=new Set,i=new Set;for(let{id:e,name:a}of t)n.add(e),i.add(a.toLowerCase());for(let e of a)"success"===e.status&&(n.add(e.model.id),i.add(e.model.name.toLowerCase()));let l=r.id,s=2;for(;n.has(l);)l="".concat(r.id,"_").concat(s),s++;let c=r.name;for(s=2;i.has(c.toLowerCase());)c="".concat(r.name).concat(s),s++;return{...r,id:l,name:c}}({existingSlices:_.current,newSlices:e,slice:n}),langSmithUrl:i}:r))},()=>{r===N.current&&L({index:t,slice:e=>({...e,status:"generateError",thumbnailUrl:a,onRetry:()=>F({index:t,imageUrl:a})})})})},z=b.some(e=>"uploading"===e.status||"generating"===e.status),R=b.filter(e=>"success"===e.status),Z=R.length>0;return(0,r.jsxs)(n.ae,{open:t,onOpenChange:e=>{e||C||(x(),N.current=crypto.randomUUID(),v([]))},children:[(0,r.jsx)(n.al,{title:"Generate from image"}),(0,r.jsxs)(n.aj,{gap:0,children:[(0,r.jsxs)(n.ak,{hidden:!0,children:["Upload images to generate ",(0,g._)(U.value)," ","with AI"]}),0===b.length?(0,r.jsx)(n.D,{padding:16,height:"100%",children:(0,r.jsx)(n.aF,{onFilesSelected:D,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(y,{onFilesSelected:D,droppingFiles:!0}),children:(0,r.jsx)(y,{onFilesSelected:D})})}):(0,r.jsx)(n.bn,{stableScrollbar:!1,children:(0,r.jsx)(n.D,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:b.map((e,t)=>(0,r.jsx)(f,{slice:e},"slice-".concat(t)))})}),(0,r.jsxs)(n.ah,{children:[(0,r.jsx)(n.ai,{disabled:C}),(0,r.jsxs)(n.af,{disabled:!Z||z,loading:C,onClick:()=>{let e=b.reduce((e,t)=>("success"===t.status&&e.push(t),e),[]);if(!e.length)return;let t=N.current;I(!0),w(e).then(async e=>{let{slices:r,library:n}=e;if(t===N.current)for(let{model:e,langSmithUrl:t}of(A((await (0,s.y0)()).libraries),k(),h({slices:r,library:n}),I(!1),N.current=crypto.randomUUID(),v([]),E("createSlice"),r))s.Xe.track({event:"slice:created",id:e.id,name:e.name,library:n,location:a,mode:"ai",langSmithUrl:t}),(0,c.nZ)({type:"model",library:n,sliceId:e.id,variationId:e.variations[0].id,langSmithUrl:t})}).catch(()=>{t===N.current&&(I(!1),l.Am.error("An unexpected error happened while adding slices."))})},children:[S({location:a,sectionsNamingExperiment:U})," (",R.length,")"]})]})]})]})}function y(e){let t=(0,o.k)(),{droppingFiles:a=!1,onFilesSelected:i}=e;return(0,r.jsx)(n.D,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:a?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:a?"purple9":"grey6",children:(0,r.jsxs)(n.s,{children:[(0,r.jsx)(n.x,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(n.z,{children:"Upload your design images."}),(0,r.jsxs)(n.w,{children:["Once uploaded, you can generate"," ",(0,g._)(t.value)," automatically using AI."]}),(0,r.jsx)(n.v,{children:(0,r.jsx)(n.aG,{startIcon:"attachFile",onFilesSelected:i,color:"grey",children:"Add images"})})]})})}async function j(e){let{image:t}=e,a=[await m.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await m.managerClient.screenshots.initS3ACL();let{url:r}=await m.managerClient.screenshots.uploadScreenshot({keyPrefix:a,data:t});return r}async function w(e){let{libraries:t=[]}=await m.managerClient.project.getSliceMachineConfig(),a=t[0];if(!a)throw Error("No library found in the config.");for(let{model:t}of e){let{errors:e}=await m.managerClient.slices.createSlice({libraryID:a,model:t});if(e.length)throw Error("Failed to create slice ".concat(t.id,"."))}let r=await Promise.all(e.map(async e=>{let{model:t,image:r,langSmithUrl:n}=e;return await m.managerClient.slices.updateSliceScreenshot({libraryID:a,sliceID:t.id,variationID:t.variations[0].id,data:r}),{model:t,langSmithUrl:n}}));return{library:a,slices:r}}let S=e=>{let{location:t,sectionsNamingExperiment:a}=e;switch(t){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to ".concat((0,g._)(a.value))}}},27213:function(e,t,a){a.d(t,{F:function(){return l}});var r=a(52322),n=a(56803),i=a(31860);let l=e=>{let{menuType:t,sectionsNamingExperiment:a}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(n.B,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a ".concat(a.value," based on your design image.")},fromScratch:{BackgroundIcon:(0,r.jsx)(n.B,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom ".concat(a.value," your way.")},fromTemplate:{BackgroundIcon:(0,r.jsx)(n.B,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(n.B,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing ".concat(a.value),description:"Select from your created ".concat((0,i._)(a.value))}}}},6256:function(e,t,a){a.d(t,{c:function(){return S}});var r=a(52322),n=a(2784),i=a(36131),l=a(75289),s=a(94160),c=a(63470),o=a(98250),u=a(88932),d=a(63908),m=a(358),p=a(80148);async function g(e){let{sliceName:t,libraryName:a,location:r,onSuccess:n}=e;try{let e=(0,d.fo)(t),{errors:i}=await p.managerClient.slices.createSlice({libraryID:a,model:e});if(i.length>0)throw i;s.Xe.track({event:"slice:created",id:(0,m.MP)(t),name:t,library:a,location:r,mode:"manual"}),await n(e)}catch(a){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,a),u.Am.error(e)}}var h=a(68968),f=a(59532),x=a(54597),y=a(31860),j=a(46999),w=a(63019);let S=e=>{let{onClose:t,onSuccess:a,localLibraries:u,location:d,remoteSlices:m}=e,{createSliceSuccess:p}=(0,x.Z)(),[S,b]=(0,n.useState)(!1),{syncChanges:v}=(0,h.g)(),{completeStep:C}=(0,o.k)(),I=(0,c.k)(),k=async e=>{let t=e.sliceName,r=e.from;b(!0),await g({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{p((await (0,s.y0)()).libraries),a(e,r),v(),C("createSlice")}})};return(0,r.jsx)(f.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:S,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{k(e)},initialValues:{sliceName:"",from:u[0].name},validate:e=>(0,w.h)(e,u,m),content:{title:"Create a new ".concat(I.value)},children:e=>{let{touched:t,values:a,setFieldValue:n,errors:s}=e;return(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(j.W,{name:"sliceName",label:"".concat((0,y.f)(I.value)," name"),placeholder:"Pascalised ".concat(I.value," API ID (e.g. TextBlock)"),error:t.sliceName?s.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(l.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(i.ZP,{name:"from",options:u.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void n("from",e.value):null,defaultValue:{value:a.from,label:a.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,a){a.d(t,{h:function(){return c}});var r=a(96009),n=a.n(r),i=a(74600),l=a.n(i),s=a(7974);function c(e,t,a){let{sliceName:r}=e;return r?s.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:s.xo.exec(r)?l()(n()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...a.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,a){var r=a(52322),n=a(75289);t.Z=function(e){let{elems:t,renderElem:a,defineElementKey:i,gridTemplateMinPx:l="320px",gridGap:s="16px",sx:c}=e;return(0,r.jsx)(n.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(l,", 1fr))"),gridGap:s,pt:2,...c},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:a(e,t)},"".concat(i(e),"-").concat(t+1)):null)})}}}]);
|