slice-machine-ui 2.20.5-alpha.jp-import-slices-2.8 → 2.20.5-alpha.jp-import-slices-2.9
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/{spmKy_6GvIC8Xf-vl7NhM → 3S3TKrlwoZ6gqxx0Sct9l}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/907-2394b754e1d357f7.js +1 -0
- package/out/_next/static/chunks/pages/{_app-2a5bb84572ac3f55.js → _app-4d68d810313d1c29.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 +3 -3
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/ImportSlicesFromLibraryModal.tsx +10 -6
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/LibrarySlicesDialogContent.tsx +5 -8
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/LocalSlicesDialogContent.tsx +2 -2
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +1 -1
- package/out/_next/static/chunks/907-7a845d6591a5679d.js +0 -1
- /package/out/_next/static/{spmKy_6GvIC8Xf-vl7NhM → 3S3TKrlwoZ6gqxx0Sct9l}/_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/b30fbbc3ed00a725.css" as="style"/><link rel="stylesheet" href="/_next/static/css/b30fbbc3ed00a725.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-e986dd216b883a74.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/b30fbbc3ed00a725.css" as="style"/><link rel="stylesheet" href="/_next/static/css/b30fbbc3ed00a725.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-e986dd216b883a74.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-4d68d810313d1c29.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/3S3TKrlwoZ6gqxx0Sct9l/_buildManifest.js" defer=""></script><script src="/_next/static/3S3TKrlwoZ6gqxx0Sct9l/_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":"3S3TKrlwoZ6gqxx0Sct9l","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,t,
|
|
1
|
+
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,b,d,n,u,h,f,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-bc83e25e8d316ca9.js"],"/changes":[c,b,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",e,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-6f371ebe52dbe76a.js"],"/custom-types":[s,t,o,r,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,e,t,p,g,_,y,"static/chunks/pages/custom-types/[customTypeId]-02704945f838f3da.js"],"/labs":["static/chunks/pages/labs-16d118a80936d583.js"],"/page-types/[pageTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,e,t,p,g,_,y,"static/chunks/pages/page-types/[pageTypeId]-8f29474c7d2c5daa.js"],"/slices":[c,b,I,s,a,d,N,e,g,n,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-93fc784c443a996c.js"],"/slices/[lib]/[sliceName]/[variation]":[c,b,u,h,f,k,I,s,a,i,d,j,N,"static/chunks/484-3e011e79c41f0342.js",e,p,n,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-0e9aa745ed9fe1ec.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[b,"static/chunks/72585f70-28b4d7d5384b3703.js",l,"static/chunks/429-e5d7e39160de9f5e.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-873c0c89aaf50b3c.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-8ab59c0c72307c87.js","static/chunks/647-a29bee23cb9ac7a2.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-4fe1e982234bd925.js","static/chunks/633-2d20c3e815c79c7f.js","static/chunks/248-2902bda47821f37b.js","static/css/4e475d945cf8a890.css","static/chunks/21-f3962d02eda0a46e.js","static/chunks/907-2394b754e1d357f7.js","static/css/56f2a6684a524374.css","static/chunks/52d4c156-89c6ec6efca0a0bb.js","static/chunks/444-d39213143f782fec.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{61907:function(e,t,n){"use strict";n.d(t,{H:function(){return td}});var i=n(52322),a=n(18337),o=n(97729),l=n.n(o),r=n(5632),s=n(2784),c=n(56580),d=n(43388),m=n(77630),h=n(23094),u=n(59294),p=n(58446),f=n(74217),g=n(94160),x=n(68968),b=n(23710),y=n(54597),v=n(98564);let j=(0,s.createContext)(void 0);function S(e){let{children:t,initialCustomType:n}=e,[a,o]=(0,s.useState)(n),l=(0,m.y6)(a),r=v.$[l],{actionQueueStatus:c,setNextAction:d}=(0,b.c)({errorMessage:r.autoSaveFailed}),{refreshState:h}=(0,y.Z)(),u=(0,f.R9)(h),{syncChanges:p}=(0,x.g)(),S=(0,s.useCallback)(e=>{let{customType:t,onSaveCallback:n,updateMeta:i}=e;o(t),d(async()=>{let{errors:e}=await (0,g.KA)({customType:t,updateMeta:i});if(e.length>0)throw e;u(await (0,g.y0)()),p(),null==n||n()})},[d,u,p]),w=(0,s.useMemo)(()=>({actionQueueStatus:c,customType:a,setCustomType:S}),[c,a,S]);return(0,i.jsx)(j.Provider,{value:w,children:"function"==typeof t?t(w):t})}function w(){let e=(0,s.useContext)(j);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:o,setCustomType:l}=w(),[r,c]=null!==(e=(0,m.j5)(o))&&void 0!==e?e:[],d=c?(0,m.N3)(c):"",[h,u]=(0,s.useState)(null!=d?d:""),[p,g]=(0,s.useState)();(0,f.pQ)(t,()=>{t||(u(null!=d?d:""),g(void 0))});let x=(0,s.useCallback)(()=>(0,i.jsx)(a.aX,{name:c?"language":"add",size:"small",color:"grey11"}),[c]);return(0,i.jsxs)(a.ae,{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.al,{title:"Edit the UID label"}),(0,i.jsx)(a.aj,{children:(0,i.jsxs)(a.aJ,{onSubmit:function(){p||(l({customType:c?(0,m.eK)(h,o):(0,m.H8)(h,o)}),n(!1))},children:[(0,i.jsx)(a.D,{flexDirection:"column",padding:16,gap:4,children:(0,i.jsx)(a.aM,{type:"text",label:"Label *",placeholder:"UID",value:h,onValueChange:function(e){u(e),g(function(e){let t=D.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.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",disabled:!!p,children:"Save"})]})]})})]})}let D=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 k=n(94840),_=n(59532),A=n(63397),E=n(75289);let L=e=>{let{name:t,label:n,placeholder:a,error:o,...l}=e;return(0,i.jsxs)(E.xu,{mb:3,children:[(0,i.jsx)(E.__,{htmlFor:t,mb:2,children:n}),(0,i.jsx)(A.gN,{name:t,type:"text",placeholder:a,as:E.II,autoComplete:"off",...l}),o?(0,i.jsx)(E.xv,{sx:{color:"error",mt:1},children:o}):null]})};var z=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:o}=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?o.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)(L,{name:"id",label:"New Tab ID",placeholder:"A label for selecting the tab (i.e. not used in the API)",error:t.id})}})},N=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)(E.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(E.X6,{as:"h4",children:"Remove this tab?"}),(0,i.jsx)(E.xv,{as:"p",color:"textClear",sx:{mt:2},children:"This action cannot be undone."}),(0,i.jsx)(E.zx,{type:"button",variant:"buttons.actionDelete",sx:{mt:3},onClick:()=>{n({}),a()},children:"Yes, remove tab"})]})})},M=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:o,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?o.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Rename Tab"},children:e=>{let{errors:t,values:o,setFieldValue:l,isValid:r}=e;return(0,i.jsxs)(E.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(L,{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=>{o.id!==e.target.value&&l("id",e.target.value.trim())},onChange:e=>{l("id",e.target.value)}}),(0,i.jsx)(E.zx,{type:"button",sx:{mt:3,width:"100%"},disabled:!r,onClick:()=>{o.id&&o.id.length&&n({id:o.id.trim()}),a()},children:"Save"})]})}})},P=n(28316),F=n(88932),O=n(35289),U=n(87446),Z=n(45440),G=n(16086),B=n(358),R=n(5495),H=n(39302),K=n(3285),V=n(40141),X=n(65077),q=n(21446),W=n(80148),Y=n(98250);let $=(e,t)=>{switch(e){case"custom_type":case"page_type":return"Add to ".concat(t)}};function J(e){let{totalSelected:t,onSubmit:n,isSubmitting:o,location:l,typeName:r}=e;return(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{disabled:o,size:"medium"}),(0,i.jsxs)(a.af,{disabled:0===t,loading:o,onClick:()=>void n(),size:"medium",children:[$(l,r)," (",t,")"]})]})}function Q(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 ee(e){let{selectedTab:t,onSelectTab:n,rightContent:o}=e;return(0,i.jsxs)(a.D,{justifyContent:"space-between",padding:16,border:{bottom:!0},children:[(0,i.jsxs)(a.D,{gap:8,children:[(0,i.jsx)(a.bD,{selected:"local"===t,onClick:()=>n("local"),children:"Local Slices"}),(0,i.jsx)(a.bD,{selected:"library"===t,onClick:()=>n("library"),children:"Library Slices"})]}),o]})}var et=n(74686),en=n(88866);async function ei(e,t,n){let i=Array(e.length),a=0,o=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(o),i}class ea{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 o=atob(a.content.replace(/\s/g,""));if(!n)return o;{let e=new Uint8Array(o.length);for(let t=0;t<o.length;t++)e[t]=o.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(" "))),o=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(o)}async getSliceLibraries(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())}).parse(JSON.parse(e)).libraries}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 eo=e=>{let t=e.match(/github\.com\/([^\/]+)\/([^\/]+)(?:\/|$)/);if(!t)throw Error("Invalid GitHub URL format");let[,n,i]=t;return{owner:n,repo:i.replace(/\.git$/,"")}},el=async e=>{let{owner:t,repo:n}=e;return new ea({owner:t,repo:n}).getDefaultBranch()},er=async e=>{let{owner:t,repo:n,branch:i}=e;return new ea({owner:t,repo:n}).getSliceLibraries(i)},es=async e=>{let{owner:t,repo:n,branch:i,libraries:a}=e,o=new ea({owner:t,repo:n}),l=[];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 o.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 o.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 o.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=en.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 ec({api:o,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=et.SharedSliceContent.decode(JSON.parse(i.contents));if("Left"===t._tag)console.warn("Failed to decode mocks.json for slice: ".concat(e.name));else{let e=t.right;Array.isArray(e)&&e.length>0&&(n=e)}}catch(t){console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}let h={};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"),l=await o.getFileContents(n,i,!0);if(l instanceof ArrayBuffer){let e=new Blob([l],{type:"image/png"}),n=new File([e],"screenshot-".concat(t.id,".png"),{type:"image/png"});h[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 u=null!=r?r:new File([],"".concat(d.name,".json"),{type:"application/json"}),p={image:u,thumbnailUrl:null!=a?a:URL.createObjectURL(u),model:d,files:m,componentContents:t,mocks:n,screenshots:Object.keys(h).length>0?h:void 0};l.push(p)}catch(t){console.warn("Error fetching slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}};await ei(n,6,r)}return l},ec=async e=>{let{api:t,branch:n,directoryPath:i}=e,a=[],o=!1;try{let e=await t.getDirectoryContents(i);o=!0;let l=e.filter(e=>"file"===e.type),r=e.filter(e=>"dir"===e.type);for(let e of(await ei(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 r)for(let i of(await ec({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(!o)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 o of(console.log("Found ".concat(e.items.length," file(s) via Search API for ").concat(i)),await ei(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,o=[".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,o);return{path:a,contents:l,isBinary:o}}catch(t){return console.warn("Error fetching file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))o&&a.push(o);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};var ed=n(62434);function em(e){let{thumbnailUrl:t,model:n,selected:o=!0,onSelectedChange:l}=e,r=(0,i.jsxs)(i.Fragment,{children:[void 0!==t&&t?(0,i.jsx)(ed.ZB,{src:t}):(0,i.jsx)(ed.ZB,{component:"div"}),(0,i.jsx)(ed.eW,{title:n.name,action:(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,i.jsx)(a.U,{checked:o,onCheckedChange:l})})})]});return(0,i.jsx)(ed.Zb,{interactive:!0,onClick:()=>{l(!o)},checked:o,size:"small","data-testid":"slice-card",children:r})}async function eh(e){let{libraries:t=[]}=await W.managerClient.project.getSliceMachineConfig(),n=t[0];if(!n)throw Error("No library found in the config.");await ei(e,3,async e=>{let{errors:t}=await W.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 ei(e,3,async e=>{let{model:t,image:i,langSmithUrl:a,mocks:o,files:l,screenshots:r}=e;if(o&&Array.isArray(o)&&o.length>0){let{errors:e}=await W.managerClient.slices.updateSliceMocks({libraryID:n,sliceID:t.id,mocks:o});e.length&&console.warn("Failed to update mocks for slice ".concat(t.id,":"),e)}return r&&Object.keys(r).length>0?await Promise.all(Object.entries(r).map(async e=>{let[i,a]=e;a.size>0&&await W.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:i,data:a})})):i.size>0&&void 0!==t.variations&&t.variations.length>0&&await W.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 eu({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 eu(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 W.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 ep(e){let{open:t,location:n,typeName:o,onSelectTab:l,onSuccess:r,selected:c}=e,[d,m]=(0,s.useState)(""),[h,u]=(0,s.useState)(!1),[p,b]=(0,s.useState)([]),{isLoadingSlices:v,handleImportFromGithub:j,slices:S,resetSlices:w}=function(){let[e,t]=(0,s.useState)(!1),[n,i]=(0,s.useState)([]);return{isLoadingSlices:e,slices:n,resetSlices:()=>{i([]),t(!1)},handleImportFromGithub:async e=>{try{let n;t(!0);let{owner:a,repo:o}=eo(e);if(!a||!o)throw F.Am.error("Invalid GitHub URL format"),t(!1),Error("Invalid GitHub URL format");let l=await el({owner:a,repo:o});try{n=await er({owner:a,repo:o,branch:l})}catch(e){throw console.error("Failed to fetch slicemachine.config.json:",e),F.Am.error("Failed to fetch slicemachine.config.json: ".concat(e instanceof Error?e.message:"Unknown error")),t(!1),e}if(0===n.length)throw console.warn("No libraries were found in the SM config."),t(!1),F.Am.error("No libraries were found in the SM config."),Error("No libraries were found in the SM config.");let r=await es({owner:a,repo:o,branch:l,libraries:n});if(0===r.length)throw F.Am.error("Error fetching slices from the repository"),t(!1),Error("No slices were found in the libraries.");return i(r),t(!1),F.Am.success("Found ".concat(r.length," slice(s) from ").concat(n.length," library/libraries")),r}catch(e){return console.error("Error importing from GitHub:",e),F.Am.error("Error importing from GitHub: ".concat(e instanceof Error?e.message:"Unknown error")),t(!1),[]}}}}(),C=(0,y.Z)(),I=function(e){let{open:t}=e,n=(0,s.useRef)([]);return(0,s.useEffect)(()=>{t&&(n.current=[],W.managerClient.slices.readAllSlices().then(e=>{n.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),n}({open:t}),{syncChanges:D}=(0,x.g)(),{completeStep:T}=(0,Y.k)(),k=(0,s.useRef)(crypto.randomUUID());(0,f.Ng)(()=>{t||(b([]),w(),m(""),k.current=crypto.randomUUID())},[t]);let _=()=>{j(d)},A=e=>{b(t=>t.some(t=>t.model.id===e.model.id)?t.filter(t=>t.model.id!==e.model.id):[...t,e])},E=async()=>{if(0===p.length){F.Am.error("Please select at least one slice");return}let e=p.map(e=>({image:e.image,model:e.model,files:e.files,componentContents:e.componentContents,mocks:e.mocks,screenshots:e.screenshots})),t=[];for(let n of e){let e=function(e){let{existingSlices:t,newSlices:n,slice:i}=e,a=new Set,o=new Set;for(let{id:e,name:n}of t)a.add(e),o.add(n.toLowerCase());for(let e of n)a.add(e.model.id),o.add(e.model.name.toLowerCase());let l=i.id,r=2;for(;a.has(l);)l="".concat(i.id,"_").concat(r),r++;let s=i.name;for(r=2;o.has(s.toLowerCase());)s="".concat(i.name).concat(r),r++;return{...i,id:l,name:s}}({existingSlices:I.current,newSlices:t,slice:n.model});t.push({...n,model:e})}let i=k.current;u(!0);try{let{slices:a,library:o}=await eh(t);if(i!==k.current)throw Error("Modal instance changed");await new Promise(e=>setTimeout(e,100));let l=(await (0,g.y0)()).libraries.map(e=>e.name!==o?e:{...e,components:e.components.map(e=>{let n=t.find(t=>t.model.id===e.model.id),i=e.mocks&&e.mocks.length>0?e.mocks:null==n?void 0:n.mocks;return{...e,mocks:null!=i?i:e.mocks}})});for(let t of(C.createSliceSuccess(l),e))t.mocks&&Array.isArray(t.mocks)&&t.mocks.length>0&&C.updateSliceMockSuccess({libraryID:o,sliceID:t.model.id,mocks:t.mocks});for(let{model:e}of(D(),u(!1),w(),T("createSlice"),a))g.Xe.track({event:"slice:created",id:e.id,name:e.name,library:o,location:n,mode:"import"});r({slices:a,library:o})}catch(e){if(i!==k.current)throw e;throw u(!1),F.Am.error("An unexpected error happened while adding slices."),e}},L=S.every(e=>p.some(t=>t.model.id===e.model.id)),z=S.some(e=>p.some(t=>t.model.id===e.model.id)),N="Select all slices";return L?N="Selected all slices (".concat(p.length,")"):z&&(N="".concat(p.length," of ").concat(S.length," selected")),(0,i.jsxs)(Q,{selected:c,children:[(0,i.jsx)(ee,{selectedTab:"library",onSelectTab:l,rightContent:"<repo-select>"}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:S.length>0?(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.aR,{value:N,children:(0,i.jsx)(a.U,{checked:L,indeterminate:z&&!L,onCheckedChange:e=>{b(e?S:[])}})})}),(0,i.jsx)(a.bn,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{inline:16,bottom:16},children:S.map(e=>{let t=p.some(t=>t.model.id===e.model.id);return(0,i.jsx)(em,{model:e.model,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>A(e)},e.model.id)})})})]}):(0,i.jsx)(a.D,{padding:16,height:"100%",flexDirection:"column",gap:16,children:(0,i.jsx)(a.D,{flexDirection:"column",gap:8,children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:8,padding:16,border:!0,borderRadius:8,children:[(0,i.jsx)(a.bL,{color:"grey11",children:"Import from GitHub"}),(0,i.jsx)(a.bN,{placeholder:"https://github.com/username/repository",value:d,onValueChange:m}),(0,i.jsx)(a.E,{onClick:()=>void _(),disabled:!d.trim()||v,loading:v,color:"purple",children:v?"Loading slices...":"Import from GitHub"})]})})})}),(0,i.jsx)(J,{totalSelected:p.length,onSubmit:()=>void E(),isSubmitting:h,location:n,typeName:o})]})}function ef(e){let{open:t,location:n,typeName:o,onSelectTab:l,onSuccess:r,availableSlices:c=[],selected:d}=e,[m,h]=(0,s.useState)([]);(0,s.useEffect)(()=>{t||h([])},[t]);let u=e=>{h(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])};return(0,i.jsxs)(Q,{selected:d,children:[(0,i.jsx)(ee,{selectedTab:"local",onSelectTab:l}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:c.length>0?(0,i.jsx)(a.bn,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,flexGrow:1,padding:16,minHeight:0,children:c.map(e=>{let t=m.some(t=>t.id===e.id);return(0,i.jsx)(em,{model:e,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>u(e)},e.id)})})}):(0,i.jsx)(a.D,{padding:16,height:"100%",flexDirection:"column",gap:16,children:(0,i.jsx)(a.D,{flexDirection:"column",gap:8,children:(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:8,padding:16,alignItems:"center",justifyContent:"center",children:"No local slices available"})})})}),(0,i.jsx)(J,{totalSelected:m.length,onSubmit:()=>{if(0===m.length){F.Am.error("Please select at least one slice");return}r({slices:m.map(e=>({model:e}))})},location:n,typeName:o})]})}function eg(e){let{open:t,availableSlices:n=[],onClose:o,...l}=e,[r,c]=(0,s.useState)("local");return(0,i.jsxs)(a.ae,{open:t,onOpenChange:e=>{e||(o(),setTimeout(()=>c("local"),250))},children:[(0,i.jsx)(a.al,{title:"Reuse an existing slice"}),(0,i.jsxs)(a.aj,{gap:0,children:[(0,i.jsx)(a.ak,{hidden:!0,children:"Select existing slices or import slices from a GitHub repository"}),(0,i.jsx)(ef,{...l,open:t,selected:"local"===r,onSelectTab:c,availableSlices:n,onClose:o}),(0,i.jsx)(ep,{...l,open:t,selected:"library"===r,onSelectTab:c,onClose:o})]})]})}var ex=n(27213);let eb=e=>{let{openCreateSliceModal:t,openCreateSliceFromImageModal:n,openUpdateSliceZoneModal:o,openSlicesTemplatesModal:l,isSlicesTemplatesSupported:r}=e,s=(0,ex.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}),r&&(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:o,description:s.fromExisting.description,children:s.fromExisting.title})]})})]})};function ey(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)}}),g.Xe.track({event:"custom-type:slice-zone-updated",customTypeId:t.id}),a}var ev=n(18566);async function ej(){try{let{templates:e,errors:t}=await W.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 eS=n(6256),ew=n(39204),eC=n(26109),eI=n(7723),eD=n(33986),eT=n(30527),ek=n(55862);let e_=e=>{let{deleteSliceZone:t,closeDeleteSliceZoneModal:n}=e;return(0,i.jsx)(ek.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:n,children:(0,i.jsx)(eT.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)(E.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)(E.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:"Do you really want to delete Slice Zone?"}),(0,i.jsx)(E.x8,{type:"button",onClick:n})]}),Footer:()=>(0,i.jsxs)(E.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)(eD.z,{label:"Cancel",variant:"secondary",onClick:n,sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),(0,i.jsx)(eD.z,{label:"Delete",variant:"danger",onClick:t,sx:{minHeight:39,minWidth:78}})]}),children:(0,i.jsx)(E.nv,{children:"You're about to delete Slice Zone."})})})};var eA=n(84879),eE=n(63908),eL=n(63019),ez=n(65375),eN=n.n(ez);let eM=e=>{var t;let{isOpen:n,close:o,onSubmit:l,isLoading:r,slice:d,libraries:m}=e,{remoteSlices:h}=(0,c.v9)(e=>({remoteSlices:(0,eI.sT)(e)})),u={from:null===(t=m[0])||void 0===t?void 0:t.name,sliceName:(0,B.MP)(d.key)},[p,g]=(0,s.useState)(u),[x,b]=(0,s.useState)();function y(e){g(e),b((0,eL.h)(e,m,h))}return(0,f.pQ)(n,()=>{n||(g(u),b(void 0))}),(0,i.jsxs)(a.ae,{open:n,onOpenChange:e=>!e&&o(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Upgrade slice"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{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.bn,{className:eN().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"This will create a new slice with the same fields. The new slice will replace the legacy slice in all of your types, and the existing slice content will be re-mapped to the new slice."}),(0,i.jsx)(a.bL,{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.aM,{label:"Slice name *",placeholder:"Pascalised Slice API ID (e.g. ".concat((0,B.MP)(d.key),")"),error:null==x?void 0:x.sliceName,value:p.sliceName,onValueChange:e=>y({...p,sliceName:e.slice(0,30)}),"data-testid":"slice-name-input"}),(0,i.jsx)(a.bL,{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:eN().label,children:(0,i.jsx)(a.bL,{variant:"bold",children:"Slice library *"})}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"folder",flexContent:!0,value:p.from,onValueChange:e=>{e&&y({...p,from:e})},children:m.map(e=>(0,i.jsx)(a.bt,{value:e.name,children:e.name},e.name))}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"The library where we'll store your slice"})]})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:r,disabled:x&&Object.keys(x).length>0,children:"Upgrade"})]})]})})})]})};var eP=n(96009),eF=n.n(eP);let eO=e=>{var t,n;let{isOpen:o,close:l,onSubmit:r,isLoading:c,slice:d,sliceName:m,libraries:h,localSharedSlices:u}=e,p={libraryID:null===(t=u[0])||void 0===t?void 0:t.from,sliceID:null===(n=u[0])||void 0===n?void 0:n.model.id,variationID:eF()(d.key),variationName:m},[g,x]=(0,s.useState)(!0),[b,y]=(0,s.useState)(p),[v,j]=(0,s.useState)({});function S(e){y(e),j(eU(e,h))}return(0,f.pQ)(o,()=>{o||(y(p),j({}))}),(0,i.jsxs)(a.ae,{open:o,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Convert to slice variation"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{onSubmit:function(){Object.keys(v).length>0||r(b)},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bn,{className:eN().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple slices that are similar, you can combine them as variations of the same slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eN().label,children:[(0,i.jsx)(a.bL,{variant:"bold",children:"Target slice *"}),"string"==typeof v.libraryID?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:v.libraryID}):null,"string"==typeof v.sliceID?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:v.sliceID}):null]}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:"".concat(b.libraryID,"::").concat(b.sliceID),onValueChange:e=>{if(e){let[t,n]=e.split("::");S({...b,libraryID:t,sliceID:n})}},children:u.map(e=>(0,i.jsxs)(a.bt,{value:"".concat(e.from,"::").concat(e.model.id),children:[e.from," ",">"," ",e.model.name," (",e.model.id,")"]},"".concat(e.from,"::").concat(e.model.id)))}),(0,i.jsx)(a.bL,{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.aM,{label:"Variation name *",placeholder:m,error:v.variationName,value:b.variationName,onValueChange:e=>{let t={...b,variationName:e.slice(0,30)};g&&(t.variationID=eF()(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.aM,{label:"ID *",placeholder:eF()(d.key),error:v.variationID,value:b.variationID,onValueChange:e=>{x(!1),S({...b,variationID:e.slice(0,30)})},"data-testid":"variation-id-input"})})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:Object.keys(v).length>0,children:"Convert"})]})]})})})]})},eU=(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 o;(null!==(o=null==a?void 0:a.model.variations.map(e=>e.id))&&void 0!==o?o:[]).includes(e.variationID)&&(n.variationID="Slice variation ID is already taken.")}else n.variationID="Cannot be empty.";return n},eZ=e=>{var t,n;let{isOpen:o,close:l,onSubmit:r,isLoading:c,identicalSlices:d}=e,m=null!==(n=null===(t=d[0])||void 0===t?void 0:t.path)&&void 0!==n?n:"",[h,u]=(0,s.useState)(m),[p,g]=(0,s.useState)();return(0,f.pQ)(o,()=>{o||(u(m),g(void 0))}),(0,i.jsxs)(a.ae,{open:o,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Merge with an existing slice"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{onSubmit:function(){if(p)return;let[e,t,n]=h.split("::");r({libraryID:e,sliceID:t,variationID:n})},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bn,{className:eN().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple identical slices, you can merge them. All of your content will be remapped to the target slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eN().label,children:[(0,i.jsx)(a.bL,{variant:"bold",children:"Target slice*"}),"string"==typeof p?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:p}):null]}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:h,onValueChange:function(e){u(e),e||g("Cannot be empty.")},children:d.map(e=>(0,i.jsx)(a.bt,{value:e.path,children:e.path.split("::").join(" > ")},e.path))}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"Choose a slice that you would like to merge this into."})]})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:!!p,children:"Merge"})]})]})})})]})},eG=e=>{var t;let{slice:n,path:o}=e,{refreshState:l}=(0,y.Z)(),[r,d]=(0,s.useState)(!1),[m,h]=(0,s.useState)(),{setCustomType:u}=w(),{libraries:p}=(0,c.v9)(e=>({libraries:(0,eI.Sd)(e)})),f="Slice"===n.value.type&&null!==(t=n.value.fieldset)&&void 0!==t?t:n.key,x=p.filter(e=>e.isLocal),b=x.map(e=>e.components).flat(),v=eB(n,f,b),j=async e=>{var t,i,a;if(!m)return;d(!0),g.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:r}=await W.managerClient.slices.convertLegacySliceToSharedSlice({model:n.value,src:{...o,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(r.length)throw console.error("Could not convert slice `".concat(f,"`"),r),F.Am.error("Could not convert slice `".concat(f,"`")),r;let{model:s,errors:c}=await W.managerClient.customTypes.readCustomType({id:o.customTypeID});if(c.length||!s){console.error("Could not refresh custom type view `".concat(o.customTypeID,"`"),c),F.Am.error("Could not refresh custom type view `".concat(o.customTypeID,"`"));return}switch(l(await (0,g.y0)()),d(!1),h(void 0),m){case"as_new_slice":F.Am.success("".concat(f," has been upgraded to a new slice ").concat(e.libraryID," > ").concat(e.sliceID));break;case"as_new_variation":F.Am.success("".concat(f," has been converted as a variation of ").concat(e.libraryID," > ").concat(e.sliceID));break;default:F.Am.success("".concat(f," has been merged with ").concat(e.libraryID," > ").concat(e.sliceID))}u({customType:s})},S={path:o,slice:n,sliceName:f,libraries:x,localSharedSlices:b,identicalSlices:v,close:()=>h(void 0),onSubmit:j,isLoading:r};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.ar,{children:[(0,i.jsx)(a.av,{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.as,{align:"start",children:[(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"folder",size:"large"}),description:"Use it with new types",onSelect:()=>h("as_new_slice"),children:"Upgrade slice"}),(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"viewDay",size:"large"}),description:"Add it to another slice",onSelect:()=>h("as_new_variation"),disabled:!b.length,children:"Convert to slice variation"}),(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"driveFileMove",size:"large"}),description:"Combine identical slices",onSelect:()=>h("merge_with_identical"),disabled:!v.length,children:"Merge with another slice"})]})]}),(0,i.jsx)(eM,{...S,isOpen:"as_new_slice"===m}),(0,i.jsx)(eO,{...S,isOpen:"as_new_variation"===m}),(0,i.jsx)(eZ,{...S,isOpen:"merge_with_identical"===m})]})},eB=(e,t,n)=>(0,s.useMemo)(()=>{let i=[],a=(0,eE.ux)(e.value,t);for(let e of n)for(let t of e.model.variations){let n=(0,eE.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]),eR=e=>{let{slice:t,path:n}=e,[o]=(0,eA.E)("legacySliceUpgrader"),l=o.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)(ed.Zb,{children:[(0,i.jsx)(ed.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(a.bL,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsxs)(ed.T$,{children:[(0,i.jsx)(a.c3,{content:l,side:"bottom",children:(0,i.jsx)(a.m,{color:"purple",title:"Legacy Slice"})}),o.enabled?(0,i.jsx)(eG,{slice:t,path:n}):null]}),(0,i.jsx)(ed.eW,{subtitle:"1 variation",title:(0,eE.Dj)(t.value)})]})};var eH=n(51507),eK=n(21151);let eV=e=>{let{slices:t,format:n,path:a,onRemoveSharedSlice:o}=e,l=t.some(e=>"SharedSlice"!==e.type),r=v.$[n],[c]=(0,eA.E)("legacySliceUpgrader");return(0,s.useEffect)(()=>{l&&(c.enabled?F.Am.info("This ".concat(r.name({start:!1,plural:!1})," contains legacy slices that can be upgraded.")):F.Am.warning("This ".concat(r.name({start:!1,plural:!1})," contains slices that are incompatible.")))},[l]),(0,i.jsx)(eK.Z,{elems:t,defineElementKey:e=>"SharedSlice"!==e.type?e.payload.key:e.payload.model.name,renderElem:e=>{if("SharedSlice"!==e.type){let t=e.payload;return(0,i.jsx)(eR,{slice:t,path:a})}{let t=e.payload;return(0,i.jsx)(eH.b,{action:{type:"remove",onRemove:()=>{o(t.model.id)}},mode:"navigation",slice:t,variant:"solid"})}},sx:{padding:"16px"}})};async function eX(e){try{let{templateIDs:t,localLibrariesNames:n,location:i,onSuccess:a}=e,{data:o,errors:l}=await W.managerClient.sliceTemplateLibrary.createSlices({templateIDs:t});if(l.length>0||void 0===o)throw l;o.sliceIDs.forEach((e,a)=>{g.Xe.track({event:"slice:created",id:e,name:e,library:n[0],location:i,mode:"template",sliceTemplate:t[a]})}),await a(o.sliceIDs)}catch(t){let e="Internal Error: Slice(s) not created";console.error(e,t),F.Am.error(e)}}var eq=e=>{let{availableSlices:t,values:n}=e;return(0,i.jsx)(A.F2,{name:"sliceKeys",render:e=>(0,i.jsx)(eK.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)(eH.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 eW=e=>{let{formId:t,close:n,onSuccess:a,availableSlicesTemplates:o,localLibraries:l,location:r}=e,{createSliceSuccess:s}=(0,y.Z)();return(0,i.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:n,onSubmit:e=>{let{sliceKeys:t}=e;eX({templateIDs:t,localLibrariesNames:l.map(e=>e.name),location:r,onSuccess:async e=>{s((await (0,g.y0)()).libraries),a(await Promise.all(e.map(async e=>(await W.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)(E.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,i.jsx)(eq,{values:t,availableSlices:o.map(e=>({extension:"",fileName:"",from:"",href:"",pathToSlice:"",model:eC.id.toSM(e.model),screenshots:Object.entries(e.screenshots).reduce((e,t)=>({...e,[t[0]]:{url:t[1]}}),{})}))})}})},eY=(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 e$=e=>{var t,n;let{customType:o,onCreateSliceZone:l,onDeleteSliceZone:r,onRemoveSharedSlice:d,sliceZone:m,tabId:h}=e,u=(0,ev.QT)(ej,[]),[p,f]=(0,s.useState)(!1),[x,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),{remoteSlices:I,libraries:D}=(0,c.v9)(e=>({remoteSlices:(0,eI.sT)(e),libraries:(0,eI.Sd)(e),slices:(0,eI.xC)(e)})),{setCustomType:T}=w(),{completeStep:_}=(0,Y.k)(),{openLoginModal:A}=(0,y.Z)(),E=(0,ex.F)({menuType:"Dropdown"}),L=D.filter(e=>e.isLocal),{availableSlices:z,slicesInSliceZone:N,notFound:M}=(0,s.useMemo)(()=>m?eY(m,D):{availableSlices:[],slicesInSliceZone:[],notFound:[]},[m,D]),[P,U]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(null==M?void 0:M.length)&&M.forEach(e=>{let{key:t}=e;d(t)})},[M]);let Z=N.filter(e=>"SharedSlice"===e.type).map(e=>e.payload),G=z.filter(e=>!Z.some(t=>t.model.id===e.model.id)),B=()=>{b(!0)},R=()=>{j(!0)},H=async()=>{await W.managerClient.user.checkIsLoggedIn()?C(!0):A()},K=()=>{f(!0),g.Xe.track({event:"custom-type:open-add-from-templates",customTypeId:o.id,customTypeFormat:o.format})},V=()=>{b(!1)},$=()=>{j(!1)},J=()=>{C(!1)},Q=()=>{f(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(O.Bu,{actions:m?(0,i.jsxs)(a.ar,{children:[(0,i.jsx)(a.av,{children:(0,i.jsx)(a.E,{color:"purple",startIcon:"add","data-testid":"add-new-slice-dropdown",children:"Add"})}),(0,i.jsxs)(a.as,{align:"end",children:[(0,i.jsx)(a.at,{renderStartIcon:()=>E.fromImage.BackgroundIcon,onSelect:()=>void H(),description:E.fromImage.description,children:E.fromImage.title}),(0,i.jsx)(a.at,{renderStartIcon:()=>E.fromScratch.BackgroundIcon,onSelect:R,description:E.fromScratch.description,children:E.fromScratch.title}),u.length>0?(0,i.jsx)(a.at,{onSelect:K,renderStartIcon:()=>E.fromTemplate.BackgroundIcon,description:E.fromTemplate.description,children:E.fromTemplate.title}):void 0,(0,i.jsx)(a.at,{onSelect:B,renderStartIcon:()=>E.fromExisting.BackgroundIcon,description:E.fromExisting.description,children:E.fromExisting.title})]})]}):void 0,toggle:"page"!==o.format||"Main"!==h?(0,i.jsx)(a.bC,{checked:!!m,onCheckedChange:e=>{e?l():U(!0)},size:"small","data-testid":"slice-zone-switch"}):void 0,children:"Slices"}),m?N.length>0?(0,i.jsx)(X.xR,{children:(0,i.jsx)(eV,{slices:N,format:o.format,path:{customTypeID:o.id,tabID:h,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)(eb,{openUpdateSliceZoneModal:B,openCreateSliceModal:R,openCreateSliceFromImageModal:()=>void H(),openSlicesTemplatesModal:K,projectHasAvailableSlices:G.length>0,isSlicesTemplatesSupported:u.length>0})}):void 0,(0,i.jsx)(eg,{open:x,location:"".concat(o.format,"_type"),typeName:null!==(n=o.label)&&void 0!==n?n:o.id,availableSlices:G.map(e=>{var t;return{...eC.id.fromSM(e.model),thumbnailUrl:null===(t=Object.values(e.screenshots)[0])||void 0===t?void 0:t.url}}),onSuccess:e=>{let{slices:t}=e,n=ey({customType:o,tabId:h,slices:t.map(e=>e.model)});T({customType:k.Dc.fromSM(n),onSaveCallback:()=>{F.Am.success("Slices successfully added")}}),_("createSlice"),V()},onClose:V}),p&&(0,i.jsx)(eW,{formId:"tab-slicezone-form-".concat(h),availableSlicesTemplates:u,localLibraries:L,location:"".concat(o.format,"_type"),onSuccess:e=>{let t=ey({customType:o,tabId:h,slices:e});T({customType:k.Dc.fromSM(t),onSaveCallback:()=>{F.Am.success((0,i.jsx)(ew.GX,{message:"Slice template(s) added to slice zone and created at: ",path:"".concat(L[0].name,"/")}))}}),_("createSlice"),Q()},close:Q}),P&&(0,i.jsx)(e_,{closeDeleteSliceZoneModal:()=>{U(!1)},deleteSliceZone:()=>{r(),U(!1)}}),(null==L?void 0:L.length)!==0&&v&&(0,i.jsx)(eS.c,{onSuccess:e=>{let t=ey({customType:o,tabId:h,slices:[e]});T({customType:k.Dc.fromSM(t),onSaveCallback:()=>{F.Am.success((0,i.jsx)(ew.GX,{message:"New slice added to slice zone and created at: ",path:"".concat(L[0].name,"/")}))}}),$()},localLibraries:L,location:"".concat(o.format,"_type"),remoteSlices:I,onClose:$}),(0,i.jsx)(q.S,{open:S,location:"".concat(o.format,"_type"),onSuccess:e=>{let{slices:t,library:n}=e,a=ey({customType:o,tabId:h,slices:t});T({customType:k.Dc.fromSM(a),onSaveCallback:()=>{F.Am.success((0,i.jsx)(ew.GX,{message:"Slice(s) added to slice zone and created at: ",path:n}))}}),J()},onClose:J})]})};let eJ=[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 eQ=e=>{var t,n,o,l;let{tabId:r}=e,{customType:c,setCustomType:d}=w(),h=k.Dc.toSM(c),u=null===(t=h.tabs.find(e=>e.key===r))||void 0===t?void 0:t.sliceZone,p=null!==(o=null===(n=h.tabs.find(e=>e.key===r))||void 0===n?void 0:n.value)&&void 0!==o?o:[],f="page"===h.format&&h.repeatable?p.filter(e=>"uid"!==e.key):p,g=h.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,G.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 o=Z.C[i.type];try{o.schema.validateSync(i,{stripUnknown:!1})}catch(e){throw Error('Add field: Model is invalid for field "'.concat(i.type,'".'))}let l=k.L$.fromSM(i);d({customType:(0,m.xS)({customType:c,newField:l,newFieldId:n,sectionId:r}),onSaveCallback:()=>{F.Am.success("".concat("Group"===i.type?"Group":"Field"," added"))}}),(0,R.V)({id:n,field:l})},b=e=>{let{apiId:t,newKey:n,value:i,inGroupFieldAction:a,updateMeta:o}=e;if((0,G.Ss)(Z.C,i.type))return;let l=k.L$.fromSM(i);d({customType:(0,m.L4)({customType:c,previousFieldId:t,newFieldId:n,newField:l,sectionId:r}),onSaveCallback:()=>{"add"===a&&F.Am.success("Field added")},updateMeta:o}),a||(0,H.Z)({previousId:t,id:n,field:l})};return(0,i.jsx)(U.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.D,{padding:32,children:(0,i.jsx)(a.bg,{})}),children:(0,i.jsxs)(O.aV,{border:!1,style:{flexGrow:1},children:[(0,i.jsx)(V.Z,{zoneType:"customType",zoneTypeFormat:null!==(l=c.format)&&void 0!==l?l:"custom",tabId:r,title:"Static zone",dataTip:"",fields:f,poolOfFieldsToCheck:g,showHints:!0,EditModal:K.Z,widgetsArray:eJ,onDeleteItem:e=>{d({customType:(0,m.AK)({customType:c,fieldId:e,sectionId:r})})},onSave:e=>""===e.apiId?x({...e,apiId:e.newKey}):b(e),onDragEnd:e=>{if((0,G.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:r});(0,P.flushSync)(()=>d({customType:i}))},renderHintBase:e=>{let{item:t}=e;return"data".concat((0,B.Ti)(t.key))},renderFieldAccessor:e=>"data".concat((0,B.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:c.repeatable}),(0,i.jsx)(e$,{customType:h,tabId:r,sliceZone:u,onRemoveSharedSlice:e=>{d({customType:(0,m.EN)({customType:c,sectionId:r,sliceId:e})})},onCreateSliceZone:()=>{d({customType:(0,m.Tr)(c,r)})},onDeleteSliceZone:()=>{d({customType:(0,m.E3)(c,r)})}})]})})})};let e0=()=>{var e,t,n;let{customType:o,setCustomType:l}=w(),r=k.Dc.toSM(o),[c,d]=(0,s.useState)(null===(e=r.tabs[0])||void 0===e?void 0:e.key),[h,u]=(0,s.useState)(),p=(null===(n=r.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.c9,{sx:p?{flexGrow:1}:void 0,children:["page"===o.format?(0,i.jsx)(a.ca,{title:o.repeatable?(0,i.jsx)(I,{}):void 0}):void 0,(0,i.jsxs)(a.cb,{onValueChange:d,value:c,children:[(0,i.jsx)(a.cd,{onAddNewTab:()=>{u({type:"CREATE_CUSTOM_TYPE_TAB"})},children:r.tabs.map(e=>(0,i.jsx)(a.ce,{menu:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.at,{onSelect:()=>{u({type:"UPDATE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aX,{name:"edit"}),children:"Rename"}),(0,i.jsx)(a.at,{color:"tomato",disabled:function(e){if(r.tabs.length<=1)return!0;let t=r.tabs.find(e=>e.value.find(e=>"uid"===e.key));return"page"===o.format&&o.repeatable&&(null==t?void 0:t.key)===e}(e.key),onSelect:()=>{u({type:"DELETE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aX,{name:"delete"}),children:"Remove"})]}),value:e.key,children:e.key},e.key))}),r.tabs.map(e=>(0,i.jsx)(a.cc,{value:e.key,children:(0,i.jsx)(eQ,{tabId:e.key})},e.key))]})]}),(null==h?void 0:h.type)==="CREATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(z,{close:()=>{u(void 0)},isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.vB)(o,t)}),d(t)},tabIds:r.tabs.map(e=>e.key.toLowerCase())}):void 0,(null==h?void 0:h.type)==="UPDATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(M,{close:()=>{u(void 0)},initialTabKey:h.tabKey,isOpen:!0,onSubmit:e=>{let{id:t}=e;l({customType:(0,m.HO)(o,h.tabKey,t)}),c===h.tabKey&&d(t)},tabIds:r.tabs.filter(e=>e.key!==h.tabKey).map(e=>e.key.toLowerCase())}):void 0,(null==h?void 0:h.type)==="DELETE_CUSTOM_TYPE_TAB"?(0,i.jsx)(N,{close:()=>{u(void 0)},isOpen:!0,onSubmit:()=>{if(l({customType:(0,m.F$)(o,h.tabKey)}),c===h.tabKey){var e;let t=null===(e=r.tabs.find(e=>e.key!==h.tabKey))||void 0===e?void 0:e.key;void 0!==t&&d(t)}}}):void 0]})};var e1=n(16442),e4=n(78254),e6=n(60867),e8=n(11166),e2=n(34919),e3=n.n(e2);let e5=e=>{let{tabs:t,...n}=e;return(0,i.jsxs)(e8.fC,{...n,className:e3().root,defaultValue:t[0].label,orientation:"vertical",children:[(0,i.jsx)(e8.aV,{className:e3().list,"aria-label":"content tabs",children:t.map((e,t)=>{let{label:n}=e;return(0,i.jsx)(e8.xz,{className:e3().trigger,value:n,children:(0,i.jsx)(a.bL,{className:e3().triggerText,component:"span",color:"inherit",children:n})},"".concat(n,"-trig").concat(t+1))})}),t.map((e,t)=>{let{label:n,content:o}=e;return(0,i.jsx)(e8.VY,{className:e3().content,value:n,children:(0,i.jsx)(a.bn,{className:e3().scrollArea,children:o})},"".concat(n,"-content").concat(t+1))})]})};var e9=n(25661),e7=n(88241),te=n(32554),tt=n(44621),tn=n.n(tt);let ti=e=>{var t,n;let{inline:o,...l}=e,r=(0,te.p)();if(!0===o)return(0,i.jsx)("code",{...l,className:tn().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.W,{...l,onCopy:()=>{g.Xe.track({event:"page-type:copy-snippet",framework:r})},language:c,code:String(l.children).replace(/\n$/,""),title:null==s?void 0:s.fileName})},ta=e=>{let{markdown:t}=e;return(0,i.jsx)(e9.D,{children:t,linkTarget:"_blank",remarkPlugins:[e7.Z],components:{code:e=>(0,i.jsx)(ti,{...e}),h1:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h1",variant:"h1"}),h2:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h2",variant:"h2"}),h3:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h3",variant:"h3"}),h4:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),h5:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),p:e=>(0,i.jsx)(a.bL,{className:tn().section,children:e.children,component:"p",variant:"normal"}),pre:e=>(0,i.jsx)(a.bL,{className:tn().section,children:e.children,component:"pre",variant:"normal"})}})};async function to(e){let t=JSON.parse(e),{errors:n,documentation:i}=await W.managerClient.documentation.read({kind:t.kind,data:t.data});if(n.length>0)throw n;return i}var tl=n(65480),tr=n.n(tl);let ts=e=>{var t;let{model:n}=e,o=(0,te.p)(),l=(t={kind:"PageSnippet",data:{model:n}},(0,ev.QT)(to,[JSON.stringify(t)])),{completeStep:r}=(0,Y.k)();return 0===l.length?null:(0,i.jsxs)(a.ae,{size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",onClick:()=>{r("codePage"),g.Xe.track({event:"page-type:open-snippet",framework:o})},startIcon:"code",children:"Page snippet"}),children:[(0,i.jsx)(a.al,{icon:"code",title:"Page snippet"}),(0,i.jsx)("section",{className:tr().content,children:l.length>1?(0,i.jsx)(e5,{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)(ta,{markdown:a})}})}):(0,i.jsx)(a.bn,{style:{flex:1,padding:16},children:(0,i.jsx)(ta,{markdown:l[0].content})})})]})},tc=e=>{let{model:t}=e;return(0,i.jsx)("div",{children:(0,i.jsx)(U.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.E,{color:"grey",startIcon:"code",children:"Page snippet"}),children:(0,i.jsx)(ts,{model:t})})})})},td=()=>{let e=(0,r.useRouter)(),{selectedCustomType:t}=(0,c.v9)(t=>({selectedCustomType:(0,e4.Jk)(t,(0,u.Ag)(e.query))}));return((0,s.useEffect)(()=>{t&&(0,e1.TG)(t)||e.replace("/")},[t,e]),t&&(0,e1.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)(tm,{customType:t.local})]}):(0,i.jsx)(p.LN,{})},tm=e=>{let{customType:t}=e;return null===t?(0,i.jsx)(p.LN,{}):(0,i.jsx)(p.LN,{children:(0,i.jsx)(S,{initialCustomType:k.Dc.fromSM(t),children:e=>{var n;let{actionQueueStatus:o,customType:l,setCustomType:r}=e,s=(0,m.y6)(l),c=u.cd[t.format],f=v.$[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:f.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)(h.X,{status:o}),"page"===l.format?(0,i.jsx)(tc,{model:l}):void 0,(0,i.jsx)(e6._,{isChangesLocal:!0,format:s,customType:l,setLocalCustomType:r})]})]}),(0,i.jsx)(p.RN,{children:(0,i.jsx)(a.D,{flexDirection:"column",minWidth:0,children:(0,i.jsx)(e0,{})})})]})}})})}},84879:function(e,t,n){"use strict";n.d(t,{E:function(){return l}});var i=n(18566),a=n(80148);async function o(){return a.managerClient.project.getSliceMachineConfig()}function l(e){var t,n;let[l,r]=[(0,i.QT)(o,[]),async e=>{await a.managerClient.project.writeSliceMachineConfig({config:e}),(0,i.VA)(o,[],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 r(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"}}}]);
|