slice-machine-ui 2.20.1-beta.5 → 2.20.2-alpha.lg-import-slices.1
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/-rx3Dikh863L90KD25ytx/_buildManifest.js +1 -0
- package/out/_next/static/chunks/130-e1a16d2f94fb2b64.js +1 -0
- package/out/_next/static/chunks/422-10a9f299957417bb.js +1 -0
- package/out/_next/static/chunks/{429-aab52070cad2884b.js → 429-e5d7e39160de9f5e.js} +1 -1
- package/out/_next/static/chunks/489-c9535ef34da63d1a.js +1 -0
- package/out/_next/static/chunks/585-c89bb2471e85b9f8.js +1 -0
- package/out/_next/static/chunks/954-bedaaabf664584a0.js +1 -0
- package/out/_next/static/chunks/pages/{_app-e595114a0455ad49.js → _app-2566e110112a7719.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-6d613b67e6967ae5.js → [customTypeId]-273e9a82c085b596.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-40207b66190e3fcd.js → [pageTypeId]-3fa7667de1a790d9.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-faeb6d2f77d97096.js → simulator-8c70298caf51bed0.js} +1 -1
- package/out/_next/static/chunks/pages/slices-76679cf064761d2b.js +1 -0
- 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 -4
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/ImportSlicesFromLibraryModal.tsx +336 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/SliceCard.tsx +48 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/hooks/useImportSlicesFromGithub.ts +91 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/index.tsx +1 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/types.ts +28 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/addSlices.ts +186 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/github.ts +657 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/mapWithConcurrency.ts +28 -0
- package/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/utils/sliceWithoutConflicts.ts +51 -0
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +11 -0
- package/src/features/customTypes/customTypesBuilder/shared/getSubmitButtonLabel.ts +12 -0
- package/src/features/customTypes/customTypesBuilder/shared/useExistingSlices.ts +26 -0
- package/src/features/customTypes/customTypesBuilder/sliceCreationOptions.tsx +14 -0
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +51 -0
- package/src/pages/slices.tsx +30 -0
- package/out/_next/static/9LzZngwZPG59uAvDGA4B-/_buildManifest.js +0 -1
- package/out/_next/static/chunks/422-c9192a1dbdd2ae0e.js +0 -1
- package/out/_next/static/chunks/489-32281540712d98bb.js +0 -1
- package/out/_next/static/chunks/633-152bf078e5366a0c.js +0 -1
- package/out/_next/static/chunks/pages/slices-ec56b94b35794675.js +0 -1
- /package/out/_next/static/{9LzZngwZPG59uAvDGA4B- → -rx3Dikh863L90KD25ytx}/_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/bc89f2cd4e4781f5.css" as="style"/><link rel="stylesheet" href="/_next/static/css/bc89f2cd4e4781f5.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-24ddb02bea621501.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/bc89f2cd4e4781f5.css" as="style"/><link rel="stylesheet" href="/_next/static/css/bc89f2cd4e4781f5.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-24ddb02bea621501.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-2566e110112a7719.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/-rx3Dikh863L90KD25ytx/_buildManifest.js" defer=""></script><script src="/_next/static/-rx3Dikh863L90KD25ytx/_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":"-rx3Dikh863L90KD25ytx","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,b,n,d,u,f,h,k,j,l,p,g,o,r,m,_,y,I,N,T){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,t,r,m,"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-8514e0696e90a1b2.js"],"/changes":[c,b,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",e,u,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-e66094f57453cf9c.js"],"/custom-types":[s,t,r,m,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,f,h,k,j,s,a,i,n,d,l,p,_,e,t,g,o,y,I,"static/chunks/pages/custom-types/[customTypeId]-273e9a82c085b596.js"],"/labs":["static/chunks/pages/labs-56fd818a63553497.js"],"/page-types/[pageTypeId]":[c,f,h,k,j,s,a,i,n,d,l,p,_,e,t,g,o,y,I,"static/chunks/pages/page-types/[pageTypeId]-3fa7667de1a790d9.js"],"/slices":[c,b,N,s,a,n,d,p,T,e,o,u,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-76679cf064761d2b.js"],"/slices/[lib]/[sliceName]/[variation]":[c,b,f,h,k,j,N,s,a,i,n,l,T,"static/chunks/484-3e011e79c41f0342.js",e,g,u,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-22ffa2561ac66557.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[b,"static/chunks/72585f70-28b4d7d5384b3703.js",d,"static/chunks/429-e5d7e39160de9f5e.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-8c70298caf51bed0.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-48d61b2fabee28d8.js","static/chunks/647-aa094286bc248d52.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/344-b64f09e670634ed1.js","static/chunks/130-e1a16d2f94fb2b64.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/954-bedaaabf664584a0.js","static/chunks/630-2bf927bca082a191.js","static/chunks/422-10a9f299957417bb.js","static/chunks/248-84a5987f0499b074.js","static/css/4e475d945cf8a890.css","static/chunks/585-c89bb2471e85b9f8.js","static/chunks/489-c9535ef34da63d1a.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
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[130],{60130:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return a.default}});var r=s(n(27343)),u=s(n(46076)),l=s(n(85854)),o=s(n(95899)),f=s(n(15384)),a=s(n(25791)),d=s(n(77888)),i=s(n(49926)),c=s(n(9964));function s(e){return e&&e.__esModule?e:{default:e}}},2763:function(e,t){function n(e){return(e+64>>>9<<4)+14+1}function r(e,t){let n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function u(e,t,n,u,l,o){var f;return r((f=r(r(t,e),r(u,o)))<<l|f>>>32-l,n)}function l(e,t,n,r,l,o,f){return u(t&n|~t&r,e,t,l,o,f)}function o(e,t,n,r,l,o,f){return u(t&r|n&~r,e,t,l,o,f)}function f(e,t,n,r,l,o,f){return u(t^n^r,e,t,l,o,f)}function a(e,t,n,r,l,o,f){return u(n^(t|~r),e,t,l,o,f)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=function(e){if("string"==typeof e){let t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){let t=[],n=32*e.length,r="0123456789abcdef";for(let u=0;u<n;u+=8){let n=e[u>>5]>>>u%32&255,l=parseInt(r.charAt(n>>>4&15)+r.charAt(15&n),16);t.push(l)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[n(t)-1]=t;let u=1732584193,d=-271733879,i=-1732584194,c=271733878;for(let t=0;t<e.length;t+=16){let n=u,s=d,p=i,y=c;u=l(u,d,i,c,e[t],7,-680876936),c=l(c,u,d,i,e[t+1],12,-389564586),i=l(i,c,u,d,e[t+2],17,606105819),d=l(d,i,c,u,e[t+3],22,-1044525330),u=l(u,d,i,c,e[t+4],7,-176418897),c=l(c,u,d,i,e[t+5],12,1200080426),i=l(i,c,u,d,e[t+6],17,-1473231341),d=l(d,i,c,u,e[t+7],22,-45705983),u=l(u,d,i,c,e[t+8],7,1770035416),c=l(c,u,d,i,e[t+9],12,-1958414417),i=l(i,c,u,d,e[t+10],17,-42063),d=l(d,i,c,u,e[t+11],22,-1990404162),u=l(u,d,i,c,e[t+12],7,1804603682),c=l(c,u,d,i,e[t+13],12,-40341101),i=l(i,c,u,d,e[t+14],17,-1502002290),d=l(d,i,c,u,e[t+15],22,1236535329),u=o(u,d,i,c,e[t+1],5,-165796510),c=o(c,u,d,i,e[t+6],9,-1069501632),i=o(i,c,u,d,e[t+11],14,643717713),d=o(d,i,c,u,e[t],20,-373897302),u=o(u,d,i,c,e[t+5],5,-701558691),c=o(c,u,d,i,e[t+10],9,38016083),i=o(i,c,u,d,e[t+15],14,-660478335),d=o(d,i,c,u,e[t+4],20,-405537848),u=o(u,d,i,c,e[t+9],5,568446438),c=o(c,u,d,i,e[t+14],9,-1019803690),i=o(i,c,u,d,e[t+3],14,-187363961),d=o(d,i,c,u,e[t+8],20,1163531501),u=o(u,d,i,c,e[t+13],5,-1444681467),c=o(c,u,d,i,e[t+2],9,-51403784),i=o(i,c,u,d,e[t+7],14,1735328473),d=o(d,i,c,u,e[t+12],20,-1926607734),u=f(u,d,i,c,e[t+5],4,-378558),c=f(c,u,d,i,e[t+8],11,-2022574463),i=f(i,c,u,d,e[t+11],16,1839030562),d=f(d,i,c,u,e[t+14],23,-35309556),u=f(u,d,i,c,e[t+1],4,-1530992060),c=f(c,u,d,i,e[t+4],11,1272893353),i=f(i,c,u,d,e[t+7],16,-155497632),d=f(d,i,c,u,e[t+10],23,-1094730640),u=f(u,d,i,c,e[t+13],4,681279174),c=f(c,u,d,i,e[t],11,-358537222),i=f(i,c,u,d,e[t+3],16,-722521979),d=f(d,i,c,u,e[t+6],23,76029189),u=f(u,d,i,c,e[t+9],4,-640364487),c=f(c,u,d,i,e[t+12],11,-421815835),i=f(i,c,u,d,e[t+15],16,530742520),d=f(d,i,c,u,e[t+2],23,-995338651),u=a(u,d,i,c,e[t],6,-198630844),c=a(c,u,d,i,e[t+7],10,1126891415),i=a(i,c,u,d,e[t+14],15,-1416354905),d=a(d,i,c,u,e[t+5],21,-57434055),u=a(u,d,i,c,e[t+12],6,1700485571),c=a(c,u,d,i,e[t+3],10,-1894986606),i=a(i,c,u,d,e[t+10],15,-1051523),d=a(d,i,c,u,e[t+1],21,-2054922799),u=a(u,d,i,c,e[t+8],6,1873313359),c=a(c,u,d,i,e[t+15],10,-30611744),i=a(i,c,u,d,e[t+6],15,-1560198380),d=a(d,i,c,u,e[t+13],21,1309151649),u=a(u,d,i,c,e[t+4],6,-145523070),c=a(c,u,d,i,e[t+11],10,-1120210379),i=a(i,c,u,d,e[t+2],15,718787259),d=a(d,i,c,u,e[t+9],21,-343485551),u=r(u,n),d=r(d,s),i=r(i,p),c=r(c,y)}return[u,d,i,c]}(function(e){if(0===e.length)return[];let t=8*e.length,r=new Uint32Array(n(t));for(let n=0;n<t;n+=8)r[n>>5]|=(255&e[n/8])<<n%32;return r}(e),8*e.length))}},74267:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;let n="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);t.default={randomUUID:n}},15384:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default="00000000-0000-0000-0000-000000000000"},9964:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,u=(r=n(77888))&&r.__esModule?r:{default:r};t.default=function(e){let t;if(!(0,u.default)(e))throw TypeError("Invalid UUID");let n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}},76678:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},41874:function(e,t){let n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(r)};let r=new Uint8Array(16)},13254:function(e,t){function n(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=function(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){let t=unescape(encodeURIComponent(e));e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let u=Math.ceil((e.length/4+2)/16),l=Array(u);for(let t=0;t<u;++t){let n=new Uint32Array(16);for(let r=0;r<16;++r)n[r]=e[64*t+4*r]<<24|e[64*t+4*r+1]<<16|e[64*t+4*r+2]<<8|e[64*t+4*r+3];l[t]=n}l[u-1][14]=(e.length-1)*8/4294967296,l[u-1][14]=Math.floor(l[u-1][14]),l[u-1][15]=(e.length-1)*8&4294967295;for(let e=0;e<u;++e){let u=new Uint32Array(80);for(let t=0;t<16;++t)u[t]=l[e][t];for(let e=16;e<80;++e)u[e]=n(u[e-3]^u[e-8]^u[e-14]^u[e-16],1);let o=r[0],f=r[1],a=r[2],d=r[3],i=r[4];for(let e=0;e<80;++e){let r=Math.floor(e/20),l=n(o,5)+function(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}(r,f,a,d)+i+t[r]+u[e]>>>0;i=d,d=a,a=n(f,30)>>>0,f=o,o=l}r[0]=r[0]+o>>>0,r[1]=r[1]+f>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+d>>>0,r[4]=r[4]+i>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}},49926:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.unsafeStringify=o;var r,u=(r=n(77888))&&r.__esModule?r:{default:r};let l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).slice(1));function o(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}t.default=function(e,t=0){let n=o(e,t);if(!(0,u.default)(n))throw TypeError("Stringified UUID is invalid");return n}},27343:function(e,t,n){let r,u;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l,o=(l=n(41874))&&l.__esModule?l:{default:l},f=n(49926);let a=0,d=0;t.default=function(e,t,n){let l=t&&n||0,i=t||Array(16),c=(e=e||{}).node||r,s=void 0!==e.clockseq?e.clockseq:u;if(null==c||null==s){let t=e.random||(e.rng||o.default)();null==c&&(c=r=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==s&&(s=u=(t[6]<<8|t[7])&16383)}let p=void 0!==e.msecs?e.msecs:Date.now(),y=void 0!==e.nsecs?e.nsecs:d+1,v=p-a+(y-d)/1e4;if(v<0&&void 0===e.clockseq&&(s=s+1&16383),(v<0||p>a)&&void 0===e.nsecs&&(y=0),y>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");a=p,d=y,u=s;let _=((268435455&(p+=122192928e5))*1e4+y)%4294967296;i[l++]=_>>>24&255,i[l++]=_>>>16&255,i[l++]=_>>>8&255,i[l++]=255&_;let b=p/4294967296*1e4&268435455;i[l++]=b>>>8&255,i[l++]=255&b,i[l++]=b>>>24&15|16,i[l++]=b>>>16&255,i[l++]=s>>>8|128,i[l++]=255&s;for(let e=0;e<6;++e)i[l+e]=c[e];return t||(0,f.unsafeStringify)(i)}},46076:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=l(n(18679)),u=l(n(2763));function l(e){return e&&e.__esModule?e:{default:e}}let o=(0,r.default)("v3",48,u.default);t.default=o},18679:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0,t.default=function(e,t,n){function r(e,r,o,f){var a;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=(0,l.default)(r)),(null===(a=r)||void 0===a?void 0:a.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let d=new Uint8Array(16+e.length);if(d.set(r),d.set(e,r.length),(d=n(d))[6]=15&d[6]|t,d[8]=63&d[8]|128,o){f=f||0;for(let e=0;e<16;++e)o[f+e]=d[e];return o}return(0,u.unsafeStringify)(d)}try{r.name=e}catch(e){}return r.DNS=o,r.URL=f,r};var r,u=n(49926),l=(r=n(9964))&&r.__esModule?r:{default:r};let o="6ba7b810-9dad-11d1-80b4-00c04fd430c8";t.DNS=o;let f="6ba7b811-9dad-11d1-80b4-00c04fd430c8";t.URL=f},85854:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=o(n(74267)),u=o(n(41874)),l=n(49926);function o(e){return e&&e.__esModule?e:{default:e}}t.default=function(e,t,n){if(r.default.randomUUID&&!t&&!e)return r.default.randomUUID();let o=(e=e||{}).random||(e.rng||u.default)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return(0,l.unsafeStringify)(o)}},95899:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=l(n(18679)),u=l(n(13254));function l(e){return e&&e.__esModule?e:{default:e}}let o=(0,r.default)("v5",80,u.default);t.default=o},77888:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,u=(r=n(76678))&&r.__esModule?r:{default:r};t.default=function(e){return"string"==typeof e&&u.default.test(e)}},25791:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,u=(r=n(77888))&&r.__esModule?r:{default:r};t.default=function(e){if(!(0,u.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[422],{21446:function(e,t,n){n.d(t,{S:function(){return v}});var r=n(52322),a=n(74217),i=n(11699),o=n(5632),s=n(2784),l=n(76473),c=n(88932),d=n(30195),u=n(94160),m=n(34166),g=n(98250),h=n(68968),f=n(96317);let p=(0,s.forwardRef)((e,t)=>{let{width:n,height:a}=e;return void 0===n&&void 0===a&&(n=10,a=16),(0,r.jsxs)("svg",{ref:t,viewBox:"0 0 10 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",height:a,width:n,children:[(0,r.jsx)("path",{d:"M5 7.83323C5 6.45253 6.11928 5.33325 7.49997 5.33325C8.8807 5.33325 10 6.45255 10 7.83328V8.16656C10 9.54728 8.8807 10.6666 7.49997 10.6666C6.11928 10.6666 5 9.54731 5 8.16661V7.83323Z",fill:"#1ABCFE"}),(0,r.jsx)("path",{d:"M0 13.3334C0 11.8607 1.19391 10.6667 2.66667 10.6667H5V13.5001C5 14.8808 3.88071 16.0001 2.5 16.0001C1.11929 16.0001 0 14.8808 0 13.5001L0 13.3334Z",fill:"#0ACF83"}),(0,r.jsx)("path",{d:"M5 0V5.33333H7.33333C8.80609 5.33333 10 4.13943 10 2.66667C10 1.19391 8.80609 0 7.33333 0L5 0Z",fill:"#FF7262"}),(0,r.jsx)("path",{d:"M0 2.66659C0 4.13934 1.19391 5.33325 2.66667 5.33325L5 5.33325L5 -8.15392e-05L2.66667 -8.15392e-05C1.19391 -8.15392e-05 0 1.19383 0 2.66659Z",fill:"#F24E1E"}),(0,r.jsx)("path",{d:"M0 8.00008C0 9.47284 1.19391 10.6667 2.66667 10.6667H5L5 5.33341L2.66667 5.33341C1.19391 5.33341 0 6.52732 0 8.00008Z",fill:"#A259FF"})]})});var y=n(80148),w=n(54597),x=n(62434),b=n(56141);function j(e){let t;let{slice:n}=e,a="uploading"===n.status||"generating"===n.status,o="uploadError"===n.status||"generateError"===n.status||"cancelled"===n.status,s="pending"===n.status||"generateError"===n.status||"generating"===n.status||"success"===n.status||"cancelled"===n.status;return o?t=(0,r.jsx)(i.E,{startIcon:"refresh",color:"grey",onClick:n.onRetry,children:"Retry"}):"figma"===n.source&&(t=(0,r.jsx)(i.c3,{content:"Pasted from Figma",children:(0,r.jsx)(b.S,{})})),(0,r.jsxs)(x.Zb,{disabled:a,children:[s?(0,r.jsx)(x.ZB,{src:n.thumbnailUrl}):(0,r.jsx)(x.ZB,{component:"div"}),(0,r.jsx)(x.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":case"cancelled":return"close";case"pending":return"image";case"success":return"check";default:return}}(n.status),title:"success"===n.status?n.model.name:"figma"===n.source?n.image.name.split(".")[0]:n.image.name,subtitle:function(e){switch(e.status){case"uploading":return"Uploading...";case"pending":var t;return(t=e.image.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," kB"):"".concat((t/1048576).toFixed(1)," MB");case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"cancelled":return"Cancelled";case"success":return"Generated"}}(n),error:o,action:t})]})}let S=d.z.object({__type:d.z.literal("figma-to-prismic/clipboard-data"),name:d.z.string(),image:d.z.string().startsWith("data:image/")});function v(e){let{open:t,location:n,onSuccess:d,onClose:f}=e,x=(0,o.useRouter)(),[b,v]=(0,s.useState)([]),[F,E]=(0,s.useState)(!1),[D,z]=(0,s.useState)(!1),{syncChanges:L}=(0,h.g)(),{createSliceSuccess:U}=(0,w.Z)(),{completeStep:P}=(0,g.k)(),B=function(e){let{open:t}=e,n=(0,s.useRef)([]);return(0,s.useEffect)(()=>{t&&(n.current=[],y.managerClient.slices.readAllSlices().then(e=>{n.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),n}({open:t}),G=k(),{libraryID:N,isLoading:R}=function(){let[e,t]=(0,s.useState)();return(0,s.useEffect)(()=>{y.managerClient.project.getSliceMachineConfig().then(e=>{var n;let r=null==e?void 0:null===(n=e.libraries)||void 0===n?void 0:n[0];if(void 0===r)throw Error("No library found in the config.");t(r)}).catch(()=>{throw Error("Could not get library ID from the config.")})},[]),{libraryID:e,isLoading:void 0===e}}(),H=(0,a.R9)(X),_=(0,s.useRef)(crypto.randomUUID());(0,l.y1)(["meta+v","ctrl+v"],e=>{e.preventDefault(),$()},{enabled:t&&G}),(0,s.useEffect)(()=>{if(!b.some(e=>"generating"===e.status))return;let e=e=>{H();let t="Your current generating slices will be cancelled.";return e.returnValue=t,t};return x.events.on("routeChangeStart",H),window.addEventListener("beforeunload",e),()=>{x.events.off("routeChangeStart",H),window.removeEventListener("beforeunload",e)}},[b,x.events,H]);let M=e=>{let{index:t,slice:n}=e;v(e=>e.map((e,r)=>r===t?n(e):e))},Z=e=>{if(q)return;if(e.length>10){c.Am.error("You can only upload ".concat(10," images at a time."));return}let t=b.length;v(t=>[...t,...e.map(e=>({source:"upload",status:"uploading",image:e}))]),e.forEach((e,n)=>{T({index:t+n,image:e,source:"upload"})})},T=async e=>{let{index:t,image:n,source:r}=e,a=_.current;M({index:t,slice:e=>({...e,status:"uploading",image:n,source:r})});try{let e=await I({image:n});if(a!==_.current)return;M({index:t,slice:t=>({...t,status:"pending",thumbnailUrl:e})})}catch(e){if(a!==_.current)return;M({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>void T({index:t,image:n,source:r})})})}},O=async e=>{if(void 0===N)return;let{index:t,imageUrl:r,source:a}=e,i=_.current,o=crypto.randomUUID();M({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:r,requestId:o})});try{let e=await y.managerClient.customTypes.inferSlice({source:a,libraryID:N,imageUrl:r,requestId:o});if(i!==_.current)return;let s=function(e){let{existingSlices:t,newSlices:n,slice:r}=e,a=new Set,i=new Set;for(let{id:e,name:n}of t)a.add(e),i.add(n.toLowerCase());for(let e of n)"success"===e.status&&(a.add(e.model.id),i.add(e.model.name.toLowerCase()));let o=r.id,s=2;for(;a.has(o);)o="".concat(r.id,"_").concat(s),s++;let l=r.name;for(s=2;i.has(l.toLowerCase());)l="".concat(r.name).concat(s),s++;return{...r,id:o,name:l}}({existingSlices:B.current,newSlices:b,slice:e.slice});if(v(n=>n.map((n,a)=>a!==t?n:{...n,status:"success",thumbnailUrl:r,model:s,langSmithUrl:e.langSmithUrl})),"upload"===a){i=_.current;let e=b[t],{errors:n}=await y.managerClient.slices.createSlice({libraryID:N,model:s});if(n.length)throw Error("Failed to create slice ".concat(s.id,"."));if(await y.managerClient.slices.updateSliceScreenshot({libraryID:N,sliceID:s.id,variationID:s.variations[0].id,data:e.image}),i!==_.current)return}P("createSlice"),u.Xe.track({event:"slice:created",id:s.id,name:s.name,library:N,location:n,..."figma"===a?{mode:"figma-to-slice"}:{mode:"ai",langSmithUrl:e.langSmithUrl}}),(0,m.nZ)({type:"model",library:N,sliceId:s.id,variationId:s.variations[0].id,langSmithUrl:e.langSmithUrl})}catch(e){if(i!==_.current)return;M({index:t,slice:n=>({...n,status:e instanceof Error&&"AbortError"===e.name?"cancelled":"generateError",thumbnailUrl:r,onRetry:()=>{O({index:t,imageUrl:r,source:a})}})})}},W=b.reduce((e,t)=>("generating"===t.status?e.generating++:"uploading"===t.status?e.uploading++:"pending"===t.status?e.pending++:"success"===t.status&&e.completed++,e.loading=e.generating+e.uploading,e.generate=e.loading+e.pending,e),{generating:0,uploading:0,pending:0,completed:0,loading:0,generate:0}),q=W.generating>0||W.completed>0,V=()=>{W.loading>0||(f(),_.current=crypto.randomUUID(),setTimeout(()=>v([]),250))},J=async()=>{if(void 0!==N)try{E(!0);let e=await (0,u.y0)();U(e.libraries),L(),d({slices:b.flatMap(e=>"success"===e.status?e.model:[]),library:N}),V()}finally{E(!1)}},$=async()=>{var e;if(!(!t||!G||b.some(e=>"figma"===e.source)||b.some(e=>"uploading"===e.status||"generating"===e.status))){if("function"!=typeof(null===(e=navigator.clipboard)||void 0===e?void 0:e.read)){c.Am.error("Clipboard paste is not supported in this browser.");return}try{let e=await navigator.clipboard.read();if(0===e.length){c.Am.error("No data found in clipboard.");return}let t="pasted-image.png",n=null,r=!1;for(let t of e){let e=t.types.find(e=>e.startsWith("image/"));if(void 0!==e){n=await t.getType(e);break}}for(let a of e)if(a.types.includes("text/plain"))try{let e=await a.getType("text/plain"),i=await e.text(),o=S.safeParse(JSON.parse(i));if(o.success){r=!0;let e=o.data;if(t="".concat(e.name,".png"),!n){let t=await fetch(e.image);n=await t.blob()}}else console.warn("Clipboard data validation failed:",o.error)}catch(e){console.warn("Failed to parse JSON from clipboard:",e)}if(!n){r?c.Am.error("Could not extract Figma data from clipboard. Please try copying again using the Prismic Figma plugin."):c.Am.error("No Figma data found in clipboard. Make sure you've copied a design using the Prismic Figma plugin.");return}let a=b.length;if(a>=10){c.Am.error("You can only upload ".concat(10," images at a time."));return}let i=new File([n],t,{type:n.type});v(e=>[...e,{source:"figma",status:"uploading",image:i}]),T({index:a,image:i,source:"figma"}),c.Am.success("Pasted ".concat(t).concat(r?" from Figma":""))}catch(e){console.error("Failed to paste from clipboard:",e),c.Am.error("Failed to paste from clipboard. Please check browser permissions and try again.")}}};function X(){let e=b.flatMap(e=>"generating"===e.status?[e.requestId]:[]);0!==e.length&&e.forEach(e=>{y.managerClient.customTypes.cancelInferSlice({requestId:e})})}return(0,r.jsxs)(i.ae,{open:t,onOpenChange:e=>!e&&V(),children:[(0,r.jsx)(i.al,{title:"Generate slices with AI"}),(0,r.jsxs)(i.aj,{gap:0,children:[(0,r.jsx)(i.ak,{hidden:!0,children:"Upload images to generate slices with AI"}),R?(0,r.jsx)(i.D,{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",children:(0,r.jsx)(i.bg,{color:"purple9"})}):(0,r.jsxs)(r.Fragment,{children:[0===b.length?(0,r.jsxs)(i.D,{padding:16,height:"100%",gap:16,display:"flex",flexDirection:"column",children:[G&&(0,r.jsxs)(i.D,{display:"flex",gap:16,alignItems:"center",backgroundColor:"grey2",padding:16,borderRadius:12,children:[(0,r.jsxs)(i.D,{display:"flex",gap:8,alignItems:"center",flexGrow:1,children:[(0,r.jsx)(i.D,{width:48,height:48,backgroundColor:"grey12",borderRadius:"100%",display:"flex",alignItems:"center",justifyContent:"center",children:(0,r.jsx)(p,{height:25})}),(0,r.jsxs)(i.D,{display:"flex",flexDirection:"column",flexGrow:1,children:[(0,r.jsx)(i.bL,{variant:"bold",children:"Want to work faster?"}),(0,r.jsx)(i.bL,{variant:"small",color:"grey11",children:"Copy frames from Figma with the Slice Machine plugin and paste them here."})]})]}),(0,r.jsx)(i.E,{endIcon:"arrowForward",color:"indigo",onClick:()=>window.open("https://www.figma.com/community/plugin/1567955296461153730/figma-to-slice","_blank"),sx:{marginRight:8},invisible:!0,children:"Install plugin"})]}),(0,r.jsx)(i.aF,{onFilesSelected:Z,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(C,{onFilesSelected:Z,onPaste:()=>void $(),droppingFiles:!0}),children:(0,r.jsx)(C,{onFilesSelected:Z,onPaste:()=>void $()})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.D,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:16,children:[(0,r.jsx)(i.bL,{variant:"h3",children:"Design"}),(0,r.jsx)(i.aG,{size:"medium",color:"grey",onFilesSelected:Z,startIcon:"attachFile",disabled:q,children:"Add images"})]}),(0,r.jsx)(i.bn,{stableScrollbar:!1,children:(0,r.jsx)(i.D,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:b.map((e,t)=>(0,r.jsx)(j,{slice:e},"slice-".concat(t)))})})]}),(0,r.jsxs)(i.ah,{children:[W.generating>0?(0,r.jsx)(i.ai,{onClick:()=>z(!0),size:"medium",sx:{marginRight:8},invisible:!0,children:"Cancel"}):(0,r.jsx)(i.ai,{onClick:()=>V(),size:"medium",sx:{marginRight:8},invisible:!0,children:"Close"}),0===W.completed||W.loading>0?(0,r.jsxs)(i.af,{color:"purple",startIcon:"autoFixHigh",onClick:()=>{void 0!==N&&b.forEach((e,t)=>{"pending"===e.status&&O({index:t,imageUrl:e.thumbnailUrl,source:e.source})})},disabled:q||W.loading>0||0===W.pending,loading:W.loading>0,size:"medium",children:["Generate ",W.generate>0?"(".concat(W.generate,") "):"",1===W.generate?"Slice":"Slices"]}):(0,r.jsx)(i.af,{color:"purple",onClick:()=>void J(),loading:F,size:"medium",children:A(n,W.completed)})]})]})]}),(0,r.jsxs)(i.ae,{size:"small",open:D,onOpenChange:z,children:[(0,r.jsx)(i.al,{title:"Cancel generation"}),(0,r.jsxs)(i.aj,{children:[(0,r.jsx)(i.ak,{children:(0,r.jsx)(i.D,{display:"flex",flexDirection:"column",padding:{inline:16},children:(0,r.jsx)(i.bL,{variant:"bold",children:"Are you sure you want to cancel the generation for all slices?"})})}),(0,r.jsxs)(i.ah,{children:[(0,r.jsx)(i.ai,{onClick:()=>z(!1),size:"small",children:"Keep generating"}),(0,r.jsx)(i.af,{color:"tomato",onClick:()=>{z(!1),X()},size:"small",children:"Confirm"})]})]})]})]})}function C(e){let{droppingFiles:t=!1,onFilesSelected:n,onPaste:a}=e,o=k();return(0,r.jsx)(i.D,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:t?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:t?"purple9":"grey6",borderRadius:12,flexGrow:1,children:(0,r.jsx)(i.s,{children:(0,r.jsxs)(i.D,{display:"flex",flexDirection:"column",gap:16,alignItems:"center",children:[(0,r.jsx)(i.x,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(i.D,{display:"flex",flexDirection:"column",gap:4,alignItems:"center",children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.bL,{children:"Generate slices from your designs"}),(0,r.jsx)(i.bL,{variant:"small",color:"grey11",children:"Upload your design images or paste them directly from Figma."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.bL,{children:"Upload your design images."}),(0,r.jsx)(i.bL,{variant:"small",color:"grey11",children:"Once uploaded, you can generate slices automatically using AI."})]})}),(0,r.jsx)(i.D,{display:"flex",alignItems:"center",gap:16,children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.E,{size:"small",renderStartIcon:()=>(0,r.jsx)(p,{height:16}),color:"grey",onClick:a,children:"Paste from Figma"}),(0,r.jsx)(i.aG,{size:"small",onFilesSelected:n,color:"purple",invisible:!0,children:"Add images"})]}):(0,r.jsx)(i.aG,{startIcon:"attachFile",onFilesSelected:n,color:"grey",children:"Add images"})})]})})})}async function I(e){let{image:t}=e,n=[await y.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await y.managerClient.screenshots.initS3ACL();let{url:r}=await y.managerClient.screenshots.uploadScreenshot({keyPrefix:n,data:t});return r}let A=(e,t)=>{switch(e){case"custom_type":return"Add to type (".concat(t,")");case"page_type":return"Add to page (".concat(t,")");case"slices":return"Done"}};function k(){let e=(0,f.L)("llm-proxy-access");return(null==e?void 0:e.value)==="on"}},51967:function(e,t,n){n.d(t,{w:function(){return k}});var r=n(52322),a=n(11699),i=n(2784),o=n(88932),s=n(94160),l=n(98250),c=n(68968),d=n(54597);let u=e=>{switch(e){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to slices"}};var m=n(80148),g=n(74686),h=n(88866),f=n(30195);async function p(e,t,n){let r=Array(e.length),a=0,i=Array(Math.min(t,e.length)).fill(null).map(async()=>{for(;;){let t=a++;if(t>=e.length)break;r[t]=await n(e[t],t)}});return await Promise.all(i),r}class y{getHeaders(){let e={Accept:"application/vnd.github.v3+json"};return this.token&&(e.Authorization="Bearer ".concat(this.token)),e}async request(e,t){let n="".concat(this.baseUrl).concat(e),r=await fetch(n,{...t,headers:{...this.getHeaders(),...null==t?void 0:t.headers}});if(!r.ok)throw Error("GitHub API request failed: ".concat(r.status," ").concat(r.statusText));return r.json()}async getDefaultBranch(){let e=await this.request("/repos/".concat(this.owner,"/").concat(this.repo));return f.z.object({default_branch:f.z.string()}).parse(e).default_branch}async getFileContents(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e,"?ref=").concat(t)),a=f.z.object({content:f.z.string(),encoding:f.z.string()}).parse(r);if("base64"!==a.encoding)throw Error("Unexpected encoding for ".concat(e,": ").concat(a.encoding));let i=atob(a.content.replace(/\s/g,""));if(!n)return i;{let e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e.buffer}}async getDirectoryContents(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e));return f.z.array(f.z.object({name:f.z.string(),type:f.z.string(),path:f.z.string()})).parse(t)}async searchCode(e){let{path:t,filename:n}=e,r=[];t&&r.push("path:".concat(t)),n&&r.push("filename:".concat(n)),r.push("repo:".concat(this.owner,"/").concat(this.repo));let a="/search/code?q=".concat(encodeURIComponent(r.join(" "))),i=await this.request(a);return f.z.object({items:f.z.array(f.z.object({path:f.z.string(),name:f.z.string()})).optional(),total_count:f.z.number().optional()}).parse(i)}async getSliceLibraries(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/slicemachine.config.json?ref=").concat(e)),n=f.z.object({content:f.z.string().optional(),encoding:f.z.string().optional()}).parse(t);if("string"==typeof n.content){let e=atob(n.content.replace(/\s/g,""));return f.z.object({libraries:f.z.array(f.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 w=e=>{let t=e.match(/github\.com\/([^\/]+)\/([^\/]+)(?:\/|$)/);if(!t)throw Error("Invalid GitHub URL format");let[,n,r]=t;return{owner:n,repo:r.replace(/\.git$/,"")}},x=async e=>{let{owner:t,repo:n}=e;return new y({owner:t,repo:n}).getDefaultBranch()},b=async e=>{let{owner:t,repo:n,branch:r}=e;return new y({owner:t,repo:n}).getSliceLibraries(r)},j=async e=>{let{owner:t,repo:n,branch:r,libraries:a}=e,i=new y({owner:t,repo:n}),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 i.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 r=await i.searchCode({path:t,filename:"model.json"});if(r.items&&r.items.length>0){let a=new Set;for(let e of r.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 s=async e=>{try{let t,n,a,s;let l=await i.getFileContents("".concat(e.path,"/model.json"),r,!1);if("string"!=typeof l){console.warn("Failed to fetch model.json for slice: ".concat(e.name," - unexpected content type"));return}let c=h.SharedSlice.decode(JSON.parse(l));if("Left"===c._tag){console.warn("Failed to decode model.json for slice: ".concat(e.name));return}let d=c.right,u=[];try{u=await S({api:i,branch:r,directoryPath:e.path}),console.log("Fetched ".concat(u.length," file(s) for slice ").concat(e.name,":"),u.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 r of u)if(void 0===t&&r.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/)&&"string"==typeof r.contents&&(t=r.contents),"mocks.json"===r.path&&"string"==typeof r.contents)try{let t=g.SharedSliceContent.decode(JSON.parse(r.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 m={};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 i.getFileContents(n,r,!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"});m[t.id]=n,void 0===a&&void 0!==d.variations[0]&&t.id===d.variations[0].id&&(a=URL.createObjectURL(e),s=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 f=null!=s?s:new File([],"".concat(d.name,".json"),{type:"application/json"}),p={image:f,thumbnailUrl:null!=a?a:URL.createObjectURL(f),model:d,files:u,componentContents:t,mocks:n,screenshots:Object.keys(m).length>0?m:void 0};o.push(p)}catch(t){console.warn("Error fetching slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}};await p(n,6,s)}return o},S=async e=>{let{api:t,branch:n,directoryPath:r}=e,a=[],i=!1;try{let e=await t.getDirectoryContents(r);i=!0;let o=e.filter(e=>"file"===e.type),s=e.filter(e=>"dir"===e.type);for(let e of(await p(o,8,async e=>{if("model.json"===e.name)return null;try{let r=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp"].some(t=>e.name.toLowerCase().endsWith(t)),a=await t.getFileContents(e.path,n,r);return{path:e.name,contents:a,isBinary:r}}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 s)for(let r of(await S({api:t,branch:n,directoryPath:e.path})))a.push({...r,path:"".concat(e.name,"/").concat(r.path)})}catch(e){console.warn("GitHub API failed for directory ".concat(r,", trying Search API..."),e instanceof Error?e.message:String(e))}if(!i)try{console.log("Using GitHub Search API to find all files in ".concat(r,"..."));let e=await t.searchCode({path:r});if(e.items&&e.items.length>0){for(let i of(console.log("Found ".concat(e.items.length," file(s) via Search API for ").concat(r)),await p(e.items,8,async e=>{try{if("model.json"===e.name)return null;let a=e.path.startsWith(r+"/")?e.path.slice(r.length+1):e.name,i=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp",".woff",".woff2",".ttf",".eot",".otf",".pdf",".zip",".gz"].some(t=>e.name.toLowerCase().endsWith(t)),o=await t.getFileContents(e.path,n,i);return{path:a,contents:o,isBinary:i}}catch(t){return console.warn("Error fetching file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))i&&a.push(i);console.log("Fetched ".concat(a.length," file(s) from ").concat(r," via Search API"))}else console.warn("GitHub Search API found no files in ".concat(r))}catch(t){let e=t instanceof Error?t.message:String(t);e.includes("403")?console.warn("GitHub Search API returned 403 for ".concat(r,". Cannot fetch files without API access.")):console.warn("Error using GitHub Search API for ".concat(r,":"),e)}return a};var v=n(62434);function C(e){let{thumbnailUrl:t,model:n,selected:i=!0,onSelectedChange:o}=e,s=(0,r.jsxs)(r.Fragment,{children:[void 0!==t&&t?(0,r.jsx)(v.ZB,{src:t}):(0,r.jsx)(v.ZB,{component:"div"}),(0,r.jsx)(v.eW,{title:n.name,action:(0,r.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,r.jsx)(a.U,{checked:i,onCheckedChange:o})})})]});return(0,r.jsx)(v.Zb,{interactive:!0,onClick:()=>{o(!i)},checked:i,size:"small",children:s})}async function I(e){let{libraries:t=[]}=await m.managerClient.project.getSliceMachineConfig(),n=t[0];if(!n)throw Error("No library found in the config.");await p(e,3,async e=>{let{errors:t}=await m.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 r=await p(e,3,async e=>{let{model:t,image:r,langSmithUrl:a,mocks:i,files:o,screenshots:s}=e;if(i&&Array.isArray(i)&&i.length>0){let{errors:e}=await m.managerClient.slices.updateSliceMocks({libraryID:n,sliceID:t.id,mocks:i});e.length&&console.warn("Failed to update mocks for slice ".concat(t.id,":"),e)}return s&&Object.keys(s).length>0?await Promise.all(Object.entries(s).map(async e=>{let[r,a]=e;a.size>0&&await m.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:r,data:a})})):r.size>0&&void 0!==t.variations&&t.variations.length>0&&await m.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:t.variations[0].id,data:r}),console.log("About to write files for slice ".concat(t.id,":"),o?"".concat(o.length," file(s) - ").concat(o.map(e=>e.path).join(", ")):"no files"),o&&o.length>0?await A({libraryID:n,sliceID:t.id,files:o}):console.warn("No files to write for slice ".concat(t.id,". Files:"),o),{model:t,langSmithUrl:a}});return{library:n,slices:r}}async function A(e){let{libraryID:t,sliceID:n,files:r}=e;if(0===r.length)return;let a=r.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))}),r=await m.managerClient.slices.writeSliceFiles({libraryID:t,sliceID:n,files:e});r.errors.length>0?console.error("Errors writing files for slice ".concat(n,":"),r.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 k(e){let{open:t,location:n,onSuccess:g,onClose:h}=e,[f,p]=(0,i.useState)(!1),[y,S]=(0,i.useState)(""),[v,A]=(0,i.useState)(new Set),{syncChanges:k}=(0,c.g)(),{createSliceSuccess:F,updateSliceMockSuccess:E}=(0,d.Z)(),{completeStep:D}=(0,l.k)(),z=function(e){let{open:t}=e,n=(0,i.useRef)([]);return(0,i.useEffect)(()=>{t&&(n.current=[],m.managerClient.slices.readAllSlices().then(e=>{n.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),n}({open:t}),{isLoadingSlices:L,handleImportFromGithub:U,slices:P,resetSlices:B}=function(){let[e,t]=(0,i.useState)(!1),[n,r]=(0,i.useState)([]);return{isLoadingSlices:e,slices:n,resetSlices:()=>{r([]),t(!1)},handleImportFromGithub:async e=>{try{let n;t(!0);let{owner:a,repo:i}=w(e);if(!a||!i){o.Am.error("Invalid GitHub URL format"),t(!1);return}let s=await x({owner:a,repo:i});try{n=await b({owner:a,repo:i,branch:s})}catch(e){console.error("Failed to fetch slicemachine.config.json:",e),o.Am.error("Failed to fetch slicemachine.config.json: ".concat(e instanceof Error?e.message:"Unknown error")),t(!1);return}if(0===n.length){console.warn("No libraries were found in the SM config."),t(!1),o.Am.error("No libraries were found in the SM config.");return}let l=await j({owner:a,repo:i,branch:s,libraries:n});if(0===l.length){o.Am.error("Error fetching slices from the repository"),t(!1);return}r(l),t(!1),o.Am.success("Found ".concat(l.length," slice(s) from ").concat(n.length," library/libraries"))}catch(e){console.error("Error importing from GitHub:",e),o.Am.error("Error importing from GitHub: ".concat(e instanceof Error?e.message:"Unknown error")),t(!1)}}}}();(0,i.useEffect)(()=>{if(0===P.length)return;let e=new Set;for(let t of P)e.add(t.model.id);A(e)},[P]);let G=(0,i.useRef)(crypto.randomUUID()),N=P.filter(e=>v.has(e.model.id)),R=P.length>0&&v.size===P.length,H=v.size>0&&v.size<P.length,_="Select all slices";return R?_="Selected all slices (".concat(v.size,")"):H&&(_="".concat(v.size," of ").concat(P.length," selected")),(0,r.jsxs)(a.ae,{open:t,onOpenChange:e=>{e||f||(h(),G.current=crypto.randomUUID(),S(""),A(new Set),B())},children:[(0,r.jsx)(a.al,{title:"Import slices from library"}),(0,r.jsxs)(a.aj,{gap:0,children:[(0,r.jsx)(a.ak,{hidden:!0,children:"Import slices from a github repository"}),0===P.length?(0,r.jsx)(a.D,{padding:16,height:"100%",flexDirection:"column",gap:16,children:(0,r.jsx)(a.D,{flexDirection:"column",gap:8,children:(0,r.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:8,padding:16,border:!0,borderRadius:8,children:[(0,r.jsx)(a.bL,{color:"grey11",children:"Import from GitHub"}),(0,r.jsx)(a.bN,{placeholder:"https://github.com/username/repository",value:y,onValueChange:S}),(0,r.jsx)(a.E,{onClick:()=>void U(y),disabled:!y.trim()||L,loading:L,color:"purple",children:L?"Loading slices...":"Import from GitHub"})]})})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.D,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:16,border:{bottom:!0},children:(0,r.jsx)(a.D,{display:"flex",alignItems:"center",gap:8,children:(0,r.jsx)(a.aR,{value:_,children:(0,r.jsx)(a.U,{checked:R,indeterminate:H,onCheckedChange:e=>{if(e){let e=new Set;for(let t of P)e.add(t.model.id);A(e)}else A(new Set)}})})})}),(0,r.jsx)(a.bn,{stableScrollbar:!1,children:(0,r.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:16,children:P.map(e=>(0,r.jsx)(C,{model:e.model,thumbnailUrl:e.thumbnailUrl,selected:v.has(e.model.id),onSelectedChange:t=>{t?A(t=>{let n=new Set(t);return n.add(e.model.id),n}):A(t=>{let n=new Set(t);return n.delete(e.model.id),n})}},e.model.id))})})]}),(0,r.jsxs)(a.ah,{children:[(0,r.jsx)(a.ai,{disabled:f}),(0,r.jsxs)(a.af,{disabled:0===N.length,loading:f,onClick:()=>{let e=P.reduce((e,t)=>(v.has(t.model.id)&&e.push({image:t.image,model:t.model,files:t.files,componentContents:t.componentContents,mocks:t.mocks,screenshots:t.screenshots}),e),[]);if(!e.length){o.Am.error("Please select at least one slice to import");return}let t=[];for(let n of e){let e=function(e){let{existingSlices:t,newSlices:n,slice:r}=e,a=new Set,i=new Set;for(let{id:e,name:n}of t)a.add(e),i.add(n.toLowerCase());for(let e of n)a.add(e.model.id),i.add(e.model.name.toLowerCase());let o=r.id,s=2;for(;a.has(o);)o="".concat(r.id,"_").concat(s),s++;let l=r.name;for(s=2;i.has(l.toLowerCase());)l="".concat(r.name).concat(s),s++;return{...r,id:o,name:l}}({existingSlices:z.current,newSlices:t,slice:n.model});t.push({...n,model:e})}let r=G.current;p(!0),I(t).then(async a=>{let{slices:i,library:o}=a;if(r===G.current){for(let n of(await new Promise(e=>setTimeout(e,100)),F((await (0,s.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),r=e.mocks&&e.mocks.length>0?e.mocks:null==n?void 0:n.mocks;return{...e,mocks:null!=r?r:e.mocks}})})),e))n.mocks&&Array.isArray(n.mocks)&&n.mocks.length>0&&E({libraryID:o,sliceID:n.model.id,mocks:n.mocks});for(let{model:e}of(k(),g({slices:i,library:o}),p(!1),G.current=crypto.randomUUID(),B(),D("createSlice"),i))s.Xe.track({event:"slice:created",id:e.id,name:e.name,library:o,location:n,mode:"import"})}}).catch(()=>{r===G.current&&(p(!1),o.Am.error("An unexpected error happened while adding slices."))})},children:[u(n)," (",N.length,")"]})]})]})]})}},27213:function(e,t,n){n.d(t,{F:function(){return i}});var r=n(52322),a=n(11699);let i=e=>{let{menuType:t}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(a.B,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a slice based on your design image."},fromScratch:{BackgroundIcon:(0,r.jsx)(a.B,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom slice your way."},fromTemplate:{BackgroundIcon:(0,r.jsx)(a.B,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(a.B,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing slice",description:"Select from your created slices."},importFromExternal:{BackgroundIcon:(0,r.jsx)(a.B,{name:"cloudUpload",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Add from external library",description:"Import slices from a github repository."}}}},6256:function(e,t,n){n.d(t,{c:function(){return x}});var r=n(52322),a=n(2784),i=n(36131),o=n(75289),s=n(94160),l=n(98250),c=n(88932),d=n(63908),u=n(358),m=n(80148);async function g(e){let{sliceName:t,libraryName:n,location:r,onSuccess:a}=e;try{let e=(0,d.fo)(t),{errors:i}=await m.managerClient.slices.createSlice({libraryID:n,model:e});if(i.length>0)throw i;s.Xe.track({event:"slice:created",id:(0,u.MP)(t),name:t,library:n,location:r,mode:"manual"}),await a(e)}catch(n){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,n),c.Am.error(e)}}var h=n(68968),f=n(59532),p=n(54597),y=n(46999),w=n(63019);let x=e=>{let{onClose:t,onSuccess:n,localLibraries:c,location:d,remoteSlices:u}=e,{createSliceSuccess:m}=(0,p.Z)(),[x,b]=(0,a.useState)(!1),{syncChanges:j}=(0,h.g)(),{completeStep:S}=(0,l.k)(),v=async e=>{let t=e.sliceName,r=e.from;b(!0),await g({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{m((await (0,s.y0)()).libraries),n(e,r),j(),S("createSlice")}})};return(0,r.jsx)(f.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:x,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{v(e)},initialValues:{sliceName:"",from:c[0].name},validate:e=>(0,w.h)(e,c,u),content:{title:"Create a new slice"},children:e=>{let{touched:t,values:n,setFieldValue:a,errors:s}=e;return(0,r.jsxs)(o.xu,{children:[(0,r.jsx)(y.W,{name:"sliceName",label:"Slice name",placeholder:"Pascalised slice API ID (e.g. TextBlock)",error:t.sliceName?s.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(o.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(i.ZP,{name:"from",options:c.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void a("from",e.value):null,defaultValue:{value:n.from,label:n.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,n){n.d(t,{h:function(){return l}});var r=n(96009),a=n.n(r),i=n(74600),o=n.n(i),s=n(7974);function l(e,t,n){let{sliceName:r}=e;return r?s.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:s.xo.exec(r)?o()(a()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...n.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,n){var r=n(52322),a=n(75289);t.Z=function(e){let{elems:t,renderElem:n,defineElementKey:i,gridTemplateMinPx:o="320px",gridGap:s="16px",sx:l}=e;return(0,r.jsx)(a.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(o,", 1fr))"),gridGap:s,pt:2,...l},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:n(e,t)},"".concat(i(e),"-").concat(t+1)):null)})}}}]);
|