@builder.io/dev-tools 1.41.2-beta.202604081155.f368de7 → 1.41.2-beta.202604081246.fe4cb67

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/cli/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var wLe=Object.create;var BD=Object.defineProperty;var bLe=Object.getOwnPropertyDescriptor;var vLe=Object.getOwnPropertyNames;var SLe=Object.getPrototypeOf,xLe=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gA=(t,e)=>{for(var r in e)BD(t,r,{get:e[r],enumerable:!0})},k5=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vLe(e))!xLe.call(t,i)&&i!==r&&BD(t,i,{get:()=>e[i],enumerable:!(n=bLe(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?wLe(SLe(t)):{},k5(e||!t||!t.__esModule?BD(r,"default",{value:t,enumerable:!0}):r,t)),mn=t=>k5(BD({},"__esModule",{value:!0}),t);var m=N(()=>{(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"f368de7b3f3d1794908b985c5caac0cf798e54a9"}}catch{}})()});var N5=k((TRt,R5)=>{m();function YN(t){return t==null?[]:Array.isArray(t)?t:[t]}function FLe(t,e,r,n){var i,o=t[e],s=~n.string.indexOf(e)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~n.boolean.indexOf(e)?r==="false"?!1:r==="true"||(t._.push((i=+r,i*0===0?i:r)),!!r):(i=+r,i*0===0?i:r);t[e]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}R5.exports=function(t,e){t=t||[],e=e||{};var r,n,i,o,s,a={_:[]},A=0,c=0,u=0,l=t.length;let p=e.alias!==void 0,g=e.unknown!==void 0,d=e.default!==void 0;if(e.alias=e.alias||{},e.string=YN(e.string),e.boolean=YN(e.boolean),p)for(r in e.alias)for(n=e.alias[r]=YN(e.alias[r]),A=0;A<n.length;A++)(e.alias[n[A]]=n.concat(r)).splice(A,1);for(A=e.boolean.length;A-- >0;)for(n=e.alias[e.boolean[A]]||[],c=n.length;c-- >0;)e.boolean.push(n[c]);for(A=e.string.length;A-- >0;)for(n=e.alias[e.string[A]]||[],c=n.length;c-- >0;)e.string.push(n[c]);if(d){for(r in e.default)if(o=typeof e.default[r],n=e.alias[r]=e.alias[r]||[],e[o]!==void 0)for(e[o].push(r),A=0;A<n.length;A++)e[o].push(n[A])}let f=g?Object.keys(e.alias):[];for(A=0;A<l;A++){if(i=t[A],i==="--"){a._=a._.concat(t.slice(++A));break}for(c=0;c<i.length&&i.charCodeAt(c)===45;c++);if(c===0)a._.push(i);else if(i.substring(c,c+3)==="no-"){if(o=i.substring(c+3),g&&!~f.indexOf(o))return e.unknown(i);a[o]=!1}else{for(u=c+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(o=i.substring(c,u),s=i.substring(++u)||A+1===l||(""+t[A+1]).charCodeAt(0)===45||t[++A],n=c===2?[o]:o,u=0;u<n.length;u++){if(o=n[u],g&&!~f.indexOf(o))return e.unknown("-".repeat(c)+o);FLe(a,o,u+1<n.length||s,e)}}}if(d)for(r in e.default)a[r]===void 0&&(a[r]=e.default[r]);if(p)for(r in a)for(n=e.alias[r]||[];n.length>0;)a[n.shift()]=a[r];return a}});function kLe(){if(PC!==void 0)return PC;try{return PC=require("prettier"),PC}catch{return PC=null,null}}function RLe(t){let e=[],r=bg.default.dirname(t);for(;r!==bg.default.dirname(r);){let n=bg.default.join(r,".prettierignore");qN.default.existsSync(n)&&e.push(n);let i=bg.default.join(r,".git");if(qN.default.existsSync(i))break;r=bg.default.dirname(r)}return e}function NLe(t){if(t)try{let r=(0,T5.createRequire)(t)("prettier");if(r)return r}catch{}return kLe()}async function bc(t,e,r,n){try{let i=bg.default.resolve(t,n??"file.tsx"),o=NLe(i);if(!o)return e;if(n){let A=RLe(i);if((await o.getFileInfo(i,{ignorePath:A.length>0?A:void 0})).ignored)return e}let s=await o.resolveConfig(i);return await o.format(e,{...s,filepath:n,parser:r})}catch{return e}}var T5,bg,qN,PC,VN=N(()=>{"use strict";m();T5=require("node:module"),bg=z(require("node:path"),1),qN=z(require("node:fs"),1)});var zN,Nd,yD,QD,M5,vg,WN,ZN,Sg,P5,Td=N(()=>{"use strict";m();zN="preview-url",Nd="framework",yD="platform",QD="node",M5="/~builder-connect",vg="/~builder-connected",WN="/~builder-dev-tools",ZN="/~builder-dev-tools.js",Sg="/~builder-dev-tools-close",P5="/mappings"});var DD=k((ORt,_5)=>{"use strict";m();var XN={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},TLe={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},MLe={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?XN.up():"");return t&&(e+=XN.left),e}};_5.exports={cursor:XN,scroll:TLe,erase:MLe,beep:"\x07"}});var Hr=k((KRt,eT)=>{m();var bD=process||{},L5=bD.argv||[],wD=bD.env||{},PLe=!(wD.NO_COLOR||L5.includes("--no-color"))&&(!!wD.FORCE_COLOR||L5.includes("--color")||bD.platform==="win32"||(bD.stdout||{}).isTTY&&wD.TERM!=="dumb"||!!wD.CI),_Le=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+LLe(i,e,r,o)+e:t+i+e},LLe=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},U5=(t=PLe)=>{let e=t?_Le:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};eT.exports=U5();eT.exports.createColors=U5});function ULe({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function z5(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(OLe,"")}function W5(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _C(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=z5(t),t.length===0))return 0;t=t.replace($Le()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(KLe.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function YLe(){let t=new Map;for(let[e,r]of Object.entries(en)){for(let[n,i]of Object.entries(r))en[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=en[n],t.set(i[0],i[1]);Object.defineProperty(en,e,{value:r,enumerable:!1})}return Object.defineProperty(en,"codes",{value:t,enumerable:!1}),en.color.close="\x1B[39m",en.bgColor.close="\x1B[49m",en.color.ansi=O5(),en.color.ansi256=G5(),en.color.ansi16m=K5(),en.bgColor.ansi=O5(tT),en.bgColor.ansi256=G5(tT),en.bgColor.ansi16m=K5(tT),Object.defineProperties(en,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>en.rgbToAnsi256(...en.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>en.ansi256ToAnsi(en.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>en.ansi256ToAnsi(en.hexToAnsi256(e)),enumerable:!1}}),en}function J5(t,e,r){return String(t).normalize().replace(/\r\n/g,`
1
+ var wLe=Object.create;var BD=Object.defineProperty;var bLe=Object.getOwnPropertyDescriptor;var vLe=Object.getOwnPropertyNames;var SLe=Object.getPrototypeOf,xLe=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gA=(t,e)=>{for(var r in e)BD(t,r,{get:e[r],enumerable:!0})},k5=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vLe(e))!xLe.call(t,i)&&i!==r&&BD(t,i,{get:()=>e[i],enumerable:!(n=bLe(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?wLe(SLe(t)):{},k5(e||!t||!t.__esModule?BD(r,"default",{value:t,enumerable:!0}):r,t)),mn=t=>k5(BD({},"__esModule",{value:!0}),t);var m=N(()=>{(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"fe4cb672ea183db0a322dcd4305bc5d8c786ce6b"}}catch{}})()});var N5=k((TRt,R5)=>{m();function YN(t){return t==null?[]:Array.isArray(t)?t:[t]}function FLe(t,e,r,n){var i,o=t[e],s=~n.string.indexOf(e)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~n.boolean.indexOf(e)?r==="false"?!1:r==="true"||(t._.push((i=+r,i*0===0?i:r)),!!r):(i=+r,i*0===0?i:r);t[e]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}R5.exports=function(t,e){t=t||[],e=e||{};var r,n,i,o,s,a={_:[]},A=0,c=0,u=0,l=t.length;let p=e.alias!==void 0,g=e.unknown!==void 0,d=e.default!==void 0;if(e.alias=e.alias||{},e.string=YN(e.string),e.boolean=YN(e.boolean),p)for(r in e.alias)for(n=e.alias[r]=YN(e.alias[r]),A=0;A<n.length;A++)(e.alias[n[A]]=n.concat(r)).splice(A,1);for(A=e.boolean.length;A-- >0;)for(n=e.alias[e.boolean[A]]||[],c=n.length;c-- >0;)e.boolean.push(n[c]);for(A=e.string.length;A-- >0;)for(n=e.alias[e.string[A]]||[],c=n.length;c-- >0;)e.string.push(n[c]);if(d){for(r in e.default)if(o=typeof e.default[r],n=e.alias[r]=e.alias[r]||[],e[o]!==void 0)for(e[o].push(r),A=0;A<n.length;A++)e[o].push(n[A])}let f=g?Object.keys(e.alias):[];for(A=0;A<l;A++){if(i=t[A],i==="--"){a._=a._.concat(t.slice(++A));break}for(c=0;c<i.length&&i.charCodeAt(c)===45;c++);if(c===0)a._.push(i);else if(i.substring(c,c+3)==="no-"){if(o=i.substring(c+3),g&&!~f.indexOf(o))return e.unknown(i);a[o]=!1}else{for(u=c+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(o=i.substring(c,u),s=i.substring(++u)||A+1===l||(""+t[A+1]).charCodeAt(0)===45||t[++A],n=c===2?[o]:o,u=0;u<n.length;u++){if(o=n[u],g&&!~f.indexOf(o))return e.unknown("-".repeat(c)+o);FLe(a,o,u+1<n.length||s,e)}}}if(d)for(r in e.default)a[r]===void 0&&(a[r]=e.default[r]);if(p)for(r in a)for(n=e.alias[r]||[];n.length>0;)a[n.shift()]=a[r];return a}});function kLe(){if(PC!==void 0)return PC;try{return PC=require("prettier"),PC}catch{return PC=null,null}}function RLe(t){let e=[],r=bg.default.dirname(t);for(;r!==bg.default.dirname(r);){let n=bg.default.join(r,".prettierignore");qN.default.existsSync(n)&&e.push(n);let i=bg.default.join(r,".git");if(qN.default.existsSync(i))break;r=bg.default.dirname(r)}return e}function NLe(t){if(t)try{let r=(0,T5.createRequire)(t)("prettier");if(r)return r}catch{}return kLe()}async function bc(t,e,r,n){try{let i=bg.default.resolve(t,n??"file.tsx"),o=NLe(i);if(!o)return e;if(n){let A=RLe(i);if((await o.getFileInfo(i,{ignorePath:A.length>0?A:void 0})).ignored)return e}let s=await o.resolveConfig(i);return await o.format(e,{...s,filepath:n,parser:r})}catch{return e}}var T5,bg,qN,PC,VN=N(()=>{"use strict";m();T5=require("node:module"),bg=z(require("node:path"),1),qN=z(require("node:fs"),1)});var zN,Nd,yD,QD,M5,vg,WN,ZN,Sg,P5,Td=N(()=>{"use strict";m();zN="preview-url",Nd="framework",yD="platform",QD="node",M5="/~builder-connect",vg="/~builder-connected",WN="/~builder-dev-tools",ZN="/~builder-dev-tools.js",Sg="/~builder-dev-tools-close",P5="/mappings"});var DD=k((ORt,_5)=>{"use strict";m();var XN={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},TLe={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},MLe={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?XN.up():"");return t&&(e+=XN.left),e}};_5.exports={cursor:XN,scroll:TLe,erase:MLe,beep:"\x07"}});var Hr=k((KRt,eT)=>{m();var bD=process||{},L5=bD.argv||[],wD=bD.env||{},PLe=!(wD.NO_COLOR||L5.includes("--no-color"))&&(!!wD.FORCE_COLOR||L5.includes("--color")||bD.platform==="win32"||(bD.stdout||{}).isTTY&&wD.TERM!=="dumb"||!!wD.CI),_Le=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+LLe(i,e,r,o)+e:t+i+e},LLe=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},U5=(t=PLe)=>{let e=t?_Le:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};eT.exports=U5();eT.exports.createColors=U5});function ULe({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function z5(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(OLe,"")}function W5(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _C(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=z5(t),t.length===0))return 0;t=t.replace($Le()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(KLe.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function YLe(){let t=new Map;for(let[e,r]of Object.entries(en)){for(let[n,i]of Object.entries(r))en[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=en[n],t.set(i[0],i[1]);Object.defineProperty(en,e,{value:r,enumerable:!1})}return Object.defineProperty(en,"codes",{value:t,enumerable:!1}),en.color.close="\x1B[39m",en.bgColor.close="\x1B[49m",en.color.ansi=O5(),en.color.ansi256=G5(),en.color.ansi16m=K5(),en.bgColor.ansi=O5(tT),en.bgColor.ansi256=G5(tT),en.bgColor.ansi16m=K5(tT),Object.defineProperties(en,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>en.rgbToAnsi256(...en.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>en.ansi256ToAnsi(en.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>en.ansi256ToAnsi(en.hexToAnsi256(e)),enumerable:!1}}),en}function J5(t,e,r){return String(t).normalize().replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `).map(n=>XLe(n,e,r)).join(`
4
4
  `)}function aT(t,e){if(typeof t=="string")return SD.aliases.get(t)===e;for(let r of t)if(r!==void 0&&aT(r,e))return!0;return!1}function tUe(t,e){if(t===e)return;let r=t.split(`
@@ -73,7 +73,7 @@ ${oV}${n.trimStart()}`),r=3+(0,xg.stripVTControlCharacters)(n.trimStart()).lengt
73
73
  `),d(),i()};return{start:I,stop:B,message:(E="")=>{a=h(E??a)}}}});function sr(t,e=""){return t.ts.createSourceFile("module.tsx",typeof e=="string"?e:"",t.ts.ScriptTarget.Latest,void 0)}function MD(t,e=""){let r=sr(t,e?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${e}`);return r.statements[0]}function ni(t,e,r){if(e){let n=t.ts.createPrinter({newLine:t.ts.NewLineKind.LineFeed,removeComments:r});return t.ts.isSourceFile(e)?n.printFile(e).trim()+`
74
74
  `:n.printNode(t.ts.EmitHint.Unspecified,e,t.ts.createSourceFile("module.tsx","",t.ts.ScriptTarget.Latest)).trim()+`
75
75
  `}return""}var ln=N(()=>{"use strict";m()});var pV=k((iNt,gV)=>{"use strict";m();gV.exports=function(){if(process.env.npm_config_user_agent)return CUe(process.env.npm_config_user_agent)};function CUe(t){let e=t.split(" ")[0],r=e.lastIndexOf("/"),n=e.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:e.substring(r+1)}}});function bs(t){return t.endsWith(".mapper.tsx")||t.endsWith(".mapper.jsx")||t.endsWith(".mapper.ts")||t.endsWith(".mapper.js")||t.endsWith(".mapper.mjs")}function ar(t,e,r){e=Ba(e),r=Ba(r),e=t.dirname(e);let n=t.basename(r,t.extname(r));r=t.dirname(r);let i;return n==="index"?i=t.relative(e,r):i=t.relative(e,t.join(r,n)),i=Ba(t.normalize(i)),i.startsWith(".")||(i="./"+i),i}function Ba(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}function kg(t,e){let r=t.extname(e),n=t.basename(e,r).split(/[\/\\]/),i=n[n.length-1];return dV(i==="index"?t.basename(t.dirname(e)):i)}function dV(t){return _r(t).replace(/ /g,"")}function vs(t,e){let r=t.extname(e),n=Ba(t.basename(e,r)).split("/").pop();return _r(n==="index"?t.basename(t.dirname(e)):n)}function Lr(t,e){let r=Ba(t.relative(t.getAppRootDir(),e));r=r.split("/").filter(i=>i!=="."&&i!==".."&&i!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=t.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(i=>i.name.includes("next"))?"@/"+r:"~/"+r}function hr(t,e){let r=e,n=[];for(let i=0;i<2;i++){let o=t.basename(r);if(!o||o==="components")break;n.unshift(o),r=t.dirname(r)}return n.join("/")}function _r(t){for(t=t.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();t.includes(" ");)t=t.replace(/ /g," ");return t.split(" ").map(e=>e.length>2?e[0].toUpperCase()+e.slice(1):e).join("").trim()}function xo(t){return t.sort((e,r)=>e.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function Fr(t,e,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${e}`);return n&&(e=n),e=t.normalize(e),(await t.hash(e+"#"+r)).substring(0,8)}async function mV(t){return(await t.hash(t.getAppRootDir())).substring(0,8)}function UC(t){return typeof t=="number"}function Ld(t){return typeof t=="boolean"}function io(t){return typeof t=="string"}function Ud(t){return typeof t=="string"?/^[A-Z][A-Za-z0-9]*$/.test(t):!1}function ts(t){return JSON.parse(JSON.stringify(t))}function PD(t,e,r){for(let n of e)if(t.dirname(r).includes(n))return!0;return!1}function hV(){try{let t=(0,fV.default)();if(t?.name)return t.name}catch{}return"npm"}function IUe(){return process.platform.startsWith("win")}function Cr(){return process.pkg?"@builder.io/agent":IUe()?'"@builder.io/dev-tools"':"builder.io"}function pT(t){return t.replace(/[^a-zA-Z0-9-_]/g,"_")}var fV,tr=N(()=>{"use strict";m();fV=z(pV(),1)});function oo(t){let e=t.join(t.getAppRootDir(),"tsconfig.json");return t.exists(e)}async function Fo(t,e){async function r(i,o){if(o>10)return;let s=await t.readdir(i);for(let a of s){if(EUe.includes(a))continue;let A=t.join(i,a),c=await t.stat(A);if(c){if(c.isFile()&&a.startsWith("builder-registry."))return A;if(c.isDirectory()){let u=await r(A,o+1);if(u)return u}}}}let n=await r(t.getAppRootDir(),0);if(!n){let o=`builder-registry.${await oo(t)?"ts":"js"}`;return t.join(e,o)}return n}async function ya(t,e){let r=t.resolve("/");for(let n=0;n<20;n++){let i=t.join(e,"package.json"),o=await t.readFile(i);if(o)return JSON.parse(o);if(e===r)break;e=t.dirname(e)}return null}async function CV(t,e){for(let r=0;r<20;r++){let n=t.dirname(e),i=t.join(n,"node_modules");if(await t.exists(i))return i;if(e===t.getAppRootDir())break;e=t.dirname(e)}return t.join(t.getAppRootDir(),"node_modules")}async function OC(t,e,r){let n=await t.readdir(e);return n.includes(r)?t.join(e,r):(await Promise.all(n.map(async o=>{if(o.startsWith(".")||o==="node_modules")return;let s=t.join(e,o);if((await t.stat(s)).isDirectory()){let A=await OC(t,s,r);if(A)return A}}))).find(o=>typeof o=="string")}var EUe,Ki=N(()=>{"use strict";m();EUe=["node_modules","dist","build","public"]});async function Hn(t,e,r){if(!Array.isArray(e)||e.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${e}`);let n=await CV(t,e[0]),i=t.join(n,"typescript","lib"),o=new Map,s={fileExists:a=>{if(a=t.normalize(a),a.includes("node_modules")){let A=GC.get(a);if(!A){try{t.statSync(a).isFile()?A={exists:!0,content:t.readFileSync(a)}:A={exists:!1}}catch{A={exists:!1}}GC.set(a,A)}return A.exists}if(!o.has(a))if(t.existsSync(a)){let c=t.statSync(a);o.set(a,c.isFile())}else o.set(a,!1);return o.get(a)},getCanonicalFileName:a=>t.normalize(a),getCurrentDirectory:()=>t.cwd(),getDefaultLibFileName:()=>t.join(i,"lib.d.ts"),getDefaultLibLocation:()=>i,getNewLine:()=>`
76
- `,getSourceFile:a=>{if(a=t.normalize(a),a.includes("node_modules")){let c=GC.get(a);if(c)return sr(t,c.content)}let A;try{A=t.readFileSync(a)}catch{console.error(`Could not read: ${a}`),A==null}if(A==null){let c=t.basename(a),u=t.extname(c).toLowerCase();if(a.startsWith(i)&&u===".ts"&&(A=EV.get(c),A==null&&typeof self<"u"&&typeof fetch=="function"))throw new LD(c)}return a.includes("node_modules")&&(A?GC.set(a,{exists:!0,content:A}):GC.set(a,{exists:!1})),sr(t,A)},readFile:a=>{let A=t.readFileSync(a);return typeof A=="string"?A:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return BUe(t,s,e,r)}catch(a){if(a instanceof LD){await yUe(t,a.libName);continue}throw t.Sentry?.captureException(a),new Error(`createTsProgram() Could not create program for: ${e[0]}`,{cause:a})}}function BUe(t,e,r,n){let i={rootNames:[...r],host:e,options:{}},o=t.ts.findConfigFile(t.dirname(r[0]),s=>t.existsSync(s));if(o){let s=IV.get(o);if(!s){let a=t.ts.readConfigFile(o,A=>{let c=t.readFileSync(A);return typeof c=="string"?c:void 0});a.error?t.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:a.error,tsConfigPath:o}}):(s=t.ts.parseJsonConfigFileContent(a.config,t.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(c,u)=>t.readdirSync(c),fileExists:c=>t.existsSync(c),readFile:c=>t.readFileSync(c)||void 0},t.dirname(o),void 0,o).options,IV.set(o,s))}s&&(i.options=ts(s))}return i.options.noEmit=!0,i.options.isolatedModules=!1,i.options.strict=!1,i.options.jsx=t.ts.JsxEmit.Preserve,i.options.allowJs=!0,Object.assign(i.options,n),t.ts.createProgram(i)}async function Od(t,e,r){r||(r=await Hn(t,[e]));let n=r.getSourceFile(e);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${e}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}async function yUe(t,e){let r=`https://cdn.jsdelivr.net/npm/typescript@${t.ts.version}/lib/${e}`;_D.has(e)||_D.set(e,fetch(r).then(n=>n.text()).then(n=>{EV.set(e,n)})),await _D.get(e),_D.delete(e)}async function BV(t,e){let r=await t.readFile(e.filePath);return r==null?{diagnostics:[{messageText:`Error reading: ${e.filePath}`}],code:null,output:null}:dT(t,{code:r,filePath:e.filePath,compilerOptions:e.compilerOptions})}function dT(t,e){let r={diagnostics:[],code:e.code,output:null};try{let n=t.ts.transpileModule(e.code,{compilerOptions:e.compilerOptions,fileName:e.filePath??"module.tsx",reportDiagnostics:!0});n.diagnostics?.forEach(i=>{r.diagnostics.push({messageText:String(i.messageText)})}),r.output=n.outputText}catch(n){console.error("transpileModule",n),r.diagnostics.push({messageText:String(n)})}return r}var LD,EV,_D,GC,IV,Ss=N(()=>{"use strict";m();ln();tr();Ki();LD=class{libName;constructor(e){this.libName=e}};EV=new Map,_D=new Map,GC=new Map,IV=new Map});var QUe,vt,Pn=N(()=>{"use strict";m();QUe="1.41.2-beta.202604081155.f368de7",vt=process.env.OVERRIDE_VERSION??QUe});async function Rg(t){let e=[],r=await ya(t,t.getRepoRootDir());if(r){let n=await QV(r,t);e.push(...n)}return e}async function QV(t,e){let r=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of DUe)if(n.has(i)&&!r.some(o=>o.name===i)){let o={name:i};yV.has(i)&&(o.version=await yV.get(i)(e)),r.push(o)}}return r}function fT(t){let e=parseInt(t);return Number.isNaN(e)?void 0:e}var yV,DUe,Ng=N(()=>{"use strict";m();Ki();tr();yV=new Map([["next",async t=>{if(!t.spawnSync)return;let e=hV(),r=e==="npm"?"npx":e,{stdout:n}=t.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let i=n.match(/(Next.js v)([\d.]+)/g);if(!i)return;let o=i[0].split("Next.js v")[1],[s,a,A]=o.split(".");return{major:fT(s),minor:fT(a),patch:fT(A)}}]]),DUe=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"]});async function xs(t){let e=DV(t),r=await t.readFile(e);return typeof r=="string"?JSON.parse(r):{}}async function Fs(t,e){e=typeof e=="object"&&e!=null?e:{};let r=DV(t);await t.writeFile(r,JSON.stringify(e??{},null,2))}function DV(t){let e=t.getAppRootDir();return t.join(e,"node_modules",".builder","builder-cache.json")}var Tg=N(()=>{"use strict";m()});async function pA(t,e,r){let n={envKey:r,envValue:null,file:""};for(let i of e){let o=t.join(t.getAppRootDir(),i),s=await wUe(t,o);if(s){let a=s[r];if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=o,n}}return n.file=t.join(t.getAppRootDir(),e[e.length-1]),n}async function wUe(t,e){let r=await t.readFile(e);return typeof r=="string"?wV(r):null}function wV(t){let e={},r=t.replace(/\r\n?/gm,`
76
+ `,getSourceFile:a=>{if(a=t.normalize(a),a.includes("node_modules")){let c=GC.get(a);if(c)return sr(t,c.content)}let A;try{A=t.readFileSync(a)}catch{console.error(`Could not read: ${a}`),A==null}if(A==null){let c=t.basename(a),u=t.extname(c).toLowerCase();if(a.startsWith(i)&&u===".ts"&&(A=EV.get(c),A==null&&typeof self<"u"&&typeof fetch=="function"))throw new LD(c)}return a.includes("node_modules")&&(A?GC.set(a,{exists:!0,content:A}):GC.set(a,{exists:!1})),sr(t,A)},readFile:a=>{let A=t.readFileSync(a);return typeof A=="string"?A:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return BUe(t,s,e,r)}catch(a){if(a instanceof LD){await yUe(t,a.libName);continue}throw t.Sentry?.captureException(a),new Error(`createTsProgram() Could not create program for: ${e[0]}`,{cause:a})}}function BUe(t,e,r,n){let i={rootNames:[...r],host:e,options:{}},o=t.ts.findConfigFile(t.dirname(r[0]),s=>t.existsSync(s));if(o){let s=IV.get(o);if(!s){let a=t.ts.readConfigFile(o,A=>{let c=t.readFileSync(A);return typeof c=="string"?c:void 0});a.error?t.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:a.error,tsConfigPath:o}}):(s=t.ts.parseJsonConfigFileContent(a.config,t.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(c,u)=>t.readdirSync(c),fileExists:c=>t.existsSync(c),readFile:c=>t.readFileSync(c)||void 0},t.dirname(o),void 0,o).options,IV.set(o,s))}s&&(i.options=ts(s))}return i.options.noEmit=!0,i.options.isolatedModules=!1,i.options.strict=!1,i.options.jsx=t.ts.JsxEmit.Preserve,i.options.allowJs=!0,Object.assign(i.options,n),t.ts.createProgram(i)}async function Od(t,e,r){r||(r=await Hn(t,[e]));let n=r.getSourceFile(e);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${e}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}async function yUe(t,e){let r=`https://cdn.jsdelivr.net/npm/typescript@${t.ts.version}/lib/${e}`;_D.has(e)||_D.set(e,fetch(r).then(n=>n.text()).then(n=>{EV.set(e,n)})),await _D.get(e),_D.delete(e)}async function BV(t,e){let r=await t.readFile(e.filePath);return r==null?{diagnostics:[{messageText:`Error reading: ${e.filePath}`}],code:null,output:null}:dT(t,{code:r,filePath:e.filePath,compilerOptions:e.compilerOptions})}function dT(t,e){let r={diagnostics:[],code:e.code,output:null};try{let n=t.ts.transpileModule(e.code,{compilerOptions:e.compilerOptions,fileName:e.filePath??"module.tsx",reportDiagnostics:!0});n.diagnostics?.forEach(i=>{r.diagnostics.push({messageText:String(i.messageText)})}),r.output=n.outputText}catch(n){console.error("transpileModule",n),r.diagnostics.push({messageText:String(n)})}return r}var LD,EV,_D,GC,IV,Ss=N(()=>{"use strict";m();ln();tr();Ki();LD=class{libName;constructor(e){this.libName=e}};EV=new Map,_D=new Map,GC=new Map,IV=new Map});var QUe,vt,Pn=N(()=>{"use strict";m();QUe="1.41.2-beta.202604081246.fe4cb67",vt=process.env.OVERRIDE_VERSION??QUe});async function Rg(t){let e=[],r=await ya(t,t.getRepoRootDir());if(r){let n=await QV(r,t);e.push(...n)}return e}async function QV(t,e){let r=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of DUe)if(n.has(i)&&!r.some(o=>o.name===i)){let o={name:i};yV.has(i)&&(o.version=await yV.get(i)(e)),r.push(o)}}return r}function fT(t){let e=parseInt(t);return Number.isNaN(e)?void 0:e}var yV,DUe,Ng=N(()=>{"use strict";m();Ki();tr();yV=new Map([["next",async t=>{if(!t.spawnSync)return;let e=hV(),r=e==="npm"?"npx":e,{stdout:n}=t.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let i=n.match(/(Next.js v)([\d.]+)/g);if(!i)return;let o=i[0].split("Next.js v")[1],[s,a,A]=o.split(".");return{major:fT(s),minor:fT(a),patch:fT(A)}}]]),DUe=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"]});async function xs(t){let e=DV(t),r=await t.readFile(e);return typeof r=="string"?JSON.parse(r):{}}async function Fs(t,e){e=typeof e=="object"&&e!=null?e:{};let r=DV(t);await t.writeFile(r,JSON.stringify(e??{},null,2))}function DV(t){let e=t.getAppRootDir();return t.join(e,"node_modules",".builder","builder-cache.json")}var Tg=N(()=>{"use strict";m()});async function pA(t,e,r){let n={envKey:r,envValue:null,file:""};for(let i of e){let o=t.join(t.getAppRootDir(),i),s=await wUe(t,o);if(s){let a=s[r];if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=o,n}}return n.file=t.join(t.getAppRootDir(),e[e.length-1]),n}async function wUe(t,e){let r=await t.readFile(e);return typeof r=="string"?wV(r):null}function wV(t){let e={},r=t.replace(/\r\n?/gm,`
77
77
  `),n;for(;(n=bUe.exec(r))!=null;){let i=n[1],o=n[2]||"";o=o.trim();let s=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),s==='"'&&(o=o.replace(/\\n/g,`
78
78
  `),o=o.replace(/\\r/g,"\r")),e[i]=o}return e}async function dA(t,e,r,n){let i="# https://www.builder.io/c/docs/using-your-api-key",o=await t.readFile(e);try{if(o)if(o.includes(r))if(o.includes(n))t.debug(`"${r}" with "${n}" already set in ${e}`);else return t.debug(`Replace "${r}" in ${e}`),o=o.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await t.writeFile(e,o),"update";else return t.debug(`Append "${r}" to ${e}`),o+=`
79
79
 
@@ -1276,7 +1276,7 @@ Restarting server after Builder Devtools update...
1276
1276
  <h3>How's Devtools working for you?</h3>
1277
1277
  <p>We'd love your feedback!</p>
1278
1278
  </div>
1279
- \`,t.appendChild(e),setTimeout(()=>{e.classList.add("menu-toggle-tooltip-show"),e.addEventListener("click",()=>{e.classList.remove("menu-toggle-tooltip-show")})},1e3)};function ui(t){t.getElementById("go-to-builder").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(Ur(),"builder")}),t.getElementById("components-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let c=t.querySelector(".nav-cmp-list .section-content");c.scrollTop=0,oe(t,"nav-cmp-list"),ai(t)}),t.getElementById("settings-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),oe(t,"nav-settings")}),t.getElementById("add-page-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(je(),"builder")}),t.getElementById("import-from-figma").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open("https://www.figma.com/community/plugin/747985167520967365/builder-io-ai-powered-figma-to-code-react-vue-tailwind-more")})}function ci(t){let e=t.getElementById("enable-edit");e.addEventListener("change",r=>{r.stopPropagation(),Ht(e.checked)}),e.checked=it(),Ht(e.checked)}var Dt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=\`<style>*,*:before,*:after{box-sizing:border-box}:host{--background-color: rgba(40, 40, 40, 1);--primary-color: rgba(72, 161, 255, 1);--primary-color-subdued: rgb(72, 161, 255, .6);--primary-color-highlight: rgb(126, 188, 255);--primary-contrast-color: white;--edit-color: #1d74e2;--edit-color-highlight: #1c6bd1;--edit-color-alpha: rgb(72, 161, 255, .15);--error-color: #ff2b55;--text-color: white;--text-color-highlight: white;--border-color: #454545;--button-background-color-hover: rgba(255, 255, 255, .1);--menu-width: 320px;--transition-time: .15s;--font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-family:var(--font-family);line-height:1.6}button{cursor:pointer;color:var(--text-color);-webkit-tap-highlight-color:transparent}input,select,button{font-family:var(--font-family)}.menu-toggle{position:absolute;right:0;bottom:0;pointer-events:auto;padding:8px;background:transparent;border:none;appearance:none}.menu-toggle div{position:relative;width:64px;height:64px;pointer-events:none;border-radius:50%;background:#000;border:1px solid white;box-shadow:#00000054 0 0 8px}.menu-toggle:hover div{background-color:var(--background-color);border:1px solid rgb(220,220,220)}.menu-toggle svg{position:absolute;top:15px;left:15px;width:33px;height:32px}div.highlight-bg{position:absolute;top:-1px;left:-1px;background-color:#1a1a1a;pointer-events:none;transition:all .4s ease-out;opacity:0}.menu-toggle-highlight-no-transition div.highlight-bg{transition:none}.menu-toggle-highlight div.highlight-bg{opacity:1}.menu-toggle-tooltip{position:absolute;bottom:0;right:0;width:382px;height:72px;padding:0;text-align:left;appearance:none;background-color:transparent;border:none;pointer-events:none;transform:translate3d(320px,0,0);opacity:0;transition:all .15s ease-in-out;color:#fff}.menu-toggle-tooltip.menu-toggle-tooltip-show{pointer-events:auto;opacity:1;transform:translateZ(0)}.menu-toggle-tooltip-content{position:absolute;inset:0 95px 10px 0;padding:8px 12px;background-color:var(--primary-color);box-shadow:#00000054 0 0 20px;border-radius:2px}.menu-toggle-tooltip-content:before{content:"";position:absolute;bottom:15px;right:-6px;width:30px;height:30px;background-color:var(--primary-color);transform:rotate(45deg)}.menu-toggle-tooltip:hover .menu-toggle-tooltip-content,.menu-toggle-tooltip:hover .menu-toggle-tooltip-content:before{background-color:var(--primary-color-highlight)}.menu-toggle-tooltip-content h3{margin:0;font-size:16px}.menu-toggle-tooltip-content p{margin:0;font-size:12px}section{position:absolute;display:grid;grid-template-rows:64px auto 64px;top:0;left:0;width:100%;height:100%;padding:0;pointer-events:none}.section-content{margin:0;padding:0 0 10px;font-weight:300;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;overflow-y:auto}.section-content .error{color:var(--error-color);font-weight:700}section a{text-decoration:none;color:var(--text-color)}section h3,section p{margin-left:16px;margin-right:16px}.info{font-size:12px}ul.list{list-style:none;padding:0;margin:0}ul.list li{display:block;padding:0;margin:0}ul.list a,ul.list button{display:grid;grid-template-columns:24px auto;grid-gap:16px;padding:12px;margin:8px 0;border:none;background:transparent;appearance:none;width:100%;font-weight:300;text-align:left;text-decoration:none;color:var(--text-color)}ul.list a:hover,ul.list button:hover{text-decoration:none;color:var(--text-color);background-color:var(--button-background-color-hover)}ul.list a span,ul.list button span{display:block;font-size:16px;font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}header{position:relative;display:grid;grid-template-columns:44px 1fr;gap:8px;padding-left:8px;border-bottom:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}header>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nav-home header>div{margin-right:56px}header h2{margin:7px 0 0;font-size:18px;font-weight:500;line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p{margin:2px 0 0;font-size:12px;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button{display:block;margin:0;padding:0;width:100%;font-size:12px;font-weight:300;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button:hover{text-decoration:underline;color:var(--primary-color)}.builder-logo{margin:12px 0 0 8px}#close{display:block;position:absolute;appearance:none;background:transparent;border:none;border-radius:50%;margin:0;padding:0;right:4px;top:8px;width:48px;height:48px;z-index:1;opacity:.7}#close:hover{opacity:1;background-color:var(--button-background-color-hover)}#close svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}.back-button{position:relative;display:block;margin:7px 0 0 -2px;width:48px;height:48px;background:transparent;border:none;appearance:none;border-radius:50%}.back-button:hover{background-color:var(--button-background-color-hover)}.back-button svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}footer{border-top:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}section.nav-cmp-list{grid-template-rows:64px auto 120px}footer a{text-decoration:underline;color:var(--primary-color)}footer a:hover{color:var(--primary-color);text-decoration:none}.nav-list{padding:2px 0}.nav-loading{pointer-events:none}.nav-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.nav-loading .nav-loading-icon{opacity:.5}.nav-list h4{margin:8px 8px 8px 10px;font-size:14px;font-weight:600}.nav-list .nav-list-item+h4{margin-top:30px}.nav-list-item{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:relative;margin:2px 0;padding:8px 28px 8px 46px;width:100%;font-size:14px;font-weight:300;text-align:left;border:none;background:transparent;appearance:none}.nav-list-item:hover{background-color:var(--button-background-color-hover)}.nav-list-item-icon{position:absolute;top:4px;left:10px;width:24px;height:24px;object-fit:contain;filter:invert(100%);background-size:24px 24px;background-repeat:no-repeat;background-position:center center}.nav-list-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none}.nav-list-item:after{display:block;position:absolute;content:"";background-image:url('data:image/svg+xml,<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L7 7L1 13" stroke="%23F2F2F2" stroke-opacity="0.5" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');background-repeat:no-repeat;background-position:12px 9px;top:0;right:0;width:32px;height:32px;pointer-events:none}.nav-list-item-note{opacity:0;font-size:12px;padding-top:1px;text-align:right}.nav-list-item:hover .nav-list-item-note{opacity:.5}.ui-select{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-select h3{margin:0;font-size:14px;font-weight:500}.ui-select p{margin:8px 0;font-size:12px;font-weight:300}.ui-select .select{position:relative;margin:8px 0;border-radius:4px;padding:0;line-height:1.1;overflow:hidden;border:1px solid var(--border-color)}.ui-select select{appearance:none;background-color:transparent;border:none;outline:none;padding:8px 32px 8px 8px;margin:0;width:100%;font-size:14px;cursor:pointer;text-overflow:ellipsis;opacity:.6;color:var(--text-color)}.ui-select .select:after{content:"";top:6px;right:5px;width:24px;height:24px;position:absolute;background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="%23F2F2F2" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/></svg>');background-repeat:no-repeat;background-position:center;pointer-events:none;opacity:.6}.ui-select .select:hover{border-color:var(--primary-color-subdued)}.ui-text-input .select:focus-within{border-color:var(--primary-color)}.ui-text-input .select:focus-within select{opacity:1}.spinner:after{content:" ";display:block;width:32px;height:32px;margin:0 auto;pointer-events:auto;border-radius:50%;border:3px solid var(--text-color);border-color:var(--text-color) transparent var(--text-color) transparent;animation:spinner .75s linear infinite}@keyframes spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ui-switch{display:grid;grid-template-columns:auto 48px;grid-gap:20px;margin:8px 0 16px;padding:8px 0 8px 16px;cursor:pointer}.ui-switch>*{pointer-events:none}.ui-switch input{display:none;visibility:hidden}.ui-switch .switcher{display:inline-block;border-radius:100px;width:35px;height:14px;background-color:#ccc;position:relative;top:6px;vertical-align:middle;cursor:pointer}.ui-switch input[type=checkbox]:checked+.switcher{background-color:var(--primary-color-subdued)}.ui-switch .switcher:before{content:"";display:block;width:20px;height:20px;background-color:var(--text-color);box-shadow:0 1px 3px #0009;border-radius:50%;position:absolute;top:-3px;left:0;margin-right:0;transition:all .15s}.ui-switch input[type=checkbox]:checked+.switcher:before{left:100%;margin-left:-20px;background-color:var(--primary-color)}.ui-switch h3{margin:0;font-size:14px;font-weight:500}.ui-switch p{margin:4px 0 0;font-size:12px;font-weight:300}.ui-text-input{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-text-input h3{margin:0;font-size:14px;font-weight:500}.ui-text-input p{margin:8px 0;font-size:12px;font-weight:300}.ui-text-input .input{position:relative;margin:8px 0;border:1px solid var(--border-color);border-radius:4px;background:transparent;padding:2px;overflow:hidden}.ui-text-input input{display:block;width:235px;font-size:14px;border:none;background:transparent;padding:6px;appearance:none;color:var(--text-color);opacity:.6;outline:none}.ui-text-input .input:hover{border-color:var(--primary-color-subdued)}.ui-text-input .input:focus-within{border-color:var(--primary-color)}.ui-text-input .input:focus-within input{opacity:1}.ui-text-input .input:after{content:"";position:absolute;top:5px;right:14px;width:8px;height:17px;border:2px solid rgba(51,181,51,1);border-top:none;border-left:none;transform:rotate(45deg);opacity:0;transition:opacity 80ms ease-in-out;pointer-events:none}.ui-text-input.saved .input:after{opacity:1}.ui-toast{position:fixed;bottom:8px;left:8px;right:8px;padding:6px 12px;font-size:14px;border-radius:4px;transform:translate3d(0,150%,0);opacity:0;transition:all var(--transition-time) ease-in-out;background-color:var(--primary-color-subdued);color:var(--text-color);pointer-events:none}.ui-toast.ui-toast-show{transform:translateZ(0);opacity:1;pointer-events:auto}[data-view=nav-home] .nav-home .section-content,[data-view=nav-cmp-list] .nav-cmp-list .section-content,[data-view=nav-cmp-detail] .nav-cmp-detail .section-content,[data-view=nav-cmp-input] .nav-cmp-input .section-content,[data-view=nav-settings] .nav-settings .section-content{transform:translateZ(0);pointer-events:auto}[data-view=nav-home] .nav-home header,[data-view=nav-home] .nav-home footer,[data-view=nav-cmp-list] .nav-cmp-list header,[data-view=nav-cmp-list] .nav-cmp-list footer,[data-view=nav-cmp-detail] .nav-cmp-detail header,[data-view=nav-cmp-detail] .nav-cmp-detail footer,[data-view=nav-cmp-input] .nav-cmp-input header,[data-view=nav-cmp-input] .nav-cmp-input footer,[data-view=nav-settings] .nav-settings header,[data-view=nav-settings] .nav-settings footer{opacity:1;pointer-events:auto}[data-view=nav-cmp-list] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-home .section-content,[data-view=nav-cmp-input] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-cmp-detail .section-content,[data-view=nav-settings] .nav-home .section-content{transform:translate3d(-105%,0,0)}.cmp-item .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20.83 16.809C20.94 16.561 21 16.289 21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L7.988 3.99001M5.441 5.44801L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L18.544 18.56" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.532 10.538L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.27002 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3 3L21 21" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');opacity:.3}.cmp-item.registered .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /></svg>');opacity:.8}.search-highlight{background-color:var(--primary-color-alpha);padding:0 2px;border-radius:2px;font-weight:500}.search-container{position:sticky;top:0;z-index:10;padding:12px 16px;background:var(--background-color);border-bottom:1px solid var(--border-color)}.search-input-wrapper{position:relative;display:flex;align-items:center}.search-icon{position:absolute;left:12px;color:var(--text-color-secondary);pointer-events:none}.component-search-input{width:100%;height:36px;padding:8px 36px;border:1px solid var(--border-color);border-radius:6px;background:var(--input-background);color:var(--text-color);font-size:14px;transition:border-color .2s,box-shadow .2s}.component-search-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 2px var(--primary-color-alpha)}.component-search-input::placeholder{color:var(--text-color-tertiary)}.clear-search-button{position:absolute;right:8px;padding:4px;color:var(--text-color-secondary);border:none;background:transparent;border-radius:4px;cursor:pointer;opacity:0;transition:opacity .2s,background-color .2s;display:flex;align-items:center;justify-content:center}.clear-search-button:hover{background-color:var(--hover-color)}.component-search-input:not(:placeholder-shown)+.clear-search-button{opacity:1}.no-results{padding:32px 16px;text-align:center;color:var(--text-color-secondary);font-size:14px}#cmp-detail{position:relative}.cmp-loading{pointer-events:none!important}.cmp-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.cmp-loading .cmp-loading-icon{opacity:.5}.cmp-cover{position:absolute;top:160px;left:0;width:100%;height:100vh;background:var(--background-color);transform:translateZ(0);pointer-events:none;display:none}[data-view=nav-cmp-detail] .cmp-cover{display:block;pointer-events:auto}.cmp-enabled .cmp-cover{transform:translate3d(0,105%,0);pointer-events:none}.section-ready .cmp-cover{transition:all var(--transition-time) ease-in-out}.cmp-detail-inputs-container{margin:8px 0 16px;padding:0}.cmp-detail-inputs-container h3{margin:0 0 6px;padding-left:16px;padding-right:8px;font-size:14px;font-weight:500;display:flex;justify-content:space-between;align-items:center}.cmp-detail-inputs-reload{font-weight:300;font-size:.9em;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cmp-detail-inputs-reload:hover{text-decoration:underline;color:var(--primary-color)}.cmp-detail-inputs-container .cmp-inputs-empty{padding:0;margin-top:12px;font-size:12px;font-weight:300;opacity:.5;font-style:italic}.cmp-detail-inputs-container .nav-list-item-icon{opacity:.8;background-size:20px 20px;background-position:4px center}.input-icon{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path></svg>')}.input-icon-array{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-6a2 2 0 1 1 4 0v6"></path> <path d="M10 13h4"></path></svg>')}.input-icon-boolean{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16h2a2 2 0 1 0 0 -4h-2h2a2 2 0 1 0 0 -4h-2v8z"></path></svg>')}.input-icon-number{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-8l4 8v-8"></path></svg>')}.input-icon-object{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path></svg>')}.input-icon-string{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path></svg>')}.cmp-input-item-unregistered{opacity:.4}.cmp-input-item-unregistered .input-icon:after{content:"";position:absolute;top:11px;left:4px;width:20px;height:2px;background-color:#000;transform:rotate(-45deg)}.cmp-prop-info{border-bottom:1px solid var(--border-color)}.cmp-input-readonly{margin:16px 0;padding:0 16px;display:grid;grid-template-columns:50% 50%;gap:12px}.cmp-input-readonly h3{margin:0;font-size:14px;font-weight:500}.cmp-input-readonly span{margin-top:2px;font-size:12px;font-weight:300;opacity:.8}.cmp-input-detail{margin:16px 0}.cmp-input-detail a{color:var(--primary-color);text-decoration:none}.cmp-input-detail a:hover{text-decoration:underline}.input-cover{position:absolute;top:175px;left:0;width:100%;height:100%;background:var(--background-color);transform:translateZ(0);transition:all var(--transition-time) ease-in-out;pointer-events:auto}.input-enabled .input-cover{transform:translate3d(0,105%,0);pointer-events:none}.input-loading-icon{position:absolute;display:inline-block;top:190px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.input-loading .input-loading-icon{opacity:.5}:host{position:fixed;inset:0;z-index:2147483646;user-select:none;pointer-events:none;color:var(--text-color)}aside{position:absolute;top:0;right:0;width:var(--menu-width);height:100%;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;background:var(--background-color);box-shadow:#000000c9 5px 0 20px;overflow:hidden;z-index:1}:host(.show-builder-menu) aside{pointer-events:auto;transform:translateZ(0)}#hit{position:absolute;inset:0;display:none}:host(.show-builder-menu) #hit{display:block;pointer-events:auto}#version{position:absolute;bottom:6px;right:6px;font-size:8px;color:#9b9b9b}</style><div id="hit"></div> <aside data-view="nav-home"> <section class="nav-home"> <header> <svg class="builder-logo" viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> <div> <h2 class="builder-home-title">Builder Devtools</h2> <p><button id="go-to-builder">Go to Builder</button></p> </div> <button id="close" aria-label="Close Menu"> <svg viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M18 6l-12 12" /> <path d="M6 6l12 12" /> </svg> </button> </header> <div class="section-content"> <ul class="list"> <li> <button id="components-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Components</span> </button> </li> <li> <button id="settings-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M10.325 4.317C10.751 2.561 13.249 2.561 13.675 4.317C13.7389 4.5808 13.8642 4.82578 14.0407 5.032C14.2172 5.23822 14.4399 5.39985 14.6907 5.50375C14.9414 5.60764 15.2132 5.65085 15.4838 5.62987C15.7544 5.60889 16.0162 5.5243 16.248 5.383C17.791 4.443 19.558 6.209 18.618 7.753C18.4769 7.98466 18.3924 8.24634 18.3715 8.51677C18.3506 8.78721 18.3938 9.05877 18.4975 9.30938C18.6013 9.55999 18.7627 9.78258 18.9687 9.95905C19.1747 10.1355 19.4194 10.2609 19.683 10.325C21.439 10.751 21.439 13.249 19.683 13.675C19.4192 13.7389 19.1742 13.8642 18.968 14.0407C18.7618 14.2172 18.6001 14.4399 18.4963 14.6907C18.3924 14.9414 18.3491 15.2132 18.3701 15.4838C18.3911 15.7544 18.4757 16.0162 18.617 16.248C19.557 17.791 17.791 19.558 16.247 18.618C16.0153 18.4769 15.7537 18.3924 15.4832 18.3715C15.2128 18.3506 14.9412 18.3938 14.6906 18.4975C14.44 18.6013 14.2174 18.7627 14.0409 18.9687C13.8645 19.1747 13.7391 19.4194 13.675 19.683C13.249 21.439 10.751 21.439 10.325 19.683C10.2611 19.4192 10.1358 19.1742 9.95929 18.968C9.7828 18.7618 9.56011 18.6001 9.30935 18.4963C9.05859 18.3924 8.78683 18.3491 8.51621 18.3701C8.24559 18.3911 7.98375 18.4757 7.752 18.617C6.209 19.557 4.442 17.791 5.382 16.247C5.5231 16.0153 5.60755 15.7537 5.62848 15.4832C5.64942 15.2128 5.60624 14.9412 5.50247 14.6906C5.3987 14.44 5.23726 14.2174 5.03127 14.0409C4.82529 13.8645 4.58056 13.7391 4.317 13.675C2.561 13.249 2.561 10.751 4.317 10.325C4.5808 10.2611 4.82578 10.1358 5.032 9.95929C5.23822 9.7828 5.39985 9.56011 5.50375 9.30935C5.60764 9.05859 5.65085 8.78683 5.62987 8.51621C5.60889 8.24559 5.5243 7.98375 5.383 7.752C4.443 6.209 6.209 4.442 7.753 5.382C8.753 5.99 10.049 5.452 10.325 4.317Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M9 12C9 12.7956 9.31607 13.5587 9.87868 14.1213C10.4413 14.6839 11.2044 15 12 15C12.7956 15 13.5587 14.6839 14.1213 14.1213C14.6839 13.5587 15 12.7956 15 12C15 11.2044 14.6839 10.4413 14.1213 9.87868C13.5587 9.31607 12.7956 9 12 9C11.2044 9 10.4413 9.31607 9.87868 9.87868C9.31607 10.4413 9 11.2044 9 12Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Settings</span> </button> </li> <li> <button id="add-page-link"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M14 3v4a1 1 0 0 0 1 1h4" /> <path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /> <path d="M12 11l0 6" /> <path d="M9 14l6 0" /> </svg> <span>Add Builder Page</span> </button> </li> <li> <button id="import-from-figma"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-figma" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M15 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /> <path d="M6 3m0 3a3 3 0 0 1 3 -3h6a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3 -3z" /> <path d="M9 9a3 3 0 0 0 0 6h3m-3 0a3 3 0 1 0 3 3v-15" /> </svg> <span>Import From Figma</span> </button> </li> </ul> </div> <footer> <ul class="list"> <li> <a href="https://docs.google.com/forms/d/e/1FAIpQLSdqZcJpRtm_Ia5DTHP6SDY9Xa6LID3KiTjRWkjMzWyJRUtSHw/viewform" target="_blank" > <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M11.013 17.0114L10.013 18.0114L2.513 10.5834C2.0183 10.102 1.62864 9.52342 1.36854 8.88404C1.10845 8.24466 0.983558 7.55836 1.00173 6.86834C1.01991 6.17832 1.18076 5.49954 1.47415 4.87474C1.76755 4.24994 2.18713 3.69266 2.70648 3.23799C3.22583 2.78331 3.8337 2.4411 4.49181 2.23289C5.14991 2.02468 5.844 1.95499 6.53036 2.02821C7.21673 2.10143 7.8805 2.31596 8.47987 2.65831C9.07925 3.00066 9.60124 3.46341 10.013 4.01741C10.8086 2.95654 11.9931 2.2552 13.3059 2.06766C14.6186 1.88012 15.9521 2.22176 17.013 3.01741C18.0739 3.81306 18.7752 4.99755 18.9627 6.3103C19.1503 7.62305 18.8086 8.95654 18.013 10.0174" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> <path d="M18.2006 19.8175L16.0286 20.9555C15.9642 20.989 15.8917 21.004 15.8192 20.9987C15.7467 20.9934 15.6771 20.9681 15.6182 20.9256C15.5593 20.8831 15.5134 20.825 15.4855 20.7579C15.4577 20.6907 15.4491 20.6172 15.4606 20.5455L15.8756 18.1345L14.1186 16.4275C14.0662 16.3768 14.0291 16.3123 14.0115 16.2416C13.9939 16.1708 13.9966 16.0965 14.0192 16.0271C14.0418 15.9578 14.0835 15.8962 14.1394 15.8494C14.1954 15.8026 14.2634 15.7725 14.3356 15.7625L16.7636 15.4105L17.8496 13.2175C17.8821 13.1521 17.9322 13.0972 17.9942 13.0588C18.0562 13.0204 18.1277 13 18.2006 13C18.2736 13 18.3451 13.0204 18.4071 13.0588C18.4691 13.0972 18.5191 13.1521 18.5516 13.2175L19.6376 15.4105L22.0656 15.7625C22.1377 15.7728 22.2054 15.8031 22.2611 15.85C22.3168 15.8968 22.3583 15.9583 22.3809 16.0275C22.4034 16.0967 22.4062 16.1708 22.3888 16.2415C22.3715 16.3122 22.3347 16.3766 22.2826 16.4275L20.5256 18.1345L20.9396 20.5445C20.9521 20.6163 20.9441 20.6902 20.9166 20.7578C20.8891 20.8254 20.8433 20.8839 20.7842 20.9267C20.7252 20.9695 20.6553 20.9949 20.5825 21C20.5098 21.005 20.4371 20.9896 20.3726 20.9555L18.2006 19.8175Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Give Feedback</span> </a> </li> </ul> <div id="version"></div> </footer> </section> <section class="nav-cmp-list"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div class="search-container"> <div class="search-input-wrapper"> <svg class="search-icon" viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M15.5 15.5L20 20M10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10C17 13.866 13.866 17 10 17Z" /> </svg> <input type="text" id="component-search" class="component-search-input" placeholder="Search components..." autocomplete="off" spellcheck="false" /> <button id="clear-search" class="clear-search-button" type="button" aria-label="Clear search" > <svg viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M6 6l12 12M6 18L18 6" /> </svg> </button> </div> </div> <div> <h2>Custom Components</h2> <p> <button id="open-builder-registry"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-list" class="cmp-list nav-list"></div> </div> <div class="nav-loading-icon spinner"></div> <footer> <p class="info"> Expand on Builder's selection of built-in blocks by <a target="_blank" href="https://www.builder.io/c/docs/custom-components-intro" >registering components</a > from your codebase. This way, teammates can drag and drop your components within Builder's Visual Editor just like any other block. </p> </footer> </section> <section class="nav-cmp-detail"> <header> <button class="back-button" data-back="nav-cmp-list"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-detail-title"></h2> <p> <button id="cmp-open-source"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-error"></div> <label class="ui-switch"> <div> <h3>Register Component</h3> <p> Registers this component so it can be used within Builder Visual CMS </p> </div> <input type="checkbox" role="switch" id="cmp-register" /> <span class="switcher"></span> </label> <div id="cmp-detail"> <label class="ui-text-input"> <h3>Component Name</h3> <div class="input"> <input type="text" id="cmp-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="2" maxlength="30" required placeholder="e.g. My Counter" /> </div> <p> Unique name to identify this custom component within Builder. Press ESC to cancel </p> </label> <div class="cmp-detail-inputs-container"> <h3> <span>Builder Inputs (Props)</span> <button class="cmp-detail-inputs-reload" id="btn-inputs-reload"> Reload </button> </h3> <div id="cmp-detail-inputs"></div> </div> </div> </div> <div class="cmp-cover"></div> <div class="cmp-loading-icon spinner"></div> </section> <section class="nav-cmp-input"> <header> <button class="back-button" data-back="nav-cmp-detail"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-input-title"></h2> <p> <button id="input-open-source"></button> </p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable Input</h3> <p>Add this component prop as a Builder input</p> </div> <input type="checkbox" role="switch" id="input-register" /> <span class="switcher"></span> </label> <div class="cmp-prop-info"> <div class="cmp-input-readonly"> <h3>Prop Name</h3> <span id="cmp-prop-name"></span> </div> <div class="cmp-input-readonly"> <h3>Prop Type</h3> <span id="cmp-prop-type"></span> </div> </div> <div class="cmp-input-detail"> <label class="ui-text-input"> <h3>Builder Input Name</h3> <div class="input"> <input type="text" id="input-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="1" maxlength="30" required placeholder="e.g. Text" /> </div> <p> Friendly name to identify this component prop as a Builder input. Press ESC to cancel </p> </label> <label class="ui-select"> <h3>Builder Input Type</h3> <div class="select"> <select id="input-type"></select> </div> <p> Correlate to what editing UI is appropriate for this Builder input. <a href="https://www.builder.io/c/docs/custom-components-input-types" target="_blank" >Read more about input types.</a > </p> </label> </div> <div class="input-cover"></div> <div class="input-loading-icon spinner"></div> </div> </section> <section class="nav-settings"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2>Settings</h2> <p>Configure Builder's Devtools</p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable edit button in UI</h3> <p>Enables the edit button so you can edit content in Builder</p> </div> <input type="checkbox" role="switch" id="enable-edit" /> <span class="switcher"></span> </label> </div> </section> <div class="ui-toast" id="toast"></div> </aside> <button class="menu-toggle" aria-label="Toggle Builder Devtools"> <div> <div class="highlight-bg"></div> <svg viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> </div> </button>\`,si(e),ui(e),oi(e),ri(e),ti(e),ci(e),this.setAttribute("aria-hidden","true"),e.getElementById("version").textContent="v1.41.2-beta.202604081155.f368de7"}highlightOpener(){let e=this.shadowRoot.querySelector(".menu-toggle");e.classList.add("menu-toggle-highlight"),e.classList.add("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight")},20)},20)}};var lo=\`<style>*,*:before,*:after{box-sizing:border-box}html,body,:host{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:2147483646;margin:0;padding:0;line-height:1.8;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";background-color:#252525;color:#fff;transition:opacity .25s ease-in-out}:host([aria-hidden="true"]){opacity:0;pointer-events:none}main{position:absolute;top:0;left:0;width:100%;height:100vh}h1{margin-top:0;font-size:24px;font-weight:300;line-height:1.4}p{margin:20px 0;font-weight:300}button{cursor:pointer}aside{position:absolute;top:0;left:0;width:350px;height:100vh;padding:60px 0 0 50px;background-color:#121212}aside ul{margin:30px 0 0;padding:0;list-style:none}aside li{position:relative;margin:0;padding:20px 10px;font-weight:300}aside li.highlight{color:#48a1ff}aside li.active{font-weight:700}aside li .circle{position:absolute;top:20px;left:10px;width:24px;height:24px;border:3px solid white;border-radius:50%;font-size:14px}aside li.highlight .circle{border-color:#48a1ff}aside li.active .circle:after{content:"";position:absolute;top:3px;left:3px;width:12px;height:12px;border-radius:50%;background-color:#48a1ff}aside li.completed .circle{background-color:#48a1ff}aside li.completed .circle:after{content:"";position:absolute;top:2px;left:6px;width:6px;height:13px;border:3px solid black;border-top:none;border-left:none;transform:rotate(45deg)}aside li .line{position:absolute;top:44px;left:21px;width:3px;height:45px;background-color:#fff}aside li.completed .line{background-color:#48a1ff}aside li span{display:block;margin-left:44px}nav{margin-top:30px}section{position:absolute;top:135px;left:350px;padding:0 80px 0 140px;transition:opacity .15s ease-in-out}section[aria-hidden=true]{pointer-events:none;opacity:0}section h1,section p{min-width:300px;max-width:600px}.button{position:relative;display:inline-block;color:#fff;background-color:#48a1ff;border-radius:4px;text-decoration:none;padding:10px 40px 10px 20px;white-space:nowrap}.button:hover{background-color:#48a1ffd9}#button-icon{position:absolute;top:1px;right:5px;bottom:0;width:30px;background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="none" stroke="white" stroke-linecap="square" stroke-miterlimit="10" stroke-width="48" d="M184 112l144 144-144 144"/></svg>');background-repeat:no-repeat;background-position:center;background-size:24px 24px}.button[aria-disabled=true]{opacity:.9;background-color:#ffffff4d;pointer-events:none;padding-right:60px}.button[aria-disabled=true] #button-icon{top:21px;right:29px;width:8px;height:8px;border-radius:4px;background:#fff;color:#fff;animation:dot-flashing .5s infinite linear alternate;animation-delay:.25s}.button[aria-disabled=true] #button-icon:before,.button[aria-disabled=true] #button-icon:after{content:"";display:inline-block;position:absolute;top:0}.button[aria-disabled=true] #button-icon:before{left:-12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:0s}.button[aria-disabled=true] #button-icon:after{left:12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:.5s}@keyframes dot-flashing{0%{background-color:#fff}50%,to{background-color:#ffffff4d}}.logo{margin-left:9px;background:url('data:image/svg+xml,<svg viewBox="0 0 150 32" fill="none" xmlns="http://www.w3.org/2000/svg" > <g clip-path="url(%23clip0_4_304)"> <path d="M27.9858 8.99927C27.9872 10.3415 27.688 11.667 27.1101 12.8783C26.5321 14.0896 25.6902 15.156 24.6462 15.9989V15.9989L0.634502 2.36355C0.542657 2.31119 0.457444 2.24796 0.380701 2.17523C0.260289 2.05715 0.164605 1.91624 0.0992389 1.76075C0.0338732 1.60525 0.000136546 1.43828 0 1.26959C0 0.932873 0.133698 0.609948 0.371683 0.371854C0.609667 0.13376 0.932443 0 1.269 0L18.9906 0C21.3763 0 23.6642 0.948135 25.3512 2.63583C27.0381 4.32352 27.9858 6.61252 27.9858 8.99927V8.99927Z" fill="%2318B4F4" /> <path d="M27.9858 22.9986C27.9861 24.1806 27.7536 25.351 27.3017 26.4431C26.8498 27.5352 26.1873 28.5275 25.352 29.3634C24.5167 30.1993 23.5249 30.8624 22.4335 31.3147C21.342 31.7671 20.1721 32 18.9907 32H1.26906C1.01802 31.9973 0.77343 31.9202 0.566221 31.7784C0.359012 31.6366 0.198499 31.4364 0.104989 31.2034C0.0114791 30.9703 -0.0108254 30.7147 0.0408974 30.4689C0.0926201 30.2231 0.216046 29.9982 0.395559 29.8226V29.8226C0.467112 29.7508 0.547407 29.6882 0.634555 29.6364L10.0844 24.2703L24.6441 16.001C25.688 16.8438 26.53 17.9097 27.1083 19.1206C27.6866 20.3315 27.9864 21.6566 27.9858 22.9986V22.9986Z" fill="%23FD6B3C" /> <path d="M24.6461 15.9989L10.0843 24.2703L0.634458 29.6365C0.54372 29.6868 0.459841 29.7487 0.384888 29.8205C3.98804 26.1233 6.00266 21.1627 5.99812 15.9989C6.0049 10.8346 3.99085 5.87268 0.387003 2.17523C0.463746 2.24796 0.548959 2.31119 0.640803 2.36355L24.6461 15.9989Z" fill="%23A97FF2" /> <path d="M47.6659 11.7352C51.8177 11.7352 54.1632 15.0531 54.1632 19.0714C54.1632 23.0896 51.8177 26.3821 47.6659 26.3821C45.5086 26.3821 43.8589 25.5188 42.9473 24.0545L42.5709 26.052H39.9736V6.77115H43.1884V13.8914C43.971 12.6959 45.5086 11.7352 47.6659 11.7352ZM47.0187 23.5488C49.4446 23.5488 50.9547 21.5809 50.9547 19.0714C50.9547 16.5089 49.4446 14.5664 47.0187 14.5664C44.5928 14.5664 43.0806 16.5047 43.0806 19.0714C43.0806 21.583 44.5653 23.5488 47.0187 23.5488V23.5488Z" fill="white" /> <path d="M65.4595 20.2859V12.0611H68.668V20.123C68.668 23.7202 67.0246 26.3821 62.4943 26.3821C57.9639 26.3821 56.3206 23.7117 56.3206 20.123V12.0611H59.529V20.2859C59.529 22.4696 60.5527 23.5488 62.49 23.5488C64.4274 23.5488 65.4595 22.4696 65.4595 20.2859Z" fill="white" /> <path d="M71.2355 7.74451C71.2247 7.46284 71.2724 7.18199 71.3755 6.91968C71.4787 6.65737 71.6351 6.41929 71.8348 6.22047C72.0345 6.02165 72.2732 5.8664 72.5359 5.76452C72.7986 5.66264 73.0796 5.61633 73.3611 5.62853C74.5793 5.62853 75.4571 6.50666 75.4571 7.75509C75.4571 9.00352 74.5793 9.8224 73.3611 9.8224C72.1428 9.8224 71.2355 8.9612 71.2355 7.74451Z" fill="white" /> <path d="M128.476 7.74451C128.465 7.46376 128.513 7.18383 128.615 6.92227C128.718 6.66071 128.873 6.42315 129.072 6.22449C129.27 6.02583 129.508 5.87035 129.769 5.7678C130.031 5.66524 130.31 5.61783 130.591 5.62852C131.809 5.62852 132.687 6.50666 132.687 7.75509C132.687 9.00352 131.809 9.8224 130.591 9.8224C129.373 9.8224 128.476 8.9612 128.476 7.74451Z" fill="white" /> <path d="M122.302 24.1031C122.291 23.8223 122.339 23.5422 122.441 23.2805C122.543 23.0188 122.699 22.7811 122.897 22.5824C123.096 22.3837 123.334 22.2282 123.595 22.1258C123.857 22.0233 124.137 21.9761 124.417 21.9872C125.636 21.9872 126.513 22.8653 126.513 24.1031C126.513 25.341 125.636 26.1726 124.417 26.1726C123.199 26.1726 122.302 25.3219 122.302 24.1031Z" fill="white" /> <path d="M74.9516 12.059H71.7432V26.0583H74.9516V12.059Z" fill="white" /> <path d="M78.16 26.0583V6.77115H81.3685V26.0626L78.16 26.0583Z" fill="white" /> <path d="M94.6063 6.77115H97.8148V26.0626H95.2239L94.8474 24.0651C93.9591 25.523 92.3094 26.3927 90.131 26.3927C86.0046 26.3927 83.6591 23.0748 83.6591 19.0819C83.6591 15.0891 86.0046 11.7458 90.131 11.7458C92.3137 11.7458 93.8238 12.7149 94.6063 13.902V6.77115ZM90.7993 14.5707C88.3734 14.5707 86.8633 16.5131 86.8633 19.0756C86.8633 21.5851 88.3734 23.553 90.7993 23.553C93.2252 23.553 94.7354 21.5851 94.7354 19.0756C94.7396 16.5047 93.257 14.5664 90.8036 14.5664L90.7993 14.5707Z" fill="white" /> <path d="M113.479 22.2284C112.482 24.7359 110.162 26.3821 107.117 26.3821C102.887 26.3821 100.137 23.225 100.137 19.0439C100.137 14.9706 102.942 11.7353 107.093 11.7353C111.245 11.7353 113.969 14.8902 113.969 18.991C113.982 19.3255 113.953 19.6604 113.883 19.9876H103.288C103.53 22.2009 104.959 23.6292 107.197 23.6292C108.735 23.6292 110.001 22.8738 110.594 21.473L113.479 22.2284ZM103.341 17.6156H110.784C110.513 15.6731 109.166 14.3506 107.089 14.3506C105.012 14.3506 103.665 15.7006 103.341 17.6156V17.6156Z" fill="white" /> <path d="M123.779 14.9452C123.538 14.9117 123.295 14.8933 123.051 14.8902C120.786 14.8902 119.439 16.0772 119.439 18.7751V26.0583H116.23V12.0611H118.821L119.195 14.0014C119.707 13.1127 120.887 11.9257 123.322 11.9257C123.455 11.9257 123.779 11.9532 123.779 11.9532V14.9452Z" fill="white" /> <path d="M132.192 12.059H128.984V26.0583H132.192V12.059Z" fill="white" /> <path d="M134.483 19.0714C134.483 15.1335 137.287 11.7353 141.735 11.7353C146.183 11.7353 149.015 15.1335 149.015 19.0714C149.015 23.0092 146.213 26.3821 141.735 26.3821C137.258 26.3821 134.483 23.0092 134.483 19.0714ZM141.735 23.5488C144.083 23.5488 145.806 21.7692 145.806 19.0714C145.806 16.3735 144.083 14.5664 141.735 14.5664C139.387 14.5664 137.687 16.346 137.687 19.0714C137.687 21.7968 139.417 23.5488 141.735 23.5488V23.5488Z" fill="white" /> </g> <defs> <clipPath id="clip0_4_304"> <rect width="149.015" height="32" fill="white" /> </clipPath> </defs> </svg>');background-repeat:no-repeat;width:150px;height:32px}@media(max-width:840px){aside{width:250px;padding:60px 0 0 20px}section{left:250px;padding:0 80px}}@media(max-width:590px){aside{width:230px;padding:60px 0 0 10px}section{left:230px;padding:0 40px}}#modified-files-message a{color:#cbcbcb;font-weight:300;text-decoration:underline}#modified-files-message a:hover{color:#fff;text-decoration:none}#restart-warning{border-radius:4px;padding:8px 16px;border:1px solid #fd6b3c;background:#fd6b3c1a}#react-router-steps{margin:0 0 5px;padding:0 20px}#need-help{color:#48a1ff;text-decoration:none}#router-message{border-radius:4px;padding:16px;border:1px solid #48a1ff}#router-finish-button{margin-top:12px}#router-checkbox-div{display:flex;align-items:center}#router-checkbox{margin-right:10px;width:15px;height:15px}#success-title{display:flex;align-items:center;gap:10px}#success-title .check-icon{display:inline-block;width:24px;height:24px;border:2px solid #28a745;border-radius:50%;position:relative}#success-title .check-icon:before{content:"";position:absolute;top:50%;left:50%;width:6px;height:12px;border:solid #28a745;border-width:0 2px 2px 0;transform:translate(-50%,-60%) rotate(45deg)}
1279
+ \`,t.appendChild(e),setTimeout(()=>{e.classList.add("menu-toggle-tooltip-show"),e.addEventListener("click",()=>{e.classList.remove("menu-toggle-tooltip-show")})},1e3)};function ui(t){t.getElementById("go-to-builder").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(Ur(),"builder")}),t.getElementById("components-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let c=t.querySelector(".nav-cmp-list .section-content");c.scrollTop=0,oe(t,"nav-cmp-list"),ai(t)}),t.getElementById("settings-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),oe(t,"nav-settings")}),t.getElementById("add-page-link").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open(je(),"builder")}),t.getElementById("import-from-figma").addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),Ee(t,!1),window.open("https://www.figma.com/community/plugin/747985167520967365/builder-io-ai-powered-figma-to-code-react-vue-tailwind-more")})}function ci(t){let e=t.getElementById("enable-edit");e.addEventListener("change",r=>{r.stopPropagation(),Ht(e.checked)}),e.checked=it(),Ht(e.checked)}var Dt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=\`<style>*,*:before,*:after{box-sizing:border-box}:host{--background-color: rgba(40, 40, 40, 1);--primary-color: rgba(72, 161, 255, 1);--primary-color-subdued: rgb(72, 161, 255, .6);--primary-color-highlight: rgb(126, 188, 255);--primary-contrast-color: white;--edit-color: #1d74e2;--edit-color-highlight: #1c6bd1;--edit-color-alpha: rgb(72, 161, 255, .15);--error-color: #ff2b55;--text-color: white;--text-color-highlight: white;--border-color: #454545;--button-background-color-hover: rgba(255, 255, 255, .1);--menu-width: 320px;--transition-time: .15s;--font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-family:var(--font-family);line-height:1.6}button{cursor:pointer;color:var(--text-color);-webkit-tap-highlight-color:transparent}input,select,button{font-family:var(--font-family)}.menu-toggle{position:absolute;right:0;bottom:0;pointer-events:auto;padding:8px;background:transparent;border:none;appearance:none}.menu-toggle div{position:relative;width:64px;height:64px;pointer-events:none;border-radius:50%;background:#000;border:1px solid white;box-shadow:#00000054 0 0 8px}.menu-toggle:hover div{background-color:var(--background-color);border:1px solid rgb(220,220,220)}.menu-toggle svg{position:absolute;top:15px;left:15px;width:33px;height:32px}div.highlight-bg{position:absolute;top:-1px;left:-1px;background-color:#1a1a1a;pointer-events:none;transition:all .4s ease-out;opacity:0}.menu-toggle-highlight-no-transition div.highlight-bg{transition:none}.menu-toggle-highlight div.highlight-bg{opacity:1}.menu-toggle-tooltip{position:absolute;bottom:0;right:0;width:382px;height:72px;padding:0;text-align:left;appearance:none;background-color:transparent;border:none;pointer-events:none;transform:translate3d(320px,0,0);opacity:0;transition:all .15s ease-in-out;color:#fff}.menu-toggle-tooltip.menu-toggle-tooltip-show{pointer-events:auto;opacity:1;transform:translateZ(0)}.menu-toggle-tooltip-content{position:absolute;inset:0 95px 10px 0;padding:8px 12px;background-color:var(--primary-color);box-shadow:#00000054 0 0 20px;border-radius:2px}.menu-toggle-tooltip-content:before{content:"";position:absolute;bottom:15px;right:-6px;width:30px;height:30px;background-color:var(--primary-color);transform:rotate(45deg)}.menu-toggle-tooltip:hover .menu-toggle-tooltip-content,.menu-toggle-tooltip:hover .menu-toggle-tooltip-content:before{background-color:var(--primary-color-highlight)}.menu-toggle-tooltip-content h3{margin:0;font-size:16px}.menu-toggle-tooltip-content p{margin:0;font-size:12px}section{position:absolute;display:grid;grid-template-rows:64px auto 64px;top:0;left:0;width:100%;height:100%;padding:0;pointer-events:none}.section-content{margin:0;padding:0 0 10px;font-weight:300;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;overflow-y:auto}.section-content .error{color:var(--error-color);font-weight:700}section a{text-decoration:none;color:var(--text-color)}section h3,section p{margin-left:16px;margin-right:16px}.info{font-size:12px}ul.list{list-style:none;padding:0;margin:0}ul.list li{display:block;padding:0;margin:0}ul.list a,ul.list button{display:grid;grid-template-columns:24px auto;grid-gap:16px;padding:12px;margin:8px 0;border:none;background:transparent;appearance:none;width:100%;font-weight:300;text-align:left;text-decoration:none;color:var(--text-color)}ul.list a:hover,ul.list button:hover{text-decoration:none;color:var(--text-color);background-color:var(--button-background-color-hover)}ul.list a span,ul.list button span{display:block;font-size:16px;font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}header{position:relative;display:grid;grid-template-columns:44px 1fr;gap:8px;padding-left:8px;border-bottom:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}header>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nav-home header>div{margin-right:56px}header h2{margin:7px 0 0;font-size:18px;font-weight:500;line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p{margin:2px 0 0;font-size:12px;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button{display:block;margin:0;padding:0;width:100%;font-size:12px;font-weight:300;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header p button:hover{text-decoration:underline;color:var(--primary-color)}.builder-logo{margin:12px 0 0 8px}#close{display:block;position:absolute;appearance:none;background:transparent;border:none;border-radius:50%;margin:0;padding:0;right:4px;top:8px;width:48px;height:48px;z-index:1;opacity:.7}#close:hover{opacity:1;background-color:var(--button-background-color-hover)}#close svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}.back-button{position:relative;display:block;margin:7px 0 0 -2px;width:48px;height:48px;background:transparent;border:none;appearance:none;border-radius:50%}.back-button:hover{background-color:var(--button-background-color-hover)}.back-button svg{position:absolute;top:12px;left:12px;width:24px;height:24px;fill:currentColor;pointer-events:none}footer{border-top:1px solid var(--border-color);transition:opacity var(--transition-time) ease-in-out;opacity:0;pointer-events:none}section.nav-cmp-list{grid-template-rows:64px auto 120px}footer a{text-decoration:underline;color:var(--primary-color)}footer a:hover{color:var(--primary-color);text-decoration:none}.nav-list{padding:2px 0}.nav-loading{pointer-events:none}.nav-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.nav-loading .nav-loading-icon{opacity:.5}.nav-list h4{margin:8px 8px 8px 10px;font-size:14px;font-weight:600}.nav-list .nav-list-item+h4{margin-top:30px}.nav-list-item{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:relative;margin:2px 0;padding:8px 28px 8px 46px;width:100%;font-size:14px;font-weight:300;text-align:left;border:none;background:transparent;appearance:none}.nav-list-item:hover{background-color:var(--button-background-color-hover)}.nav-list-item-icon{position:absolute;top:4px;left:10px;width:24px;height:24px;object-fit:contain;filter:invert(100%);background-size:24px 24px;background-repeat:no-repeat;background-position:center center}.nav-list-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none}.nav-list-item:after{display:block;position:absolute;content:"";background-image:url('data:image/svg+xml,<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L7 7L1 13" stroke="%23F2F2F2" stroke-opacity="0.5" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');background-repeat:no-repeat;background-position:12px 9px;top:0;right:0;width:32px;height:32px;pointer-events:none}.nav-list-item-note{opacity:0;font-size:12px;padding-top:1px;text-align:right}.nav-list-item:hover .nav-list-item-note{opacity:.5}.ui-select{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-select h3{margin:0;font-size:14px;font-weight:500}.ui-select p{margin:8px 0;font-size:12px;font-weight:300}.ui-select .select{position:relative;margin:8px 0;border-radius:4px;padding:0;line-height:1.1;overflow:hidden;border:1px solid var(--border-color)}.ui-select select{appearance:none;background-color:transparent;border:none;outline:none;padding:8px 32px 8px 8px;margin:0;width:100%;font-size:14px;cursor:pointer;text-overflow:ellipsis;opacity:.6;color:var(--text-color)}.ui-select .select:after{content:"";top:6px;right:5px;width:24px;height:24px;position:absolute;background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="%23F2F2F2" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/></svg>');background-repeat:no-repeat;background-position:center;pointer-events:none;opacity:.6}.ui-select .select:hover{border-color:var(--primary-color-subdued)}.ui-text-input .select:focus-within{border-color:var(--primary-color)}.ui-text-input .select:focus-within select{opacity:1}.spinner:after{content:" ";display:block;width:32px;height:32px;margin:0 auto;pointer-events:auto;border-radius:50%;border:3px solid var(--text-color);border-color:var(--text-color) transparent var(--text-color) transparent;animation:spinner .75s linear infinite}@keyframes spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.ui-switch{display:grid;grid-template-columns:auto 48px;grid-gap:20px;margin:8px 0 16px;padding:8px 0 8px 16px;cursor:pointer}.ui-switch>*{pointer-events:none}.ui-switch input{display:none;visibility:hidden}.ui-switch .switcher{display:inline-block;border-radius:100px;width:35px;height:14px;background-color:#ccc;position:relative;top:6px;vertical-align:middle;cursor:pointer}.ui-switch input[type=checkbox]:checked+.switcher{background-color:var(--primary-color-subdued)}.ui-switch .switcher:before{content:"";display:block;width:20px;height:20px;background-color:var(--text-color);box-shadow:0 1px 3px #0009;border-radius:50%;position:absolute;top:-3px;left:0;margin-right:0;transition:all .15s}.ui-switch input[type=checkbox]:checked+.switcher:before{left:100%;margin-left:-20px;background-color:var(--primary-color)}.ui-switch h3{margin:0;font-size:14px;font-weight:500}.ui-switch p{margin:4px 0 0;font-size:12px;font-weight:300}.ui-text-input{display:block;margin:8px 0 16px;padding:8px 16px;cursor:pointer}.ui-text-input h3{margin:0;font-size:14px;font-weight:500}.ui-text-input p{margin:8px 0;font-size:12px;font-weight:300}.ui-text-input .input{position:relative;margin:8px 0;border:1px solid var(--border-color);border-radius:4px;background:transparent;padding:2px;overflow:hidden}.ui-text-input input{display:block;width:235px;font-size:14px;border:none;background:transparent;padding:6px;appearance:none;color:var(--text-color);opacity:.6;outline:none}.ui-text-input .input:hover{border-color:var(--primary-color-subdued)}.ui-text-input .input:focus-within{border-color:var(--primary-color)}.ui-text-input .input:focus-within input{opacity:1}.ui-text-input .input:after{content:"";position:absolute;top:5px;right:14px;width:8px;height:17px;border:2px solid rgba(51,181,51,1);border-top:none;border-left:none;transform:rotate(45deg);opacity:0;transition:opacity 80ms ease-in-out;pointer-events:none}.ui-text-input.saved .input:after{opacity:1}.ui-toast{position:fixed;bottom:8px;left:8px;right:8px;padding:6px 12px;font-size:14px;border-radius:4px;transform:translate3d(0,150%,0);opacity:0;transition:all var(--transition-time) ease-in-out;background-color:var(--primary-color-subdued);color:var(--text-color);pointer-events:none}.ui-toast.ui-toast-show{transform:translateZ(0);opacity:1;pointer-events:auto}[data-view=nav-home] .nav-home .section-content,[data-view=nav-cmp-list] .nav-cmp-list .section-content,[data-view=nav-cmp-detail] .nav-cmp-detail .section-content,[data-view=nav-cmp-input] .nav-cmp-input .section-content,[data-view=nav-settings] .nav-settings .section-content{transform:translateZ(0);pointer-events:auto}[data-view=nav-home] .nav-home header,[data-view=nav-home] .nav-home footer,[data-view=nav-cmp-list] .nav-cmp-list header,[data-view=nav-cmp-list] .nav-cmp-list footer,[data-view=nav-cmp-detail] .nav-cmp-detail header,[data-view=nav-cmp-detail] .nav-cmp-detail footer,[data-view=nav-cmp-input] .nav-cmp-input header,[data-view=nav-cmp-input] .nav-cmp-input footer,[data-view=nav-settings] .nav-settings header,[data-view=nav-settings] .nav-settings footer{opacity:1;pointer-events:auto}[data-view=nav-cmp-list] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-home .section-content,[data-view=nav-cmp-detail] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-home .section-content,[data-view=nav-cmp-input] .nav-cmp-list .section-content,[data-view=nav-cmp-input] .nav-cmp-detail .section-content,[data-view=nav-settings] .nav-home .section-content{transform:translate3d(-105%,0,0)}.cmp-item .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20.83 16.809C20.94 16.561 21 16.289 21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L7.988 3.99001M5.441 5.44801L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L18.544 18.56" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.532 10.538L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.27002 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><path d="M3 3L21 21" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>');opacity:.3}.cmp-item.registered .nav-list-item-icon{background-image:url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /></svg>');opacity:.8}.search-highlight{background-color:var(--primary-color-alpha);padding:0 2px;border-radius:2px;font-weight:500}.search-container{position:sticky;top:0;z-index:10;padding:12px 16px;background:var(--background-color);border-bottom:1px solid var(--border-color)}.search-input-wrapper{position:relative;display:flex;align-items:center}.search-icon{position:absolute;left:12px;color:var(--text-color-secondary);pointer-events:none}.component-search-input{width:100%;height:36px;padding:8px 36px;border:1px solid var(--border-color);border-radius:6px;background:var(--input-background);color:var(--text-color);font-size:14px;transition:border-color .2s,box-shadow .2s}.component-search-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 2px var(--primary-color-alpha)}.component-search-input::placeholder{color:var(--text-color-tertiary)}.clear-search-button{position:absolute;right:8px;padding:4px;color:var(--text-color-secondary);border:none;background:transparent;border-radius:4px;cursor:pointer;opacity:0;transition:opacity .2s,background-color .2s;display:flex;align-items:center;justify-content:center}.clear-search-button:hover{background-color:var(--hover-color)}.component-search-input:not(:placeholder-shown)+.clear-search-button{opacity:1}.no-results{padding:32px 16px;text-align:center;color:var(--text-color-secondary);font-size:14px}#cmp-detail{position:relative}.cmp-loading{pointer-events:none!important}.cmp-loading-icon{position:absolute;display:inline-block;top:170px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.cmp-loading .cmp-loading-icon{opacity:.5}.cmp-cover{position:absolute;top:160px;left:0;width:100%;height:100vh;background:var(--background-color);transform:translateZ(0);pointer-events:none;display:none}[data-view=nav-cmp-detail] .cmp-cover{display:block;pointer-events:auto}.cmp-enabled .cmp-cover{transform:translate3d(0,105%,0);pointer-events:none}.section-ready .cmp-cover{transition:all var(--transition-time) ease-in-out}.cmp-detail-inputs-container{margin:8px 0 16px;padding:0}.cmp-detail-inputs-container h3{margin:0 0 6px;padding-left:16px;padding-right:8px;font-size:14px;font-weight:500;display:flex;justify-content:space-between;align-items:center}.cmp-detail-inputs-reload{font-weight:300;font-size:.9em;text-decoration:none;appearance:none;text-align:left;background-color:transparent;border:none;color:var(--primary-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cmp-detail-inputs-reload:hover{text-decoration:underline;color:var(--primary-color)}.cmp-detail-inputs-container .cmp-inputs-empty{padding:0;margin-top:12px;font-size:12px;font-weight:300;opacity:.5;font-style:italic}.cmp-detail-inputs-container .nav-list-item-icon{opacity:.8;background-size:20px 20px;background-position:4px center}.input-icon{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path></svg>')}.input-icon-array{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-6a2 2 0 1 1 4 0v6"></path> <path d="M10 13h4"></path></svg>')}.input-icon-boolean{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16h2a2 2 0 1 0 0 -4h-2h2a2 2 0 1 0 0 -4h-2v8z"></path></svg>')}.input-icon-number{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 16v-8l4 8v-8"></path></svg>')}.input-icon-object{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path></svg>')}.input-icon-string{background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path> <path d="M10 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path></svg>')}.cmp-input-item-unregistered{opacity:.4}.cmp-input-item-unregistered .input-icon:after{content:"";position:absolute;top:11px;left:4px;width:20px;height:2px;background-color:#000;transform:rotate(-45deg)}.cmp-prop-info{border-bottom:1px solid var(--border-color)}.cmp-input-readonly{margin:16px 0;padding:0 16px;display:grid;grid-template-columns:50% 50%;gap:12px}.cmp-input-readonly h3{margin:0;font-size:14px;font-weight:500}.cmp-input-readonly span{margin-top:2px;font-size:12px;font-weight:300;opacity:.8}.cmp-input-detail{margin:16px 0}.cmp-input-detail a{color:var(--primary-color);text-decoration:none}.cmp-input-detail a:hover{text-decoration:underline}.input-cover{position:absolute;top:175px;left:0;width:100%;height:100%;background:var(--background-color);transform:translateZ(0);transition:all var(--transition-time) ease-in-out;pointer-events:auto}.input-enabled .input-cover{transform:translate3d(0,105%,0);pointer-events:none}.input-loading-icon{position:absolute;display:inline-block;top:190px;left:0;width:100%;transform:translateZ(0);pointer-events:auto;opacity:0;transition:all 50ms ease-in-out;transition-delay:50ms;pointer-events:none}.input-loading .input-loading-icon{opacity:.5}:host{position:fixed;inset:0;z-index:2147483646;user-select:none;pointer-events:none;color:var(--text-color)}aside{position:absolute;top:0;right:0;width:var(--menu-width);height:100%;transform:translate3d(105%,0,0);transition:transform var(--transition-time) ease-in-out;background:var(--background-color);box-shadow:#000000c9 5px 0 20px;overflow:hidden;z-index:1}:host(.show-builder-menu) aside{pointer-events:auto;transform:translateZ(0)}#hit{position:absolute;inset:0;display:none}:host(.show-builder-menu) #hit{display:block;pointer-events:auto}#version{position:absolute;bottom:6px;right:6px;font-size:8px;color:#9b9b9b}</style><div id="hit"></div> <aside data-view="nav-home"> <section class="nav-home"> <header> <svg class="builder-logo" viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> <div> <h2 class="builder-home-title">Builder Devtools</h2> <p><button id="go-to-builder">Go to Builder</button></p> </div> <button id="close" aria-label="Close Menu"> <svg viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M18 6l-12 12" /> <path d="M6 6l12 12" /> </svg> </button> </header> <div class="section-content"> <ul class="list"> <li> <button id="components-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M21 16.008V7.99001C20.9994 7.64108 20.9066 7.29851 20.731 6.99699C20.5554 6.69547 20.3032 6.44571 20 6.27301L13 2.26501C12.6954 2.09103 12.3508 1.99951 12 1.99951C11.6492 1.99951 11.3046 2.09103 11 2.26501L4 6.27301C3.381 6.62801 3 7.28301 3 7.99101V16.009C3 16.718 3.381 17.372 4 17.726L11 21.734C11.3046 21.908 11.6492 21.9995 12 21.9995C12.3508 21.9995 12.6954 21.908 13 21.734L20 17.726C20.619 17.371 21 16.716 21 16.008Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 22V12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 12L20.73 6.95996" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M3.26999 6.95996L12 12" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Components</span> </button> </li> <li> <button id="settings-link"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M10.325 4.317C10.751 2.561 13.249 2.561 13.675 4.317C13.7389 4.5808 13.8642 4.82578 14.0407 5.032C14.2172 5.23822 14.4399 5.39985 14.6907 5.50375C14.9414 5.60764 15.2132 5.65085 15.4838 5.62987C15.7544 5.60889 16.0162 5.5243 16.248 5.383C17.791 4.443 19.558 6.209 18.618 7.753C18.4769 7.98466 18.3924 8.24634 18.3715 8.51677C18.3506 8.78721 18.3938 9.05877 18.4975 9.30938C18.6013 9.55999 18.7627 9.78258 18.9687 9.95905C19.1747 10.1355 19.4194 10.2609 19.683 10.325C21.439 10.751 21.439 13.249 19.683 13.675C19.4192 13.7389 19.1742 13.8642 18.968 14.0407C18.7618 14.2172 18.6001 14.4399 18.4963 14.6907C18.3924 14.9414 18.3491 15.2132 18.3701 15.4838C18.3911 15.7544 18.4757 16.0162 18.617 16.248C19.557 17.791 17.791 19.558 16.247 18.618C16.0153 18.4769 15.7537 18.3924 15.4832 18.3715C15.2128 18.3506 14.9412 18.3938 14.6906 18.4975C14.44 18.6013 14.2174 18.7627 14.0409 18.9687C13.8645 19.1747 13.7391 19.4194 13.675 19.683C13.249 21.439 10.751 21.439 10.325 19.683C10.2611 19.4192 10.1358 19.1742 9.95929 18.968C9.7828 18.7618 9.56011 18.6001 9.30935 18.4963C9.05859 18.3924 8.78683 18.3491 8.51621 18.3701C8.24559 18.3911 7.98375 18.4757 7.752 18.617C6.209 19.557 4.442 17.791 5.382 16.247C5.5231 16.0153 5.60755 15.7537 5.62848 15.4832C5.64942 15.2128 5.60624 14.9412 5.50247 14.6906C5.3987 14.44 5.23726 14.2174 5.03127 14.0409C4.82529 13.8645 4.58056 13.7391 4.317 13.675C2.561 13.249 2.561 10.751 4.317 10.325C4.5808 10.2611 4.82578 10.1358 5.032 9.95929C5.23822 9.7828 5.39985 9.56011 5.50375 9.30935C5.60764 9.05859 5.65085 8.78683 5.62987 8.51621C5.60889 8.24559 5.5243 7.98375 5.383 7.752C4.443 6.209 6.209 4.442 7.753 5.382C8.753 5.99 10.049 5.452 10.325 4.317Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> <path d="M9 12C9 12.7956 9.31607 13.5587 9.87868 14.1213C10.4413 14.6839 11.2044 15 12 15C12.7956 15 13.5587 14.6839 14.1213 14.1213C14.6839 13.5587 15 12.7956 15 12C15 11.2044 14.6839 10.4413 14.1213 9.87868C13.5587 9.31607 12.7956 9 12 9C11.2044 9 10.4413 9.31607 9.87868 9.87868C9.31607 10.4413 9 11.2044 9 12Z" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Settings</span> </button> </li> <li> <button id="add-page-link"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M14 3v4a1 1 0 0 0 1 1h4" /> <path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /> <path d="M12 11l0 6" /> <path d="M9 14l6 0" /> </svg> <span>Add Builder Page</span> </button> </li> <li> <button id="import-from-figma"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-figma" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" > <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M15 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /> <path d="M6 3m0 3a3 3 0 0 1 3 -3h6a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3 -3z" /> <path d="M9 9a3 3 0 0 0 0 6h3m-3 0a3 3 0 1 0 3 3v-15" /> </svg> <span>Import From Figma</span> </button> </li> </ul> </div> <footer> <ul class="list"> <li> <a href="https://docs.google.com/forms/d/e/1FAIpQLSdqZcJpRtm_Ia5DTHP6SDY9Xa6LID3KiTjRWkjMzWyJRUtSHw/viewform" target="_blank" > <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M11.013 17.0114L10.013 18.0114L2.513 10.5834C2.0183 10.102 1.62864 9.52342 1.36854 8.88404C1.10845 8.24466 0.983558 7.55836 1.00173 6.86834C1.01991 6.17832 1.18076 5.49954 1.47415 4.87474C1.76755 4.24994 2.18713 3.69266 2.70648 3.23799C3.22583 2.78331 3.8337 2.4411 4.49181 2.23289C5.14991 2.02468 5.844 1.95499 6.53036 2.02821C7.21673 2.10143 7.8805 2.31596 8.47987 2.65831C9.07925 3.00066 9.60124 3.46341 10.013 4.01741C10.8086 2.95654 11.9931 2.2552 13.3059 2.06766C14.6186 1.88012 15.9521 2.22176 17.013 3.01741C18.0739 3.81306 18.7752 4.99755 18.9627 6.3103C19.1503 7.62305 18.8086 8.95654 18.013 10.0174" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> <path d="M18.2006 19.8175L16.0286 20.9555C15.9642 20.989 15.8917 21.004 15.8192 20.9987C15.7467 20.9934 15.6771 20.9681 15.6182 20.9256C15.5593 20.8831 15.5134 20.825 15.4855 20.7579C15.4577 20.6907 15.4491 20.6172 15.4606 20.5455L15.8756 18.1345L14.1186 16.4275C14.0662 16.3768 14.0291 16.3123 14.0115 16.2416C13.9939 16.1708 13.9966 16.0965 14.0192 16.0271C14.0418 15.9578 14.0835 15.8962 14.1394 15.8494C14.1954 15.8026 14.2634 15.7725 14.3356 15.7625L16.7636 15.4105L17.8496 13.2175C17.8821 13.1521 17.9322 13.0972 17.9942 13.0588C18.0562 13.0204 18.1277 13 18.2006 13C18.2736 13 18.3451 13.0204 18.4071 13.0588C18.4691 13.0972 18.5191 13.1521 18.5516 13.2175L19.6376 15.4105L22.0656 15.7625C22.1377 15.7728 22.2054 15.8031 22.2611 15.85C22.3168 15.8968 22.3583 15.9583 22.3809 16.0275C22.4034 16.0967 22.4062 16.1708 22.3888 16.2415C22.3715 16.3122 22.3347 16.3766 22.2826 16.4275L20.5256 18.1345L20.9396 20.5445C20.9521 20.6163 20.9441 20.6902 20.9166 20.7578C20.8891 20.8254 20.8433 20.8839 20.7842 20.9267C20.7252 20.9695 20.6553 20.9949 20.5825 21C20.5098 21.005 20.4371 20.9896 20.3726 20.9555L18.2006 19.8175Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span>Give Feedback</span> </a> </li> </ul> <div id="version"></div> </footer> </section> <section class="nav-cmp-list"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div class="search-container"> <div class="search-input-wrapper"> <svg class="search-icon" viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M15.5 15.5L20 20M10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10C17 13.866 13.866 17 10 17Z" /> </svg> <input type="text" id="component-search" class="component-search-input" placeholder="Search components..." autocomplete="off" spellcheck="false" /> <button id="clear-search" class="clear-search-button" type="button" aria-label="Clear search" > <svg viewBox="0 0 24 24" width="16" height="16"> <path fill="none" stroke="currentColor" stroke-width="2" d="M6 6l12 12M6 18L18 6" /> </svg> </button> </div> </div> <div> <h2>Custom Components</h2> <p> <button id="open-builder-registry"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-list" class="cmp-list nav-list"></div> </div> <div class="nav-loading-icon spinner"></div> <footer> <p class="info"> Expand on Builder's selection of built-in blocks by <a target="_blank" href="https://www.builder.io/c/docs/custom-components-intro" >registering components</a > from your codebase. This way, teammates can drag and drop your components within Builder's Visual Editor just like any other block. </p> </footer> </section> <section class="nav-cmp-detail"> <header> <button class="back-button" data-back="nav-cmp-list"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-detail-title"></h2> <p> <button id="cmp-open-source"></button> </p> </div> </header> <div class="section-content"> <div id="cmp-error"></div> <label class="ui-switch"> <div> <h3>Register Component</h3> <p> Registers this component so it can be used within Builder Visual CMS </p> </div> <input type="checkbox" role="switch" id="cmp-register" /> <span class="switcher"></span> </label> <div id="cmp-detail"> <label class="ui-text-input"> <h3>Component Name</h3> <div class="input"> <input type="text" id="cmp-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="2" maxlength="30" required placeholder="e.g. My Counter" /> </div> <p> Unique name to identify this custom component within Builder. Press ESC to cancel </p> </label> <div class="cmp-detail-inputs-container"> <h3> <span>Builder Inputs (Props)</span> <button class="cmp-detail-inputs-reload" id="btn-inputs-reload"> Reload </button> </h3> <div id="cmp-detail-inputs"></div> </div> </div> </div> <div class="cmp-cover"></div> <div class="cmp-loading-icon spinner"></div> </section> <section class="nav-cmp-input"> <header> <button class="back-button" data-back="nav-cmp-detail"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2 id="cmp-input-title"></h2> <p> <button id="input-open-source"></button> </p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable Input</h3> <p>Add this component prop as a Builder input</p> </div> <input type="checkbox" role="switch" id="input-register" /> <span class="switcher"></span> </label> <div class="cmp-prop-info"> <div class="cmp-input-readonly"> <h3>Prop Name</h3> <span id="cmp-prop-name"></span> </div> <div class="cmp-input-readonly"> <h3>Prop Type</h3> <span id="cmp-prop-type"></span> </div> </div> <div class="cmp-input-detail"> <label class="ui-text-input"> <h3>Builder Input Name</h3> <div class="input"> <input type="text" id="input-name" autocapitalize="off" autocorrect="off" spellcheck="false" autocomplete="off" minlength="1" maxlength="30" required placeholder="e.g. Text" /> </div> <p> Friendly name to identify this component prop as a Builder input. Press ESC to cancel </p> </label> <label class="ui-select"> <h3>Builder Input Type</h3> <div class="select"> <select id="input-type"></select> </div> <p> Correlate to what editing UI is appropriate for this Builder input. <a href="https://www.builder.io/c/docs/custom-components-input-types" target="_blank" >Read more about input types.</a > </p> </label> </div> <div class="input-cover"></div> <div class="input-loading-icon spinner"></div> </div> </section> <section class="nav-settings"> <header> <button class="back-button"> <svg viewBox="0 0 24 24"> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> </svg> </button> <div> <h2>Settings</h2> <p>Configure Builder's Devtools</p> </div> </header> <div class="section-content"> <label class="ui-switch"> <div> <h3>Enable edit button in UI</h3> <p>Enables the edit button so you can edit content in Builder</p> </div> <input type="checkbox" role="switch" id="enable-edit" /> <span class="switcher"></span> </label> </div> </section> <div class="ui-toast" id="toast"></div> </aside> <button class="menu-toggle" aria-label="Toggle Builder Devtools"> <div> <div class="highlight-bg"></div> <svg viewBox="0 0 31 36" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M31 9.96854C31.0016 11.4553 30.6701 12.9236 30.03 14.2654C29.3898 15.6072 28.4572 16.7884 27.3007 17.7221L0.702841 2.61812C0.601104 2.56012 0.506714 2.49008 0.421705 2.40951C0.288323 2.27871 0.182333 2.12263 0.109928 1.95039C0.0375215 1.77814 0.000151253 1.59319 0 1.40633C0 1.03335 0.148098 0.675643 0.411715 0.411905C0.675332 0.148167 1.03287 0 1.40568 0L21.036 0C23.6786 0 26.213 1.05025 28.0816 2.91972C29.9502 4.78918 31 7.32472 31 9.96854Z" fill="#18B4F4" /> <path d="M31 25.4757C31.0004 26.7849 30.7429 28.0815 30.2423 29.2912C29.7417 30.5009 29.0078 31.6001 28.0825 32.526C27.1572 33.4519 26.0587 34.1864 24.8497 34.6875C23.6406 35.1886 22.3448 35.4465 21.0361 35.4465H1.40573C1.12766 35.4436 0.856725 35.3581 0.627199 35.201C0.397672 35.044 0.219871 34.8223 0.116289 34.5641C0.0127078 34.3059 -0.011999 34.0228 0.0452946 33.7505C0.102588 33.4783 0.239308 33.2292 0.438156 33.0347C0.517415 32.9551 0.606358 32.8858 0.702893 32.8284L11.1705 26.8843L27.2984 17.7244C28.4548 18.6579 29.3874 19.8387 30.028 21.18C30.6685 22.5213 31.0007 23.9891 31 25.4757Z" fill="#FD6B3C" /> <path d="M27.3011 17.7221L11.1709 26.8843L0.703209 32.8284C0.602697 32.8843 0.509784 32.9528 0.426758 33.0323C4.41799 28.9369 6.6496 23.442 6.64456 17.7221C6.65208 12.0015 4.42111 6.50517 0.429101 2.40948C0.51411 2.49005 0.6085 2.56009 0.710237 2.61809L27.3011 17.7221Z" fill="#A97FF2" /> </svg> </div> </button>\`,si(e),ui(e),oi(e),ri(e),ti(e),ci(e),this.setAttribute("aria-hidden","true"),e.getElementById("version").textContent="v1.41.2-beta.202604081246.fe4cb67"}highlightOpener(){let e=this.shadowRoot.querySelector(".menu-toggle");e.classList.add("menu-toggle-highlight"),e.classList.add("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight-no-transition"),setTimeout(()=>{e.classList.remove("menu-toggle-highlight")},20)},20)}};var lo=\`<style>*,*:before,*:after{box-sizing:border-box}html,body,:host{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:2147483646;margin:0;padding:0;line-height:1.8;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";background-color:#252525;color:#fff;transition:opacity .25s ease-in-out}:host([aria-hidden="true"]){opacity:0;pointer-events:none}main{position:absolute;top:0;left:0;width:100%;height:100vh}h1{margin-top:0;font-size:24px;font-weight:300;line-height:1.4}p{margin:20px 0;font-weight:300}button{cursor:pointer}aside{position:absolute;top:0;left:0;width:350px;height:100vh;padding:60px 0 0 50px;background-color:#121212}aside ul{margin:30px 0 0;padding:0;list-style:none}aside li{position:relative;margin:0;padding:20px 10px;font-weight:300}aside li.highlight{color:#48a1ff}aside li.active{font-weight:700}aside li .circle{position:absolute;top:20px;left:10px;width:24px;height:24px;border:3px solid white;border-radius:50%;font-size:14px}aside li.highlight .circle{border-color:#48a1ff}aside li.active .circle:after{content:"";position:absolute;top:3px;left:3px;width:12px;height:12px;border-radius:50%;background-color:#48a1ff}aside li.completed .circle{background-color:#48a1ff}aside li.completed .circle:after{content:"";position:absolute;top:2px;left:6px;width:6px;height:13px;border:3px solid black;border-top:none;border-left:none;transform:rotate(45deg)}aside li .line{position:absolute;top:44px;left:21px;width:3px;height:45px;background-color:#fff}aside li.completed .line{background-color:#48a1ff}aside li span{display:block;margin-left:44px}nav{margin-top:30px}section{position:absolute;top:135px;left:350px;padding:0 80px 0 140px;transition:opacity .15s ease-in-out}section[aria-hidden=true]{pointer-events:none;opacity:0}section h1,section p{min-width:300px;max-width:600px}.button{position:relative;display:inline-block;color:#fff;background-color:#48a1ff;border-radius:4px;text-decoration:none;padding:10px 40px 10px 20px;white-space:nowrap}.button:hover{background-color:#48a1ffd9}#button-icon{position:absolute;top:1px;right:5px;bottom:0;width:30px;background-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="none" stroke="white" stroke-linecap="square" stroke-miterlimit="10" stroke-width="48" d="M184 112l144 144-144 144"/></svg>');background-repeat:no-repeat;background-position:center;background-size:24px 24px}.button[aria-disabled=true]{opacity:.9;background-color:#ffffff4d;pointer-events:none;padding-right:60px}.button[aria-disabled=true] #button-icon{top:21px;right:29px;width:8px;height:8px;border-radius:4px;background:#fff;color:#fff;animation:dot-flashing .5s infinite linear alternate;animation-delay:.25s}.button[aria-disabled=true] #button-icon:before,.button[aria-disabled=true] #button-icon:after{content:"";display:inline-block;position:absolute;top:0}.button[aria-disabled=true] #button-icon:before{left:-12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:0s}.button[aria-disabled=true] #button-icon:after{left:12px;width:8px;height:8px;border-radius:4px;background-color:#fff;color:#fff;animation:dot-flashing .5s infinite alternate;animation-delay:.5s}@keyframes dot-flashing{0%{background-color:#fff}50%,to{background-color:#ffffff4d}}.logo{margin-left:9px;background:url('data:image/svg+xml,<svg viewBox="0 0 150 32" fill="none" xmlns="http://www.w3.org/2000/svg" > <g clip-path="url(%23clip0_4_304)"> <path d="M27.9858 8.99927C27.9872 10.3415 27.688 11.667 27.1101 12.8783C26.5321 14.0896 25.6902 15.156 24.6462 15.9989V15.9989L0.634502 2.36355C0.542657 2.31119 0.457444 2.24796 0.380701 2.17523C0.260289 2.05715 0.164605 1.91624 0.0992389 1.76075C0.0338732 1.60525 0.000136546 1.43828 0 1.26959C0 0.932873 0.133698 0.609948 0.371683 0.371854C0.609667 0.13376 0.932443 0 1.269 0L18.9906 0C21.3763 0 23.6642 0.948135 25.3512 2.63583C27.0381 4.32352 27.9858 6.61252 27.9858 8.99927V8.99927Z" fill="%2318B4F4" /> <path d="M27.9858 22.9986C27.9861 24.1806 27.7536 25.351 27.3017 26.4431C26.8498 27.5352 26.1873 28.5275 25.352 29.3634C24.5167 30.1993 23.5249 30.8624 22.4335 31.3147C21.342 31.7671 20.1721 32 18.9907 32H1.26906C1.01802 31.9973 0.77343 31.9202 0.566221 31.7784C0.359012 31.6366 0.198499 31.4364 0.104989 31.2034C0.0114791 30.9703 -0.0108254 30.7147 0.0408974 30.4689C0.0926201 30.2231 0.216046 29.9982 0.395559 29.8226V29.8226C0.467112 29.7508 0.547407 29.6882 0.634555 29.6364L10.0844 24.2703L24.6441 16.001C25.688 16.8438 26.53 17.9097 27.1083 19.1206C27.6866 20.3315 27.9864 21.6566 27.9858 22.9986V22.9986Z" fill="%23FD6B3C" /> <path d="M24.6461 15.9989L10.0843 24.2703L0.634458 29.6365C0.54372 29.6868 0.459841 29.7487 0.384888 29.8205C3.98804 26.1233 6.00266 21.1627 5.99812 15.9989C6.0049 10.8346 3.99085 5.87268 0.387003 2.17523C0.463746 2.24796 0.548959 2.31119 0.640803 2.36355L24.6461 15.9989Z" fill="%23A97FF2" /> <path d="M47.6659 11.7352C51.8177 11.7352 54.1632 15.0531 54.1632 19.0714C54.1632 23.0896 51.8177 26.3821 47.6659 26.3821C45.5086 26.3821 43.8589 25.5188 42.9473 24.0545L42.5709 26.052H39.9736V6.77115H43.1884V13.8914C43.971 12.6959 45.5086 11.7352 47.6659 11.7352ZM47.0187 23.5488C49.4446 23.5488 50.9547 21.5809 50.9547 19.0714C50.9547 16.5089 49.4446 14.5664 47.0187 14.5664C44.5928 14.5664 43.0806 16.5047 43.0806 19.0714C43.0806 21.583 44.5653 23.5488 47.0187 23.5488V23.5488Z" fill="white" /> <path d="M65.4595 20.2859V12.0611H68.668V20.123C68.668 23.7202 67.0246 26.3821 62.4943 26.3821C57.9639 26.3821 56.3206 23.7117 56.3206 20.123V12.0611H59.529V20.2859C59.529 22.4696 60.5527 23.5488 62.49 23.5488C64.4274 23.5488 65.4595 22.4696 65.4595 20.2859Z" fill="white" /> <path d="M71.2355 7.74451C71.2247 7.46284 71.2724 7.18199 71.3755 6.91968C71.4787 6.65737 71.6351 6.41929 71.8348 6.22047C72.0345 6.02165 72.2732 5.8664 72.5359 5.76452C72.7986 5.66264 73.0796 5.61633 73.3611 5.62853C74.5793 5.62853 75.4571 6.50666 75.4571 7.75509C75.4571 9.00352 74.5793 9.8224 73.3611 9.8224C72.1428 9.8224 71.2355 8.9612 71.2355 7.74451Z" fill="white" /> <path d="M128.476 7.74451C128.465 7.46376 128.513 7.18383 128.615 6.92227C128.718 6.66071 128.873 6.42315 129.072 6.22449C129.27 6.02583 129.508 5.87035 129.769 5.7678C130.031 5.66524 130.31 5.61783 130.591 5.62852C131.809 5.62852 132.687 6.50666 132.687 7.75509C132.687 9.00352 131.809 9.8224 130.591 9.8224C129.373 9.8224 128.476 8.9612 128.476 7.74451Z" fill="white" /> <path d="M122.302 24.1031C122.291 23.8223 122.339 23.5422 122.441 23.2805C122.543 23.0188 122.699 22.7811 122.897 22.5824C123.096 22.3837 123.334 22.2282 123.595 22.1258C123.857 22.0233 124.137 21.9761 124.417 21.9872C125.636 21.9872 126.513 22.8653 126.513 24.1031C126.513 25.341 125.636 26.1726 124.417 26.1726C123.199 26.1726 122.302 25.3219 122.302 24.1031Z" fill="white" /> <path d="M74.9516 12.059H71.7432V26.0583H74.9516V12.059Z" fill="white" /> <path d="M78.16 26.0583V6.77115H81.3685V26.0626L78.16 26.0583Z" fill="white" /> <path d="M94.6063 6.77115H97.8148V26.0626H95.2239L94.8474 24.0651C93.9591 25.523 92.3094 26.3927 90.131 26.3927C86.0046 26.3927 83.6591 23.0748 83.6591 19.0819C83.6591 15.0891 86.0046 11.7458 90.131 11.7458C92.3137 11.7458 93.8238 12.7149 94.6063 13.902V6.77115ZM90.7993 14.5707C88.3734 14.5707 86.8633 16.5131 86.8633 19.0756C86.8633 21.5851 88.3734 23.553 90.7993 23.553C93.2252 23.553 94.7354 21.5851 94.7354 19.0756C94.7396 16.5047 93.257 14.5664 90.8036 14.5664L90.7993 14.5707Z" fill="white" /> <path d="M113.479 22.2284C112.482 24.7359 110.162 26.3821 107.117 26.3821C102.887 26.3821 100.137 23.225 100.137 19.0439C100.137 14.9706 102.942 11.7353 107.093 11.7353C111.245 11.7353 113.969 14.8902 113.969 18.991C113.982 19.3255 113.953 19.6604 113.883 19.9876H103.288C103.53 22.2009 104.959 23.6292 107.197 23.6292C108.735 23.6292 110.001 22.8738 110.594 21.473L113.479 22.2284ZM103.341 17.6156H110.784C110.513 15.6731 109.166 14.3506 107.089 14.3506C105.012 14.3506 103.665 15.7006 103.341 17.6156V17.6156Z" fill="white" /> <path d="M123.779 14.9452C123.538 14.9117 123.295 14.8933 123.051 14.8902C120.786 14.8902 119.439 16.0772 119.439 18.7751V26.0583H116.23V12.0611H118.821L119.195 14.0014C119.707 13.1127 120.887 11.9257 123.322 11.9257C123.455 11.9257 123.779 11.9532 123.779 11.9532V14.9452Z" fill="white" /> <path d="M132.192 12.059H128.984V26.0583H132.192V12.059Z" fill="white" /> <path d="M134.483 19.0714C134.483 15.1335 137.287 11.7353 141.735 11.7353C146.183 11.7353 149.015 15.1335 149.015 19.0714C149.015 23.0092 146.213 26.3821 141.735 26.3821C137.258 26.3821 134.483 23.0092 134.483 19.0714ZM141.735 23.5488C144.083 23.5488 145.806 21.7692 145.806 19.0714C145.806 16.3735 144.083 14.5664 141.735 14.5664C139.387 14.5664 137.687 16.346 137.687 19.0714C137.687 21.7968 139.417 23.5488 141.735 23.5488V23.5488Z" fill="white" /> </g> <defs> <clipPath id="clip0_4_304"> <rect width="149.015" height="32" fill="white" /> </clipPath> </defs> </svg>');background-repeat:no-repeat;width:150px;height:32px}@media(max-width:840px){aside{width:250px;padding:60px 0 0 20px}section{left:250px;padding:0 80px}}@media(max-width:590px){aside{width:230px;padding:60px 0 0 10px}section{left:230px;padding:0 40px}}#modified-files-message a{color:#cbcbcb;font-weight:300;text-decoration:underline}#modified-files-message a:hover{color:#fff;text-decoration:none}#restart-warning{border-radius:4px;padding:8px 16px;border:1px solid #fd6b3c;background:#fd6b3c1a}#react-router-steps{margin:0 0 5px;padding:0 20px}#need-help{color:#48a1ff;text-decoration:none}#router-message{border-radius:4px;padding:16px;border:1px solid #48a1ff}#router-finish-button{margin-top:12px}#router-checkbox-div{display:flex;align-items:center}#router-checkbox{margin-right:10px;width:15px;height:15px}#success-title{display:flex;align-items:center;gap:10px}#success-title .check-icon{display:inline-block;width:24px;height:24px;border:2px solid #28a745;border-radius:50%;position:relative}#success-title .check-icon:before{content:"";position:absolute;top:50%;left:50%;width:6px;height:12px;border:solid #28a745;border-width:0 2px 2px 0;transform:translate(-50%,-60%) rotate(45deg)}
1280
1280
  </style>\`,Nt=class extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.attachShadow({mode:"open"});e.innerHTML=lo+\`<main>
1281
1281
  <aside>
1282
1282
  <div class="logo"></div>
@@ -1315,7 +1315,7 @@ Restarting server after Builder Devtools update...
1315
1315
  </nav>
1316
1316
  </section>
1317
1317
  </main>
1318
- \`,po();let r=new URL(Fr,ot);r.searchParams.set(Br,location.href);let n=e.querySelectorAll(".next-step");for(let i of n)i.setAttribute("href",r.href);ye("overview step viewed")}},po=()=>{let t=document.head.querySelector("link[rel='icon'], link[rel='icon shortcut']");t?(t.href="https://cdn.builder.io/favicon.ico",t.removeAttribute("type")):(t=document.createElement("link"),t.rel="icon",t.href="https://cdn.builder.io/favicon.ico",document.head.appendChild(t))};var li=async()=>{(await jr()).isValid||fo()},fo=()=>{customElements.get("builder-dev-tools-overview")||customElements.define("builder-dev-tools-overview",Nt);let t=document.querySelector("builder-dev-tools-overview");t||(t=document.createElement("builder-dev-tools-overview"),t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),setTimeout(()=>{t.removeAttribute("aria-hidden")},32)};var mo=()=>{try{customElements.get("builder-dev-tools-edit")||customElements.define("builder-dev-tools-edit",at),customElements.get("builder-dev-tools-menu")||customElements.define("builder-dev-tools-menu",Dt);let t=document.querySelector("builder-dev-tools-menu");t||(t=document.createElement("builder-dev-tools-menu"),t.setAttribute("data-version","1.41.2-beta.202604081155.f368de7"),document.body.appendChild(t));let e=document.querySelector("builder-dev-tools-edit");e||(e=document.createElement("builder-dev-tools-edit"),document.body.appendChild(e));let r=document.getElementById("builder-dev-tools-style");r||(r=document.createElement("style"),r.id="builder-dev-tools-style",r.innerHTML=".builder-no-scroll{overflow:hidden !important}",document.head.appendChild(r)),li(),Jn()}catch(t){console.error("Builder Devtools:",t)}};window.location===window.parent.location&&(console.debug("Builder.io Devtools v1.41.2-beta.202604081155.f368de7"),mo());})();`)}async function ece(t){return tce(t,`<!doctype html>
1318
+ \`,po();let r=new URL(Fr,ot);r.searchParams.set(Br,location.href);let n=e.querySelectorAll(".next-step");for(let i of n)i.setAttribute("href",r.href);ye("overview step viewed")}},po=()=>{let t=document.head.querySelector("link[rel='icon'], link[rel='icon shortcut']");t?(t.href="https://cdn.builder.io/favicon.ico",t.removeAttribute("type")):(t=document.createElement("link"),t.rel="icon",t.href="https://cdn.builder.io/favicon.ico",document.head.appendChild(t))};var li=async()=>{(await jr()).isValid||fo()},fo=()=>{customElements.get("builder-dev-tools-overview")||customElements.define("builder-dev-tools-overview",Nt);let t=document.querySelector("builder-dev-tools-overview");t||(t=document.createElement("builder-dev-tools-overview"),t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),setTimeout(()=>{t.removeAttribute("aria-hidden")},32)};var mo=()=>{try{customElements.get("builder-dev-tools-edit")||customElements.define("builder-dev-tools-edit",at),customElements.get("builder-dev-tools-menu")||customElements.define("builder-dev-tools-menu",Dt);let t=document.querySelector("builder-dev-tools-menu");t||(t=document.createElement("builder-dev-tools-menu"),t.setAttribute("data-version","1.41.2-beta.202604081246.fe4cb67"),document.body.appendChild(t));let e=document.querySelector("builder-dev-tools-edit");e||(e=document.createElement("builder-dev-tools-edit"),document.body.appendChild(e));let r=document.getElementById("builder-dev-tools-style");r||(r=document.createElement("style"),r.id="builder-dev-tools-style",r.innerHTML=".builder-no-scroll{overflow:hidden !important}",document.head.appendChild(r)),li(),Jn()}catch(t){console.error("Builder Devtools:",t)}};window.location===window.parent.location&&(console.debug("Builder.io Devtools v1.41.2-beta.202604081246.fe4cb67"),mo());})();`)}async function ece(t){return tce(t,`<!doctype html>
1319
1319
  <html lang="en" dir="ltr">
1320
1320
  <head>
1321
1321
  <meta charset="utf-8" />
@@ -1845,11 +1845,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
1845
1845
  `):void 0})}let f=d.substring(4).split(" ")[0],h=tut(f);d.startsWith("--- ")?(o=h,i=h,a=0,A=0,c=[],u=[],s=null,l=f==="/dev/null",p=!1):d.startsWith("+++ ")&&(p=f==="/dev/null",f==="/dev/null"?i=o:i=h);continue}else{if(d.startsWith("@@"))continue;d.startsWith("+")?(a++,c.push(d.substring(1)),s===null&&(s="update")):d.startsWith("-")?(A++,u.push(d.substring(1)),s===null&&(s="update")):(d.startsWith(" ")||d==="")&&(c.push(d.substring(1)),u.push(d.substring(1)))}}if(i&&s){let g;l?g="create":p?g="delete":g="update";let d=g==="delete"&&o?o:i;r.push({filePath:d,addedLines:a,removedLines:A,action:g,content:c.length>0?c.join(`
1846
1846
  `):void 0,oldContent:u.length>0?u.join(`
1847
1847
  `):void 0})}return r}var _Be=N(()=>{"use strict";m()});var zl,LBe=N(()=>{"use strict";m();zl=(...t)=>{typeof process<"u"&&process.env.DEBUG==="true"&&console.debug("[DEBUG] ",...t)}});var nut,vh,UBe,iut,out,sut,lF,V$=N(()=>{"use strict";m();LBe();nut=()=>{if(typeof globalThis<"u"&&globalThis.crypto)return globalThis.crypto;if(typeof require<"u")try{let t=require("crypto");if(t.webcrypto)return t.webcrypto}catch{}throw new Error("Web Crypto API is not available. Requires Node.js 15+ or a browser environment.")},vh=nut(),UBe=async()=>{let t=await vh.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),e=await vh.subtle.exportKey("jwk",t);return JSON.stringify(e)},iut=async()=>vh.getRandomValues(new Uint8Array(16)),out=async(t,e,r)=>{let n=await vh.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:128},t,typeof r=="string"?new TextEncoder().encode(r):r);return Buffer.from(n)},sut=async(t,e,r)=>{let n=await vh.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:128},t,r);return new TextDecoder().decode(n)},lF=async t=>{try{zl("validateEncryptionKey: Validating encryption key");let e=JSON.parse(t);zl("validateEncryptionKey: Parsed JWK");let r=await vh.subtle.importKey("jwk",e,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);zl("validateEncryptionKey: Imported crypto key");let n="test",i=await iut();zl("validateEncryptionKey: Generated test IV",i);let o=await out(r,i,n);zl("validateEncryptionKey: Encrypted test data",o);let s=new Uint8Array(o);zl("validateEncryptionKey: Encrypted test data array",s);let a=await sut(r,i,s);return zl("validateEncryptionKey: Decrypted test data",a),a===n}catch(e){return console.error("Could not validate encryption key:",e),!1}}});var z$,OBe,aut,GBe=N(()=>{m();z$=(t,e,r)=>{let n=t instanceof RegExp?OBe(t,r):t,i=e instanceof RegExp?OBe(e,r):e,o=n!==null&&i!=null&&aut(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},OBe=(t,e)=>{let r=e.match(t);return r?r[0]:null},aut=(t,e,r)=>{let n,i,o,s,a,A=r.indexOf(t),c=r.indexOf(e,A+1),u=A;if(A>=0&&c>0){if(t===e)return[A,c];for(n=[],o=r.length;u>=0&&!a;){if(u===A)n.push(u),A=r.indexOf(t,u+1);else if(n.length===1){let l=n.pop();l!==void 0&&(a=[l,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(e,u+1);u=A<c&&A>=0?A:c}n.length&&s!==void 0&&(a=[o,s])}return a}});function W$(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Iut(t){return t.replace(put,KBe).replace(dut,HBe).replace(fut,Z$).replace(mut,$Be).replace(hut,JBe)}function Eut(t){return t.replace(Aut,"\\").replace(cut,"{").replace(uut,"}").replace(lut,",").replace(gut,".")}function jBe(t){if(!t)return[""];let e=[],r=z$("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=jBe(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function YBe(t,e={}){if(!t)return[];let{max:r=Cut}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),eQ(Iut(t),r,!0).map(Eut)}function But(t){return"{"+t+"}"}function yut(t){return/^-?0\d/.test(t)}function Qut(t,e){return t<=e}function Dut(t,e){return t>=e}function eQ(t,e,r){let n=[],i=z$("{","}",t);if(!i)return[t];let o=i.pre,s=i.post.length?eQ(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<s.length&&a<e;a++){let A=o+"{"+i.body+"}"+s[a];n.push(A)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),A=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||A,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+Z$+i.post,eQ(t,e,!0)):[t];let l;if(c)l=i.body.split(/\.\./);else if(l=jBe(i.body),l.length===1&&l[0]!==void 0&&(l=eQ(l[0],e,!1).map(But),l.length===1))return s.map(g=>i.pre+l[0]+g);let p;if(c&&l[0]!==void 0&&l[1]!==void 0){let g=W$(l[0]),d=W$(l[1]),f=Math.max(l[0].length,l[1].length),h=l.length===3&&l[2]!==void 0?Math.abs(W$(l[2])):1,C=Qut;d<g&&(h*=-1,C=Dut);let B=l.some(yut);p=[];for(let E=g;C(E,d);E+=h){let y;if(A)y=String.fromCharCode(E),y==="\\"&&(y="");else if(y=String(E),B){let D=f-y.length;if(D>0){let v=new Array(D+1).join("0");E<0?y="-"+v+y.slice(1):y=v+y}}p.push(y)}}else{p=[];for(let g=0;g<l.length;g++)p.push.apply(p,eQ(l[g],e,!1))}for(let g=0;g<p.length;g++)for(let d=0;d<s.length&&n.length<e;d++){let f=o+p[g]+s[d];(!r||c||f)&&n.push(f)}}return n}var KBe,HBe,Z$,$Be,JBe,Aut,cut,uut,lut,gut,put,dut,fut,mut,hut,Cut,qBe=N(()=>{m();GBe();KBe="\0SLASH"+Math.random()+"\0",HBe="\0OPEN"+Math.random()+"\0",Z$="\0CLOSE"+Math.random()+"\0",$Be="\0COMMA"+Math.random()+"\0",JBe="\0PERIOD"+Math.random()+"\0",Aut=new RegExp(KBe,"g"),cut=new RegExp(HBe,"g"),uut=new RegExp(Z$,"g"),lut=new RegExp($Be,"g"),gut=new RegExp(JBe,"g"),put=/\\\\/g,dut=/\\{/g,fut=/\\}/g,mut=/\\,/g,hut=/\\\./g,Cut=1e5});var tQ,VBe=N(()=>{m();tQ=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")}});var wut,rQ,but,zBe,WBe,ZBe=N(()=>{m();wut={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},rQ=t=>t.replace(/[[\]\\-]/g,"\\$&"),but=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zBe=t=>t.join(""),WBe=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,A=!1,c=!1,u=r,l="";e:for(;o<t.length;){let f=t.charAt(o);if((f==="!"||f==="^")&&o===r+1){c=!0,o++;continue}if(f==="]"&&s&&!A){u=o+1;break}if(s=!0,f==="\\"&&!A){A=!0,o++;continue}if(f==="["&&!A){for(let[h,[C,I,B]]of Object.entries(wut))if(t.startsWith(h,o)){if(l)return["$.",!1,t.length-r,!0];o+=h.length,B?i.push(C):n.push(C),a=a||I;continue e}}if(A=!1,l){f>l?n.push(rQ(l)+"-"+rQ(f)):f===l&&n.push(rQ(f)),l="",o++;continue}if(t.startsWith("-]",o+1)){n.push(rQ(f+"-")),o+=2;continue}if(t.startsWith("-",o+1)){l=f,o+=2;continue}n.push(rQ(f)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let f=n[0].length===2?n[0].slice(-1):n[0];return[but(f),!1,u-r,!1]}let p="["+(c?"^":"")+zBe(n)+"]",g="["+(c?"":"^")+zBe(i)+"]";return[n.length&&i.length?"("+p+"|"+g+")":n.length?p:g,a,u-r,!0]}});var Wl,gF=N(()=>{m();Wl=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")});var qo,vut,X$,XBe,Sut,xut,Fut,eye,kut,pF,Rut,Nut,Tut,Mut,eJ,tye,rye,Put,ed,tJ=N(()=>{m();ZBe();gF();vut=new Set(["!","?","+","*","@"]),X$=t=>vut.has(t),XBe=t=>X$(t.type),Sut=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),xut=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Fut=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),eye=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),kut="(?!(?:^|/)\\.\\.?(?:$|/))",pF="(?!\\.)",Rut=new Set(["[","."]),Nut=new Set(["..","."]),Tut=new Set("().*{}+?[]^$\\!"),Mut=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),eJ="[^/]",tye=eJ+"*?",rye=eJ+"+?",Put=0,ed=class{type;#n;#c;#o=!1;#t=[];#A;#i;#e;#a=!1;#B;#C;#T=!1;id=++Put;get depth(){return(this.#A?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#n.id,parent:this.#A?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(e,r,n={}){this.type=e,e&&(this.#c=!0),this.#A=r,this.#n=this.#A?this.#A.#n:this,this.#B=this.#n===this?n:this.#n.#B,this.#e=this.#n===this?[]:this.#n.#e,e==="!"&&!this.#n.#a&&this.#e.push(this),this.#i=this.#A?this.#A.#t.length:0}get hasMagic(){if(this.#c!==void 0)return this.#c;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#c=!0;return this.#c}toString(){return this.#C!==void 0?this.#C:this.type?this.#C=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#C=this.#t.map(e=>String(e)).join("")}#x(){if(this!==this.#n)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let e;for(;e=this.#e.pop();){if(e.type!=="!")continue;let r=e,n=r.#A;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#t.length;i++)for(let o of e.#t){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#t[i])}r=n,n=r.#A}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof qo&&r.#A===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let e=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#a&&this.#A?.type==="!")&&e.push({}),e}isStart(){if(this.#n===this)return!0;if(!this.#A?.isStart())return!1;if(this.#i===0)return!0;let e=this.#A;for(let r=0;r<this.#i;r++){let n=e.#t[r];if(!(n instanceof qo&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#A?.type==="!")return!0;if(!this.#A?.isEnd())return!1;if(!this.type)return this.#A?.isEnd();let e=this.#A?this.#A.#t.length:0;return this.#i===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new qo(this.type,e);for(let n of this.#t)r.copyIn(n);return r}static#b(e,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,A=!1,c=-1,u=!1;if(r.type===null){let f=n,h="";for(;f<e.length;){let C=e.charAt(f++);if(a||C==="\\"){a=!a,h+=C;continue}if(A){f===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(f===c+2&&u)&&(A=!1),h+=C;continue}else if(C==="["){A=!0,c=f,u=!1,h+=C;continue}if(!i.noext&&X$(C)&&e.charAt(f)==="("&&o<=s){r.push(h),h="";let B=new qo(C,r);f=qo.#b(e,B,f,i,o+1),r.push(B);continue}h+=C}return r.push(h),f}let l=n+1,p=new qo(null,r),g=[],d="";for(;l<e.length;){let f=e.charAt(l++);if(a||f==="\\"){a=!a,d+=f;continue}if(A){l===c+1?(f==="^"||f==="!")&&(u=!0):f==="]"&&!(l===c+2&&u)&&(A=!1),d+=f;continue}else if(f==="["){A=!0,c=l,u=!1,d+=f;continue}if(!i.noext&&X$(f)&&e.charAt(l)==="("&&(o<=s||r&&r.#f(f))){let C=r&&r.#f(f)?0:1;p.push(d),d="";let I=new qo(f,p);p.push(I),l=qo.#b(e,I,l,i,o+C);continue}if(f==="|"){p.push(d),d="",g.push(p),p=new qo(null,r);continue}if(f===")")return d===""&&r.#t.length===0&&(r.#T=!0),p.push(d),d="",r.push(...g,p),l;d+=f}return r.type=null,r.#c=void 0,r.#t=[e.substring(n-1)],l}#F(e){return this.#s(e,xut)}#s(e,r=Sut){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let n=e.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#f(n.type,r)}#f(e,r=Fut){return!!r.get(this.type)?.includes(e)}#r(e,r){let n=e.#t[0],i=new qo(null,n,this.options);i.#t.push(""),n.push(i),this.#g(e,r)}#g(e,r){let n=e.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#A=this);this.#C=void 0}#W(e){return!!eye.get(this.type)?.has(e)}#M(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=e.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#W(r.type)}#me(e){let r=eye.get(this.type),n=e.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let o of this.#t)typeof o=="object"&&(o.#A=this);this.type=i,this.#C=void 0,this.#T=!1}static fromGlob(e,r={}){let n=new qo(null,void 0,r);return qo.#b(e,n,0,r,0),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let e=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#c||this.#B.nocase&&!this.#B.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#B.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#B}toRegExpSource(e){let r=e??!!this.#B.dot;if(this.#n===this&&(this.#L(),this.#x()),!XBe(this)){let A=this.isStart()&&this.isEnd()&&!this.#t.some(g=>typeof g!="string"),c=this.#t.map(g=>{let[d,f,h,C]=typeof g=="string"?qo.#ie(g,this.#c,A):g.toRegExpSource(e);return this.#c=this.#c||h,this.#o=this.#o||C,d}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Nut.has(this.#t[0]))){let d=Rut,f=r&&d.has(c.charAt(0))||c.startsWith("\\.")&&d.has(c.charAt(2))||c.startsWith("\\.\\.")&&d.has(c.charAt(4)),h=!r&&!e&&d.has(c.charAt(0));u=f?kut:h?pF:""}let l="";return this.isEnd()&&this.#n.#a&&this.#A?.type==="!"&&(l="(?:$|\\/)"),[u+c+l,Wl(c),this.#c=!!this.#c,this.#o]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#H(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let A=this.toString(),c=this;return c.#t=[A],c.type=null,c.#c=void 0,[A,Wl(this.toString()),!1,!1]}let s=!n||e||r||!pF?"":this.#H(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#T)a=(this.isStart()&&!r?pF:"")+rye;else{let A=this.type==="!"?"))"+(this.isStart()&&!r&&!e?pF:"")+tye+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+A}return[a,Wl(o),this.#c=!!this.#c,this.#o]}#L(){if(XBe(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#L(),this.#s(i)?(r=!1,this.#g(i,n)):this.#F(i)?(r=!1,this.#r(i,n)):this.#M(i)&&(r=!1,this.#me(i)))}}while(!r&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#L();this.#C=void 0}#H(e){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(e);return this.#o=this.#o||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#ie(e,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let A=0;A<e.length;A++){let c=e.charAt(A);if(i){i=!1,o+=(Tut.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(e)?rye:tye,r=!0;continue}else a=!1;if(c==="\\"){A===e.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,l,p,g]=WBe(e,A);if(p){o+=u,s=s||l,A+=p-1,r=r||g;continue}}if(c==="?"){o+=eJ,r=!0;continue}o+=Mut(c)}return[o,Wl(e),!!r,s]}};qo=ed});var rJ,nJ=N(()=>{m();rJ=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&")});var ki,_ut,Lut,Uut,Out,Gut,Kut,Hut,$ut,Jut,jut,Yut,qut,Vut,zut,Wut,Zut,Xut,elt,oye,sye,aye,nye,tlt,ro,rlt,nlt,ilt,olt,slt,ia,alt,Aye,Alt,clt,iye,ult,Sh,cye=N(()=>{m();qBe();VBe();tJ();nJ();gF();tJ();nJ();gF();ki=(t,e,r={})=>(tQ(e),!r.nocomment&&e.charAt(0)==="#"?!1:new Sh(e,r).match(t)),_ut=/^\*+([^+@!?\*\[\(]*)$/,Lut=t=>e=>!e.startsWith(".")&&e.endsWith(t),Uut=t=>e=>e.endsWith(t),Out=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Gut=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Kut=/^\*+\.\*+$/,Hut=t=>!t.startsWith(".")&&t.includes("."),$ut=t=>t!=="."&&t!==".."&&t.includes("."),Jut=/^\.\*+$/,jut=t=>t!=="."&&t!==".."&&t.startsWith("."),Yut=/^\*+$/,qut=t=>t.length!==0&&!t.startsWith("."),Vut=t=>t.length!==0&&t!=="."&&t!=="..",zut=/^\?+([^+@!?\*\[\(]*)?$/,Wut=([t,e=""])=>{let r=oye([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Zut=([t,e=""])=>{let r=sye([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Xut=([t,e=""])=>{let r=sye([t]);return e?n=>r(n)&&n.endsWith(e):r},elt=([t,e=""])=>{let r=oye([t]);return e?n=>r(n)&&n.endsWith(e):r},oye=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},sye=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},aye=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",nye={win32:{sep:"\\"},posix:{sep:"/"}},tlt=aye==="win32"?nye.win32.sep:nye.posix.sep;ki.sep=tlt;ro=Symbol("globstar **");ki.GLOBSTAR=ro;rlt="[^/]",nlt=rlt+"*?",ilt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",olt="(?:(?!(?:\\/|^)\\.).)*?",slt=(t,e={})=>r=>ki(r,t,e);ki.filter=slt;ia=(t,e={})=>Object.assign({},t,e),alt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return ki;let e=ki;return Object.assign((n,i,o={})=>e(n,i,ia(t,o)),{Minimatch:class extends e.Minimatch{constructor(i,o={}){super(i,ia(t,o))}static defaults(i){return e.defaults(ia(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,o,s={}){super(i,o,ia(t,s))}static fromGlob(i,o={}){return e.AST.fromGlob(i,ia(t,o))}},unescape:(n,i={})=>e.unescape(n,ia(t,i)),escape:(n,i={})=>e.escape(n,ia(t,i)),filter:(n,i={})=>e.filter(n,ia(t,i)),defaults:n=>e.defaults(ia(t,n)),makeRe:(n,i={})=>e.makeRe(n,ia(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,ia(t,i)),match:(n,i,o={})=>e.match(n,i,ia(t,o)),sep:e.sep,GLOBSTAR:ro})};ki.defaults=alt;Aye=(t,e={})=>(tQ(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:YBe(t,{max:e.braceExpandMax}));ki.braceExpand=Aye;Alt=(t,e={})=>new Sh(t,e).makeRe();ki.makeRe=Alt;clt=(t,e,r={})=>{let n=new Sh(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};ki.match=clt;iye=/[?*]|[+@!]\(.*?\)|\[|\]/,ult=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Sh=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){tQ(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||aye,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let A=o[0]===""&&o[1]===""&&(o[2]==="?"||!iye.test(o[2]))&&!iye.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(A)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(A=>this.parse(A))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let o=e[i];i===1&&o===""&&e[0]===""||(o==="."||o==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],A=n[i+2],c=n[i+3];if(a!==".."||!A||A==="."||A===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",e.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let A=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...A),n.length===0&&n.push(""),o-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,o=0,s=[],a="";for(;i<e.length&&o<r.length;)if(e[i]===r[o])s.push(a==="b"?r[o]:e[i]),i++,o++;else if(n&&e[i]==="**"&&r[o]===e[i+1])s.push(e[i]),i++;else if(n&&r[o]==="**"&&e[i]===r[o+1])s.push(r[o]),o++;else if(e[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(e[i]),i++,o++}else if(r[o]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return e.length===r.length&&s}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),A=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),l=A?3:a?0:void 0,p=u?3:c?0:void 0;if(typeof l=="number"&&typeof p=="number"){let[g,d]=[e[l],r[p]];g.toLowerCase()===d.toLowerCase()&&(r[p]=g,o=p,i=l)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(ro)?this.#n(e,r,n,i,o):this.#o(e,r,n,i,o)}#n(e,r,n,i,o){let s=r.indexOf(ro,o),a=r.lastIndexOf(ro),[A,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(A.length){let I=e.slice(i,i+A.length);if(!this.#o(I,A,n,0,0))return!1;i+=A.length,o+=A.length}let l=0;if(u.length){if(u.length+i>e.length)return!1;let I=e.length-u.length;if(this.#o(e,u,n,I,0))l=u.length;else{if(e[e.length-1]!==""||i+u.length===e.length||(I--,!this.#o(e,u,n,I,0)))return!1;l=u.length+1}}if(!c.length){let I=!!l;for(let B=i;B<e.length-l;B++){let E=String(e[B]);if(I=!0,E==="."||E===".."||!this.options.dot&&E.startsWith("."))return!1}return n||I}let p=[[[],0]],g=p[0],d=0,f=[0];for(let I of c)I===ro?(f.push(d),g=[[],0],p.push(g)):(g[0].push(I),d++);let h=p.length-1,C=e.length-l;for(let I of p)I[1]=C-(f[h--]+I[0].length);return!!this.#c(e,p,i,0,n,0,!!l)}#c(e,r,n,i,o,s,a){let A=r[i];if(!A){for(let l=n;l<e.length;l++){a=!0;let p=e[l];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[c,u]=A;for(;n<=u;){if(this.#o(e.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let g=this.#c(e,r,n+c.length,i+1,o,s+1,a);if(g!==!1)return g}let p=e[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return o||null}#o(e,r,n,i,o){let s,a,A,c;for(s=i,a=o,c=e.length,A=r.length;s<c&&a<A;s++,a++){this.debug("matchOne loop");let u=r[a],l=e[s];if(this.debug(r,u,l),u===!1||u===ro)return!1;let p;if(typeof u=="string"?(p=l===u,this.debug("string match",u,l,p)):(p=u.test(l),this.debug("pattern match",u,l,p)),!p)return!1}if(s===c&&a===A)return!0;if(s===c)return n;if(a===A)return s===c-1&&e[s]==="";throw new Error("wtf?")}braceExpand(){return Aye(this.pattern,this.options)}parse(e){tQ(e);let r=this.options;if(e==="**")return ro;if(e==="")return"";let n,i=null;(n=e.match(Yut))?i=r.dot?Vut:qut:(n=e.match(_ut))?i=(r.nocase?r.dot?Gut:Out:r.dot?Uut:Lut)(n[1]):(n=e.match(zut))?i=(r.nocase?r.dot?Zut:Wut:r.dot?Xut:elt)(n):(n=e.match(Kut))?i=r.dot?$ut:Hut:(n=e.match(Jut))&&(i=jut);let o=ed.fromGlob(e,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?nlt:r.dot?ilt:olt,i=new Set(r.nocase?["i"]:[]),o=e.map(A=>{let c=A.map(l=>{if(l instanceof RegExp)for(let p of l.flags.split(""))i.add(p);return typeof l=="string"?ult(l):l===ro?ro:l._src});c.forEach((l,p)=>{let g=c[p+1],d=c[p-1];l!==ro||d===ro||(d===void 0?g!==void 0&&g!==ro?c[p+1]="(?:\\/|"+n+"\\/)?"+g:c[p]=n:g===void 0?c[p-1]=d+"(?:\\/|\\/"+n+")?":g!==ro&&(c[p-1]=d+"(?:\\/|\\/"+n+"\\/)"+g,c[p+1]=ro))});let u=c.filter(l=>l!==ro);if(this.partial&&u.length>=1){let l=[];for(let p=1;p<=u.length;p++)l.push(u.slice(0,p).join("/"));return"(?:"+l.join("|")+")"}return u.join("/")}).join("|"),[s,a]=e.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a=0;a<o.length;a++){let A=o[a],c=i;if(n.matchBase&&A.length===1&&(c=[s]),this.matchOne(c,A,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return ki.defaults(e).Minimatch}};ki.AST=ed;ki.Minimatch=Sh;ki.escape=rJ;ki.unescape=Wl});async function llt(t,e,r){let n=t.builderPublicKey;if(!n)return[];let i=new URL(`${Oe}/projects/memories`);i.searchParams.set("apiKey",n),i.searchParams.set("projectId",e),t.userId&&i.searchParams.set("userId",t.userId);let o={"Content-Type":"application/json"};t.builderPrivateKey&&(o.Authorization=`Bearer ${t.builderPrivateKey}`);let a=await(await Ue(i,{method:"GET",headers:o,keepalive:!0,signal:r})).json();return Array.isArray(a?.memories)?a.memories:[]}function glt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function uye(t){return t.replace(/[*?{}[\]!]/g,"").replace(/\/+/g,"/").toLowerCase()}async function plt(t,e){let r=new Map;for(let i of t){let o=i.category||"general";r.has(o)||r.set(o,[]),r.get(o).push(i)}if(r.size===0)return;await dF.default.mkdir(e,{recursive:!0});let n=[];for(let[i,o]of r){let s=`${glt(i)}.md`,a=lye.default.join(e,s),A=o.filter(g=>g.glob),c=o.filter(g=>!g.glob),u=new Map;for(let g of A){let d=g.glob;u.has(d)||u.set(d,[]),u.get(d).push(g)}let l=[...u.keys()].sort((g,d)=>uye(g).localeCompare(uye(d))),p=[];if(p.push(`# ${i}`),p.push(""),l.length>0){p.push("## File-specific"),p.push("");for(let g of l){let d=u.get(g);p.push(`### \`${g}\``),p.push("");for(let f of d)p.push(`- **When**: ${f.when}`),p.push(` ${f.memory}`),p.push("")}}if(c.length>0){p.push("## General"),p.push("");for(let g of c)p.push(`- **When**: ${g.when}`),p.push(` ${g.memory}`),p.push("")}n.push(dF.default.writeFile(a,p.join(`
1848
- `),"utf-8"))}await Promise.all(n)}function dlt(t){let e=[],r=0,n=0;for(let i=0;i<t.length;i++){let o=t[i];o==="{"?r++:o==="}"&&r>0?r--:o===","&&r===0&&(e.push(t.slice(n,i)),n=i+1)}return e.push(t.slice(n)),e.map(i=>i.trim()).filter(Boolean)}function gye(t,e){if(!e)return[];let r=e.replace(/\\/g,"/");return t.filter(n=>n.glob?dlt(n.glob).some(o=>{try{return ki(r,o.replace(/\\/g,"/"),{matchBase:!0})}catch{return!1}}):!1)}async function pye(t,e,r,n){try{return await llt(e,r,n)}catch(i){return t.Sentry?.captureException(new Error("Failed to load memories",{cause:i})),[]}}async function fF(t,e,r){try{await dF.default.rm(r,{recursive:!0,force:!0}),e.length>0&&await plt(e,r)}catch(n){t.Sentry?.captureException(new Error("Failed to sync memories to disk",{cause:n}))}}var dF,lye,iJ=N(()=>{"use strict";m();dF=z(require("node:fs/promises"),1),lye=z(require("node:path"),1);cye();gn();on()});function flt(){if(nQ!==void 0)return nQ;try{return nQ=require("prettier"),nQ}catch{return nQ=null,null}}function oa(t){try{return JSON.stringify(t)}catch{return String(t)}}var Zl,oJ,hF,fye,EF,CF,mye,nQ,dye,mlt,tA,mF,Fh=N(()=>{"use strict";m();bp();rge();Bn();os();gn();on();Zl=z(require("node:fs"),1),oJ=require("node:crypto");$2();sge();uge();z2();qU();fE();dge();hF=z(require("node:os"),1);eO();Ji();Pt();yge();Sv();Tge();_ge();Os();nO();fye=z(require("chokidar"),1);oO();gJ();Kge();fJ();mr();EF=z(require("node:events"),1);BE();CF=require("node:crypto");gm();jge();ZU();IE();ap();PBe();Vc();_Be();mye=require("node:fs/promises");V$();EE();SE();$A();iJ();Oa();tv();ob();kv();iO();dye=["ask-to-continue","credits-limit-daily","credits-limit-monthly","credits-limit-other","invalid-last-message"],mlt=["initial-with-url","initial-without-url","success"],tA=class t{#n;#c;#o;#t=[];#A;#i;#e;#a;#B;#C;#T;#x;#b;#F;#s=!!(process.env.DEBUG||process.env.FUSION_DEBUG==="true");#f=!1;#r=ke("Agent",{debug:()=>this.#s});#g=new EF.default;#W=new Map;#M;#me;#L;#H;#ie=[];#He=void 0;#ut="";#Z;#lt=Promise.resolve(void 0);#Y=[];#P;#$=[];#he;#X=new Map;#Fe=[];#oe;#_t=0;#se;#q;#d;#m;#gt;#$e;#Je;#ke=!1;#Ce;#Ie=void 0;#je;#Ye;#Re;#ae;#I;#p=[];#v;#pt;#E;#qe;#Ee;#Be=0;#Ae;#D;#dt=[];#ft=new Set;#u;#h;#y;#mt;#_;#Ve;#Ne=!1;#ht=0;#ce=null;#ue=0;#ee=!1;#k=!1;#te;#Te;#Me;#re;#Ct;#Pe;#le=[];#_e=[];#ze=!1;#It=new Set;#Et=new Map;#Le=new Map;#ye={};#U={};#Bt=!1;#yt;#We=!1;#Lt=new Set;#Qe;#R={};#Ze;#Xe=[];#De=null;#Qt=void 0;#w=new Map;#Q={watcher:null,listeners:new Set,debounceMs:300,pendingEvents:[]};#Dt=!1;#l=null;#Ue=new Set;#Oe=new Map;#we=new Map;#be=new Map;static#wt=3e4;get primaryGitPath(){return this.#p[0]?.path||this.#I}#ve(e){if(!e)return this.primaryGitPath;let r=this.#p.find(n=>n.folderName===e);if(!r)throw new Error(`Folder "${e}" not found in git-enabled folders`);return r.path}#bt(e,r){if(typeof e!="string")throw new TypeError(`#parsePathWithFolder: 'path' must be a string, received ${typeof e}: ${oa(e)}`);if(r)return{repoPath:this.#ve(r),relativePath:e};for(let n of this.#p){let i=`${n.folderName}/`;if(e.startsWith(i))return{repoPath:n.path,relativePath:e.slice(i.length)}}return{repoPath:this.primaryGitPath,relativePath:e}}constructor(e){if(this.#e=e.sys,this.#_=e.modelOverride,this.#a=e.credentials,"initialUrl"in e){let n=bye(e.initialUrl).id;n?this.#q=n:this.#B=e.initialUrl}typeof e.autoImportLocalMCPs=="boolean"&&(this.#Dt=e.autoImportLocalMCPs),"sessionOrCompletionId"in e?this.#q=e.sessionOrCompletionId:this.#q=e.fusionConfig?.sessionId;let r=e.workingDirectory??e.fusionConfig?.workingDirectory;if(this.#I=r?e.sys.resolve(e.sys.cwd(),r):e.sys.getCwdDir(),this.#T=e.skipFileDiff??!0,this.#C=e.position,this.#M=e.mode,this.#P=e.privacyMode??e.fusionConfig?.privacyMode,this.#d=e.devServerOrchestrator,this.#m=e.git??!1,this.#b=e.softContextWindow,this.#m&&(process.env.GIT_CEILING_DIRECTORIES=this.#I),this.#gt=e.gitAutoInit??!1,this.#u=e.fusionConfig,this.#ze=e.asyncSubAgents??!1,this.#A=e.queueMode??"next-turn",this.#me=e.fusionConfig?.autoPush,this.#h=e.fusionConfig?.projectId,this.#y=e.fusionConfig?.branchName,this.#L=e.fusionConfig?.featureBranch,this.#H=e.fusionConfig?.aiBranch,this.#Te=e.fusionConfig?.proxyOrigin,this.#Me=e.fusionConfig?.proxyDefaultOrigin,this.#$e=e.fusionStatusMonitor,process.env.FUSION_ENV_ORIGIN&&(this.#Ct=process.env.FUSION_ENV_ORIGIN),this.#re=e.agentType,this.#Bt=e.persistSessionLocally??!1,this.#yt=e.parentSessionId,e.enabledTools)this.#D=mF(this.#u,e.enabledTools);else if(this.#M==="quality-v3"){let n=["write_file","search_replace_file","view_path","get_rule","get_style_inspiration","grep_search","web_search","find_media",process.platform==="win32"?"powershell":"bash"];this.#d&&n.push("dev_server_control"),this.#D=mF(this.#u,n)}else if(this.#M==="quality-v4"){let n=["Write","Edit","Read","MultiEdit","Grep","Glob","ReadRule","TodoRead","TodoWrite","Agent","Media","WebFetch","AskUserQuestion","ExitPlanMode","EnterPlanMode",process.platform==="win32"?"PowerShell":"Bash"],i=!!(this.#P?.enabled||this.#P?.redactUserMessages||this.#P?.redactLLMMessages);i||n.push("WebSearch"),this.#h&&!i&&this.getCommitMode()!=="commits"&&n.push("SearchMemories"),i||n.push("GetScreenshot"),n.push("NavigatePreview"),this.#d&&(n.push("DevServerLogs"),n.push("DevServerRestart"),n.push("ProposeEnvVariable")),process.env.FUSION_IDE_PORT&&n.push("IDEDiagnostics"),this.#D=mF(this.#u,n)}if(this.#pt=e.maxTokens,this.#Ve=e.reasoning,this.#je=e.builtInCustomInstructions??[],this.#Ye=e.builtInCustomAgents??[],this.#Re=e.builtInMCPServerConfig??{},this.#ae=e.systemPromptOverride,this.#E=e.fusionConfig?.workspace,this.#qe=e.mcpServers??!1,this.#v=this.#I,this.#p=[],this.#E?.folders.length){let n=this.#E.folders.filter(i=>i.enableGit);this.#p=n.map(i=>({folderName:i.name??i.path,path:this.#e.resolve(this.#I,i.path),branchName:i.branchName||"main",repoUrl:i.repoUrl,originalRepoUrl:i.originalRepoUrl,repoName:i.repoName}));for(let i of n){let o=i.backupMetadata?.check.backup,s=i.name??i.path,a=PE({version:o?.version,originalRepoUrl:o?.repoUrl,commitHash:o?.lastCommitHash});a&&(this.#ye[s]=a)}}this.#p.length===0&&(this.#p=[{folderName:ME,path:this.#I,branchName:"main"}]),this.#Qe=_ye(this.#E),this.#E?.folders[0]&&this.#N()&&(this.#v=this.#e.resolve(this.#I,this.#E.folders[0].path)),this.#g.on("idle",()=>{this.#h==null&&this.#y==null||(this.#r.debug("emitting ClientDevtoolsSessionIdleEventV1",{projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:Sce,extraData:{sessionId:this.getSessionId(),lastMessage:this.getLastMessage(),projectId:this.#h,branchName:this.#y,hasPlanToApply:this.#k,sessionMode:this.getSessionMode(),gifId:this.#U.gif_id,planContent:this.#te},extraAttributes:{projectId:this.#h,branchName:this.#y}},{debug:this.#s}))})}get fusionConfig(){return this.#u}get gitEnabledFolder(){return this.#E?.folders.find(e=>e.enableGit)}get gitEnabledFolders(){return this.#E?.folders.filter(e=>e.enableGit)||[]}get gitRepoContexts(){return this.#p}get workingDirectory(){return this.#I}get bashWorkingDirectory(){return this.#v}getSessionMode(){return this.#n?.sessionMode??"normal"}async switchSessionMode(e){let r=this.getSessionContext();r.sessionMode!==e&&(r.sessionMode=e,this.#k=!1,this.#te=void 0,await this.#fe())}async switchModelOverride(e){this.#_=e||void 0,await this.#fe()}removeSystemReminder(e){let r=this.#$.findIndex(n=>n.tag===e);r!==-1&&this.#$.splice(r,1)}getMemoriesForFile(e){let r=gye(this.#dt,e).filter(n=>!this.#ft.has(n.id));for(let n of r)this.#ft.add(n.id);return r}queueSystemReminder(e){let r=e.tag?this.#$.findIndex(n=>n.tag===e.tag):-1;return r!==-1?e.text?(this.#$[r]=e,{operation:"update"}):(this.#$.splice(r,1),{operation:"delete"}):e.text?(this.#$.push(e),{operation:"add"}):{operation:"noop"}}setDefaultAutoPush(e){this.#me=e}async setPrivacyMode(e){if(e&&e.enabled){if(!e.encryptKey&&!this.#he)this.#he=await UBe();else if(e.encryptKey){if(!await lF(e.encryptKey))throw new Error("Invalid encryption key: key failed validation");this.#he=e.encryptKey}}else this.#he=void 0;this.#P=e}async initializeSession(e={}){return this.#Je||(this.#Je=this.#Gt(e)),await this.#Je}async loadHistory(){let e=this.getSessionContext(),r=await IF(this.#e,this.#a,e.sessionId,!1,this.#s),n=new Map,i=new Map;for(let a of r.turns)for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=hm(A,this.gitRepoContexts[0]?.folderName);n.set(A,c);for(let[u,l]of Object.entries(c))i.has(u)||i.set(u,new Set),i.get(u).add(l)}let o=new Map;for(let[a,A]of i.entries()){let c=this.gitRepoContexts.find(l=>l.folderName===a);if(!c||A.size===0)continue;let u=new Set;try{let p=(await this.git(["cat-file","--batch-check","--buffer"],{sys:this.#e,cwd:c.path,stdin:Array.from(A).map(d=>`${d}^{commit}`).join(`
1848
+ `),"utf-8"))}await Promise.all(n)}function dlt(t){let e=[],r=0,n=0;for(let i=0;i<t.length;i++){let o=t[i];o==="{"?r++:o==="}"&&r>0?r--:o===","&&r===0&&(e.push(t.slice(n,i)),n=i+1)}return e.push(t.slice(n)),e.map(i=>i.trim()).filter(Boolean)}function gye(t,e){if(!e)return[];let r=e.replace(/\\/g,"/");return t.filter(n=>n.glob?dlt(n.glob).some(o=>{try{return ki(r,o.replace(/\\/g,"/"),{matchBase:!0})}catch{return!1}}):!1)}async function pye(t,e,r,n){try{return await llt(e,r,n)}catch(i){return t.Sentry?.captureException(new Error("Failed to load memories",{cause:i})),[]}}async function fF(t,e,r){try{await dF.default.rm(r,{recursive:!0,force:!0}),e.length>0&&await plt(e,r)}catch(n){t.Sentry?.captureException(new Error("Failed to sync memories to disk",{cause:n}))}}var dF,lye,iJ=N(()=>{"use strict";m();dF=z(require("node:fs/promises"),1),lye=z(require("node:path"),1);cye();gn();on()});function flt(){if(nQ!==void 0)return nQ;try{return nQ=require("prettier"),nQ}catch{return nQ=null,null}}function oa(t){try{return JSON.stringify(t)}catch{return String(t)}}var Zl,oJ,hF,fye,EF,CF,mye,nQ,dye,mlt,tA,mF,Fh=N(()=>{"use strict";m();bp();rge();Bn();os();gn();on();Zl=z(require("node:fs"),1),oJ=require("node:crypto");$2();sge();uge();z2();qU();fE();dge();hF=z(require("node:os"),1);eO();Ji();Pt();yge();Sv();Tge();_ge();Os();nO();fye=z(require("chokidar"),1);oO();gJ();Kge();fJ();mr();EF=z(require("node:events"),1);BE();CF=require("node:crypto");gm();jge();ZU();IE();ap();PBe();Vc();_Be();mye=require("node:fs/promises");V$();EE();SE();$A();iJ();Oa();tv();ob();kv();iO();dye=["ask-to-continue","credits-limit-daily","credits-limit-monthly","credits-limit-other","invalid-last-message"],mlt=["initial-with-url","initial-without-url","success"],tA=class t{#n;#c;#o;#t=[];#A;#i;#e;#a;#B;#C;#T;#x;#b;#F;#s=!!(process.env.DEBUG||process.env.FUSION_DEBUG==="true");#f=!1;#r=ke("Agent",{debug:()=>this.#s});#g=new EF.default;#W=new Map;#M;#me;#L;#H;#ie=[];#He=void 0;#lt="";#Z;#gt=Promise.resolve(void 0);#Y=[];#P;#$=[];#he;#X=new Map;#Fe=[];#oe;#_t=0;#se;#q;#d;#m;#pt;#$e;#Je;#ke=!1;#Ce;#Ie=void 0;#je;#Ye;#Re;#ae;#I;#p=[];#v;#dt;#E;#qe;#Ee;#Be=0;#Ae;#D;#ft=[];#mt=new Set;#u;#h;#y;#ht;#_;#Ve;#Ne=!1;#Ct=0;#ce=null;#ue=0;#ee=!1;#k=!1;#te;#Te;#Me;#re;#It;#Pe;#le=[];#_e=[];#ze=!1;#Et=new Set;#Bt=new Map;#Le=new Map;#ye={};#U={};#yt=!1;#We;#Ze=!1;#Lt=new Set;#Qe;#R={};#Xe;#et=[];#De=null;#Qt=void 0;#w=new Map;#Q={watcher:null,listeners:new Set,debounceMs:300,pendingEvents:[]};#Dt=!1;#l=null;#Ue=new Set;#Oe=new Map;#we=new Map;#be=new Map;static#wt=3e4;get primaryGitPath(){return this.#p[0]?.path||this.#I}#ve(e){if(!e)return this.primaryGitPath;let r=this.#p.find(n=>n.folderName===e);if(!r)throw new Error(`Folder "${e}" not found in git-enabled folders`);return r.path}#bt(e,r){if(typeof e!="string")throw new TypeError(`#parsePathWithFolder: 'path' must be a string, received ${typeof e}: ${oa(e)}`);if(r)return{repoPath:this.#ve(r),relativePath:e};for(let n of this.#p){let i=`${n.folderName}/`;if(e.startsWith(i))return{repoPath:n.path,relativePath:e.slice(i.length)}}return{repoPath:this.primaryGitPath,relativePath:e}}constructor(e){if(this.#e=e.sys,this.#_=e.modelOverride,this.#a=e.credentials,"initialUrl"in e){let n=bye(e.initialUrl).id;n?this.#q=n:this.#B=e.initialUrl}typeof e.autoImportLocalMCPs=="boolean"&&(this.#Dt=e.autoImportLocalMCPs),"sessionOrCompletionId"in e?this.#q=e.sessionOrCompletionId:this.#q=e.fusionConfig?.sessionId;let r=e.workingDirectory??e.fusionConfig?.workingDirectory;if(this.#I=r?e.sys.resolve(e.sys.cwd(),r):e.sys.getCwdDir(),this.#T=e.skipFileDiff??!0,this.#C=e.position,this.#M=e.mode,this.#P=e.privacyMode??e.fusionConfig?.privacyMode,this.#d=e.devServerOrchestrator,this.#m=e.git??!1,this.#b=e.softContextWindow,this.#m&&(process.env.GIT_CEILING_DIRECTORIES=this.#I),this.#pt=e.gitAutoInit??!1,this.#u=e.fusionConfig,this.#ze=e.asyncSubAgents??!1,this.#A=e.queueMode??"next-turn",this.#me=e.fusionConfig?.autoPush,this.#h=e.fusionConfig?.projectId,this.#y=e.fusionConfig?.branchName,this.#L=e.fusionConfig?.featureBranch,this.#H=e.fusionConfig?.aiBranch,this.#Te=e.fusionConfig?.proxyOrigin,this.#Me=e.fusionConfig?.proxyDefaultOrigin,this.#$e=e.fusionStatusMonitor,process.env.FUSION_ENV_ORIGIN&&(this.#It=process.env.FUSION_ENV_ORIGIN),this.#re=e.agentType,this.#yt=e.persistSessionLocally??!1,this.#We=e.parentSessionId,e.enabledTools)this.#D=mF(this.#u,e.enabledTools);else if(this.#M==="quality-v3"){let n=["write_file","search_replace_file","view_path","get_rule","get_style_inspiration","grep_search","web_search","find_media",process.platform==="win32"?"powershell":"bash"];this.#d&&n.push("dev_server_control"),this.#D=mF(this.#u,n)}else if(this.#M==="quality-v4"){let n=["Write","Edit","Read","MultiEdit","Grep","Glob","ReadRule","TodoRead","TodoWrite","Agent","Media","WebFetch","AskUserQuestion","ExitPlanMode","EnterPlanMode",process.platform==="win32"?"PowerShell":"Bash"],i=!!(this.#P?.enabled||this.#P?.redactUserMessages||this.#P?.redactLLMMessages);i||n.push("WebSearch"),this.#h&&!i&&this.getCommitMode()!=="commits"&&n.push("SearchMemories"),i||n.push("GetScreenshot"),n.push("NavigatePreview"),this.#d&&(n.push("DevServerLogs"),n.push("DevServerRestart"),n.push("ProposeEnvVariable")),process.env.FUSION_IDE_PORT&&n.push("IDEDiagnostics"),this.#D=mF(this.#u,n)}if(this.#dt=e.maxTokens,this.#Ve=e.reasoning,this.#je=e.builtInCustomInstructions??[],this.#Ye=e.builtInCustomAgents??[],this.#Re=e.builtInMCPServerConfig??{},this.#ae=e.systemPromptOverride,this.#E=e.fusionConfig?.workspace,this.#qe=e.mcpServers??!1,this.#v=this.#I,this.#p=[],this.#E?.folders.length){let n=this.#E.folders.filter(i=>i.enableGit);this.#p=n.map(i=>({folderName:i.name??i.path,path:this.#e.resolve(this.#I,i.path),branchName:i.branchName||"main",repoUrl:i.repoUrl,originalRepoUrl:i.originalRepoUrl,repoName:i.repoName}));for(let i of n){let o=i.backupMetadata?.check.backup,s=i.name??i.path,a=PE({version:o?.version,originalRepoUrl:o?.repoUrl,commitHash:o?.lastCommitHash});a&&(this.#ye[s]=a)}}this.#p.length===0&&(this.#p=[{folderName:ME,path:this.#I,branchName:"main"}]),this.#Qe=_ye(this.#E),this.#E?.folders[0]&&this.#N()&&(this.#v=this.#e.resolve(this.#I,this.#E.folders[0].path)),this.#g.on("idle",()=>{this.#h==null&&this.#y==null||this.#We||(this.#r.debug("emitting ClientDevtoolsSessionIdleEventV1",{projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:Sce,extraData:{sessionId:this.getSessionId(),lastMessage:this.getLastMessage(),projectId:this.#h,branchName:this.#y,hasPlanToApply:this.#k,sessionMode:this.getSessionMode(),gifId:this.#U.gif_id,planContent:this.#te},extraAttributes:{projectId:this.#h,branchName:this.#y}},{debug:this.#s}))})}get fusionConfig(){return this.#u}get gitEnabledFolder(){return this.#E?.folders.find(e=>e.enableGit)}get gitEnabledFolders(){return this.#E?.folders.filter(e=>e.enableGit)||[]}get gitRepoContexts(){return this.#p}get workingDirectory(){return this.#I}get bashWorkingDirectory(){return this.#v}getSessionMode(){return this.#n?.sessionMode??"normal"}async switchSessionMode(e){let r=this.getSessionContext();r.sessionMode!==e&&(r.sessionMode=e,this.#k=!1,this.#te=void 0,await this.#fe())}async switchModelOverride(e){this.#_=e||void 0,await this.#fe()}removeSystemReminder(e){let r=this.#$.findIndex(n=>n.tag===e);r!==-1&&this.#$.splice(r,1)}getMemoriesForFile(e){let r=gye(this.#ft,e).filter(n=>!this.#mt.has(n.id));for(let n of r)this.#mt.add(n.id);return r}queueSystemReminder(e){let r=e.tag?this.#$.findIndex(n=>n.tag===e.tag):-1;return r!==-1?e.text?(this.#$[r]=e,{operation:"update"}):(this.#$.splice(r,1),{operation:"delete"}):e.text?(this.#$.push(e),{operation:"add"}):{operation:"noop"}}setDefaultAutoPush(e){this.#me=e}async setPrivacyMode(e){if(e&&e.enabled){if(!e.encryptKey&&!this.#he)this.#he=await UBe();else if(e.encryptKey){if(!await lF(e.encryptKey))throw new Error("Invalid encryption key: key failed validation");this.#he=e.encryptKey}}else this.#he=void 0;this.#P=e}async initializeSession(e={}){return this.#Je||(this.#Je=this.#Gt(e)),await this.#Je}async loadHistory(){let e=this.getSessionContext(),r=await IF(this.#e,this.#a,e.sessionId,!1,this.#s),n=new Map,i=new Map;for(let a of r.turns)for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=hm(A,this.gitRepoContexts[0]?.folderName);n.set(A,c);for(let[u,l]of Object.entries(c))i.has(u)||i.set(u,new Set),i.get(u).add(l)}let o=new Map;for(let[a,A]of i.entries()){let c=this.gitRepoContexts.find(l=>l.folderName===a);if(!c||A.size===0)continue;let u=new Set;try{let p=(await this.git(["cat-file","--batch-check","--buffer"],{sys:this.#e,cwd:c.path,stdin:Array.from(A).map(d=>`${d}^{commit}`).join(`
1849
1849
  `)})).trim().split(`
1850
- `),g=new Set;for(let d of p)if(d.includes("missing")){let f=d.split(/\s+/)[0].replace("^{commit}","");g.add(f)}for(let d of A)g.has(d)||u.add(d)}catch(l){this.#e.Sentry?.captureException(l)}o.set(a,u)}let s=r.turns.filter(a=>{for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=n.get(A);if(c)for(let[u,l]of Object.entries(c)){if(!this.gitRepoContexts.find(d=>d.folderName===u))continue;let g=o.get(u);if(!g||!g.has(l))return!1}}return!0});return{sessionId:e.sessionId,title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:s}}async loadWholeSession(e={}){let{getAll:r=!0}=e,n=this.getSessionContext(),i=0;for(;n.canLoadMore&&n.canLoadMore;){let o=await this.loadMoreTurns();i+=o.length}return{sessionId:n.sessionId,title:n.title,beforeCommit:n.beforeCommit,createdUnixTime:n.createdUnixTime,updatedUnixTime:n.updatedUnixTime,addedTurns:i,turns:r?n.turns:n.turns.slice(0,i)}}async loadMoreTurns(){return this.#Ce||(this.#Ce=this.#Ut().then(e=>(this.#Ce=void 0,e))),this.#Ce}async#Ut(){let e=this.getSessionContext();if(e.canLoadMore){let r=e.turns[0]?.completionId,n=await IF(this.#e,this.#a,e.sessionId,!0,this.#s,r);return n.turns.length>0&&e.turns.unshift(...n.turns),e.canLoadMore=n.canLoadMore,n.turns}return[]}async#Ot(){try{let e=flt();if(!e)return null;let r=this.#e.join(this.primaryGitPath,"file.tsx");return await e.resolveConfig(r)}catch{return null}}async setCustomInstructions(e){this.#je=e,this.#n&&(this.#n.customInstructions=await this.#Se())}async setCustomAgents(e){this.#Ye=e,this.#n&&(this.#n.customAgents=await this.#Ge())}async#Se(){let r=(await Promise.all(this.#p.map(n=>dJ({sys:this.#e,projectDir:this.#I,currentDir:n.path,rootDir:"/",allowedCommands:Xb(this.#u?.allowedCommands??[]),skipCommandSecurity:this.#u?.skipCommandSecurity===!0})))).flat();return sJ(this.#je??[],r)}async#Ge(){if(!this.#D?.includes("Agent"))return[];let r=(await Promise.all(this.#p.map(n=>Gge({sys:this.#e,projectDir:this.#I,currentDir:n.path,rootDir:"/"})))).flat();return sJ(this.#Ye??[],r)}async#Gt(e){try{if(this.#Ne)throw new Error("Code session already closed");if(this.#n)throw new Error("Session context already initialized");this.#r.debug(`Current AI working directory: ${this.#I}`),await this.setPrivacyMode(this.#P);let r=await this.#Ht(),n=await this.#Ot();r&&(this.#R=await this.#O());let i=this.#p[0]?.repoUrl;this.#mt=await rO(i);let o,s;this.#q||(this.#q=r?.sessionId),this.#q?e.skipSessionLoading?o=this.#q:(s=await IF(this.#e,this.#a,this.#q,!0,this.#s,void 0,e.signal),o=s.sessionId,this.#r.debug(`Session recovered (sessionId=${o}, turnsCount=${s.turns.length})`)):o=(0,CF.randomUUID)(),this.#L||(this.#L=r?.featureBranch?.trim());let a={turns:s?.turns??[],sessionId:o,customInstructions:await this.#Se(),customAgents:await this.#Ge(),title:s?.title,beforeCommit:s?.beforeCommit,createdUnixTime:s?.createdUnixTime??Date.now(),updatedUnixTime:s?.updatedUnixTime??Date.now(),userContext:await vye(this.#e,this.primaryGitPath),prettierConfig:n,canLoadMore:s?.canLoadMore??!1,state:s?.turns.length?"success":this.#B?"initial-with-url":"initial-without-url",sessionMode:s?.sessionMode??"normal"};if(this.#U=s?.metadata??{},s?.hasPlanToApply&&(this.#k=!0),s){let c=sc(s.turns);c?.completionId!==s.lastCompletionId&&this.#e.Sentry?.captureException(new Error("Last completion id mismatch"),{tags:{operation:"codegen-initialize-session"},extra:{lastTurn:c,sessionMetadata:s}})}if(this.#s&&this.#g.on("step",c=>{c.type!=="delta"&&this.#r.debug(`(${c.type}): ${nm(JSON.stringify(c),400)}`)}),await this.#Jt(a),this.#n=a,this.#re){let c=await this.getNamedAgentConfig(this.#re,this.getSessionId(),e.signal);if(c.success){if(this.#x=c.options.includeMemories,this.#D=c.options.enabledTools,this.#_=c.options.modelOverride,this.#M=c.options.mode,this.#ae=c.options.systemPromptOverride,this.#C=c.options.position,this.#A=c.options.queueMode??"next-turn",this.#ze=c.options.asyncSubAgents??!1,this.#b=c.options.softContextWindow,this.#Re={...this.#Re,...c.options.builtInMCPServerConfig},c.options.builtInMCPServerConfig?.chrome&&!this.#it){let u=new NE(this.getSessionId(),{framesDir:this.#e.join(hF.default.homedir(),".builder","recordings"),debug:this.#s});this.setTimeline(u)}typeof c.options.mcpServers=="boolean"&&(this.#qe=c.options.mcpServers)}else this.#r.error(c.response)}try{let c=await MBe(this.#e,this.primaryGitPath,this.#Re,this.#Dt,e.signal);c.length>0?(this.#r.debug(`Initializing ${c.length} local MCP server(s)...`),this.#Ee=await TBe(c,this.#e,this.primaryGitPath,e.signal)):this.#r.debug(`No local MCP servers found in: ${this.primaryGitPath}`)}catch(c){this.#r.error("Failed to initialize local MCP servers:",c,{loggerOptions:{debug:!0}})}if(this.#m&&this.#h&&this.#D?.includes("SearchMemories")){let c=await pye(this.#e,this.#a,this.#h,e.signal);await fF(this.#e,c,this.#e.join(this.#v,".builder","memories")),this.#dt=c,this.#D&&c.length===0&&(this.#D=this.#D.filter(u=>u!=="SearchMemories"))}let A=this.#d;if(A){let c=()=>{this.#g.emit("step",lJ(A,this.#u))},u=()=>{this.#g.emit("step",lJ(A,this.#u)),this.#fe(),this.#pe()},l=p=>{p==="ok-2xx"&&(this.requestRefresh(),this.isIdle()&&this.#u?.branchType==="code-review"&&!this.#It.has("browser-testing")&&this.sendMessage({userPrompt:"The dev server is now ready. You have not run the browser-testing agent yet. Run Step 5 now \u2014 spawn the browser-testing agent with a complete test plan based on the PR changes and code review findings from your earlier analysis.",category:"background-subagent",user:{role:"agent",source:"builder.io"}}))};A.emitter.on("setupState",u),A.emitter.on("devState",u),A.emitter.on("httpServerData",u),A.emitter.on("httpServerState",l),A.emitter.on("validateState",c),this.#Fe.push(()=>{A.emitter.off("setupState",u),A.emitter.off("devState",u),A.emitter.off("httpServerData",u),A.emitter.off("httpServerState",l),A.emitter.off("validateState",c)})}}catch(r){throw this.#r.error(r),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-initialize-session"}}),r}}async#et(e,r){let n="reminder:health";this.removeSystemReminder(n);let i=this.#d;if(!i||!(this.#D?.includes("DevServerLogs")||this.#D?.includes("DevServerRestart")||this.#D?.includes("DevServerControl")||this.#D?.includes("ProposeEnvVariable")))return;let s=this.getSessionContext();if(s.sessionMode!=="normal")return;e&&await i.waitUntilIdle(500,500);let a=i.setupState,A=await this.#rt(),c=i.devCommand,u=i.devState,l=i.state,p=i.setupCommand,g=await i.getOpenPorts(),d=i.proxyTarget,f=i.httpServerState.state,h=i.lastServerStatus,C=f==="error-fetch",I=!1;this.#m&&(I=await this.getCurrentBranch()!==this.getAiBranch());let B=f==="error-5xx"||f==="error-4xx"&&h!==401&&h!==404,E="",y=!1,D=!1;l==="install-failed"||l==="install-aborted"?E=i.getSetupOutput():(E=i.getCheckpoints(1,u!=="running"?"err":"all"),y=Fye(E??""));let v="",Q="",x="error",b="Try to fix",S="repair-unknown";if(l==="not-installed"||l==="install-failed"||l==="install-aborted"||l==="failed"||I||C||B||y||A.length>0){if(I&&(S="repair-bad-branch",Q+=`- The current git branch is not the AI branch (${this.getAiBranch()}).
1850
+ `),g=new Set;for(let d of p)if(d.includes("missing")){let f=d.split(/\s+/)[0].replace("^{commit}","");g.add(f)}for(let d of A)g.has(d)||u.add(d)}catch(l){this.#e.Sentry?.captureException(l)}o.set(a,u)}let s=r.turns.filter(a=>{for(let A of[a.beforeCommit,a.afterCommit,a.lastCommit]){if(!A)continue;let c=n.get(A);if(c)for(let[u,l]of Object.entries(c)){if(!this.gitRepoContexts.find(d=>d.folderName===u))continue;let g=o.get(u);if(!g||!g.has(l))return!1}}return!0});return{sessionId:e.sessionId,title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:s}}async loadWholeSession(e={}){let{getAll:r=!0}=e,n=this.getSessionContext(),i=0;for(;n.canLoadMore&&n.canLoadMore;){let o=await this.loadMoreTurns();i+=o.length}return{sessionId:n.sessionId,title:n.title,beforeCommit:n.beforeCommit,createdUnixTime:n.createdUnixTime,updatedUnixTime:n.updatedUnixTime,addedTurns:i,turns:r?n.turns:n.turns.slice(0,i)}}async loadMoreTurns(){return this.#Ce||(this.#Ce=this.#Ut().then(e=>(this.#Ce=void 0,e))),this.#Ce}async#Ut(){let e=this.getSessionContext();if(e.canLoadMore){let r=e.turns[0]?.completionId,n=await IF(this.#e,this.#a,e.sessionId,!0,this.#s,r);return n.turns.length>0&&e.turns.unshift(...n.turns),e.canLoadMore=n.canLoadMore,n.turns}return[]}async#Ot(){try{let e=flt();if(!e)return null;let r=this.#e.join(this.primaryGitPath,"file.tsx");return await e.resolveConfig(r)}catch{return null}}async setCustomInstructions(e){this.#je=e,this.#n&&(this.#n.customInstructions=await this.#Se())}async setCustomAgents(e){this.#Ye=e,this.#n&&(this.#n.customAgents=await this.#Ge())}async#Se(){let r=(await Promise.all(this.#p.map(n=>dJ({sys:this.#e,projectDir:this.#I,currentDir:n.path,rootDir:"/",allowedCommands:Xb(this.#u?.allowedCommands??[]),skipCommandSecurity:this.#u?.skipCommandSecurity===!0})))).flat();return sJ(this.#je??[],r)}async#Ge(){if(!this.#D?.includes("Agent"))return[];let r=(await Promise.all(this.#p.map(n=>Gge({sys:this.#e,projectDir:this.#I,currentDir:n.path,rootDir:"/"})))).flat();return sJ(this.#Ye??[],r)}async#Gt(e){try{if(this.#Ne)throw new Error("Code session already closed");if(this.#n)throw new Error("Session context already initialized");this.#r.debug(`Current AI working directory: ${this.#I}`),await this.setPrivacyMode(this.#P);let r=await this.#Ht(),n=await this.#Ot();r&&(this.#R=await this.#O());let i=this.#p[0]?.repoUrl;this.#ht=await rO(i);let o,s;this.#q||(this.#q=r?.sessionId),this.#q?e.skipSessionLoading?o=this.#q:(s=await IF(this.#e,this.#a,this.#q,!0,this.#s,void 0,e.signal),o=s.sessionId,this.#r.debug(`Session recovered (sessionId=${o}, turnsCount=${s.turns.length})`)):o=(0,CF.randomUUID)(),this.#L||(this.#L=r?.featureBranch?.trim());let a={turns:s?.turns??[],sessionId:o,customInstructions:await this.#Se(),customAgents:await this.#Ge(),title:s?.title,beforeCommit:s?.beforeCommit,createdUnixTime:s?.createdUnixTime??Date.now(),updatedUnixTime:s?.updatedUnixTime??Date.now(),userContext:await vye(this.#e,this.primaryGitPath),prettierConfig:n,canLoadMore:s?.canLoadMore??!1,state:s?.turns.length?"success":this.#B?"initial-with-url":"initial-without-url",sessionMode:s?.sessionMode??"normal"};if(this.#U=s?.metadata??{},s?.hasPlanToApply&&(this.#k=!0),s){let c=sc(s.turns);c?.completionId!==s.lastCompletionId&&this.#e.Sentry?.captureException(new Error("Last completion id mismatch"),{tags:{operation:"codegen-initialize-session"},extra:{lastTurn:c,sessionMetadata:s}})}if(this.#s&&this.#g.on("step",c=>{c.type!=="delta"&&this.#r.debug(`(${c.type}): ${nm(JSON.stringify(c),400)}`)}),await this.#Jt(a),this.#n=a,this.#re){let c=await this.getNamedAgentConfig(this.#re,this.getSessionId(),e.signal);if(c.success){if(this.#x=c.options.includeMemories,this.#D=c.options.enabledTools,this.#_=c.options.modelOverride,this.#M=c.options.mode,this.#ae=c.options.systemPromptOverride,this.#C=c.options.position,this.#A=c.options.queueMode??"next-turn",this.#ze=c.options.asyncSubAgents??!1,this.#b=c.options.softContextWindow,this.#Re={...this.#Re,...c.options.builtInMCPServerConfig},c.options.builtInMCPServerConfig?.chrome&&!this.#ot){let u=new NE(this.getSessionId(),{framesDir:this.#e.join(hF.default.homedir(),".builder","recordings"),debug:this.#s});this.setTimeline(u)}typeof c.options.mcpServers=="boolean"&&(this.#qe=c.options.mcpServers)}else this.#r.error(c.response)}try{let c=await MBe(this.#e,this.primaryGitPath,this.#Re,this.#Dt,e.signal);c.length>0?(this.#r.debug(`Initializing ${c.length} local MCP server(s)...`),this.#Ee=await TBe(c,this.#e,this.primaryGitPath,e.signal)):this.#r.debug(`No local MCP servers found in: ${this.primaryGitPath}`)}catch(c){this.#r.error("Failed to initialize local MCP servers:",c,{loggerOptions:{debug:!0}})}if(this.#m&&this.#h&&this.#D?.includes("SearchMemories")){let c=await pye(this.#e,this.#a,this.#h,e.signal);await fF(this.#e,c,this.#e.join(this.#v,".builder","memories")),this.#ft=c,this.#D&&c.length===0&&(this.#D=this.#D.filter(u=>u!=="SearchMemories"))}let A=this.#d;if(A){let c=()=>{this.#g.emit("step",lJ(A,this.#u))},u=()=>{this.#g.emit("step",lJ(A,this.#u)),this.#fe(),this.#pe()},l=p=>{p==="ok-2xx"&&(this.requestRefresh(),this.isIdle()&&this.#u?.branchType==="code-review"&&!this.#Et.has("browser-testing")&&this.sendMessage({userPrompt:"The dev server is now ready. You have not run the browser-testing agent yet. Run Step 5 now \u2014 spawn the browser-testing agent with a complete test plan based on the PR changes and code review findings from your earlier analysis.",category:"background-subagent",user:{role:"agent",source:"builder.io"}}))};A.emitter.on("setupState",u),A.emitter.on("devState",u),A.emitter.on("httpServerData",u),A.emitter.on("httpServerState",l),A.emitter.on("validateState",c),this.#Fe.push(()=>{A.emitter.off("setupState",u),A.emitter.off("devState",u),A.emitter.off("httpServerData",u),A.emitter.off("httpServerState",l),A.emitter.off("validateState",c)})}}catch(r){throw this.#r.error(r),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-initialize-session"}}),r}}async#tt(e,r){let n="reminder:health";this.removeSystemReminder(n);let i=this.#d;if(!i||!(this.#D?.includes("DevServerLogs")||this.#D?.includes("DevServerRestart")||this.#D?.includes("DevServerControl")||this.#D?.includes("ProposeEnvVariable")))return;let s=this.getSessionContext();if(s.sessionMode!=="normal")return;e&&await i.waitUntilIdle(500,500);let a=i.setupState,A=await this.#nt(),c=i.devCommand,u=i.devState,l=i.state,p=i.setupCommand,g=await i.getOpenPorts(),d=i.proxyTarget,f=i.httpServerState.state,h=i.lastServerStatus,C=f==="error-fetch",I=!1;this.#m&&(I=await this.getCurrentBranch()!==this.getAiBranch());let B=f==="error-5xx"||f==="error-4xx"&&h!==401&&h!==404,E="",y=!1,D=!1;l==="install-failed"||l==="install-aborted"?E=i.getSetupOutput():(E=i.getCheckpoints(1,u!=="running"?"err":"all"),y=Fye(E??""));let v="",Q="",x="error",b="Try to fix",S="repair-unknown";if(l==="not-installed"||l==="install-failed"||l==="install-aborted"||l==="failed"||I||C||B||y||A.length>0){if(I&&(S="repair-bad-branch",Q+=`- The current git branch is not the AI branch (${this.getAiBranch()}).
1851
1851
  `,Q+=`- Please switch to the AI branch using the 'git' tool.
1852
- `,v=`The current branch is not the AI branch (${this.getAiBranch()}).`),A.length>0){S="repair-merge-conflict",b="Resolve conflict",v="Merge conflict detected - changes from different sources need to be combined";let U=this.#Ze,M=U?`
1852
+ `,v=`The current branch is not the AI branch (${this.getAiBranch()}).`),A.length>0){S="repair-merge-conflict",b="Resolve conflict",v="Merge conflict detected - changes from different sources need to be combined";let U=this.#Xe,M=U?`
1853
1853
  ours (:2:) = ${U.ourBranch} (AI branch), theirs (:3:) = ${U.theirBranch} (${U.theirIsMain?"main \u2014 prefer preserving these changes":"AI remote"})`:"";Q+=`Merge conflict detected. Resolve ALL conflicted files:
1854
1854
  ${A.join(`
1855
1855
  `)}
@@ -1898,20 +1898,20 @@ ${i.getSetupOutput().slice(-8e3)}
1898
1898
  `:E&&(Q+=`<dev_logs>
1899
1899
  ${E}
1900
1900
  </dev_logs>
1901
- `)}(r==="all"||r==="critical"&&!D)&&this.queueSystemReminder({text:nm(Q,2e3),tag:n});let _={devServerState:u,setupState:a,httpServerState:f,proxyServer:d,devCommand:c,setupCommand:p,hasMergeConflict:A.length>0,hasConfigurationIssue:D,logs:E,prompt:"Debug and fix the issue before continuing.",message:v},$=this.#t.length===0&&mlt.includes(s.state);return{actionButtonText:b,type:"build-error",level:x,canAutoApply:$,healthStatus:_,message:_.message,userMessage:{userPrompt:_.prompt,repair:!0,category:S,displayPrompt:_.message}}}}async#Kt(){let e=await this.#et(!1,"critical"),r=!!(e&&!e.healthStatus.hasConfigurationIssue);return r&&this.#d?.addCheckpoint(),{hasHealthIssue:r}}async#Ht(){let e;if(this.#m)try{if(this.#r.debug("Initializing Fusion session for AI side-car branch workflow..."),e=await this.#e.getRepoInfo(this.primaryGitPath),!e.hasGit)if(this.#gt){this.#r.warn("No git repository detected. Initializing a new git repository...",{loggerOptions:{debug:!0}});try{await this.git(["init"]),await this.git(["add","."]),await this.git(["branch","-M","main"]),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Initial commit for Fusion workflow"]),this.#r.debug("Successfully initialized a new git repository")}catch(r){this.#r.error("Failed to initialize git repository:",r);return}}else{this.#r.error("Not in a git repository. Fusion requires a git repository.");return}return await mv({sys:this.#e,gitWorkingDirectory:this.primaryGitPath,strict:!0})}catch(r){O.error(`\u274C Error initializing Fusion session: ${r}`);let n=new Error("Initialize Git failed",{cause:r});throw this.#e.Sentry?.captureException(n,{level:"fatal",tags:{operation:"codegen-initialize-session"},extra:{repoInfo:e}}),n}}async#$t(e,r){try{await this.git(["checkout",e],{cwd:r})}catch{await this.git(["checkout","-b",e],{cwd:r})}}async#Jt(e){if(!this.#m)return;if(!this.#H){let o=Ule(this.getFeatureBranch(),e.sessionId);this.#H=o}let r=this.getAiBranch();await this.#J(async o=>{await this.getCurrentBranch(o.path)!==r&&await this.#$t(r,o.path);try{await this.git(["branch","--set-upstream-to",`refs/remotes/origin/${this.#ge(o)}`],{cwd:o.path})}catch{}});let n=sc(e.turns),i=n?.afterCommit??n?.lastCommit;if(i)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=yl(i,o.folderName,s);if(a){let A=await this.getCurrentCommitHash("HEAD",o.path);A&&A!==a&&this.#e.Sentry?.captureException(new Error(`Init: After commit mismatch for ${o.folderName}`),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,targetCommit:a,currentCommitHash:A,lastTurn:n}})}}if(e.beforeCommit)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=yl(e.beforeCommit,o.folderName,s);if(a)try{await this.git(["rev-parse","--quiet","--verify",a],{cwd:o.path})}catch(A){this.#e.Sentry?.captureException(new Error(`Init: Before commit not found for ${o.folderName}`,{cause:A}),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,beforeCommit:a,turnStates:e.turns.length,lastCompletionId:sc(e.turns)?.completionId}})}}}async#jt(e,r,n){let i;try{i=(await this.git(["remote","get-url","origin"],r)).trim()}catch{}let{url:o,token:s,provider:a}=e;try{new URL(o)}catch{throw this.#e.Sentry?.captureException(new Error("Provided remote url is invalid"),{tags:{operation:"codegen-git"},extra:{url:o,currentOriginUrl:i}}),new Error("Provided remote url is invalid")}if(i!==o&&(this.#ye={},i?await this.git(["remote","set-url","origin",o],r):await this.git(["remote","add","origin",o],r),(a==="github"||a==="selfHostedGithub")&&s)){(!n||n===this.gitEnabledFolders[0]?.name)&&(process.env.GH_TOKEN=s);let c=this.gitEnabledFolders.length>1;n&&c&&(process.env[yF(n)]=s)}}async pushRepoV2(e){return await this.#K(this.#xe({pullFirst:!1,updateRepo:e,refreshRemote:!0}),"pushRepoV2",!0)}async ensureGitAuth(){return this.#m?this.#tt():{success:!0,message:"Git is not enabled, skipping auth"}}async#tt({force:e}={}){if(!this.#m)return{success:!0,message:"Git is not enabled"};let n=Date.now()-this.#ht,i=300*1e3;if(!e&&n<=i)return{success:!0,message:"Git auth still valid (within 5min)"};if(this.#ce){if(!e)return this.#ce;await this.#ce.catch(()=>{})}return this.#ce=this.#Yt().then(o=>(o.success&&(this.#ht=Date.now()),o)).finally(()=>{this.#ce=null}),this.#ce}async#Yt(){let e;try{let r=this.gitEnabledFolders;if(r.length===0)throw new Error("No git-enabled repos found");let n=r.filter(o=>!o.initializationCommand&&!o.repoUrl?.startsWith("ssh://"));if(n.length===0)return{success:!0,message:"Git remote URLs update not needed"};if(!this.#h)throw new Error("Project ID is required to update git URLs");let i=await Cm(this.#a,this.#h,this.#s);if(!i.success)throw i.error;e=i.gitConfigs;for(let o of n){if(!o.repoName)continue;let s=e?.[o.repoName];if(s?.url){let a=this.#e.resolve(this.#I,o.path);await this.#jt(s,a,o.name)}}return{success:!0,message:"Git remote URLs updated"}}catch(r){let n=`Failed to update git remote URLs: ${td(r)}`;return this.#r.error(n,{loggerOptions:{debug:!0}}),this.#g.emit("step",{type:"error",message:n,code:"git-update-error"}),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-git",endpoint:"updateGitUrls"},extra:{projectId:this.#h,workspaceFolders:this.#E?.folders,gitConfigs:e}}),{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async zipFolder(e){if(typeof e!="string")throw new TypeError(`zipFolder: 'folderName' must be a string, received ${typeof e}: ${oa(e)}`);let{resolvedPath:r}=this.resolveWorkspacePath(e,!1),n=Date.now(),i=Math.random().toString(36).substring(2,8),o=`zip-${n}-${i}.zip`,s="/tmp",a=this.#e.join(s,o);return Zl.default.mkdirSync(s,{recursive:!0}),await Ha("zip",["-r",a,".","-x","**/node_modules/**"],{cwd:r,sys:this.#e}),a}async archiveProject(){if(!this.#m)throw new Error("Can not archive project in non git mode");try{let e=Date.now(),r=Math.random().toString(36).substring(2,8),n=`project-${e}-${r}.zip`,i="/tmp",o=this.#e.join(i,n);return Zl.default.mkdirSync(i,{recursive:!0}),await this.git(["archive","--format=zip","-o",o,"HEAD"]),o}catch(e){throw new Error("Failed to archive project",{cause:e})}}isIdle(){let e=this.getSessionContext(),r=["generating","replay"];return!this.#Ae&&!r.includes(e.state)&&this.#le.length===0}async needsBackup(){if(!this.#m||!this.#h||!this.#y)return!1;for(let e of this.#p){let r=e.originalRepoUrl??e.repoUrl;if(!r)continue;let n=await this.getCurrentCommitHash("HEAD",e.path);if(!n)continue;let i=PE({version:"v2",originalRepoUrl:r,commitHash:n});if(this.#ye[e.folderName]!==i)return!0}return!1}async uploadBackup(e=!1){try{await this.waitUntilBlockingPendingPromises(),await this.#ne(!1);let r=this.#h,n=this.#y;if(!this.#m)throw new Error("Cannot upload backup in non-git mode");if(!r)throw new Error("Project ID is required for backup upload");if(!n)throw new Error("Branch ID is required for backup upload");let i=this.getAiBranch(),o=this.getFeatureBranch(),s=await this.#O();await vv(this.#e,this.#a,{commits:s,projectId:r,branchName:n},this.#s);let a=performance.now(),A=[];for(let l of this.#p){let p=l.originalRepoUrl??l.repoUrl;if(!p)continue;let g=await this.#Ft(()=>wv({sys:this.#e,credentials:this.#a,projectId:r,branchName:n,repoPath:l.path,aiBranch:i,featureBranch:l.branchName||o,workspace:this.#E,debug:this.#s,isConnectedToProvider:!0,forcedFullBackup:e,canAbortMerge:this.#Ne,folderName:l.folderName,repoUrl:p}));if(!g.success)return g;A.push({result:g,folderName:l.folderName})}if(A.length===0)return{success:!1,error:new Error("No repos to backup")};let c=A.map(l=>l.result.backupEntry),u=performance.now()-a;await bv(this.#a,c,u,this.#s);for(let{result:l,folderName:p}of A)l.backupRef&&(this.#ye[p]=l.backupRef);return A[0].result}catch(r){if(this.#r.error("Failed to upload backup",r),this.#ye={},this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-backup",backupError:""}}),r instanceof Error&&r.message.includes("Commit(s) not found on remote"))throw r instanceof Error?r:new Error(String(r));return{success:!1,error:r instanceof Error?r:new Error(String(r))}}}getCommitMode(){return this.#u?.commitMode??"prs"}#ge(e){return this.getCommitMode()==="commits"?`${e?.branchName||this.getFeatureBranch()}`:`${this.getAiBranch()}`}async#vt(e,r){let n=this.getCommitMode(),i=this.#ge(r),o=await this.getCurrentBranch(r?.path);return n==="commits"?["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",`${o}:${i}`]:["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",i]}async pushChanges(e){let r=performance.now(),n=await this.#K(this.#xe(e),"pushChanges",!0);return this.#G("git_push_changes_total",performance.now()-r,{success:String(n.success!==!1)}),n}async#xe(e){let{pullFirst:r,updateRepo:n,actor:i,refreshRemote:o,forcePush:s,folderName:a,requireFastForward:A,abortOnMergeConflict:c}=Tye(e);try{if(!this.#m)throw new Error("Can not push changes in non-git mode");if(this.#u?.isFork)throw new Error("Cannot push changes to fork PRs. Fork PRs are read-only. You can only review and validate changes locally.");if(n){let h=this.#E?.folders.find(C=>C.enableGit);h&&(h.repoName=n.repoFullName,h.originalRepoUrl=n.repoUrl)}if(o||n){let h=performance.now(),C=await this.#tt({force:!!o});if(this.#G("git_push_ensure_auth",performance.now()-h),!C.success)throw C.error}let u=a?this.#p.find(h=>h.folderName===a):this.#p[0];if(!u)throw new Error(a?`Folder "${a}" not found in workspace`:"No git repos configured");if(A&&await this.#qt(u),r){let h=performance.now(),C=await this.#Vt({requestRefresh:!1,abortOnMergeConflict:c,ctx:u});if(this.#G("git_push_pull_latest",performance.now()-h,{success:String(C.success!==!1)}),!C.success)throw C.error??new Error(C.message)}if((await this.#V(u.path)).length>0)throw new Error(`Merge conflict detected in ${u.folderName}, please resolve before pushing`);let p=await this.#vt(s??!1,u),g=performance.now(),d=!0;try{await this.git(p,{cwd:u.path})}catch(h){throw d=!1,h}finally{this.#G("git_push_push",performance.now()-g,{success:String(d)})}await this.#S();let f=await this.#O();return await this.#de({lastCommit:$s(f)}),this.queueGitStatusReminder({trigger:"push-success",pushedToRemote:!0}),{success:!0}}catch(u){this.#e.Sentry?.captureException(u,{tags:{operation:"codegen-git",endpoint:"pushChanges",actor:i},extra:{pullFirst:r,forcePush:s,requireFastForward:A,abortOnMergeConflict:c,commitMode:this.getCommitMode(),updateRepo:n,refreshRemote:o}});let l=td(u);return{success:!1,message:l,error:u instanceof Error?u:new Error(l)}}}async#qt(e){let r=this.#ge(e);await this.git(["fetch","origin",r],{cwd:e.path});let i=this.getCommitMode()==="commits"?await this.getCurrentBranch(e.path):r;try{await this.git(["merge-base","--is-ancestor",`origin/${r}`,i],{cwd:e.path})}catch{throw new Error("[GIT_PUSH_ERROR] Cannot push: remote has diverged from local branch. Fast-forward push is not possible. Please pull the latest changes first or use a different push mode.")}}async#Vt(e){if(e?.abortOnMergeConflict){let n=e.ctx?[e.ctx]:this.#p;if(n.length===0)return{success:!1,message:"No git repos configured",error:new Error("No git repos configured")};try{for(let i of n){let o=this.#ge(i),s=performance.now();await this.git(["fetch","origin",o],{cwd:i.path}),this.#G("git_push_fetch",performance.now()-s,{folder:i.folderName,mode:"abort-on-conflict"});let a=performance.now(),A=!0;try{await this.git(["merge",`origin/${o}`],{cwd:i.path})}catch(c){if(A=!1,(await this.#V(i.path)).length>0){try{await this.git(["merge","--abort"],{cwd:i.path})}catch(l){this.#e.Sentry?.captureException(l,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote-abort-merge-conflict",folderName:i.folderName}})}throw new Error(`[GIT_PUSH_ERROR] Cannot push: merge conflict detected in ${i.folderName} when pulling latest changes. The merge has been aborted. Please resolve conflicts manually.`)}throw c}finally{this.#G("git_push_merge",performance.now()-a,{folder:i.folderName,mode:"abort-on-conflict",success:String(A)})}}return{success:!0}}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote"}});let o=td(i);return{success:!1,message:o,error:i instanceof Error?i:new Error(o)}}}return await this.#K(this.#St({branches:[],allowUnrelatedHistory:!1,canPush:!1,uncommittedChanges:"commit",fastForward:"auto",requestRefresh:e?.requestRefresh??!0,syncRemoteBranch:!0}),"syncChangesFromBranches",!0)}async abortMerge(e=!0){try{let r=await this.#J(async n=>{try{return await this.git(["merge","--abort"],{cwd:n.path}),!0}catch{return!1}});return this.#Ze=void 0,e&&r.results.some(n=>n.result===!0)&&(await this.#S(),await this.#fe(),this.requestRefresh()),r.success?{success:!0,message:"Merge aborted"}:{success:!1,message:`Failed to abort merge in: ${r.results.filter(i=>!i.success).map(i=>i.folderName).join(", ")}`,error:new Error("Merge abort failed in some repositories")}}catch(r){await this.#S();let n=td(r);return{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async syncChangesFromRemote(e){let r=[],n=e?.remoteBranches??"both";return n==="both"?r.push(this.getAiBranch(),this.getFeatureBranch()):n==="main"?r.push(this.getFeatureBranch()):n==="ai"&&r.push(this.getAiBranch()),await this.#K(this.#St({branches:r,allowUnrelatedHistory:e?.allowUnrelatedHistory??!0,canPush:e?.canPush??!1,uncommittedChanges:e?.uncommittedChanges??"commit",requestRefresh:e?.requestRefresh,fastForward:e?.fastForward??"auto"}),"syncChangesFromRemote",!0)}async#V(e){try{return(await this.git(["--no-pager","diff","--name-only","--diff-filter=U"],{cwd:e})).trim().split(`
1902
- `).filter(i=>i.length>0)}catch{return[]}}async#rt(){return(await this.#J(async r=>{let n=await this.#V(r.path);return this.#N()?n:n.map(i=>this.#e.join(r.path,i))})).results.flatMap(r=>r.success?r.result??[]:[])}async#zt(e){let r=n=>n.split(`
1901
+ `)}(r==="all"||r==="critical"&&!D)&&this.queueSystemReminder({text:nm(Q,2e3),tag:n});let _={devServerState:u,setupState:a,httpServerState:f,proxyServer:d,devCommand:c,setupCommand:p,hasMergeConflict:A.length>0,hasConfigurationIssue:D,logs:E,prompt:"Debug and fix the issue before continuing.",message:v},$=this.#t.length===0&&mlt.includes(s.state);return{actionButtonText:b,type:"build-error",level:x,canAutoApply:$,healthStatus:_,message:_.message,userMessage:{userPrompt:_.prompt,repair:!0,category:S,displayPrompt:_.message}}}}async#Kt(){let e=await this.#tt(!1,"critical"),r=!!(e&&!e.healthStatus.hasConfigurationIssue);return r&&this.#d?.addCheckpoint(),{hasHealthIssue:r}}async#Ht(){let e;if(this.#m)try{if(this.#r.debug("Initializing Fusion session for AI side-car branch workflow..."),e=await this.#e.getRepoInfo(this.primaryGitPath),!e.hasGit)if(this.#pt){this.#r.warn("No git repository detected. Initializing a new git repository...",{loggerOptions:{debug:!0}});try{await this.git(["init"]),await this.git(["add","."]),await this.git(["branch","-M","main"]),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Initial commit for Fusion workflow"]),this.#r.debug("Successfully initialized a new git repository")}catch(r){this.#r.error("Failed to initialize git repository:",r);return}}else{this.#r.error("Not in a git repository. Fusion requires a git repository.");return}return await mv({sys:this.#e,gitWorkingDirectory:this.primaryGitPath,strict:!0})}catch(r){O.error(`\u274C Error initializing Fusion session: ${r}`);let n=new Error("Initialize Git failed",{cause:r});throw this.#e.Sentry?.captureException(n,{level:"fatal",tags:{operation:"codegen-initialize-session"},extra:{repoInfo:e}}),n}}async#$t(e,r){try{await this.git(["checkout",e],{cwd:r})}catch{await this.git(["checkout","-b",e],{cwd:r})}}async#Jt(e){if(!this.#m)return;if(!this.#H){let o=Ule(this.getFeatureBranch(),e.sessionId);this.#H=o}let r=this.getAiBranch();await this.#J(async o=>{await this.getCurrentBranch(o.path)!==r&&await this.#$t(r,o.path);try{await this.git(["branch","--set-upstream-to",`refs/remotes/origin/${this.#ge(o)}`],{cwd:o.path})}catch{}});let n=sc(e.turns),i=n?.afterCommit??n?.lastCommit;if(i)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=yl(i,o.folderName,s);if(a){let A=await this.getCurrentCommitHash("HEAD",o.path);A&&A!==a&&this.#e.Sentry?.captureException(new Error(`Init: After commit mismatch for ${o.folderName}`),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,targetCommit:a,currentCommitHash:A,lastTurn:n}})}}if(e.beforeCommit)for(let o of this.gitRepoContexts){let s=this.gitRepoContexts[0]?.folderName,a=yl(e.beforeCommit,o.folderName,s);if(a)try{await this.git(["rev-parse","--quiet","--verify",a],{cwd:o.path})}catch(A){this.#e.Sentry?.captureException(new Error(`Init: Before commit not found for ${o.folderName}`,{cause:A}),{tags:{operation:"codegen-initialize-session",folderName:o.folderName},extra:{sessionId:e.sessionId,beforeCommit:a,turnStates:e.turns.length,lastCompletionId:sc(e.turns)?.completionId}})}}}async#jt(e,r,n){let i;try{i=(await this.git(["remote","get-url","origin"],r)).trim()}catch{}let{url:o,token:s,provider:a}=e;try{new URL(o)}catch{throw this.#e.Sentry?.captureException(new Error("Provided remote url is invalid"),{tags:{operation:"codegen-git"},extra:{url:o,currentOriginUrl:i}}),new Error("Provided remote url is invalid")}if(i!==o&&(this.#ye={},i?await this.git(["remote","set-url","origin",o],r):await this.git(["remote","add","origin",o],r),(a==="github"||a==="selfHostedGithub")&&s)){(!n||n===this.gitEnabledFolders[0]?.name)&&(process.env.GH_TOKEN=s);let c=this.gitEnabledFolders.length>1;n&&c&&(process.env[yF(n)]=s)}}async pushRepoV2(e){return await this.#K(this.#xe({pullFirst:!1,updateRepo:e,refreshRemote:!0}),"pushRepoV2",!0)}async ensureGitAuth(){return this.#m?this.#rt():{success:!0,message:"Git is not enabled, skipping auth"}}async#rt({force:e}={}){if(!this.#m)return{success:!0,message:"Git is not enabled"};let n=Date.now()-this.#Ct,i=300*1e3;if(!e&&n<=i)return{success:!0,message:"Git auth still valid (within 5min)"};if(this.#ce){if(!e)return this.#ce;await this.#ce.catch(()=>{})}return this.#ce=this.#Yt().then(o=>(o.success&&(this.#Ct=Date.now()),o)).finally(()=>{this.#ce=null}),this.#ce}async#Yt(){let e;try{let r=this.gitEnabledFolders;if(r.length===0)throw new Error("No git-enabled repos found");let n=r.filter(o=>!o.initializationCommand&&!o.repoUrl?.startsWith("ssh://"));if(n.length===0)return{success:!0,message:"Git remote URLs update not needed"};if(!this.#h)throw new Error("Project ID is required to update git URLs");let i=await Cm(this.#a,this.#h,this.#s);if(!i.success)throw i.error;e=i.gitConfigs;for(let o of n){if(!o.repoName)continue;let s=e?.[o.repoName];if(s?.url){let a=this.#e.resolve(this.#I,o.path);await this.#jt(s,a,o.name)}}return{success:!0,message:"Git remote URLs updated"}}catch(r){let n=`Failed to update git remote URLs: ${td(r)}`;return this.#r.error(n,{loggerOptions:{debug:!0}}),this.#g.emit("step",{type:"error",message:n,code:"git-update-error"}),this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-git",endpoint:"updateGitUrls"},extra:{projectId:this.#h,workspaceFolders:this.#E?.folders,gitConfigs:e}}),{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async zipFolder(e){if(typeof e!="string")throw new TypeError(`zipFolder: 'folderName' must be a string, received ${typeof e}: ${oa(e)}`);let{resolvedPath:r}=this.resolveWorkspacePath(e,!1),n=Date.now(),i=Math.random().toString(36).substring(2,8),o=`zip-${n}-${i}.zip`,s="/tmp",a=this.#e.join(s,o);return Zl.default.mkdirSync(s,{recursive:!0}),await Ha("zip",["-r",a,".","-x","**/node_modules/**"],{cwd:r,sys:this.#e}),a}async archiveProject(){if(!this.#m)throw new Error("Can not archive project in non git mode");try{let e=Date.now(),r=Math.random().toString(36).substring(2,8),n=`project-${e}-${r}.zip`,i="/tmp",o=this.#e.join(i,n);return Zl.default.mkdirSync(i,{recursive:!0}),await this.git(["archive","--format=zip","-o",o,"HEAD"]),o}catch(e){throw new Error("Failed to archive project",{cause:e})}}isIdle(){let e=this.getSessionContext(),r=["generating","replay"];return!this.#Ae&&!r.includes(e.state)&&this.#le.length===0}async needsBackup(){if(!this.#m||!this.#h||!this.#y)return!1;for(let e of this.#p){let r=e.originalRepoUrl??e.repoUrl;if(!r)continue;let n=await this.getCurrentCommitHash("HEAD",e.path);if(!n)continue;let i=PE({version:"v2",originalRepoUrl:r,commitHash:n});if(this.#ye[e.folderName]!==i)return!0}return!1}async uploadBackup(e=!1){try{await this.waitUntilBlockingPendingPromises(),await this.#ne(!1);let r=this.#h,n=this.#y;if(!this.#m)throw new Error("Cannot upload backup in non-git mode");if(!r)throw new Error("Project ID is required for backup upload");if(!n)throw new Error("Branch ID is required for backup upload");let i=this.getAiBranch(),o=this.getFeatureBranch(),s=await this.#O();await vv(this.#e,this.#a,{commits:s,projectId:r,branchName:n},this.#s);let a=performance.now(),A=[];for(let l of this.#p){let p=l.originalRepoUrl??l.repoUrl;if(!p)continue;let g=await this.#Ft(()=>wv({sys:this.#e,credentials:this.#a,projectId:r,branchName:n,repoPath:l.path,aiBranch:i,featureBranch:l.branchName||o,workspace:this.#E,debug:this.#s,isConnectedToProvider:!0,forcedFullBackup:e,canAbortMerge:this.#Ne,folderName:l.folderName,repoUrl:p}));if(!g.success)return g;A.push({result:g,folderName:l.folderName})}if(A.length===0)return{success:!1,error:new Error("No repos to backup")};let c=A.map(l=>l.result.backupEntry),u=performance.now()-a;await bv(this.#a,c,u,this.#s);for(let{result:l,folderName:p}of A)l.backupRef&&(this.#ye[p]=l.backupRef);return A[0].result}catch(r){if(this.#r.error("Failed to upload backup",r),this.#ye={},this.#e.Sentry?.captureException(r,{tags:{operation:"codegen-backup",backupError:""}}),r instanceof Error&&r.message.includes("Commit(s) not found on remote"))throw r instanceof Error?r:new Error(String(r));return{success:!1,error:r instanceof Error?r:new Error(String(r))}}}getCommitMode(){return this.#u?.commitMode??"prs"}#ge(e){return this.getCommitMode()==="commits"?`${e?.branchName||this.getFeatureBranch()}`:`${this.getAiBranch()}`}async#vt(e,r){let n=this.getCommitMode(),i=this.#ge(r),o=await this.getCurrentBranch(r?.path);return n==="commits"?["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",`${o}:${i}`]:["push","--no-verify","--set-upstream",...e?["-f"]:[],"origin",i]}async pushChanges(e){let r=performance.now(),n=await this.#K(this.#xe(e),"pushChanges",!0);return this.#G("git_push_changes_total",performance.now()-r,{success:String(n.success!==!1)}),n}async#xe(e){let{pullFirst:r,updateRepo:n,actor:i,refreshRemote:o,forcePush:s,folderName:a,requireFastForward:A,abortOnMergeConflict:c}=Tye(e);try{if(!this.#m)throw new Error("Can not push changes in non-git mode");if(this.#u?.isFork)throw new Error("Cannot push changes to fork PRs. Fork PRs are read-only. You can only review and validate changes locally.");if(n){let h=this.#E?.folders.find(C=>C.enableGit);h&&(h.repoName=n.repoFullName,h.originalRepoUrl=n.repoUrl)}if(o||n){let h=performance.now(),C=await this.#rt({force:!!o});if(this.#G("git_push_ensure_auth",performance.now()-h),!C.success)throw C.error}let u=a?this.#p.find(h=>h.folderName===a):this.#p[0];if(!u)throw new Error(a?`Folder "${a}" not found in workspace`:"No git repos configured");if(A&&await this.#qt(u),r){let h=performance.now(),C=await this.#Vt({requestRefresh:!1,abortOnMergeConflict:c,ctx:u});if(this.#G("git_push_pull_latest",performance.now()-h,{success:String(C.success!==!1)}),!C.success)throw C.error??new Error(C.message)}if((await this.#V(u.path)).length>0)throw new Error(`Merge conflict detected in ${u.folderName}, please resolve before pushing`);let p=await this.#vt(s??!1,u),g=performance.now(),d=!0;try{await this.git(p,{cwd:u.path})}catch(h){throw d=!1,h}finally{this.#G("git_push_push",performance.now()-g,{success:String(d)})}await this.#S();let f=await this.#O();return await this.#de({lastCommit:$s(f)}),this.queueGitStatusReminder({trigger:"push-success",pushedToRemote:!0}),{success:!0}}catch(u){this.#e.Sentry?.captureException(u,{tags:{operation:"codegen-git",endpoint:"pushChanges",actor:i},extra:{pullFirst:r,forcePush:s,requireFastForward:A,abortOnMergeConflict:c,commitMode:this.getCommitMode(),updateRepo:n,refreshRemote:o}});let l=td(u);return{success:!1,message:l,error:u instanceof Error?u:new Error(l)}}}async#qt(e){let r=this.#ge(e);await this.git(["fetch","origin",r],{cwd:e.path});let i=this.getCommitMode()==="commits"?await this.getCurrentBranch(e.path):r;try{await this.git(["merge-base","--is-ancestor",`origin/${r}`,i],{cwd:e.path})}catch{throw new Error("[GIT_PUSH_ERROR] Cannot push: remote has diverged from local branch. Fast-forward push is not possible. Please pull the latest changes first or use a different push mode.")}}async#Vt(e){if(e?.abortOnMergeConflict){let n=e.ctx?[e.ctx]:this.#p;if(n.length===0)return{success:!1,message:"No git repos configured",error:new Error("No git repos configured")};try{for(let i of n){let o=this.#ge(i),s=performance.now();await this.git(["fetch","origin",o],{cwd:i.path}),this.#G("git_push_fetch",performance.now()-s,{folder:i.folderName,mode:"abort-on-conflict"});let a=performance.now(),A=!0;try{await this.git(["merge",`origin/${o}`],{cwd:i.path})}catch(c){if(A=!1,(await this.#V(i.path)).length>0){try{await this.git(["merge","--abort"],{cwd:i.path})}catch(l){this.#e.Sentry?.captureException(l,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote-abort-merge-conflict",folderName:i.folderName}})}throw new Error(`[GIT_PUSH_ERROR] Cannot push: merge conflict detected in ${i.folderName} when pulling latest changes. The merge has been aborted. Please resolve conflicts manually.`)}throw c}finally{this.#G("git_push_merge",performance.now()-a,{folder:i.folderName,mode:"abort-on-conflict",success:String(A)})}}return{success:!0}}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"codegen-git",endpoint:"pullLatestFromRemote"}});let o=td(i);return{success:!1,message:o,error:i instanceof Error?i:new Error(o)}}}return await this.#K(this.#St({branches:[],allowUnrelatedHistory:!1,canPush:!1,uncommittedChanges:"commit",fastForward:"auto",requestRefresh:e?.requestRefresh??!0,syncRemoteBranch:!0}),"syncChangesFromBranches",!0)}async abortMerge(e=!0){try{let r=await this.#J(async n=>{try{return await this.git(["merge","--abort"],{cwd:n.path}),!0}catch{return!1}});return this.#Xe=void 0,e&&r.results.some(n=>n.result===!0)&&(await this.#S(),await this.#fe(),this.requestRefresh()),r.success?{success:!0,message:"Merge aborted"}:{success:!1,message:`Failed to abort merge in: ${r.results.filter(i=>!i.success).map(i=>i.folderName).join(", ")}`,error:new Error("Merge abort failed in some repositories")}}catch(r){await this.#S();let n=td(r);return{success:!1,message:n,error:r instanceof Error?r:new Error(n)}}}async syncChangesFromRemote(e){let r=[],n=e?.remoteBranches??"both";return n==="both"?r.push(this.getAiBranch(),this.getFeatureBranch()):n==="main"?r.push(this.getFeatureBranch()):n==="ai"&&r.push(this.getAiBranch()),await this.#K(this.#St({branches:r,allowUnrelatedHistory:e?.allowUnrelatedHistory??!0,canPush:e?.canPush??!1,uncommittedChanges:e?.uncommittedChanges??"commit",requestRefresh:e?.requestRefresh,fastForward:e?.fastForward??"auto"}),"syncChangesFromRemote",!0)}async#V(e){try{return(await this.git(["--no-pager","diff","--name-only","--diff-filter=U"],{cwd:e})).trim().split(`
1902
+ `).filter(i=>i.length>0)}catch{return[]}}async#nt(){return(await this.#J(async r=>{let n=await this.#V(r.path);return this.#N()?n:n.map(i=>this.#e.join(r.path,i))})).results.flatMap(r=>r.success?r.result??[]:[])}async#zt(e){let r=n=>n.split(`
1903
1903
  `).map(i=>i.trim().slice(0,400)).filter(i=>i.length>0).slice(0,20);try{let n=this.#L||"main",i=await this.git(["log",n,"-n","20","--format=%s"],{cwd:e});return r(i)}catch{try{let n=await this.git(["log","-n","20","--format=%s"],{cwd:e});return r(n)}catch{return[]}}}async#St({branches:e,allowUnrelatedHistory:r,canPush:n,fastForward:i,uncommittedChanges:o,requestRefresh:s=!1,syncRemoteBranch:a=!1}){try{if(!this.#m)throw new Error("Can not pull changes in non-git mode");if(!a&&!e.length)throw new Error("At least one branch name is required");let A=this.getAiBranch(),c=this.getFeatureBranch(),u=[],l=performance.now();await this.#ne(!1),this.#G("git_sync_commit_accumulated",performance.now()-l);let g=(await this.#J(async d=>{let f=d.path,h;a?h=[this.#ge(d)]:h=e.map(Q=>Q===c?d.branchName:Q);let C=await this.getCurrentBranch(f);if(C!==A)throw new Error(`Repo ${d.folderName} not on AI branch: ${C} != ${A}`);let I=await this.#V(f);if(I.length>0)throw new Error(`Merge conflict in ${d.folderName}:
1904
1904
  ${I.join(`
1905
- `)}`);let B=!1;if(!await this.#At(f))switch(o){case"stash":await this.git(["stash","--include-untracked"],{cwd:f}),B=!0;break;case"commit":await this.git(["add","-A","."],{cwd:f}),await this.git(["commit","--no-verify","--no-gpg-sign","-m","Commit unstaged changes"],{cwd:f});break;default:throw new Error(`Uncommitted changes in ${d.folderName}`)}let y=performance.now();await this.git(["fetch","origin","--prune"],{cwd:f}),this.#G("git_sync_fetch",performance.now()-y,{folder:d.folderName});let D=await this.git(["for-each-ref","refs/remotes/origin"],{cwd:f}),v=h.filter(Q=>D.includes(`refs/remotes/origin/${Q}`));for(let Q of v){Q!==A&&await this.git(["update-ref",`refs/heads/${Q}`,`refs/remotes/origin/${Q}`],{cwd:f});try{let x=performance.now(),b=!0,S;try{S=await this.git(["merge",...i==="never"?["--no-ff"]:[],...i==="required"?["--ff-only"]:[],...i==="auto"?["--ff"]:[],...r?["--allow-unrelated-histories"]:[],`refs/remotes/origin/${Q}`],{cwd:f})}catch(M){throw b=!1,M}finally{this.#G("git_sync_merge",performance.now()-x,{folder:d.folderName,branch:Q,success:String(b)})}let _=Q===d.branchName,$=S?.includes("Already up to date"),U=this.#N()?"":`[${d.folderName}] `;$||u.push(`${U}Successfully merged branch "${Q}" into ${A}${_?" (this was the main/feature branch \u2014 its changes are now in your working branch)":" (AI branch synced with remote)"}.`)}catch(x){let b=Q===d.branchName,S=this.#N()?"":`[${d.folderName}] `;throw this.#Ze={ourBranch:A,theirBranch:Q,theirIsMain:b},x instanceof aa&&u.push(`${S}The user tries to sync git changes, but something failed:
1905
+ `)}`);let B=!1;if(!await this.#ct(f))switch(o){case"stash":await this.git(["stash","--include-untracked"],{cwd:f}),B=!0;break;case"commit":await this.git(["add","-A","."],{cwd:f}),await this.git(["commit","--no-verify","--no-gpg-sign","-m","Commit unstaged changes"],{cwd:f});break;default:throw new Error(`Uncommitted changes in ${d.folderName}`)}let y=performance.now();await this.git(["fetch","origin","--prune"],{cwd:f}),this.#G("git_sync_fetch",performance.now()-y,{folder:d.folderName});let D=await this.git(["for-each-ref","refs/remotes/origin"],{cwd:f}),v=h.filter(Q=>D.includes(`refs/remotes/origin/${Q}`));for(let Q of v){Q!==A&&await this.git(["update-ref",`refs/heads/${Q}`,`refs/remotes/origin/${Q}`],{cwd:f});try{let x=performance.now(),b=!0,S;try{S=await this.git(["merge",...i==="never"?["--no-ff"]:[],...i==="required"?["--ff-only"]:[],...i==="auto"?["--ff"]:[],...r?["--allow-unrelated-histories"]:[],`refs/remotes/origin/${Q}`],{cwd:f})}catch(M){throw b=!1,M}finally{this.#G("git_sync_merge",performance.now()-x,{folder:d.folderName,branch:Q,success:String(b)})}let _=Q===d.branchName,$=S?.includes("Already up to date"),U=this.#N()?"":`[${d.folderName}] `;$||u.push(`${U}Successfully merged branch "${Q}" into ${A}${_?" (this was the main/feature branch \u2014 its changes are now in your working branch)":" (AI branch synced with remote)"}.`)}catch(x){let b=Q===d.branchName,S=this.#N()?"":`[${d.folderName}] `;throw this.#Xe={ourBranch:A,theirBranch:Q,theirIsMain:b},x instanceof aa&&u.push(`${S}The user tries to sync git changes, but something failed:
1906
1906
  - our branch (ours): ${A} -- this is the AI's working branch
1907
1907
  - their branch (theirs): refs/remotes/origin/${Q} ${b?" -- this is main/feature branch (work here needs to be preserved)":"-- same branch pushed by remote"}
1908
1908
  `),x}}if(n){let Q=await this.#vt(!0,d);await this.git(Q,{cwd:d.path})}if(B)try{await this.git(["stash","pop"],{cwd:f})}catch(Q){this.#e.Sentry?.captureException(Q,{tags:{operation:"codegen-git",endpoint:"syncChanges-stash-pop"}})}})).results.filter(d=>!d.success||d.error);if(g.length>0){let d=g.map(f=>f.error?.message||`${f.folderName} failed`).join("; ");throw new Error(`Sync failed: ${d}`)}if(n){let d=await this.#xe(!1);if(!d.success)throw d.error}else{await this.#S();let d=await this.#O();this.#R={...this.#R,...d},await this.#de({lastCommit:$s(d)})}return u.length>0&&this.queueSystemReminder({text:u.join(`
1909
1909
 
1910
- `)}),s&&this.requestRefresh(),{success:!0,message:`Successfully merged ${e.join(", ")} in all repos`}}catch(A){this.#r.error(`Error syncing changes from branches: ${A}`,{loggerOptions:{debug:!0}}),await this.#S();let c=await this.#O();this.#R={...this.#R,...c},this.#e.Sentry?.captureException(A,{tags:{operation:"codegen-git",endpoint:"syncChangesFromBranches"},extra:{branches:e,allowUnrelatedHistory:r}});let u=td(A);return{success:!1,message:u,error:A instanceof Error?A:new Error(u)}}}async getCurrentCommitHash(e="HEAD",r){if(this.#m)try{let n=["rev-parse",e];return(await this.git(n,{sys:this.#e,cwd:r})).trim()}catch{return}}async#O(e="HEAD"){let r={};for(let n of this.gitRepoContexts)try{let i=await this.getCurrentCommitHash(e,n.path);i&&(r[n.folderName]=i)}catch(i){this.#r.warn(`Failed to get commit for ${n.folderName}:`,i)}return r}async getCurrentBranch(e){return(await this.git(["branch","--show-current"],{cwd:e})).trim()}getFeatureBranch(){if(!this.#L)throw new Error("Feature branch is missing");return this.#L}getAiBranch(){if(!this.#H)throw new Error("AI branch is missing");return this.#H}async git(e,r){if(!this.#m)throw new Error("Can not execute git command in non-git mode.");let n=e[0];(n==="push"||n==="fetch"||n==="pull")&&await this.#tt();let o=typeof r=="object"?{sys:this.#e,...r}:r,s=await this.#Ft(()=>this.#er(e,o));return this.#Zt(n)&&(this.#be.clear(),this.#we.clear()),s}static#Wt=new Set(["commit","merge","rebase","checkout","switch","pull","fetch","reset","cherry-pick","revert","am","stash","push"]);#Zt(e){return!!e&&t.#Wt.has(e)}async#J(e){if(this.#p.length===0)return{success:!0,partialSuccess:!1,results:[]};let n=(await Promise.allSettled(this.#p.map(s=>e(s)))).map((s,a)=>({folderName:this.#p[a].folderName,success:s.status==="fulfilled",result:s.status==="fulfilled"?s.value:void 0,error:s.status==="rejected"?s.reason:void 0,message:s.status==="rejected"?s.reason?.message:void 0})),i=n.filter(s=>s.success),o=n.filter(s=>!s.success);return{success:o.length===0,partialSuccess:i.length>0&&o.length>0,results:n}}#xt(e){let r=gs(e),n=this.#p.find(a=>{let A=gs(a.folderName);return r.startsWith(A+"/")||r===A});if(n)return n;let i=e.startsWith("/")||e.includes(":")?e:this.#e.resolve(this.#I,e),o=gs(i);return this.#p.find(a=>{let A=gs(a.path);return o.startsWith(A+"/")||o===A})}#Xt(e){let r=new Map;for(let n of e){let i=this.#xt(n);if(i){let o=r.get(i.folderName)||[];o.push(n),r.set(i.folderName,o)}}return r}#Ft(e){let r=this.#lt.then(()=>e());return this.#lt=r.catch(()=>{}),r}async#er(e,r){if(!this.#m)throw new Error(`Can not execute git command in non-git mode: git ${e.join(" ")}`);let n=`git ${e.join(" ")}`;this.#Ae&&this.#e.Sentry?.captureException(new Error(`currentGitCommand is not finished yet. Current command: ${this.#Ae}, New command Received: ${n}`),{tags:{operation:"codegen-git"},extra:{oldCommand:this.#Ae,newCommand:n}});try{this.#Ae=n;let i=typeof r=="object"?r:void 0,o=typeof r=="string"?r:i?.cwd??this.primaryGitPath;return await Ha("git",e,{...i,cwd:o,sys:this.#e,timeout:60*1e3})}finally{this.#Ae=void 0}}setDebug(e){this.#s=e,e&&!process.env.DEBUG?(process.env.DEBUG="1",this.#f=!0):!e&&this.#f&&(delete process.env.DEBUG,this.#f=!1)}async createTerminal(e){let r=this.#d,n=e?.terminalId||`pty_${Date.now()}_${(0,CF.randomUUID)()}`,i=this.#nt().find(B=>B.terminalId===n),o=new Set,s=new Set;if(i&&e?.terminalId){if(!e?.force)return i;let B=this.#w.get(e.terminalId);if(!B)return i;B.onDataListeners.forEach(E=>{o.add(E)}),B.onExitListeners.forEach(E=>{s.add(E)}),this.disposeTerminal({terminalId:n,emitTerminals:!1})}let a=e?.shell||(process.platform==="win32"?"powershell.exe":process.env.SHELL||"/bin/bash"),A=e?.cols??120,c=e?.rows??30,u={...process.env,...r?.envVars,...e?.env};e?.inheritCredentials&&(u.BUILDER_USER_ID=e.createdBy??this.#a.userId,u.BUILDER_PUBLIC_KEY=this.#a.builderPublicKey,u.BUILDER_PRIVATE_KEY=this.#a.builderPrivateKey);let l=[],p=B=>{for(let E of o)E(B)},g=({exitCode:B,error:E})=>{let y=this.#w.get(n);y&&(y.state=E?"error":"exited",y.exitCode=B);for(let D of s)D(B);this.#w.delete(n),l.forEach(D=>D())},d=e?.cwd||this.#v,f,h;if(e?.readonly){f="starting";let B=!r?.hasSetupEnvVars,E=HA(a,e?.initialCommand??"true",{cwd:d,env:u,stdio:["ignore","pipe","pipe"]},B);E.on("spawn",()=>{let y=this.#w.get(n);y&&(y.state="running")}),E.stdout.on("data",y=>{p(y.toString())}),E.stderr.on("data",y=>{p(y.toString())}),E.on("error",y=>{g({exitCode:1,error:y})}),E.on("exit",y=>{g({exitCode:y??0})}),l.push(()=>{try{E.removeAllListeners()}catch{}E.kill()}),h=E}else{f="running";let B=L2(this.#e);if(!B)throw new Error("Could not import node-pty");let E=a.includes("bash")||a.includes("zsh"),y=a.includes("zsh")?"%~ $ ":"\\w $ ",D=B.spawn(a,[],{name:"xterm-color",cwd:d,cols:A,rows:c,env:E?{...u,PS1:y}:u}),v=D.onData(p);l.push(()=>{try{v?.dispose?.()}catch{}});let Q=D.onExit(g);l.push(()=>{try{Q?.dispose?.()}catch{}});let x=e?.initialCommand;x&&(x.endsWith(`
1910
+ `)}),s&&this.requestRefresh(),{success:!0,message:`Successfully merged ${e.join(", ")} in all repos`}}catch(A){this.#r.error(`Error syncing changes from branches: ${A}`,{loggerOptions:{debug:!0}}),await this.#S();let c=await this.#O();this.#R={...this.#R,...c},this.#e.Sentry?.captureException(A,{tags:{operation:"codegen-git",endpoint:"syncChangesFromBranches"},extra:{branches:e,allowUnrelatedHistory:r}});let u=td(A);return{success:!1,message:u,error:A instanceof Error?A:new Error(u)}}}async getCurrentCommitHash(e="HEAD",r){if(this.#m)try{let n=["rev-parse",e];return(await this.git(n,{sys:this.#e,cwd:r})).trim()}catch{return}}async#O(e="HEAD"){let r={};for(let n of this.gitRepoContexts)try{let i=await this.getCurrentCommitHash(e,n.path);i&&(r[n.folderName]=i)}catch(i){this.#r.warn(`Failed to get commit for ${n.folderName}:`,i)}return r}async getCurrentBranch(e){return(await this.git(["branch","--show-current"],{cwd:e})).trim()}getFeatureBranch(){if(!this.#L)throw new Error("Feature branch is missing");return this.#L}getAiBranch(){if(!this.#H)throw new Error("AI branch is missing");return this.#H}async git(e,r){if(!this.#m)throw new Error("Can not execute git command in non-git mode.");let n=e[0];(n==="push"||n==="fetch"||n==="pull")&&await this.#rt();let o=typeof r=="object"?{sys:this.#e,...r}:r,s=await this.#Ft(()=>this.#er(e,o));return this.#Zt(n)&&(this.#be.clear(),this.#we.clear()),s}static#Wt=new Set(["commit","merge","rebase","checkout","switch","pull","fetch","reset","cherry-pick","revert","am","stash","push"]);#Zt(e){return!!e&&t.#Wt.has(e)}async#J(e){if(this.#p.length===0)return{success:!0,partialSuccess:!1,results:[]};let n=(await Promise.allSettled(this.#p.map(s=>e(s)))).map((s,a)=>({folderName:this.#p[a].folderName,success:s.status==="fulfilled",result:s.status==="fulfilled"?s.value:void 0,error:s.status==="rejected"?s.reason:void 0,message:s.status==="rejected"?s.reason?.message:void 0})),i=n.filter(s=>s.success),o=n.filter(s=>!s.success);return{success:o.length===0,partialSuccess:i.length>0&&o.length>0,results:n}}#xt(e){let r=gs(e),n=this.#p.find(a=>{let A=gs(a.folderName);return r.startsWith(A+"/")||r===A});if(n)return n;let i=e.startsWith("/")||e.includes(":")?e:this.#e.resolve(this.#I,e),o=gs(i);return this.#p.find(a=>{let A=gs(a.path);return o.startsWith(A+"/")||o===A})}#Xt(e){let r=new Map;for(let n of e){let i=this.#xt(n);if(i){let o=r.get(i.folderName)||[];o.push(n),r.set(i.folderName,o)}}return r}#Ft(e){let r=this.#gt.then(()=>e());return this.#gt=r.catch(()=>{}),r}async#er(e,r){if(!this.#m)throw new Error(`Can not execute git command in non-git mode: git ${e.join(" ")}`);let n=`git ${e.join(" ")}`;this.#Ae&&this.#e.Sentry?.captureException(new Error(`currentGitCommand is not finished yet. Current command: ${this.#Ae}, New command Received: ${n}`),{tags:{operation:"codegen-git"},extra:{oldCommand:this.#Ae,newCommand:n}});try{this.#Ae=n;let i=typeof r=="object"?r:void 0,o=typeof r=="string"?r:i?.cwd??this.primaryGitPath;return await Ha("git",e,{...i,cwd:o,sys:this.#e,timeout:60*1e3})}finally{this.#Ae=void 0}}setDebug(e){this.#s=e,e&&!process.env.DEBUG?(process.env.DEBUG="1",this.#f=!0):!e&&this.#f&&(delete process.env.DEBUG,this.#f=!1)}async createTerminal(e){let r=this.#d,n=e?.terminalId||`pty_${Date.now()}_${(0,CF.randomUUID)()}`,i=this.#it().find(B=>B.terminalId===n),o=new Set,s=new Set;if(i&&e?.terminalId){if(!e?.force)return i;let B=this.#w.get(e.terminalId);if(!B)return i;B.onDataListeners.forEach(E=>{o.add(E)}),B.onExitListeners.forEach(E=>{s.add(E)}),this.disposeTerminal({terminalId:n,emitTerminals:!1})}let a=e?.shell||(process.platform==="win32"?"powershell.exe":process.env.SHELL||"/bin/bash"),A=e?.cols??120,c=e?.rows??30,u={...process.env,...r?.envVars,...e?.env};e?.inheritCredentials&&(u.BUILDER_USER_ID=e.createdBy??this.#a.userId,u.BUILDER_PUBLIC_KEY=this.#a.builderPublicKey,u.BUILDER_PRIVATE_KEY=this.#a.builderPrivateKey);let l=[],p=B=>{for(let E of o)E(B)},g=({exitCode:B,error:E})=>{let y=this.#w.get(n);y&&(y.state=E?"error":"exited",y.exitCode=B);for(let D of s)D(B);this.#w.delete(n),l.forEach(D=>D())},d=e?.cwd||this.#v,f,h;if(e?.readonly){f="starting";let B=!r?.hasSetupEnvVars,E=HA(a,e?.initialCommand??"true",{cwd:d,env:u,stdio:["ignore","pipe","pipe"]},B);E.on("spawn",()=>{let y=this.#w.get(n);y&&(y.state="running")}),E.stdout.on("data",y=>{p(y.toString())}),E.stderr.on("data",y=>{p(y.toString())}),E.on("error",y=>{g({exitCode:1,error:y})}),E.on("exit",y=>{g({exitCode:y??0})}),l.push(()=>{try{E.removeAllListeners()}catch{}E.kill()}),h=E}else{f="running";let B=L2(this.#e);if(!B)throw new Error("Could not import node-pty");let E=a.includes("bash")||a.includes("zsh"),y=a.includes("zsh")?"%~ $ ":"\\w $ ",D=B.spawn(a,[],{name:"xterm-color",cwd:d,cols:A,rows:c,env:E?{...u,PS1:y}:u}),v=D.onData(p);l.push(()=>{try{v?.dispose?.()}catch{}});let Q=D.onExit(g);l.push(()=>{try{Q?.dispose?.()}catch{}});let x=e?.initialCommand;x&&(x.endsWith(`
1911
1911
  `)||(x+=`
1912
- `),D.write(x)),h=D}let C=Date.now(),I={terminalId:n,title:e?.title||`Terminal ${this.#w.size+1}`,cwd:d,createdAt:C,lastWrittenAt:C,createdBy:e?.createdBy||"unknown",readonly:e?.readonly??!1,initialCommand:e?.initialCommand,builtIn:!1,state:f,stale:!1,exitCode:void 0,command:void 0};return this.#w.set(n,{...I,pty:h,onDataListeners:o,onExitListeners:s,disposeFns:l,env:e?.env,shell:a,inheritCredentials:e?.inheritCredentials}),(e?.emitTerminals??!0)&&this.#pe(),I}#nt(){let e=this.getSessionContext(),r=Array.from(this.#w.values()).map(o=>({terminalId:o.terminalId,title:o.title,cwd:o.cwd,createdAt:o.createdAt,lastWrittenAt:o.lastWrittenAt,createdBy:o.createdBy,readonly:o.readonly,builtIn:o.builtIn,exitCode:o.exitCode,state:o.state,stale:o.stale,command:o.command})),n=[];this.#D?.includes("Bash")&&n.push({terminalId:"bash-tools",title:"Bash",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:Date.now(),createdBy:"fusion",readonly:!0,builtIn:!0,exitCode:void 0,state:"running",command:void 0});let i=this.#d;if(i){let o=Date.now();if(i.devState!=="unset"&&n.push({terminalId:"dev-command",title:"Dev Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!i.devCommandProcess?.write,builtIn:!0,state:i.devState==="running"?"running":"exited",exitCode:void 0,command:i.devCommand}),i.setupCommand&&n.push({terminalId:"setup-command",title:"Setup Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:i.setupState==="installing"?"running":"exited",exitCode:void 0,command:i.setupCommand}),i.validateCommandState!=="unset"){let s;switch(i.validateCommandState){case"running":s="running";break;case"success":s="exited";break;case"failure":s="error";break;case"stopped":s="exited";break}n.unshift({terminalId:"validate-command",title:"Validate Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:s,exitCode:void 0,command:i.validateCommand})}}return n.push(...r),n}#pe(){this.#g.emit("step",{type:"terminals",terminals:this.#nt()})}updateTerminal({terminalId:e,cols:r,rows:n,title:i}){if(e==="dev-command"){if(r||n){let s=this.#d;if(s?.devCommandProcess?.resize)return s.devCommandProcess.resize(r,n),!0}return!1}let o=this.#w.get(e);return o?("resize"in o.pty&&(r||n)&&o.pty.resize(r??o.pty.cols,n??o.pty.rows),i&&(o.title=i,this.#pe()),!0):!1}writeTerminal({terminalId:e,data:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.write?(i.devCommandProcess.write(r),!0):!1}let n=this.#w.get(e);return!n||n.readonly?!1:("write"in n.pty&&n.pty.write(r),n.lastWrittenAt=Date.now(),!0)}signalTerminal({terminalId:e,signal:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.kill?(i.devCommandProcess.kill(r),!0):!1}let n=this.#w.get(e);if(!n||n.readonly)return!1;try{"write"in n.pty?process.platform==="win32"?n.pty.kill():(r==="SIGINT"&&n.pty.write(""),n.pty.kill(r)):n.pty.kill(r)}catch{}return!0}disposeTerminal({terminalId:e,emitTerminals:r=!0}){let n=this.#w.get(e);if(!n)return!1;try{n.pty.kill()}catch{}return n.disposeFns.forEach(i=>{try{i()}catch{}}),n.onDataListeners.clear(),n.onExitListeners.clear(),n.disposeFns=[],this.#w.delete(e),r&&this.#pe(),!0}async restartTerminal({terminalId:e}){if(e==="dev-command"){let i=this.#d;if(i)try{return await i.restart(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="setup-command"){let i=this.#d;if(i)try{return await i.runSetupCommand(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="validate-command"){if(this.#d)try{return await this.#Mt(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="bash-tools")return!1;let r=this.#w.get(e);return r?(await this.createTerminal({terminalId:e,title:r.title,cwd:r.cwd,env:r.env,shell:r.shell,cols:"cols"in r.pty?r.pty.cols:void 0,rows:"rows"in r.pty?r.pty.rows:void 0,createdBy:r.createdBy,emitTerminals:!1,initialCommand:r.initialCommand,readonly:r.readonly,inheritCredentials:r.inheritCredentials,force:!0}),this.#w.get(e)?(this.#pe(),!0):!1):!1}subscribeTerminal({terminalId:e,onData:r,onExit:n}){if(e==="dev-command"){let i=this.#d;if(i){let o=i.getDevWrite();return o&&r(o),i.emitter.on("stdout",r),i.emitter.on("stderr",r),()=>{i.emitter.off("stdout",r),i.emitter.off("stderr",r)}}}else if(e==="setup-command"){let i=this.#d;if(i){let o=i.getSetupOutput();return o&&r(o),i.emitter.on("installStdout",r),i.emitter.on("installStderr",r),()=>{i.emitter.off("installStdout",r),i.emitter.off("installStderr",r)}}}else if(e==="validate-command"){let i=this.#d;if(i){let o=i.getValidateOutput();return o&&r(o),i.emitter.on("validateStdout",r),i.emitter.on("validateStderr",r),()=>{i.emitter.off("validateStdout",r),i.emitter.off("validateStderr",r)}}}else if(e==="bash-tools"){let i=o=>{o.type==="stdio"&&o.source==="tool-command"&&r(o.content)};return this.#g.on("step",i),()=>{this.#g.off("step",i)}}else{let i=this.#w.get(e);if(!i)throw new Error("Terminal not found");return i.onDataListeners.add(r),n&&i.onExitListeners.add(n),()=>{i.onDataListeners.delete(r),n&&i.onExitListeners.delete(n)}}}async getAllFiles(e={}){let{getDotFiles:r=!1,globbyPattern:n="**/*",includePattern:i,gitignore:o,deep:s,truncate:a,maxFiles:A=5e4,onlyFiles:c=!0}=e,u=this.#u?.accessControl,l=u?.entries?.filter(f=>f.action==="allow"&&f.permissions.includes("list")).map(f=>(f.resource.startsWith("/")?f.resource.slice(1):f.resource)||".")??[];if(!this.#E?.folders?.length){let f=await wp({basePath:this.#I,globPattern:[i??n,...l],extraIgnorePatterns:ev(u).deny,dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A});return WU(f,a)}let p=[],g=await this.#e.readdir(this.#I);for(let f of g)mJ(f)&&p.push(f);!p.includes("AGENTS.md")&&this.#E.agentsMD&&p.push("AGENTS.md");for(let f of this.#E.folders){let h=this.#e.resolve(this.#I,f.path),C=await wp({basePath:h,globPattern:[n,...l],dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A}),I=this.#N()?".":f.name||this.#e.basename(h);for(let B of C)I!=="."?p.push(this.#e.join(I,B)):p.push(B)}let d=im({files:p,policy:u,filterPattern:i,getDotFiles:r});return WU(d,a)}async searchFiles(e){let{query:r,caseInsensitive:n=!0,includeGlob:i,excludeGlob:o,maxResults:s=1e3,contextBefore:a=0,contextAfter:A=0}=e,c=await xh(this.#e),u=["--path-separator","/","--json","--line-number","--column","--hidden","--max-columns","500"];return n&&u.push("-i"),a>0&&u.push("-B",a.toString()),A>0&&u.push("-A",A.toString()),i&&u.push("--glob",i),o&&u.push("--glob",`!${o}`),u.push("--ignore-file",".builderignore"),u.push("--",r),new Promise(l=>{let p=KA({command:c,args:u,options:{env:process.env,cwd:this.#v,stdio:["ignore","pipe","pipe"]}}),g=new Qi(5e4);p.stdout.on("data",d=>{g.write(d.toString())}),p.on("error",()=>{l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1})}),p.on("close",d=>{if(d!==0)l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1});else{let f=[],h=new Set,I=g.getContent().split(`
1912
+ `),D.write(x)),h=D}let C=Date.now(),I={terminalId:n,title:e?.title||`Terminal ${this.#w.size+1}`,cwd:d,createdAt:C,lastWrittenAt:C,createdBy:e?.createdBy||"unknown",readonly:e?.readonly??!1,initialCommand:e?.initialCommand,builtIn:!1,state:f,stale:!1,exitCode:void 0,command:void 0};return this.#w.set(n,{...I,pty:h,onDataListeners:o,onExitListeners:s,disposeFns:l,env:e?.env,shell:a,inheritCredentials:e?.inheritCredentials}),(e?.emitTerminals??!0)&&this.#pe(),I}#it(){let e=this.getSessionContext(),r=Array.from(this.#w.values()).map(o=>({terminalId:o.terminalId,title:o.title,cwd:o.cwd,createdAt:o.createdAt,lastWrittenAt:o.lastWrittenAt,createdBy:o.createdBy,readonly:o.readonly,builtIn:o.builtIn,exitCode:o.exitCode,state:o.state,stale:o.stale,command:o.command})),n=[];this.#D?.includes("Bash")&&n.push({terminalId:"bash-tools",title:"Bash",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:Date.now(),createdBy:"fusion",readonly:!0,builtIn:!0,exitCode:void 0,state:"running",command:void 0});let i=this.#d;if(i){let o=Date.now();if(i.devState!=="unset"&&n.push({terminalId:"dev-command",title:"Dev Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!i.devCommandProcess?.write,builtIn:!0,state:i.devState==="running"?"running":"exited",exitCode:void 0,command:i.devCommand}),i.setupCommand&&n.push({terminalId:"setup-command",title:"Setup Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:i.setupState==="installing"?"running":"exited",exitCode:void 0,command:i.setupCommand}),i.validateCommandState!=="unset"){let s;switch(i.validateCommandState){case"running":s="running";break;case"success":s="exited";break;case"failure":s="error";break;case"stopped":s="exited";break}n.unshift({terminalId:"validate-command",title:"Validate Command",cwd:this.#v,createdAt:e.createdUnixTime,lastWrittenAt:o,createdBy:"fusion",readonly:!0,builtIn:!0,state:s,exitCode:void 0,command:i.validateCommand})}}return n.push(...r),n}#pe(){this.#g.emit("step",{type:"terminals",terminals:this.#it()})}updateTerminal({terminalId:e,cols:r,rows:n,title:i}){if(e==="dev-command"){if(r||n){let s=this.#d;if(s?.devCommandProcess?.resize)return s.devCommandProcess.resize(r,n),!0}return!1}let o=this.#w.get(e);return o?("resize"in o.pty&&(r||n)&&o.pty.resize(r??o.pty.cols,n??o.pty.rows),i&&(o.title=i,this.#pe()),!0):!1}writeTerminal({terminalId:e,data:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.write?(i.devCommandProcess.write(r),!0):!1}let n=this.#w.get(e);return!n||n.readonly?!1:("write"in n.pty&&n.pty.write(r),n.lastWrittenAt=Date.now(),!0)}signalTerminal({terminalId:e,signal:r}){if(e==="dev-command"){let i=this.#d;return i?.devCommandProcess?.kill?(i.devCommandProcess.kill(r),!0):!1}let n=this.#w.get(e);if(!n||n.readonly)return!1;try{"write"in n.pty?process.platform==="win32"?n.pty.kill():(r==="SIGINT"&&n.pty.write(""),n.pty.kill(r)):n.pty.kill(r)}catch{}return!0}disposeTerminal({terminalId:e,emitTerminals:r=!0}){let n=this.#w.get(e);if(!n)return!1;try{n.pty.kill()}catch{}return n.disposeFns.forEach(i=>{try{i()}catch{}}),n.onDataListeners.clear(),n.onExitListeners.clear(),n.disposeFns=[],this.#w.delete(e),r&&this.#pe(),!0}async restartTerminal({terminalId:e}){if(e==="dev-command"){let i=this.#d;if(i)try{return await i.restart(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="setup-command"){let i=this.#d;if(i)try{return await i.runSetupCommand(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="validate-command"){if(this.#d)try{return await this.#Mt(),!0}catch(o){return this.#e.Sentry?.captureException(o),!1}return!1}if(e==="bash-tools")return!1;let r=this.#w.get(e);return r?(await this.createTerminal({terminalId:e,title:r.title,cwd:r.cwd,env:r.env,shell:r.shell,cols:"cols"in r.pty?r.pty.cols:void 0,rows:"rows"in r.pty?r.pty.rows:void 0,createdBy:r.createdBy,emitTerminals:!1,initialCommand:r.initialCommand,readonly:r.readonly,inheritCredentials:r.inheritCredentials,force:!0}),this.#w.get(e)?(this.#pe(),!0):!1):!1}subscribeTerminal({terminalId:e,onData:r,onExit:n}){if(e==="dev-command"){let i=this.#d;if(i){let o=i.getDevWrite();return o&&r(o),i.emitter.on("stdout",r),i.emitter.on("stderr",r),()=>{i.emitter.off("stdout",r),i.emitter.off("stderr",r)}}}else if(e==="setup-command"){let i=this.#d;if(i){let o=i.getSetupOutput();return o&&r(o),i.emitter.on("installStdout",r),i.emitter.on("installStderr",r),()=>{i.emitter.off("installStdout",r),i.emitter.off("installStderr",r)}}}else if(e==="validate-command"){let i=this.#d;if(i){let o=i.getValidateOutput();return o&&r(o),i.emitter.on("validateStdout",r),i.emitter.on("validateStderr",r),()=>{i.emitter.off("validateStdout",r),i.emitter.off("validateStderr",r)}}}else if(e==="bash-tools"){let i=o=>{o.type==="stdio"&&o.source==="tool-command"&&r(o.content)};return this.#g.on("step",i),()=>{this.#g.off("step",i)}}else{let i=this.#w.get(e);if(!i)throw new Error("Terminal not found");return i.onDataListeners.add(r),n&&i.onExitListeners.add(n),()=>{i.onDataListeners.delete(r),n&&i.onExitListeners.delete(n)}}}async getAllFiles(e={}){let{getDotFiles:r=!1,globbyPattern:n="**/*",includePattern:i,gitignore:o,deep:s,truncate:a,maxFiles:A=5e4,onlyFiles:c=!0}=e,u=this.#u?.accessControl,l=u?.entries?.filter(f=>f.action==="allow"&&f.permissions.includes("list")).map(f=>(f.resource.startsWith("/")?f.resource.slice(1):f.resource)||".")??[];if(!this.#E?.folders?.length){let f=await wp({basePath:this.#I,globPattern:[i??n,...l],extraIgnorePatterns:ev(u).deny,dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A});return WU(f,a)}let p=[],g=await this.#e.readdir(this.#I);for(let f of g)mJ(f)&&p.push(f);!p.includes("AGENTS.md")&&this.#E.agentsMD&&p.push("AGENTS.md");for(let f of this.#E.folders){let h=this.#e.resolve(this.#I,f.path),C=await wp({basePath:h,globPattern:[n,...l],dot:r,gitignore:o,sys:this.#e,deep:s,onlyFiles:c,maxFiles:A}),I=this.#N()?".":f.name||this.#e.basename(h);for(let B of C)I!=="."?p.push(this.#e.join(I,B)):p.push(B)}let d=im({files:p,policy:u,filterPattern:i,getDotFiles:r});return WU(d,a)}async searchFiles(e){let{query:r,caseInsensitive:n=!0,includeGlob:i,excludeGlob:o,maxResults:s=1e3,contextBefore:a=0,contextAfter:A=0}=e,c=await xh(this.#e),u=["--path-separator","/","--json","--line-number","--column","--hidden","--max-columns","500"];return n&&u.push("-i"),a>0&&u.push("-B",a.toString()),A>0&&u.push("-A",A.toString()),i&&u.push("--glob",i),o&&u.push("--glob",`!${o}`),u.push("--ignore-file",".builderignore"),u.push("--",r),new Promise(l=>{let p=KA({command:c,args:u,options:{env:process.env,cwd:this.#v,stdio:["ignore","pipe","pipe"]}}),g=new Qi(5e4);p.stdout.on("data",d=>{g.write(d.toString())}),p.on("error",()=>{l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1})}),p.on("close",d=>{if(d!==0)l({matches:[],totalMatches:0,filesWithMatches:0,truncated:!1});else{let f=[],h=new Set,I=g.getContent().split(`
1913
1913
  `),B=[],E=null;for(let D of I)if(D.trim())try{let v=JSON.parse(D);if(v.type==="match"){let Q=v.data.path.text,x=v.data.line_number,b=v.data.lines.text.trimEnd(),S=v.data.submatches||[],_,$;S.length>0&&(_=S[0].start,$=S[0].end),h.add(Q);let U={filePath:Q,lineNumber:x,lineContent:b,columnStart:_,columnEnd:$,contextBefore:B,contextAfter:[]};if(B=[],E=U,f.push(U),f.length>=s)break}else if(v.type==="context"){let Q=v.data.line_number,x=v.data.lines.text.trimEnd();E&&Q>E.lineNumber?E.contextAfter.push(x):B.push(x)}}catch{continue}let y=f.length>=s;l({matches:f,totalMatches:f.length,filesWithMatches:h.size,truncated:y})}})})}async searchFileTree(e){let{query:r,excludeGlob:n,maxResults:i=100}=e,o=await xh(this.#e),s=["--files","--path-separator","/"],a=pge(r);a&&s.push("--glob",a),n&&s.push("--glob",`!${n}`);let A=this.#u?.accessControl,c=ev(A).deny;for(let l of c)s.push("--glob",`!${l}`);s.push("--ignore-file",".builderignore");let u=r.toLowerCase();return new Promise(l=>{let p=KA({command:o,args:s,options:{env:process.env,cwd:this.#v,stdio:["ignore","pipe","pipe"]}}),g=new Qi(1e5);p.stdout.on("data",d=>{g.write(d.toString())}),p.on("error",()=>{l({matches:[],totalMatches:0,truncated:!1})}),p.on("close",d=>{if(d!==0&&d!==1){l({matches:[],totalMatches:0,truncated:!1});return}let f=g.getContent(),h=[...new Set(f.split(`
1914
- `).filter(B=>B.trim()))];h=im({files:h,policy:A,getDotFiles:!0});let C=[];for(let B of h){let E=B.lastIndexOf("/"),y=E>=0?B.slice(E+1):B,D=E>=0?B.slice(0,E):"",v=lge(u,B.toLowerCase()),Q=gge(u,B,v);C.push({filePath:B,fileName:y,parentPath:D,matchIndices:v,score:Q})}C.sort((B,E)=>E.score-B.score);let I=C.slice(0,i).map(({score:B,...E})=>E);l({matches:I,totalMatches:h.length,truncated:h.length>i})})})}async collectRepoMetrics(e={}){let r=this.#ve(e.folderName);return e.rootPath&&(r=this.#e.join(r,e.rootPath)),Nge(this.#e,r)}getSessionId(){return this.getSessionContext().sessionId}updateMetadata(e){this.#ot(e,!1)}getMetadata(){return this.#U}#it=null;setTimeline(e){this.#it=e}getTimeline(){return this.#it}getSpaceId(){return this.#a.builderPublicKey}async revertToCommitSnapshot(e){this.#k=!1,this.#te=void 0,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#ne(!1);let n=(await this.#J(async o=>{let s=yl(e,o.folderName,this.gitRepoContexts[0]?.folderName);return s?(await this.git(["revert","--no-commit",`${s}..HEAD`],{cwd:o.path}),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Revert changes"],{cwd:o.path}),{commitHash:await this.getCurrentCommitHash("HEAD",o.path)}):(this.#r.warn(`No commit found for ${o.folderName}, skipping revert`),{skipped:!0})})).results.filter(o=>!o.success);if(n.length>0)throw new Error(`Failed to revert ${n.length} repos`);let i=await this.#O();this.#R={...this.#R,...i},await this.#S(),this.requestRefresh(),await this.#de({lastCommit:$s(i)})}async revertToCommitHash(e){let r=hm(e,this.gitRepoContexts[0]?.folderName),n=Object.keys(r).length===0?e:$s(r);return this.revertToCommitSnapshot(n)}async resetToCommitSnapshot(e,r=!0){this.#k=!1,this.#te=void 0,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#ne(!1);let i=(await this.#J(async s=>{let a=yl(e,s.folderName,this.gitRepoContexts[0]?.folderName);if(!a)return this.#r.warn(`No commit found for ${s.folderName}, skipping reset`),{skipped:!0};await this.git(["reset","--quiet","--hard",a],{cwd:s.path}),await this.git(["clean","-fd"],{cwd:s.path});let A=await this.getCurrentCommitHash("HEAD",s.path);if(A!==a)throw new Error(`Failed to reset commit hash for ${s.folderName}: expected ${a}, got ${A}`);return{commitHash:A}})).results.filter(s=>!s.success);if(i.length>0)throw new Error(`Failed to reset ${i.length} repos`);let o=hm(e,this.gitRepoContexts[0]?.folderName);this.#R={...this.#R,...o},await this.#S(),r&&this.requestRefresh()}async resetToCommitHash(e,r=!0){let n=hm(e,this.gitRepoContexts[0]?.folderName),i=Object.keys(n).length===0?e:$s(n);return this.resetToCommitSnapshot(i,r)}async restore({location:e,predicate:r,revert:n=!1,dryRun:i=!1,forceReplay:o=!1,debug:s}){let a=this.getSessionContext(),A=a.turns.length,c=null;for(let d=A-1;d>=-1;d--)if(r(d>=0?a.turns[d]:null,d)){c=d;break}if(c===null)return{undone:null,message:"Could not find the target to restore to, the completion id could be wrong"};n||await this.abort({cleanCurrentMessage:!0});let u=new Map,l=!!this.#m,p=a.turns,g=Math.max(0,e==="before"?c:c+1);for(let d=p.length-1;d>=g;d--){let f=p[d];for(let h of f.applyResults)u.set(h.filePath,h.oldContent??"")}if(!i){let d;if(l){c===-1?a.beforeCommit?d=a.beforeCommit:p.length>0&&(d=p[0].beforeCommit):c<p.length&&(e==="after"?(d=p[c].afterCommit,!d&&c+1<p.length&&(d=p[c+1].beforeCommit)):d=p[c].beforeCommit);let I={commitSnapshot:d,sessionId:a.sessionId,sessionBeforeCommit:a.beforeCommit,turnsLength:p.length,targetIndex:c,currentTurn:p[p.length-1],targetTurn:p[c],targetTurnNext:p[c+1],location:e,forceReplay:o,dryRun:i,debug:s};if(!d)return this.#e.Sentry?.captureException(new Error("No commit snapshot found for restore"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Could not find the target to restore to, the git history is missing"};try{n?await this.revertToCommitSnapshot(d):await this.resetToCommitSnapshot(d)}catch(B){return this.#e.Sentry?.captureException(new Error("Error resetting git",{cause:B}),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Failed to reset/restore, the file history is missing"}}}else for(let[I,B]of u.entries())try{B?await this.writeFile(I,B):await this.deleteFile(I)}catch{}if(n)return{undone:[],message:"The revert operation was successful"};let f=p.splice(g,p.length-g),h=sc(p);h&&h?.afterCommit!==d&&(this.#e.Sentry?.captureException(new Error("Reset After commit snapshot mismatch"),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},extra:{lastTurn:h,commitSnapshot:d}}),h.lastCommit=d,await this.#de({completionId:h.completionId,lastCommit:d}));let C=h?.completionId;if(f.length>0&&(await cJ(this.#e,this.#a,{lastCompletionId:C,sessionId:a.sessionId},!!this.#s),a.updatedUnixTime=Date.now()),o){let I=a.state;this.#g.emit("step",{type:"batch",steps:[{type:"state",newState:"replay",abortable:!1,previousState:I},...this.#Tt(),{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e},{type:"state",newState:I,abortable:!1,previousState:"replay"}]})}else f.length>0&&this.#g.emit("step",{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e})}return await this.#kt(),{undone:Array.from(u.keys()),message:"The restore operation was successful"}}async#kt(e){return await this.#d?.ensureDevCommand(e)}async restoreFromCompletionId({location:e,completionId:r,forceReplay:n}){let i=this.getSessionContext();return i.turns.find(s=>s.completionId===r)?this.restore({location:e,predicate:s=>s?.completionId===r,forceReplay:n,debug:`restore to: ${r}`}):(await this.#Ce,i.turns=[],i.canLoadMore=!0,await cJ(this.#e,this.#a,{sessionId:i.sessionId,lastCompletionId:r},!!this.#s),await this.loadMoreTurns(),this.restore({location:e,predicate:()=>!0,forceReplay:!0,debug:"restore after history"}))}async restoreBeforeCompletionId(e){return this.restoreFromCompletionId({location:"before",completionId:e,forceReplay:!1})}async undoLastUserMessage(e=!1){return this.restore({location:"before",predicate:r=>r?.user.role==="user",dryRun:e})}getLastUserCompletionId(){let e=this.getSessionContext();return Bye(e)?.completionId}getLastCompletionId(){let e=this.getSessionContext();return aJ(e)?.completionId}getCurrentState(){return this.getSessionContext().state}getLastApplyResultsTurn(){let e=this.getSessionContext();return yye(e)}getLastTurn(){let e=this.getSessionContext();return aJ(e)}getLastMessage(){return this.getLastTurn()?.actions.find(r=>r.type==="text")?.content}getNextUrl(){return this.getLastTurn()?.nextUrl}async sendFeedback(e){if(process.env.NODE_ENV==="test")return;if(e.feedbackSentiment){let n=e.feedbackSentiment==="positive"?`User provided positive feedback (thumbs up) on the previous completion.${e.feedbackText??""}`:`User provided negative feedback (thumbs down) on the previous completion.${e.feedbackText??""}`;this.queueSystemReminder({text:n,tag:"reminder:user-feedback"})}Jt("quality code feedback given",{spaceId:this.#a.builderPublicKey,sentiment:e.feedbackSentiment,mode:"cli"});let r=e.id??this.getLastCompletionId();r&&await this.#rr({...e,id:r})}#de(e){let r=e.completionId;if(!r){let i=this.getLastTurn();i&&e.lastCommit&&(i.lastCommit=e.lastCommit),r=i?.completionId}let n=AJ(this.#e,this.#a,"/codegen/finalize",{completionId:r,projectId:this.#u?.projectId,branchName:this.#u?.branchName,userCompletionId:this.getLastUserCompletionId(),sessionId:this.getSessionId(),metadata:this.#U,hasPlanToApply:this.#k,...e},this.#s);return this.#Bt&&this.#tr(),this.#K(n,"completionFinalize")}#tr(){try{let e=this.#e.getCwdDir(),r=this.getSessionId();if(this.#We){X2(this.#e,e,r).catch(()=>{});return}let n=Dv(this.#e,e).then(i=>{if(i.some(l=>l.sessionId===r)){this.#We=!0,X2(this.#e,e,r).catch(()=>{});return}let o=this.getSessionContext().turns,s=o[o.length-1],a=s?.title,A=a&&a!=="Untitled"&&!a.startsWith("completionId:"),c=s?.userMessage?.displayPrompt??s?.userMessage?.userPrompt??"",u=A?a:Ege(c);return Ige(this.#e,e,r,u).then(()=>{this.#We=!0})}).catch(()=>{});this.#K(n,"saveLocalHistory")}catch{}}#rr(e){let r=AJ(this.#e,this.#a,"/codegen/feedback",e,this.#s);return this.#K(r,"completionFeedback")}#G(e,r,n={}){this.#d?.emitter.emit("metrics",{durations:[{key:e,ms:r,attributes:n}]})}#K(e,r,n=!1){let i=eA();this.#r.debug(`(addToPendingPromises-${i}): adding ${r} (blocking: ${n})`),this.#le.push(e),n&&this.#_e.push(e);let o=new Error(`Deadlock detected in codegen (function: ${r})`),s=setTimeout(()=>{this.#e.Sentry?.captureException(o,{level:"fatal",tags:{operation:"codegen-stream",functionName:r,sessionId:this.getSessionId(),projectId:this.#h,branchName:this.#y}})},300*1e3);return e.finally(()=>{clearTimeout(s),this.#r.debug(`(addToPendingPromises-${i}): removing ${r} (blocking: ${n})`);let a=this.#_e.indexOf(e);a!==-1&&this.#_e.splice(a,1);let A=this.#le.indexOf(e);A!==-1&&this.#le.splice(A,1)})}async lastTurnHasChanges(){let e=await this.undoLastUserMessage(!0);return e.undone?e.undone.length>0:!1}#j(e){let r=this.getSessionContext(),n=r.state;return n!==e?(r.state=e,this.#g.emit("step",{type:"state",abortable:e==="generating",previousState:n,newState:e}),!0):!1}waitUntilState(e,r=1e4){return new Promise(n=>{if(this.getSessionContext().state===e){n();return}let o,s=a=>{a.type==="state"&&a.newState===e&&(clearTimeout(o),this.#g.removeListener("step",s),n())};o=setTimeout(()=>{this.#g.removeListener("step",s),n()},r),this.#g.on("step",s)})}getProxyConfig(){return oue({devServerUrl:this.#u?.serverUrl,proxyOrigin:this.#Te,proxyDefaultOrigin:this.#Me,proxyDestination:this.#Ct})}async clearSession(){this.#r.debug("(clearSession): clearing session"),await this.abort({cleanCurrentMessage:!0,flushMessageQueue:!1});let e=this.getSessionContext();e.turns=[],e.customInstructions=await this.#Se(),e.customAgents=await this.#Ge(),this.#$.length=0,this.#k=!1,this.#te=void 0,this.#U={},this.#Z=void 0,this.#ke=!1,this.clearMessageQueue(),this.queueGitStatusReminder({trigger:"session-start"}),this.#g.emit("step",this.#Nt())}async clearMessageQueue(e=!1){let r=[];if(e)for(let n of this.#t)n.user&&r.push({type:"user",displayPrompt:n.displayPrompt,user:n.user,role:n.user.role,compacting:!1,idempotencyKey:n.idempotencyKey});this.#t.length=0,this.#Ke(),r.length>0&&this.#g.emit("step",{type:"batch",steps:r})}updateMessage(e){if(e.type==="delete"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&this.#t.splice(r,1)}else if(e.type==="move"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&Pye(this.#t,r,r+e.delta)}this.#Ke()}async flushMessageQueue(){this.#r.debug("(flushMessageQueue): flushing message queue"),await this.abort({cleanCurrentMessage:!1,flushMessageQueue:!0}),this.#o&&this.#o()}#Rt(e){let r=e.idempotencyKey;if(r){let n=this.#t.findIndex(i=>i.idempotencyKey===r);if(n>=0)return this.#t[n]=e,!1}else e.idempotencyKey=(0,CF.randomUUID)();if(e.queue==null&&(e.queue=!0),e.user?e.user={...this.#Z,...e.user}:e.user=this.#Z,e.userPrompt==="___BROWSER_AUTOMATION_PROMPT___"){let n=this.getProxyConfig();e.userPrompt=Bge(n.proxyDefaultOrigin,this.#Qe||void 0)}return this.#t.push(e),!0}async sendMessage(e){this.#ke=!1;let r=0;if(Array.isArray(e))for(let i of e)this.#Rt(i)&&r++;else this.#Rt(e)&&r++;if(r===0)return null;this.#r.debug(`(sendMessage): added messages(${r}) to queue(${this.#t.length})`),this.#Ke();let n=this.#t[this.#t.length-1];return n?(this.#k=!1,this.#te=void 0,this.cancelAllPendingToolFulfilments(n.userPrompt),n.queue?this.#o&&this.#o():await this.flushMessageQueue(),await Bl(),n.idempotencyKey):null}#nr(){if(this.#A==="until-idle")return;let e=this.#t;if(e.length!==0){for(let r of e)if(r.systemReminders)for(let n of r.systemReminders)this.queueSystemReminder(n);return this.#i=uJ(e),this.#Z=this.#i.user,this.#i.softContextWindow&&(this.#b=Math.min(this.#b??3e4,this.#i.softContextWindow)),this.clearMessageQueue(!0),this.#i}}#ir(){let e=this.#t.length===0||this.#ke,r=new Promise(n=>{e?this.#o=n:n()}).then(()=>{let n=this.#t;if(n.length!==0)if(this.#A==="until-idle"){let i=this.#t.shift();if(i.user&&(this.#Z=i.user,this.#g.emit("step",{type:"user",displayPrompt:i.displayPrompt,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.idempotencyKey})),i.systemReminders)for(let o of i.systemReminders)this.queueSystemReminder(o);return this.#i=i,this.#Z=i.user,this.#i.softContextWindow&&(this.#b=Math.min(this.#b??3e4,this.#i.softContextWindow)),this.#Ke(),i}else{for(let o of n)if(o.systemReminders)for(let s of o.systemReminders)this.queueSystemReminder(s);let i=uJ(n);if(!i.dropAbortedPrompt&&this.#i){let o=i.idempotencyKey;i=hJ(this.#i,i),i.idempotencyKey=o}return this.clearMessageQueue(!0),this.#i=i,this.#Z=i.user,i}});return{shouldWait:e,promise:r}}#Ke(){this.#g.emit("step",{type:"message-queue",queue:this.#t.map(e=>({idempotencyKey:e.idempotencyKey,displayPrompt:e.displayPrompt,user:e.user}))})}#ot(e,r=!1){r&&(this.#U={}),Object.assign(this.#U,e),this.#g.emit("step",{type:"metadata",...this.#U})}async waitForSetupCommand(e){let r=this.#d;if(!r)return{state:"installed",shouldProceed:!0};if(r.setupState==="installing")try{await Yc(r.setupCommandPromise,e)}catch{}let n=r.setupState;return n==="not-installed"||n==="install-failed"||n==="install-aborted"?{state:n,shouldProceed:!0}:{state:"installed",shouldProceed:!0}}async waitForDevServer(e,r,n){if(!this.#d&&this.#u?.serverUrl)return{shouldProceed:!0,message:"Dev server is ready.",serverUrl:this.#u.serverUrl};let i=await this.waitForSetupCommand(e);if(!i.shouldProceed)return{shouldProceed:!1,message:`Project setup command did not completed. State: ${i.state}`};let o=this.#d;if(o){await o.ensureDevCommand(e);let s=await o.waitUntilServer(e,r,n);return s.ok?{shouldProceed:!0,message:"Dev server is ready.",serverUrl:o.serverUrl?.toString()}:{shouldProceed:!1,message:s.message,serverUrl:void 0}}return{shouldProceed:!1,message:"Dev server is not ready.",serverUrl:void 0}}async getNamedAgentConfig(e,r,n){let i=this.getSessionContext(),o=i.customAgents,s=e?o.find($=>$.name.toLowerCase()===e.toLowerCase()):void 0,a=s?.name??"explorer",{mcpServers:A=!1,model:c,mode:u="quality-v4-agent",systemPrompt:l,subagent_type:p,includeMemories:g,needDevServer:d,needValidation:f,queueMode:h,asyncSubAgents:C,resetAfterRun:I=!1,reasoning:B,softContextWindow:E}={mcpServers:s?.mcpServers,subagent_type:a,systemPrompt:s?.systemPrompt,softContextWindow:s?.softContextWindow,model:(()=>{if(s?.roundRobinModels?.length){let $=s.name,U=this.#Et.get($)??0;return this.#Et.set($,U+1),s.roundRobinModels[U%s.roundRobinModels.length]}return s?.model})(),mode:s?.mode,includeMemories:s?.includeMemories??a==="explorer",needDevServer:s?.needDevServer,needValidation:s?.needValidation,resetAfterRun:s?.resetAfterRun,queueMode:s?.queueMode,asyncSubAgents:s?.asyncSubAgents,reasoning:s?.reasoning??this.#Ve},y=["Read","Glob","ReadRule","Grep","WebSearch","SearchMemories"];i.sessionMode==="deep-research"&&y.push("Bash","WebFetch"),y=y.filter($=>this.#D?this.#D.includes($):!0),y.push("ExplorationMetadata");let D=mF(this.#u,s?.tools??y),v=c===void 0?p==="explorer"?"opa5-mini":void 0:c,Q=this.#d;if(d&&n){if(!Q)return{success:!1,response:`The ${p} agent can not be used on this session. Do no try again.`};if(Q.httpServerState.state==="stopped"||Q.httpServerState.state==="connecting"||Q.httpServerState.state==="error-fetch")try{if(Q.state==="not-installed")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, the dev server is not installed.`);if(Q.state==="install-failed")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it failed.`);if(Q.state==="install-aborted")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it was aborted.`);await this.waitForSetupCommand(n),await Q.ensureDevCommand(n)}catch(U){return{success:!1,response:U instanceof Error?U.message:String(U)}}if(f&&Q.validateCommand&&this.#ee){let U=await Q.runValidateCommand(void 0,n);if(U.status==="failure")return{success:!1,response:`The Agent could not start yet, because the validate command failed:
1914
+ `).filter(B=>B.trim()))];h=im({files:h,policy:A,getDotFiles:!0});let C=[];for(let B of h){let E=B.lastIndexOf("/"),y=E>=0?B.slice(E+1):B,D=E>=0?B.slice(0,E):"",v=lge(u,B.toLowerCase()),Q=gge(u,B,v);C.push({filePath:B,fileName:y,parentPath:D,matchIndices:v,score:Q})}C.sort((B,E)=>E.score-B.score);let I=C.slice(0,i).map(({score:B,...E})=>E);l({matches:I,totalMatches:h.length,truncated:h.length>i})})})}async collectRepoMetrics(e={}){let r=this.#ve(e.folderName);return e.rootPath&&(r=this.#e.join(r,e.rootPath)),Nge(this.#e,r)}getSessionId(){return this.getSessionContext().sessionId}updateMetadata(e){this.#st(e,!1)}getMetadata(){return this.#U}#ot=null;setTimeline(e){this.#ot=e}getTimeline(){return this.#ot}getSpaceId(){return this.#a.builderPublicKey}async revertToCommitSnapshot(e){this.#k=!1,this.#te=void 0,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#ne(!1);let n=(await this.#J(async o=>{let s=yl(e,o.folderName,this.gitRepoContexts[0]?.folderName);return s?(await this.git(["revert","--no-commit",`${s}..HEAD`],{cwd:o.path}),await this.git(["commit","--allow-empty","--quiet","--no-verify","--no-gpg-sign","-m","Revert changes"],{cwd:o.path}),{commitHash:await this.getCurrentCommitHash("HEAD",o.path)}):(this.#r.warn(`No commit found for ${o.folderName}, skipping revert`),{skipped:!0})})).results.filter(o=>!o.success);if(n.length>0)throw new Error(`Failed to revert ${n.length} repos`);let i=await this.#O();this.#R={...this.#R,...i},await this.#S(),this.requestRefresh(),await this.#de({lastCommit:$s(i)})}async revertToCommitHash(e){let r=hm(e,this.gitRepoContexts[0]?.folderName),n=Object.keys(r).length===0?e:$s(r);return this.revertToCommitSnapshot(n)}async resetToCommitSnapshot(e,r=!0){this.#k=!1,this.#te=void 0,await this.waitUntilBlockingPendingPromises(),await this.abortMerge(!1),await this.#ne(!1);let i=(await this.#J(async s=>{let a=yl(e,s.folderName,this.gitRepoContexts[0]?.folderName);if(!a)return this.#r.warn(`No commit found for ${s.folderName}, skipping reset`),{skipped:!0};await this.git(["reset","--quiet","--hard",a],{cwd:s.path}),await this.git(["clean","-fd"],{cwd:s.path});let A=await this.getCurrentCommitHash("HEAD",s.path);if(A!==a)throw new Error(`Failed to reset commit hash for ${s.folderName}: expected ${a}, got ${A}`);return{commitHash:A}})).results.filter(s=>!s.success);if(i.length>0)throw new Error(`Failed to reset ${i.length} repos`);let o=hm(e,this.gitRepoContexts[0]?.folderName);this.#R={...this.#R,...o},await this.#S(),r&&this.requestRefresh()}async resetToCommitHash(e,r=!0){let n=hm(e,this.gitRepoContexts[0]?.folderName),i=Object.keys(n).length===0?e:$s(n);return this.resetToCommitSnapshot(i,r)}async restore({location:e,predicate:r,revert:n=!1,dryRun:i=!1,forceReplay:o=!1,debug:s}){let a=this.getSessionContext(),A=a.turns.length,c=null;for(let d=A-1;d>=-1;d--)if(r(d>=0?a.turns[d]:null,d)){c=d;break}if(c===null)return{undone:null,message:"Could not find the target to restore to, the completion id could be wrong"};n||await this.abort({cleanCurrentMessage:!0});let u=new Map,l=!!this.#m,p=a.turns,g=Math.max(0,e==="before"?c:c+1);for(let d=p.length-1;d>=g;d--){let f=p[d];for(let h of f.applyResults)u.set(h.filePath,h.oldContent??"")}if(!i){let d;if(l){c===-1?a.beforeCommit?d=a.beforeCommit:p.length>0&&(d=p[0].beforeCommit):c<p.length&&(e==="after"?(d=p[c].afterCommit,!d&&c+1<p.length&&(d=p[c+1].beforeCommit)):d=p[c].beforeCommit);let I={commitSnapshot:d,sessionId:a.sessionId,sessionBeforeCommit:a.beforeCommit,turnsLength:p.length,targetIndex:c,currentTurn:p[p.length-1],targetTurn:p[c],targetTurnNext:p[c+1],location:e,forceReplay:o,dryRun:i,debug:s};if(!d)return this.#e.Sentry?.captureException(new Error("No commit snapshot found for restore"),{tags:{operation:"codegen-git",endpoint:"revertToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Could not find the target to restore to, the git history is missing"};try{n?await this.revertToCommitSnapshot(d):await this.resetToCommitSnapshot(d)}catch(B){return this.#e.Sentry?.captureException(new Error("Error resetting git",{cause:B}),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},contexts:{restore:I}}),{undone:null,message:"Failed to reset/restore, the file history is missing"}}}else for(let[I,B]of u.entries())try{B?await this.writeFile(I,B):await this.deleteFile(I)}catch{}if(n)return{undone:[],message:"The revert operation was successful"};let f=p.splice(g,p.length-g),h=sc(p);h&&h?.afterCommit!==d&&(this.#e.Sentry?.captureException(new Error("Reset After commit snapshot mismatch"),{tags:{operation:"codegen-git",endpoint:"resetToCommitHash"},extra:{lastTurn:h,commitSnapshot:d}}),h.lastCommit=d,await this.#de({completionId:h.completionId,lastCommit:d}));let C=h?.completionId;if(f.length>0&&(await cJ(this.#e,this.#a,{lastCompletionId:C,sessionId:a.sessionId},!!this.#s),a.updatedUnixTime=Date.now()),o){let I=a.state;this.#g.emit("step",{type:"batch",steps:[{type:"state",newState:"replay",abortable:!1,previousState:I},...this.#Tt(),{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e},{type:"state",newState:I,abortable:!1,previousState:"replay"}]})}else f.length>0&&this.#g.emit("step",{type:"restore",files:Array.from(u.keys()),lastCompletionId:C,location:e})}return await this.#kt(),{undone:Array.from(u.keys()),message:"The restore operation was successful"}}async#kt(e){return await this.#d?.ensureDevCommand(e)}async restoreFromCompletionId({location:e,completionId:r,forceReplay:n}){let i=this.getSessionContext();return i.turns.find(s=>s.completionId===r)?this.restore({location:e,predicate:s=>s?.completionId===r,forceReplay:n,debug:`restore to: ${r}`}):(await this.#Ce,i.turns=[],i.canLoadMore=!0,await cJ(this.#e,this.#a,{sessionId:i.sessionId,lastCompletionId:r},!!this.#s),await this.loadMoreTurns(),this.restore({location:e,predicate:()=>!0,forceReplay:!0,debug:"restore after history"}))}async restoreBeforeCompletionId(e){return this.restoreFromCompletionId({location:"before",completionId:e,forceReplay:!1})}async undoLastUserMessage(e=!1){return this.restore({location:"before",predicate:r=>r?.user.role==="user",dryRun:e})}getLastUserCompletionId(){let e=this.getSessionContext();return Bye(e)?.completionId}getLastCompletionId(){let e=this.getSessionContext();return aJ(e)?.completionId}getCurrentState(){return this.getSessionContext().state}getLastApplyResultsTurn(){let e=this.getSessionContext();return yye(e)}getLastTurn(){let e=this.getSessionContext();return aJ(e)}getLastMessage(){return this.getLastTurn()?.actions.find(r=>r.type==="text")?.content}getNextUrl(){return this.getLastTurn()?.nextUrl}async sendFeedback(e){if(process.env.NODE_ENV==="test")return;if(e.feedbackSentiment){let n=e.feedbackSentiment==="positive"?`User provided positive feedback (thumbs up) on the previous completion.${e.feedbackText??""}`:`User provided negative feedback (thumbs down) on the previous completion.${e.feedbackText??""}`;this.queueSystemReminder({text:n,tag:"reminder:user-feedback"})}Jt("quality code feedback given",{spaceId:this.#a.builderPublicKey,sentiment:e.feedbackSentiment,mode:"cli"});let r=e.id??this.getLastCompletionId();r&&await this.#rr({...e,id:r})}#de(e){let r=e.completionId;if(!r){let i=this.getLastTurn();i&&e.lastCommit&&(i.lastCommit=e.lastCommit),r=i?.completionId}let n=AJ(this.#e,this.#a,"/codegen/finalize",{completionId:r,projectId:this.#u?.projectId,branchName:this.#u?.branchName,userCompletionId:this.getLastUserCompletionId(),sessionId:this.getSessionId(),metadata:this.#U,hasPlanToApply:this.#k,...e},this.#s);return this.#yt&&this.#tr(),this.#K(n,"completionFinalize")}#tr(){try{let e=this.#e.getCwdDir(),r=this.getSessionId();if(this.#Ze){X2(this.#e,e,r).catch(()=>{});return}let n=Dv(this.#e,e).then(i=>{if(i.some(l=>l.sessionId===r)){this.#Ze=!0,X2(this.#e,e,r).catch(()=>{});return}let o=this.getSessionContext().turns,s=o[o.length-1],a=s?.title,A=a&&a!=="Untitled"&&!a.startsWith("completionId:"),c=s?.userMessage?.displayPrompt??s?.userMessage?.userPrompt??"",u=A?a:Ege(c);return Ige(this.#e,e,r,u).then(()=>{this.#Ze=!0})}).catch(()=>{});this.#K(n,"saveLocalHistory")}catch{}}#rr(e){let r=AJ(this.#e,this.#a,"/codegen/feedback",e,this.#s);return this.#K(r,"completionFeedback")}#G(e,r,n={}){this.#d?.emitter.emit("metrics",{durations:[{key:e,ms:r,attributes:n}]})}#K(e,r,n=!1){let i=eA();this.#r.debug(`(addToPendingPromises-${i}): adding ${r} (blocking: ${n})`),this.#le.push(e),n&&this.#_e.push(e);let o=new Error(`Deadlock detected in codegen (function: ${r})`),s=setTimeout(()=>{this.#e.Sentry?.captureException(o,{level:"fatal",tags:{operation:"codegen-stream",functionName:r,sessionId:this.getSessionId(),projectId:this.#h,branchName:this.#y}})},300*1e3);return e.finally(()=>{clearTimeout(s),this.#r.debug(`(addToPendingPromises-${i}): removing ${r} (blocking: ${n})`);let a=this.#_e.indexOf(e);a!==-1&&this.#_e.splice(a,1);let A=this.#le.indexOf(e);A!==-1&&this.#le.splice(A,1)})}async lastTurnHasChanges(){let e=await this.undoLastUserMessage(!0);return e.undone?e.undone.length>0:!1}#j(e){let r=this.getSessionContext(),n=r.state;return n!==e?(r.state=e,this.#g.emit("step",{type:"state",abortable:e==="generating",previousState:n,newState:e}),!0):!1}waitUntilState(e,r=1e4){return new Promise(n=>{if(this.getSessionContext().state===e){n();return}let o,s=a=>{a.type==="state"&&a.newState===e&&(clearTimeout(o),this.#g.removeListener("step",s),n())};o=setTimeout(()=>{this.#g.removeListener("step",s),n()},r),this.#g.on("step",s)})}getProxyConfig(){return oue({devServerUrl:this.#u?.serverUrl,proxyOrigin:this.#Te,proxyDefaultOrigin:this.#Me,proxyDestination:this.#It})}async clearSession(){this.#r.debug("(clearSession): clearing session"),await this.abort({cleanCurrentMessage:!0,flushMessageQueue:!1});let e=this.getSessionContext();e.turns=[],e.customInstructions=await this.#Se(),e.customAgents=await this.#Ge(),this.#$.length=0,this.#k=!1,this.#te=void 0,this.#U={},this.#Z=void 0,this.#ke=!1,this.clearMessageQueue(),this.queueGitStatusReminder({trigger:"session-start"}),this.#g.emit("step",this.#Nt())}async clearMessageQueue(e=!1){let r=[];if(e)for(let n of this.#t)n.user&&r.push({type:"user",displayPrompt:n.displayPrompt,user:n.user,role:n.user.role,compacting:!1,idempotencyKey:n.idempotencyKey});this.#t.length=0,this.#Ke(),r.length>0&&this.#g.emit("step",{type:"batch",steps:r})}updateMessage(e){if(e.type==="delete"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&this.#t.splice(r,1)}else if(e.type==="move"){let r=this.#t.findIndex(n=>n.idempotencyKey===e.idempotencyKey);r>=0&&Pye(this.#t,r,r+e.delta)}this.#Ke()}async flushMessageQueue(){this.#r.debug("(flushMessageQueue): flushing message queue"),await this.abort({cleanCurrentMessage:!1,flushMessageQueue:!0}),this.#o&&this.#o()}#Rt(e){let r=e.idempotencyKey;if(r){let n=this.#t.findIndex(i=>i.idempotencyKey===r);if(n>=0)return this.#t[n]=e,!1}else e.idempotencyKey=(0,CF.randomUUID)();if(e.queue==null&&(e.queue=!0),e.user?e.user={...this.#Z,...e.user}:e.user=this.#Z,e.userPrompt==="___BROWSER_AUTOMATION_PROMPT___"){let n=this.getProxyConfig();e.userPrompt=Bge(n.proxyDefaultOrigin,this.#Qe||void 0)}return this.#t.push(e),!0}async sendMessage(e){this.#ke=!1;let r=0;if(Array.isArray(e))for(let i of e)this.#Rt(i)&&r++;else this.#Rt(e)&&r++;if(r===0)return null;this.#r.debug(`(sendMessage): added messages(${r}) to queue(${this.#t.length})`),this.#Ke();let n=this.#t[this.#t.length-1];return n?(this.#k=!1,this.#te=void 0,this.cancelAllPendingToolFulfilments(n.userPrompt),n.queue?this.#o&&this.#o():await this.flushMessageQueue(),await Bl(),n.idempotencyKey):null}#nr(){if(this.#A==="until-idle")return;let e=this.#t;if(e.length!==0){for(let r of e)if(r.systemReminders)for(let n of r.systemReminders)this.queueSystemReminder(n);return this.#i=uJ(e),this.#Z=this.#i.user,this.#i.softContextWindow&&(this.#b=Math.min(this.#b??3e4,this.#i.softContextWindow)),this.clearMessageQueue(!0),this.#i}}#ir(){let e=this.#t.length===0||this.#ke,r=new Promise(n=>{e?this.#o=n:n()}).then(()=>{let n=this.#t;if(n.length!==0)if(this.#A==="until-idle"){let i=this.#t.shift();if(i.user&&(this.#Z=i.user,this.#g.emit("step",{type:"user",displayPrompt:i.displayPrompt,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.idempotencyKey})),i.systemReminders)for(let o of i.systemReminders)this.queueSystemReminder(o);return this.#i=i,this.#Z=i.user,this.#i.softContextWindow&&(this.#b=Math.min(this.#b??3e4,this.#i.softContextWindow)),this.#Ke(),i}else{for(let o of n)if(o.systemReminders)for(let s of o.systemReminders)this.queueSystemReminder(s);let i=uJ(n);if(!i.dropAbortedPrompt&&this.#i){let o=i.idempotencyKey;i=hJ(this.#i,i),i.idempotencyKey=o}return this.clearMessageQueue(!0),this.#i=i,this.#Z=i.user,i}});return{shouldWait:e,promise:r}}#Ke(){this.#g.emit("step",{type:"message-queue",queue:this.#t.map(e=>({idempotencyKey:e.idempotencyKey,displayPrompt:e.displayPrompt,user:e.user}))})}#st(e,r=!1){r&&(this.#U={}),Object.assign(this.#U,e),this.#g.emit("step",{type:"metadata",...this.#U})}async waitForSetupCommand(e){let r=this.#d;if(!r)return{state:"installed",shouldProceed:!0};if(r.setupState==="installing")try{await Yc(r.setupCommandPromise,e)}catch{}let n=r.setupState;return n==="not-installed"||n==="install-failed"||n==="install-aborted"?{state:n,shouldProceed:!0}:{state:"installed",shouldProceed:!0}}async waitForDevServer(e,r,n){if(!this.#d&&this.#u?.serverUrl)return{shouldProceed:!0,message:"Dev server is ready.",serverUrl:this.#u.serverUrl};let i=await this.waitForSetupCommand(e);if(!i.shouldProceed)return{shouldProceed:!1,message:`Project setup command did not completed. State: ${i.state}`};let o=this.#d;if(o){await o.ensureDevCommand(e);let s=await o.waitUntilServer(e,r,n);return s.ok?{shouldProceed:!0,message:"Dev server is ready.",serverUrl:o.serverUrl?.toString()}:{shouldProceed:!1,message:s.message,serverUrl:void 0}}return{shouldProceed:!1,message:"Dev server is not ready.",serverUrl:void 0}}async getNamedAgentConfig(e,r,n){let i=this.getSessionContext(),o=i.customAgents,s=e?o.find($=>$.name.toLowerCase()===e.toLowerCase()):void 0,a=s?.name??"explorer",{mcpServers:A=!1,model:c,mode:u="quality-v4-agent",systemPrompt:l,subagent_type:p,includeMemories:g,needDevServer:d,needValidation:f,queueMode:h,asyncSubAgents:C,resetAfterRun:I=!1,reasoning:B,softContextWindow:E}={mcpServers:s?.mcpServers,subagent_type:a,systemPrompt:s?.systemPrompt,softContextWindow:s?.softContextWindow,model:(()=>{if(s?.roundRobinModels?.length){let $=s.name,U=this.#Bt.get($)??0;return this.#Bt.set($,U+1),s.roundRobinModels[U%s.roundRobinModels.length]}return s?.model})(),mode:s?.mode,includeMemories:s?.includeMemories??a==="explorer",needDevServer:s?.needDevServer,needValidation:s?.needValidation,resetAfterRun:s?.resetAfterRun,queueMode:s?.queueMode,asyncSubAgents:s?.asyncSubAgents,reasoning:s?.reasoning??this.#Ve},y=["Read","Glob","ReadRule","Grep","WebSearch","SearchMemories"];i.sessionMode==="deep-research"&&y.push("Bash","WebFetch"),y=y.filter($=>this.#D?this.#D.includes($):!0),y.push("ExplorationMetadata");let D=mF(this.#u,s?.tools??y),v=c===void 0?p==="explorer"?"opa5-mini":void 0:c,Q=this.#d;if(d&&n){if(!Q)return{success:!1,response:`The ${p} agent can not be used on this session. Do no try again.`};if(Q.httpServerState.state==="stopped"||Q.httpServerState.state==="connecting"||Q.httpServerState.state==="error-fetch")try{if(Q.state==="not-installed")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, the dev server is not installed.`);if(Q.state==="install-failed")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it failed.`);if(Q.state==="install-aborted")throw new Error(`The ${p} agent can not be used until the setupCommand finish successfully. However, last time we try to run the install script, it was aborted.`);await this.waitForSetupCommand(n),await Q.ensureDevCommand(n)}catch(U){return{success:!1,response:U instanceof Error?U.message:String(U)}}if(f&&Q.validateCommand&&this.#ee){let U=await Q.runValidateCommand(void 0,n);if(U.status==="failure")return{success:!1,response:`The Agent could not start yet, because the validate command failed:
1915
1915
  <command>
1916
1916
  ${U.command}
1917
1917
  </command>
@@ -1920,19 +1920,19 @@ ${U.output}
1920
1920
  </logs>
1921
1921
 
1922
1922
  Make the necessary changes and try again.`};if(U.status==="aborted")return{success:!1,response:"The Agent could not start yet, because the validate command was aborted by the user."};this.#ee=!1}let $=await this.waitForDevServer(n);if(!$.shouldProceed)return{success:!1,response:$.message}}let x=this.#C.replace(/-agent$/,""),b={};if(D.includes("mcp:chrome")){let $=await this.#or(r,n);if($)b.chrome={command:"npx",args:["-y","chrome-devtools-mcp@latest","--wsEndpoint",$,"--categoryEmulation=false"],retries:5};else{let U=["mcp:chrome","RecordFrame","CompileRecording","DevServerLogs"];for(let M of U){let L=D.indexOf(M);L!==-1&&D.splice(L,1)}this.#r.debug("Chrome MCP not available \u2014 browser tools removed from agent")}}let S=["## Workspace Context","",`**Bash tool Working Directory:** ${this.#v}`,"","**Git Repositories:**",...this.#p.map($=>`- repository: ${$.repoName} in folder: ${$.folderName}`)].join(`
1923
- `),_=l?Ev(l,{cwd:this.#v,env:{FUSION_CONTEXT:S,FUSION_TEST_PROMPT:this.#u?.browserAutomationInstructions??"",...Q?.envVars??process.env},allowedCommands:Xb(this.#u?.allowedCommands??[]),skipCommandSecurity:this.#u?.skipCommandSecurity===!0}):void 0;return{success:!0,subagent_type:p,resetAfterRun:I,options:{sys:this.#e,credentials:this.#a,position:s?.position??`${x}-${a}`,mode:u,softContextWindow:E,includeMemories:g,modelOverride:s?.inheritSessionModel&&(this.#Pe??this.#_)?this.#Pe??this.#_:ym(v)??this.#Pe??this.#_,sessionOrCompletionId:r,workingDirectory:this.#I,mcpServers:A,fusionStatusMonitor:this.#$e,autoImportLocalMCPs:!1,fusionConfig:this.#u,privacyMode:this.#P,enabledTools:D,builtInMCPServerConfig:b,systemPromptOverride:_,queueMode:h,asyncSubAgents:C,reasoning:B,devServerOrchestrator:D.includes("DevServerLogs")||D.includes("DevServerRestart")||D.includes("DevServerControl")||D.includes("ProposeEnvVariable")?this.#d:void 0}}}async spawnNamedAgent(e,r){let n=r.resume??r.sessionId,i=await this.getNamedAgentConfig(e,n,r.signal);if(!i.success)return{success:!1,response:i.response};await this.waitUntilBlockingPendingPromises(),await this.#ne(!0);let o;if(i.resetAfterRun){if(this.#m&&!await this.#At())return{success:!1,response:`Cannot run browser automation with uncommitted changes. The "${i.subagent_type}" agent modifies code during testing and automatically resets changes afterward. Your uncommitted changes would be permanently lost.
1923
+ `),_=l?Ev(l,{cwd:this.#v,env:{FUSION_CONTEXT:S,FUSION_TEST_PROMPT:this.#u?.browserAutomationInstructions??"",...Q?.envVars??process.env},allowedCommands:Xb(this.#u?.allowedCommands??[]),skipCommandSecurity:this.#u?.skipCommandSecurity===!0}):void 0;return{success:!0,subagent_type:p,resetAfterRun:I,options:{sys:this.#e,credentials:this.#a,position:s?.position??`${x}-${a}`,mode:u,softContextWindow:E,includeMemories:g,modelOverride:s?.inheritSessionModel&&(this.#Pe??this.#_)?this.#Pe??this.#_:ym(v)??this.#Pe??this.#_,sessionOrCompletionId:r,workingDirectory:this.#I,mcpServers:A,fusionStatusMonitor:this.#$e,autoImportLocalMCPs:!1,fusionConfig:this.#u,privacyMode:this.#P,enabledTools:D,builtInMCPServerConfig:b,systemPromptOverride:_,queueMode:h,asyncSubAgents:C,reasoning:B,devServerOrchestrator:D.includes("DevServerLogs")||D.includes("DevServerRestart")||D.includes("DevServerControl")||D.includes("ProposeEnvVariable")?this.#d:void 0}}}async spawnNamedAgent(e,r){let n=r.resume??r.sessionId,i=await this.getNamedAgentConfig(e,n,r.signal);if(!i.success)return{success:!1,response:i.response};await this.waitUntilBlockingPendingPromises(),await this.#ne(!0);let o;if(i.resetAfterRun){if(this.#m&&!await this.#ct())return{success:!1,response:`Cannot run browser automation with uncommitted changes. The "${i.subagent_type}" agent modifies code during testing and automatically resets changes afterward. Your uncommitted changes would be permanently lost.
1924
1924
 
1925
- Please commit or stash your changes first, then try again.`};o=(await this.#S())?.currentCommit}let s=i.subagent_type,a=new t({...i.options,git:!1,parentSessionId:this.getSessionId()}),A=r.sessionId??r.resume??n,c=Promise.withResolvers();this.#Le.set(A,{description:r.prompt.substring(0,200),startedAt:Date.now(),promise:c.promise}),await a.initializeSession({skipSessionLoading:!r.resume,signal:r.signal}),r.resume&&i.options.builtInMCPServerConfig?.chrome&&a.queueSystemReminder({text:"The connected browser might have restarted. This means cookies and open pages might have been cleared."});let u=a.getSessionId(),l={important_files:[]},p=new NE(u,{framesDir:this.#e.join(hF.default.homedir(),".builder","recordings"),debug:this.#s}),g=[],d={value:null},f=[],h={value:null},C=[],I=r.maxCompletions,B=a.connectToEventLoop(!1,D=>{try{if(D.type==="tool_result"&&D.result.tool_name==="ExplorationMetadata"&&typeof D.result.content=="string")try{l=JSON.parse(D.result.content)}catch(v){this.#e.Sentry?.captureException(v,{extra:{contentPreview:D.result.content.substring(0,500),contentLength:D.result.content.length},tags:{operation:"exploration-metadata-parse"}})}else{if(D.type==="done"&&(I--,I<10)){let v="";if(h.value){let Q=new Set(C.map(b=>b.test_case_id)),x=h.value.test_cases.filter(b=>!Q.has(b.id));x.length>0&&(v=` You have ${x.length} unreported test cases: ${x.map(b=>b.id).join(", ")}. Report them as "couldnt_verify" with failure_category="timeout" if you cannot test them.`)}a.queueSystemReminder({text:`The agent has been working for a while. Please try to wrap up soon because soon it will be interrupted. T-minus ${I} turns.${v}`})}this.#g.emit("step",{type:"agent",id:u,step:D,subagent_type:s})}if(D.type==="tool"&&p.onToolCall(D.name,D.id,D.content),D.type==="thinking"&&p.onThinking(D.content),D.type==="tool_result"){let v=p.getFrameCount();if(p.onToolResult(D.result,Cye()),D.result.tool_name==="RecordFrame")try{let Q=JSON.parse(D.result.tool_input||"{}");p.onRecordFrame(Q)}catch{p.onRecordFrame({title:"Untitled",frame:"last-image"})}if(p.getFrameCount()>v&&this.#ot({timeline_progress:p.getProgressSnapshot()},!1),D.result.tool_name==="ReportUIIssue")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.title&&Q.description&&g.push({title:Q.title,description:Q.description,debugInfo:Q.debugInfo})}catch{}if(D.result.tool_name==="ReportTestOutcome")try{let Q=JSON.parse(D.result.tool_input||"{}");if(Q.test_case_id){let x=h.value&&!h.value.test_cases.some(S=>S.id===Q.test_case_id);x&&a.queueSystemReminder({text:`WARNING: "${Q.test_case_id}" is not in your registered test plan. Use one of: ${h.value.test_cases.map(S=>S.id).join(", ")}`,tag:"reminder:unknown-test-case"});let b=!!x;if(Q.outcome==="succeeded"&&(!Q.evidence_frame_count||Q.evidence_frame_count<1)&&(a.queueSystemReminder({text:`REJECTED: You reported "${Q.test_case_id}" as "succeeded" but evidence_frame_count is ${Q.evidence_frame_count??0}. A test case CANNOT be "succeeded" without visual evidence. Take a screenshot, call RecordFrame, then re-report this test case with evidence_frame_count >= 1. If you cannot get visual evidence, report as "couldnt_verify" instead.`,tag:"reminder:evidence-required"}),b=!0),Q.outcome!=="succeeded"&&Q.outcome!=="other"&&!Q.failure_category&&(a.queueSystemReminder({text:`WARNING: "${Q.test_case_id}" reported as "${Q.outcome}" without failure_category. Re-report with a failure_category (env_issue, creds_missing, needs_user_input, server_not_ready, feature_not_reachable, timeout, assertion_failed, unexpected_error, not_applicable).`,tag:"reminder:failure-category-required"}),b=!0),!b){let S=C.findIndex($=>$.test_case_id===Q.test_case_id),_={...Q,timestamp:Date.now()};if(S!==-1?C[S]=_:C.push(_),h.value){let $=new Set(C.map(M=>M.test_case_id)),U=h.value.test_cases.filter(M=>!$.has(M.id));U.length>0&&a.queueSystemReminder({text:`Progress: ${C.length}/${h.value.test_cases.length} test cases reported. Remaining: ${U.map(M=>M.id).join(", ")}`,tag:"reminder:test-progress"})}}}else if(Q.outcome&&Q.summary&&(d.value={outcome:Q.outcome,summary:Q.summary,details:Q.details}),h.value){let x=new Set(C.map(S=>S.test_case_id)),b=h.value.test_cases.filter(S=>!x.has(S.id)).map(S=>S.id);b.length>0&&a.queueSystemReminder({text:`WARNING: ${b.length} test cases unreported: ${b.join(", ")}. Call ReportTestOutcome with test_case_id for each remaining case before the final summary.`,tag:"reminder:missing-test-cases"})}}catch{}if(D.result.tool_name==="RegisterTestPlan")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.mode&&Q.test_cases?.length>0&&(h.value={mode:Q.mode,test_cases:Q.test_cases})}catch{}if(D.result.tool_name==="ReportIssue")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.file_path&&Q.line&&Q.title&&Q.severity&&Q.body&&f.push({file_path:Q.file_path,line:Q.line,...Q.start_line?{start_line:Q.start_line}:{},title:Q.title,severity:Q.severity,body:Q.body})}catch{}}}catch{}}),E=async()=>{B(),await a.close(!1)};if(r.signal?.aborted){await E(),this.#Le.delete(A);let D={success:!1,response:"Agent task aborted"};return c.resolve(D),D}let y=async()=>{await E()};r.signal&&r.signal.addEventListener("abort",y);try{let D=r.attachmentUrls?.map(b=>({type:"url",value:b}));await a.sendMessage({userPrompt:r.prompt,user:r.user,maxCompletions:r.maxCompletions,category:"background-subagent",includeRelevantMemories:i.options.includeMemories,queue:!0,...D?.length&&{attachments:D}}),await a.waitUntilIdle(r.signal),this.#It.add(s);let v=a.getLastTurn();if(!v)return{success:!1,response:"Agent task failed"};let Q=v.actions.filter(b=>b.type==="text").map(b=>b.content).join(`
1925
+ Please commit or stash your changes first, then try again.`};o=(await this.#S())?.currentCommit}let s=i.subagent_type,a=new t({...i.options,git:!1,parentSessionId:this.getSessionId()}),A=r.sessionId??r.resume??n,c=Promise.withResolvers();this.#Le.set(A,{description:r.prompt.substring(0,200),startedAt:Date.now(),promise:c.promise}),await a.initializeSession({skipSessionLoading:!r.resume,signal:r.signal}),r.resume&&i.options.builtInMCPServerConfig?.chrome&&a.queueSystemReminder({text:"The connected browser might have restarted. This means cookies and open pages might have been cleared."});let u=a.getSessionId(),l={important_files:[]},p=new NE(u,{framesDir:this.#e.join(hF.default.homedir(),".builder","recordings"),debug:this.#s}),g=[],d={value:null},f=[],h={value:null},C=[],I=r.maxCompletions,B=a.connectToEventLoop(!1,D=>{try{if(D.type==="tool_result"&&D.result.tool_name==="ExplorationMetadata"&&typeof D.result.content=="string")try{l=JSON.parse(D.result.content)}catch(v){this.#e.Sentry?.captureException(v,{extra:{contentPreview:D.result.content.substring(0,500),contentLength:D.result.content.length},tags:{operation:"exploration-metadata-parse"}})}else{if(D.type==="done"&&(I--,I<10)){let v="";if(h.value){let Q=new Set(C.map(b=>b.test_case_id)),x=h.value.test_cases.filter(b=>!Q.has(b.id));x.length>0&&(v=` You have ${x.length} unreported test cases: ${x.map(b=>b.id).join(", ")}. Report them as "couldnt_verify" with failure_category="timeout" if you cannot test them.`)}a.queueSystemReminder({text:`The agent has been working for a while. Please try to wrap up soon because soon it will be interrupted. T-minus ${I} turns.${v}`})}this.#g.emit("step",{type:"agent",id:u,step:D,subagent_type:s})}if(D.type==="tool"&&p.onToolCall(D.name,D.id,D.content),D.type==="thinking"&&p.onThinking(D.content),D.type==="tool_result"){let v=p.getFrameCount();if(p.onToolResult(D.result,Cye()),D.result.tool_name==="RecordFrame")try{let Q=JSON.parse(D.result.tool_input||"{}");p.onRecordFrame(Q)}catch{p.onRecordFrame({title:"Untitled",frame:"last-image"})}if(p.getFrameCount()>v&&this.#st({timeline_progress:p.getProgressSnapshot()},!1),D.result.tool_name==="ReportUIIssue")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.title&&Q.description&&g.push({title:Q.title,description:Q.description,debugInfo:Q.debugInfo})}catch{}if(D.result.tool_name==="ReportTestOutcome")try{let Q=JSON.parse(D.result.tool_input||"{}");if(Q.test_case_id){let x=h.value&&!h.value.test_cases.some(S=>S.id===Q.test_case_id);x&&a.queueSystemReminder({text:`WARNING: "${Q.test_case_id}" is not in your registered test plan. Use one of: ${h.value.test_cases.map(S=>S.id).join(", ")}`,tag:"reminder:unknown-test-case"});let b=!!x;if(Q.outcome==="succeeded"&&(!Q.evidence_frame_count||Q.evidence_frame_count<1)&&(a.queueSystemReminder({text:`REJECTED: You reported "${Q.test_case_id}" as "succeeded" but evidence_frame_count is ${Q.evidence_frame_count??0}. A test case CANNOT be "succeeded" without visual evidence. Take a screenshot, call RecordFrame, then re-report this test case with evidence_frame_count >= 1. If you cannot get visual evidence, report as "couldnt_verify" instead.`,tag:"reminder:evidence-required"}),b=!0),Q.outcome!=="succeeded"&&Q.outcome!=="other"&&!Q.failure_category&&(a.queueSystemReminder({text:`WARNING: "${Q.test_case_id}" reported as "${Q.outcome}" without failure_category. Re-report with a failure_category (env_issue, creds_missing, needs_user_input, server_not_ready, feature_not_reachable, timeout, assertion_failed, unexpected_error, not_applicable).`,tag:"reminder:failure-category-required"}),b=!0),!b){let S=C.findIndex($=>$.test_case_id===Q.test_case_id),_={...Q,timestamp:Date.now()};if(S!==-1?C[S]=_:C.push(_),h.value){let $=new Set(C.map(M=>M.test_case_id)),U=h.value.test_cases.filter(M=>!$.has(M.id));U.length>0&&a.queueSystemReminder({text:`Progress: ${C.length}/${h.value.test_cases.length} test cases reported. Remaining: ${U.map(M=>M.id).join(", ")}`,tag:"reminder:test-progress"})}}}else if(Q.outcome&&Q.summary&&(d.value={outcome:Q.outcome,summary:Q.summary,details:Q.details}),h.value){let x=new Set(C.map(S=>S.test_case_id)),b=h.value.test_cases.filter(S=>!x.has(S.id)).map(S=>S.id);b.length>0&&a.queueSystemReminder({text:`WARNING: ${b.length} test cases unreported: ${b.join(", ")}. Call ReportTestOutcome with test_case_id for each remaining case before the final summary.`,tag:"reminder:missing-test-cases"})}}catch{}if(D.result.tool_name==="RegisterTestPlan")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.mode&&Q.test_cases?.length>0&&(h.value={mode:Q.mode,test_cases:Q.test_cases})}catch{}if(D.result.tool_name==="ReportIssue")try{let Q=JSON.parse(D.result.tool_input||"{}");Q.file_path&&Q.line&&Q.title&&Q.severity&&Q.body&&f.push({file_path:Q.file_path,line:Q.line,...Q.start_line?{start_line:Q.start_line}:{},title:Q.title,severity:Q.severity,body:Q.body})}catch{}}}catch{}}),E=async()=>{B(),await a.close(!1)};if(r.signal?.aborted){await E(),this.#Le.delete(A);let D={success:!1,response:"Agent task aborted"};return c.resolve(D),D}let y=async()=>{await E()};r.signal&&r.signal.addEventListener("abort",y);try{let D=r.attachmentUrls?.map(b=>({type:"url",value:b}));await a.sendMessage({userPrompt:r.prompt,user:r.user,maxCompletions:r.maxCompletions,category:"background-subagent",includeRelevantMemories:i.options.includeMemories,queue:!0,...D?.length&&{attachments:D}}),await a.waitUntilIdle(r.signal),this.#Et.add(s);let v=a.getLastTurn();if(!v)return{success:!1,response:"Agent task failed"};let Q=v.actions.filter(b=>b.type==="text").map(b=>b.content).join(`
1926
1926
  `);if(h.value&&(Q=`<browser_automation_test_plan>${JSON.stringify(h.value,null,2)}</browser_automation_test_plan>
1927
1927
  ${Q}`),C.length>0&&(Q=`<browser_automation_test_results>${JSON.stringify(C,null,2)}</browser_automation_test_results>
1928
1928
  ${Q}`),g.length>0&&(Q=`<browser_automation_ui_issues>${JSON.stringify(g,null,2)}</browser_automation_ui_issues><browser_automation_summary>${Q}</browser_automation_summary>`),f.length>0&&(Q=`<code_review_issues>${JSON.stringify(f,null,2)}</code_review_issues><code_review_summary>${Q}</code_review_summary>`),p.hasAnyFrames())try{let b=a.getSessionId(),S=p.getHighlightImages(),_=S.length>0?p.getHighlightMetadataFrames():p.getLegacyMetadataFrames(),$=S.length>0?S:p.getExplicitImages(),U=`${b}.webp`,M=`${b}.json`,L=`${b}-timeline.json`,Y=this.#e.join(hF.default.homedir(),".builder","recordings"),W=this.#e.join(Y,U),K=this.#e.join(Y,M),J=this.#e.join(Y,L);await Zl.default.promises.mkdir(Y,{recursive:!0}),await Zl.default.promises.writeFile(K,JSON.stringify(_,null,2));let G=await p.finalize();await Zl.default.promises.writeFile(J,JSON.stringify(G,null,2)),l.timeline_id=L;let ie=this.getSessionContext().userContext,de=ie?.browserTestingShadowMode==="true",me=ie?.prNumber&&!de?{prNumber:Number(ie.prNumber),repoFullName:ie.repoFullName,hostname:ie.hostname,prHeadSha:ie.prHeadSha,checkRunId:ie.checkRunId?Number(ie.checkRunId):void 0,projectId:this.#h??void 0,branchName:this.#y??void 0,ownerId:this.#a.builderPublicKey,configId:this.getLastCompletionId(),containerUrl:ie.containerUrl,recordingCaption:(()=>{if(h.value&&C.length>0){let X=C.filter(rt=>rt.outcome==="succeeded").length,ve=h.value.test_cases.length;return`Browser testing: ${X}/${ve} passed`}return d.value?`Browser testing: ${d.value.outcome}`:"Browser testing"})(),summary:d.value?.summary??void 0}:null,fe=await sa(this.#a,"/codegen/timeline",{...G,projectId:this.#h??null,branchName:this.#y??null,testOutcome:d.value?.outcome??null,testSummary:d.value?.summary??null,testDetails:d.value?.details??null,uiIssues:g.length>0?g:null,testPlan:h.value??null,testCaseResults:C.length>0?C:null,submission:me});if(fe?.recording_id&&(l.recording_id=fe.recording_id),$.length>0){let X=S.length>0?p.getHighlightFrameDurations():p.getExplicitFrameDurations();if(await oge($,{duration:"1",frameDurations:X.length>0?X:void 0,outputPath:W,cleanup:!1,sys:this.#e,debug:this.#s,signal:r.signal})&&(l.gif_id=U??void 0,this.#r.debug(`(subagent=${s}): Generated recording from ${$.length} frames: ${U}`),U)){let rt=_.map(Be=>Be.title);Q=`<browser_automation_gif_id>${U}</browser_automation_gif_id>
1929
1929
  <browser_automation_timeline_id>${L}</browser_automation_timeline_id>
1930
1930
  <browser_automation_recorded_frames>${JSON.stringify(rt)}</browser_automation_recorded_frames>
1931
1931
 
1932
- ${Q}`}}this.#ot({gif_id:l.gif_id,gif_frames:_,timeline_id:L,recording_id:l.recording_id},!1),l.recording_id&&p.cleanupSessionFiles().catch(X=>{this.#r.warn(`[${s}] Failed to clean up local recording files: ${X instanceof Error?X.message:String(X)}`)})}catch(b){this.#r.warn(`[${s}] Failed to generate recording (non-critical): ${b instanceof Error?b.message:String(b)}`),this.#e.Sentry?.captureException(b,{level:"warning",tags:{component:"gif-generator",operation:"generateGifFromImages",subagent_type:s},extra:{sessionId:a.getSessionId(),frameCount:p.getFrameCount()}})}let x={success:!0,response:Q,metadata:l,sessionId:u,lastTurn:v};return c.resolve(x),x}catch(D){let v={success:!1,response:`Agent task failed: ${D instanceof Error?D.message:String(D)}`,metadata:{important_files:[]}};return c.resolve(v),v}finally{this.#Le.delete(A),r.signal?.removeEventListener("abort",y);try{await E()}catch(D){this.#r.warn(`[${s}] Cleanup failed: ${D instanceof Error?D.message:String(D)}`)}if(i.resetAfterRun&&o)try{await this.resetToCommitHash(o,!1)}catch(D){this.#r.warn(`[${s}] Failed to reset changes: ${D instanceof Error?D.message:String(D)}`)}}}getRunningSubAgents(){return Array.from(this.#Le.entries()).map(([e,r])=>({id:e,description:r.description,startedAt:r.startedAt}))}canHandleTool(e){return(this.#W.get(e)??0)>0}setProxyOrigin(e,r){if(e!==this.#Te||r!==this.#Me){this.#Te=e,this.#Me=r;let n=this.getProxyConfig();n.proxyDestination&&n.proxyDefaultOrigin&&this.queueSystemReminder({text:`The dev server is running at ${n.proxyDefaultOrigin}. e.g. for taking screenshots of a "/foo" route take a screenshot of ${n.proxyDefaultOrigin}/foo`,tag:"reminder:url"})}}async#or(e,r){let n=this.getProxyConfig();if(n.proxyOrigin&&!n.proxyDestination)return;let i=await sa(this.#a,"/codegen/get-browser-connection",{sessionId:e,projectId:this.#h,branchName:this.#y,proxyOrigin:n.proxyOrigin,proxyDefaultOrigin:n.proxyDefaultOrigin,proxyDst:n.proxyDestination},{signal:r,debug:this.#s});return typeof i?.wsUrl=="string"?i.wsUrl:void 0}getTurns(){let e=this.getSessionContext();return structuredClone(e.turns)}getSessionContext(){if(!this.#n)throw new Error("Session context not initialized");return this.#n}async runSetupCommand(){return await this.#d?.runSetupCommand()}abortSetupCommand(){return this.#d?.abortSetupCommand()}abortValidateCommand(){return this.#d?.abortValidateCommand()}toolsRunning(){return this.#Y.length>0}abortAllTools(){for(let e of this.#Y)e.abortController.abort()}toolFullfilment(e,r){return typeof r=="string"&&(r={toolResult:r,isError:!1}),this.fulfillToolCall(e,r)}cancelAllPendingToolFulfilments(e){for(let[r,n]of Array.from(this.#X.entries()))n.messageValid&&e?this.fulfillToolCall(r,{toolResult:"The user answered with a follow-up message (see the next user message in the conversation).",isError:!1,title:"Resolved by user message"}):this.fulfillToolCall(r,{toolResult:"Aborted by the user. So the task could not be completed.",isError:!0,title:"Aborted by the user."});this.#X.clear()}fulfillToolCall(e,r){let n=this.#X.get(e);return n?(n.resolve(r),this.#X.delete(e),!0):!1}abortToolCall(e,r){let n=this.#Y.find(o=>o.id===e),i=yn(r??"The user manually aborted the tool call.");if(n)return n.abortController.abort(i),!0;if(this.#Y.length===0){let o=new AbortController;return o.abort(i),this.#Y.push({id:e,abortController:o,input:{id:e},name:"bash"}),!0}return!1}async acceptCode(){if(this.#at()){let e=this.getLinesStats();await this.sendFeedback({position:this.#C,acceptedLines:e.net,linesOfCodeAdded:e.added,linesOfCodeRemoved:e.removed})}}async abort(e){this.#s&&this.#r.debug(`(abort): ${JSON.stringify(e)}`);let r=!1,n=!0;return typeof e=="boolean"?r=e:(r=e?.cleanCurrentMessage??!1,n=e?.flushMessageQueue??!0),r&&(this.#i=void 0,this.clearMessageQueue()),this.#ke=!n,this.cancelAllPendingToolFulfilments(),this.#ue=0,this.#c?(this.#c.abort(),this.#c=void 0,!0):!1}async stopEventLoop(){await this.abort({cleanCurrentMessage:!0}),this.#F?.abort(),this.#F=void 0,this.#o&&this.#o()}requestRefresh(){this.#g.emit("step",{type:"builder-action",action:"refresh",metadata:{}})}async configureDevOrchestrator(e){let r=this.#d,n={devCommand:!1,hosts:!1,setupCommand:!1,proxyServer:!1,validateCommand:!1,env:!1,fileOverrides:!1,setupResult:void 0,devResult:void 0,validateResult:void 0};if(r){let i=[];if(e.env&&(e.replaceEnvs&&(r.environmentVariables.length>0&&(n.env=!0),r.clearEnvVariables()),Object.entries(e.env).forEach(([o,s])=>{r.setEnvVariable(o,s??void 0)&&(n.env=!0)}),this.queueSystemReminder({text:`The system has the following environment variables:
1933
- ${Lye(r.environmentVariables)}`,tag:"reminder:environment-variables"})),e.proxyServer?i.push(r?.setProxyServer(e.proxyServer).then(o=>{n.proxyServer=o.updatedProxyServer,n.hosts=o.updatedHosts})):e.proxyPort&&i.push(r?.setPort(e.proxyPort).then(o=>n.proxyServer=o)),e.fileOverrides&&(n.fileOverrides=r.setFileOverrides(e.fileOverrides)),e.setupCommand!==void 0||e.setupDependencies!==void 0?i.push(r.setSetupCommand({setupDependencies:e.setupDependencies,setupCommand:e.setupCommand,forceRestart:e.forceSetupCommand}).then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})):(e.forceSetupCommand||n.fileOverrides||n.env&&r.setupState!=="installed")&&i.push(r?.runSetupCommand().then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})),e.devCommand!==void 0?i.push(r.setDevCommand(e.devCommand??void 0,e.forceDevCommand||n.env).then(o=>{n.devCommand=o.status==="success",n.devResult=o??void 0})):(e.forceDevCommand||n.env)&&i.push(r?.restart().then(o=>{n.devCommand=!0,n.devResult=o??void 0})),e.autoDetectDevServer!==void 0&&i.push(r.setAutoDetectSettings(e.autoDetectDevServer,e.autoDetectDevServerPatterns).then(o=>n.proxyServer=n.proxyServer||o)),e.validateCommand!==void 0&&i.push(r.runValidateCommand(e.validateCommand).then(o=>n.validateResult=o)),await Promise.allSettled(i),n.env){let o=!1;for(let s of this.#w.values())(s.state==="running"||s.state==="starting")&&(s.stale=!0,o=!0);o&&this.#pe()}}return n}#sr(){for(let e of Array.from(this.#w.keys()))try{this.disposeTerminal({terminalId:e})}catch{}this.#w.clear()}async#st(){if(this.#Q.debounceTimer&&clearTimeout(this.#Q.debounceTimer),this.#Q.pendingEvents=[],this.#Q.listeners.clear(),this.#Q.watcher){try{await this.#Q.watcher.close()}catch{}this.#Q.watcher=null}}#ar(){if(this.#Q.watcher)return;let e=this.#p.map(A=>A.path),r=new Map;for(let A of this.#p)r.set(A.path,pJ(A.path));let n=A=>{for(let c of this.#p)if(A.startsWith(c.path+"/")||A===c.path)return c.path;return null},i=A=>{let c=n(A);if(!c)return!1;let u=this.#e.relative(c,A).replace(/\\/g,"/");if(!u)return!1;if(this.#Pt(u))return!0;let l=r.get(c);return l?l(u):!1},o,s=!1;try{o=fye.default.watch(e,{ignored:i,ignoreInitial:!0,persistent:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:100},ignorePermissionErrors:!0,followSymlinks:!1,usePolling:!0,interval:1e3,binaryInterval:3e5,atomic:!0})}catch(A){this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch-init"}}),this.#r.error(`Failed to initialize file watcher: ${A instanceof Error?A.message:String(A)}`),this.#r.error("File watching will be disabled. Code generation will still work but may not detect all changes automatically.");return}let a=(A,c)=>{let u=n(c),l=u?this.#e.relative(u,c).replace(/\\/g,"/"):this.#e.relative(this.primaryGitPath,c).replace(/\\/g,"/");if(this.#p.length>1&&u){let g=this.#p.find(d=>d.path===u);g&&!this.#N()&&(l=`${g.folderName}/${l}`)}let p={type:"folder-watch",watchId:"global",event:A,path:l,timestamp:Date.now()};this.#Q.pendingEvents.push(p),this.#Q.debounceTimer&&clearTimeout(this.#Q.debounceTimer),this.#Q.debounceTimer=setTimeout(()=>{let g=this.#Q.pendingEvents;this.#Q.pendingEvents=[];for(let d of g)for(let f of this.#Q.listeners)try{f(d)}catch(h){this.#e.Sentry?.captureException(h)}},this.#Q.debounceMs)};o.on("add",A=>a("add",A)).on("change",A=>a("change",A)).on("unlink",A=>a("unlink",A)).on("addDir",A=>a("addDir",A)).on("unlinkDir",A=>a("unlinkDir",A)).on("error",A=>{s||(s=!0,this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch"}}),this.#r.error(`File watcher error: ${A instanceof Error?A.message:String(A)}`),this.#r.error("Closing file watcher to prevent further errors. File watching will be disabled."),this.#st().catch(()=>{}))}),this.#Q.watcher=o,this.#r.debug(`Initialized global file watcher on: ${e.join(", ")}`)}subscribeToFileChanges(e){return this.#Q.listeners.size===0&&this.#ar(),this.#Q.listeners.add(e),this.#r.debug(`Subscribed to file changes(${this.#Q.listeners.size} active listeners)`),async()=>{this.#Q.listeners.delete(e),this.#r.debug(`Unsubscribed from file changes(${this.#Q.listeners.size} remaining listeners)`),this.#Q.listeners.size===0&&this.#Q.watcher&&(await this.#st(),this.#r.debug("Closed global file watcher (no more listeners)"))}}async tsServerInit(){try{return this.#l?{ok:!0,cwd:this.#I}:(this.#l=new Fv(this.#I),this.#l.setEventHandler(e=>{for(let r of this.#Ue)r(e)}),await this.#l.start(),{ok:!0,cwd:this.#I})}catch(e){return this.#l=null,{ok:!1,error:e?.message||"Failed to start tsserver"}}}async tsServerOpenFile(e,r){this.#l&&await this.#l.openFile(e,r)}async tsServerChangeFile(e,r){this.#l&&await this.#l.changeFile(e,r)}async tsServerCloseFile(e){this.#l&&await this.#l.closeFile(e)}async tsServerGetCompletions(e,r,n,i){return this.#l?this.#l.getCompletions(e,r,n,i):{success:!1,body:null}}async tsServerGetCompletionDetails(e,r,n,i){return this.#l?this.#l.getCompletionDetails(e,r,n,i):{success:!1,body:null}}async tsServerGetDefinition(e,r,n){return this.#l?this.#l.getDefinition(e,r,n):{success:!1,body:null}}async tsServerGetTypeDefinition(e,r,n){return this.#l?this.#l.getTypeDefinition(e,r,n):{success:!1,body:null}}async tsServerGetQuickInfo(e,r,n){return this.#l?this.#l.getQuickInfo(e,r,n):{success:!1,body:null}}async tsServerGetReferences(e,r,n){return this.#l?this.#l.getReferences(e,r,n):{success:!1,body:null}}async tsServerGetSignatureHelp(e,r,n){return this.#l?this.#l.getSignatureHelp(e,r,n):{success:!1,body:null}}async tsServerRequestDiagnostics(e){this.#l&&await this.#l.requestDiagnostics(e)}async tsServerGetRenameLocations(e,r,n){return this.#l?this.#l.getRenameLocations(e,r,n):{success:!1,body:null}}async tsServerGetNavTree(e){return this.#l?this.#l.getNavTree(e):{success:!1,body:null}}async tsServerOrganizeImports(e){return this.#l?this.#l.organizeImports(e):{success:!1,body:null}}async tsServerGetInlayHints(e){return this.#l?this.#l.getInlayHints(e):{success:!1,body:null}}async tsServerGetCodeFixes(e,r,n,i,o,s){return this.#l?this.#l.getCodeFixes(e,r,n,i,o,s):{success:!1,body:null}}async tsServerGetApplicableRefactors(e,r,n,i,o){return this.#l?this.#l.getApplicableRefactors(e,r,n,i,o):{success:!1,body:null}}async tsServerGetEditsForRefactor(e,r,n,i,o,s,a){return this.#l?this.#l.getEditsForRefactor(e,r,n,i,o,s,a):{success:!1,body:null}}async tsServerGetImplementation(e,r,n){return this.#l?this.#l.getImplementation(e,r,n):{success:!1,body:null}}async tsServerGetSelectionRange(e,r){return this.#l?this.#l.getSelectionRange(e,r):{success:!1,body:null}}async tsServerGetLinkedEditingRange(e,r,n){return this.#l?this.#l.getLinkedEditingRange(e,r,n):{success:!1,body:null}}async tsServerGetFormatRange(e,r,n,i,o){return this.#l?this.#l.getFormatRange(e,r,n,i,o):{success:!1,body:null}}subscribeToDiagnostics(e){return this.#Ue.add(e),()=>{this.#Ue.delete(e)}}async close(e=!1){if(!this.#Ne){if(this.#Ne=!0,this.#f&&(delete process.env.DEBUG,this.#f=!1),this.#Fe.forEach(r=>r()),this.#sr(),await this.#st(),this.#l&&(this.#l.dispose(),this.#l=null),this.#Ue.clear(),this.#Ee)try{this.#r.debug("Cleaning up local MCP servers"),await this.#Ee.cleanup()}catch(r){this.#e.Sentry?.captureException(r,{level:"warning",tags:{operation:"local-mcp-cleanup"}})}if(await this.stopEventLoop(),await this.waitUntilState("close",5e3),this.#g.removeAllListeners(),await Promise.allSettled(this.#le),e){let r=await this.needsBackup();this.#s&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e,needsBackup:r})}`),r&&await this.uploadBackup()}else this.#s&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e})}`)}}async#S(){if(!this.#m||this.#p.length===0)return null;let r=(await this.#J(async i=>this.#cr(i))).results.filter(i=>i.success&&i.result).map(i=>i.result);if(r.length===0)return null;for(let i of r)this.#g.emit("step",i);return this.#ie=r,this.#K(this.#Ar(r),"updateBranchUnpushedStatus",!1),r.some(i=>i.hasMergeConflict)&&await this.#fe(),r[0]}async#Ar(e){if(!this.#h||!this.#y||!this.#a.builderPublicKey||!this.#a.userId||!this.#a.builderPrivateKey)return;let r=e.some(n=>n.ahead>0||n.isSessionDirty);try{let n=new URL("/projects/branches",Oe);n.searchParams.set("apiKey",this.#a.builderPublicKey),n.searchParams.set("userId",this.#a.userId),n.searchParams.set("projectId",this.#h),n.searchParams.set("branchName",this.#y);let i=await Ue(n,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#a.builderPrivateKey}`},body:JSON.stringify({hasUnpushedChanges:r}),signal:AbortSignal.timeout(1e4)},this.#s);i.ok||this.#r.error(`Failed to update branch unpushed status: ${i.status} ${i.statusText}`,{loggerOptions:{debug:!0}})}catch(n){this.#r.error("Failed to update branch unpushed status:",n,{loggerOptions:{debug:!0}})}}async sendMessageToOrgAgent(e){try{let r=new URL("/projects/org-agent/send-message",Oe);this.#a.builderPublicKey&&r.searchParams.set("apiKey",this.#a.builderPublicKey),this.#a.userId&&r.searchParams.set("userId",this.#a.userId);let n=await Ue(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#a.builderPrivateKey}`},body:JSON.stringify(e),signal:AbortSignal.timeout(1e4)},this.#s),i=await n.json();return n.ok?{status:"success"}:{status:"error",error:i.error??`HTTP ${n.status}`}}catch(r){return{status:"error",error:r?.message??"Unknown error"}}}queueGitStatusReminder(e){if(this.#ie.length===0||this.#re||this.#M!=="quality-v4")return;let r=this.#ie.map(n=>Uye(n,this.gitEnabledFolders,e));this.queueSystemReminder({text:r.join(`
1932
+ ${Q}`}}this.#st({gif_id:l.gif_id,gif_frames:_,timeline_id:L,recording_id:l.recording_id},!1),l.recording_id&&p.cleanupSessionFiles().catch(X=>{this.#r.warn(`[${s}] Failed to clean up local recording files: ${X instanceof Error?X.message:String(X)}`)})}catch(b){this.#r.warn(`[${s}] Failed to generate recording (non-critical): ${b instanceof Error?b.message:String(b)}`),this.#e.Sentry?.captureException(b,{level:"warning",tags:{component:"gif-generator",operation:"generateGifFromImages",subagent_type:s},extra:{sessionId:a.getSessionId(),frameCount:p.getFrameCount()}})}let x={success:!0,response:Q,metadata:l,sessionId:u,lastTurn:v};return c.resolve(x),x}catch(D){let v={success:!1,response:`Agent task failed: ${D instanceof Error?D.message:String(D)}`,metadata:{important_files:[]}};return c.resolve(v),v}finally{this.#Le.delete(A),r.signal?.removeEventListener("abort",y);try{await E()}catch(D){this.#r.warn(`[${s}] Cleanup failed: ${D instanceof Error?D.message:String(D)}`)}if(i.resetAfterRun&&o)try{await this.resetToCommitHash(o,!1)}catch(D){this.#r.warn(`[${s}] Failed to reset changes: ${D instanceof Error?D.message:String(D)}`)}}}getRunningSubAgents(){return Array.from(this.#Le.entries()).map(([e,r])=>({id:e,description:r.description,startedAt:r.startedAt}))}canHandleTool(e){return(this.#W.get(e)??0)>0}setProxyOrigin(e,r){if(e!==this.#Te||r!==this.#Me){this.#Te=e,this.#Me=r;let n=this.getProxyConfig();n.proxyDestination&&n.proxyDefaultOrigin&&this.queueSystemReminder({text:`The dev server is running at ${n.proxyDefaultOrigin}. e.g. for taking screenshots of a "/foo" route take a screenshot of ${n.proxyDefaultOrigin}/foo`,tag:"reminder:url"})}}async#or(e,r){let n=this.getProxyConfig();if(n.proxyOrigin&&!n.proxyDestination)return;let i=await sa(this.#a,"/codegen/get-browser-connection",{sessionId:e,projectId:this.#h,branchName:this.#y,proxyOrigin:n.proxyOrigin,proxyDefaultOrigin:n.proxyDefaultOrigin,proxyDst:n.proxyDestination},{signal:r,debug:this.#s});return typeof i?.wsUrl=="string"?i.wsUrl:void 0}getTurns(){let e=this.getSessionContext();return structuredClone(e.turns)}getSessionContext(){if(!this.#n)throw new Error("Session context not initialized");return this.#n}async runSetupCommand(){return await this.#d?.runSetupCommand()}abortSetupCommand(){return this.#d?.abortSetupCommand()}abortValidateCommand(){return this.#d?.abortValidateCommand()}toolsRunning(){return this.#Y.length>0}abortAllTools(){for(let e of this.#Y)e.abortController.abort()}toolFullfilment(e,r){return typeof r=="string"&&(r={toolResult:r,isError:!1}),this.fulfillToolCall(e,r)}cancelAllPendingToolFulfilments(e){for(let[r,n]of Array.from(this.#X.entries()))n.messageValid&&e?this.fulfillToolCall(r,{toolResult:"The user answered with a follow-up message (see the next user message in the conversation).",isError:!1,title:"Resolved by user message"}):this.fulfillToolCall(r,{toolResult:"Aborted by the user. So the task could not be completed.",isError:!0,title:"Aborted by the user."});this.#X.clear()}fulfillToolCall(e,r){let n=this.#X.get(e);return n?(n.resolve(r),this.#X.delete(e),!0):!1}abortToolCall(e,r){let n=this.#Y.find(o=>o.id===e),i=yn(r??"The user manually aborted the tool call.");if(n)return n.abortController.abort(i),!0;if(this.#Y.length===0){let o=new AbortController;return o.abort(i),this.#Y.push({id:e,abortController:o,input:{id:e},name:"bash"}),!0}return!1}async acceptCode(){if(this.#At()){let e=this.getLinesStats();await this.sendFeedback({position:this.#C,acceptedLines:e.net,linesOfCodeAdded:e.added,linesOfCodeRemoved:e.removed})}}async abort(e){this.#s&&this.#r.debug(`(abort): ${JSON.stringify(e)}`);let r=!1,n=!0;return typeof e=="boolean"?r=e:(r=e?.cleanCurrentMessage??!1,n=e?.flushMessageQueue??!0),r&&(this.#i=void 0,this.clearMessageQueue()),this.#ke=!n,this.cancelAllPendingToolFulfilments(),this.#ue=0,this.#c?(this.#c.abort(),this.#c=void 0,!0):!1}async stopEventLoop(){await this.abort({cleanCurrentMessage:!0}),this.#F?.abort(),this.#F=void 0,this.#o&&this.#o()}requestRefresh(){this.#g.emit("step",{type:"builder-action",action:"refresh",metadata:{}})}async configureDevOrchestrator(e){let r=this.#d,n={devCommand:!1,hosts:!1,setupCommand:!1,proxyServer:!1,validateCommand:!1,env:!1,fileOverrides:!1,setupResult:void 0,devResult:void 0,validateResult:void 0};if(r){let i=[];if(e.env&&(e.replaceEnvs&&(r.environmentVariables.length>0&&(n.env=!0),r.clearEnvVariables()),Object.entries(e.env).forEach(([o,s])=>{r.setEnvVariable(o,s??void 0)&&(n.env=!0)}),this.queueSystemReminder({text:`The system has the following environment variables:
1933
+ ${Lye(r.environmentVariables)}`,tag:"reminder:environment-variables"})),e.proxyServer?i.push(r?.setProxyServer(e.proxyServer).then(o=>{n.proxyServer=o.updatedProxyServer,n.hosts=o.updatedHosts})):e.proxyPort&&i.push(r?.setPort(e.proxyPort).then(o=>n.proxyServer=o)),e.fileOverrides&&(n.fileOverrides=r.setFileOverrides(e.fileOverrides)),e.setupCommand!==void 0||e.setupDependencies!==void 0?i.push(r.setSetupCommand({setupDependencies:e.setupDependencies,setupCommand:e.setupCommand,forceRestart:e.forceSetupCommand}).then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})):(e.forceSetupCommand||n.fileOverrides||n.env&&r.setupState!=="installed")&&i.push(r?.runSetupCommand().then(o=>{n.setupCommand=!!o,n.setupResult=o??void 0})),e.devCommand!==void 0?i.push(r.setDevCommand(e.devCommand??void 0,e.forceDevCommand||n.env).then(o=>{n.devCommand=o.status==="success",n.devResult=o??void 0})):(e.forceDevCommand||n.env)&&i.push(r?.restart().then(o=>{n.devCommand=!0,n.devResult=o??void 0})),e.autoDetectDevServer!==void 0&&i.push(r.setAutoDetectSettings(e.autoDetectDevServer,e.autoDetectDevServerPatterns).then(o=>n.proxyServer=n.proxyServer||o)),e.validateCommand!==void 0&&i.push(r.runValidateCommand(e.validateCommand).then(o=>n.validateResult=o)),await Promise.allSettled(i),n.env){let o=!1;for(let s of this.#w.values())(s.state==="running"||s.state==="starting")&&(s.stale=!0,o=!0);o&&this.#pe()}}return n}#sr(){for(let e of Array.from(this.#w.keys()))try{this.disposeTerminal({terminalId:e})}catch{}this.#w.clear()}async#at(){if(this.#Q.debounceTimer&&clearTimeout(this.#Q.debounceTimer),this.#Q.pendingEvents=[],this.#Q.listeners.clear(),this.#Q.watcher){try{await this.#Q.watcher.close()}catch{}this.#Q.watcher=null}}#ar(){if(this.#Q.watcher)return;let e=this.#p.map(A=>A.path),r=new Map;for(let A of this.#p)r.set(A.path,pJ(A.path));let n=A=>{for(let c of this.#p)if(A.startsWith(c.path+"/")||A===c.path)return c.path;return null},i=A=>{let c=n(A);if(!c)return!1;let u=this.#e.relative(c,A).replace(/\\/g,"/");if(!u)return!1;if(this.#Pt(u))return!0;let l=r.get(c);return l?l(u):!1},o,s=!1;try{o=fye.default.watch(e,{ignored:i,ignoreInitial:!0,persistent:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:100},ignorePermissionErrors:!0,followSymlinks:!1,usePolling:!0,interval:1e3,binaryInterval:3e5,atomic:!0})}catch(A){this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch-init"}}),this.#r.error(`Failed to initialize file watcher: ${A instanceof Error?A.message:String(A)}`),this.#r.error("File watching will be disabled. Code generation will still work but may not detect all changes automatically.");return}let a=(A,c)=>{let u=n(c),l=u?this.#e.relative(u,c).replace(/\\/g,"/"):this.#e.relative(this.primaryGitPath,c).replace(/\\/g,"/");if(this.#p.length>1&&u){let g=this.#p.find(d=>d.path===u);g&&!this.#N()&&(l=`${g.folderName}/${l}`)}let p={type:"folder-watch",watchId:"global",event:A,path:l,timestamp:Date.now()};this.#Q.pendingEvents.push(p),this.#Q.debounceTimer&&clearTimeout(this.#Q.debounceTimer),this.#Q.debounceTimer=setTimeout(()=>{let g=this.#Q.pendingEvents;this.#Q.pendingEvents=[];for(let d of g)for(let f of this.#Q.listeners)try{f(d)}catch(h){this.#e.Sentry?.captureException(h)}},this.#Q.debounceMs)};o.on("add",A=>a("add",A)).on("change",A=>a("change",A)).on("unlink",A=>a("unlink",A)).on("addDir",A=>a("addDir",A)).on("unlinkDir",A=>a("unlinkDir",A)).on("error",A=>{s||(s=!0,this.#e.Sentry?.captureException(A,{tags:{operation:"global-file-watch"}}),this.#r.error(`File watcher error: ${A instanceof Error?A.message:String(A)}`),this.#r.error("Closing file watcher to prevent further errors. File watching will be disabled."),this.#at().catch(()=>{}))}),this.#Q.watcher=o,this.#r.debug(`Initialized global file watcher on: ${e.join(", ")}`)}subscribeToFileChanges(e){return this.#Q.listeners.size===0&&this.#ar(),this.#Q.listeners.add(e),this.#r.debug(`Subscribed to file changes(${this.#Q.listeners.size} active listeners)`),async()=>{this.#Q.listeners.delete(e),this.#r.debug(`Unsubscribed from file changes(${this.#Q.listeners.size} remaining listeners)`),this.#Q.listeners.size===0&&this.#Q.watcher&&(await this.#at(),this.#r.debug("Closed global file watcher (no more listeners)"))}}async tsServerInit(){try{return this.#l?{ok:!0,cwd:this.#I}:(this.#l=new Fv(this.#I),this.#l.setEventHandler(e=>{for(let r of this.#Ue)r(e)}),await this.#l.start(),{ok:!0,cwd:this.#I})}catch(e){return this.#l=null,{ok:!1,error:e?.message||"Failed to start tsserver"}}}async tsServerOpenFile(e,r){this.#l&&await this.#l.openFile(e,r)}async tsServerChangeFile(e,r){this.#l&&await this.#l.changeFile(e,r)}async tsServerCloseFile(e){this.#l&&await this.#l.closeFile(e)}async tsServerGetCompletions(e,r,n,i){return this.#l?this.#l.getCompletions(e,r,n,i):{success:!1,body:null}}async tsServerGetCompletionDetails(e,r,n,i){return this.#l?this.#l.getCompletionDetails(e,r,n,i):{success:!1,body:null}}async tsServerGetDefinition(e,r,n){return this.#l?this.#l.getDefinition(e,r,n):{success:!1,body:null}}async tsServerGetTypeDefinition(e,r,n){return this.#l?this.#l.getTypeDefinition(e,r,n):{success:!1,body:null}}async tsServerGetQuickInfo(e,r,n){return this.#l?this.#l.getQuickInfo(e,r,n):{success:!1,body:null}}async tsServerGetReferences(e,r,n){return this.#l?this.#l.getReferences(e,r,n):{success:!1,body:null}}async tsServerGetSignatureHelp(e,r,n){return this.#l?this.#l.getSignatureHelp(e,r,n):{success:!1,body:null}}async tsServerRequestDiagnostics(e){this.#l&&await this.#l.requestDiagnostics(e)}async tsServerGetRenameLocations(e,r,n){return this.#l?this.#l.getRenameLocations(e,r,n):{success:!1,body:null}}async tsServerGetNavTree(e){return this.#l?this.#l.getNavTree(e):{success:!1,body:null}}async tsServerOrganizeImports(e){return this.#l?this.#l.organizeImports(e):{success:!1,body:null}}async tsServerGetInlayHints(e){return this.#l?this.#l.getInlayHints(e):{success:!1,body:null}}async tsServerGetCodeFixes(e,r,n,i,o,s){return this.#l?this.#l.getCodeFixes(e,r,n,i,o,s):{success:!1,body:null}}async tsServerGetApplicableRefactors(e,r,n,i,o){return this.#l?this.#l.getApplicableRefactors(e,r,n,i,o):{success:!1,body:null}}async tsServerGetEditsForRefactor(e,r,n,i,o,s,a){return this.#l?this.#l.getEditsForRefactor(e,r,n,i,o,s,a):{success:!1,body:null}}async tsServerGetImplementation(e,r,n){return this.#l?this.#l.getImplementation(e,r,n):{success:!1,body:null}}async tsServerGetSelectionRange(e,r){return this.#l?this.#l.getSelectionRange(e,r):{success:!1,body:null}}async tsServerGetLinkedEditingRange(e,r,n){return this.#l?this.#l.getLinkedEditingRange(e,r,n):{success:!1,body:null}}async tsServerGetFormatRange(e,r,n,i,o){return this.#l?this.#l.getFormatRange(e,r,n,i,o):{success:!1,body:null}}subscribeToDiagnostics(e){return this.#Ue.add(e),()=>{this.#Ue.delete(e)}}async close(e=!1){if(!this.#Ne){if(this.#Ne=!0,this.#f&&(delete process.env.DEBUG,this.#f=!1),this.#Fe.forEach(r=>r()),this.#sr(),await this.#at(),this.#l&&(this.#l.dispose(),this.#l=null),this.#Ue.clear(),this.#Ee)try{this.#r.debug("Cleaning up local MCP servers"),await this.#Ee.cleanup()}catch(r){this.#e.Sentry?.captureException(r,{level:"warning",tags:{operation:"local-mcp-cleanup"}})}if(await this.stopEventLoop(),await this.waitUntilState("close",5e3),this.#g.removeAllListeners(),await Promise.allSettled(this.#le),e){let r=await this.needsBackup();this.#s&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e,needsBackup:r})}`),r&&await this.uploadBackup()}else this.#s&&this.#r.debug(`Closing code gen server: ${JSON.stringify({uploadGitBackup:e})}`)}}async#S(){if(!this.#m||this.#p.length===0)return null;let r=(await this.#J(async i=>this.#cr(i))).results.filter(i=>i.success&&i.result).map(i=>i.result);if(r.length===0)return null;for(let i of r)this.#g.emit("step",i);return this.#ie=r,this.#K(this.#Ar(r),"updateBranchUnpushedStatus",!1),r.some(i=>i.hasMergeConflict)&&await this.#fe(),r[0]}async#Ar(e){if(!this.#h||!this.#y||!this.#a.builderPublicKey||!this.#a.userId||!this.#a.builderPrivateKey)return;let r=e.some(n=>n.ahead>0||n.isSessionDirty);try{let n=new URL("/projects/branches",Oe);n.searchParams.set("apiKey",this.#a.builderPublicKey),n.searchParams.set("userId",this.#a.userId),n.searchParams.set("projectId",this.#h),n.searchParams.set("branchName",this.#y);let i=await Ue(n,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#a.builderPrivateKey}`},body:JSON.stringify({hasUnpushedChanges:r}),signal:AbortSignal.timeout(1e4)},this.#s);i.ok||this.#r.error(`Failed to update branch unpushed status: ${i.status} ${i.statusText}`,{loggerOptions:{debug:!0}})}catch(n){this.#r.error("Failed to update branch unpushed status:",n,{loggerOptions:{debug:!0}})}}async sendMessageToOrgAgent(e){try{let r=new URL("/projects/org-agent/send-message",Oe);this.#a.builderPublicKey&&r.searchParams.set("apiKey",this.#a.builderPublicKey),this.#a.userId&&r.searchParams.set("userId",this.#a.userId);let n=await Ue(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#a.builderPrivateKey}`},body:JSON.stringify(e),signal:AbortSignal.timeout(1e4)},this.#s),i=await n.json();return n.ok?{status:"success"}:{status:"error",error:i.error??`HTTP ${n.status}`}}catch(r){return{status:"error",error:r?.message??"Unknown error"}}}queueGitStatusReminder(e){if(this.#ie.length===0||this.#re||this.#M!=="quality-v4")return;let r=this.#ie.map(n=>Uye(n,this.gitEnabledFolders,e));this.queueSystemReminder({text:r.join(`
1934
1934
 
1935
- `),tag:"reminder:git-status"})}async manualCommit(e){if(!this.#m)return!1;let r=this.getSessionContext();if(!r.beforeCommit){let n=await this.#O();Object.keys(n).length>0&&(r.beforeCommit=$s(n))}return await this.commitWorkInProgress(e.commitMessage,[e.add]),await this.#ne(!0),!0}getLastSuggestedAction(){return this.#se}async#fe(){let e=this.getSessionContext();if(e.state==="generating"||e.state==="close")return this.#se=void 0,!1;let r=await this.#et(!0,"all");return e=this.getSessionContext(),e.state!=="generating"&&e.state!=="close"?(this.#se=r,this.#g.emit("step",{type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:e.state,suggestion:r,sessionMode:e.sessionMode,hasPlanToApply:this.#k,modelOverride:this.#_}),!0):!1}async#cr(e){if(!this.#m)return null;this.#Be++;try{let r=this.getCommitMode(),n=this.getFeatureBranch(),i=this.#ge(e),o=e.path,s=e.folderName===this.#p[0]?.folderName,a=this.getSessionContext(),A=!1,c=!1,u="",l=null;try{let E=await this.git(["rev-parse","--absolute-git-dir"],{cwd:o});l=this.#e.join(E.trim(),"FETCH_HEAD"),Zl.default.existsSync(l)&&Zl.default.unlinkSync(l)}catch(E){this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchHeadFilePath:l,isCheckingGitStatus:this.#Be,folderName:e.folderName}}),l=null}try{u=await this.git(["fetch","--no-tags","origin",i],{cwd:o}),A=!0}catch{A=!1}let p=await this.#e.getRepoInfo(o),g=yl(a.beforeCommit,e.folderName,this.gitRepoContexts[0]?.folderName);!s&&!e.initialCommit&&p.commit&&(e.initialCommit=p.commit),!g&&e.initialCommit&&(g=e.initialCommit);let d=this.#at(e.folderName),f=d?1:0,h=0;if(A){if(n!==i)try{await this.git(["--no-pager","diff","--quiet",`refs/remotes/origin/${n}...refs/remotes/origin/${i}`],{cwd:o}),c=!1}catch{c=!0}else c=!0;try{let E=Rye(await this.git(["rev-list","--left-right","--count","HEAD...FETCH_HEAD"],{cwd:o}));f=E.ahead,h=E.behind}catch(E){let y=null;if(l)try{y=await this.#e.readFile(this.#e.join(o,".git/FETCH_HEAD")),y=`FETCH_HEAD: ${y} `}catch(D){y=`FETCH_HEAD FAILED: ${String(D)} `}else y="FETCH_HEAD MISSING";this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchOutput:u,fetchHead:y,remoteBranch:i,currentBranch:p.currentBranch,currentCommit:p.commit,isCheckingGitStatus:this.#Be,folderName:e.folderName}})}}else!A&&r!=="commits"&&g&&g!==p.commit&&(f=Math.max(f,1));let C=await this.#V(o),I=C.length>0,B=await this.#Cr(o);return{type:"git",folderName:e.folderName,remoteBranchExists:A,remoteBranchHasChanges:c,hasGeneratingPlaceholder:await this.#mr(),isSessionDirty:d||!!g&&g!==p.commit,canSync:(f>0||h>0||B)&&!I,canPush:(f>0||h>0)&&!I,hasStagedChanges:B,canPull:h>0&&A,ahead:f,hasMergeConflict:I,commitMode:r,behind:h,currentCommit:p.commit,currentBranch:p.currentBranch,pendingValidation:this.#ee,remoteBranch:i,unmergedFiles:C}}finally{this.#Be--}}#Nt(){let e=this.getSessionContext();return{type:"session",title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:e.turns.length,id:e.sessionId,lastCompletionId:this.getLastCompletionId(),sessionMode:e.sessionMode,fusionConfig:dv(this.#u),hasBrowserAutomation:e.customAgents.some(r=>r.name==="browser-testing"),customInstructions:e.customInstructions.filter(r=>!r.hideUI).map(r=>({name:r.name,description:r.description??"",type:r.type??"always",glob:r.glob,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,userInvocable:r.userInvocable})),hasPlanToApply:this.#k}}#Tt(){let r=this.getSessionContext().turns,n=[];n.push(this.#Nt()),Object.keys(this.#U).length>0&&n.push({type:"metadata",...this.#U}),this.#t.length>0&&n.push({type:"message-queue",queue:this.#t.map(i=>({idempotencyKey:i.idempotencyKey,displayPrompt:i.displayPrompt,user:i.user}))});for(let i of r){n.push({type:"user",displayPrompt:i.userMessage?i.userMessage.displayPrompt??i.userMessage.userPrompt:void 0,attachments:i.userMessage?.attachments,id:i.completionId,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.userMessage?.idempotencyKey??""});for(let o of i.actions)if(o.type==="tool"||o.type==="text"||o.type==="thinking")if(n.push({type:"start",name:o.type,content:"",id:o.id??"",filePath:o.filePath??"",title:o.actionTitle??o.artifactTitle??o.filePath??""}),n.push({type:"delta",name:o.type,delta:o.content}),o.type==="tool"){if(n.push({type:o.type,id:o.id,name:o.filePath,content:o.content}),o.filePath==="UpdateSetupValue"||o.filePath==="ProposeConfig")try{let s=JSON.parse(o.content);if(o.filePath==="UpdateSetupValue")n.push({type:"update_setup_value",field:s.field,value:s.value,reason:s.reason});else{let a=s.config,A=a!=null&&!a.installCommand?.command&&(!a.runtimeDependencies||a.runtimeDependencies.length===0);n.push({type:"propose_config",config:a,message:s.message,noDependencies:A})}}catch{}}else o.type==="thinking"?n.push({type:"thinking",content:o.content}):o.type==="text"&&n.push({type:"text",content:o.content})}return n}connectToEventLoop(e,r,n){let i=n?.canHandleTools??[];if(e){let o=[],s=this.getSessionContext();o.push({type:"state",newState:"replay",abortable:!1,previousState:s.state}),this.#He&&o.push(this.#He),o.push(...this.#ie),o.push(...this.#Tt()),this.#X.forEach(c=>{o.push({type:"tool-call-request",id:c.id,name:c.name,input:c.input})});let a=this.#Ie?sc(this.#Ie):void 0;if(a)switch(a.type){case"file":case"diff":case"text":case"thinking":case"suggestion":case"tool":o.push({type:"start",id:a.id,name:a.type,filePath:a.filePath??"",title:a.actionTitle??a.artifactTitle??"",content:""}),o.push({type:"delta",name:a.type,delta:a.content});break}o.push({type:"terminals",terminals:this.#nt()});let A=this.#d;A?(o.push({type:"dev-server",devServerState:A.devState,setupState:A.setupState,httpServerState:A.httpServerState.state,devCommand:A.devCommand,setupCommand:A.setupCommand,proxyServer:A.proxyTarget,proxyServerSelection:A.proxyServerSelection,remoteAddress:A.httpServerState.remoteAddress,remotePort:A.httpServerState.remotePort,proxyServerReachable:!!this.#u?.isLocal,validateState:A.validateCommandState}),A.setupState!=="installed"&&o.push({type:"stdio",id:"setupCommand",command:A.setupCommand??"",content:A.getSetupWrite(),source:"run-command",stream:"stdout"}),o.push({type:"stdio",id:"devServer",command:A.devCommand,content:A.getDevWrite(),source:"run-command",stream:"stdout"})):r({type:"dev-server",devServerState:"running",setupState:"installed",httpServerState:"ok-2xx",devCommand:this.#u?.devCommand,setupCommand:this.#u?.setupCommand,proxyServer:this.#u?.serverUrl,proxyServerSelection:"hardcoded",remoteAddress:void 0,remotePort:void 0,proxyServerReachable:!!this.#u?.isLocal,validateState:"unset"}),o.push({type:"state",newState:s.state,abortable:s.state==="generating",previousState:"replay"}),this.#oe&&s.state!=="generating"&&o.push({type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:s.state,suggestion:this.#se,sessionMode:s.sessionMode,hasPlanToApply:this.#k}),r({type:"batch",steps:o})}this.#g.on("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)+1);return this.waitForEventLoop(),()=>{this.#g.off("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)-1)}}waitUntilPendingPromises(e){let r=eA();return this.#r.debug(`(waitUntilPendingPromises-${r}): started`),Yc(Promise.allSettled(this.#le),e).then(()=>Bl()).then(()=>{this.#r.debug(`(waitUntilPendingPromises-${r}): finished`)})}waitUntilBlockingPendingPromises(e){let r=eA();return this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): started`),Yc(Promise.allSettled(this.#_e),e).then(()=>Bl()).then(()=>{this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): finished`)})}waitUntilIdle(e){let r=eA();return this.waitForEventLoop(),this.#r.debug(`(waitUntilIdle-${r}): started`),Yc(Bl().then(()=>this.waitUntilPendingPromises()).then(()=>{let n=this.getSessionContext();return this.#r.debug(`(waitUntilIdle-${r}): starting in ${n.state} `),n.state==="generating"?(0,EF.once)(this.#g,"idle"):Promise.resolve(void 0)}).then(()=>this.waitUntilPendingPromises()).then(()=>{this.#r.debug(`(waitUntilIdle-${r}): idle reached in ${this.getSessionContext().state} `)}),e)}async#Mt(e){let r=this.#d;if(!r)throw new Error("Dev server not found");let n=await r.runValidateCommand(void 0,e);return n.status==="success"&&(this.#ee=!1,this.#m&&(await this.#rt()).length===0&&(await this.#At()||await this.manualCommit({add:".",commitMessage:"Validate command fixes"}))),n}waitForEventLoop(){return this.#oe?this.#oe:this.#oe=this.#ur()}async#ur(){if(this.#oe||this.#F)throw new Error("Event loop already started");this.#r.debug("(eventLoop): started");let e=kye(),r=c=>{if(c.type==="error"&&this.#ue>0&&(dye.includes(c.code)||(c.restoreCredits=this.#ue,this.#ue=0,Dye(this.#e,this.#a,o.sessionId,c.restoreCredits).catch(u=>{this.#e.Sentry?.captureException(u)}))),c.type==="tool_result"&&(c.result.tool_name==="ExitPlanMode"||c.result.tool_name==="TodoWrite")&&(this.#r.debug("emitting ClientDevtoolsToolResultV1",{toolName:c.result.tool_name,projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:kce,extraData:{toolUseId:c.result.tool_use_id,toolName:c.result.tool_name??"",result:c.result.content,isError:c.result.is_error,sessionId:o.sessionId,projectId:this.#h,branchName:this.#y},extraAttributes:{toolName:c.result.tool_name??"",projectId:this.#h,branchName:this.#y}},{debug:this.#s})),c.type==="tool"&&c.name==="Agent"){let u;try{u=JSON.parse(c.content)?.description}catch{}let l=JSON.stringify({description:u});this.#r.debug("emitting ClientDevtoolsToolCallV1",{toolName:c.name,projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:Fce,extraData:{toolUseId:c.id,toolName:c.name,content:l,sessionId:o.sessionId,projectId:this.#h,branchName:this.#y},extraAttributes:{toolName:c.name,projectId:this.#h,branchName:this.#y}},{debug:this.#s})}this.#g.emit("step",c)};this.#F=new AbortController;let n=this.#F.signal,i=this.#d,o=this.getSessionContext(),s=()=>this.getLastCompletionId();this.#e.Sentry?.setContext("codeGen",{sessionId:o.sessionId,get completionId(){return s()}}),await this.#K(this.#S(),"initial-emitGitStatus");let a=setInterval(()=>{this.canHandleTool("GetScreenshot")&&(this.#Be>0||this.#S().catch(()=>{}))},6e4),A=()=>clearInterval(a);if(this.#Fe.push(A),process.env.FUSION_IDE_PORT){let c=setInterval(()=>{aue().then(u=>{let l=JSON.stringify(u);l!==this.#ut&&(this.#ut=l,this.#g.emit("step",{type:"ide",context:u}),this.queueSystemReminder({text:u?cue(u):"",tag:"reminder:ide-context"}))}).catch(()=>{})},1e3);this.#Fe.push(()=>clearInterval(c))}this.queueGitStatusReminder({trigger:"session-start"}),i?.setupState==="not-installed"&&this.runSetupCommand();try{let c=0;for(;!n.aborted;){c++,this.#c=void 0;let u=this.#ir();if(this.#r.debug(`(eventLoop-${c}): started (shouldWait: ${u.shouldWait})`),u.shouldWait){await this.#kt();let g=await this.#fe();if(n.aborted)break;g&&Mye(u.promise,500).then(d=>{d&&(this.#r.debug(`(eventLoop-${c}): emitting idle on next message wait`),this.#g.emit("idle"))})}let l=await u.promise;if(n.aborted)break;if(!l)continue;this.#c=new AbortController;let p=qn([n,this.#c.signal]);try{if(this.#se=void 0,l.logsCheckpoint&&i?.addCheckpoint(),p?.aborted)throw yn(p.reason);this.#j("generating"),i?.abortValidateCommand(),l.syncChanges&&(this.#r.debug(`(eventLoop-${c}): syncing changes from remote`),await this.syncChangesFromRemote(l.syncChanges),await this.#et(!1,"critical")),l.sessionMode&&l.sessionMode!==o.sessionMode&&this.switchSessionMode(l.sessionMode),await this.#lr(l,p,r),this.#j("success");let g=l.autoPush??this.#me??"none";if(g!=="none"&&this.#m&&(this.#r.debug(`(eventLoop-${c}): autoPush: ${g}`),await this.waitUntilBlockingPendingPromises(),(await this.#rt()).length===0)){let f=(()=>{switch(g){case"force-push":return{actor:"agent",forcePush:!0,pullFirst:!1};case"merge-push":return{actor:"agent",pullFirst:!0,forcePush:!1};case"ff-push":return{actor:"agent",requireFastForward:!0,pullFirst:!1};case"safe-push":return{actor:"agent",pullFirst:!0,abortOnMergeConflict:!0};default:return{actor:"agent"}}})();if(this.#p.length>1)for(let h of this.#p)await this.#xe({...f,folderName:h.folderName});else await this.#xe(f)}this.#se=void 0}catch(g){g instanceof Error?g.name==="AbortError"?(r({type:"user-abort",hasContinueMessage:this.#t.length>0}),this.#j("abort")):g instanceof We?(this.#i=void 0,r({type:"error",code:"cli-network-error",message:g.message}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):g instanceof $t?(this.#i=void 0,r({type:"error",code:"unknown",message:"An internal error occurred. Please try again."}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):g instanceof Bi?(this.#i=void 0,r({type:"error",code:g.code,message:g.message}),dye.includes(g.code)||this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):(this.#i=void 0,r({type:"error",code:"cli-genetic-error",message:g.message,metadata:{error:g}}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):this.#j("error")}this.#_t++}}catch(c){throw this.#e.Sentry?.captureException(c,{level:"fatal"}),c}finally{A(),this.#F=void 0,this.#oe=void 0,e()}this.#r.debug("(eventLoop): emitting idle on close"),this.#g.emit("idle"),this.#j("close")}async#lr(e,r,n){this.#ue=0,this.#ee=!1;let i=this.getSessionContext(),o=e.displayPrompt||e.userPrompt||"";o&&this.#Xe.push(o);let s;if(e.agentType&&e.agentType!==this.#re){let D=await this.getNamedAgentConfig(e.agentType,this.getSessionId(),r);D.success&&(s={enabledTools:this.#D,modelOverride:this.#_,mode:this.#M,systemPromptOverride:this.#ae,position:this.#C,includeMemories:this.#x},this.#D=D.options.enabledTools,this.#_=D.options.modelOverride,this.#M=D.options.mode,this.#ae=D.options.systemPromptOverride,this.#C=D.options.position,this.#x=D.options.includeMemories)}let a=e.maxCompletions??this.#u?.maxAgentCompletions,A=a??BF,c=a??Eye,u=0,l=0,p=!0,g=!1,d=!1,f=!1,h,C=0,I=0,B=!1,E=0;try{for(;;E++){if(this.#r.debug(`(agentCompletion-${E}): started`),this.#e.connectionTracker.getConnectionCount()>0&&l>=A||l>=c){n({type:"error",code:"ask-to-continue",message:"The agent has been working for a while. Do you want to continue?"});break}if(r?.aborted)throw yn(r.reason);try{if(this.cancelAllPendingToolFulfilments(),h||(h=await this.#dr(e,p,r,n),h.modelOverride=e.modelOverride),h.user.role==="user"){let v=h.files.filter(Q=>(Q.importance??0)>2.5&&Q.content).map(Q=>({filePath:Q.filePath,size:Q.content?.length??0,isCustomInstruction:!1,wasIncluded:Q.wasIncluded}));i.customInstructions.forEach(Q=>{Q.filePath&&Q.type==="always"&&v.push({filePath:Q.filePath,size:Q.content?.length??0,isCustomInstruction:!0,wasIncluded:!0})}),n({type:"user-input",prompt:h.userMessage?.displayPrompt??h.userPrompt,files:v})}try{let v=await this.#gr(i,h,r,n),{shouldContinue:Q,completions:x,filesChanged:b}=v;if(this.#s&&this.#r.debug(`(agentCompletion-${E}): completion: ${JSON.stringify(v)}`),p=!1,h=void 0,u=0,g||=b,d||=b,f||=v.navigatePreviewCalled,l+=x,this.#ee||=b,this.#i=void 0,b&&this.#d?.addCheckpoint(),r?.aborted)throw yn(r.reason);let{hasHealthIssue:S}=await this.#Kt();if(!Q){if(r?.aborted)throw yn(r.reason);let _=this.getSessionMode();if((_==="planning"||_==="auto-planning")&&!this.#k&&!B&&I<3){this.#r.debug(`(agentCompletion-${E}): adding reminder for missing plan`),B=!0,I++,this.queueSystemReminder({text:"Remember to always write the plan file and call the ExitPlanMode tool before finishing. Also, prefer using AskUserQuestion tool to ask questions to the user."});continue}if(S&&I<3){this.#r.debug(`(agentCompletion-${E}): has health issue, continuing`),I++;continue}let $=this.#nr();if($?.syncChanges&&await this.syncChangesFromRemote($.syncChanges),$){this.#r.debug(`(agentCompletion-${E}): consumed queued messages`),p=!0,e=$,l=0;continue}let U=this.#d,M=e.runValidateCommand??!0;if(U?.validateCommand&&M&&C<2&&this.#ee){d=!0,C++,n({type:"start",name:"validate-command",id:"validate-command",title:"Validate Command",content:""});let L=e.autoPush;this.#r.debug(`(agentCompletion-${E}): running validate command`),this.#Mt(r).then(Y=>{if(this.#r.debug(`(validate-command): result status ${Y.status}`),Y.status==="failure"&&Y.code){let W=Y.output?jA(Y.output,100,500):"";this.sendMessage({user:e.user,maxCompletions:e.maxCompletions,runValidateCommand:!0,userPrompt:`The validate command failed with code ${Y.code}):
1935
+ `),tag:"reminder:git-status"})}async manualCommit(e){if(!this.#m)return!1;let r=this.getSessionContext();if(!r.beforeCommit){let n=await this.#O();Object.keys(n).length>0&&(r.beforeCommit=$s(n))}return await this.commitWorkInProgress(e.commitMessage,[e.add]),await this.#ne(!0),!0}getLastSuggestedAction(){return this.#se}async#fe(){let e=this.getSessionContext();if(e.state==="generating"||e.state==="close")return this.#se=void 0,!1;let r=await this.#tt(!0,"all");return e=this.getSessionContext(),e.state!=="generating"&&e.state!=="close"?(this.#se=r,this.#g.emit("step",{type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:e.state,suggestion:r,sessionMode:e.sessionMode,hasPlanToApply:this.#k,modelOverride:this.#_}),!0):!1}async#cr(e){if(!this.#m)return null;this.#Be++;try{let r=this.getCommitMode(),n=this.getFeatureBranch(),i=this.#ge(e),o=e.path,s=e.folderName===this.#p[0]?.folderName,a=this.getSessionContext(),A=!1,c=!1,u="",l=null;try{let E=await this.git(["rev-parse","--absolute-git-dir"],{cwd:o});l=this.#e.join(E.trim(),"FETCH_HEAD"),Zl.default.existsSync(l)&&Zl.default.unlinkSync(l)}catch(E){this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchHeadFilePath:l,isCheckingGitStatus:this.#Be,folderName:e.folderName}}),l=null}try{u=await this.git(["fetch","--no-tags","origin",i],{cwd:o}),A=!0}catch{A=!1}let p=await this.#e.getRepoInfo(o),g=yl(a.beforeCommit,e.folderName,this.gitRepoContexts[0]?.folderName);!s&&!e.initialCommit&&p.commit&&(e.initialCommit=p.commit),!g&&e.initialCommit&&(g=e.initialCommit);let d=this.#At(e.folderName),f=d?1:0,h=0;if(A){if(n!==i)try{await this.git(["--no-pager","diff","--quiet",`refs/remotes/origin/${n}...refs/remotes/origin/${i}`],{cwd:o}),c=!1}catch{c=!0}else c=!0;try{let E=Rye(await this.git(["rev-list","--left-right","--count","HEAD...FETCH_HEAD"],{cwd:o}));f=E.ahead,h=E.behind}catch(E){let y=null;if(l)try{y=await this.#e.readFile(this.#e.join(o,".git/FETCH_HEAD")),y=`FETCH_HEAD: ${y} `}catch(D){y=`FETCH_HEAD FAILED: ${String(D)} `}else y="FETCH_HEAD MISSING";this.#e.Sentry?.captureException(E,{tags:{operation:"codegen-git",endpoint:"getGitStatus"},extra:{fetchOutput:u,fetchHead:y,remoteBranch:i,currentBranch:p.currentBranch,currentCommit:p.commit,isCheckingGitStatus:this.#Be,folderName:e.folderName}})}}else!A&&r!=="commits"&&g&&g!==p.commit&&(f=Math.max(f,1));let C=await this.#V(o),I=C.length>0,B=await this.#Cr(o);return{type:"git",folderName:e.folderName,remoteBranchExists:A,remoteBranchHasChanges:c,hasGeneratingPlaceholder:await this.#mr(),isSessionDirty:d||!!g&&g!==p.commit,canSync:(f>0||h>0||B)&&!I,canPush:(f>0||h>0)&&!I,hasStagedChanges:B,canPull:h>0&&A,ahead:f,hasMergeConflict:I,commitMode:r,behind:h,currentCommit:p.commit,currentBranch:p.currentBranch,pendingValidation:this.#ee,remoteBranch:i,unmergedFiles:C}}finally{this.#Be--}}#Nt(){let e=this.getSessionContext();return{type:"session",title:e.title,beforeCommit:e.beforeCommit,createdUnixTime:e.createdUnixTime,updatedUnixTime:e.updatedUnixTime,turns:e.turns.length,id:e.sessionId,lastCompletionId:this.getLastCompletionId(),sessionMode:e.sessionMode,fusionConfig:dv(this.#u),hasBrowserAutomation:e.customAgents.some(r=>r.name==="browser-testing"),customInstructions:e.customInstructions.filter(r=>!r.hideUI).map(r=>({name:r.name,description:r.description??"",type:r.type??"always",glob:r.glob,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,userInvocable:r.userInvocable})),hasPlanToApply:this.#k}}#Tt(){let r=this.getSessionContext().turns,n=[];n.push(this.#Nt()),Object.keys(this.#U).length>0&&n.push({type:"metadata",...this.#U}),this.#t.length>0&&n.push({type:"message-queue",queue:this.#t.map(i=>({idempotencyKey:i.idempotencyKey,displayPrompt:i.displayPrompt,user:i.user}))});for(let i of r){n.push({type:"user",displayPrompt:i.userMessage?i.userMessage.displayPrompt??i.userMessage.userPrompt:void 0,attachments:i.userMessage?.attachments,id:i.completionId,user:i.user,role:i.user.role,compacting:!1,idempotencyKey:i.userMessage?.idempotencyKey??""});for(let o of i.actions)if(o.type==="tool"||o.type==="text"||o.type==="thinking")if(n.push({type:"start",name:o.type,content:"",id:o.id??"",filePath:o.filePath??"",title:o.actionTitle??o.artifactTitle??o.filePath??""}),n.push({type:"delta",name:o.type,delta:o.content}),o.type==="tool"){if(n.push({type:o.type,id:o.id,name:o.filePath,content:o.content}),o.filePath==="UpdateSetupValue"||o.filePath==="ProposeConfig")try{let s=JSON.parse(o.content);if(o.filePath==="UpdateSetupValue")n.push({type:"update_setup_value",field:s.field,value:s.value,reason:s.reason});else{let a=s.config,A=a!=null&&!a.installCommand?.command&&(!a.runtimeDependencies||a.runtimeDependencies.length===0);n.push({type:"propose_config",config:a,message:s.message,noDependencies:A})}}catch{}}else o.type==="thinking"?n.push({type:"thinking",content:o.content}):o.type==="text"&&n.push({type:"text",content:o.content})}return n}connectToEventLoop(e,r,n){let i=n?.canHandleTools??[];if(e){let o=[],s=this.getSessionContext();o.push({type:"state",newState:"replay",abortable:!1,previousState:s.state}),this.#He&&o.push(this.#He),o.push(...this.#ie),o.push(...this.#Tt()),this.#X.forEach(c=>{o.push({type:"tool-call-request",id:c.id,name:c.name,input:c.input})});let a=this.#Ie?sc(this.#Ie):void 0;if(a)switch(a.type){case"file":case"diff":case"text":case"thinking":case"suggestion":case"tool":o.push({type:"start",id:a.id,name:a.type,filePath:a.filePath??"",title:a.actionTitle??a.artifactTitle??"",content:""}),o.push({type:"delta",name:a.type,delta:a.content});break}o.push({type:"terminals",terminals:this.#it()});let A=this.#d;A?(o.push({type:"dev-server",devServerState:A.devState,setupState:A.setupState,httpServerState:A.httpServerState.state,devCommand:A.devCommand,setupCommand:A.setupCommand,proxyServer:A.proxyTarget,proxyServerSelection:A.proxyServerSelection,remoteAddress:A.httpServerState.remoteAddress,remotePort:A.httpServerState.remotePort,proxyServerReachable:!!this.#u?.isLocal,validateState:A.validateCommandState}),A.setupState!=="installed"&&o.push({type:"stdio",id:"setupCommand",command:A.setupCommand??"",content:A.getSetupWrite(),source:"run-command",stream:"stdout"}),o.push({type:"stdio",id:"devServer",command:A.devCommand,content:A.getDevWrite(),source:"run-command",stream:"stdout"})):r({type:"dev-server",devServerState:"running",setupState:"installed",httpServerState:"ok-2xx",devCommand:this.#u?.devCommand,setupCommand:this.#u?.setupCommand,proxyServer:this.#u?.serverUrl,proxyServerSelection:"hardcoded",remoteAddress:void 0,remotePort:void 0,proxyServerReachable:!!this.#u?.isLocal,validateState:"unset"}),o.push({type:"state",newState:s.state,abortable:s.state==="generating",previousState:"replay"}),this.#oe&&s.state!=="generating"&&o.push({type:"wait-for-input",id:this.getLastCompletionId()??"initial",state:s.state,suggestion:this.#se,sessionMode:s.sessionMode,hasPlanToApply:this.#k}),r({type:"batch",steps:o})}this.#g.on("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)+1);return this.waitForEventLoop(),()=>{this.#g.off("step",r);for(let o of i)this.#W.set(o,(this.#W.get(o)??0)-1)}}waitUntilPendingPromises(e){let r=eA();return this.#r.debug(`(waitUntilPendingPromises-${r}): started`),Yc(Promise.allSettled(this.#le),e).then(()=>Bl()).then(()=>{this.#r.debug(`(waitUntilPendingPromises-${r}): finished`)})}waitUntilBlockingPendingPromises(e){let r=eA();return this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): started`),Yc(Promise.allSettled(this.#_e),e).then(()=>Bl()).then(()=>{this.#r.debug(`(waitUntilBlockingPendingPromises-${r}): finished`)})}waitUntilIdle(e){let r=eA();return this.waitForEventLoop(),this.#r.debug(`(waitUntilIdle-${r}): started`),Yc(Bl().then(()=>this.waitUntilPendingPromises()).then(()=>{let n=this.getSessionContext();return this.#r.debug(`(waitUntilIdle-${r}): starting in ${n.state} `),n.state==="generating"?(0,EF.once)(this.#g,"idle"):Promise.resolve(void 0)}).then(()=>this.waitUntilPendingPromises()).then(()=>{this.#r.debug(`(waitUntilIdle-${r}): idle reached in ${this.getSessionContext().state} `)}),e)}async#Mt(e){let r=this.#d;if(!r)throw new Error("Dev server not found");let n=await r.runValidateCommand(void 0,e);return n.status==="success"&&(this.#ee=!1,this.#m&&(await this.#nt()).length===0&&(await this.#ct()||await this.manualCommit({add:".",commitMessage:"Validate command fixes"}))),n}waitForEventLoop(){return this.#oe?this.#oe:this.#oe=this.#ur()}async#ur(){if(this.#oe||this.#F)throw new Error("Event loop already started");this.#r.debug("(eventLoop): started");let e=kye(),r=c=>{if(c.type==="error"&&this.#ue>0&&(dye.includes(c.code)||(c.restoreCredits=this.#ue,this.#ue=0,Dye(this.#e,this.#a,o.sessionId,c.restoreCredits).catch(u=>{this.#e.Sentry?.captureException(u)}))),c.type==="tool_result"&&(c.result.tool_name==="ExitPlanMode"||c.result.tool_name==="TodoWrite")&&(this.#r.debug("emitting ClientDevtoolsToolResultV1",{toolName:c.result.tool_name,projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:kce,extraData:{toolUseId:c.result.tool_use_id,toolName:c.result.tool_name??"",result:c.result.content,isError:c.result.is_error,sessionId:o.sessionId,projectId:this.#h,branchName:this.#y},extraAttributes:{toolName:c.result.tool_name??"",projectId:this.#h,branchName:this.#y}},{debug:this.#s})),c.type==="tool"&&c.name==="Agent"){let u;try{u=JSON.parse(c.content)?.description}catch{}let l=JSON.stringify({description:u});this.#r.debug("emitting ClientDevtoolsToolCallV1",{toolName:c.name,projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:Fce,extraData:{toolUseId:c.id,toolName:c.name,content:l,sessionId:o.sessionId,projectId:this.#h,branchName:this.#y},extraAttributes:{toolName:c.name,projectId:this.#h,branchName:this.#y}},{debug:this.#s})}this.#g.emit("step",c)};this.#F=new AbortController;let n=this.#F.signal,i=this.#d,o=this.getSessionContext(),s=()=>this.getLastCompletionId();this.#e.Sentry?.setContext("codeGen",{sessionId:o.sessionId,get completionId(){return s()}}),await this.#K(this.#S(),"initial-emitGitStatus");let a=setInterval(()=>{this.canHandleTool("GetScreenshot")&&(this.#Be>0||this.#S().catch(()=>{}))},6e4),A=()=>clearInterval(a);if(this.#Fe.push(A),process.env.FUSION_IDE_PORT){let c=setInterval(()=>{aue().then(u=>{let l=JSON.stringify(u);l!==this.#lt&&(this.#lt=l,this.#g.emit("step",{type:"ide",context:u}),this.queueSystemReminder({text:u?cue(u):"",tag:"reminder:ide-context"}))}).catch(()=>{})},1e3);this.#Fe.push(()=>clearInterval(c))}this.queueGitStatusReminder({trigger:"session-start"}),i?.setupState==="not-installed"&&this.runSetupCommand();try{let c=0;for(;!n.aborted;){c++,this.#c=void 0;let u=this.#ir();if(this.#r.debug(`(eventLoop-${c}): started (shouldWait: ${u.shouldWait})`),u.shouldWait){await this.#kt();let g=await this.#fe();if(n.aborted)break;g&&Mye(u.promise,500).then(d=>{d&&(this.#r.debug(`(eventLoop-${c}): emitting idle on next message wait`),this.#g.emit("idle"))})}let l=await u.promise;if(n.aborted)break;if(!l)continue;this.#c=new AbortController;let p=qn([n,this.#c.signal]);try{if(this.#se=void 0,l.logsCheckpoint&&i?.addCheckpoint(),p?.aborted)throw yn(p.reason);this.#j("generating"),i?.abortValidateCommand(),l.syncChanges&&(this.#r.debug(`(eventLoop-${c}): syncing changes from remote`),await this.syncChangesFromRemote(l.syncChanges),await this.#tt(!1,"critical")),l.sessionMode&&l.sessionMode!==o.sessionMode&&this.switchSessionMode(l.sessionMode),await this.#lr(l,p,r),this.#j("success");let g=l.autoPush??this.#me??"none";if(g!=="none"&&this.#m&&(this.#r.debug(`(eventLoop-${c}): autoPush: ${g}`),await this.waitUntilBlockingPendingPromises(),(await this.#nt()).length===0)){let f=(()=>{switch(g){case"force-push":return{actor:"agent",forcePush:!0,pullFirst:!1};case"merge-push":return{actor:"agent",pullFirst:!0,forcePush:!1};case"ff-push":return{actor:"agent",requireFastForward:!0,pullFirst:!1};case"safe-push":return{actor:"agent",pullFirst:!0,abortOnMergeConflict:!0};default:return{actor:"agent"}}})();if(this.#p.length>1)for(let h of this.#p)await this.#xe({...f,folderName:h.folderName});else await this.#xe(f)}this.#se=void 0}catch(g){g instanceof Error?g.name==="AbortError"?(r({type:"user-abort",hasContinueMessage:this.#t.length>0}),this.#j("abort")):g instanceof We?(this.#i=void 0,r({type:"error",code:"cli-network-error",message:g.message}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):g instanceof $t?(this.#i=void 0,r({type:"error",code:"unknown",message:"An internal error occurred. Please try again."}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):g instanceof Bi?(this.#i=void 0,r({type:"error",code:g.code,message:g.message}),dye.includes(g.code)||this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):(this.#i=void 0,r({type:"error",code:"cli-genetic-error",message:g.message,metadata:{error:g}}),this.#e.Sentry?.captureException(g,{tags:{operation:"codegen-stream"}}),this.#j("error")):this.#j("error")}this.#_t++}}catch(c){throw this.#e.Sentry?.captureException(c,{level:"fatal"}),c}finally{A(),this.#F=void 0,this.#oe=void 0,e()}this.#r.debug("(eventLoop): emitting idle on close"),this.#g.emit("idle"),this.#j("close")}async#lr(e,r,n){this.#ue=0,this.#ee=!1;let i=this.getSessionContext(),o=e.displayPrompt||e.userPrompt||"";o&&this.#et.push(o);let s;if(e.agentType&&e.agentType!==this.#re){let D=await this.getNamedAgentConfig(e.agentType,this.getSessionId(),r);D.success&&(s={enabledTools:this.#D,modelOverride:this.#_,mode:this.#M,systemPromptOverride:this.#ae,position:this.#C,includeMemories:this.#x},this.#D=D.options.enabledTools,this.#_=D.options.modelOverride,this.#M=D.options.mode,this.#ae=D.options.systemPromptOverride,this.#C=D.options.position,this.#x=D.options.includeMemories)}let a=e.maxCompletions??this.#u?.maxAgentCompletions,A=a??BF,c=a??Eye,u=0,l=0,p=!0,g=!1,d=!1,f=!1,h,C=0,I=0,B=!1,E=0;try{for(;;E++){if(this.#r.debug(`(agentCompletion-${E}): started`),this.#e.connectionTracker.getConnectionCount()>0&&l>=A||l>=c){n({type:"error",code:"ask-to-continue",message:"The agent has been working for a while. Do you want to continue?"});break}if(r?.aborted)throw yn(r.reason);try{if(this.cancelAllPendingToolFulfilments(),h||(h=await this.#dr(e,p,r,n),h.modelOverride=e.modelOverride),h.user.role==="user"){let v=h.files.filter(Q=>(Q.importance??0)>2.5&&Q.content).map(Q=>({filePath:Q.filePath,size:Q.content?.length??0,isCustomInstruction:!1,wasIncluded:Q.wasIncluded}));i.customInstructions.forEach(Q=>{Q.filePath&&Q.type==="always"&&v.push({filePath:Q.filePath,size:Q.content?.length??0,isCustomInstruction:!0,wasIncluded:!0})}),n({type:"user-input",prompt:h.userMessage?.displayPrompt??h.userPrompt,files:v})}try{let v=await this.#gr(i,h,r,n),{shouldContinue:Q,completions:x,filesChanged:b}=v;if(this.#s&&this.#r.debug(`(agentCompletion-${E}): completion: ${JSON.stringify(v)}`),p=!1,h=void 0,u=0,g||=b,d||=b,f||=v.navigatePreviewCalled,l+=x,this.#ee||=b,this.#i=void 0,b&&this.#d?.addCheckpoint(),r?.aborted)throw yn(r.reason);let{hasHealthIssue:S}=await this.#Kt();if(!Q){if(r?.aborted)throw yn(r.reason);let _=this.getSessionMode();if((_==="planning"||_==="auto-planning")&&!this.#k&&!B&&I<3){this.#r.debug(`(agentCompletion-${E}): adding reminder for missing plan`),B=!0,I++,this.queueSystemReminder({text:"Remember to always write the plan file and call the ExitPlanMode tool before finishing. Also, prefer using AskUserQuestion tool to ask questions to the user."});continue}if(S&&I<3){this.#r.debug(`(agentCompletion-${E}): has health issue, continuing`),I++;continue}let $=this.#nr();if($?.syncChanges&&await this.syncChangesFromRemote($.syncChanges),$){this.#r.debug(`(agentCompletion-${E}): consumed queued messages`),p=!0,e=$,l=0;continue}let U=this.#d,M=e.runValidateCommand??!0;if(U?.validateCommand&&M&&C<2&&this.#ee){d=!0,C++,n({type:"start",name:"validate-command",id:"validate-command",title:"Validate Command",content:""});let L=e.autoPush;this.#r.debug(`(agentCompletion-${E}): running validate command`),this.#Mt(r).then(Y=>{if(this.#r.debug(`(validate-command): result status ${Y.status}`),Y.status==="failure"&&Y.code){let W=Y.output?jA(Y.output,100,500):"";this.sendMessage({user:e.user,maxCompletions:e.maxCompletions,runValidateCommand:!0,userPrompt:`The validate command failed with code ${Y.code}):
1936
1936
  <validate_command>
1937
1937
  ${Y.command}
1938
1938
  </validate_command>
@@ -1941,9 +1941,9 @@ ${Y.command}
1941
1941
  ${W}
1942
1942
  </output>
1943
1943
 
1944
- failed with code ${Y.code}`,dropAbortedPrompt:!0,attachments:void 0,displayPrompt:`The validation command ${Y.command} failed with code ${Y.code}.`,queue:!0,category:"repair-validate-command",syncChanges:void 0,autoPush:L})}})}break}}catch(v){throw await this.#S(),v}}catch(v){let Q=function(x){return!!(x instanceof Bi&&x.code==="abrupt-end"||x instanceof Error&&x.name==="HTTPStreamBroke"||x instanceof We&&[502,503].includes(x.statusCode??0)||x instanceof We&&!x.statusCode&&["connection_reset","connection_timeout","connection_aborted"].includes(x.type))};var y=Q;if(u<3&&Q(v)){this.#r.debug(`(agentCompletion-${E}): retrying error`,v),await Ap(u,r),u++;continue}throw v}finally{Qye(i.turns)}}}finally{this.#r.debug(`(agentCompletion-${E}): finally block`),s&&(this.#D=s.enabledTools,this.#_=s.modelOverride,this.#M=s.mode,this.#ae=s.systemPromptOverride,this.#C=s.position,this.#x=s.includeMemories),await this.#ne(!0);let D=this.#u?.refreshPreview??!0;g&&D&&!f&&this.requestRefresh()}}async#gr(e,r,n,i){if(n.aborted)throw yn(n.reason);if(this.#Ie)throw new Error("generateCompletion already started");let o=eA(),s=this.getLastTurn()?.nextUrl??this.#B,a=!1,A=0,c=!1;try{let u=this.#Ie=[];if(!e.beforeCommit){let b=await this.#O();Object.keys(b).length>0&&(e.beforeCommit=$s(b))}let l=await this.#O(),p=$s(l),g=this.#qe;g&&this.#P?.enabled&&(g=!!this.#P.mcpServers);let d=r.userMessage?.uiContextPrompt;if(d&&!this.#N()){let b=this.#u?.workspace?.folders.find(S=>S.enableGit);b?.path&&(d=`Relative file paths are relative to: ${b.path}/`)}let f=this.#D,h={...e.userContext,fullstoryUrl:r.userMessage?.metadata?.fullstoryUrl,prNumber:r.userMessage?.metadata?.PR_NUMBER??e.userContext?.prNumber,prHeadSha:r.userMessage?.metadata?.PR_HEAD_SHA??e.userContext?.prHeadSha,repoFullName:r.userMessage?.metadata?.REPO_FULL_NAME??e.userContext?.repoFullName,hostname:r.userMessage?.metadata?.HOSTNAME??e.userContext?.hostname,checkRunId:r.userMessage?.metadata?.CHECK_RUN_ID??e.userContext?.checkRunId,containerUrl:process.env.FUSION_ENV_ORIGIN??e.userContext?.containerUrl,browserTestingShadowMode:r.userMessage?.metadata?.BROWSER_TESTING_SHADOW_MODE??e.userContext?.browserTestingShadowMode};e.userContext=h,this.#Pe=r.modelOverride;let C=this.#Ee?.listTools(),I={url:s,position:this.#C,eventName:"cli code",maxPages:2,autoContinue:1,codeGenMode:this.#M,userContext:h,systemReminders:r.systemReminders,files:r.files,skipFileDiff:this.#T,maxTokens:this.#pt,aclPolicy:this.#u?.accessControl,softContextWindow:this.#b,repoIndexingConfig:this.#u?.repoIndexingConfig??{designSystems:[]},recommendedRoot:this.#Qe,attachments:r.attachments,customInstructions:e.customInstructions,customAgents:e.customAgents.filter(b=>b.name!==this.#re).map(b=>({name:b.name,description:b.description})),systemPromptOverride:this.#ae,sessionId:e.sessionId,userPrompt:r.userPrompt,metadata:{...h.prNumber&&{PR_NUMBER:h.prNumber},...h.prHeadSha&&{PR_HEAD_SHA:h.prHeadSha},...h.repoFullName&&{REPO_FULL_NAME:h.repoFullName},...h.hostname&&{HOSTNAME:h.hostname},...h.containerUrl&&{CONTAINER_URL:h.containerUrl},...h.checkRunId&&{CHECK_RUN_ID:h.checkRunId},...r.userMessage?.metadata},ephemeralUserPrompt:r.userMessage?.ephemeralUserPrompt,uiContextPrompt:r.userMessage?.uiContextPrompt,displayUserPrompt:r.userMessage?.displayPrompt,isManualContinue:r.userMessage?.isManualContinue,sessionMode:this.getSessionMode(),includeRelevantMemories:r.userMessage?r.userMessage.includeRelevantMemories??this.#x:void 0,projectId:this.#h,branchName:this.#y,repoHash:this.#mt,repoBranch:this.#H,pingEvents:!0,workingDirectory:this.#v,beforeCommit:p,toolResults:r.toolResults,role:r.user.role,user:r.user,repair:r.repair,category:r.category,enabledTools:f,enabledMCPs:g?r.enabledMCPs:void 0,localMCPTools:C,isLocal:this.#u?.isLocal,searchResponse:r.searchResponse,encryptKey:this.#he,maxAgentTiming:180*1e3,mcpServers:g,environmentVariables:Nye(this.#u?.environmentVariables??[],this.#d?.environmentVariables??[]),redactUserMessages:this.#P?.redactUserMessages,redactLLMMessages:this.#P?.redactLLMMessages,modelOverride:this.#_??r.modelOverride,reasoning:this.#Ve,interruptActiveTask:r.userMessage?.queue===!1||void 0,parentSessionId:this.#yt};this.#s&&this.#r.debug(`(generateCompletion-${o}): request partial body. ${JSON.stringify({url:I.url,userPrompt:I.userPrompt,systemReminders:I.systemReminders,toolResultsCount:I.toolResults?.length})}`);let B=wye(this.#e,this.#a,I,n,this.#s),E,y=!1,D=!1,v=async b=>{if(b.type==="user"){E&&E.state!=="done"&&this.#e.Sentry?.captureException(new Error("Turn was not completed before starting a new turn"),{tags:{operation:"codegen-stream"},extra:{lastTurn:E}});let S=E={state:"running",unixTime:Date.now(),title:"",sentiment:void 0,userMessage:r.userMessage,afterCommit:p,beforeCommit:p,lastCommit:void 0,creditsUsed:0,actions:[],applyResults:[],completionId:b.id??"",nextUrl:void 0,user:b.user,autoContinue:!1};E=S,e.turns.push(S),b.compacting&&(e.customInstructions=await this.#Se(),e.customAgents=await this.#Ge()),i({type:"user",displayPrompt:b.displayPrompt,id:b.id,user:b.user,role:b.user.role,compacting:b.compacting,idempotencyKey:r.userMessage?.idempotencyKey})}else if(b.type==="mcp-status")this.#He=b,i(b);else{if(b.type==="mcp-auth-required")return D=!0,i(b),!0;if(b.type==="error")return D=!0,i(b),!0;if(b.type==="done"){A++,this.#$.length=0,this.#ue+=b.creditsUsed;let S=E=await this.#fr(e,b,E,p);for(let U of b.actions??[])U.type==="tool_result"&&(U.filePath==="ExitPlanMode"&&(this.#k=!0),U.filePath==="NavigatePreview"&&(c=!0),i({type:"tool_result",result:{content:U.content,tool_use_id:U.id,type:"tool_result",title:U.actionTitle,tool_name:U.filePath,is_error:!!U.errors?.length}}));await this.waitUntilBlockingPendingPromises(n);let _=await this.#Ir(this.#e,S),$=_.length>0;$&&(a=!0),await this.commitWorkInProgress(`${E.title}
1944
+ failed with code ${Y.code}`,dropAbortedPrompt:!0,attachments:void 0,displayPrompt:`The validation command ${Y.command} failed with code ${Y.code}.`,queue:!0,category:"repair-validate-command",syncChanges:void 0,autoPush:L})}})}break}}catch(v){throw await this.#S(),v}}catch(v){let Q=function(x){return!!(x instanceof Bi&&x.code==="abrupt-end"||x instanceof Error&&x.name==="HTTPStreamBroke"||x instanceof We&&[502,503].includes(x.statusCode??0)||x instanceof We&&!x.statusCode&&["connection_reset","connection_timeout","connection_aborted"].includes(x.type))};var y=Q;if(u<3&&Q(v)){this.#r.debug(`(agentCompletion-${E}): retrying error`,v),await Ap(u,r),u++;continue}throw v}finally{Qye(i.turns)}}}finally{this.#r.debug(`(agentCompletion-${E}): finally block`),s&&(this.#D=s.enabledTools,this.#_=s.modelOverride,this.#M=s.mode,this.#ae=s.systemPromptOverride,this.#C=s.position,this.#x=s.includeMemories),await this.#ne(!0);let D=this.#u?.refreshPreview??!0;g&&D&&!f&&this.requestRefresh()}}async#gr(e,r,n,i){if(n.aborted)throw yn(n.reason);if(this.#Ie)throw new Error("generateCompletion already started");let o=eA(),s=this.getLastTurn()?.nextUrl??this.#B,a=!1,A=0,c=!1;try{let u=this.#Ie=[];if(!e.beforeCommit){let b=await this.#O();Object.keys(b).length>0&&(e.beforeCommit=$s(b))}let l=await this.#O(),p=$s(l),g=this.#qe;g&&this.#P?.enabled&&(g=!!this.#P.mcpServers);let d=r.userMessage?.uiContextPrompt;if(d&&!this.#N()){let b=this.#u?.workspace?.folders.find(S=>S.enableGit);b?.path&&(d=`Relative file paths are relative to: ${b.path}/`)}let f=this.#D,h={...e.userContext,fullstoryUrl:r.userMessage?.metadata?.fullstoryUrl,prNumber:r.userMessage?.metadata?.PR_NUMBER??e.userContext?.prNumber,prHeadSha:r.userMessage?.metadata?.PR_HEAD_SHA??e.userContext?.prHeadSha,repoFullName:r.userMessage?.metadata?.REPO_FULL_NAME??e.userContext?.repoFullName,hostname:r.userMessage?.metadata?.HOSTNAME??e.userContext?.hostname,checkRunId:r.userMessage?.metadata?.CHECK_RUN_ID??e.userContext?.checkRunId,containerUrl:process.env.FUSION_ENV_ORIGIN??e.userContext?.containerUrl,browserTestingShadowMode:r.userMessage?.metadata?.BROWSER_TESTING_SHADOW_MODE??e.userContext?.browserTestingShadowMode};e.userContext=h,this.#Pe=r.modelOverride;let C=this.#Ee?.listTools(),I={url:s,position:this.#C,eventName:"cli code",maxPages:2,autoContinue:1,codeGenMode:this.#M,userContext:h,systemReminders:r.systemReminders,files:r.files,skipFileDiff:this.#T,maxTokens:this.#dt,aclPolicy:this.#u?.accessControl,softContextWindow:this.#b,repoIndexingConfig:this.#u?.repoIndexingConfig??{designSystems:[]},recommendedRoot:this.#Qe,attachments:r.attachments,customInstructions:e.customInstructions,customAgents:e.customAgents.filter(b=>b.name!==this.#re).map(b=>({name:b.name,description:b.description})),systemPromptOverride:this.#ae,sessionId:e.sessionId,userPrompt:r.userPrompt,metadata:{...h.prNumber&&{PR_NUMBER:h.prNumber},...h.prHeadSha&&{PR_HEAD_SHA:h.prHeadSha},...h.repoFullName&&{REPO_FULL_NAME:h.repoFullName},...h.hostname&&{HOSTNAME:h.hostname},...h.containerUrl&&{CONTAINER_URL:h.containerUrl},...h.checkRunId&&{CHECK_RUN_ID:h.checkRunId},...r.userMessage?.metadata},ephemeralUserPrompt:r.userMessage?.ephemeralUserPrompt,uiContextPrompt:r.userMessage?.uiContextPrompt,displayUserPrompt:r.userMessage?.displayPrompt,isManualContinue:r.userMessage?.isManualContinue,sessionMode:this.getSessionMode(),includeRelevantMemories:r.userMessage?r.userMessage.includeRelevantMemories??this.#x:void 0,projectId:this.#h,branchName:this.#y,repoHash:this.#ht,repoBranch:this.#H,pingEvents:!0,workingDirectory:this.#v,beforeCommit:p,toolResults:r.toolResults,role:r.user.role,user:r.user,repair:r.repair,category:r.category,enabledTools:f,enabledMCPs:g?r.enabledMCPs:void 0,localMCPTools:C,isLocal:this.#u?.isLocal,searchResponse:r.searchResponse,encryptKey:this.#he,maxAgentTiming:180*1e3,mcpServers:g,environmentVariables:Nye(this.#u?.environmentVariables??[],this.#d?.environmentVariables??[]),redactUserMessages:this.#P?.redactUserMessages,redactLLMMessages:this.#P?.redactLLMMessages,modelOverride:this.#_??r.modelOverride,reasoning:this.#Ve,interruptActiveTask:r.userMessage?.queue===!1||void 0,parentSessionId:this.#We};this.#s&&this.#r.debug(`(generateCompletion-${o}): request partial body. ${JSON.stringify({url:I.url,userPrompt:I.userPrompt,systemReminders:I.systemReminders,toolResultsCount:I.toolResults?.length})}`);let B=wye(this.#e,this.#a,I,n,this.#s),E,y=!1,D=!1,v=async b=>{if(b.type==="user"){E&&E.state!=="done"&&this.#e.Sentry?.captureException(new Error("Turn was not completed before starting a new turn"),{tags:{operation:"codegen-stream"},extra:{lastTurn:E}});let S=E={state:"running",unixTime:Date.now(),title:"",sentiment:void 0,userMessage:r.userMessage,afterCommit:p,beforeCommit:p,lastCommit:void 0,creditsUsed:0,actions:[],applyResults:[],completionId:b.id??"",nextUrl:void 0,user:b.user,autoContinue:!1};E=S,e.turns.push(S),b.compacting&&(e.customInstructions=await this.#Se(),e.customAgents=await this.#Ge()),i({type:"user",displayPrompt:b.displayPrompt,id:b.id,user:b.user,role:b.user.role,compacting:b.compacting,idempotencyKey:r.userMessage?.idempotencyKey})}else if(b.type==="mcp-status")this.#He=b,i(b);else{if(b.type==="mcp-auth-required")return D=!0,i(b),!0;if(b.type==="error")return D=!0,i(b),!0;if(b.type==="done"){A++,this.#$.length=0,this.#ue+=b.creditsUsed;let S=E=await this.#fr(e,b,E,p);for(let U of b.actions??[])U.type==="tool_result"&&(U.filePath==="ExitPlanMode"&&(this.#k=!0),U.filePath==="NavigatePreview"&&(c=!0),i({type:"tool_result",result:{content:U.content,tool_use_id:U.id,type:"tool_result",title:U.actionTitle,tool_name:U.filePath,is_error:!!U.errors?.length}}));await this.waitUntilBlockingPendingPromises(n);let _=await this.#Ir(this.#e,S),$=_.length>0;$&&(a=!0),await this.commitWorkInProgress(`${E.title}
1945
1945
  ${E.completionId}`,_),await this.#S(),this.#de({completionId:S.completionId,beforeCommit:S.beforeCommit}),i({type:"done",stopReason:b.stopReason,id:b.id,applyResults:S.applyResults,actions:b.actions??[],creditsUsed:b.creditsUsed,sessionUsage:b.sessionUsage,contextWindow:b.contextWindow,model:b.model,usage:b.usage,url:b.nextUrl,promptVersion:b.promptVersion,hasChanges:$})}else{if(b.type==="continue")return y=b.autoContinue,D=!0,i({type:"continue",id:b.id,url:b.nextUrl,autoContinue:b.autoContinue}),!0;b.type==="thinking"&&(b.actionTitle="Planning"),"content"in b&&b.type!=="delta"&&i({type:"start",name:b.type,filePath:b.filePath??"",id:"id"in b?b.id:void 0,title:b.actionTitle??b.artifactTitle??b.filePath??"",content:b.content??""})}}return!1},Q=b=>{if(b.type==="thinking"&&i({type:"thinking",content:b.content}),b.type==="server_tool_result"){let S;try{S=JSON.parse(b.content)}catch(_){this.#e.Sentry?.captureException(_,{extra:{contentPreview:b.content?.substring(0,500),contentLength:b.content?.length},tags:{operation:"server-tool-result-parse"}}),S=b.content}i({type:"server_tool_result",content:S,title:b.actionTitle??b.artifactTitle??"Server Tool Result",id:b.id})}b.type==="file"&&b.filePath&&!b.synthetic&&i({type:"file",filePath:b.filePath,content:b.content,title:b.actionTitle??b.artifactTitle??"Created",id:b.id,errors:b.errors}),b.type==="diff"&&b.filePath&&!b.synthetic&&i({type:"diff",filePath:b.filePath,title:b.actionTitle??b.artifactTitle??"Updated",content:b.content,id:b.id,errors:b.errors}),b.type==="tool"&&b.filePath?i({type:"tool",name:b.filePath,id:b.id,content:b.content}):b.type==="text"&&i({type:"text",content:b.content})},x=(b,S)=>{i({type:"delta",name:b.type,delta:S})};for await(let b of B){if(b.type==="ping"){this.#r.debug(`(generateCompletion-${o}): ping`);continue}if(b.type==="delta"){let S=b.content,_=sc(u);_&&"content"in _&&(_.content+=S,x(_,S))}else{let S=sc(u);if(b.type==="thinking"&&S?.type==="thinking")continue;if(S&&"content"in S&&(S.incomplete=!1,Q(S)),u.push(b),await v(b))break}}if(!D)throw new Bi("Completion stream ended abruptly","abrupt-end");if(!E)throw new Bi("Completion stream ended abruptly","abrupt-end");return{completions:A,filesChanged:a,navigatePreviewCalled:c,shouldContinue:y||E.actions.some(b=>b.type==="tool")||E.autoContinue}}finally{this.#Ie=void 0}}async commitWorkInProgress(e,r){if(!this.#m)return;let n=this.#Xt(r);await this.#J(async i=>{let o=n.get(i.folderName)||[],s=await this.#V(i.path);try{s.length>0?(o.length>0&&await this.git(["add",...o],{cwd:i.path,retry:2}),(await this.#V(i.path)).length===0&&await this.git(["add","-A","."],{cwd:i.path,retry:2})):await this.git(["add","-A","."],{cwd:i.path,retry:2})}catch(a){this.#e.Sentry?.captureException(new Error(`Error staging files in ${i.folderName}: ${a}`),{tags:{operation:"codegen-git-stage"}})}}),typeof this.#De=="string"?this.#De+=`
1946
- ${e}`:this.#De=e}async#ne(e){if(!this.#m)return!1;let r=this.#De,n=this.#Xe,i=this.getLastTurn(),o=i?.completionId;this.#De=null,this.#Xe=[];let a=(async()=>{if(await this.#Qt,!r)return!1;this.#r.debug("(#commitAccumulatedChanges): committing pending changes");let A=!1;try{await this.#J(async l=>{let p="";try{await this.git(["--no-pager","diff","--cached","--quiet"],{cwd:l.path});return}catch{try{if(p=await this.git(["--no-pager","diff","--cached","--no-color"],{cwd:l.path}),!p.trim())return}catch{return}}let g=await this.#zt(l.path),d=r,f=performance.now(),h=await sa(this.#a,"/codegen/commit-message",{diff:jA(p,500),userMessages:n,recentCommits:g,projectId:this.#h},{signal:AbortSignal.timeout(2e4),debug:this.#s});this.#G("git_commit_message_llm",performance.now()-f,{folder:l.folderName});let B=(h?.message||d).split(`
1946
+ ${e}`:this.#De=e}async#ne(e){if(!this.#m)return!1;let r=this.#De,n=this.#et,i=this.getLastTurn(),o=i?.completionId;this.#De=null,this.#et=[];let a=(async()=>{if(await this.#Qt,!r)return!1;this.#r.debug("(#commitAccumulatedChanges): committing pending changes");let A=!1;try{await this.#J(async l=>{let p="";try{await this.git(["--no-pager","diff","--cached","--quiet"],{cwd:l.path});return}catch{try{if(p=await this.git(["--no-pager","diff","--cached","--no-color"],{cwd:l.path}),!p.trim())return}catch{return}}let g=await this.#zt(l.path),d=r,f=performance.now(),h=await sa(this.#a,"/codegen/commit-message",{diff:jA(p,500),userMessages:n,recentCommits:g,projectId:this.#h},{signal:AbortSignal.timeout(2e4),debug:this.#s});this.#G("git_commit_message_llm",performance.now()-f,{folder:l.folderName});let B=(h?.message||d).split(`
1947
1947
  `).flatMap(E=>["-m",E]);try{await this.git(["commit","--quiet","--no-verify","--no-gpg-sign",...B],{cwd:l.path}),A=!0}catch(E){this.#e.Sentry?.captureException(new Error(`Error in batch commit for ${l.folderName}: ${E}`),{tags:{operation:"codegen-git-batch-commit"}})}});let c=await this.#O(),u=$s(c);return u&&(this.#R={...this.#R,...c},i&&(i.afterCommit=u,i.lastCommit=u),this.#de({completionId:o,beforeCommit:i?.beforeCommit,afterCommit:u,lastCommit:u,commitFailed:!1})),e&&await this.#S(),A}catch(c){return this.#e.Sentry?.captureException(new Error(`Error in #commitAccumulatedChanges: ${c}`),{tags:{operation:"codegen-git-batch-commit"}}),A}})();return this.#Qt=a,this.#K(a,"commitAccumulatedChanges",!0)}async#pr(e,r,n,i){let o=r.actions.filter(s=>s.type==="tool"&&s.id).map(s=>{let a=s.content.trim(),A={};try{A=a?JSON.parse(a):{}}catch{A={}}return{id:s.id,name:s.filePath,input:A,abortController:this.#Y.find(c=>c.id===s.id)?.abortController??new AbortController}})??[];if(o.length>0){this.#Y=o;try{let s={debug:this.#s,logger:ke("ToolContext",{debug:()=>!!(this.#s||process.env.DEBUG)}),sys:this.#e,credentials:this.#a,files:e.files,user:e.user,projectId:this.#h,branchName:this.#y,position:this.#C,fusionConfig:this.#u,enabledTools:this.#D??[],sessionMode:this.getSessionMode(),fusionStatusMonitor:this.#$e,asyncSubAgents:this.#ze,switchSessionMode:A=>this.switchSessionMode(A),signal:n,canCollapseWorkspace:this.#N(),emitter:this.#g,session:this,filterText:A=>(A=Vie(A,this.#v),this.#u?.accessControl?.secrets&&(A=zie(A,this.#u.accessControl.secrets)),A),allowedCommands:Xb(this.#u?.allowedCommands??[]),getAllFiles:A=>this.getAllFiles({getDotFiles:A.getDotFiles,includePattern:A.pattern,gitignore:!0,maxFiles:A.maxFiles}),workingDirectory:this.#I,bashWorkingDirectory:this.#v,workspaceFolders:this.#E?.folders??[],restore:A=>this.restore(A),patchFusionConfig:A=>{e.patchFusionConfig||(e.patchFusionConfig={});let c=e.patchFusionConfig.envVariables;Object.assign(e.patchFusionConfig,A),e.patchFusionConfig.envVariables={...c,...A.envVariables}},readFile:A=>this.readFile(A),writeFile:(A,c)=>this.writeFile(A,c),deleteFile:A=>this.deleteFile(A),fileExists:A=>this.fileExists(A),listDir:A=>this.listDir(A),evaluateAccess:(A,c)=>Ga(A,c,this.#u?.accessControl,this.#z()),stat:A=>this.stat(A),localMCPManager:this.#Ee,passThrough:(A,c)=>new Promise((u,l)=>{let p=c?.messageValid??!1,g=c?.signal??new AbortController().signal;if(!this.canHandleTool(A.name)&&!p){l(new Error("The user is currently not present in the chat. Ie, he is not able to respond to the request"));return}let f=()=>{g.removeEventListener("abort",h),this.#X.delete(A.id)},h=()=>{f(),l(new Error("Aborted by the user. So the task could not be completed."))};if(g.aborted){h();return}g.addEventListener("abort",h,{once:!0}),this.#X.set(A.id,{id:A.id,name:A.name,input:A.input,messageValid:p,resolve:C=>{f(),u(C)}}),this.#g.emit("step",{type:"tool-call-request",id:A.id,name:A.name,input:A.input,messageValid:p}),A.name==="AskUserQuestion"&&(this.#r.debug("emitting ClientDevtoolsToolCallRequestV1",{toolName:A.name,projectId:this.#h,branchName:this.#y}),sa(this.#a,"/events/publish",{event:xce,extraData:{toolUseId:A.id,toolName:A.name,input:A.input,sessionId:this.getSessionId(),projectId:this.#h,branchName:this.#y,messageValid:p},extraAttributes:{toolName:A.name,projectId:this.#h,branchName:this.#y}},{debug:this.#s}))}),resolveWorkspacePath:(A,c)=>{if(typeof A!="string")throw new TypeError(`resolveWorkspacePath: 'path' must be a string, received ${typeof A}: ${oa(A)}`);return this.resolveWorkspacePath(A,c)},absolutePathToWorkspaceUrl:A=>this.absolutePathToWorkspaceUrl(A),setHasPlanToApply:(A,c)=>{this.#k=A,this.#te=A?c:void 0},devServerOrchestrator:this.#d},a=await hye(s,o,r.cachedToolResults,i);if(r.cachedToolResults=a,s.signal?.aborted)throw yn(s.signal.reason);e.patchFusionConfig&&this.#g.emit("step",{type:"fusion-config-patch",patch:e.patchFusionConfig}),e.files=s.files,e.toolResults=a}finally{this.#Y=[]}}}async#dr(e,r,n,i){let o=this.getSessionContext(),s=sc(o.turns),a=structuredClone(e.user??s?.user??{source:"agent",role:"agent"}),A={userMessage:void 0,userPrompt:"",systemReminders:this.#$.slice(),files:[],attachments:[],searchResponse:null,rerankFiles:0,mostRelevantFile:null,toolResults:[],user:a,modelOverride:e.modelOverride,repair:e.repair,category:e.category,enabledMCPs:e.enabledMCPs},c=!!this.getLastTurn()?.nextUrl,u=o.turns.length<2||!c;if(r){let l=null;if(u){let p=Iye(await this.getAllFiles({getDotFiles:!1,gitignore:!0,deep:4,truncate:2e4})),g=new Set,d=new Set;if(e.files)for(let B of e.files)g.add(jie(B));let f=e.includeBaseFiles??o.turns.length===0,h=Array.from(g),C=B=>f&&xye(B,this.#Qe)?10:f&&Sye(B,this.#Qe)?5:d.has(B)||h.some(E=>B.toLowerCase().startsWith(E.toLowerCase()))?2:0,I=n.aborted?[]:p.map(B=>{let E=C(B);if(E===0)return{filePath:B};let y=null;try{if(y=this.readFileSync(B),!y)return{filePath:B}}catch{return{filePath:B}}let D=y.length<3e4;return{filePath:B,content:y,importance:D?E:2}});A.files=I,A.attachments=e.attachments??[]}if(this.#m&&!this.#re){let p,g=await this.getChangesReport();if(g){for(let d of g.files)if(!A.files.some(f=>f.filePath===d))try{let f=await this.readFile(d);A.files.push({filePath:d,importance:0,content:f??void 0})}catch{A.files.push({filePath:d,importance:0})}g.diff.length<3e4?p=g.diff:p=g.files.map(d=>`- ${d}`).join(`
1948
1948
  `).trim().slice(0,3e4),p&&A.systemReminders.push({text:`
1949
1949
  Since last time, some files were changed by the user or tools (formatting for example):
@@ -1951,14 +1951,14 @@ Since last time, some files were changed by the user or tools (formatting for ex
1951
1951
  ${p}
1952
1952
  </modified-files-context>`,tag:"reminder:modified-files-context"})}}A.userMessage=e,A.userPrompt=e.userPrompt,A.attachments=e.attachments??[],A.searchResponse=l,A.rerankFiles=0,A.mostRelevantFile=null,A.toolResults=[]}else A.user.role="agent";return s&&await this.#pr(A,s,n,i),A}async#fr(e,r,n,i){let{actions:o}=r,s=n||{state:"done",unixTime:r.unixTime??Date.now(),title:r.actionTitle,user:{source:"agent",role:"agent"},completionId:r.id??"",creditsUsed:r.creditsUsed??0,nextUrl:r.nextUrl,applyResults:[],actions:o??[],userMessage:void 0,beforeCommit:i,afterCommit:i,lastCommit:void 0,sentiment:void 0,autoContinue:r.autoContinue};if(s.state="done",s.title=r.actionTitle??"",s.creditsUsed=r.creditsUsed??0,s.nextUrl=r.nextUrl,s.autoContinue=r.autoContinue,s.actions=o??[],n||e.turns.push(s),Array.isArray(o))for(let a of o){let A=a.filePath;if(a.type==="file"&&A&&!a.incomplete){let u=!!await this.stat(A,!0),l=null,p=!0;if(u)try{l=this.readFileSync(A,!0)}catch{p=!1}if(l)if(a.content.trim()==="")s.applyResults.push({action:"delete",filePath:A,addedLines:0,removedLines:l.split(`
1953
1953
  `).length,content:"",oldContent:l});else{let g=tge(l,a.content);s.applyResults.push({action:"update",filePath:A,addedLines:g.filter(d=>d.added).reduce((d,f)=>d+(f.count??0),0),removedLines:g.filter(d=>d.removed).reduce((d,f)=>d+(f.count??0),0),content:a.content,oldContent:l})}else u&&!p?s.applyResults.push({action:"update",filePath:A,addedLines:0,removedLines:0,content:a.content,oldContent:void 0}):s.applyResults.push({action:"create",filePath:A,addedLines:a.content.split(`
1954
- `).length,removedLines:0,content:a.content,oldContent:""})}}return s}#at(e){let r=this.getSessionContext();if(!e)return this.gitRepoContexts.some(A=>this.#at(A.folderName));let n=e,i=yl(r.beforeCommit,n,this.gitRepoContexts[0]?.folderName),o=r.turns.findLast(A=>A.afterCommit??A.beforeCommit),s=o?.afterCommit??o?.beforeCommit,a=yl(s,n,this.gitRepoContexts[0]?.folderName);return i&&a&&i!==a?!0:r.turns.some(A=>A.applyResults.some(c=>this.#xt(c.filePath)?.folderName===e))}async#mr(){try{let e="{/* TODO: FUSION_GENERATION_APP_PLACEHOLDER replace everything here with the actual app! */}",r=await this.#e.readFile(this.resolveWorkspacePath("client/pages/Index.tsx",!0).resolvedPath);if((await this.#e.readFile(this.resolveWorkspacePath("client/App.tsx",!0).resolvedPath))?.includes('<Route path="/" element={<Index />} />')&&r&&r.includes(e))return!0}catch{}return!1}#Pt(e){let r=e.toLowerCase(),n=[".next/","dist/","build/","out/","node_modules/",".cache/","coverage/","__pycache__/","target/","vendor/",".gradle/",".build/"],i=[".gz",".zip",".tar",".tgz",".7z",".rar",".pack",".bin",".exe",".dll",".so",".dylib",".o",".a",".jar",".class",".pyc",".pyo",".wasm",".png",".jpg",".jpeg",".gif",".ico",".webp",".svg",".mp4",".mp3",".wav",".pdf",".woff",".woff2",".ttf",".eot",".map",".min.js",".min.css",".bundle.js",".chunk.js",".tsbuildinfo"];for(let o of n)if(r.includes(o))return!0;for(let o of i)if(r.endsWith(o))return!0;return!!(r.endsWith("package-lock.json")||r.endsWith("yarn.lock")||r.endsWith("pnpm-lock.yaml")||r.endsWith(".lock"))}async getChangesReport(){if(this.#m)try{let e=[],r=[];for(let i of this.#p){let o=this.#R[i.folderName];if(!o)continue;if((await this.#V(i.path)).length>0)return;try{let c=(await this.git(["--no-pager","diff","--name-only",o],{cwd:i.path})).trim().split(`
1954
+ `).length,removedLines:0,content:a.content,oldContent:""})}}return s}#At(e){let r=this.getSessionContext();if(!e)return this.gitRepoContexts.some(A=>this.#At(A.folderName));let n=e,i=yl(r.beforeCommit,n,this.gitRepoContexts[0]?.folderName),o=r.turns.findLast(A=>A.afterCommit??A.beforeCommit),s=o?.afterCommit??o?.beforeCommit,a=yl(s,n,this.gitRepoContexts[0]?.folderName);return i&&a&&i!==a?!0:r.turns.some(A=>A.applyResults.some(c=>this.#xt(c.filePath)?.folderName===e))}async#mr(){try{let e="{/* TODO: FUSION_GENERATION_APP_PLACEHOLDER replace everything here with the actual app! */}",r=await this.#e.readFile(this.resolveWorkspacePath("client/pages/Index.tsx",!0).resolvedPath);if((await this.#e.readFile(this.resolveWorkspacePath("client/App.tsx",!0).resolvedPath))?.includes('<Route path="/" element={<Index />} />')&&r&&r.includes(e))return!0}catch{}return!1}#Pt(e){let r=e.toLowerCase(),n=[".next/","dist/","build/","out/","node_modules/",".cache/","coverage/","__pycache__/","target/","vendor/",".gradle/",".build/"],i=[".gz",".zip",".tar",".tgz",".7z",".rar",".pack",".bin",".exe",".dll",".so",".dylib",".o",".a",".jar",".class",".pyc",".pyo",".wasm",".png",".jpg",".jpeg",".gif",".ico",".webp",".svg",".mp4",".mp3",".wav",".pdf",".woff",".woff2",".ttf",".eot",".map",".min.js",".min.css",".bundle.js",".chunk.js",".tsbuildinfo"];for(let o of n)if(r.includes(o))return!0;for(let o of i)if(r.endsWith(o))return!0;return!!(r.endsWith("package-lock.json")||r.endsWith("yarn.lock")||r.endsWith("pnpm-lock.yaml")||r.endsWith(".lock"))}async getChangesReport(){if(this.#m)try{let e=[],r=[];for(let i of this.#p){let o=this.#R[i.folderName];if(!o)continue;if((await this.#V(i.path)).length>0)return;try{let c=(await this.git(["--no-pager","diff","--name-only",o],{cwd:i.path})).trim().split(`
1955
1955
  `).map(p=>p.trim()).filter(p=>p).filter(p=>!this.#Pt(p));if(c.length===0)continue;let u=c.map(p=>this.absolutePathToWorkspaceUrl(this.#e.join(i.path,p))).filter(p=>p!=null);e.push(...u);let l=await this.git(["--no-pager","diff","-U0","--no-color",o,"--",...c],{cwd:i.path}).then(p=>p.trim());l.length>0&&(this.#p.length>1?r.push(`
1956
1956
  ### Changes in ${i.folderName}:
1957
1957
  ${l}`):r.push(l))}catch(a){this.#e.Sentry?.captureException(a,{tags:{operation:"codegen-git",folderName:i.folderName}})}}if(e.length===0)return{files:[],diff:""};let n="";if(!this.#N()&&r.length>0)if(this.#p.length>1)n=`Notice: This is a multi-repo workspace with folders: ${this.#p.map(o=>o.folderName).join(", ")}. File paths are prefixed with their folder names when using Read/Write/Edit tools.
1958
1958
  `;else{let i=this.gitEnabledFolder;i&&(n=`Notice that all the relative paths, are inside "${i.name}/", remember that when using Read/Write/Edit tools:
1959
1959
  `)}return{files:e,diff:nm(`${n}${r.join(`
1960
- `)}`,1e4)}}catch(e){this.#e.Sentry?.captureException(e,{tags:{operation:"codegen-git"}});return}}#hr(){return["status","--porcelain=v1","-z","--ignore-submodules=dirty"]}async#At(e){try{let r=this.#hr();return(await this.git(r,{cwd:e})).trim().length===0}catch{return!1}}async#Cr(e){try{return await this.git(["diff","--cached","--quiet"],{cwd:e}),!1}catch{return!0}}async#Ir(e,r){let n=r.applyResults,i=[];for(let o of n)try{if(o.action==="delete"){let s=await this.deleteFile(o.filePath);s&&i.push(s)}else if(o.content){let s=await this.writeFile(o.filePath,o.content);s&&(this.#Lt.add(s),i.push(s))}}catch(s){e.Sentry?.captureException(s)}return i}#N(){return this.#E?.folders?.length===1||!this.#E?.folders?.length}resolveWorkspacePath(e,r){if(typeof e!="string")throw new TypeError(`resolveWorkspacePath: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);return Hge({filePath:e,forceWorkspace:r,workspace:this.#E,workingDirectory:this.#I,sys:this.#e,canCollapseWorkspace:this.#N()})}#z(){try{let e=this.getSessionContext();return sc(e.turns)?.user.principals}catch{return}}absolutePathToWorkspaceUrl(e){return $ge({absolutePath:e,workspace:this.#E,workingDirectory:this.#I,sys:this.#e,canCollapseWorkspace:this.#N()})}async launchEditor(e={}){let r,n,i;return e.filePath?(r=this.resolveWorkspacePath(e.filePath,!1).resolvedPath,n=e.line??void 0,i=e.column??void 0):r=this.primaryGitPath,await this.#e.exists(r)?await this.#e.launchEditor({filePath:r,line:n,column:i}):{success:!1,message:`File not found: ${r}`}}async readFile(e,r){if(typeof e!="string")throw new TypeError(`readFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return this.#E.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r),i=await this.#e.readFile(n);return i!==null?i:({resolvedPath:n}=this.resolveWorkspacePath(e,!0),await this.#e.readFile(n))}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async readFileWithChecksum(e){let r=await this.readFile(e.filePath,e.skipAclCheck);if(r===null)return{content:null,checksum:null};let n=(0,oJ.createHash)("md5").update(r).digest("hex");return e.previousChecksum&&n===e.previousChecksum?{content:null,checksum:n,notModified:!0}:{content:r,checksum:n}}async readBinaryFile(e){let r=Ga(e,"read",this.#u?.accessControl,this.#z());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1),i=await this.#e.readBinaryFile(n);if(i===null&&({resolvedPath:n}=this.resolveWorkspacePath(e,!0),i=await this.#e.readBinaryFile(n)),i)return Buffer.from(i).toString("base64")}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async#ct(e){let r;e?r=this.#p.find(o=>o.path===e)?.branchName:r=this.gitEnabledFolder?.branchName;let n=r?r.startsWith("origin/")?r:`origin/${r}`:await this.getDefaultBranch(e);if(!n)throw new Error("Could not find parent branch");return n}async#Er(e){let r=this.#we.get(e);if(r&&Date.now()-r.timestamp<t.#wt)return r.promise;let n=(async()=>{let i=await this.#ct(e);try{return(await this.git(["merge-base",i,"HEAD"],{cwd:e})).trim()}catch{return i}})().catch(i=>{throw this.#we.get(e)?.promise===n&&this.#we.delete(e),i});return this.#we.set(e,{promise:n,timestamp:Date.now()}),n}async getFileAtRef(e,r,n){if(!this.#m)return null;try{let i,o;if(n)i=n,e.startsWith(i)?(o=e.substring(i.length),o.startsWith("/")&&(o=o.substring(1))):o=e;else{let{resolvedPath:u,workspaceFolder:l}=this.resolveWorkspacePath(e,!0);i=l?.path||this.#I,o=e,i&&u.startsWith(i)&&(o=u.substring(i.length),o.startsWith("/")&&(o=o.substring(1)))}let s=r??await this.#Er(i),a=`${i}:${s}:${o}`,A=this.#be.get(a);if(A&&Date.now()-A.timestamp<t.#wt)return A.promise;let c=this.git(["show",`${s}:${o}`],{cwd:i}).catch(u=>{let l=u instanceof Error?u.message:String(u);return l.includes("does not exist")||l.includes("exists on disk")||this.#be.get(a)?.promise===c&&this.#be.delete(a),null});return this.#be.set(a,{promise:c,timestamp:Date.now()}),c}catch{return null}}async getSingleFileDiff(e){if(e===null||typeof e!="string"&&typeof e!="object")throw new TypeError(`getSingleFileDiff: 'args' must be a string or object, received ${e===null?"null":typeof e}: ${oa(e)}`);let r=typeof e=="string"?{path:e}:e;if(typeof r.path!="string")throw new TypeError(`getSingleFileDiff: 'path' must be a string, received ${typeof r.path}: ${oa(r.path)}`);let n=typeof e=="object"?e.previousChecksum:void 0,{repoPath:i,relativePath:o}=this.#bt(r.path,r.folderName),s=this.#e.join(i,o),[a,A]=await Promise.all([this.#e.readFile(s).catch(()=>null),this.getFileAtRef(o,void 0,i)]),c=A===null?"":`${A}`,u=a===null?"":`${a}`,l=(0,oJ.createHash)("md5").update(`${c}\0${u}`).digest("hex"),p=A===null&&a!==null?"create":A!==null&&a===null?"delete":"update";return n===l?{oldContent:null,newContent:null,action:p,checksum:l,notModified:!0}:{oldContent:A,newContent:a,action:p,checksum:l}}async discardFileChanges(e){let r=typeof e=="string"?{filePath:e}:e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let{repoPath:n,relativePath:i}=this.#bt(r.filePath,r.folderName),o=this.#e.join(n,i),s=await this.#ct(n),a;try{a=(await this.git(["merge-base",s,"HEAD"],{cwd:n})).trim()}catch{a=s}let A=await this.getFileAtRef(i,a,n),u=(await this.git(["--no-pager","diff",`${a}`,"HEAD","--",i],{cwd:n})).trim().length>0,p=(await this.git(["status","--porcelain","--",i],{cwd:n})).trim().length>0;if(!u&&!p)return{success:!0};if(A===null){try{await this.#e.exists(o)&&await this.#e.unlink(o)}catch{}let f=this.#e.dirname(i);if(f&&f!==".")try{await this.git(["clean","-fd",f],{cwd:n})}catch{}}else try{await this.git(["restore",`--source=${a}`,"--",i],{cwd:n})}catch(f){return{success:!1,error:`Failed to restore file: ${f}`}}await this.git(["add","--",i],{cwd:n});let g=`Discard changes to ${i}`;await this.git(["commit","--no-gpg-sign","-m",g],{cwd:n});let d=(await this.git(["rev-parse","HEAD"],{cwd:n})).trim();try{await this.#S()}catch(f){this.#e.Sentry?.captureException(f,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!0,commitHash:d}}catch(n){try{await this.#S()}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!1,error:n instanceof Error?n.message:String(n)}}}async revertDiscard(e){let{commitHash:r,folderName:n}=e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let i=this.#ve(n);await this.git(["revert","--no-edit",r],{cwd:i});try{await this.#S()}catch(o){this.#e.Sentry?.captureException(o,{tags:{operation:"revert-discard",step:"emit-git-status"}})}return{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async fileExists(e){if(typeof e!="string")throw new TypeError(`fileExists: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);let r=n=>n.startsWith(this.#I)?this.#e.relative(this.#I,n):n;try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return{absolutePath:e,recommendedPath:void 0,workspaceFolder:void 0,virtual:!0};let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);return await this.#e.exists(n)?{absolutePath:n,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:i?{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:({resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!0),await this.#e.exists(n)?{absolutePath:n,recommendedPath:r(n),workspaceFolder:i,virtual:!1}:{absolutePath:void 0,recommendedPath:r(n),workspaceFolder:i,virtual:!1})}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:void 0,virtual:!1}}readFileSync(e,r){if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return this.#E.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(this.#e.existsSync(n))return this.#e.readFileSync(n);if({resolvedPath:n}=this.resolveWorkspacePath(e,!0),this.#e.existsSync(n))return this.#e.readFileSync(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async writeFile(e,r,n){if(typeof e!="string")throw new TypeError(`writeFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!n){let i=Ga(e,"write",this.#u?.accessControl,this.#z());if(!i.allowed)throw new $t(`ACL denied: ${i.message}`)}try{let{resolvedPath:i}=this.resolveWorkspacePath(e,!!n);return await this.#e.writeFile(i,r),i}catch(i){return this.#e.Sentry?.captureException(i,{extra:{filePath:e}}),null}}async listDir(e){if(typeof e!="string")throw new TypeError(`listDir: 'dirPath' must be a string, received ${typeof e}: ${oa(e)}`);let r=Ga(e,"list",this.#u?.accessControl,this.#z());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);if(!Jge({resolvedPath:n,workingDirectory:this.#I,workspace:this.#E,sys:this.#e}))throw new $t("Access denied: path outside working directory");if(!await this.#e.exists(n))return[];let A=(await(0,mye.readdir)(n,{withFileTypes:!0})).map(c=>c.name+(c.isDirectory()?"/":""));if(this.#N()){let c=A.map(u=>gs(this.#e.join(e,u)));return im({files:c,policy:this.#u?.accessControl,getDotFiles:!0})}if(i&&this.#E?.folders){let c=i.name||i.path,u=e;e.startsWith(c+"/")?u=e.substring(c.length+1):e===c&&(u="");let l=A.map(p=>{let g=u?this.#e.join(u,p):p,d=gs(g);return`${c}/${d}`});return im({files:l,policy:this.#u?.accessControl,getDotFiles:!0})}return im({files:A,policy:this.#u?.accessControl,getDotFiles:!0})}catch(n){return this.#e.Sentry?.captureException(n,{extra:{dirPath:e}}),[]}}async listCustomInstructions(){return(await this.#Se()).filter(r=>!r.hideUI).map(r=>({id:r.id,name:r.name,description:r.description,type:r.type,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,disableModelInvocation:r.disableModelInvocation,userInvocable:r.userInvocable}))}async stat(e,r){if(typeof e!="string")throw new TypeError(`stat: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(await this.#e.exists(n))return await this.#e.stat(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async deleteFile(e,r){if(typeof e!="string")throw new TypeError(`deleteFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"write",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r);return await this.#e.exists(n)?(await this.#e.unlink(n),n):null}catch(n){return this.#e.Sentry?.captureException(n,{extra:{filePath:e}}),null}}getLinesStats(){let e=this.#n?.turns.reduce((r,n)=>{let i=n.applyResults.reduce((o,s)=>({added:o.added+s.addedLines,removed:o.removed+s.removedLines}),{added:0,removed:0});return{added:r.added+i.added,removed:r.removed+i.removed}},{added:0,removed:0})??{added:0,removed:0};return{...e,net:e.added-e.removed}}async getDiffFromRemote({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){if(!this.#m)return[];let o=this.#ve(i);try{let s=(await this.git(["branch","--show-current"],{cwd:o})).trim();if(!s)throw new Error("Could not determine current branch");let a=!1;try{a=(await this.git(["remote"],{cwd:o})).includes("origin")}catch(p){throw this.#r.warn("No git remotes configured, cannot get diff from remote"),p}if(!a){this.#r.warn("Origin remote not found, trying to get diff from main branch");try{return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(p){throw this.#r.warn("Failed to get diff from main branch:",p),p}}let A=!1,c;try{let p=`origin/${s}`;if(A=(await this.git(["ls-remote","--heads","origin",s],{cwd:o})).trim().length>0,A)c=p;else return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(p){throw this.#r.warn("Failed to check remote branches:",p),p}let u=["diff",c];r?u.push("--raw","--numstat","--no-renames"):e!==void 0&&u.push(`-U${e}`),u.push("--"),n&&n.length>0&&u.push(...n);let l=await this.git(u,{cwd:o});return!l||l.trim()===""?[]:q$(l,r)}catch(s){throw s instanceof rd||this.#r.error("getDiffFromRemote error:",s),s}}async getDiff({mode:e="remote-parent-branch",numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o}){if(!this.#m)return{state:"error",error:new Error("Git not configured")};try{switch(e){case"remote-parent-branch":return{state:"success",diff:await this.getDiffFromParentBranch({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};case"remote-current-branch":return{state:"success",diff:await this.getDiffFromRemote({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};default:throw new Error(`Unknown diff mode: ${e}`)}}catch(s){return s instanceof rd?{state:"error",error:s}:(this.#r.error(`getDiff error for mode '${e}':`,s),this.#e.Sentry?.captureException(s),{state:"error",error:s instanceof Error?s:new Error(String(s))})}}async getDefaultBranch(e){let r=e??"__primary__",n=this.#Oe.get(r);if(n)return n;let i=this.#Br(e).catch(o=>{throw this.#Oe.get(r)===i&&this.#Oe.delete(r),o});return this.#Oe.set(r,i),i}async#Br(e){try{let n=(await this.git(["remote","show","origin"],{cwd:e})).match(/HEAD branch: (.+)/);if(n)return`origin/${n[1].trim()}`}catch{}try{if((await this.git(["ls-remote","--heads","origin","main"],{cwd:e})).trim().length>0)return"origin/main"}catch{}try{if((await this.git(["ls-remote","--heads","origin","master"],{cwd:e})).trim().length>0)return"origin/master"}catch{}try{let n=(await this.git(["ls-remote","--heads","origin"],{cwd:e})).trim().split(`
1961
- `).map(i=>i.split(" ")[1]).filter(i=>i&&!i.includes("HEAD"));if(n.length>0)return`origin/${n[0].replace("refs/heads/","")}`}catch{}throw new Error("Could not determine default branch. No remote branches found.")}async getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){let o=this.#ve(i);try{if(!(await this.git(["branch","--show-current"],{cwd:o})).trim())throw new Error("Could not determine current branch");let a=await this.#ct(o),A;try{A=(await this.git(["merge-base",a,"HEAD"],{cwd:o})).trim()}catch(l){throw l instanceof aa&&l.code===128?new rd(a,{cause:l}):l}let c=["--no-pager","diff",A];r?c.push("--raw","--numstat","--no-renames"):e!==void 0&&c.push(`-U${e}`),c.push("--"),n&&n.length>0&&c.push(...n);let u=await this.git(c,{cwd:o});return!u||u.trim()===""?[]:q$(u,r)}catch(s){throw s instanceof rd||this.#r.error("getDiffFromParentBranch error:",s),s}}},mF=(t,e)=>e.filter(r=>!t?.disabledTools?.includes(r))});function Oye(t){return t instanceof Error?t.message:String(t)}function iQ(t,e){if(CJ(e).test(t))return!0;if(e.toLowerCase().includes("localhost")){let n=e.replace(/localhost/gi,"127.0.0.1");if(CJ(n).test(t))return!0}else if(e.includes("127.0.0.1")){let n=e.replace(/127\.0\.0\.1/g,"localhost");if(CJ(n).test(t))return!0}return!1}function CJ(t){return t=String(t).replace(/\./g,"\\.").replace(/\?/g,".").replace(/\*/g,".*"),new RegExp(`^${t}$`,"i")}var QF,Gye=N(()=>{"use strict";m();QF=class{logger;currentOrigin=null;currentOriginPattern=null;currentDestination=null;currentOriginHost=null;constructor(e){this.logger=e}getCurrentOrigin(){return this.currentOrigin}getCurrentDestination(){return this.currentDestination}clearMapping(){this.currentOrigin=null,this.currentOriginPattern=null,this.currentDestination=null,this.currentOriginHost=null,this.logger?.info("[UrlMapper] Mapping cleared")}setMapping(e,r){if(e.includes("*")||!e.startsWith("https://")&&!e.startsWith("http://")){this.currentOriginPattern=e,this.currentOriginHost=null,this.currentOrigin=e;try{let i=new URL(r);this.currentDestination=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`}catch(i){this.logger?.error(`[UrlMapper] Failed to parse destination URL: ${Oye(i)}`),this.currentDestination=r}this.logger?.info(`[UrlMapper] Set mapping (PATTERN): ${e} \u2192 ${r}`)}else{this.currentOriginPattern=null;try{let i=new URL(e),o=i.protocol==="https:"?"443":"80",s=i.port||o;this.currentOriginHost=`${i.hostname}:${s}`,this.currentOrigin=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`;let a=new URL(r);this.currentDestination=`${a.protocol}//${a.hostname}${a.port?":"+a.port:""}`,this.logger?.info(`[UrlMapper] Set mapping (EXACT): ${e} \u2192 ${r}`),this.logger?.debug(`[UrlMapper] Normalized origin: ${this.currentOrigin} (host: ${this.currentOriginHost})`),this.logger?.debug(`[UrlMapper] Normalized destination: ${this.currentDestination}`)}catch(i){this.logger?.error(`[UrlMapper] Failed to parse origin/destination URL: ${Oye(i)}`),this.currentOriginHost=null,this.currentOrigin=e,this.currentDestination=r}}}getUpstream(e){if(!this.currentDestination)return null;if(this.currentOriginPattern){let r=this.currentOriginPattern.replace(/^https?:\/\//g,""),n=r.split(":")[0],i=e.split(":")[0];return iQ(i,n)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched hostname: ${n} -> ${this.currentDestination}`),this.currentDestination):iQ(e,r)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched host: ${r} -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO PATTERN MATCH getUpstream(${e}) !== ${r}`),null)}return this.currentOriginHost?iQ(e,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) -> ${this.currentDestination}`),this.currentDestination):iQ(`${e}:80`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (HTTP) -> ${this.currentDestination}`),this.currentDestination):iQ(`${e}:443`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (TLS) -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO MATCH getUpstream(${e}) !== ${this.currentOriginHost}`),null):null}buildUpstreamUrl(e,r="/"){let n=r||"/";n=n.replace(/^\/+/,"/");let i=new URL(n,e),o=new URL(e);return o.pathname=i.pathname.replace(/\/+/g,"/"),o.search=i.search,o.hash=i.hash,o}mapUrl(e){let r=e.host,n=this.getUpstream(r);if(!n)return e;let i=e.pathname+e.search+e.hash;return this.buildUpstreamUrl(n,i)}isOriginHttps(e=443){let r=this.currentOrigin?.split("://")[0];return r==="http"||r==="https"?r==="https":e===443}}});var Kye,Clt,IJ,Hye=N(()=>{"use strict";m();Kye=z(require("node:os"),1);Pt();Clt=ke("Priority"),IJ=(t,e)=>{try{Kye.default.setPriority(t,e)}catch(r){Clt.error(`Failed to set priority to ${e}: ${r}`)}}});function $ye(t){yJ=t}async function kh(){if(yJ){if(EJ){BJ=!0;return}EJ=!0;try{await yJ()}finally{EJ=!1,BJ&&(BJ=!1,kh())}}}var yJ,EJ,BJ,QJ=N(()=>{"use strict";m();EJ=!1,BJ=!1});async function*Ilt(t){for await(let e of Gf(t.body))if(e.length)try{yield JSON.parse(e)}catch{}}function Elt(t){t.toolContext.session.sendMessage({userPrompt:$ce({originChannelId:t.originChannelId,senderDisplayName:t.senderDisplayName,projectId:t.projectId,branchName:t.branchName,content:t.content}),category:"background-subagent",user:{...t.toolContext.user,role:"agent",source:"builder.io"},queue:!0})}function Blt(t,e){return e??("builderUserId"in t.user?t.user.builderUserId:t.user.source==="builder.io"?t.user.userId:t.credentials.userId)}function Jye(t,e){let{credentials:r}=t,{project_id:n,message:i}=e,o,s=new Promise(g=>o=g),a=!1,A,c,u,l;return(async()=>{let g=new URL("/projects/branch",Oe);g.searchParams.set("apiKey",r.builderPublicKey);let d=Blt(t,e.builder_user_id);d&&g.searchParams.set("userId",d);let f=e.model&&e.model!=="auto"?ym(e.model):void 0,h=e.attachment_urls?.map(y=>({type:"url",value:y})),C=e.origin_channel_id??t.user.channelId,I={projectId:n,userMessage:{userPrompt:i,user:{...t.user,channelId:C,role:"user"},...e.session_mode&&{sessionMode:e.session_mode},...f&&{modelOverride:f},...h?.length&&{attachments:h}},hidden:e.hidden,actor:"org-agent",metadata:{origin_channel_id:C}},B=await Ue(g,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.builderPrivateKey}`},body:JSON.stringify(I)},t.debug);if(!B.ok){let y=await B.text();throw new Error(`Failed to spawn branch: ${y}`)}let E;for await(let y of Ilt(B))if(y.type==="branch-created")E=y;else if(y.type==="error")E=y;else if(!a&&y.type==="setting-up-container")a=!0,c||(c=y.projectName),u||(u=y.branchFriendlyName??void 0),l||(l=y.branchName),o(y);else{let D=_ce(y);D&&(A=D.plan)}if(!E)throw new Error("Stream ended unexpectedly");return E})().then(g=>{a||o(null);let d=c??g.projectName??n,f=u??l??g.branchName,h=`https://builder.io/app/projects/${n}/${l??g.branchName}`;if(g.type!=="error"){let C=`Branch \`${f}\` in \`${d}\` completed.
1960
+ `)}`,1e4)}}catch(e){this.#e.Sentry?.captureException(e,{tags:{operation:"codegen-git"}});return}}#hr(){return["status","--porcelain=v1","-z","--ignore-submodules=dirty"]}async#ct(e){try{let r=this.#hr();return(await this.git(r,{cwd:e})).trim().length===0}catch{return!1}}async#Cr(e){try{return await this.git(["diff","--cached","--quiet"],{cwd:e}),!1}catch{return!0}}async#Ir(e,r){let n=r.applyResults,i=[];for(let o of n)try{if(o.action==="delete"){let s=await this.deleteFile(o.filePath);s&&i.push(s)}else if(o.content){let s=await this.writeFile(o.filePath,o.content);s&&(this.#Lt.add(s),i.push(s))}}catch(s){e.Sentry?.captureException(s)}return i}#N(){return this.#E?.folders?.length===1||!this.#E?.folders?.length}resolveWorkspacePath(e,r){if(typeof e!="string")throw new TypeError(`resolveWorkspacePath: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);return Hge({filePath:e,forceWorkspace:r,workspace:this.#E,workingDirectory:this.#I,sys:this.#e,canCollapseWorkspace:this.#N()})}#z(){try{let e=this.getSessionContext();return sc(e.turns)?.user.principals}catch{return}}absolutePathToWorkspaceUrl(e){return $ge({absolutePath:e,workspace:this.#E,workingDirectory:this.#I,sys:this.#e,canCollapseWorkspace:this.#N()})}async launchEditor(e={}){let r,n,i;return e.filePath?(r=this.resolveWorkspacePath(e.filePath,!1).resolvedPath,n=e.line??void 0,i=e.column??void 0):r=this.primaryGitPath,await this.#e.exists(r)?await this.#e.launchEditor({filePath:r,line:n,column:i}):{success:!1,message:`File not found: ${r}`}}async readFile(e,r){if(typeof e!="string")throw new TypeError(`readFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return this.#E.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r),i=await this.#e.readFile(n);return i!==null?i:({resolvedPath:n}=this.resolveWorkspacePath(e,!0),await this.#e.readFile(n))}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async readFileWithChecksum(e){let r=await this.readFile(e.filePath,e.skipAclCheck);if(r===null)return{content:null,checksum:null};let n=(0,oJ.createHash)("md5").update(r).digest("hex");return e.previousChecksum&&n===e.previousChecksum?{content:null,checksum:n,notModified:!0}:{content:r,checksum:n}}async readBinaryFile(e){let r=Ga(e,"read",this.#u?.accessControl,this.#z());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1),i=await this.#e.readBinaryFile(n);if(i===null&&({resolvedPath:n}=this.resolveWorkspacePath(e,!0),i=await this.#e.readBinaryFile(n)),i)return Buffer.from(i).toString("base64")}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async#ut(e){let r;e?r=this.#p.find(o=>o.path===e)?.branchName:r=this.gitEnabledFolder?.branchName;let n=r?r.startsWith("origin/")?r:`origin/${r}`:await this.getDefaultBranch(e);if(!n)throw new Error("Could not find parent branch");return n}async#Er(e){let r=this.#we.get(e);if(r&&Date.now()-r.timestamp<t.#wt)return r.promise;let n=(async()=>{let i=await this.#ut(e);try{return(await this.git(["merge-base",i,"HEAD"],{cwd:e})).trim()}catch{return i}})().catch(i=>{throw this.#we.get(e)?.promise===n&&this.#we.delete(e),i});return this.#we.set(e,{promise:n,timestamp:Date.now()}),n}async getFileAtRef(e,r,n){if(!this.#m)return null;try{let i,o;if(n)i=n,e.startsWith(i)?(o=e.substring(i.length),o.startsWith("/")&&(o=o.substring(1))):o=e;else{let{resolvedPath:u,workspaceFolder:l}=this.resolveWorkspacePath(e,!0);i=l?.path||this.#I,o=e,i&&u.startsWith(i)&&(o=u.substring(i.length),o.startsWith("/")&&(o=o.substring(1)))}let s=r??await this.#Er(i),a=`${i}:${s}:${o}`,A=this.#be.get(a);if(A&&Date.now()-A.timestamp<t.#wt)return A.promise;let c=this.git(["show",`${s}:${o}`],{cwd:i}).catch(u=>{let l=u instanceof Error?u.message:String(u);return l.includes("does not exist")||l.includes("exists on disk")||this.#be.get(a)?.promise===c&&this.#be.delete(a),null});return this.#be.set(a,{promise:c,timestamp:Date.now()}),c}catch{return null}}async getSingleFileDiff(e){if(e===null||typeof e!="string"&&typeof e!="object")throw new TypeError(`getSingleFileDiff: 'args' must be a string or object, received ${e===null?"null":typeof e}: ${oa(e)}`);let r=typeof e=="string"?{path:e}:e;if(typeof r.path!="string")throw new TypeError(`getSingleFileDiff: 'path' must be a string, received ${typeof r.path}: ${oa(r.path)}`);let n=typeof e=="object"?e.previousChecksum:void 0,{repoPath:i,relativePath:o}=this.#bt(r.path,r.folderName),s=this.#e.join(i,o),[a,A]=await Promise.all([this.#e.readFile(s).catch(()=>null),this.getFileAtRef(o,void 0,i)]),c=A===null?"":`${A}`,u=a===null?"":`${a}`,l=(0,oJ.createHash)("md5").update(`${c}\0${u}`).digest("hex"),p=A===null&&a!==null?"create":A!==null&&a===null?"delete":"update";return n===l?{oldContent:null,newContent:null,action:p,checksum:l,notModified:!0}:{oldContent:A,newContent:a,action:p,checksum:l}}async discardFileChanges(e){let r=typeof e=="string"?{filePath:e}:e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let{repoPath:n,relativePath:i}=this.#bt(r.filePath,r.folderName),o=this.#e.join(n,i),s=await this.#ut(n),a;try{a=(await this.git(["merge-base",s,"HEAD"],{cwd:n})).trim()}catch{a=s}let A=await this.getFileAtRef(i,a,n),u=(await this.git(["--no-pager","diff",`${a}`,"HEAD","--",i],{cwd:n})).trim().length>0,p=(await this.git(["status","--porcelain","--",i],{cwd:n})).trim().length>0;if(!u&&!p)return{success:!0};if(A===null){try{await this.#e.exists(o)&&await this.#e.unlink(o)}catch{}let f=this.#e.dirname(i);if(f&&f!==".")try{await this.git(["clean","-fd",f],{cwd:n})}catch{}}else try{await this.git(["restore",`--source=${a}`,"--",i],{cwd:n})}catch(f){return{success:!1,error:`Failed to restore file: ${f}`}}await this.git(["add","--",i],{cwd:n});let g=`Discard changes to ${i}`;await this.git(["commit","--no-gpg-sign","-m",g],{cwd:n});let d=(await this.git(["rev-parse","HEAD"],{cwd:n})).trim();try{await this.#S()}catch(f){this.#e.Sentry?.captureException(f,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!0,commitHash:d}}catch(n){try{await this.#S()}catch(i){this.#e.Sentry?.captureException(i,{tags:{operation:"discard-file-changes",step:"emit-git-status"}})}return{success:!1,error:n instanceof Error?n.message:String(n)}}}async revertDiscard(e){let{commitHash:r,folderName:n}=e;if(!this.#m)return{success:!1,error:"Git not configured"};try{let i=this.#ve(n);await this.git(["revert","--no-edit",r],{cwd:i});try{await this.#S()}catch(o){this.#e.Sentry?.captureException(o,{tags:{operation:"revert-discard",step:"emit-git-status"}})}return{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async fileExists(e){if(typeof e!="string")throw new TypeError(`fileExists: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);let r=n=>n.startsWith(this.#I)?this.#e.relative(this.#I,n):n;try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return{absolutePath:e,recommendedPath:void 0,workspaceFolder:void 0,virtual:!0};let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);return await this.#e.exists(n)?{absolutePath:n,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:i?{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:i,virtual:!1}:({resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!0),await this.#e.exists(n)?{absolutePath:n,recommendedPath:r(n),workspaceFolder:i,virtual:!1}:{absolutePath:void 0,recommendedPath:r(n),workspaceFolder:i,virtual:!1})}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return{absolutePath:void 0,recommendedPath:void 0,workspaceFolder:void 0,virtual:!1}}readFileSync(e,r){if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{if(e==="AGENTS.md"&&this.#E?.agentsMD)return this.#E.agentsMD;let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(this.#e.existsSync(n))return this.#e.readFileSync(n);if({resolvedPath:n}=this.resolveWorkspacePath(e,!0),this.#e.existsSync(n))return this.#e.readFileSync(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async writeFile(e,r,n){if(typeof e!="string")throw new TypeError(`writeFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!n){let i=Ga(e,"write",this.#u?.accessControl,this.#z());if(!i.allowed)throw new $t(`ACL denied: ${i.message}`)}try{let{resolvedPath:i}=this.resolveWorkspacePath(e,!!n);return await this.#e.writeFile(i,r),i}catch(i){return this.#e.Sentry?.captureException(i,{extra:{filePath:e}}),null}}async listDir(e){if(typeof e!="string")throw new TypeError(`listDir: 'dirPath' must be a string, received ${typeof e}: ${oa(e)}`);let r=Ga(e,"list",this.#u?.accessControl,this.#z());if(!r.allowed)throw new $t(`ACL denied: ${r.message}`);try{let{resolvedPath:n,workspaceFolder:i}=this.resolveWorkspacePath(e,!1);if(!Jge({resolvedPath:n,workingDirectory:this.#I,workspace:this.#E,sys:this.#e}))throw new $t("Access denied: path outside working directory");if(!await this.#e.exists(n))return[];let A=(await(0,mye.readdir)(n,{withFileTypes:!0})).map(c=>c.name+(c.isDirectory()?"/":""));if(this.#N()){let c=A.map(u=>gs(this.#e.join(e,u)));return im({files:c,policy:this.#u?.accessControl,getDotFiles:!0})}if(i&&this.#E?.folders){let c=i.name||i.path,u=e;e.startsWith(c+"/")?u=e.substring(c.length+1):e===c&&(u="");let l=A.map(p=>{let g=u?this.#e.join(u,p):p,d=gs(g);return`${c}/${d}`});return im({files:l,policy:this.#u?.accessControl,getDotFiles:!0})}return im({files:A,policy:this.#u?.accessControl,getDotFiles:!0})}catch(n){return this.#e.Sentry?.captureException(n,{extra:{dirPath:e}}),[]}}async listCustomInstructions(){return(await this.#Se()).filter(r=>!r.hideUI).map(r=>({id:r.id,name:r.name,description:r.description,type:r.type,isSkill:r.isSkill??r.filePath?.toLowerCase().includes("/skills/")??!1,disableModelInvocation:r.disableModelInvocation,userInvocable:r.userInvocable}))}async stat(e,r){if(typeof e!="string")throw new TypeError(`stat: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"read",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!1);if(await this.#e.exists(n))return await this.#e.stat(n)}catch(n){this.#e.Sentry?.captureException(n,{extra:{filePath:e}})}return null}async deleteFile(e,r){if(typeof e!="string")throw new TypeError(`deleteFile: 'filePath' must be a string, received ${typeof e}: ${oa(e)}`);if(!r){let n=Ga(e,"write",this.#u?.accessControl,this.#z());if(!n.allowed)throw new $t(`ACL denied: ${n.message}`)}try{let{resolvedPath:n}=this.resolveWorkspacePath(e,!!r);return await this.#e.exists(n)?(await this.#e.unlink(n),n):null}catch(n){return this.#e.Sentry?.captureException(n,{extra:{filePath:e}}),null}}getLinesStats(){let e=this.#n?.turns.reduce((r,n)=>{let i=n.applyResults.reduce((o,s)=>({added:o.added+s.addedLines,removed:o.removed+s.removedLines}),{added:0,removed:0});return{added:r.added+i.added,removed:r.removed+i.removed}},{added:0,removed:0})??{added:0,removed:0};return{...e,net:e.added-e.removed}}async getDiffFromRemote({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){if(!this.#m)return[];let o=this.#ve(i);try{let s=(await this.git(["branch","--show-current"],{cwd:o})).trim();if(!s)throw new Error("Could not determine current branch");let a=!1;try{a=(await this.git(["remote"],{cwd:o})).includes("origin")}catch(p){throw this.#r.warn("No git remotes configured, cannot get diff from remote"),p}if(!a){this.#r.warn("Origin remote not found, trying to get diff from main branch");try{return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(p){throw this.#r.warn("Failed to get diff from main branch:",p),p}}let A=!1,c;try{let p=`origin/${s}`;if(A=(await this.git(["ls-remote","--heads","origin",s],{cwd:o})).trim().length>0,A)c=p;else return await this.getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i})}catch(p){throw this.#r.warn("Failed to check remote branches:",p),p}let u=["diff",c];r?u.push("--raw","--numstat","--no-renames"):e!==void 0&&u.push(`-U${e}`),u.push("--"),n&&n.length>0&&u.push(...n);let l=await this.git(u,{cwd:o});return!l||l.trim()===""?[]:q$(l,r)}catch(s){throw s instanceof rd||this.#r.error("getDiffFromRemote error:",s),s}}async getDiff({mode:e="remote-parent-branch",numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o}){if(!this.#m)return{state:"error",error:new Error("Git not configured")};try{switch(e){case"remote-parent-branch":return{state:"success",diff:await this.getDiffFromParentBranch({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};case"remote-current-branch":return{state:"success",diff:await this.getDiffFromRemote({numberOfContextLines:r,includeFilesOnly:n,filePaths:i,folderName:o})};default:throw new Error(`Unknown diff mode: ${e}`)}}catch(s){return s instanceof rd?{state:"error",error:s}:(this.#r.error(`getDiff error for mode '${e}':`,s),this.#e.Sentry?.captureException(s),{state:"error",error:s instanceof Error?s:new Error(String(s))})}}async getDefaultBranch(e){let r=e??"__primary__",n=this.#Oe.get(r);if(n)return n;let i=this.#Br(e).catch(o=>{throw this.#Oe.get(r)===i&&this.#Oe.delete(r),o});return this.#Oe.set(r,i),i}async#Br(e){try{let n=(await this.git(["remote","show","origin"],{cwd:e})).match(/HEAD branch: (.+)/);if(n)return`origin/${n[1].trim()}`}catch{}try{if((await this.git(["ls-remote","--heads","origin","main"],{cwd:e})).trim().length>0)return"origin/main"}catch{}try{if((await this.git(["ls-remote","--heads","origin","master"],{cwd:e})).trim().length>0)return"origin/master"}catch{}try{let n=(await this.git(["ls-remote","--heads","origin"],{cwd:e})).trim().split(`
1961
+ `).map(i=>i.split(" ")[1]).filter(i=>i&&!i.includes("HEAD"));if(n.length>0)return`origin/${n[0].replace("refs/heads/","")}`}catch{}throw new Error("Could not determine default branch. No remote branches found.")}async getDiffFromParentBranch({numberOfContextLines:e,includeFilesOnly:r,filePaths:n,folderName:i}){let o=this.#ve(i);try{if(!(await this.git(["branch","--show-current"],{cwd:o})).trim())throw new Error("Could not determine current branch");let a=await this.#ut(o),A;try{A=(await this.git(["merge-base",a,"HEAD"],{cwd:o})).trim()}catch(l){throw l instanceof aa&&l.code===128?new rd(a,{cause:l}):l}let c=["--no-pager","diff",A];r?c.push("--raw","--numstat","--no-renames"):e!==void 0&&c.push(`-U${e}`),c.push("--"),n&&n.length>0&&c.push(...n);let u=await this.git(c,{cwd:o});return!u||u.trim()===""?[]:q$(u,r)}catch(s){throw s instanceof rd||this.#r.error("getDiffFromParentBranch error:",s),s}}},mF=(t,e)=>e.filter(r=>!t?.disabledTools?.includes(r))});function Oye(t){return t instanceof Error?t.message:String(t)}function iQ(t,e){if(CJ(e).test(t))return!0;if(e.toLowerCase().includes("localhost")){let n=e.replace(/localhost/gi,"127.0.0.1");if(CJ(n).test(t))return!0}else if(e.includes("127.0.0.1")){let n=e.replace(/127\.0\.0\.1/g,"localhost");if(CJ(n).test(t))return!0}return!1}function CJ(t){return t=String(t).replace(/\./g,"\\.").replace(/\?/g,".").replace(/\*/g,".*"),new RegExp(`^${t}$`,"i")}var QF,Gye=N(()=>{"use strict";m();QF=class{logger;currentOrigin=null;currentOriginPattern=null;currentDestination=null;currentOriginHost=null;constructor(e){this.logger=e}getCurrentOrigin(){return this.currentOrigin}getCurrentDestination(){return this.currentDestination}clearMapping(){this.currentOrigin=null,this.currentOriginPattern=null,this.currentDestination=null,this.currentOriginHost=null,this.logger?.info("[UrlMapper] Mapping cleared")}setMapping(e,r){if(e.includes("*")||!e.startsWith("https://")&&!e.startsWith("http://")){this.currentOriginPattern=e,this.currentOriginHost=null,this.currentOrigin=e;try{let i=new URL(r);this.currentDestination=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`}catch(i){this.logger?.error(`[UrlMapper] Failed to parse destination URL: ${Oye(i)}`),this.currentDestination=r}this.logger?.info(`[UrlMapper] Set mapping (PATTERN): ${e} \u2192 ${r}`)}else{this.currentOriginPattern=null;try{let i=new URL(e),o=i.protocol==="https:"?"443":"80",s=i.port||o;this.currentOriginHost=`${i.hostname}:${s}`,this.currentOrigin=`${i.protocol}//${i.hostname}${i.port?":"+i.port:""}`;let a=new URL(r);this.currentDestination=`${a.protocol}//${a.hostname}${a.port?":"+a.port:""}`,this.logger?.info(`[UrlMapper] Set mapping (EXACT): ${e} \u2192 ${r}`),this.logger?.debug(`[UrlMapper] Normalized origin: ${this.currentOrigin} (host: ${this.currentOriginHost})`),this.logger?.debug(`[UrlMapper] Normalized destination: ${this.currentDestination}`)}catch(i){this.logger?.error(`[UrlMapper] Failed to parse origin/destination URL: ${Oye(i)}`),this.currentOriginHost=null,this.currentOrigin=e,this.currentDestination=r}}}getUpstream(e){if(!this.currentDestination)return null;if(this.currentOriginPattern){let r=this.currentOriginPattern.replace(/^https?:\/\//g,""),n=r.split(":")[0],i=e.split(":")[0];return iQ(i,n)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched hostname: ${n} -> ${this.currentDestination}`),this.currentDestination):iQ(e,r)?(this.logger?.debug(`[UrlMapper] PATTERN MATCH FOUND getUpstream(${e}) matched host: ${r} -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO PATTERN MATCH getUpstream(${e}) !== ${r}`),null)}return this.currentOriginHost?iQ(e,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) -> ${this.currentDestination}`),this.currentDestination):iQ(`${e}:80`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (HTTP) -> ${this.currentDestination}`),this.currentDestination):iQ(`${e}:443`,this.currentOriginHost)?(this.logger?.debug(`[UrlMapper] MATCH FOUND getUpstream(${e}) (TLS) -> ${this.currentDestination}`),this.currentDestination):(this.logger?.debug(`[UrlMapper] NO MATCH getUpstream(${e}) !== ${this.currentOriginHost}`),null):null}buildUpstreamUrl(e,r="/"){let n=r||"/";n=n.replace(/^\/+/,"/");let i=new URL(n,e),o=new URL(e);return o.pathname=i.pathname.replace(/\/+/g,"/"),o.search=i.search,o.hash=i.hash,o}mapUrl(e){let r=e.host,n=this.getUpstream(r);if(!n)return e;let i=e.pathname+e.search+e.hash;return this.buildUpstreamUrl(n,i)}isOriginHttps(e=443){let r=this.currentOrigin?.split("://")[0];return r==="http"||r==="https"?r==="https":e===443}}});var Kye,Clt,IJ,Hye=N(()=>{"use strict";m();Kye=z(require("node:os"),1);Pt();Clt=ke("Priority"),IJ=(t,e)=>{try{Kye.default.setPriority(t,e)}catch(r){Clt.error(`Failed to set priority to ${e}: ${r}`)}}});function $ye(t){yJ=t}async function kh(){if(yJ){if(EJ){BJ=!0;return}EJ=!0;try{await yJ()}finally{EJ=!1,BJ&&(BJ=!1,kh())}}}var yJ,EJ,BJ,QJ=N(()=>{"use strict";m();EJ=!1,BJ=!1});async function*Ilt(t){for await(let e of Gf(t.body))if(e.length)try{yield JSON.parse(e)}catch{}}function Elt(t){t.toolContext.session.sendMessage({userPrompt:$ce({originChannelId:t.originChannelId,senderDisplayName:t.senderDisplayName,projectId:t.projectId,branchName:t.branchName,content:t.content}),category:"background-subagent",user:{...t.toolContext.user,role:"agent",source:"builder.io"},queue:!0})}function Blt(t,e){return e??("builderUserId"in t.user?t.user.builderUserId:t.user.source==="builder.io"?t.user.userId:t.credentials.userId)}function Jye(t,e){let{credentials:r}=t,{project_id:n,message:i}=e,o,s=new Promise(g=>o=g),a=!1,A,c,u,l;return(async()=>{let g=new URL("/projects/branch",Oe);g.searchParams.set("apiKey",r.builderPublicKey);let d=Blt(t,e.builder_user_id);d&&g.searchParams.set("userId",d);let f=e.model&&e.model!=="auto"?ym(e.model):void 0,h=e.attachment_urls?.map(y=>({type:"url",value:y})),C=e.origin_channel_id??t.user.channelId,I={projectId:n,userMessage:{userPrompt:i,user:{...t.user,channelId:C,role:"user"},...e.session_mode&&{sessionMode:e.session_mode},...f&&{modelOverride:f},...h?.length&&{attachments:h}},hidden:e.hidden,actor:"org-agent",metadata:{origin_channel_id:C}},B=await Ue(g,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.builderPrivateKey}`},body:JSON.stringify(I)},t.debug);if(!B.ok){let y=await B.text();throw new Error(`Failed to spawn branch: ${y}`)}let E;for await(let y of Ilt(B))if(y.type==="branch-created")E=y;else if(y.type==="error")E=y;else if(!a&&y.type==="setting-up-container")a=!0,c||(c=y.projectName),u||(u=y.branchFriendlyName??void 0),l||(l=y.branchName),o(y);else{let D=_ce(y);D&&(A=D.plan)}if(!E)throw new Error("Stream ended unexpectedly");return E})().then(g=>{a||o(null);let d=c??g.projectName??n,f=u??l??g.branchName,h=`https://builder.io/app/projects/${n}/${l??g.branchName}`;if(g.type!=="error"){let C=`Branch \`${f}\` in \`${d}\` completed.
1962
1962
  - Url: \`${h}\`
1963
1963
 
1964
1964
  ==================
@@ -2799,7 +2799,7 @@ return fn.apply(this, arguments)
2799
2799
  `)+`\r
2800
2800
  \r
2801
2801
  `+r)}function Ed(t,e,r,n,i,o){if(t.listenerCount("wsClientError")){let s=new Error(i);Error.captureStackTrace(s,Ed),t.emit("wsClientError",s,r,e)}else JQ(r,n,i,o)}});var uRe=k((pwr,cRe)=>{m();var IY=class{constructor(e,r,n){this.etaBufferLength=e||100,this.valueBuffer=[n],this.timeBuffer=[r],this.eta="0"}update(e,r,n){this.valueBuffer.push(r),this.timeBuffer.push(e),this.calculate(n-r)}getTime(){return this.eta}calculate(e){let r=this.valueBuffer.length,n=Math.min(this.etaBufferLength,r),i=this.valueBuffer[r-1]-this.valueBuffer[r-n],o=this.timeBuffer[r-1]-this.timeBuffer[r-n],s=i/o;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let a=Math.ceil(e/s/1e3);isNaN(a)?this.eta="NULL":isFinite(a)?a>1e7?this.eta="INF":a<0?this.eta=0:this.eta=a:this.eta="INF"}};cRe.exports=IY});var BY=k((fwr,lRe)=>{m();var yd=require("readline"),EY=class{constructor(e){this.stream=e,this.linewrap=!0,this.dy=0}cursorSave(){this.stream.isTTY&&this.stream.write("\x1B7")}cursorRestore(){this.stream.isTTY&&this.stream.write("\x1B8")}cursor(e){this.stream.isTTY&&(e?this.stream.write("\x1B[?25h"):this.stream.write("\x1B[?25l"))}cursorTo(e=null,r=null){this.stream.isTTY&&yd.cursorTo(this.stream,e,r)}cursorRelative(e=null,r=null){this.stream.isTTY&&(this.dy=this.dy+r,yd.moveCursor(this.stream,e,r))}cursorRelativeReset(){this.stream.isTTY&&(yd.moveCursor(this.stream,0,-this.dy),yd.cursorTo(this.stream,0,null),this.dy=0)}clearRight(){this.stream.isTTY&&yd.clearLine(this.stream,1)}clearLine(){this.stream.isTTY&&yd.clearLine(this.stream,0)}clearBottom(){this.stream.isTTY&&yd.clearScreenDown(this.stream)}newline(){this.stream.write(`
2802
- `),this.dy++}write(e,r=!1){this.linewrap===!0&&r===!1?this.stream.write(e.substr(0,this.getWidth())):this.stream.write(e)}lineWrapping(e){this.stream.isTTY&&(this.linewrap=e,e?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};lRe.exports=EY});var pRe=k((hwr,yY)=>{"use strict";m();var gRe=t=>Number.isNaN(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);yY.exports=gRe;yY.exports.default=gRe});var fRe=k((Iwr,dRe)=>{"use strict";m();dRe.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var hRe=k((Bwr,QY)=>{"use strict";m();var jwt=t2(),Ywt=pRe(),qwt=fRe(),mRe=t=>{if(typeof t!="string"||t.length===0||(t=jwt(t),t.length===0))return 0;t=t.replace(qwt()," ");let e=0;for(let r=0;r<t.length;r++){let n=t.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,e+=Ywt(n)?2:1)}return e};QY.exports=mRe;QY.exports.default=mRe});var DY=k((Qwr,CRe)=>{m();CRe.exports=function(e,r,n){if(r.autopadding!==!0)return e;function i(o,s){return(r.autopaddingChar+o).slice(-s)}return n==="percentage"?i(e,3):e}});var wY=k((wwr,IRe)=>{m();IRe.exports=function(e,r){let n=Math.round(e*r.barsize),i=r.barsize-n;return r.barCompleteString.substr(0,n)+r.barGlue+r.barIncompleteString.substr(0,i)}});var bY=k((vwr,ERe)=>{m();ERe.exports=function(e,r,n){function i(s){return n?n*Math.round(s/n):s}function o(s){return(r.autopaddingChar+s).slice(-2)}return e>3600?o(Math.floor(e/3600))+"h"+o(i(e%3600/60))+"m":e>60?o(Math.floor(e/60))+"m"+o(i(e%60))+"s":e>10?o(i(e))+"s":o(e)+"s"}});var vY=k((xwr,BRe)=>{m();var Vwt=hRe(),zwt=DY(),Wwt=wY(),Zwt=bY();BRe.exports=function(e,r,n){let i=e.format,o=e.formatTime||Zwt,s=e.formatValue||zwt,a=e.formatBar||Wwt,A=Math.floor(r.progress*100)+"",c=r.stopTime||Date.now(),u=Math.round((c-r.startTime)/1e3),l=Object.assign({},n,{bar:a(r.progress,e),percentage:s(A,e,"percentage"),total:s(r.total,e,"total"),value:s(r.value,e,"value"),eta:s(r.eta,e,"eta"),eta_formatted:o(r.eta,e,5),duration:s(u,e,"duration"),duration_formatted:o(u,e,1)});i=i.replace(/\{(\w+)\}/g,function(d,f){return typeof l[f]<"u"?l[f]:d});let p=Math.max(0,r.maxWidth-Vwt(i)-2),g=Math.floor(p/2);switch(e.align){case"right":i=p>0?" ".repeat(p)+i:i;break;case"center":i=g>0?" ".repeat(g)+i:i;break;default:break}return i}});var gR=k((kwr,yRe)=>{m();function Mr(t,e){return typeof t>"u"||t===null?e:t}yRe.exports={parse:function(e,r){let n={},i=Object.assign({},r,e);return n.throttleTime=1e3/Mr(i.fps,10),n.stream=Mr(i.stream,process.stderr),n.terminal=Mr(i.terminal,null),n.clearOnComplete=Mr(i.clearOnComplete,!1),n.stopOnComplete=Mr(i.stopOnComplete,!1),n.barsize=Mr(i.barsize,40),n.align=Mr(i.align,"left"),n.hideCursor=Mr(i.hideCursor,!1),n.linewrap=Mr(i.linewrap,!1),n.barGlue=Mr(i.barGlue,""),n.barCompleteChar=Mr(i.barCompleteChar,"="),n.barIncompleteChar=Mr(i.barIncompleteChar,"-"),n.format=Mr(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=Mr(i.formatTime,null),n.formatValue=Mr(i.formatValue,null),n.formatBar=Mr(i.formatBar,null),n.etaBufferLength=Mr(i.etaBuffer,10),n.etaAsynchronousUpdate=Mr(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=Mr(i.progressCalculationRelative,!1),n.synchronousUpdate=Mr(i.synchronousUpdate,!0),n.noTTYOutput=Mr(i.noTTYOutput,!1),n.notTTYSchedule=Mr(i.notTTYSchedule,2e3),n.emptyOnZero=Mr(i.emptyOnZero,!1),n.forceRedraw=Mr(i.forceRedraw,!1),n.autopadding=Mr(i.autopadding,!1),n.gracefulExit=Mr(i.gracefulExit,!1),n},assignDerivedOptions:function(e){return e.barCompleteString=e.barCompleteChar.repeat(e.barsize+1),e.barIncompleteString=e.barIncompleteChar.repeat(e.barsize+1),e.autopaddingChar=e.autopadding?Mr(e.autopaddingChar," "):"",e}}});var SY=k((Twr,DRe)=>{m();var QRe=uRe(),Xwt=BY(),e0t=vY(),t0t=gR(),r0t=require("events");DRe.exports=class extends r0t{constructor(e){super(),this.options=t0t.assignDerivedOptions(e),this.terminal=this.options.terminal?this.options.terminal:new Xwt(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new QRe(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:e0t}render(e=!1){let r={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,r,this.payload);(e||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(e,r,n){this.value=r||0,this.total=typeof e<"u"&&e>=0?e:100,this.startValue=r||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new QRe(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",e,r)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(e,r={}){typeof e=="number"&&(this.value=e,this.eta.update(Date.now(),e,this.total));let n=(typeof e=="object"?e:r)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let e=this.value/this.total;return this.options.progressCalculationRelative&&(e=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(e)&&(e=this.options&&this.options.emptyOnZero?0:1),e=Math.min(Math.max(e,0),1),e}increment(e=1,r={}){typeof e=="object"?this.update(this.value+1,e):this.update(this.value+e,r)}getTotal(){return this.total}setTotal(e){typeof e<"u"&&e>=0&&(this.total=e)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var bRe=k((_wr,wRe)=>{m();var n0t=SY(),i0t=gR();wRe.exports=class extends n0t{constructor(e,r){super(i0t.parse(e,r)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(e,r){this.timer&&(super.update(e,r),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(e,r,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(e,r,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var SRe=k((Owr,vRe)=>{m();var o0t=BY(),s0t=SY(),a0t=gR(),A0t=require("events");vRe.exports=class extends A0t{constructor(e,r){super(),this.bars=[],this.options=a0t.parse(e,r),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new o0t(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(e,r,n,i={}){let o=new s0t(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(o),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,o.start(e,r,n),this.emit("start")),o}remove(e){let r=this.bars.indexOf(e);return r<0?!1:(this.bars.splice(r,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(e=>e.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render(),this.bars[e].stop();this.terminal.newline()}this.emit("stop")}log(e){this.loggingBuffer.push(e)}}});var FRe=k((Kwr,xRe)=>{m();xRe.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var RRe=k(($wr,kRe)=>{m();kRe.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var TRe=k((jwr,NRe)=>{m();NRe.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var PRe=k((qwr,MRe)=>{m();MRe.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var LRe=k((zwr,_Re)=>{m();var c0t=FRe(),u0t=RRe(),l0t=TRe(),g0t=PRe();_Re.exports={legacy:c0t,shades_classic:u0t,shades_grey:l0t,rect:g0t}});var GRe=k((Zwr,ORe)=>{m();var URe=bRe(),p0t=SRe(),d0t=LRe(),f0t=vY(),m0t=DY(),h0t=wY(),C0t=bY();ORe.exports={Bar:URe,SingleBar:URe,MultiBar:p0t,Presets:d0t,Format:{Formatter:f0t,BarFormat:h0t,ValueFormat:m0t,TimeFormat:C0t}}});var qRe=k((B0r,YRe)=>{m();YRe.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var kRt={};gA(kRt,{default:()=>FRt});module.exports=mn(kRt);m();m();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="8ad538a0-8a3a-4f6f-a9da-0e7d8bf599cd",t._sentryDebugIdIdentifier="sentry-dbid-8ad538a0-8a3a-4f6f-a9da-0e7d8bf599cd")}catch{}})();m();var ELe=require("../core/index.cjs"),BLe=require("../node/index.cjs"),yLe=require("../server/index.cjs"),QLe=z(N5(),1);m();m();var OF=require("fs/promises");VN();Bn();lE();mr();var An=z(Hr(),1),Oh=require("node:path");Sa();os();on();Pn();bh();var Spt="https://cdn.builder.io",mDe=async(t,e)=>{console.log(""),fr((0,An.bgCyan)((0,An.bold)((0,An.white)(" figma migrate ")))+" "+(0,An.dim)(vt));let{builderPrivateKey:r,builderPublicKey:n}=await Er(t,e,{forceSpaceId:e.spaceId,builderPrivateKey:!0,builderPublicKey:!0});await Jt("figma publish started",{spaceId:n});let i=await uE(t);if(i.length>0){await Jt("figma migrate with existing files",{spaceId:n}),O.warning(`${(0,An.yellow)("This repo already has figma mappings in:")}
2802
+ `),this.dy++}write(e,r=!1){this.linewrap===!0&&r===!1?this.stream.write(e.substr(0,this.getWidth())):this.stream.write(e)}lineWrapping(e){this.stream.isTTY&&(this.linewrap=e,e?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};lRe.exports=EY});var pRe=k((hwr,yY)=>{"use strict";m();var gRe=t=>Number.isNaN(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);yY.exports=gRe;yY.exports.default=gRe});var fRe=k((Iwr,dRe)=>{"use strict";m();dRe.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var hRe=k((Bwr,QY)=>{"use strict";m();var jwt=t2(),Ywt=pRe(),qwt=fRe(),mRe=t=>{if(typeof t!="string"||t.length===0||(t=jwt(t),t.length===0))return 0;t=t.replace(qwt()," ");let e=0;for(let r=0;r<t.length;r++){let n=t.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,e+=Ywt(n)?2:1)}return e};QY.exports=mRe;QY.exports.default=mRe});var DY=k((Qwr,CRe)=>{m();CRe.exports=function(e,r,n){if(r.autopadding!==!0)return e;function i(o,s){return(r.autopaddingChar+o).slice(-s)}return n==="percentage"?i(e,3):e}});var wY=k((wwr,IRe)=>{m();IRe.exports=function(e,r){let n=Math.round(e*r.barsize),i=r.barsize-n;return r.barCompleteString.substr(0,n)+r.barGlue+r.barIncompleteString.substr(0,i)}});var bY=k((vwr,ERe)=>{m();ERe.exports=function(e,r,n){function i(s){return n?n*Math.round(s/n):s}function o(s){return(r.autopaddingChar+s).slice(-2)}return e>3600?o(Math.floor(e/3600))+"h"+o(i(e%3600/60))+"m":e>60?o(Math.floor(e/60))+"m"+o(i(e%60))+"s":e>10?o(i(e))+"s":o(e)+"s"}});var vY=k((xwr,BRe)=>{m();var Vwt=hRe(),zwt=DY(),Wwt=wY(),Zwt=bY();BRe.exports=function(e,r,n){let i=e.format,o=e.formatTime||Zwt,s=e.formatValue||zwt,a=e.formatBar||Wwt,A=Math.floor(r.progress*100)+"",c=r.stopTime||Date.now(),u=Math.round((c-r.startTime)/1e3),l=Object.assign({},n,{bar:a(r.progress,e),percentage:s(A,e,"percentage"),total:s(r.total,e,"total"),value:s(r.value,e,"value"),eta:s(r.eta,e,"eta"),eta_formatted:o(r.eta,e,5),duration:s(u,e,"duration"),duration_formatted:o(u,e,1)});i=i.replace(/\{(\w+)\}/g,function(d,f){return typeof l[f]<"u"?l[f]:d});let p=Math.max(0,r.maxWidth-Vwt(i)-2),g=Math.floor(p/2);switch(e.align){case"right":i=p>0?" ".repeat(p)+i:i;break;case"center":i=g>0?" ".repeat(g)+i:i;break;default:break}return i}});var gR=k((kwr,yRe)=>{m();function Mr(t,e){return typeof t>"u"||t===null?e:t}yRe.exports={parse:function(e,r){let n={},i=Object.assign({},r,e);return n.throttleTime=1e3/Mr(i.fps,10),n.stream=Mr(i.stream,process.stderr),n.terminal=Mr(i.terminal,null),n.clearOnComplete=Mr(i.clearOnComplete,!1),n.stopOnComplete=Mr(i.stopOnComplete,!1),n.barsize=Mr(i.barsize,40),n.align=Mr(i.align,"left"),n.hideCursor=Mr(i.hideCursor,!1),n.linewrap=Mr(i.linewrap,!1),n.barGlue=Mr(i.barGlue,""),n.barCompleteChar=Mr(i.barCompleteChar,"="),n.barIncompleteChar=Mr(i.barIncompleteChar,"-"),n.format=Mr(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=Mr(i.formatTime,null),n.formatValue=Mr(i.formatValue,null),n.formatBar=Mr(i.formatBar,null),n.etaBufferLength=Mr(i.etaBuffer,10),n.etaAsynchronousUpdate=Mr(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=Mr(i.progressCalculationRelative,!1),n.synchronousUpdate=Mr(i.synchronousUpdate,!0),n.noTTYOutput=Mr(i.noTTYOutput,!1),n.notTTYSchedule=Mr(i.notTTYSchedule,2e3),n.emptyOnZero=Mr(i.emptyOnZero,!1),n.forceRedraw=Mr(i.forceRedraw,!1),n.autopadding=Mr(i.autopadding,!1),n.gracefulExit=Mr(i.gracefulExit,!1),n},assignDerivedOptions:function(e){return e.barCompleteString=e.barCompleteChar.repeat(e.barsize+1),e.barIncompleteString=e.barIncompleteChar.repeat(e.barsize+1),e.autopaddingChar=e.autopadding?Mr(e.autopaddingChar," "):"",e}}});var SY=k((Twr,DRe)=>{m();var QRe=uRe(),Xwt=BY(),e0t=vY(),t0t=gR(),r0t=require("events");DRe.exports=class extends r0t{constructor(e){super(),this.options=t0t.assignDerivedOptions(e),this.terminal=this.options.terminal?this.options.terminal:new Xwt(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new QRe(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:e0t}render(e=!1){let r={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,r,this.payload);(e||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(e,r,n){this.value=r||0,this.total=typeof e<"u"&&e>=0?e:100,this.startValue=r||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new QRe(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",e,r)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(e,r={}){typeof e=="number"&&(this.value=e,this.eta.update(Date.now(),e,this.total));let n=(typeof e=="object"?e:r)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let e=this.value/this.total;return this.options.progressCalculationRelative&&(e=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(e)&&(e=this.options&&this.options.emptyOnZero?0:1),e=Math.min(Math.max(e,0),1),e}increment(e=1,r={}){typeof e=="object"?this.update(this.value+1,e):this.update(this.value+e,r)}getTotal(){return this.total}setTotal(e){typeof e<"u"&&e>=0&&(this.total=e)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var bRe=k((_wr,wRe)=>{m();var n0t=SY(),i0t=gR();wRe.exports=class extends n0t{constructor(e,r){super(i0t.parse(e,r)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(e,r){this.timer&&(super.update(e,r),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(e,r,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(e,r,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var SRe=k((Owr,vRe)=>{m();var o0t=BY(),s0t=SY(),a0t=gR(),A0t=require("events");vRe.exports=class extends A0t{constructor(e,r){super(),this.bars=[],this.options=a0t.parse(e,r),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new o0t(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(e,r,n,i={}){let o=new s0t(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(o),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,o.start(e,r,n),this.emit("start")),o}remove(e){let r=this.bars.indexOf(e);return r<0?!1:(this.bars.splice(r,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(e=>e.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let e=0;e<this.bars.length;e++)e>0&&this.terminal.newline(),this.bars[e].render(),this.bars[e].stop();this.terminal.newline()}this.emit("stop")}log(e){this.loggingBuffer.push(e)}}});var FRe=k((Kwr,xRe)=>{m();xRe.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var RRe=k(($wr,kRe)=>{m();kRe.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var TRe=k((jwr,NRe)=>{m();NRe.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var PRe=k((qwr,MRe)=>{m();MRe.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var LRe=k((zwr,_Re)=>{m();var c0t=FRe(),u0t=RRe(),l0t=TRe(),g0t=PRe();_Re.exports={legacy:c0t,shades_classic:u0t,shades_grey:l0t,rect:g0t}});var GRe=k((Zwr,ORe)=>{m();var URe=bRe(),p0t=SRe(),d0t=LRe(),f0t=vY(),m0t=DY(),h0t=wY(),C0t=bY();ORe.exports={Bar:URe,SingleBar:URe,MultiBar:p0t,Presets:d0t,Format:{Formatter:f0t,BarFormat:h0t,ValueFormat:m0t,TimeFormat:C0t}}});var qRe=k((B0r,YRe)=>{m();YRe.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var kRt={};gA(kRt,{default:()=>FRt});module.exports=mn(kRt);m();m();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f98b9a9f-dd70-4492-9a9b-6cc22a155a7c",t._sentryDebugIdIdentifier="sentry-dbid-f98b9a9f-dd70-4492-9a9b-6cc22a155a7c")}catch{}})();m();var ELe=require("../core/index.cjs"),BLe=require("../node/index.cjs"),yLe=require("../server/index.cjs"),QLe=z(N5(),1);m();m();var OF=require("fs/promises");VN();Bn();lE();mr();var An=z(Hr(),1),Oh=require("node:path");Sa();os();on();Pn();bh();var Spt="https://cdn.builder.io",mDe=async(t,e)=>{console.log(""),fr((0,An.bgCyan)((0,An.bold)((0,An.white)(" figma migrate ")))+" "+(0,An.dim)(vt));let{builderPrivateKey:r,builderPublicKey:n}=await Er(t,e,{forceSpaceId:e.spaceId,builderPrivateKey:!0,builderPublicKey:!0});await Jt("figma publish started",{spaceId:n});let i=await uE(t);if(i.length>0){await Jt("figma migrate with existing files",{spaceId:n}),O.warning(`${(0,An.yellow)("This repo already has figma mappings in:")}
2803
2803
 
2804
2804
  ${i.map(c=>` - ${(0,Oh.relative)(t.getAppRootDir(),c)}`).join(`
2805
2805
  `)}