slice-machine-ui 2.21.2-beta.2 → 2.21.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.
- package/out/404.html +1 -1
- package/out/_next/static/{Wxz3tijTq5Yp3DQn71QK5 → 9-Q5-GhGpzp1s1PQEeB5Z}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/{614-725569bd08a56760.js → 614-e7a545e2cfae9865.js} +1 -1
- package/out/_next/static/chunks/{630-7481a0c51302f44a.js → 630-2de9230aea563e24.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-3e9b632453c65838.js → _app-ed754fab3e7bde18.js} +71 -74
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-f8acda066384afab.js → [variation]-085e291733488778.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/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 +4 -5
- /package/out/_next/static/{Wxz3tijTq5Yp3DQn71QK5 → 9-Q5-GhGpzp1s1PQEeB5Z}/_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/3283e55967b5b95a.css" as="style"/><link rel="stylesheet" href="/_next/static/css/3283e55967b5b95a.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-b3122714ef005b7d.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-de87250a4e0c9fcf.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/3283e55967b5b95a.css" as="style"/><link rel="stylesheet" href="/_next/static/css/3283e55967b5b95a.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-b3122714ef005b7d.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-de87250a4e0c9fcf.js" defer=""></script><script src="/_next/static/chunks/pages/_app-ed754fab3e7bde18.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/9-Q5-GhGpzp1s1PQEeB5Z/_buildManifest.js" defer=""></script><script src="/_next/static/9-Q5-GhGpzp1s1PQEeB5Z/_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":"9-Q5-GhGpzp1s1PQEeB5Z","runtimeConfig":{"sentryEnvironment":"production"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,b,n,u,f,
|
|
1
|
+
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,d,b,n,u,f,h,k,j,l,p,g,o,r,m,_,y,I,N){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,t,o,r,"static/chunks/pages/index-0d8cb369de720a35.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[c,i,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-b677408a933c3706.js"],"/changes":[c,d,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",e,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-3e2db1d730ca49d5.js"],"/custom-types":[s,t,o,r,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,u,f,h,k,s,a,i,b,j,l,m,e,t,p,g,_,y,"static/chunks/pages/custom-types/[customTypeId]-b7568d6cdea551b4.js"],"/labs":["static/chunks/pages/labs-224cdbb9b1c2ae79.js"],"/page-types/[pageTypeId]":[c,u,f,h,k,s,a,i,b,j,l,m,e,t,p,g,_,y,"static/chunks/pages/page-types/[pageTypeId]-fcce3335e0cdee55.js"],"/slices":[c,d,I,s,a,b,N,e,g,n,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-64cda5a35f30d3b6.js"],"/slices/[lib]/[sliceName]/[variation]":[c,d,u,f,h,k,I,s,a,i,b,j,N,"static/chunks/484-3e011e79c41f0342.js",e,p,n,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-085e291733488778.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[d,"static/chunks/72585f70-28b4d7d5384b3703.js",l,"static/chunks/429-e5d7e39160de9f5e.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-2734cb1eb5762250.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/397-e6c340070a3bcb41.js","static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/66-d9d3bcb5d041cb6d.js","static/chunks/882-3fc529e17c17e932.js","static/chunks/647-743a5d447c0afd2a.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/344-b64f09e670634ed1.js","static/chunks/593-7ffd1197c3405ef8.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/256-07f768a2b19b0a0e.js","static/chunks/130-e1a16d2f94fb2b64.js","static/chunks/630-2de9230aea563e24.js","static/chunks/633-9cbdaf7853a37d77.js","static/chunks/248-ebee5770affd2316.js","static/css/4e475d945cf8a890.css","static/chunks/21-f3962d02eda0a46e.js","static/chunks/614-e7a545e2cfae9865.js","static/css/56f2a6684a524374.css","static/chunks/52d4c156-89c6ec6efca0a0bb.js","static/chunks/444-d39213143f782fec.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[614],{90614:function(e,t,n){"use strict";n.d(t,{H:function(){return tw}});var i=n(52322),a=n(15934),r=n(97729),l=n.n(r),o=n(5632),s=n(2784),c=n(56580),d=n(43388),m=n(77630),u=n(23094),h=n(59294),p=n(58446),g=n(74217),f=n(94160),x=n(68968),y=n(23710),b=n(54597),j=n(98564);let v=(0,s.createContext)(void 0);function S(e){let{children:t,initialCustomType:n}=e,[a,r]=(0,s.useState)(n),l=(0,m.y6)(a),o=j.$[l],{actionQueueStatus:c,setNextAction:d}=(0,y.c)({errorMessage:o.autoSaveFailed}),{refreshState:u}=(0,b.Z)(),h=(0,g.R9)(u),{syncChanges:p}=(0,x.g)(),S=(0,s.useCallback)(e=>{let{customType:t,onSaveCallback:n,updateMeta:i}=e;r(t),d(async()=>{let{errors:e}=await (0,f.KA)({customType:t,updateMeta:i});if(e.length>0)throw e;h(await (0,f.y0)()),p(),null==n||n()})},[d,h,p]),w=(0,s.useMemo)(()=>({actionQueueStatus:c,customType:a,setCustomType:S}),[c,a,S]);return(0,i.jsx)(v.Provider,{value:w,children:"function"==typeof t?t(w):t})}function w(){let e=(0,s.useContext)(v);if(!e)throw Error("CustomTypeProvider not found");return e}var C=n(30195);function I(){var e;let[t,n]=(0,s.useState)(!1),{customType:r,setCustomType:l}=w(),[o,c]=null!==(e=(0,m.j5)(r))&&void 0!==e?e:[],d=c?(0,m.N3)(c):"",[u,h]=(0,s.useState)(null!=d?d:""),[p,f]=(0,s.useState)();(0,g.pQ)(t,()=>{t||(h(null!=d?d:""),f(void 0))});let x=(0,s.useCallback)(()=>(0,i.jsx)(a.aW,{name:c?"language":"add",size:"small",color:"grey11"}),[c]);return(0,i.jsxs)(a.ad,{open:t,onOpenChange:n,size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",textColor:"placeholder",textWeight:"normal",renderStartIcon:x,sx:{marginInline:"auto"},children:c?d:"Add an UID"}),children:[(0,i.jsx)(a.ak,{title:"Edit the UID label"}),(0,i.jsx)(a.ai,{children:(0,i.jsxs)(a.aI,{onSubmit:function(){p||(l({customType:c?(0,m.eK)(u,r):(0,m.H8)(u,r)}),n(!1))},children:[(0,i.jsx)(a.D,{flexDirection:"column",padding:16,gap:4,children:(0,i.jsx)(a.aL,{type:"text",label:"Label *",placeholder:"UID",value:u,onValueChange:function(e){h(e),f(function(e){let t=k.safeParse(e,{errorMap:T});if(t.error)return t.error.errors[0].message}(e))},error:p,description:"A label for the UID"})}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",disabled:!!p,children:"Save"})]})]})})]})}let k=C.z.string().max(35).min(1),T=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 D=n(94840),_=n(59532),A=n(63397),N=n(75289);let E=e=>{let{name:t,label:n,placeholder:a,error:r,...l}=e;return(0,i.jsxs)(N.xu,{mb:3,children:[(0,i.jsx)(N.__,{htmlFor:t,mb:2,children:n}),(0,i.jsx)(A.gN,{name:t,type:"text",placeholder:a,as:N.II,autoComplete:"off",...l}),r?(0,i.jsx)(N.xv,{sx:{color:"error",mt:1},children:r}):null]})};var z=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:r}=e;return(0,i.jsx)(_.Z,{isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,onSubmit:e=>{n(e),a()},initialValues:{id:""},validate:e=>{let{id:t}=e;return t?r.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,i.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})}})},F=e=>{let{isOpen:t,onSubmit:n,close:a}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{},content:{title:"Remove Tab"},children:()=>(0,i.jsxs)(N.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(N.X6,{as:"h4",children:"Remove this tab?"}),(0,i.jsx)(N.xv,{as:"p",color:"textClear",sx:{mt:2},children:"This action cannot be undone."}),(0,i.jsx)(N.zx,{type:"button",variant:"buttons.actionDelete",sx:{mt:3},onClick:()=>{n({}),a()},children:"Yes, remove tab"})]})})},P=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:r,initialTabKey:l}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{id:l},validate:e=>{let{id:t}=e;return t?r.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Rename Tab"},children:e=>{let{errors:t,values:r,setFieldValue:l,isValid:o}=e;return(0,i.jsxs)(N.xu,{sx:{px:4,py:4},children:[(0,i.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=>{r.id!==e.target.value&&l("id",e.target.value.trim())},onChange:e=>{l("id",e.target.value)}}),(0,i.jsx)(N.zx,{type:"button",sx:{mt:3,width:"100%"},disabled:!o,onClick:()=>{r.id&&r.id.length&&n({id:r.id.trim()}),a()},children:"Save"})]})}})},L=n(28316),M=n(88932),K=n(35289),O=n(87446),Z=n(45440),U=n(16086),G=n(358),B=n(5495),H=n(39302),R=n(3285),q=n(40141),W=n(65077),X=n(21446),V=n(92708),Y=n(14010);function $(e){switch(e){case"@slicemachine/adapter-next":return"next";case"@slicemachine/adapter-nuxt":case"@slicemachine/adapter-nuxt2":return"nuxt";case"@slicemachine/adapter-sveltekit":return"sveltekit";default:return}}var Q=n(98250),J=n(30613),ee=n(80148);function et(){return(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.bw,{height:32,width:58.48}),(0,i.jsx)(a.bw,{height:32,width:110.38})]})}function en(e){let{totalSelected:t,onSubmit:n,isSubmitting:r,typeName:l}=e;return(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{disabled:r,size:"medium"}),(0,i.jsxs)(a.ae,{disabled:0===t,loading:r,onClick:n,size:"medium",children:["Add to ",l," (",t,")"]})]})}function ei(e){let{children:t,selected:n}=e;return n?(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:t}):(0,i.jsx)(a.D,{display:"none",minHeight:0,children:t})}function ea(e){let{selectedTab:t,onSelectTab:n,rightContent:r}=e;return(0,i.jsxs)(a.D,{justifyContent:"space-between",padding:16,border:{bottom:!0},gap:8,children:[(0,i.jsxs)(a.D,{gap:8,children:[(0,i.jsx)(a.bC,{selected:"local"===t,onClick:()=>n("local"),children:"Local Slices"}),(0,i.jsx)(a.bC,{selected:"library"===t,onClick:()=>n("library"),children:"Library Slices"})]}),r]})}function er(e){let t,n;let{title:r,description:l,icon:o,actions:s,color:c="purple"}=e;switch(c){case"purple":t="purple11",n="purple3";break;case"tomato":t="tomato11",n="tomato3"}return(0,i.jsx)(a.D,{flexDirection:"column",justifyContent:"center",alignItems:"center",gap:16,flexGrow:1,children:(0,i.jsxs)(a.s,{children:[(0,i.jsx)(a.x,{lineColor:t,backgroundColor:n,name:o}),(0,i.jsx)(a.z,{size:"medium",children:r}),void 0!==l&&(0,i.jsx)(a.w,{children:l}),void 0!==s&&(0,i.jsx)(a.v,{children:s})]})})}var el=n(87686),eo=n(74686),es=n(88866);let ec=C.z.enum(["@slicemachine/adapter-next","@slicemachine/adapter-nuxt","@slicemachine/adapter-nuxt2","@slicemachine/adapter-sveltekit"]);async function ed(e,t,n){let i=Array(e.length),a=0,r=Array(Math.min(t,e.length)).fill(null).map(async()=>{for(;;){let t=a++;if(t>=e.length)break;i[t]=await n(e[t],t)}});return await Promise.all(r),i}class em{getHeaders(){let e={Accept:"application/vnd.github.v3+json"};return void 0!==this.token&&(e.Authorization="Bearer ".concat(this.token)),e}async request(e,t){let n="".concat(this.baseUrl).concat(e),i=await fetch(n,{...t,headers:{...this.getHeaders(),...null==t?void 0:t.headers}});if(!i.ok)throw Error("GitHub API request failed: ".concat(i.status," ").concat(i.statusText));return i.json()}async getDefaultBranch(){let e=await this.request("/repos/".concat(this.owner,"/").concat(this.repo));return C.z.object({default_branch:C.z.string()}).parse(e).default_branch}async getFileContents(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e,"?ref=").concat(t)),a=C.z.object({content:C.z.string(),encoding:C.z.string()}).parse(i);if("base64"!==a.encoding)throw Error("Unexpected encoding for ".concat(e,": ").concat(a.encoding));let r=atob(a.content.replace(/\s/g,""));if(!n)return r;{let e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e.buffer}}async getDirectoryContents(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e));return C.z.array(C.z.object({name:C.z.string(),type:C.z.string(),path:C.z.string()})).parse(t)}async searchCode(e){let{path:t,filename:n}=e,i=[];void 0!==t&&i.push("path:".concat(t)),void 0!==n&&i.push("filename:".concat(n)),i.push("repo:".concat(this.owner,"/").concat(this.repo));let a="/search/code?q=".concat(encodeURIComponent(i.join(" "))),r=await this.request(a);return C.z.object({items:C.z.array(C.z.object({path:C.z.string(),name:C.z.string()})).optional(),total_count:C.z.number().optional()}).parse(r)}async getSliceMachineConfigDetails(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/slicemachine.config.json?ref=").concat(e)),n=C.z.object({content:C.z.string().optional(),encoding:C.z.string().optional()}).parse(t);if("string"==typeof n.content){let e=atob(n.content.replace(/\s/g,""));return C.z.object({libraries:C.z.array(C.z.string()),adapter:ec}).transform(e=>({framework:$(e.adapter),libraries:e.libraries})).parse(JSON.parse(e))}throw Error("No content found in slicemachine.config.json")}constructor(e){this.baseUrl="https://api.github.com",this.owner=e.owner,this.repo=e.repo,this.token=e.token}}let eu=async e=>{let{owner:t,repo:n,token:i}=e;return new em({owner:t,repo:n,token:i}).getDefaultBranch()},eh=async e=>{let{owner:t,repo:n,branch:i,token:a}=e;return new em({owner:t,repo:n,token:a}).getSliceMachineConfigDetails(i)},ep=C.z.array(C.z.unknown().transform((e,t)=>{let n=eo.SharedSliceContent.decode(e);if("Left"===n._tag){for(let e of n.left)t.addIssue({code:C.z.ZodIssueCode.custom,message:e.message});return C.z.NEVER}return n.right})),eg=async e=>{let{owner:t,repo:n,branch:i,libraries:a,token:r}=e,l=new em({owner:t,repo:n,token:r}),o=[];for(let e of(console.log("Fetching slices from ".concat(a.length," library/libraries:"),a),a)){let t=e.replace(/^\.\//,""),n=[],a=!1;try{n=(await l.getDirectoryContents(t)).filter(e=>"dir"===e.type).map(e=>({name:e.name,path:e.path}))}catch(n){a=!0;let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub API returned 403 for ".concat(e,", trying direct discovery...")):console.warn("GitHub API error for ".concat(e,", trying direct discovery..."),t)}if(a&&0===n.length){console.log("Attempting to discover slices using GitHub Search API for ".concat(e,"..."));try{let i=await l.searchCode({path:t,filename:"model.json"});if(i.items&&i.items.length>0){let a=new Set;for(let e of i.items){let t=e.path.split("/");if(t.length>=2){let e=t[t.length-2];e&&!a.has(e)&&a.add(e)}}n=Array.from(a).map(e=>({name:e,path:"".concat(t,"/").concat(e)})),console.log("Discovered ".concat(n.length," slice(s) via GitHub Search API for library ").concat(e))}else console.warn("GitHub Search API found no model.json files in ".concat(e))}catch(n){let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub Search API also returned 403. Cannot discover slices without API access."):console.warn("Error using GitHub Search API for ".concat(e,":"),t)}}if(0===n.length){console.warn("No slices found in library ".concat(e,". The repository may be private or require authentication."));continue}console.log("Processing ".concat(n.length," slice(s) in library ").concat(e));let r=async e=>{try{let t,n,a,r;let s=await l.getFileContents("".concat(e.path,"/model.json"),i,!1);if("string"!=typeof s){console.warn("Failed to fetch model.json for slice: ".concat(e.name," - unexpected content type"));return}let c=es.SharedSlice.decode(JSON.parse(s));if("Left"===c._tag){console.warn("Failed to decode model.json for slice: ".concat(e.name));return}let d=c.right,m=[];try{m=await ef({api:l,branch:i,directoryPath:e.path}),console.log("Fetched ".concat(m.length," file(s) for slice ").concat(e.name,":"),m.map(e=>"".concat(e.path).concat(e.isBinary?" (binary)":"")))}catch(t){console.warn("Failed to fetch files for slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}for(let i of m)if(void 0===t&&i.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/)&&"string"==typeof i.contents&&(t=i.contents),"mocks.json"===i.path&&"string"==typeof i.contents)try{let t=ep.safeParse(JSON.parse(i.contents));if(t.success){let e=t.data;Array.isArray(e)&&e.length>0&&(n=e)}else console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}catch(t){console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}let u={};void 0!==d.variations&&d.variations.length>0&&(await Promise.allSettled(d.variations.map(async t=>{try{let n="".concat(e.path,"/screenshot-").concat(t.id,".png"),o=await l.getFileContents(n,i,!0);if(o instanceof ArrayBuffer){let e=new Blob([o],{type:"image/png"}),n=new File([e],"screenshot-".concat(t.id,".png"),{type:"image/png"});u[t.id]=n,void 0===a&&void 0!==d.variations[0]&&t.id===d.variations[0].id&&(a=URL.createObjectURL(e),r=n)}}catch(e){console.warn("Failed to fetch screenshot for variation ".concat(t.id,":"),e instanceof Error?e.message:String(e))}}))).forEach((e,t)=>{if("rejected"===e.status){var n;console.warn("Failed to fetch screenshot for variation ".concat(null===(n=d.variations[t])||void 0===n?void 0:n.id,":"),e.reason instanceof Error?e.reason.message:String(e.reason))}});let h=null!=r?r:new File([],"".concat(d.name,".json"),{type:"application/json"}),p={image:h,thumbnailUrl:null!=a?a:URL.createObjectURL(h),model:d,files:m,componentContents:t,mocks:n,screenshots:Object.keys(u).length>0?u:void 0};o.push(p)}catch(t){console.warn("Error fetching slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}};await ed(n,6,r)}return o},ef=async e=>{let{api:t,branch:n,directoryPath:i}=e,a=[],r=!1;try{let e=await t.getDirectoryContents(i);r=!0;let l=e.filter(e=>"file"===e.type),o=e.filter(e=>"dir"===e.type);for(let e of(await ed(l,8,async e=>{if("model.json"===e.name)return null;try{let i=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp"].some(t=>e.name.toLowerCase().endsWith(t)),a=await t.getFileContents(e.path,n,i);return{path:e.name,contents:a,isBinary:i}}catch(t){return console.warn("Failed to fetch file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))e&&a.push(e);for(let e of o)for(let i of(await ef({api:t,branch:n,directoryPath:e.path})))a.push({...i,path:"".concat(e.name,"/").concat(i.path)})}catch(e){console.warn("GitHub API failed for directory ".concat(i,", trying Search API..."),e instanceof Error?e.message:String(e))}if(!r)try{console.log("Using GitHub Search API to find all files in ".concat(i,"..."));let e=await t.searchCode({path:i});if(e.items&&e.items.length>0){for(let r of(console.log("Found ".concat(e.items.length," file(s) via Search API for ").concat(i)),await ed(e.items,8,async e=>{try{if("model.json"===e.name)return null;let a=e.path.startsWith(i+"/")?e.path.slice(i.length+1):e.name,r=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp",".woff",".woff2",".ttf",".eot",".otf",".pdf",".zip",".gz"].some(t=>e.name.toLowerCase().endsWith(t)),l=await t.getFileContents(e.path,n,r);return{path:a,contents:l,isBinary:r}}catch(t){return console.warn("Error fetching file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))r&&a.push(r);console.log("Fetched ".concat(a.length," file(s) from ").concat(i," via Search API"))}else console.warn("GitHub Search API found no files in ".concat(i))}catch(t){let e=t instanceof Error?t.message:String(t);e.includes("403")?console.warn("GitHub Search API returned 403 for ".concat(i,". Cannot fetch files without API access.")):console.warn("Error using GitHub Search API for ".concat(i,":"),e)}return a};class ex extends Error{constructor(e){super(e),this.name="GitHubImportError"}}var ey=n(62434);function eb(e){let{thumbnailUrl:t,model:n,selected:r=!0,onSelectedChange:l}=e,[o,c]=(0,s.useState)(!1),d=(0,i.jsxs)(i.Fragment,{children:[void 0!==t&&t&&!o?(0,i.jsx)(ey.ZB,{src:t,onError:()=>c(!0)}):(0,i.jsx)(ey.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",flexDirection:"column",gap:8,justifyContent:"center",children:(0,i.jsx)(a.bK,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsx)(ey.eW,{title:n.name,subtitle:n.variations.length>1?"".concat(n.variations.length," variations"):"1 variation",action:(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,i.jsx)(a.T,{checked:r,onCheckedChange:l})})})]});return(0,i.jsx)(ey.Zb,{interactive:!0,onClick:()=>{l(!r)},checked:r,size:"small","data-testid":"slice-card",children:d})}async function ej(e){let{libraries:t=[]}=await ee.managerClient.project.getSliceMachineConfig(),n=t[0];if(!n)throw Error("No library found in the config.");await ed(e,3,async e=>{let{errors:t}=await ee.managerClient.slices.createSlice({libraryID:n,model:e.model,componentContents:e.componentContents});if(t.length)throw Error("Failed to create slice ".concat(e.model.id,"."))});let i=await ed(e,3,async e=>{let{model:t,image:i,langSmithUrl:a,mocks:r,files:l,screenshots:o}=e;if(r&&Array.isArray(r)&&r.length>0){let{errors:e}=await ee.managerClient.slices.updateSliceMocks({libraryID:n,sliceID:t.id,mocks:r});e.length&&console.warn("Failed to update mocks for slice ".concat(t.id,":"),e)}return o&&Object.keys(o).length>0?await Promise.all(Object.entries(o).map(async e=>{let[i,a]=e;a.size>0&&await ee.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:i,data:a})})):i.size>0&&void 0!==t.variations&&t.variations.length>0&&await ee.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:t.variations[0].id,data:i}),console.log("About to write files for slice ".concat(t.id,":"),l?"".concat(l.length," file(s) - ").concat(l.map(e=>e.path).join(", ")):"no files"),l&&l.length>0?await ev({libraryID:n,sliceID:t.id,files:l}):console.warn("No files to write for slice ".concat(t.id,". Files:"),l),{model:t,langSmithUrl:a}});return{library:n,slices:i}}async function ev(e){let{libraryID:t,sliceID:n,files:i}=e;if(0===i.length)return;let a=i.filter(e=>"mocks.json"!==e.path&&!e.path.startsWith("screenshot-")&&!e.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/));if(console.log("Writing ".concat(a.length," additional file(s) for slice ").concat(n,":"),a.map(e=>e.path)),0!==a.length)try{let e=a.map(e=>{if(e.isBinary)return{path:e.path,contents:e.contents,isBinary:!0};if("string"==typeof e.contents)return{path:e.path,contents:e.contents,isBinary:!1};throw Error("Unexpected file contents type for ".concat(e.path))}),i=await ee.managerClient.slices.writeSliceFiles({libraryID:t,sliceID:n,files:e});i.errors.length>0?console.error("Errors writing files for slice ".concat(n,":"),i.errors.map(e=>{var t;return null!==(t=e.message)&&void 0!==t?t:String(e)})):console.log("Successfully wrote ".concat(a.length," file(s) for slice ").concat(n))}catch(e){console.error("Error writing files for slice ".concat(n,":"),e instanceof Error?e.message:String(e))}}function eS(e){let t;let{location:n,typeName:r,onSelectTab:l,onSuccess:o,selected:c}=e,[d,m]=(0,s.useState)(!1),[u,h]=(0,s.useState)([]),[p,y]=(0,s.useState)(),{integrations:j,fetchedSlices:v,isImportingSlices:S,fetchSlicesFromGithub:w,resetImportedSlices:C}=function(){var e;let[t,n]=(0,s.useState)(!1),[i,a]=(0,s.useState)([]),{data:r}=(0,V.k)({queryKey:["getIntegrations"],queryFn:()=>ee.managerClient.prismicRepository.fetchGitIntegrations()}),{mutateAsync:l}=(0,el.D)({mutationFn:e=>ee.managerClient.prismicRepository.fetchGitIntegrationToken({integrationId:e.integrationId})}),o=()=>{a([]),n(!1)},c=async e=>{let{repository:t,targetFramework:i}=e;try{let r;o(),n(!0),f.Xe.track({event:"slice-library:fetching-started",source_project_id:t.fullName});let{token:s}=await l({integrationId:t.integrationId}),[c,d]=e.repository.fullName.split("/");if(!c||!d)throw new ex("Invalid GitHub URL format");let m=await eu({owner:c,repo:d,token:s});try{let e=await eh({owner:c,repo:d,branch:m,token:s});if(e.framework!==i)throw new ex("Incompatible project framework.");r=e.libraries}catch(e){throw new ex("\n Failed to fetch slicemachine.config.json: ".concat(e instanceof Error?e.message:"Unknown error","\n "))}if(0===r.length)throw new ex("No libraries were found in the SM config.");let u=await eg({owner:c,repo:d,branch:m,libraries:r,token:s});if(0===u.length)throw new ex("No slices were found in the libraries.");return a(u),M.Am.success("Found ".concat(u.length," slice(s) from ").concat(r.length," library/libraries")),f.Xe.track({event:"slice-library:fetching-ended",error:!1,slices_count:u.length,source_project_id:t.fullName}),u}catch(e){return e instanceof ex?M.Am.error(e.message):M.Am.error("Failed to import from GitHub: ".concat(e instanceof Error?e.message:"Unknown error")),f.Xe.track({event:"slice-library:fetching-ended",error:!0,source_project_id:t.fullName}),[]}finally{n(!1)}};return{integrations:null!==(e=r.integrations)&&void 0!==e?e:[],fetchedSlices:null!=i?i:[],isImportingSlices:t,resetImportedSlices:o,fetchSlicesFromGithub:c}}(),I=(0,b.Z)(),{syncChanges:k}=(0,x.g)(),{completeStep:T}=(0,Q.k)(),D=function(){let e=(0,J.U)(),{data:t}=(0,V.k)({queryKey:["getFrameworkFromAdapterName"],queryFn:async()=>$(ec.parse(await ee.managerClient.project.getAdapterName()))});return{...e,framework:t}}();(0,s.useEffect)(()=>{c&&f.Xe.track({event:"slice-library:opened"})},[c]),(0,g.Nr)(u,1e3,()=>{p&&u.length>0&&f.Xe.track({event:"slice-library:slice-selected",slices_count:u.length,source_project_id:p.fullName,destination_project_id:D.repositoryName})});let _=e=>{h(t=>t.some(t=>t.model.id===e.model.id)?t.filter(t=>t.model.id!==e.model.id):[...t,e])},A=async()=>{if(0===u.length){M.Am.error("Please select at least one slice");return}if(!p){M.Am.error("Please select a repository");return}try{m(!0),f.Xe.track({event:"slice-library:import-started",source_project_id:p.fullName});let e=u.map(e=>({image:e.image,model:e.model,files:e.files,componentContents:e.componentContents,mocks:e.mocks,screenshots:e.screenshots})),t=[],i=await ee.managerClient.slices.readAllSlices().then(e=>e.models.map(e=>{let{model:t}=e;return t}));for(let n of e){let e=function(e){let{existingSlices:t,newSlices:n,slice:i}=e,a=new Set,r=new Set;for(let{id:e,name:n}of t)a.add(e),r.add(n.toLowerCase());for(let e of n)a.add(e.model.id),r.add(e.model.name.toLowerCase());let l=i.id,o=2;for(;a.has(l);)l="".concat(i.id,"_").concat(o),o++;let s=i.name;for(o=2;r.has(s.toLowerCase());)s="".concat(i.name).concat(o),o++;return{...i,id:l,name:s}}({existingSlices:i,newSlices:t,slice:n.model});t.push({...n,model:e})}let{slices:a,library:r}=await ej(t);await new Promise(e=>setTimeout(e,100));let l=await (0,f.y0)();for(let e of(I.createSliceSuccess(l.libraries),t))e.mocks&&Array.isArray(e.mocks)&&e.mocks.length>0&&I.updateSliceMockSuccess({libraryID:r,sliceID:e.model.id,mocks:e.mocks});for(let{model:e}of(k(),m(!1),C(),T("createSlice"),a))f.Xe.track({event:"slice:created",id:e.id,name:e.name,library:r,location:n,mode:"import"});f.Xe.track({event:"slice-library:import-ended",error:!1,slices_count:a.length,source_project_id:p.fullName,destination_project_id:D.repositoryName}),o({slices:a,library:r})}catch(e){m(!1),M.Am.error("An unexpected error happened while adding slices."),f.Xe.track({event:"slice-library:import-ended",error:!0,source_project_id:p.fullName,destination_project_id:D.repositoryName})}},N=new URL("builder/settings/git-integration",D.repositoryUrl).toString();if(S)t=(0,i.jsx)(eI,{});else if(0===j.length)t=(0,i.jsx)(er,{title:"GitHub connection required",description:"Connect your GitHub account to access\nrepositories and set a library for this project.",icon:"github",actions:(0,i.jsx)(a.E,{size:"medium",color:"grey",startIcon:"github",asChild:!0,children:(0,i.jsx)("a",{href:N,target:"_blank",children:"Connect GitHub"})})});else if(p){if(0===v.length)t=(0,i.jsx)(er,{title:"No slices found",description:"This repository doesn't contain any Slice components\ncompatible with your project.",icon:"viewDay"});else{let e=v.every(e=>u.some(t=>t.model.id===e.model.id)),n=v.some(e=>u.some(t=>t.model.id===e.model.id)),l="Select all slices";e?l="Selected all slices (".concat(u.length,")"):n&&(l="".concat(u.length," of ").concat(v.length," selected")),t=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.D,{flexDirection:"column",flexGrow:1,minHeight:0,children:[(0,i.jsx)(a.D,{padding:{block:12,inline:16},alignItems:"center",gap:8,children:(0,i.jsx)(a.aQ,{value:l,children:(0,i.jsx)(a.T,{checked:e,indeterminate:n&&!e,onCheckedChange:e=>{h(e?v:[])}})})}),(0,i.jsx)(a.bm,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{inline:16,bottom:16},children:v.map(e=>(0,i.jsx)(eb,{model:e.model,thumbnailUrl:e.thumbnailUrl,selected:u.some(t=>t.model.id===e.model.id),onSelectedChange:()=>_(e)},e.model.id))})})]}),(0,i.jsx)(en,{totalSelected:u.length,onSubmit:()=>void A(),isSubmitting:d,typeName:r})]})}}else t=(0,i.jsx)(er,{title:"No repository selected",description:"Choose a GitHub repository from the menu above.",icon:"alert"});return(0,i.jsxs)(ei,{selected:c,children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:l,rightContent:(0,i.jsx)(ew,{integrations:j,selectedRepository:p,onSelectRepository:e=>{y(e),h([]),w({repository:e,targetFramework:D.framework})},configureUrl:N,isTabSelected:c})}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:t})]})}function ew(e){let{integrations:t,selectedRepository:n,onSelectRepository:r,configureUrl:l,isTabSelected:o}=e,[c,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(""),h=e=>{r(e),d(!1)},p=(0,s.useMemo)(()=>t.flatMap(e=>e.repositories.map(t=>({...t,integrationId:e.id}))),[t]);(0,g.Ng)(()=>{o&&p.length>0&&(1===p.length&&r(p[0]),f.Xe.track({event:"slice-library:projects-listed",repositories_count:p.length}))},[o,p]);let x=p.filter(e=>e.fullName.toLowerCase().includes(m.toLowerCase()));return(0,i.jsxs)(a.aq,{open:c,onOpenChange:d,children:[(0,i.jsx)(a.au,{disabled:0===t.length,children:(0,i.jsx)(a.E,{endIcon:"arrowDropDown",textWeight:"normal",sx:{width:420},startIcon:"github",color:"grey",size:"large",flexContent:!0,children:n?n.fullName:"Select a GitHub repository"})}),(0,i.jsx)(a.ar,{align:"start",border:!1,minWidth:"full-trigger-width",childrenFocusScope:!0,children:(0,i.jsxs)(a.Y,{variant:"attached",children:[(0,i.jsx)(a.$,{value:m,onValueChange:u,placeholder:"Search",endAdornment:!0}),(0,i.jsxs)(a._,{children:[x.length>0?(0,i.jsx)(i.Fragment,{children:x.map(e=>(0,i.jsx)(a.a0,{value:e.fullName,onCheckedChange:()=>h(e),checked:(null==n?void 0:n.fullName)===e.fullName,children:(0,i.jsx)(eC,{children:e.fullName})},e.fullName))}):(0,i.jsx)(a.a0,{value:"none",disabled:!0,children:(0,i.jsx)(eC,{disabled:!0,children:(0,i.jsx)(a.D,{padding:8,children:"No repositories found"})})}),(0,i.jsx)(a.Z,{children:(0,i.jsx)(a.E,{textWeight:"normal",size:"medium",color:"dark",renderEndIcon:()=>(0,i.jsx)(a.aW,{name:"openInNew",size:"small"}),flexContent:!0,asChild:!0,invisible:!0,children:(0,i.jsx)("a",{href:l,target:"_blank",children:"Configure Repositories on Prismic"})})})]})]})})]})}function eC(e){let{children:t,disabled:n}=e;return(0,i.jsx)(a.D,{padding:{inline:8,block:4},children:(0,i.jsx)(a.bK,{variant:"normal",color:!0===n?"grey9":"grey12",children:t})})}function eI(){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.D,{flexGrow:1,minHeight:0,flexDirection:"column",padding:{inline:16,top:16},gap:16,children:[(0,i.jsx)(a.bw,{height:24,width:125}),(0,i.jsx)(a.D,{flexGrow:1,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{bottom:16},overflow:"hidden",children:Array.from({length:9}).map((e,t)=>(0,i.jsx)(a.bw,{height:240,width:"100%"},t))})]}),(0,i.jsx)(et,{})]})}function ek(e){let{openLoginModal:t}=(0,b.Z)(),n=(0,Y.NL)(),{data:r}=(0,V.k)({queryKey:["checkIsLoggedIn"],queryFn:()=>ee.managerClient.user.checkIsLoggedIn(),gcTime:0,staleTime:0});return r?(0,i.jsx)(eS,{...e}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab}),(0,i.jsx)(er,{title:"You are logged out",description:"This action requires you to be logged in.\nPlease log in to continue.",icon:"logout",actions:(0,i.jsx)(a.E,{size:"small",color:"grey",onClick:()=>{e.onClose(),t(),n.invalidateQueries({queryKey:["checkIsLoggedIn"]})},children:"Log in"})})]})}function eT(e){return(0,i.jsx)(ei,{selected:e.selected,children:(0,i.jsx)(a.ax,{renderError:()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab}),(0,i.jsx)(er,{title:"Failed to load library slices",icon:"alert",color:"tomato"})]}),children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab,rightContent:(0,i.jsx)(a.bw,{height:40,width:420})}),(0,i.jsx)(eI,{})]}),children:(0,i.jsx)(ek,{...e})})})})}function eD(e){let{typeName:t,onSelectTab:n,onSuccess:r,slices:l,isEveryLocalSliceAdded:o,selected:c}=e,[d,m]=(0,s.useState)([]),u=e=>{m(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])};return(0,i.jsxs)(ei,{selected:c,children:[(0,i.jsx)(ea,{selectedTab:"local",onSelectTab:n}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:l.length>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.bm,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,flexGrow:1,padding:16,minHeight:0,children:l.map(e=>{let t=d.some(t=>t.id===e.id);return(0,i.jsx)(eb,{model:e,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>u(e)},e.name)})})}),(0,i.jsx)(en,{totalSelected:d.length,onSubmit:()=>{if(0===d.length){M.Am.error("Please select at least one slice");return}r({slices:d.map(e=>({model:e}))})},typeName:t})]}):(0,i.jsx)(er,{title:"No local slices available",description:o?"All local slices have already been added to your slice zone.":void 0,icon:"alert"})})]})}function e_(e){let{open:t,localSlices:n,isEveryLocalSliceAdded:r,onClose:l,...o}=e,[c,d]=(0,s.useState)("local");return(0,s.useEffect)(()=>{if(!t){let e=setTimeout(()=>{d("local")},250);return()=>clearTimeout(e)}},[t]),(0,i.jsxs)(a.ad,{open:t,onOpenChange:e=>!e&&l(),children:[(0,i.jsx)(a.ak,{title:"Reuse an existing slice"}),(0,i.jsxs)(a.ai,{gap:0,children:[(0,i.jsx)(a.aj,{hidden:!0,children:"Select existing slices or import slices from a GitHub repository"}),(0,i.jsx)(eD,{...o,selected:"local"===c,onSelectTab:d,slices:n,isEveryLocalSliceAdded:r,onClose:l}),(0,i.jsx)(eT,{...o,selected:"library"===c,onSelectTab:d,onClose:l})]})]})}var eA=n(27213);let eN=e=>{let{openCreateSliceModal:t,openCreateSliceFromImageModal:n,openUpdateSliceZoneModal:r,openSlicesTemplatesModal:l,isSlicesTemplatesSupported:o}=e,s=(0,eA.F)({menuType:"ActionList"});return(0,i.jsxs)(a.s,{"data-testid":"slice-zone-blank-slate",sx:{width:648},children:[(0,i.jsx)(a.x,{lineColor:"purple9",backgroundColor:"purple5",name:"add",size:"large"}),(0,i.jsx)(a.z,{size:"big",children:"Add slices"}),(0,i.jsx)(a.w,{children:"Slices are reusable website sections. You can use them on different pages and write unique content for each. Each slice has its own component in your code."}),(0,i.jsx)(a.v,{children:(0,i.jsxs)(a.A,{children:[(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromImage.BackgroundIcon,onClick:n,description:s.fromImage.description,children:s.fromImage.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromScratch.BackgroundIcon,onClick:t,description:s.fromScratch.description,children:s.fromScratch.title}),o&&(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromTemplate.BackgroundIcon,onClick:l,description:s.fromTemplate.description,children:s.fromTemplate.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromExisting.BackgroundIcon,onClick:r,description:s.fromExisting.description,children:s.fromExisting.title})]})})]})};function eE(e){let{customType:t,tabId:n,slices:i}=e,a={...t};return i.forEach(e=>{a={...a,tabs:a.tabs.map(t=>t.key===n&&t.sliceZone?{...t,sliceZone:{key:t.sliceZone.key,value:[{key:e.id,value:e},...t.sliceZone.value]}}:t)}}),f.Xe.track({event:"custom-type:slice-zone-updated",customTypeId:t.id}),a}var ez=n(18566);async function eF(){try{let{templates:e,errors:t}=await ee.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,n]=e;return[t,URL.createObjectURL(n)]}))}))}catch(e){return[]}}var eP=n(6256),eL=n(39204),eM=n(26109),eK=n(7723),eO=n(33986),eZ=n(30527),eU=n(55862);let eG=e=>{let{deleteSliceZone:t,closeDeleteSliceZoneModal:n}=e;return(0,i.jsx)(eU.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:n,children:(0,i.jsx)(eZ.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,i.jsxs)(N.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,i.jsx)(N.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:"Do you really want to delete Slice Zone?"}),(0,i.jsx)(N.x8,{type:"button",onClick:n})]}),Footer:()=>(0,i.jsxs)(N.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,i.jsx)(eO.z,{label:"Cancel",variant:"secondary",onClick:n,sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),(0,i.jsx)(eO.z,{label:"Delete",variant:"danger",onClick:t,sx:{minHeight:39,minWidth:78}})]}),children:(0,i.jsx)(N.nv,{children:"You're about to delete Slice Zone."})})})};var eB=n(84879),eH=n(63908),eR=n(63019),eq=n(65375),eW=n.n(eq);let eX=e=>{var t;let{isOpen:n,close:r,onSubmit:l,isLoading:o,slice:d,libraries:m}=e,{remoteSlices:u}=(0,c.v9)(e=>({remoteSlices:(0,eK.sT)(e)})),h={from:null===(t=m[0])||void 0===t?void 0:t.name,sliceName:(0,G.MP)(d.key)},[p,f]=(0,s.useState)(h),[x,y]=(0,s.useState)();function b(e){f(e),y((0,eR.h)(e,m,u))}return(0,g.pQ)(n,()=>{n||(f(h),y(void 0))}),(0,i.jsxs)(a.ad,{open:n,onOpenChange:e=>!e&&r(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Upgrade slice"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){x&&Object.keys(x).length>0||l({libraryID:p.from,sliceID:p.sliceName})},children:(0,i.jsxs)(a.D,{flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{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,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"This will not migrate your component. You will need to do that manually."}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)(a.aL,{label:"Slice name *",placeholder:"Pascalised Slice API ID (e.g. ".concat((0,G.MP)(d.key),")"),error:null==x?void 0:x.sliceName,value:p.sliceName,onValueChange:e=>b({...p,sliceName:e.slice(0,30)}),"data-testid":"slice-name-input"}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"A display name for the slice"})]}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)("label",{className:eW().label,children:(0,i.jsx)(a.bK,{variant:"bold",children:"Slice library *"})}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"folder",flexContent:!0,value:p.from,onValueChange:e=>{e&&b({...p,from:e})},children:m.map(e=>(0,i.jsx)(a.bs,{value:e.name,children:e.name},e.name))}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"The library where we'll store your slice"})]})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:o,disabled:x&&Object.keys(x).length>0,children:"Upgrade"})]})]})})})]})};var eV=n(96009),eY=n.n(eV);let e$=e=>{var t,n;let{isOpen:r,close:l,onSubmit:o,isLoading:c,slice:d,sliceName:m,libraries:u,localSharedSlices:h}=e,p={libraryID:null===(t=h[0])||void 0===t?void 0:t.from,sliceID:null===(n=h[0])||void 0===n?void 0:n.model.id,variationID:eY()(d.key),variationName:m},[f,x]=(0,s.useState)(!0),[y,b]=(0,s.useState)(p),[j,v]=(0,s.useState)({});function S(e){b(e),v(eQ(e,u))}return(0,g.pQ)(r,()=>{r||(b(p),v({}))}),(0,i.jsxs)(a.ad,{open:r,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Convert to slice variation"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){Object.keys(j).length>0||o(y)},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"If you have multiple slices that are similar, you can combine them as variations of the same slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eW().label,children:[(0,i.jsx)(a.bK,{variant:"bold",children:"Target slice *"}),"string"==typeof j.libraryID?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:j.libraryID}):null,"string"==typeof j.sliceID?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:j.sliceID}):null]}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:"".concat(y.libraryID,"::").concat(y.sliceID),onValueChange:e=>{if(e){let[t,n]=e.split("::");S({...y,libraryID:t,sliceID:n})}},children:h.map(e=>(0,i.jsxs)(a.bs,{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,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"Choose the slice to which you would like to add this variation."})]}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aL,{label:"Variation name *",placeholder:m,error:j.variationName,value:y.variationName,onValueChange:e=>{let t={...y,variationName:e.slice(0,30)};f&&(t.variationID=eY()(t.variationName)),S(t)},"data-testid":"variation-name-input"})}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aL,{label:"ID *",placeholder:eY()(d.key),error:j.variationID,value:y.variationID,onValueChange:e=>{x(!1),S({...y,variationID:e.slice(0,30)})},"data-testid":"variation-id-input"})})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:c,disabled:Object.keys(j).length>0,children:"Convert"})]})]})})})]})},eQ=(e,t)=>{let n={};e.libraryID||(n.libraryID="Cannot be empty.");let i=t.find(t=>t.path===e.libraryID);n.libraryID||i||(n.libraryID="Does not exist."),e.sliceID||(n.sliceID="Cannot be empty.");let a=null==i?void 0:i.components.find(t=>t.model.id===e.sliceID);if(n.sliceID||a||(n.sliceID="Does not exist."),e.variationName||(n.variationName="Cannot be empty."),e.variationID){var r;(null!==(r=null==a?void 0:a.model.variations.map(e=>e.id))&&void 0!==r?r:[]).includes(e.variationID)&&(n.variationID="Slice variation ID is already taken.")}else n.variationID="Cannot be empty.";return n},eJ=e=>{var t,n;let{isOpen:r,close:l,onSubmit:o,isLoading:c,identicalSlices:d}=e,m=null!==(n=null===(t=d[0])||void 0===t?void 0:t.path)&&void 0!==n?n:"",[u,h]=(0,s.useState)(m),[p,f]=(0,s.useState)();return(0,g.pQ)(r,()=>{r||(h(m),f(void 0))}),(0,i.jsxs)(a.ad,{open:r,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Merge with an existing slice"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){if(p)return;let[e,t,n]=u.split("::");o({libraryID:e,sliceID:t,variationID:n})},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{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,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eW().label,children:[(0,i.jsx)(a.bK,{variant:"bold",children:"Target slice*"}),"string"==typeof p?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:p}):null]}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:u,onValueChange:function(e){h(e),e||f("Cannot be empty.")},children:d.map(e=>(0,i.jsx)(a.bs,{value:e.path,children:e.path.split("::").join(" > ")},e.path))}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"Choose a slice that you would like to merge this into."})]})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:c,disabled:!!p,children:"Merge"})]})]})})})]})},e0=e=>{var t;let{slice:n,path:r}=e,{refreshState:l}=(0,b.Z)(),[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(),{setCustomType:h}=w(),{libraries:p}=(0,c.v9)(e=>({libraries:(0,eK.Sd)(e)})),g="Slice"===n.value.type&&null!==(t=n.value.fieldset)&&void 0!==t?t:n.key,x=p.filter(e=>e.isLocal),y=x.map(e=>e.components).flat(),j=e1(n,g,y),v=async e=>{var t,i,a;if(!m)return;d(!0),f.Xe.track({event:"legacy-slice:converted",id:e.sliceID,variation:null!==(t=e.variationID)&&void 0!==t?t:"default",library:e.libraryID,conversionType:m});let{errors:o}=await ee.managerClient.slices.convertLegacySliceToSharedSlice({model:n.value,src:{...r,sliceID:n.key},dest:{libraryID:e.libraryID,sliceID:e.sliceID,variationName:null!==(i=e.variationName)&&void 0!==i?i:"Default",variationID:null!==(a=e.variationID)&&void 0!==a?a:"default"}});if(o.length)throw console.error("Could not convert slice `".concat(g,"`"),o),M.Am.error("Could not convert slice `".concat(g,"`")),o;let{model:s,errors:c}=await ee.managerClient.customTypes.readCustomType({id:r.customTypeID});if(c.length||!s){console.error("Could not refresh custom type view `".concat(r.customTypeID,"`"),c),M.Am.error("Could not refresh custom type view `".concat(r.customTypeID,"`"));return}switch(l(await (0,f.y0)()),d(!1),u(void 0),m){case"as_new_slice":M.Am.success("".concat(g," has been upgraded to a new slice ").concat(e.libraryID," > ").concat(e.sliceID));break;case"as_new_variation":M.Am.success("".concat(g," has been converted as a variation of ").concat(e.libraryID," > ").concat(e.sliceID));break;default:M.Am.success("".concat(g," has been merged with ").concat(e.libraryID," > ").concat(e.sliceID))}h({customType:s})},S={path:r,slice:n,sliceName:g,libraries:x,localSharedSlices:y,identicalSlices:j,close:()=>u(void 0),onSubmit:v,isLoading:o};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.aq,{children:[(0,i.jsx)(a.au,{children:(0,i.jsx)(a.E,{"data-testid":"convert-legacy-slice",startIcon:"refresh",endIcon:"arrowDropDown",size:"medium",color:"grey",children:"Migrate legacy slice"})}),(0,i.jsxs)(a.ar,{align:"start",children:[(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"folder",size:"large"}),description:"Use it with new types",onSelect:()=>u("as_new_slice"),children:"Upgrade slice"}),(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"viewDay",size:"large"}),description:"Add it to another slice",onSelect:()=>u("as_new_variation"),disabled:!y.length,children:"Convert to slice variation"}),(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"driveFileMove",size:"large"}),description:"Combine identical slices",onSelect:()=>u("merge_with_identical"),disabled:!j.length,children:"Merge with another slice"})]})]}),(0,i.jsx)(eX,{...S,isOpen:"as_new_slice"===m}),(0,i.jsx)(e$,{...S,isOpen:"as_new_variation"===m}),(0,i.jsx)(eJ,{...S,isOpen:"merge_with_identical"===m})]})},e1=(e,t,n)=>(0,s.useMemo)(()=>{let i=[],a=(0,eH.ux)(e.value,t);for(let e of n)for(let t of e.model.variations){let n=(0,eH.ux)(t,e.model.name);a.primary===n.primary&&a.items===n.items&&i.push({libraryID:e.from,sliceID:e.model.id,variationID:t.id,path:"".concat(e.from,"::").concat(e.model.id,"::").concat(t.id)})}return i},[e,t,n]),e4=e=>{let{slice:t,path:n}=e,[r]=(0,eB.E)("legacySliceUpgrader"),l=r.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,i.jsxs)(ey.Zb,{children:[(0,i.jsx)(ey.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(a.bK,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsxs)(ey.T$,{children:[(0,i.jsx)(a.c2,{content:l,side:"bottom",children:(0,i.jsx)(a.m,{color:"purple",title:"Legacy Slice"})}),r.enabled?(0,i.jsx)(e0,{slice:t,path:n}):null]}),(0,i.jsx)(ey.eW,{subtitle:"1 variation",title:(0,eH.Dj)(t.value)})]})};var e6=n(51507),e2=n(21151);let e8=e=>{let{slices:t,format:n,path:a,onRemoveSharedSlice:r}=e,l=t.some(e=>"SharedSlice"!==e.type),o=j.$[n],[c]=(0,eB.E)("legacySliceUpgrader");return(0,s.useEffect)(()=>{l&&(c.enabled?M.Am.info("This ".concat(o.name({start:!1,plural:!1})," contains legacy slices that can be upgraded.")):M.Am.warning("This ".concat(o.name({start:!1,plural:!1})," contains slices that are incompatible.")))},[l]),(0,i.jsx)(e2.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,i.jsx)(e4,{slice:t,path:a})}{let t=e.payload;return(0,i.jsx)(e6.b,{action:{type:"remove",onRemove:()=>{r(t.model.id)}},mode:"navigation",slice:t,variant:"solid"})}},sx:{padding:"16px"}})};async function e3(e){try{let{templateIDs:t,localLibrariesNames:n,location:i,onSuccess:a}=e,{data:r,errors:l}=await ee.managerClient.sliceTemplateLibrary.createSlices({templateIDs:t});if(l.length>0||void 0===r)throw l;r.sliceIDs.forEach((e,a)=>{f.Xe.track({event:"slice:created",id:e,name:e,library:n[0],location:i,mode:"template",sliceTemplate:t[a]})}),await a(r.sliceIDs)}catch(t){let e="Internal Error: Slice(s) not created";console.error(e,t),M.Am.error(e)}}var e5=e=>{let{availableSlices:t,values:n}=e;return(0,i.jsx)(A.F2,{name:"sliceKeys",render:e=>(0,i.jsx)(e2.Z,{gridTemplateMinPx:"200px",elems:t,defineElementKey:e=>"".concat(e.from,"-").concat(e.model.name),renderElem:t=>{let a=n.sliceKeys.includes(t.model.id);return(0,i.jsx)(e6.b,{action:{type:"checkbox"},mode:"selection",onSelectedChange:i=>{i?e.push(t.model.id):e.remove(n.sliceKeys.indexOf(t.model.id))},selected:a,slice:t,variant:"outlined"})}})})};let e9=e=>{let{formId:t,close:n,onSuccess:a,availableSlicesTemplates:r,localLibraries:l,location:o}=e,{createSliceSuccess:s}=(0,b.Z)();return(0,i.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:n,onSubmit:e=>{let{sliceKeys:t}=e;e3({templateIDs:t,localLibrariesNames:l.map(e=>e.name),location:o,onSuccess:async e=>{s((await (0,f.y0)()).libraries),a(await Promise.all(e.map(async e=>(await ee.managerClient.slices.readSlice({libraryID:l[0].name,sliceID:e})).model).filter(e=>void 0!==e)))}})},initialValues:{sliceKeys:[]},content:{title:"Use template slices"},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,i.jsx)(N.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,i.jsx)(e5,{values:t,availableSlices:r.map(e=>({extension:"",fileName:"",from:"",href:"",pathToSlice:"",model:eM.id.toSM(e.model),screenshots:Object.entries(e.screenshots).reduce((e,t)=>({...e,[t[0]]:{url:t[1]}}),{})}))})}})},e7=(e,t)=>{let n=(t||[]).reduce((e,t)=>[...e,...t.components],[]),{slicesInSliceZone:i,notFound:a}=e.value.reduce((e,t)=>{let{key:i,value:a}=t;if("SharedSlice"===a.type){let t=n.find(e=>e.model.id===i);return t?{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"SharedSlice",payload:t}]}:{...e,notFound:[...e.notFound,{key:i}]}}return{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"Slice",payload:{key:i,value:a}}]}},{slicesInSliceZone:[],notFound:[]});return{availableSlices:n,slicesInSliceZone:i,notFound:a}};var te=e=>{var t,n;let{customType:r,onCreateSliceZone:l,onDeleteSliceZone:o,onRemoveSharedSlice:d,sliceZone:m,tabId:u}=e,h=(0,ez.QT)(eF,[]),[p,g]=(0,s.useState)(!1),[x,y]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),{remoteSlices:I,libraries:k}=(0,c.v9)(e=>({remoteSlices:(0,eK.sT)(e),libraries:(0,eK.Sd)(e),slices:(0,eK.xC)(e)})),{setCustomType:T}=w(),{completeStep:_}=(0,Q.k)(),{openLoginModal:A}=(0,b.Z)(),N=(0,eA.F)({menuType:"Dropdown"}),E=k.filter(e=>e.isLocal),{availableSlices:z,slicesInSliceZone:F,notFound:P}=(0,s.useMemo)(()=>m?e7(m,k):{availableSlices:[],slicesInSliceZone:[],notFound:[]},[m,k]),[L,O]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(null==P?void 0:P.length)&&P.forEach(e=>{let{key:t}=e;d(t)})},[P]);let Z=F.filter(e=>"SharedSlice"===e.type).map(e=>e.payload),U=z.filter(e=>!Z.some(t=>t.model.id===e.model.id)),G=()=>{y(!0)},B=()=>{v(!0)},H=async()=>{await ee.managerClient.user.checkIsLoggedIn()?C(!0):A()},R=()=>{g(!0),f.Xe.track({event:"custom-type:open-add-from-templates",customTypeId:r.id,customTypeFormat:r.format})},q=()=>{y(!1)},V=()=>{v(!1)},Y=()=>{C(!1)},$=()=>{g(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(K.Bu,{actions:m?(0,i.jsxs)(a.aq,{children:[(0,i.jsx)(a.au,{children:(0,i.jsx)(a.E,{color:"purple",startIcon:"add","data-testid":"add-new-slice-dropdown",children:"Add"})}),(0,i.jsxs)(a.ar,{align:"end",children:[(0,i.jsx)(a.as,{renderStartIcon:()=>N.fromImage.BackgroundIcon,onSelect:()=>void H(),description:N.fromImage.description,children:N.fromImage.title}),(0,i.jsx)(a.as,{renderStartIcon:()=>N.fromScratch.BackgroundIcon,onSelect:B,description:N.fromScratch.description,children:N.fromScratch.title}),h.length>0?(0,i.jsx)(a.as,{onSelect:R,renderStartIcon:()=>N.fromTemplate.BackgroundIcon,description:N.fromTemplate.description,children:N.fromTemplate.title}):void 0,(0,i.jsx)(a.as,{onSelect:G,renderStartIcon:()=>N.fromExisting.BackgroundIcon,description:N.fromExisting.description,children:N.fromExisting.title})]})]}):void 0,toggle:"page"!==r.format||"Main"!==u?(0,i.jsx)(a.bB,{checked:!!m,onCheckedChange:e=>{e?l():O(!0)},size:"small","data-testid":"slice-zone-switch"}):void 0,children:"Slices"}),m?F.length>0?(0,i.jsx)(W.xR,{children:(0,i.jsx)(e8,{slices:F,format:r.format,path:{customTypeID:r.id,tabID:u,sliceZoneID:null!==(t=null==m?void 0:m.key)&&void 0!==t?t:""},onRemoveSharedSlice:d})}):(0,i.jsx)(a.D,{flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center",padding:{block:32},children:(0,i.jsx)(eN,{openUpdateSliceZoneModal:G,openCreateSliceModal:B,openCreateSliceFromImageModal:()=>void H(),openSlicesTemplatesModal:R,projectHasAvailableSlices:U.length>0,isSlicesTemplatesSupported:h.length>0})}):void 0,(0,i.jsx)(e_,{open:x,location:"".concat(r.format,"_type"),typeName:null!==(n=r.label)&&void 0!==n?n:r.id,localSlices:U.map(e=>{var t;return{...eM.id.fromSM(e.model),thumbnailUrl:"default"in e.screenshots?e.screenshots.default.url:null===(t=Object.values(e.screenshots)[0])||void 0===t?void 0:t.url}}),isEveryLocalSliceAdded:z.length>0&&0===U.length,onSuccess:e=>{let{slices:t}=e,n=eE({customType:r,tabId:u,slices:t.map(e=>e.model)});T({customType:D.Dc.fromSM(n),onSaveCallback:()=>{M.Am.success("Slices successfully added")}}),_("createSlice"),q()},onClose:q}),p&&(0,i.jsx)(e9,{formId:"tab-slicezone-form-".concat(u),availableSlicesTemplates:h,localLibraries:E,location:"".concat(r.format,"_type"),onSuccess:e=>{let t=eE({customType:r,tabId:u,slices:e});T({customType:D.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"Slice template(s) added to slice zone and created at: ",path:"".concat(E[0].name,"/")}))}}),_("createSlice"),$()},close:$}),L&&(0,i.jsx)(eG,{closeDeleteSliceZoneModal:()=>{O(!1)},deleteSliceZone:()=>{o(),O(!1)}}),(null==E?void 0:E.length)!==0&&j&&(0,i.jsx)(eP.c,{onSuccess:e=>{let t=eE({customType:r,tabId:u,slices:[e]});T({customType:D.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"New slice added to slice zone and created at: ",path:"".concat(E[0].name,"/")}))}}),V()},localLibraries:E,location:"".concat(r.format,"_type"),remoteSlices:I,onClose:V}),(0,i.jsx)(X.S,{open:S,location:"".concat(r.format,"_type"),onSuccess:e=>{let{slices:t,library:n}=e,a=eE({customType:r,tabId:u,slices:t});T({customType:D.Dc.fromSM(a),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"Slice(s) added to slice zone and created at: ",path:n}))}}),Y()},onClose:Y})]})};let tt=[Z.C.UID,Z.C.Image,Z.C.Text,Z.C.StructuredText,Z.C.Link,Z.C.Select,Z.C.Boolean,Z.C.Number,Z.C.Color,Z.C.Date,Z.C.Table,Z.C.Embed,Z.C.Timestamp,Z.C.GeoPoint,Z.C.ContentRelationship,Z.C.LinkToMedia,Z.C.Group,Z.C.NestedGroup];var tn=e=>{var t,n,r,l;let{tabId:o}=e,{customType:c,setCustomType:d}=w(),u=D.Dc.toSM(c),h=null===(t=u.tabs.find(e=>e.key===o))||void 0===t?void 0:t.sliceZone,p=null!==(r=null===(n=u.tabs.find(e=>e.key===o))||void 0===n?void 0:n.value)&&void 0!==r?r:[],g="page"===u.format&&u.repeatable?p.filter(e=>"uid"!==e.key):p,f=u.tabs.reduce((e,t)=>[...e,...t.value],[]),x=e=>{var t;let{apiId:n,value:i}=e,a=null===(t=i.config)||void 0===t?void 0:t.label;if((0,U.Ss)(Z.C,i.type)||null==a)return;if("Range"===i.type||"IntegrationFields"===i.type||"Separator"===i.type)throw Error("Unsupported Field Type: ".concat(i.type));let r=Z.C[i.type];try{r.schema.validateSync(i,{stripUnknown:!1})}catch(e){throw Error('Add field: Model is invalid for field "'.concat(i.type,'".'))}let l=D.L$.fromSM(i);d({customType:(0,m.xS)({customType:c,newField:l,newFieldId:n,sectionId:o}),onSaveCallback:()=>{M.Am.success("".concat("Group"===i.type?"Group":"Field"," added"))}}),(0,B.V)({id:n,field:l})},y=e=>{let{apiId:t,newKey:n,value:i,inGroupFieldAction:a,updateMeta:r}=e;if((0,U.Ss)(Z.C,i.type))return;let l=D.L$.fromSM(i);d({customType:(0,m.L4)({customType:c,previousFieldId:t,newFieldId:n,newField:l,sectionId:o}),onSaveCallback:()=>{"add"===a&&M.Am.success("Field added")},updateMeta:r}),a||(0,H.Z)({previousId:t,id:n,field:l})};return(0,i.jsx)(O.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.D,{padding:32,children:(0,i.jsx)(a.bf,{})}),children:(0,i.jsxs)(K.aV,{border:!1,style:{flexGrow:1},children:[(0,i.jsx)(q.Z,{zoneType:"customType",zoneTypeFormat:null!==(l=c.format)&&void 0!==l?l:"custom",tabId:o,title:"Static zone",dataTip:"",fields:g,poolOfFieldsToCheck:f,showHints:!0,EditModal:R.Z,widgetsArray:tt,onDeleteItem:e=>{d({customType:(0,m.AK)({customType:c,fieldId:e,sectionId:o})})},onSave:e=>""===e.apiId?x({...e,apiId:e.newKey}):y(e),onDragEnd:e=>{if((0,U.uS)(e))return;let{source:t,destination:n}=e;if(!n)return;let i=(0,m.gR)({customType:c,sourceIndex:t.index,destinationIndex:n.index,sectionId:o});(0,L.flushSync)(()=>d({customType:i}))},renderHintBase:e=>{let{item:t}=e;return"data".concat((0,G.Ti)(t.key))},renderFieldAccessor:e=>"data".concat((0,G.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:c.repeatable}),(0,i.jsx)(te,{customType:u,tabId:o,sliceZone:h,onRemoveSharedSlice:e=>{d({customType:(0,m.EN)({customType:c,sectionId:o,sliceId:e})})},onCreateSliceZone:()=>{d({customType:(0,m.Tr)(c,o)})},onDeleteSliceZone:()=>{d({customType:(0,m.E3)(c,o)})}})]})})})};let ti=()=>{var e,t,n;let{customType:r,setCustomType:l}=w(),o=D.Dc.toSM(r),[c,d]=(0,s.useState)(null===(e=o.tabs[0])||void 0===e?void 0:e.key),[u,h]=(0,s.useState)(),p=(null===(n=o.tabs.find(e=>e.key===c))||void 0===n?void 0:null===(t=n.sliceZone)||void 0===t?void 0:t.value.length)===0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.c8,{sx:p?{flexGrow:1}:void 0,children:["page"===r.format?(0,i.jsx)(a.c9,{title:r.repeatable?(0,i.jsx)(I,{}):void 0}):void 0,(0,i.jsxs)(a.ca,{onValueChange:d,value:c,children:[(0,i.jsx)(a.cc,{onAddNewTab:()=>{h({type:"CREATE_CUSTOM_TYPE_TAB"})},children:o.tabs.map(e=>(0,i.jsx)(a.cd,{menu:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.as,{onSelect:()=>{h({type:"UPDATE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aW,{name:"edit"}),children:"Rename"}),(0,i.jsx)(a.as,{color:"tomato",disabled:function(e){if(o.tabs.length<=1)return!0;let t=o.tabs.find(e=>e.value.find(e=>"uid"===e.key));return"page"===r.format&&r.repeatable&&(null==t?void 0:t.key)===e}(e.key),onSelect:()=>{h({type:"DELETE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aW,{name:"delete"}),children:"Remove"})]}),value:e.key,children:e.key},e.key))}),o.tabs.map(e=>(0,i.jsx)(a.cb,{value:e.key,children:(0,i.jsx)(tn,{tabId:e.key})},e.key))]})]}),(null==u?void 0:u.type)==="CREATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(z,{close:()=>{h(void 0)},isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.vB)(r,t)}),d(t)},tabIds:o.tabs.map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="UPDATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(P,{close:()=>{h(void 0)},initialTabKey:u.tabKey,isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.HO)(r,u.tabKey,t)}),c===u.tabKey&&d(t)},tabIds:o.tabs.filter(e=>e.key!==u.tabKey).map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="DELETE_CUSTOM_TYPE_TAB"?(0,i.jsx)(F,{close:()=>{h(void 0)},isOpen:!0,onSubmit:()=>{if(l({customType:(0,m.F$)(r,u.tabKey)}),c===u.tabKey){var e;let t=null===(e=o.tabs.find(e=>e.key!==u.tabKey))||void 0===e?void 0:e.key;void 0!==t&&d(t)}}}):void 0]})};var ta=n(16442),tr=n(78254),tl=n(60867),to=n(11166),ts=n(34919),tc=n.n(ts);let td=e=>{let{tabs:t,...n}=e;return(0,i.jsxs)(to.fC,{...n,className:tc().root,defaultValue:t[0].label,orientation:"vertical",children:[(0,i.jsx)(to.aV,{className:tc().list,"aria-label":"content tabs",children:t.map((e,t)=>{let{label:n}=e;return(0,i.jsx)(to.xz,{className:tc().trigger,value:n,children:(0,i.jsx)(a.bK,{className:tc().triggerText,component:"span",color:"inherit",children:n})},"".concat(n,"-trig").concat(t+1))})}),t.map((e,t)=>{let{label:n,content:r}=e;return(0,i.jsx)(to.VY,{className:tc().content,value:n,children:(0,i.jsx)(a.bm,{className:tc().scrollArea,children:r})},"".concat(n,"-content").concat(t+1))})]})};var tm=n(25661),tu=n(88241),th=n(32554),tp=n(44621),tg=n.n(tp);let tf=e=>{var t,n;let{inline:r,...l}=e,o=(0,th.p)();if(!0===r)return(0,i.jsx)("code",{...l,className:tg().inlineCode});let s=(()=>{var e,t,n,i,a;if((null===(t=l.node)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.meta)!==void 0){let e=null===(i=l.node)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.meta;return{fileName:e.substring(1,e.length-1),language:null===(a=l.className)||void 0===a?void 0:a.split("-")[1]}}return null})(),c=null===(t=/language-(\w+)/.exec(null!==(n=l.className)&&void 0!==n?n:""))||void 0===t?void 0:t[1];return(0,i.jsx)(a.V,{...l,onCopy:()=>{f.Xe.track({event:"page-type:copy-snippet",framework:o})},language:c,code:String(l.children).replace(/\n$/,""),title:null==s?void 0:s.fileName})},tx=e=>{let{markdown:t}=e;return(0,i.jsx)(tm.D,{children:t,linkTarget:"_blank",remarkPlugins:[tu.Z],components:{code:e=>(0,i.jsx)(tf,{...e}),h1:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h1",variant:"h1"}),h2:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h2",variant:"h2"}),h3:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h3",variant:"h3"}),h4:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h4",variant:"h4"}),h5:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h4",variant:"h4"}),p:e=>(0,i.jsx)(a.bK,{className:tg().section,children:e.children,component:"p",variant:"normal"}),pre:e=>(0,i.jsx)(a.bK,{className:tg().section,children:e.children,component:"pre",variant:"normal"})}})};async function ty(e){let t=JSON.parse(e),{errors:n,documentation:i}=await ee.managerClient.documentation.read({kind:t.kind,data:t.data});if(n.length>0)throw n;return i}var tb=n(65480),tj=n.n(tb);let tv=e=>{var t;let{model:n}=e,r=(0,th.p)(),l=(t={kind:"PageSnippet",data:{model:n}},(0,ez.QT)(ty,[JSON.stringify(t)])),{completeStep:o}=(0,Q.k)();return 0===l.length?null:(0,i.jsxs)(a.ad,{size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",onClick:()=>{o("codePage"),f.Xe.track({event:"page-type:open-snippet",framework:r})},startIcon:"code",children:"Page snippet"}),children:[(0,i.jsx)(a.ak,{icon:"code",title:"Page snippet"}),(0,i.jsx)("section",{className:tj().content,children:l.length>1?(0,i.jsx)(td,{style:{flex:1},tabs:l.map((e,t)=>{let{label:n,content:a}=e;return{label:null!=n?n:"Tab ".concat(t+1),content:(0,i.jsx)(tx,{markdown:a})}})}):(0,i.jsx)(a.bm,{style:{flex:1,padding:16},children:(0,i.jsx)(tx,{markdown:l[0].content})})})]})},tS=e=>{let{model:t}=e;return(0,i.jsx)("div",{children:(0,i.jsx)(O.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.E,{color:"grey",startIcon:"code",children:"Page snippet"}),children:(0,i.jsx)(tv,{model:t})})})})},tw=()=>{let e=(0,o.useRouter)(),{selectedCustomType:t}=(0,c.v9)(t=>({selectedCustomType:(0,tr.Jk)(t,(0,h.Ag)(e.query))}));return((0,s.useEffect)(()=>{t&&(0,ta.TG)(t)||e.replace("/")},[t,e]),t&&(0,ta.TG)(t))?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l(),{children:(0,i.jsxs)("title",{children:[t.local.label," - Slice Machine"]})}),(0,i.jsx)(tC,{customType:t.local})]}):(0,i.jsx)(p.LN,{})},tC=e=>{let{customType:t}=e;return null===t?(0,i.jsx)(p.LN,{}):(0,i.jsx)(p.LN,{children:(0,i.jsx)(S,{initialCustomType:D.Dc.fromSM(t),children:e=>{var n;let{actionQueueStatus:r,customType:l,setCustomType:o}=e,s=(0,m.y6)(l),c=h.cd[t.format],g=j.$[t.format];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.wd,{children:[(0,i.jsx)(p.Xq,{url:c.tablePagePathname}),(0,i.jsxs)(p.Cx,{children:[(0,i.jsx)(d.g,{children:g.name({start:!0,plural:!0})}),(0,i.jsx)(d.g,{active:!0,children:null!==(n=l.label)&&void 0!==n?n:l.id})]}),(0,i.jsxs)(p.K2,{children:[(0,i.jsx)(u.X,{status:r}),"page"===l.format?(0,i.jsx)(tS,{model:l}):void 0,(0,i.jsx)(tl._,{isChangesLocal:!0,format:s,customType:l,setLocalCustomType:o})]})]}),(0,i.jsx)(p.RN,{children:(0,i.jsx)(a.D,{flexDirection:"column",minWidth:0,children:(0,i.jsx)(ti,{})})})]})}})})}},84879:function(e,t,n){"use strict";n.d(t,{E:function(){return l}});var i=n(18566),a=n(80148);async function r(){return a.managerClient.project.getSliceMachineConfig()}function l(e){var t,n;let[l,o]=[(0,i.QT)(r,[]),async e=>{await a.managerClient.project.writeSliceMachineConfig({config:e}),(0,i.VA)(r,[],e)}],s=async t=>{let n={...l,labs:{...l.labs}};t?n.labs[e]=t:e in n.labs&&delete n.labs[e],0===Object.keys(n.labs).length&&delete n.labs,await o(n)};return[{enabled:null!==(n=null==l?void 0:null===(t=l.labs)||void 0===t?void 0:t[e])&&void 0!==n&&n},s]}},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"}}}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[614],{90614:function(e,t,n){"use strict";n.d(t,{H:function(){return tw}});var i=n(52322),a=n(15934),r=n(97729),l=n.n(r),o=n(5632),s=n(2784),c=n(56580),d=n(43388),m=n(77630),u=n(23094),h=n(59294),p=n(58446),g=n(74217),f=n(94160),x=n(68968),y=n(23710),b=n(54597),j=n(98564);let v=(0,s.createContext)(void 0);function S(e){let{children:t,initialCustomType:n}=e,[a,r]=(0,s.useState)(n),l=(0,m.y6)(a),o=j.$[l],{actionQueueStatus:c,setNextAction:d}=(0,y.c)({errorMessage:o.autoSaveFailed}),{refreshState:u}=(0,b.Z)(),h=(0,g.R9)(u),{syncChanges:p}=(0,x.g)(),S=(0,s.useCallback)(e=>{let{customType:t,onSaveCallback:n,updateMeta:i}=e;r(t),d(async()=>{let{errors:e}=await (0,f.KA)({customType:t,updateMeta:i});if(e.length>0)throw e;h(await (0,f.y0)()),p(),null==n||n()})},[d,h,p]),w=(0,s.useMemo)(()=>({actionQueueStatus:c,customType:a,setCustomType:S}),[c,a,S]);return(0,i.jsx)(v.Provider,{value:w,children:"function"==typeof t?t(w):t})}function w(){let e=(0,s.useContext)(v);if(!e)throw Error("CustomTypeProvider not found");return e}var C=n(30195);function I(){var e;let[t,n]=(0,s.useState)(!1),{customType:r,setCustomType:l}=w(),[o,c]=null!==(e=(0,m.j5)(r))&&void 0!==e?e:[],d=c?(0,m.N3)(c):"",[u,h]=(0,s.useState)(null!=d?d:""),[p,f]=(0,s.useState)();(0,g.pQ)(t,()=>{t||(h(null!=d?d:""),f(void 0))});let x=(0,s.useCallback)(()=>(0,i.jsx)(a.aW,{name:c?"language":"add",size:"small",color:"grey11"}),[c]);return(0,i.jsxs)(a.ad,{open:t,onOpenChange:n,size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",textColor:"placeholder",textWeight:"normal",renderStartIcon:x,sx:{marginInline:"auto"},children:c?d:"Add an UID"}),children:[(0,i.jsx)(a.ak,{title:"Edit the UID label"}),(0,i.jsx)(a.ai,{children:(0,i.jsxs)(a.aI,{onSubmit:function(){p||(l({customType:c?(0,m.eK)(u,r):(0,m.H8)(u,r)}),n(!1))},children:[(0,i.jsx)(a.D,{flexDirection:"column",padding:16,gap:4,children:(0,i.jsx)(a.aL,{type:"text",label:"Label *",placeholder:"UID",value:u,onValueChange:function(e){h(e),f(function(e){let t=k.safeParse(e,{errorMap:T});if(t.error)return t.error.errors[0].message}(e))},error:p,description:"A label for the UID"})}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",disabled:!!p,children:"Save"})]})]})})]})}let k=C.z.string().max(35).min(1),T=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 D=n(94840),_=n(59532),A=n(63397),N=n(75289);let E=e=>{let{name:t,label:n,placeholder:a,error:r,...l}=e;return(0,i.jsxs)(N.xu,{mb:3,children:[(0,i.jsx)(N.__,{htmlFor:t,mb:2,children:n}),(0,i.jsx)(A.gN,{name:t,type:"text",placeholder:a,as:N.II,autoComplete:"off",...l}),r?(0,i.jsx)(N.xv,{sx:{color:"error",mt:1},children:r}):null]})};var z=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:r}=e;return(0,i.jsx)(_.Z,{isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,onSubmit:e=>{n(e),a()},initialValues:{id:""},validate:e=>{let{id:t}=e;return t?r.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,i.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})}})},F=e=>{let{isOpen:t,onSubmit:n,close:a}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{},content:{title:"Remove Tab"},children:()=>(0,i.jsxs)(N.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(N.X6,{as:"h4",children:"Remove this tab?"}),(0,i.jsx)(N.xv,{as:"p",color:"textClear",sx:{mt:2},children:"This action cannot be undone."}),(0,i.jsx)(N.zx,{type:"button",variant:"buttons.actionDelete",sx:{mt:3},onClick:()=>{n({}),a()},children:"Yes, remove tab"})]})})},P=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:r,initialTabKey:l}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{id:l},validate:e=>{let{id:t}=e;return t?r.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Rename Tab"},children:e=>{let{errors:t,values:r,setFieldValue:l,isValid:o}=e;return(0,i.jsxs)(N.xu,{sx:{px:4,py:4},children:[(0,i.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=>{r.id!==e.target.value&&l("id",e.target.value.trim())},onChange:e=>{l("id",e.target.value)}}),(0,i.jsx)(N.zx,{type:"button",sx:{mt:3,width:"100%"},disabled:!o,onClick:()=>{r.id&&r.id.length&&n({id:r.id.trim()}),a()},children:"Save"})]})}})},L=n(28316),M=n(88932),K=n(35289),O=n(87446),Z=n(45440),U=n(16086),G=n(358),B=n(5495),H=n(39302),R=n(3285),q=n(64844),W=n(65077),X=n(21446),V=n(92708),Y=n(14010);function $(e){switch(e){case"@slicemachine/adapter-next":return"next";case"@slicemachine/adapter-nuxt":case"@slicemachine/adapter-nuxt2":return"nuxt";case"@slicemachine/adapter-sveltekit":return"sveltekit";default:return}}var Q=n(98250),J=n(30613),ee=n(80148);function et(){return(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.bw,{height:32,width:58.48}),(0,i.jsx)(a.bw,{height:32,width:110.38})]})}function en(e){let{totalSelected:t,onSubmit:n,isSubmitting:r,typeName:l}=e;return(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{disabled:r,size:"medium"}),(0,i.jsxs)(a.ae,{disabled:0===t,loading:r,onClick:n,size:"medium",children:["Add to ",l," (",t,")"]})]})}function ei(e){let{children:t,selected:n}=e;return n?(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:t}):(0,i.jsx)(a.D,{display:"none",minHeight:0,children:t})}function ea(e){let{selectedTab:t,onSelectTab:n,rightContent:r}=e;return(0,i.jsxs)(a.D,{justifyContent:"space-between",padding:16,border:{bottom:!0},gap:8,children:[(0,i.jsxs)(a.D,{gap:8,children:[(0,i.jsx)(a.bC,{selected:"local"===t,onClick:()=>n("local"),children:"Local Slices"}),(0,i.jsx)(a.bC,{selected:"library"===t,onClick:()=>n("library"),children:"Library Slices"})]}),r]})}function er(e){let t,n;let{title:r,description:l,icon:o,actions:s,color:c="purple"}=e;switch(c){case"purple":t="purple11",n="purple3";break;case"tomato":t="tomato11",n="tomato3"}return(0,i.jsx)(a.D,{flexDirection:"column",justifyContent:"center",alignItems:"center",gap:16,flexGrow:1,children:(0,i.jsxs)(a.s,{children:[(0,i.jsx)(a.x,{lineColor:t,backgroundColor:n,name:o}),(0,i.jsx)(a.z,{size:"medium",children:r}),void 0!==l&&(0,i.jsx)(a.w,{children:l}),void 0!==s&&(0,i.jsx)(a.v,{children:s})]})})}var el=n(87686),eo=n(74686),es=n(88866);let ec=C.z.enum(["@slicemachine/adapter-next","@slicemachine/adapter-nuxt","@slicemachine/adapter-nuxt2","@slicemachine/adapter-sveltekit"]);async function ed(e,t,n){let i=Array(e.length),a=0,r=Array(Math.min(t,e.length)).fill(null).map(async()=>{for(;;){let t=a++;if(t>=e.length)break;i[t]=await n(e[t],t)}});return await Promise.all(r),i}class em{getHeaders(){let e={Accept:"application/vnd.github.v3+json"};return void 0!==this.token&&(e.Authorization="Bearer ".concat(this.token)),e}async request(e,t){let n="".concat(this.baseUrl).concat(e),i=await fetch(n,{...t,headers:{...this.getHeaders(),...null==t?void 0:t.headers}});if(!i.ok)throw Error("GitHub API request failed: ".concat(i.status," ").concat(i.statusText));return i.json()}async getDefaultBranch(){let e=await this.request("/repos/".concat(this.owner,"/").concat(this.repo));return C.z.object({default_branch:C.z.string()}).parse(e).default_branch}async getFileContents(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e,"?ref=").concat(t)),a=C.z.object({content:C.z.string(),encoding:C.z.string()}).parse(i);if("base64"!==a.encoding)throw Error("Unexpected encoding for ".concat(e,": ").concat(a.encoding));let r=atob(a.content.replace(/\s/g,""));if(!n)return r;{let e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e.buffer}}async getDirectoryContents(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e));return C.z.array(C.z.object({name:C.z.string(),type:C.z.string(),path:C.z.string()})).parse(t)}async searchCode(e){let{path:t,filename:n}=e,i=[];void 0!==t&&i.push("path:".concat(t)),void 0!==n&&i.push("filename:".concat(n)),i.push("repo:".concat(this.owner,"/").concat(this.repo));let a="/search/code?q=".concat(encodeURIComponent(i.join(" "))),r=await this.request(a);return C.z.object({items:C.z.array(C.z.object({path:C.z.string(),name:C.z.string()})).optional(),total_count:C.z.number().optional()}).parse(r)}async getSliceMachineConfigDetails(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/slicemachine.config.json?ref=").concat(e)),n=C.z.object({content:C.z.string().optional(),encoding:C.z.string().optional()}).parse(t);if("string"==typeof n.content){let e=atob(n.content.replace(/\s/g,""));return C.z.object({libraries:C.z.array(C.z.string()),adapter:ec}).transform(e=>({framework:$(e.adapter),libraries:e.libraries})).parse(JSON.parse(e))}throw Error("No content found in slicemachine.config.json")}constructor(e){this.baseUrl="https://api.github.com",this.owner=e.owner,this.repo=e.repo,this.token=e.token}}let eu=async e=>{let{owner:t,repo:n,token:i}=e;return new em({owner:t,repo:n,token:i}).getDefaultBranch()},eh=async e=>{let{owner:t,repo:n,branch:i,token:a}=e;return new em({owner:t,repo:n,token:a}).getSliceMachineConfigDetails(i)},ep=C.z.array(C.z.unknown().transform((e,t)=>{let n=eo.SharedSliceContent.decode(e);if("Left"===n._tag){for(let e of n.left)t.addIssue({code:C.z.ZodIssueCode.custom,message:e.message});return C.z.NEVER}return n.right})),eg=async e=>{let{owner:t,repo:n,branch:i,libraries:a,token:r}=e,l=new em({owner:t,repo:n,token:r}),o=[];for(let e of(console.log("Fetching slices from ".concat(a.length," library/libraries:"),a),a)){let t=e.replace(/^\.\//,""),n=[],a=!1;try{n=(await l.getDirectoryContents(t)).filter(e=>"dir"===e.type).map(e=>({name:e.name,path:e.path}))}catch(n){a=!0;let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub API returned 403 for ".concat(e,", trying direct discovery...")):console.warn("GitHub API error for ".concat(e,", trying direct discovery..."),t)}if(a&&0===n.length){console.log("Attempting to discover slices using GitHub Search API for ".concat(e,"..."));try{let i=await l.searchCode({path:t,filename:"model.json"});if(i.items&&i.items.length>0){let a=new Set;for(let e of i.items){let t=e.path.split("/");if(t.length>=2){let e=t[t.length-2];e&&!a.has(e)&&a.add(e)}}n=Array.from(a).map(e=>({name:e,path:"".concat(t,"/").concat(e)})),console.log("Discovered ".concat(n.length," slice(s) via GitHub Search API for library ").concat(e))}else console.warn("GitHub Search API found no model.json files in ".concat(e))}catch(n){let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub Search API also returned 403. Cannot discover slices without API access."):console.warn("Error using GitHub Search API for ".concat(e,":"),t)}}if(0===n.length){console.warn("No slices found in library ".concat(e,". The repository may be private or require authentication."));continue}console.log("Processing ".concat(n.length," slice(s) in library ").concat(e));let r=async e=>{try{let t,n,a,r;let s=await l.getFileContents("".concat(e.path,"/model.json"),i,!1);if("string"!=typeof s){console.warn("Failed to fetch model.json for slice: ".concat(e.name," - unexpected content type"));return}let c=es.SharedSlice.decode(JSON.parse(s));if("Left"===c._tag){console.warn("Failed to decode model.json for slice: ".concat(e.name));return}let d=c.right,m=[];try{m=await ef({api:l,branch:i,directoryPath:e.path}),console.log("Fetched ".concat(m.length," file(s) for slice ").concat(e.name,":"),m.map(e=>"".concat(e.path).concat(e.isBinary?" (binary)":"")))}catch(t){console.warn("Failed to fetch files for slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}for(let i of m)if(void 0===t&&i.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/)&&"string"==typeof i.contents&&(t=i.contents),"mocks.json"===i.path&&"string"==typeof i.contents)try{let t=ep.safeParse(JSON.parse(i.contents));if(t.success){let e=t.data;Array.isArray(e)&&e.length>0&&(n=e)}else console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}catch(t){console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}let u={};void 0!==d.variations&&d.variations.length>0&&(await Promise.allSettled(d.variations.map(async t=>{try{let n="".concat(e.path,"/screenshot-").concat(t.id,".png"),o=await l.getFileContents(n,i,!0);if(o instanceof ArrayBuffer){let e=new Blob([o],{type:"image/png"}),n=new File([e],"screenshot-".concat(t.id,".png"),{type:"image/png"});u[t.id]=n,void 0===a&&void 0!==d.variations[0]&&t.id===d.variations[0].id&&(a=URL.createObjectURL(e),r=n)}}catch(e){console.warn("Failed to fetch screenshot for variation ".concat(t.id,":"),e instanceof Error?e.message:String(e))}}))).forEach((e,t)=>{if("rejected"===e.status){var n;console.warn("Failed to fetch screenshot for variation ".concat(null===(n=d.variations[t])||void 0===n?void 0:n.id,":"),e.reason instanceof Error?e.reason.message:String(e.reason))}});let h=null!=r?r:new File([],"".concat(d.name,".json"),{type:"application/json"}),p={image:h,thumbnailUrl:null!=a?a:URL.createObjectURL(h),model:d,files:m,componentContents:t,mocks:n,screenshots:Object.keys(u).length>0?u:void 0};o.push(p)}catch(t){console.warn("Error fetching slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}};await ed(n,6,r)}return o},ef=async e=>{let{api:t,branch:n,directoryPath:i}=e,a=[],r=!1;try{let e=await t.getDirectoryContents(i);r=!0;let l=e.filter(e=>"file"===e.type),o=e.filter(e=>"dir"===e.type);for(let e of(await ed(l,8,async e=>{if("model.json"===e.name)return null;try{let i=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp"].some(t=>e.name.toLowerCase().endsWith(t)),a=await t.getFileContents(e.path,n,i);return{path:e.name,contents:a,isBinary:i}}catch(t){return console.warn("Failed to fetch file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))e&&a.push(e);for(let e of o)for(let i of(await ef({api:t,branch:n,directoryPath:e.path})))a.push({...i,path:"".concat(e.name,"/").concat(i.path)})}catch(e){console.warn("GitHub API failed for directory ".concat(i,", trying Search API..."),e instanceof Error?e.message:String(e))}if(!r)try{console.log("Using GitHub Search API to find all files in ".concat(i,"..."));let e=await t.searchCode({path:i});if(e.items&&e.items.length>0){for(let r of(console.log("Found ".concat(e.items.length," file(s) via Search API for ").concat(i)),await ed(e.items,8,async e=>{try{if("model.json"===e.name)return null;let a=e.path.startsWith(i+"/")?e.path.slice(i.length+1):e.name,r=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp",".woff",".woff2",".ttf",".eot",".otf",".pdf",".zip",".gz"].some(t=>e.name.toLowerCase().endsWith(t)),l=await t.getFileContents(e.path,n,r);return{path:a,contents:l,isBinary:r}}catch(t){return console.warn("Error fetching file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))r&&a.push(r);console.log("Fetched ".concat(a.length," file(s) from ").concat(i," via Search API"))}else console.warn("GitHub Search API found no files in ".concat(i))}catch(t){let e=t instanceof Error?t.message:String(t);e.includes("403")?console.warn("GitHub Search API returned 403 for ".concat(i,". Cannot fetch files without API access.")):console.warn("Error using GitHub Search API for ".concat(i,":"),e)}return a};class ex extends Error{constructor(e){super(e),this.name="GitHubImportError"}}var ey=n(62434);function eb(e){let{thumbnailUrl:t,model:n,selected:r=!0,onSelectedChange:l}=e,[o,c]=(0,s.useState)(!1),d=(0,i.jsxs)(i.Fragment,{children:[void 0!==t&&t&&!o?(0,i.jsx)(ey.ZB,{src:t,onError:()=>c(!0)}):(0,i.jsx)(ey.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",flexDirection:"column",gap:8,justifyContent:"center",children:(0,i.jsx)(a.bK,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsx)(ey.eW,{title:n.name,subtitle:n.variations.length>1?"".concat(n.variations.length," variations"):"1 variation",action:(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,i.jsx)(a.T,{checked:r,onCheckedChange:l})})})]});return(0,i.jsx)(ey.Zb,{interactive:!0,onClick:()=>{l(!r)},checked:r,size:"small","data-testid":"slice-card",children:d})}async function ej(e){let{libraries:t=[]}=await ee.managerClient.project.getSliceMachineConfig(),n=t[0];if(!n)throw Error("No library found in the config.");await ed(e,3,async e=>{let{errors:t}=await ee.managerClient.slices.createSlice({libraryID:n,model:e.model,componentContents:e.componentContents});if(t.length)throw Error("Failed to create slice ".concat(e.model.id,"."))});let i=await ed(e,3,async e=>{let{model:t,image:i,langSmithUrl:a,mocks:r,files:l,screenshots:o}=e;if(r&&Array.isArray(r)&&r.length>0){let{errors:e}=await ee.managerClient.slices.updateSliceMocks({libraryID:n,sliceID:t.id,mocks:r});e.length&&console.warn("Failed to update mocks for slice ".concat(t.id,":"),e)}return o&&Object.keys(o).length>0?await Promise.all(Object.entries(o).map(async e=>{let[i,a]=e;a.size>0&&await ee.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:i,data:a})})):i.size>0&&void 0!==t.variations&&t.variations.length>0&&await ee.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:t.variations[0].id,data:i}),console.log("About to write files for slice ".concat(t.id,":"),l?"".concat(l.length," file(s) - ").concat(l.map(e=>e.path).join(", ")):"no files"),l&&l.length>0?await ev({libraryID:n,sliceID:t.id,files:l}):console.warn("No files to write for slice ".concat(t.id,". Files:"),l),{model:t,langSmithUrl:a}});return{library:n,slices:i}}async function ev(e){let{libraryID:t,sliceID:n,files:i}=e;if(0===i.length)return;let a=i.filter(e=>"mocks.json"!==e.path&&!e.path.startsWith("screenshot-")&&!e.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/));if(console.log("Writing ".concat(a.length," additional file(s) for slice ").concat(n,":"),a.map(e=>e.path)),0!==a.length)try{let e=a.map(e=>{if(e.isBinary)return{path:e.path,contents:e.contents,isBinary:!0};if("string"==typeof e.contents)return{path:e.path,contents:e.contents,isBinary:!1};throw Error("Unexpected file contents type for ".concat(e.path))}),i=await ee.managerClient.slices.writeSliceFiles({libraryID:t,sliceID:n,files:e});i.errors.length>0?console.error("Errors writing files for slice ".concat(n,":"),i.errors.map(e=>{var t;return null!==(t=e.message)&&void 0!==t?t:String(e)})):console.log("Successfully wrote ".concat(a.length," file(s) for slice ").concat(n))}catch(e){console.error("Error writing files for slice ".concat(n,":"),e instanceof Error?e.message:String(e))}}function eS(e){let t;let{location:n,typeName:r,onSelectTab:l,onSuccess:o,selected:c}=e,[d,m]=(0,s.useState)(!1),[u,h]=(0,s.useState)([]),[p,y]=(0,s.useState)(),{integrations:j,fetchedSlices:v,isImportingSlices:S,fetchSlicesFromGithub:w,resetImportedSlices:C}=function(){var e;let[t,n]=(0,s.useState)(!1),[i,a]=(0,s.useState)([]),{data:r}=(0,V.k)({queryKey:["getIntegrations"],queryFn:()=>ee.managerClient.prismicRepository.fetchGitIntegrations()}),{mutateAsync:l}=(0,el.D)({mutationFn:e=>ee.managerClient.prismicRepository.fetchGitIntegrationToken({integrationId:e.integrationId})}),o=()=>{a([]),n(!1)},c=async e=>{let{repository:t,targetFramework:i}=e;try{let r;o(),n(!0),f.Xe.track({event:"slice-library:fetching-started",source_project_id:t.fullName});let{token:s}=await l({integrationId:t.integrationId}),[c,d]=e.repository.fullName.split("/");if(!c||!d)throw new ex("Invalid GitHub URL format");let m=await eu({owner:c,repo:d,token:s});try{let e=await eh({owner:c,repo:d,branch:m,token:s});if(e.framework!==i)throw new ex("Incompatible project framework.");r=e.libraries}catch(e){throw new ex("\n Failed to fetch slicemachine.config.json: ".concat(e instanceof Error?e.message:"Unknown error","\n "))}if(0===r.length)throw new ex("No libraries were found in the SM config.");let u=await eg({owner:c,repo:d,branch:m,libraries:r,token:s});if(0===u.length)throw new ex("No slices were found in the libraries.");return a(u),M.Am.success("Found ".concat(u.length," slice(s) from ").concat(r.length," library/libraries")),f.Xe.track({event:"slice-library:fetching-ended",error:!1,slices_count:u.length,source_project_id:t.fullName}),u}catch(e){return e instanceof ex?M.Am.error(e.message):M.Am.error("Failed to import from GitHub: ".concat(e instanceof Error?e.message:"Unknown error")),f.Xe.track({event:"slice-library:fetching-ended",error:!0,source_project_id:t.fullName}),[]}finally{n(!1)}};return{integrations:null!==(e=r.integrations)&&void 0!==e?e:[],fetchedSlices:null!=i?i:[],isImportingSlices:t,resetImportedSlices:o,fetchSlicesFromGithub:c}}(),I=(0,b.Z)(),{syncChanges:k}=(0,x.g)(),{completeStep:T}=(0,Q.k)(),D=function(){let e=(0,J.U)(),{data:t}=(0,V.k)({queryKey:["getFrameworkFromAdapterName"],queryFn:async()=>$(ec.parse(await ee.managerClient.project.getAdapterName()))});return{...e,framework:t}}();(0,s.useEffect)(()=>{c&&f.Xe.track({event:"slice-library:opened"})},[c]),(0,g.Nr)(u,1e3,()=>{p&&u.length>0&&f.Xe.track({event:"slice-library:slice-selected",slices_count:u.length,source_project_id:p.fullName,destination_project_id:D.repositoryName})});let _=e=>{h(t=>t.some(t=>t.model.id===e.model.id)?t.filter(t=>t.model.id!==e.model.id):[...t,e])},A=async()=>{if(0===u.length){M.Am.error("Please select at least one slice");return}if(!p){M.Am.error("Please select a repository");return}try{m(!0),f.Xe.track({event:"slice-library:import-started",source_project_id:p.fullName});let e=u.map(e=>({image:e.image,model:e.model,files:e.files,componentContents:e.componentContents,mocks:e.mocks,screenshots:e.screenshots})),t=[],i=await ee.managerClient.slices.readAllSlices().then(e=>e.models.map(e=>{let{model:t}=e;return t}));for(let n of e){let e=function(e){let{existingSlices:t,newSlices:n,slice:i}=e,a=new Set,r=new Set;for(let{id:e,name:n}of t)a.add(e),r.add(n.toLowerCase());for(let e of n)a.add(e.model.id),r.add(e.model.name.toLowerCase());let l=i.id,o=2;for(;a.has(l);)l="".concat(i.id,"_").concat(o),o++;let s=i.name;for(o=2;r.has(s.toLowerCase());)s="".concat(i.name).concat(o),o++;return{...i,id:l,name:s}}({existingSlices:i,newSlices:t,slice:n.model});t.push({...n,model:e})}let{slices:a,library:r}=await ej(t);await new Promise(e=>setTimeout(e,100));let l=await (0,f.y0)();for(let e of(I.createSliceSuccess(l.libraries),t))e.mocks&&Array.isArray(e.mocks)&&e.mocks.length>0&&I.updateSliceMockSuccess({libraryID:r,sliceID:e.model.id,mocks:e.mocks});for(let{model:e}of(k(),m(!1),C(),T("createSlice"),a))f.Xe.track({event:"slice:created",id:e.id,name:e.name,library:r,location:n,mode:"import"});f.Xe.track({event:"slice-library:import-ended",error:!1,slices_count:a.length,source_project_id:p.fullName,destination_project_id:D.repositoryName}),o({slices:a,library:r})}catch(e){m(!1),M.Am.error("An unexpected error happened while adding slices."),f.Xe.track({event:"slice-library:import-ended",error:!0,source_project_id:p.fullName,destination_project_id:D.repositoryName})}},N=new URL("builder/settings/git-integration",D.repositoryUrl).toString();if(S)t=(0,i.jsx)(eI,{});else if(0===j.length)t=(0,i.jsx)(er,{title:"GitHub connection required",description:"Connect your GitHub account to access\nrepositories and set a library for this project.",icon:"github",actions:(0,i.jsx)(a.E,{size:"medium",color:"grey",startIcon:"github",asChild:!0,children:(0,i.jsx)("a",{href:N,target:"_blank",children:"Connect GitHub"})})});else if(p){if(0===v.length)t=(0,i.jsx)(er,{title:"No slices found",description:"This repository doesn't contain any Slice components\ncompatible with your project.",icon:"viewDay"});else{let e=v.every(e=>u.some(t=>t.model.id===e.model.id)),n=v.some(e=>u.some(t=>t.model.id===e.model.id)),l="Select all slices";e?l="Selected all slices (".concat(u.length,")"):n&&(l="".concat(u.length," of ").concat(v.length," selected")),t=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.D,{flexDirection:"column",flexGrow:1,minHeight:0,children:[(0,i.jsx)(a.D,{padding:{block:12,inline:16},alignItems:"center",gap:8,children:(0,i.jsx)(a.aQ,{value:l,children:(0,i.jsx)(a.T,{checked:e,indeterminate:n&&!e,onCheckedChange:e=>{h(e?v:[])}})})}),(0,i.jsx)(a.bm,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{inline:16,bottom:16},children:v.map(e=>(0,i.jsx)(eb,{model:e.model,thumbnailUrl:e.thumbnailUrl,selected:u.some(t=>t.model.id===e.model.id),onSelectedChange:()=>_(e)},e.model.id))})})]}),(0,i.jsx)(en,{totalSelected:u.length,onSubmit:()=>void A(),isSubmitting:d,typeName:r})]})}}else t=(0,i.jsx)(er,{title:"No repository selected",description:"Choose a GitHub repository from the menu above.",icon:"alert"});return(0,i.jsxs)(ei,{selected:c,children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:l,rightContent:(0,i.jsx)(ew,{integrations:j,selectedRepository:p,onSelectRepository:e=>{y(e),h([]),w({repository:e,targetFramework:D.framework})},configureUrl:N,isTabSelected:c})}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:t})]})}function ew(e){let{integrations:t,selectedRepository:n,onSelectRepository:r,configureUrl:l,isTabSelected:o}=e,[c,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(""),h=e=>{r(e),d(!1)},p=(0,s.useMemo)(()=>t.flatMap(e=>e.repositories.map(t=>({...t,integrationId:e.id}))),[t]);(0,g.Ng)(()=>{o&&p.length>0&&(1===p.length&&r(p[0]),f.Xe.track({event:"slice-library:projects-listed",repositories_count:p.length}))},[o,p]);let x=p.filter(e=>e.fullName.toLowerCase().includes(m.toLowerCase()));return(0,i.jsxs)(a.aq,{open:c,onOpenChange:d,children:[(0,i.jsx)(a.au,{disabled:0===t.length,children:(0,i.jsx)(a.E,{endIcon:"arrowDropDown",textWeight:"normal",sx:{width:420},startIcon:"github",color:"grey",size:"large",flexContent:!0,children:n?n.fullName:"Select a GitHub repository"})}),(0,i.jsx)(a.ar,{align:"start",border:!1,minWidth:"full-trigger-width",childrenFocusScope:!0,children:(0,i.jsxs)(a.Y,{variant:"attached",children:[(0,i.jsx)(a.$,{value:m,onValueChange:u,placeholder:"Search",endAdornment:!0}),(0,i.jsxs)(a._,{children:[x.length>0?(0,i.jsx)(i.Fragment,{children:x.map(e=>(0,i.jsx)(a.a0,{value:e.fullName,onCheckedChange:()=>h(e),checked:(null==n?void 0:n.fullName)===e.fullName,children:(0,i.jsx)(eC,{children:e.fullName})},e.fullName))}):(0,i.jsx)(a.a0,{value:"none",disabled:!0,children:(0,i.jsx)(eC,{disabled:!0,children:(0,i.jsx)(a.D,{padding:8,children:"No repositories found"})})}),(0,i.jsx)(a.Z,{children:(0,i.jsx)(a.E,{textWeight:"normal",size:"medium",color:"dark",renderEndIcon:()=>(0,i.jsx)(a.aW,{name:"openInNew",size:"small"}),flexContent:!0,asChild:!0,invisible:!0,children:(0,i.jsx)("a",{href:l,target:"_blank",children:"Configure Repositories on Prismic"})})})]})]})})]})}function eC(e){let{children:t,disabled:n}=e;return(0,i.jsx)(a.D,{padding:{inline:8,block:4},children:(0,i.jsx)(a.bK,{variant:"normal",color:!0===n?"grey9":"grey12",children:t})})}function eI(){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.D,{flexGrow:1,minHeight:0,flexDirection:"column",padding:{inline:16,top:16},gap:16,children:[(0,i.jsx)(a.bw,{height:24,width:125}),(0,i.jsx)(a.D,{flexGrow:1,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{bottom:16},overflow:"hidden",children:Array.from({length:9}).map((e,t)=>(0,i.jsx)(a.bw,{height:240,width:"100%"},t))})]}),(0,i.jsx)(et,{})]})}function ek(e){let{openLoginModal:t}=(0,b.Z)(),n=(0,Y.NL)(),{data:r}=(0,V.k)({queryKey:["checkIsLoggedIn"],queryFn:()=>ee.managerClient.user.checkIsLoggedIn(),gcTime:0,staleTime:0});return r?(0,i.jsx)(eS,{...e}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab}),(0,i.jsx)(er,{title:"You are logged out",description:"This action requires you to be logged in.\nPlease log in to continue.",icon:"logout",actions:(0,i.jsx)(a.E,{size:"small",color:"grey",onClick:()=>{e.onClose(),t(),n.invalidateQueries({queryKey:["checkIsLoggedIn"]})},children:"Log in"})})]})}function eT(e){return(0,i.jsx)(ei,{selected:e.selected,children:(0,i.jsx)(a.ax,{renderError:()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab}),(0,i.jsx)(er,{title:"Failed to load library slices",icon:"alert",color:"tomato"})]}),children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{selectedTab:"library",onSelectTab:e.onSelectTab,rightContent:(0,i.jsx)(a.bw,{height:40,width:420})}),(0,i.jsx)(eI,{})]}),children:(0,i.jsx)(ek,{...e})})})})}function eD(e){let{typeName:t,onSelectTab:n,onSuccess:r,slices:l,isEveryLocalSliceAdded:o,selected:c}=e,[d,m]=(0,s.useState)([]),u=e=>{m(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])};return(0,i.jsxs)(ei,{selected:c,children:[(0,i.jsx)(ea,{selectedTab:"local",onSelectTab:n}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:l.length>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.bm,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,flexGrow:1,padding:16,minHeight:0,children:l.map(e=>{let t=d.some(t=>t.id===e.id);return(0,i.jsx)(eb,{model:e,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>u(e)},e.name)})})}),(0,i.jsx)(en,{totalSelected:d.length,onSubmit:()=>{if(0===d.length){M.Am.error("Please select at least one slice");return}r({slices:d.map(e=>({model:e}))})},typeName:t})]}):(0,i.jsx)(er,{title:"No local slices available",description:o?"All local slices have already been added to your slice zone.":void 0,icon:"alert"})})]})}function e_(e){let{open:t,localSlices:n,isEveryLocalSliceAdded:r,onClose:l,...o}=e,[c,d]=(0,s.useState)("local");return(0,s.useEffect)(()=>{if(!t){let e=setTimeout(()=>{d("local")},250);return()=>clearTimeout(e)}},[t]),(0,i.jsxs)(a.ad,{open:t,onOpenChange:e=>!e&&l(),children:[(0,i.jsx)(a.ak,{title:"Reuse an existing slice"}),(0,i.jsxs)(a.ai,{gap:0,children:[(0,i.jsx)(a.aj,{hidden:!0,children:"Select existing slices or import slices from a GitHub repository"}),(0,i.jsx)(eD,{...o,selected:"local"===c,onSelectTab:d,slices:n,isEveryLocalSliceAdded:r,onClose:l}),(0,i.jsx)(eT,{...o,selected:"library"===c,onSelectTab:d,onClose:l})]})]})}var eA=n(27213);let eN=e=>{let{openCreateSliceModal:t,openCreateSliceFromImageModal:n,openUpdateSliceZoneModal:r,openSlicesTemplatesModal:l,isSlicesTemplatesSupported:o}=e,s=(0,eA.F)({menuType:"ActionList"});return(0,i.jsxs)(a.s,{"data-testid":"slice-zone-blank-slate",sx:{width:648},children:[(0,i.jsx)(a.x,{lineColor:"purple9",backgroundColor:"purple5",name:"add",size:"large"}),(0,i.jsx)(a.z,{size:"big",children:"Add slices"}),(0,i.jsx)(a.w,{children:"Slices are reusable website sections. You can use them on different pages and write unique content for each. Each slice has its own component in your code."}),(0,i.jsx)(a.v,{children:(0,i.jsxs)(a.A,{children:[(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromImage.BackgroundIcon,onClick:n,description:s.fromImage.description,children:s.fromImage.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromScratch.BackgroundIcon,onClick:t,description:s.fromScratch.description,children:s.fromScratch.title}),o&&(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromTemplate.BackgroundIcon,onClick:l,description:s.fromTemplate.description,children:s.fromTemplate.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromExisting.BackgroundIcon,onClick:r,description:s.fromExisting.description,children:s.fromExisting.title})]})})]})};function eE(e){let{customType:t,tabId:n,slices:i}=e,a={...t};return i.forEach(e=>{a={...a,tabs:a.tabs.map(t=>t.key===n&&t.sliceZone?{...t,sliceZone:{key:t.sliceZone.key,value:[{key:e.id,value:e},...t.sliceZone.value]}}:t)}}),f.Xe.track({event:"custom-type:slice-zone-updated",customTypeId:t.id}),a}var ez=n(18566);async function eF(){try{let{templates:e,errors:t}=await ee.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,n]=e;return[t,URL.createObjectURL(n)]}))}))}catch(e){return[]}}var eP=n(6256),eL=n(39204),eM=n(26109),eK=n(7723),eO=n(33986),eZ=n(30527),eU=n(55862);let eG=e=>{let{deleteSliceZone:t,closeDeleteSliceZoneModal:n}=e;return(0,i.jsx)(eU.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:n,children:(0,i.jsx)(eZ.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,i.jsxs)(N.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,i.jsx)(N.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:"Do you really want to delete Slice Zone?"}),(0,i.jsx)(N.x8,{type:"button",onClick:n})]}),Footer:()=>(0,i.jsxs)(N.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,i.jsx)(eO.z,{label:"Cancel",variant:"secondary",onClick:n,sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),(0,i.jsx)(eO.z,{label:"Delete",variant:"danger",onClick:t,sx:{minHeight:39,minWidth:78}})]}),children:(0,i.jsx)(N.nv,{children:"You're about to delete Slice Zone."})})})};var eB=n(84879),eH=n(63908),eR=n(63019),eq=n(65375),eW=n.n(eq);let eX=e=>{var t;let{isOpen:n,close:r,onSubmit:l,isLoading:o,slice:d,libraries:m}=e,{remoteSlices:u}=(0,c.v9)(e=>({remoteSlices:(0,eK.sT)(e)})),h={from:null===(t=m[0])||void 0===t?void 0:t.name,sliceName:(0,G.MP)(d.key)},[p,f]=(0,s.useState)(h),[x,y]=(0,s.useState)();function b(e){f(e),y((0,eR.h)(e,m,u))}return(0,g.pQ)(n,()=>{n||(f(h),y(void 0))}),(0,i.jsxs)(a.ad,{open:n,onOpenChange:e=>!e&&r(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Upgrade slice"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){x&&Object.keys(x).length>0||l({libraryID:p.from,sliceID:p.sliceName})},children:(0,i.jsxs)(a.D,{flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{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,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"This will not migrate your component. You will need to do that manually."}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)(a.aL,{label:"Slice name *",placeholder:"Pascalised Slice API ID (e.g. ".concat((0,G.MP)(d.key),")"),error:null==x?void 0:x.sliceName,value:p.sliceName,onValueChange:e=>b({...p,sliceName:e.slice(0,30)}),"data-testid":"slice-name-input"}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"A display name for the slice"})]}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)("label",{className:eW().label,children:(0,i.jsx)(a.bK,{variant:"bold",children:"Slice library *"})}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"folder",flexContent:!0,value:p.from,onValueChange:e=>{e&&b({...p,from:e})},children:m.map(e=>(0,i.jsx)(a.bs,{value:e.name,children:e.name},e.name))}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"The library where we'll store your slice"})]})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:o,disabled:x&&Object.keys(x).length>0,children:"Upgrade"})]})]})})})]})};var eV=n(96009),eY=n.n(eV);let e$=e=>{var t,n;let{isOpen:r,close:l,onSubmit:o,isLoading:c,slice:d,sliceName:m,libraries:u,localSharedSlices:h}=e,p={libraryID:null===(t=h[0])||void 0===t?void 0:t.from,sliceID:null===(n=h[0])||void 0===n?void 0:n.model.id,variationID:eY()(d.key),variationName:m},[f,x]=(0,s.useState)(!0),[y,b]=(0,s.useState)(p),[j,v]=(0,s.useState)({});function S(e){b(e),v(eQ(e,u))}return(0,g.pQ)(r,()=>{r||(b(p),v({}))}),(0,i.jsxs)(a.ad,{open:r,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Convert to slice variation"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){Object.keys(j).length>0||o(y)},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"If you have multiple slices that are similar, you can combine them as variations of the same slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eW().label,children:[(0,i.jsx)(a.bK,{variant:"bold",children:"Target slice *"}),"string"==typeof j.libraryID?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:j.libraryID}):null,"string"==typeof j.sliceID?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:j.sliceID}):null]}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:"".concat(y.libraryID,"::").concat(y.sliceID),onValueChange:e=>{if(e){let[t,n]=e.split("::");S({...y,libraryID:t,sliceID:n})}},children:h.map(e=>(0,i.jsxs)(a.bs,{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,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"Choose the slice to which you would like to add this variation."})]}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aL,{label:"Variation name *",placeholder:m,error:j.variationName,value:y.variationName,onValueChange:e=>{let t={...y,variationName:e.slice(0,30)};f&&(t.variationID=eY()(t.variationName)),S(t)},"data-testid":"variation-name-input"})}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aL,{label:"ID *",placeholder:eY()(d.key),error:j.variationID,value:y.variationID,onValueChange:e=>{x(!1),S({...y,variationID:e.slice(0,30)})},"data-testid":"variation-id-input"})})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:c,disabled:Object.keys(j).length>0,children:"Convert"})]})]})})})]})},eQ=(e,t)=>{let n={};e.libraryID||(n.libraryID="Cannot be empty.");let i=t.find(t=>t.path===e.libraryID);n.libraryID||i||(n.libraryID="Does not exist."),e.sliceID||(n.sliceID="Cannot be empty.");let a=null==i?void 0:i.components.find(t=>t.model.id===e.sliceID);if(n.sliceID||a||(n.sliceID="Does not exist."),e.variationName||(n.variationName="Cannot be empty."),e.variationID){var r;(null!==(r=null==a?void 0:a.model.variations.map(e=>e.id))&&void 0!==r?r:[]).includes(e.variationID)&&(n.variationID="Slice variation ID is already taken.")}else n.variationID="Cannot be empty.";return n},eJ=e=>{var t,n;let{isOpen:r,close:l,onSubmit:o,isLoading:c,identicalSlices:d}=e,m=null!==(n=null===(t=d[0])||void 0===t?void 0:t.path)&&void 0!==n?n:"",[u,h]=(0,s.useState)(m),[p,f]=(0,s.useState)();return(0,g.pQ)(r,()=>{r||(h(m),f(void 0))}),(0,i.jsxs)(a.ad,{open:r,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.ak,{title:"Merge with an existing slice"}),(0,i.jsx)(a.ai,{children:(0,i.jsx)(a.aI,{onSubmit:function(){if(p)return;let[e,t,n]=u.split("::");o({libraryID:e,sliceID:t,variationID:n})},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bm,{className:eW().scrollArea,children:[(0,i.jsx)(a.bK,{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,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eW().label,children:[(0,i.jsx)(a.bK,{variant:"bold",children:"Target slice*"}),"string"==typeof p?(0,i.jsx)(a.bK,{variant:"small",color:"tomato10",children:p}):null]}),(0,i.jsx)(a.bp,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:u,onValueChange:function(e){h(e),e||f("Cannot be empty.")},children:d.map(e=>(0,i.jsx)(a.bs,{value:e.path,children:e.path.split("::").join(" > ")},e.path))}),(0,i.jsx)(a.bK,{variant:"normal",color:"grey11",children:"Choose a slice that you would like to merge this into."})]})]}),(0,i.jsxs)(a.ag,{children:[(0,i.jsx)(a.ah,{size:"medium"}),(0,i.jsx)(a.ae,{type:"submit",size:"medium",loading:c,disabled:!!p,children:"Merge"})]})]})})})]})},e0=e=>{var t;let{slice:n,path:r}=e,{refreshState:l}=(0,b.Z)(),[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(),{setCustomType:h}=w(),{libraries:p}=(0,c.v9)(e=>({libraries:(0,eK.Sd)(e)})),g="Slice"===n.value.type&&null!==(t=n.value.fieldset)&&void 0!==t?t:n.key,x=p.filter(e=>e.isLocal),y=x.map(e=>e.components).flat(),j=e1(n,g,y),v=async e=>{var t,i,a;if(!m)return;d(!0),f.Xe.track({event:"legacy-slice:converted",id:e.sliceID,variation:null!==(t=e.variationID)&&void 0!==t?t:"default",library:e.libraryID,conversionType:m});let{errors:o}=await ee.managerClient.slices.convertLegacySliceToSharedSlice({model:n.value,src:{...r,sliceID:n.key},dest:{libraryID:e.libraryID,sliceID:e.sliceID,variationName:null!==(i=e.variationName)&&void 0!==i?i:"Default",variationID:null!==(a=e.variationID)&&void 0!==a?a:"default"}});if(o.length)throw console.error("Could not convert slice `".concat(g,"`"),o),M.Am.error("Could not convert slice `".concat(g,"`")),o;let{model:s,errors:c}=await ee.managerClient.customTypes.readCustomType({id:r.customTypeID});if(c.length||!s){console.error("Could not refresh custom type view `".concat(r.customTypeID,"`"),c),M.Am.error("Could not refresh custom type view `".concat(r.customTypeID,"`"));return}switch(l(await (0,f.y0)()),d(!1),u(void 0),m){case"as_new_slice":M.Am.success("".concat(g," has been upgraded to a new slice ").concat(e.libraryID," > ").concat(e.sliceID));break;case"as_new_variation":M.Am.success("".concat(g," has been converted as a variation of ").concat(e.libraryID," > ").concat(e.sliceID));break;default:M.Am.success("".concat(g," has been merged with ").concat(e.libraryID," > ").concat(e.sliceID))}h({customType:s})},S={path:r,slice:n,sliceName:g,libraries:x,localSharedSlices:y,identicalSlices:j,close:()=>u(void 0),onSubmit:v,isLoading:o};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.aq,{children:[(0,i.jsx)(a.au,{children:(0,i.jsx)(a.E,{"data-testid":"convert-legacy-slice",startIcon:"refresh",endIcon:"arrowDropDown",size:"medium",color:"grey",children:"Migrate legacy slice"})}),(0,i.jsxs)(a.ar,{align:"start",children:[(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"folder",size:"large"}),description:"Use it with new types",onSelect:()=>u("as_new_slice"),children:"Upgrade slice"}),(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"viewDay",size:"large"}),description:"Add it to another slice",onSelect:()=>u("as_new_variation"),disabled:!y.length,children:"Convert to slice variation"}),(0,i.jsx)(a.as,{startIcon:(0,i.jsx)(a.aW,{name:"driveFileMove",size:"large"}),description:"Combine identical slices",onSelect:()=>u("merge_with_identical"),disabled:!j.length,children:"Merge with another slice"})]})]}),(0,i.jsx)(eX,{...S,isOpen:"as_new_slice"===m}),(0,i.jsx)(e$,{...S,isOpen:"as_new_variation"===m}),(0,i.jsx)(eJ,{...S,isOpen:"merge_with_identical"===m})]})},e1=(e,t,n)=>(0,s.useMemo)(()=>{let i=[],a=(0,eH.ux)(e.value,t);for(let e of n)for(let t of e.model.variations){let n=(0,eH.ux)(t,e.model.name);a.primary===n.primary&&a.items===n.items&&i.push({libraryID:e.from,sliceID:e.model.id,variationID:t.id,path:"".concat(e.from,"::").concat(e.model.id,"::").concat(t.id)})}return i},[e,t,n]),e4=e=>{let{slice:t,path:n}=e,[r]=(0,eB.E)("legacySliceUpgrader"),l=r.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,i.jsxs)(ey.Zb,{children:[(0,i.jsx)(ey.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(a.bK,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsxs)(ey.T$,{children:[(0,i.jsx)(a.c2,{content:l,side:"bottom",children:(0,i.jsx)(a.m,{color:"purple",title:"Legacy Slice"})}),r.enabled?(0,i.jsx)(e0,{slice:t,path:n}):null]}),(0,i.jsx)(ey.eW,{subtitle:"1 variation",title:(0,eH.Dj)(t.value)})]})};var e6=n(51507),e2=n(21151);let e8=e=>{let{slices:t,format:n,path:a,onRemoveSharedSlice:r}=e,l=t.some(e=>"SharedSlice"!==e.type),o=j.$[n],[c]=(0,eB.E)("legacySliceUpgrader");return(0,s.useEffect)(()=>{l&&(c.enabled?M.Am.info("This ".concat(o.name({start:!1,plural:!1})," contains legacy slices that can be upgraded.")):M.Am.warning("This ".concat(o.name({start:!1,plural:!1})," contains slices that are incompatible.")))},[l]),(0,i.jsx)(e2.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,i.jsx)(e4,{slice:t,path:a})}{let t=e.payload;return(0,i.jsx)(e6.b,{action:{type:"remove",onRemove:()=>{r(t.model.id)}},mode:"navigation",slice:t,variant:"solid"})}},sx:{padding:"16px"}})};async function e3(e){try{let{templateIDs:t,localLibrariesNames:n,location:i,onSuccess:a}=e,{data:r,errors:l}=await ee.managerClient.sliceTemplateLibrary.createSlices({templateIDs:t});if(l.length>0||void 0===r)throw l;r.sliceIDs.forEach((e,a)=>{f.Xe.track({event:"slice:created",id:e,name:e,library:n[0],location:i,mode:"template",sliceTemplate:t[a]})}),await a(r.sliceIDs)}catch(t){let e="Internal Error: Slice(s) not created";console.error(e,t),M.Am.error(e)}}var e5=e=>{let{availableSlices:t,values:n}=e;return(0,i.jsx)(A.F2,{name:"sliceKeys",render:e=>(0,i.jsx)(e2.Z,{gridTemplateMinPx:"200px",elems:t,defineElementKey:e=>"".concat(e.from,"-").concat(e.model.name),renderElem:t=>{let a=n.sliceKeys.includes(t.model.id);return(0,i.jsx)(e6.b,{action:{type:"checkbox"},mode:"selection",onSelectedChange:i=>{i?e.push(t.model.id):e.remove(n.sliceKeys.indexOf(t.model.id))},selected:a,slice:t,variant:"outlined"})}})})};let e9=e=>{let{formId:t,close:n,onSuccess:a,availableSlicesTemplates:r,localLibraries:l,location:o}=e,{createSliceSuccess:s}=(0,b.Z)();return(0,i.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:n,onSubmit:e=>{let{sliceKeys:t}=e;e3({templateIDs:t,localLibrariesNames:l.map(e=>e.name),location:o,onSuccess:async e=>{s((await (0,f.y0)()).libraries),a(await Promise.all(e.map(async e=>(await ee.managerClient.slices.readSlice({libraryID:l[0].name,sliceID:e})).model).filter(e=>void 0!==e)))}})},initialValues:{sliceKeys:[]},content:{title:"Use template slices"},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,i.jsx)(N.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,i.jsx)(e5,{values:t,availableSlices:r.map(e=>({extension:"",fileName:"",from:"",href:"",pathToSlice:"",model:eM.id.toSM(e.model),screenshots:Object.entries(e.screenshots).reduce((e,t)=>({...e,[t[0]]:{url:t[1]}}),{})}))})}})},e7=(e,t)=>{let n=(t||[]).reduce((e,t)=>[...e,...t.components],[]),{slicesInSliceZone:i,notFound:a}=e.value.reduce((e,t)=>{let{key:i,value:a}=t;if("SharedSlice"===a.type){let t=n.find(e=>e.model.id===i);return t?{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"SharedSlice",payload:t}]}:{...e,notFound:[...e.notFound,{key:i}]}}return{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"Slice",payload:{key:i,value:a}}]}},{slicesInSliceZone:[],notFound:[]});return{availableSlices:n,slicesInSliceZone:i,notFound:a}};var te=e=>{var t,n;let{customType:r,onCreateSliceZone:l,onDeleteSliceZone:o,onRemoveSharedSlice:d,sliceZone:m,tabId:u}=e,h=(0,ez.QT)(eF,[]),[p,g]=(0,s.useState)(!1),[x,y]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),{remoteSlices:I,libraries:k}=(0,c.v9)(e=>({remoteSlices:(0,eK.sT)(e),libraries:(0,eK.Sd)(e),slices:(0,eK.xC)(e)})),{setCustomType:T}=w(),{completeStep:_}=(0,Q.k)(),{openLoginModal:A}=(0,b.Z)(),N=(0,eA.F)({menuType:"Dropdown"}),E=k.filter(e=>e.isLocal),{availableSlices:z,slicesInSliceZone:F,notFound:P}=(0,s.useMemo)(()=>m?e7(m,k):{availableSlices:[],slicesInSliceZone:[],notFound:[]},[m,k]),[L,O]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(null==P?void 0:P.length)&&P.forEach(e=>{let{key:t}=e;d(t)})},[P]);let Z=F.filter(e=>"SharedSlice"===e.type).map(e=>e.payload),U=z.filter(e=>!Z.some(t=>t.model.id===e.model.id)),G=()=>{y(!0)},B=()=>{v(!0)},H=async()=>{await ee.managerClient.user.checkIsLoggedIn()?C(!0):A()},R=()=>{g(!0),f.Xe.track({event:"custom-type:open-add-from-templates",customTypeId:r.id,customTypeFormat:r.format})},q=()=>{y(!1)},V=()=>{v(!1)},Y=()=>{C(!1)},$=()=>{g(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(K.Bu,{actions:m?(0,i.jsxs)(a.aq,{children:[(0,i.jsx)(a.au,{children:(0,i.jsx)(a.E,{color:"purple",startIcon:"add","data-testid":"add-new-slice-dropdown",children:"Add"})}),(0,i.jsxs)(a.ar,{align:"end",children:[(0,i.jsx)(a.as,{renderStartIcon:()=>N.fromImage.BackgroundIcon,onSelect:()=>void H(),description:N.fromImage.description,children:N.fromImage.title}),(0,i.jsx)(a.as,{renderStartIcon:()=>N.fromScratch.BackgroundIcon,onSelect:B,description:N.fromScratch.description,children:N.fromScratch.title}),h.length>0?(0,i.jsx)(a.as,{onSelect:R,renderStartIcon:()=>N.fromTemplate.BackgroundIcon,description:N.fromTemplate.description,children:N.fromTemplate.title}):void 0,(0,i.jsx)(a.as,{onSelect:G,renderStartIcon:()=>N.fromExisting.BackgroundIcon,description:N.fromExisting.description,children:N.fromExisting.title})]})]}):void 0,toggle:"page"!==r.format||"Main"!==u?(0,i.jsx)(a.bB,{checked:!!m,onCheckedChange:e=>{e?l():O(!0)},size:"small","data-testid":"slice-zone-switch"}):void 0,children:"Slices"}),m?F.length>0?(0,i.jsx)(W.xR,{children:(0,i.jsx)(e8,{slices:F,format:r.format,path:{customTypeID:r.id,tabID:u,sliceZoneID:null!==(t=null==m?void 0:m.key)&&void 0!==t?t:""},onRemoveSharedSlice:d})}):(0,i.jsx)(a.D,{flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center",padding:{block:32},children:(0,i.jsx)(eN,{openUpdateSliceZoneModal:G,openCreateSliceModal:B,openCreateSliceFromImageModal:()=>void H(),openSlicesTemplatesModal:R,projectHasAvailableSlices:U.length>0,isSlicesTemplatesSupported:h.length>0})}):void 0,(0,i.jsx)(e_,{open:x,location:"".concat(r.format,"_type"),typeName:null!==(n=r.label)&&void 0!==n?n:r.id,localSlices:U.map(e=>{var t;return{...eM.id.fromSM(e.model),thumbnailUrl:"default"in e.screenshots?e.screenshots.default.url:null===(t=Object.values(e.screenshots)[0])||void 0===t?void 0:t.url}}),isEveryLocalSliceAdded:z.length>0&&0===U.length,onSuccess:e=>{let{slices:t}=e,n=eE({customType:r,tabId:u,slices:t.map(e=>e.model)});T({customType:D.Dc.fromSM(n),onSaveCallback:()=>{M.Am.success("Slices successfully added")}}),_("createSlice"),q()},onClose:q}),p&&(0,i.jsx)(e9,{formId:"tab-slicezone-form-".concat(u),availableSlicesTemplates:h,localLibraries:E,location:"".concat(r.format,"_type"),onSuccess:e=>{let t=eE({customType:r,tabId:u,slices:e});T({customType:D.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"Slice template(s) added to slice zone and created at: ",path:"".concat(E[0].name,"/")}))}}),_("createSlice"),$()},close:$}),L&&(0,i.jsx)(eG,{closeDeleteSliceZoneModal:()=>{O(!1)},deleteSliceZone:()=>{o(),O(!1)}}),(null==E?void 0:E.length)!==0&&j&&(0,i.jsx)(eP.c,{onSuccess:e=>{let t=eE({customType:r,tabId:u,slices:[e]});T({customType:D.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"New slice added to slice zone and created at: ",path:"".concat(E[0].name,"/")}))}}),V()},localLibraries:E,location:"".concat(r.format,"_type"),remoteSlices:I,onClose:V}),(0,i.jsx)(X.S,{open:S,location:"".concat(r.format,"_type"),onSuccess:e=>{let{slices:t,library:n}=e,a=eE({customType:r,tabId:u,slices:t});T({customType:D.Dc.fromSM(a),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eL.GX,{message:"Slice(s) added to slice zone and created at: ",path:n}))}}),Y()},onClose:Y})]})};let tt=[Z.C.UID,Z.C.Image,Z.C.Text,Z.C.StructuredText,Z.C.Link,Z.C.Select,Z.C.Boolean,Z.C.Number,Z.C.Color,Z.C.Date,Z.C.Table,Z.C.Embed,Z.C.Timestamp,Z.C.GeoPoint,Z.C.ContentRelationship,Z.C.LinkToMedia,Z.C.Group,Z.C.NestedGroup];var tn=e=>{var t,n,r,l;let{tabId:o}=e,{customType:c,setCustomType:d}=w(),u=D.Dc.toSM(c),h=null===(t=u.tabs.find(e=>e.key===o))||void 0===t?void 0:t.sliceZone,p=null!==(r=null===(n=u.tabs.find(e=>e.key===o))||void 0===n?void 0:n.value)&&void 0!==r?r:[],g="page"===u.format&&u.repeatable?p.filter(e=>"uid"!==e.key):p,f=u.tabs.reduce((e,t)=>[...e,...t.value],[]),x=e=>{var t;let{apiId:n,value:i}=e,a=null===(t=i.config)||void 0===t?void 0:t.label;if((0,U.Ss)(Z.C,i.type)||null==a)return;if("Range"===i.type||"IntegrationFields"===i.type||"Separator"===i.type)throw Error("Unsupported Field Type: ".concat(i.type));let r=Z.C[i.type];try{r.schema.validateSync(i,{stripUnknown:!1})}catch(e){throw Error('Add field: Model is invalid for field "'.concat(i.type,'".'))}let l=D.L$.fromSM(i);d({customType:(0,m.xS)({customType:c,newField:l,newFieldId:n,sectionId:o}),onSaveCallback:()=>{M.Am.success("".concat("Group"===i.type?"Group":"Field"," added"))}}),(0,B.V)({id:n,field:l})},y=e=>{let{apiId:t,newKey:n,value:i,inGroupFieldAction:a,updateMeta:r}=e;if((0,U.Ss)(Z.C,i.type))return;let l=D.L$.fromSM(i);d({customType:(0,m.L4)({customType:c,previousFieldId:t,newFieldId:n,newField:l,sectionId:o}),onSaveCallback:()=>{"add"===a&&M.Am.success("Field added")},updateMeta:r}),a||(0,H.Z)({previousId:t,id:n,field:l})};return(0,i.jsx)(O.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.D,{padding:32,children:(0,i.jsx)(a.bf,{})}),children:(0,i.jsxs)(K.aV,{border:!1,style:{flexGrow:1},children:[(0,i.jsx)(q.Z,{zoneType:"customType",zoneTypeFormat:null!==(l=c.format)&&void 0!==l?l:"custom",tabId:o,title:"Static zone",dataTip:"",fields:g,poolOfFieldsToCheck:f,showHints:!0,EditModal:R.Z,widgetsArray:tt,onDeleteItem:e=>{d({customType:(0,m.AK)({customType:c,fieldId:e,sectionId:o})})},onSave:e=>""===e.apiId?x({...e,apiId:e.newKey}):y(e),onDragEnd:e=>{if((0,U.uS)(e))return;let{source:t,destination:n}=e;if(!n)return;let i=(0,m.gR)({customType:c,sourceIndex:t.index,destinationIndex:n.index,sectionId:o});(0,L.flushSync)(()=>d({customType:i}))},renderHintBase:e=>{let{item:t}=e;return"data".concat((0,G.Ti)(t.key))},renderFieldAccessor:e=>"data".concat((0,G.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:c.repeatable}),(0,i.jsx)(te,{customType:u,tabId:o,sliceZone:h,onRemoveSharedSlice:e=>{d({customType:(0,m.EN)({customType:c,sectionId:o,sliceId:e})})},onCreateSliceZone:()=>{d({customType:(0,m.Tr)(c,o)})},onDeleteSliceZone:()=>{d({customType:(0,m.E3)(c,o)})}})]})})})};let ti=()=>{var e,t,n;let{customType:r,setCustomType:l}=w(),o=D.Dc.toSM(r),[c,d]=(0,s.useState)(null===(e=o.tabs[0])||void 0===e?void 0:e.key),[u,h]=(0,s.useState)(),p=(null===(n=o.tabs.find(e=>e.key===c))||void 0===n?void 0:null===(t=n.sliceZone)||void 0===t?void 0:t.value.length)===0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.c8,{sx:p?{flexGrow:1}:void 0,children:["page"===r.format?(0,i.jsx)(a.c9,{title:r.repeatable?(0,i.jsx)(I,{}):void 0}):void 0,(0,i.jsxs)(a.ca,{onValueChange:d,value:c,children:[(0,i.jsx)(a.cc,{onAddNewTab:()=>{h({type:"CREATE_CUSTOM_TYPE_TAB"})},children:o.tabs.map(e=>(0,i.jsx)(a.cd,{menu:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.as,{onSelect:()=>{h({type:"UPDATE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aW,{name:"edit"}),children:"Rename"}),(0,i.jsx)(a.as,{color:"tomato",disabled:function(e){if(o.tabs.length<=1)return!0;let t=o.tabs.find(e=>e.value.find(e=>"uid"===e.key));return"page"===r.format&&r.repeatable&&(null==t?void 0:t.key)===e}(e.key),onSelect:()=>{h({type:"DELETE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aW,{name:"delete"}),children:"Remove"})]}),value:e.key,children:e.key},e.key))}),o.tabs.map(e=>(0,i.jsx)(a.cb,{value:e.key,children:(0,i.jsx)(tn,{tabId:e.key})},e.key))]})]}),(null==u?void 0:u.type)==="CREATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(z,{close:()=>{h(void 0)},isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.vB)(r,t)}),d(t)},tabIds:o.tabs.map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="UPDATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(P,{close:()=>{h(void 0)},initialTabKey:u.tabKey,isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.HO)(r,u.tabKey,t)}),c===u.tabKey&&d(t)},tabIds:o.tabs.filter(e=>e.key!==u.tabKey).map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="DELETE_CUSTOM_TYPE_TAB"?(0,i.jsx)(F,{close:()=>{h(void 0)},isOpen:!0,onSubmit:()=>{if(l({customType:(0,m.F$)(r,u.tabKey)}),c===u.tabKey){var e;let t=null===(e=o.tabs.find(e=>e.key!==u.tabKey))||void 0===e?void 0:e.key;void 0!==t&&d(t)}}}):void 0]})};var ta=n(16442),tr=n(78254),tl=n(60867),to=n(11166),ts=n(34919),tc=n.n(ts);let td=e=>{let{tabs:t,...n}=e;return(0,i.jsxs)(to.fC,{...n,className:tc().root,defaultValue:t[0].label,orientation:"vertical",children:[(0,i.jsx)(to.aV,{className:tc().list,"aria-label":"content tabs",children:t.map((e,t)=>{let{label:n}=e;return(0,i.jsx)(to.xz,{className:tc().trigger,value:n,children:(0,i.jsx)(a.bK,{className:tc().triggerText,component:"span",color:"inherit",children:n})},"".concat(n,"-trig").concat(t+1))})}),t.map((e,t)=>{let{label:n,content:r}=e;return(0,i.jsx)(to.VY,{className:tc().content,value:n,children:(0,i.jsx)(a.bm,{className:tc().scrollArea,children:r})},"".concat(n,"-content").concat(t+1))})]})};var tm=n(25661),tu=n(88241),th=n(32554),tp=n(44621),tg=n.n(tp);let tf=e=>{var t,n;let{inline:r,...l}=e,o=(0,th.p)();if(!0===r)return(0,i.jsx)("code",{...l,className:tg().inlineCode});let s=(()=>{var e,t,n,i,a;if((null===(t=l.node)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.meta)!==void 0){let e=null===(i=l.node)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.meta;return{fileName:e.substring(1,e.length-1),language:null===(a=l.className)||void 0===a?void 0:a.split("-")[1]}}return null})(),c=null===(t=/language-(\w+)/.exec(null!==(n=l.className)&&void 0!==n?n:""))||void 0===t?void 0:t[1];return(0,i.jsx)(a.V,{...l,onCopy:()=>{f.Xe.track({event:"page-type:copy-snippet",framework:o})},language:c,code:String(l.children).replace(/\n$/,""),title:null==s?void 0:s.fileName})},tx=e=>{let{markdown:t}=e;return(0,i.jsx)(tm.D,{children:t,linkTarget:"_blank",remarkPlugins:[tu.Z],components:{code:e=>(0,i.jsx)(tf,{...e}),h1:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h1",variant:"h1"}),h2:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h2",variant:"h2"}),h3:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h3",variant:"h3"}),h4:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h4",variant:"h4"}),h5:e=>(0,i.jsx)(a.bK,{children:e.children,component:"h4",variant:"h4"}),p:e=>(0,i.jsx)(a.bK,{className:tg().section,children:e.children,component:"p",variant:"normal"}),pre:e=>(0,i.jsx)(a.bK,{className:tg().section,children:e.children,component:"pre",variant:"normal"})}})};async function ty(e){let t=JSON.parse(e),{errors:n,documentation:i}=await ee.managerClient.documentation.read({kind:t.kind,data:t.data});if(n.length>0)throw n;return i}var tb=n(65480),tj=n.n(tb);let tv=e=>{var t;let{model:n}=e,r=(0,th.p)(),l=(t={kind:"PageSnippet",data:{model:n}},(0,ez.QT)(ty,[JSON.stringify(t)])),{completeStep:o}=(0,Q.k)();return 0===l.length?null:(0,i.jsxs)(a.ad,{size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",onClick:()=>{o("codePage"),f.Xe.track({event:"page-type:open-snippet",framework:r})},startIcon:"code",children:"Page snippet"}),children:[(0,i.jsx)(a.ak,{icon:"code",title:"Page snippet"}),(0,i.jsx)("section",{className:tj().content,children:l.length>1?(0,i.jsx)(td,{style:{flex:1},tabs:l.map((e,t)=>{let{label:n,content:a}=e;return{label:null!=n?n:"Tab ".concat(t+1),content:(0,i.jsx)(tx,{markdown:a})}})}):(0,i.jsx)(a.bm,{style:{flex:1,padding:16},children:(0,i.jsx)(tx,{markdown:l[0].content})})})]})},tS=e=>{let{model:t}=e;return(0,i.jsx)("div",{children:(0,i.jsx)(O.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.E,{color:"grey",startIcon:"code",children:"Page snippet"}),children:(0,i.jsx)(tv,{model:t})})})})},tw=()=>{let e=(0,o.useRouter)(),{selectedCustomType:t}=(0,c.v9)(t=>({selectedCustomType:(0,tr.Jk)(t,(0,h.Ag)(e.query))}));return((0,s.useEffect)(()=>{t&&(0,ta.TG)(t)||e.replace("/")},[t,e]),t&&(0,ta.TG)(t))?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l(),{children:(0,i.jsxs)("title",{children:[t.local.label," - Slice Machine"]})}),(0,i.jsx)(tC,{customType:t.local})]}):(0,i.jsx)(p.LN,{})},tC=e=>{let{customType:t}=e;return null===t?(0,i.jsx)(p.LN,{}):(0,i.jsx)(p.LN,{children:(0,i.jsx)(S,{initialCustomType:D.Dc.fromSM(t),children:e=>{var n;let{actionQueueStatus:r,customType:l,setCustomType:o}=e,s=(0,m.y6)(l),c=h.cd[t.format],g=j.$[t.format];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.wd,{children:[(0,i.jsx)(p.Xq,{url:c.tablePagePathname}),(0,i.jsxs)(p.Cx,{children:[(0,i.jsx)(d.g,{children:g.name({start:!0,plural:!0})}),(0,i.jsx)(d.g,{active:!0,children:null!==(n=l.label)&&void 0!==n?n:l.id})]}),(0,i.jsxs)(p.K2,{children:[(0,i.jsx)(u.X,{status:r}),"page"===l.format?(0,i.jsx)(tS,{model:l}):void 0,(0,i.jsx)(tl._,{isChangesLocal:!0,format:s,customType:l,setLocalCustomType:o})]})]}),(0,i.jsx)(p.RN,{children:(0,i.jsx)(a.D,{flexDirection:"column",minWidth:0,children:(0,i.jsx)(ti,{})})})]})}})})}},84879:function(e,t,n){"use strict";n.d(t,{E:function(){return l}});var i=n(18566),a=n(80148);async function r(){return a.managerClient.project.getSliceMachineConfig()}function l(e){var t,n;let[l,o]=[(0,i.QT)(r,[]),async e=>{await a.managerClient.project.writeSliceMachineConfig({config:e}),(0,i.VA)(r,[],e)}],s=async t=>{let n={...l,labs:{...l.labs}};t?n.labs[e]=t:e in n.labs&&delete n.labs[e],0===Object.keys(n.labs).length&&delete n.labs,await o(n)};return[{enabled:null!==(n=null==l?void 0:null===(t=l.labs)||void 0===t?void 0:t[e])&&void 0!==n&&n},s]}},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"}}}]);
|