builder.io 1.13.5 → 1.14.0

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/core/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ii=Object.create;var Dt=Object.defineProperty;var Ri=Object.getOwnPropertyDescriptor;var Ni=Object.getOwnPropertyNames;var Bi=Object.getPrototypeOf,Oi=Object.prototype.hasOwnProperty;var ki=(e,t,r)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Li=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ni(t))!Oi.call(e,o)&&o!==r&&Dt(e,o,{get:()=>t[o],enumerable:!(n=Ri(t,o))||n.enumerable});return e};var rr=(e,t,r)=>(r=e!=null?Ii(Bi(e)):{},nr(t||!e||!e.__esModule?Dt(r,"default",{value:e,enumerable:!0}):r,e)),_i=e=>nr(Dt({},"__esModule",{value:!0}),e);var Me=(e,t,r)=>ki(e,typeof t!="symbol"?t+"":t,r);var sr=Le((wp,ar)=>{"use strict";ar.exports=function(){if(process.env.npm_config_user_agent)return $i(process.env.npm_config_user_agent)};function $i(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var jn=Le(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.throwUnsupportedData=We.throwUnknownDataType=We.getType=void 0;function Ho(e){return Object.prototype.toString.call(e)}We.getType=Ho;function $u(e){throw new TypeError("unsupported data type: "+Ho(e))}We.throwUnknownDataType=$u;function Ku(e){throw new TypeError("unsupported data type: "+e)}We.throwUnsupportedData=Ku});var Un=Le(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.s_to_num=G.int_str_to_s=G.num_to_s=G.big_int_to_s=G.int_to_s=G.s_to_big_int=G.s_to_int=void 0;var Ke="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Ke+=t}var dt=Ke.length,$n={};for(let e=0;e<dt;e++){let t=Ke[e];$n[t]=e}function Kn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=$n[o];i*=r,t+=i,r*=dt}return t}G.s_to_int=Kn;function Yo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(dt);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt($n[i]);a*=r,t+=a,r*=n}return t}G.s_to_big_int=Yo;function Mn(e){if(e===0)return Ke[0];let t=[];for(;e!==0;){let r=e%dt,n=Ke[r];t.push(n),e-=r,e/=dt}return t.reverse().join("")}G.int_to_s=Mn;function Go(e){let t=BigInt(0),r=BigInt(dt);if(e===t)return Ke[0];let n=[];for(;e!==t;){let o=e%r,i=Ke[Number(o)];n.push(i),e/=r}return n.reverse().join("")}G.big_int_to_s=Go;function Xo(e){return e.split("").reverse().join("")}function Zo(e){if(e<0)return"-"+Zo(-e);let[t,r]=e.toString().split(".");if(!r)if(t.includes("e")){let[i,a]=t.split("e");t=i,r="0e"+a}else return Mn(e);let n;r&&([r,n]=r.split("e")),t=Zt(t),r=Xo(r),r=Zt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Zt(n),o+=n}return o}G.num_to_s=Zo;function Zt(e){let t=+e;return t.toString()===e&&t+1!==t&&t-1!==t?Mn(t):":"+Go(BigInt(e))}G.int_str_to_s=Zt;function Vn(e){return e[0]===":"?Yo(e.substring(1)).toString():Kn(e).toString()}function ei(e){if(e[0]==="-")return-ei(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Kn(t);t=Vn(t),r=Vn(r),r=Xo(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=Vn(n),o+=i?-n:+n}return+o}G.s_to_num=ei});var qn=Le(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.decodeStr=X.encodeStr=X.decodeBool=X.encodeBool=X.decodeKey=X.decodeNum=X.encodeNum=void 0;var zn=Un();function Mu(e){return"n|"+(0,zn.num_to_s)(e)}X.encodeNum=Mu;function Uu(e){return e=e.replace("n|",""),(0,zn.s_to_num)(e)}X.decodeNum=Uu;function zu(e){return typeof e=="number"?e:(0,zn.s_to_int)(e)}X.decodeKey=zu;function qu(e){return e?"b|T":"b|F"}X.encodeBool=qu;function Ju(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}X.decodeBool=Ju;function Wu(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}X.encodeStr=Wu;function Qu(e){return e[0]+e[1]==="s|"?e.substr(2):e}X.decodeStr=Qu});var Jn=Le(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.config=void 0;en.config={sort_key:!1,error_on_nan:!1,error_on_infinite:!1}});var Yn=Le(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.addValue=xe.makeInMemoryMemory=xe.makeInMemoryCache=xe.makeInMemoryStore=xe.memToValues=void 0;var Hn=Jn(),Wn=jn(),Qn=qn(),Hu=Un();function Yu(e){return e.store.toArray()}xe.memToValues=Yu;function ti(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}xe.makeInMemoryStore=ti;function ni(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}xe.makeInMemoryCache=ni;function Gu(){return{store:ti(),cache:ni(),keyCount:0}}xe.makeInMemoryMemory=Gu;function nt(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=(0,Hu.num_to_s)(r);return e.store.add(t),e.cache.setValue(t,n),n}function Xu(e,t){Hn.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=Ot(e,t,void 0);return e.cache.setSchema(r,n),n}function Ot(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return Ot(e,null,r);break;case"object":if(t===null)return nt(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":Ot(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),nt(e,n)}else{let n=Object.keys(t);if(n.length===0)return nt(e,"o|");let o="o",i=Xu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=Ot(e,s,t);o+="|"+u}return nt(e,o)}case"boolean":return nt(e,(0,Qn.encodeBool)(t));case"number":return Number.isNaN(t)?(Hn.config.error_on_nan&&(0,Wn.throwUnsupportedData)("[number NaN]"),""):Number.POSITIVE_INFINITY===t||Number.NEGATIVE_INFINITY===t?(Hn.config.error_on_infinite&&(0,Wn.throwUnsupportedData)("[number Infinity]"),""):nt(e,(0,Qn.encodeNum)(t));case"string":return nt(e,(0,Qn.encodeStr)(t))}return(0,Wn.throwUnknownDataType)(t)}xe.addValue=Ot});var Xn=Le(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.decompress=Qe.decode=Qe.compress=void 0;var Zu=jn(),tn=qn(),Gn=Yn();function ep(e){let t=(0,Gn.makeInMemoryMemory)(),r=(0,Gn.addValue)(t,e,void 0);return[(0,Gn.memToValues)(t),r]}Qe.compress=ep;function tp(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=kt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=kt(e,p),r[u]=p}return r}function np(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=kt(e,a),o[i]=a}return o}function kt(e,t){if(t===""||t==="_")return null;let r=(0,tn.decodeKey)(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return(0,tn.decodeBool)(n);case"o|":return tp(e,n);case"n|":return(0,tn.decodeNum)(n);case"a|":return np(e,n);default:return(0,tn.decodeStr)(n)}}return(0,Zu.throwUnknownDataType)(n)}Qe.decode=kt;function rp(e){let[t,r]=e;return kt(t,r)}Qe.decompress=rp});var oi=Le(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.trimUndefinedRecursively=gt.trimUndefined=void 0;function op(e){for(let t in e)e[t]===void 0&&delete e[t]}gt.trimUndefined=op;function ip(e){ri(e,new Set)}gt.trimUndefinedRecursively=ip;function ri(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&ri(n,t)}}});var si=Le(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.config=Z.trimUndefinedRecursively=Z.trimUndefined=Z.addValue=Z.decode=Z.decompress=Z.compress=void 0;var ii=Xn();Object.defineProperty(Z,"compress",{enumerable:!0,get:function(){return ii.compress}});Object.defineProperty(Z,"decompress",{enumerable:!0,get:function(){return ii.decompress}});var ap=Xn();Object.defineProperty(Z,"decode",{enumerable:!0,get:function(){return ap.decode}});var sp=Yn();Object.defineProperty(Z,"addValue",{enumerable:!0,get:function(){return sp.addValue}});var ai=oi();Object.defineProperty(Z,"trimUndefined",{enumerable:!0,get:function(){return ai.trimUndefined}});Object.defineProperty(Z,"trimUndefinedRecursively",{enumerable:!0,get:function(){return ai.trimUndefinedRecursively}});var up=Jn();Object.defineProperty(Z,"config",{enumerable:!0,get:function(){return up.config}})});var Ap={};Li(Ap,{createDevTools:()=>li,createDevToolsSys:()=>fi,detectFrameworks:()=>Ue,detectFrameworksFromPackageJson:()=>un,ensureConfigPlugin:()=>vi,findBuildToolConfig:()=>tr,getClientScript:()=>bi,parseDotEnvContent:()=>pn,version:()=>_t});module.exports=_i(Ap);var ji="1.13.5",or=process.env.OVERRIDE_VERSION??ji;function ne(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var Vi=["node_modules","dist","build","public"];async function ie(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(Vi.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let f=await r(u,i+1);if(f)return f}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await ne(e)?"ts":"js"}`;return e.join(t,i)}return n}async function xt(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function ir(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function Ct(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await Ct(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var pr=rr(sr(),1);function Ae(e){return e.endsWith(".mapper.tsx")||e.endsWith(".mapper.jsx")||e.endsWith(".mapper.ts")||e.endsWith(".mapper.js")||e.endsWith(".mapper.mjs")}function N(e,t,r){t=he(t),r=he(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=he(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function he(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function Ye(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return ur(o==="index"?e.basename(e.dirname(t)):o)}function ur(e){return K(e).replace(/ /g,"")}function le(e,t){let r=e.extname(t),n=he(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function M(e,t){let r=he(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").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=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function O(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function ae(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function V(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function ht(e){return typeof e=="number"}function rt(e){return typeof e=="boolean"}function re(e){return typeof e=="string"}function ot(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function ue(e){return JSON.parse(JSON.stringify(e))}function jt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function cr(){try{let e=(0,pr.default)();if(e?.name)return e.name}catch{}return"npm"}async function Ue(e){let t=[],r=await xt(e,e.getRepoRootDir());if(r){let n=await un(r,e);t.push(...n)}return t}async function mr(e){let t=await xt(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function un(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Ki)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};lr.has(o)&&(i.version=await lr.get(o)(t)),r.push(i)}}return r}function sn(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var lr=new Map([["next",async e=>{if(!e.spawnSync)return;let t=cr(),r=t==="npm"?"npx":t,{stdout:n}=e.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:sn(a),minor:sn(s),patch:sn(u)}}]]),Ki=["@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 me(e){let t=fr(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function fe(e,t){t=typeof t=="object"&&t!=null?t:{};let r=fr(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function fr(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Fe(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Mi(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function Mi(e,t){let r=await e.readFile(t);return typeof r=="string"?pn(r):null}function pn(e){let t={},r=e.replace(/\r\n?/gm,`
1
+ "use strict";var Ii=Object.create;var Dt=Object.defineProperty;var Ri=Object.getOwnPropertyDescriptor;var Ni=Object.getOwnPropertyNames;var Bi=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty;var Oi=(e,t,r)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Li=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},rr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ni(t))!ki.call(e,o)&&o!==r&&Dt(e,o,{get:()=>t[o],enumerable:!(n=Ri(t,o))||n.enumerable});return e};var or=(e,t,r)=>(r=e!=null?Ii(Bi(e)):{},rr(t||!e||!e.__esModule?Dt(r,"default",{value:e,enumerable:!0}):r,e)),_i=e=>rr(Dt({},"__esModule",{value:!0}),e);var Me=(e,t,r)=>Oi(e,typeof t!="symbol"?t+"":t,r);var ur=Le((wp,sr)=>{"use strict";sr.exports=function(){if(process.env.npm_config_user_agent)return $i(process.env.npm_config_user_agent)};function $i(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var Vn=Le(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.throwUnsupportedData=We.throwUnknownDataType=We.getType=void 0;function Ho(e){return Object.prototype.toString.call(e)}We.getType=Ho;function $u(e){throw new TypeError("unsupported data type: "+Ho(e))}We.throwUnknownDataType=$u;function Ku(e){throw new TypeError("unsupported data type: "+e)}We.throwUnsupportedData=Ku});var zn=Le(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.s_to_num=G.int_str_to_s=G.num_to_s=G.big_int_to_s=G.int_to_s=G.s_to_big_int=G.s_to_int=void 0;var Ke="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Ke+=t}var dt=Ke.length,Kn={};for(let e=0;e<dt;e++){let t=Ke[e];Kn[t]=e}function Mn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=Kn[o];i*=r,t+=i,r*=dt}return t}G.s_to_int=Mn;function Yo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(dt);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(Kn[i]);a*=r,t+=a,r*=n}return t}G.s_to_big_int=Yo;function Un(e){if(e===0)return Ke[0];let t=[];for(;e!==0;){let r=e%dt,n=Ke[r];t.push(n),e-=r,e/=dt}return t.reverse().join("")}G.int_to_s=Un;function Go(e){let t=BigInt(0),r=BigInt(dt);if(e===t)return Ke[0];let n=[];for(;e!==t;){let o=e%r,i=Ke[Number(o)];n.push(i),e/=r}return n.reverse().join("")}G.big_int_to_s=Go;function Xo(e){return e.split("").reverse().join("")}function Zo(e){if(e<0)return"-"+Zo(-e);let[t,r]=e.toString().split(".");if(!r)if(t.includes("e")){let[i,a]=t.split("e");t=i,r="0e"+a}else return Un(e);let n;r&&([r,n]=r.split("e")),t=Zt(t),r=Xo(r),r=Zt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Zt(n),o+=n}return o}G.num_to_s=Zo;function Zt(e){let t=+e;return t.toString()===e&&t+1!==t&&t-1!==t?Un(t):":"+Go(BigInt(e))}G.int_str_to_s=Zt;function $n(e){return e[0]===":"?Yo(e.substring(1)).toString():Mn(e).toString()}function ei(e){if(e[0]==="-")return-ei(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Mn(t);t=$n(t),r=$n(r),r=Xo(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=$n(n),o+=i?-n:+n}return+o}G.s_to_num=ei});var Jn=Le(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.decodeStr=X.encodeStr=X.decodeBool=X.encodeBool=X.decodeKey=X.decodeNum=X.encodeNum=void 0;var qn=zn();function Mu(e){return"n|"+(0,qn.num_to_s)(e)}X.encodeNum=Mu;function Uu(e){return e=e.replace("n|",""),(0,qn.s_to_num)(e)}X.decodeNum=Uu;function zu(e){return typeof e=="number"?e:(0,qn.s_to_int)(e)}X.decodeKey=zu;function qu(e){return e?"b|T":"b|F"}X.encodeBool=qu;function Ju(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}X.decodeBool=Ju;function Wu(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}X.encodeStr=Wu;function Qu(e){return e[0]+e[1]==="s|"?e.substr(2):e}X.decodeStr=Qu});var Wn=Le(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.config=void 0;en.config={sort_key:!1,error_on_nan:!1,error_on_infinite:!1}});var Gn=Le(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.addValue=xe.makeInMemoryMemory=xe.makeInMemoryCache=xe.makeInMemoryStore=xe.memToValues=void 0;var Yn=Wn(),Qn=Vn(),Hn=Jn(),Hu=zn();function Yu(e){return e.store.toArray()}xe.memToValues=Yu;function ti(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}xe.makeInMemoryStore=ti;function ni(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}xe.makeInMemoryCache=ni;function Gu(){return{store:ti(),cache:ni(),keyCount:0}}xe.makeInMemoryMemory=Gu;function nt(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=(0,Hu.num_to_s)(r);return e.store.add(t),e.cache.setValue(t,n),n}function Xu(e,t){Yn.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=kt(e,t,void 0);return e.cache.setSchema(r,n),n}function kt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return kt(e,null,r);break;case"object":if(t===null)return nt(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":kt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),nt(e,n)}else{let n=Object.keys(t);if(n.length===0)return nt(e,"o|");let o="o",i=Xu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=kt(e,s,t);o+="|"+u}return nt(e,o)}case"boolean":return nt(e,(0,Hn.encodeBool)(t));case"number":return Number.isNaN(t)?(Yn.config.error_on_nan&&(0,Qn.throwUnsupportedData)("[number NaN]"),""):Number.POSITIVE_INFINITY===t||Number.NEGATIVE_INFINITY===t?(Yn.config.error_on_infinite&&(0,Qn.throwUnsupportedData)("[number Infinity]"),""):nt(e,(0,Hn.encodeNum)(t));case"string":return nt(e,(0,Hn.encodeStr)(t))}return(0,Qn.throwUnknownDataType)(t)}xe.addValue=kt});var Zn=Le(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.decompress=Qe.decode=Qe.compress=void 0;var Zu=Vn(),tn=Jn(),Xn=Gn();function ep(e){let t=(0,Xn.makeInMemoryMemory)(),r=(0,Xn.addValue)(t,e,void 0);return[(0,Xn.memToValues)(t),r]}Qe.compress=ep;function tp(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=Ot(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=Ot(e,p),r[u]=p}return r}function np(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=Ot(e,a),o[i]=a}return o}function Ot(e,t){if(t===""||t==="_")return null;let r=(0,tn.decodeKey)(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return(0,tn.decodeBool)(n);case"o|":return tp(e,n);case"n|":return(0,tn.decodeNum)(n);case"a|":return np(e,n);default:return(0,tn.decodeStr)(n)}}return(0,Zu.throwUnknownDataType)(n)}Qe.decode=Ot;function rp(e){let[t,r]=e;return Ot(t,r)}Qe.decompress=rp});var oi=Le(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.trimUndefinedRecursively=gt.trimUndefined=void 0;function op(e){for(let t in e)e[t]===void 0&&delete e[t]}gt.trimUndefined=op;function ip(e){ri(e,new Set)}gt.trimUndefinedRecursively=ip;function ri(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&ri(n,t)}}});var si=Le(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.config=Z.trimUndefinedRecursively=Z.trimUndefined=Z.addValue=Z.decode=Z.decompress=Z.compress=void 0;var ii=Zn();Object.defineProperty(Z,"compress",{enumerable:!0,get:function(){return ii.compress}});Object.defineProperty(Z,"decompress",{enumerable:!0,get:function(){return ii.decompress}});var ap=Zn();Object.defineProperty(Z,"decode",{enumerable:!0,get:function(){return ap.decode}});var sp=Gn();Object.defineProperty(Z,"addValue",{enumerable:!0,get:function(){return sp.addValue}});var ai=oi();Object.defineProperty(Z,"trimUndefined",{enumerable:!0,get:function(){return ai.trimUndefined}});Object.defineProperty(Z,"trimUndefinedRecursively",{enumerable:!0,get:function(){return ai.trimUndefinedRecursively}});var up=Wn();Object.defineProperty(Z,"config",{enumerable:!0,get:function(){return up.config}})});var Ap={};Li(Ap,{createDevTools:()=>li,createDevToolsSys:()=>fi,detectFrameworks:()=>Ue,detectFrameworksFromPackageJson:()=>un,ensureConfigPlugin:()=>vi,findBuildToolConfig:()=>nr,getClientScript:()=>bi,parseDotEnvContent:()=>pn,version:()=>_t});module.exports=_i(Ap);var ji="1.14.0",ir=process.env.OVERRIDE_VERSION??ji;function ne(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var Vi=["node_modules","dist","build","public"];async function ie(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(Vi.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let f=await r(u,i+1);if(f)return f}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await ne(e)?"ts":"js"}`;return e.join(t,i)}return n}async function xt(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function ar(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function Ct(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await Ct(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var cr=or(ur(),1);function Ae(e){return e.endsWith(".mapper.tsx")||e.endsWith(".mapper.jsx")||e.endsWith(".mapper.ts")||e.endsWith(".mapper.js")||e.endsWith(".mapper.mjs")}function N(e,t,r){t=he(t),r=he(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=he(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function he(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function Ye(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return pr(o==="index"?e.basename(e.dirname(t)):o)}function pr(e){return K(e).replace(/ /g,"")}function le(e,t){let r=e.extname(t),n=he(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function M(e,t){let r=he(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").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=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function ae(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function V(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function ht(e){return typeof e=="number"}function rt(e){return typeof e=="boolean"}function re(e){return typeof e=="string"}function ot(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function pe(e){return JSON.parse(JSON.stringify(e))}function jt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function lr(){try{let e=(0,cr.default)();if(e?.name)return e.name}catch{}return"npm"}async function Ue(e){let t=[],r=await xt(e,e.getRepoRootDir());if(r){let n=await un(r,e);t.push(...n)}return t}async function fr(e){let t=await xt(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function un(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Ki)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};mr.has(o)&&(i.version=await mr.get(o)(t)),r.push(i)}}return r}function sn(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var mr=new Map([["next",async e=>{if(!e.spawnSync)return;let t=lr(),r=t==="npm"?"npx":t,{stdout:n}=e.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:sn(a),minor:sn(s),patch:sn(u)}}]]),Ki=["@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 me(e){let t=dr(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function fe(e,t){t=typeof t=="object"&&t!=null?t:{};let r=dr(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function dr(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Fe(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Mi(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function Mi(e,t){let r=await e.readFile(t);return typeof r=="string"?pn(r):null}function pn(e){let t={},r=e.replace(/\r\n?/gm,`
2
2
  `),n;for(;(n=Ui.exec(r))!=null;){let o=n[1],i=n[2]||"";i=i.trim();let a=i[0];i=i.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),a==='"'&&(i=i.replace(/\\n/g,`
3
3
  `),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var Ui=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;async function Pe(e,t,r,n){let o="# https://www.builder.io/c/docs/using-your-api-key",i=await e.readFile(t);try{if(i)if(i.includes(r))if(i.includes(n))e.debug(`"${r}" with "${n}" already set in ${t}`);else return e.debug(`Replace "${r}" in ${t}`),i=i.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await e.writeFile(t,i),"update";else return e.debug(`Append "${r}" to ${t}`),i+=`
4
4
 
@@ -6,9 +6,9 @@ ${o}
6
6
  ${r}=${n}
7
7
 
8
8
  `,await e.writeFile(t,i),"update";else return e.debug(`Creating new .env file with "${r}" at ${t}`),i=[o,`${r}=${n}`,""].join(`
9
- `),await e.writeFile(t,i),"create"}catch(a){if(a&&String(a).includes("EACCES"))return e.debug(`Permssion denied, failed to create or modify .env file with "${r}=${n}" at ${t}`),"permission-error";e.Sentry?.captureException(a)}return null}async function Et(e){return await Fe(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],ye)}async function dr(e,t){let r=await Et(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var ye="NEXT_PUBLIC_BUILDER_API_KEY";var y={gen1:"Gen 1",gen2:"Gen 2"};function b(e,t=""){return e.ts.createSourceFile("module.tsx",typeof t=="string"?t:"",e.ts.ScriptTarget.Latest,void 0)}function Vt(e,t=""){let r=b(e,t?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${t}`);return r.statements[0]}function j(e,t,r){if(t){let n=e.ts.createPrinter({newLine:e.ts.NewLineKind.LineFeed,removeComments:r});return e.ts.isSourceFile(t)?n.printFile(t).trim()+`
9
+ `),await e.writeFile(t,i),"create"}catch(a){if(a&&String(a).includes("EACCES"))return e.debug(`Permssion denied, failed to create or modify .env file with "${r}=${n}" at ${t}`),"permission-error";e.Sentry?.captureException(a)}return null}async function Et(e){return await Fe(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],ye)}async function gr(e,t){let r=await Et(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var ye="NEXT_PUBLIC_BUILDER_API_KEY";var y={gen1:"Gen 1",gen2:"Gen 2"};function b(e,t=""){return e.ts.createSourceFile("module.tsx",typeof t=="string"?t:"",e.ts.ScriptTarget.Latest,void 0)}function Vt(e,t=""){let r=b(e,t?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${t}`);return r.statements[0]}function j(e,t,r){if(t){let n=e.ts.createPrinter({newLine:e.ts.NewLineKind.LineFeed,removeComments:r});return e.ts.isSourceFile(t)?n.printFile(t).trim()+`
10
10
  `:n.printNode(e.ts.EmitHint.Unspecified,t,e.ts.createSourceFile("module.tsx","",e.ts.ScriptTarget.Latest)).trim()+`
11
- `}return""}function it(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=zi(e,t,r);return a>-1?n==null&&o?e.ts.factory.updateObjectLiteralExpression(t,i.filter((s,u)=>u!==a)):(i[a]=e.ts.factory.updatePropertyAssignment(i[a],i[a].name,St(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,St(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function zi(e,t,r){return t.properties.findIndex(n=>L(e,n)===r)}function At(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return Ji(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return qi(e,t);case e.ts.SyntaxKind.StringLiteral:return t.text;case e.ts.SyntaxKind.NumericLiteral:return Number(t.text);case e.ts.SyntaxKind.NoSubstitutionTemplateLiteral:return t.text;case e.ts.SyntaxKind.TrueKeyword:return!0;case e.ts.SyntaxKind.FalseKeyword:return!1;case e.ts.SyntaxKind.Identifier:switch(t.escapedText){case"undefined":return;case"null":return null;case"String":return String;case"Number":return Number;case"Boolean":return Boolean;case"NaN":return NaN}}}function qi(e,t){let r={};if(t&&e.ts.isObjectLiteralExpression(t)){for(let n of t.properties)if(e.ts.isPropertyAssignment(n)){let o=L(e,n);o&&(r[o]=At(e,n.initializer))}}return r}function Ji(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>At(e,r)):[]}function L(e,t){if(t&&e.ts.isPropertyAssignment(t)){let r=t.name;switch(r.kind){case e.ts.SyntaxKind.Identifier:return r.text;case e.ts.SyntaxKind.StringLiteral:case e.ts.SyntaxKind.NumericLiteral:return r.text;case e.ts.SyntaxKind.ComputedPropertyName:let n=r.expression;if(e.ts.isStringLiteral(n)||e.ts.isNumericLiteral(n))return r.expression.text}}}function St(e,t){return cn(e,t,new WeakSet)}function cn(e,t,r){return t===void 0?e.ts.factory.createIdentifier("undefined"):t===null?e.ts.factory.createIdentifier("null"):typeof t=="string"?e.ts.factory.createStringLiteral(t):typeof t=="number"?isNaN(t)?e.ts.factory.createIdentifier("NaN"):e.ts.factory.createNumericLiteral(t):t===!0?e.ts.factory.createTrue():t===!1?e.ts.factory.createFalse():t===String?e.ts.factory.createIdentifier("String"):t===Number?e.ts.factory.createIdentifier("Number"):t===Boolean?e.ts.factory.createIdentifier("Boolean"):Array.isArray(t)?Wi(e,t,r):typeof t=="object"?Qi(e,t,r):e.ts.factory.createIdentifier(t)}function Wi(e,t,r){let n=t.map(o=>cn(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Qi(e,t,r){if(r.has(t))return e.ts.factory.createIdentifier("undefined");r.add(t);let n=Object.keys(t).map(o=>e.ts.factory.createPropertyAssignment(o,cn(e,t[o],r)));return e.ts.factory.createObjectLiteralExpression(n,!0)}function Ge(e,t,r){let n=[];if(!r)return n;let o=null;if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r)){let i=r.parameters;if(i.length>0){let a=i[0],s=t.getTypeAtLocation(a);s.aliasTypeArguments&&s.aliasTypeArguments.length>0&&(s=s.aliasTypeArguments[0]),!!(s.flags&e.ts.TypeFlags.Object)&&(o=s.getProperties())}}else if(e.ts.isIdentifier(r)){let i=t.getTypeAtLocation(r),a=i.symbol?.valueDeclaration;if(a&&e.ts.isClassDeclaration(a)){let u=a.heritageClauses?.find(p=>p.token===e.ts.SyntaxKind.ExtendsKeyword)?.types;if(u){for(let p of u)if(t.getSymbolAtLocation(p.expression)?.name==="Component"){if(e.ts.isExpressionWithTypeArguments(p)){let m=p.typeArguments;if(m){let c=m[0];o=t.getTypeFromTypeNode(c).getProperties()}}break}}}if(!o){let s=i.getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}else if(e.ts.isExportSpecifier(r)){let i=t.getSymbolAtLocation(r.name);if(i){let s=t.getTypeOfSymbolAtLocation(i,r).getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}if(o)for(let i of o){let a=Hi(e,t,i);a&&n.push(a)}return n=n.filter(Dr),n.length>0?n:Yi(e,r)}function Hi(e,t,r){let n=r.valueDeclaration,o=r.getName();if(n||(n=r.getDeclarations()?.[0]),n&&e.ts.isPropertySignature(n)){if(o!=="children"&&n.getSourceFile().fileName.includes("node_modules/@types/"))return null;let i="string",a;if(n?.type){let u=t.getTypeFromTypeNode(n.type),p=t.typeToString(u),f=ln(p);f.knownType?i=f.builderType:Xi(p)||u.flags&e.ts.TypeFlags.StringLike?i="string":u.flags&e.ts.TypeFlags.NumberLike?i="number":u.flags&e.ts.TypeFlags.IndexedAccess?i="list":u.flags&e.ts.TypeFlags.Object||u.isUnion()&&u.types.every(m=>m.flags&e.ts.TypeFlags.Object)||u.isIntersection()&&u.types.some(m=>m.flags&e.ts.TypeFlags.Object)?i="object":i="string",p!==i&&(a=p)}let s={name:o,type:i,isRegistered:!1};if(a&&n.type){let u=na(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(ea)?s.enum=u.map(ta):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function Yi(e,t){let r=[],n=e.ts.getJSDocCommentsAndTags(t);for(let o of n)if(!(!e.ts.isJSDoc(o)||!o.tags))for(let i of o.tags){if(!e.ts.isJSDocParameterTag(i)||i.tagName.text!=="param")continue;let s=i.typeExpression?.type;if(!s||!e.ts.isJSDocTypeLiteral(s))continue;let u=s.jsDocPropertyTags;if(u)for(let p of u){if(!e.ts.isJSDocPropertyLikeTag(p))continue;let f=p.name;if(!e.ts.isQualifiedName(f))continue;let m=p.typeExpression;if(!m)continue;let c="";switch(m.type.kind){case e.ts.SyntaxKind.StringKeyword:{c="string";break}case e.ts.SyntaxKind.NumberKeyword:{c="number";break}case e.ts.SyntaxKind.BooleanKeyword:{c="boolean";break}default:continue}let D={name:f.right.text,type:c,isRegistered:!1};r.push(D)}}return r.filter(Dr)}var Gi=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function Xi(e){return typeof e!="string"?!1:!!Gi.some(t=>e.includes(t))}function ln(e){return typeof e=="string"&&(e=e.trim(),Zi.some(t=>t.value===e))?{builderType:e,knownType:!0}:{builderType:"string",knownType:!1}}var Zi=[{value:"boolean",text:"boolean"},{value:"color",text:"color (provides a color in hex or rgb)"},{value:"date",text:"date (same format as the Date constructor)"},{value:"email",text:"email"},{value:"file",text:"file (uploads a file and provides a url)"},{value:"list",text:"list (collection of items)"},{value:"longText",text:"longText (multiline text editor)"},{value:"number",text:"number"},{value:"object",text:"object (set of specific names and values)"},{value:"richText",text:"richText (provides value as html)"},{value:"string",text:"string"}];function ea(e){return/^['"].*['"]$/.test(e)}function ta(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var na=(e,t,r)=>{let n=new Set;gr(e,t,r,n);let o=n.delete("true"),i=n.delete("false");(o||i)&&n.add("boolean");let a=Array.from(n.keys()).sort();if(a.length>1&&(a=a.map(s=>s.indexOf("=>")>=0?`(${s})`:s)),!(a.length>20))return a},ra=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},gr=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{gr(e,t,o,n)});else if(r.isLiteral()){let o=ra(e,t,r);n.add(o)}};function Dr(e){let t=e?.name;if(typeof t!="string"||t===""||t.startsWith("aria")||t.startsWith("data-"))return!1;if(t.startsWith("on")&&t.length>2){let r=t.charAt(2);if(r.toUpperCase()===r)return!1}return!oa.has(t.toLowerCase())}var oa=new Set(["about","accessKey","accessKeyLabel","asChild","autoCapitalize","autoCorrect","autoFocus","autoSave","blur","contentEditable","contextMenu","dangerouslySetInnerHTML","datatype","defaultChecked","defaultValue","dir","draggable","enterKeyHint","focus","form","formAction","formEncType","formMethod","formNoValidate","formTarget","inlist","innerText","inputMode","is","isContentEditable","itemID","itemProp","itemRef","itemScope","itemType","lang","nonce","offsetHeight","offsetLeft","offsetTop","offsetWidth","outerText","prefix","property","radioGroup","rel","resource","results","rev","role","security","slot","spellCheck","suppressContentEditableWarning","suppressHydrationWarning","tabIndex","translate","typeof","unselectable","vocab"].map(e=>e.toLowerCase()));function se(e,t,r){for(let n of r.properties){if(!e.ts.isPropertyAssignment(n))continue;let o=L(e,n);if(o==="name"&&e.ts.isStringLiteral(n.initializer)){t.name=n.initializer.text;continue}if(o==="description"&&e.ts.isStringLiteral(n.initializer)){t.description=n.initializer.text;continue}if(o==="image"&&e.ts.isStringLiteral(n.initializer)){t.image=n.initializer.text;continue}if(o==="inputs"&&e.ts.isArrayLiteralExpression(n.initializer)){let i=ia(e,n.initializer);pe(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=At(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function ia(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(aa(e,n));return r}function aa(e,t){let r=At(e,t),n=fa(r);return n.isRegistered=!0,n}function W(e,t,r){let n=ua(r);return t=it(e,t,"name",n.name,!1),t=it(e,t,"description",n.description),t=it(e,t,"image",n.image),t=it(e,t,"meta",n.meta),t=sa(e,t,n),da(e,t)}function sa(e,t,r){let n=null,o=t.properties.filter(s=>e.ts.isPropertyAssignment(s)&&e.ts.isIdentifier(s.name)),i=o.findIndex(s=>e.ts.isIdentifier(s.name)&&s.name.text==="inputs"),a=[...r.inputs??[]];if(i>-1){if(a.length===0)return it(e,t,"inputs",null);let s=o[i];e.ts.isPropertyAssignment(s)&&e.ts.isArrayLiteralExpression(s.initializer)&&(n=s.initializer)}return a.length===0?t:(n=ca(e,n||e.ts.factory.createArrayLiteralExpression(),a),i>-1?o[i]=e.ts.factory.updatePropertyAssignment(o[i],o[i].name,n):o.push(e.ts.factory.createPropertyAssignment("inputs",n)),e.ts.factory.updateObjectLiteralExpression(t,o))}function ua(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(pa),...e.meta?{meta:{...e.meta}}:{}}}function pa(e){let t={name:e.name,type:e.type};return(re(e.defaultValue)||ht(e.defaultValue)||rt(e.defaultValue))&&(t.defaultValue=e.defaultValue),re(e.friendlyName)&&(t.friendlyName=e.friendlyName),re(e.helperText)&&(t.helperText=e.helperText),e.required===!0&&(t.required=!0),Array.isArray(e.enum)&&(t.enum=e.enum),e.hideFromUI===!0&&(t.hideFromUI=!0),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(t.meta=e.meta),t}function ca(e,t,r){let n=t.elements.filter(o=>{if(!e.ts.isObjectLiteralExpression(o))return!1;let i=o.properties.find(s=>L(e,s)==="name");if(!i)return!1;let a=i.initializer;return e.ts.isStringLiteral(a)?r.some(s=>s.name===a.text):!1});for(let o of r)n=la(e,n,o);return n.sort((o,i)=>{let a=o.properties.find(c=>L(e,c)==="name"),s=i.properties.find(c=>L(e,c)==="name"),u=a?.initializer,p=s?.initializer,f=u&&e.ts.isStringLiteral(u)?u.text:"zz",m=p&&e.ts.isStringLiteral(p)?p.text:"zz";return f.toLowerCase().localeCompare(m.toLowerCase())}),e.ts.factory.updateArrayLiteralExpression(t,n)}function la(e,t,r){let n=t.findIndex(o=>o.properties.some(i=>{let a=L(e,i);return e.ts.isPropertyAssignment(i)&&a==="name"&&e.ts.isStringLiteral(i.initializer)&&i.initializer.text===r.name}));if(n>-1)t[n]=xr(e,t[n],r);else{let o=xr(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function xr(e,t,r){let n=t.properties.filter(i=>e.ts.isPropertyAssignment(i)),o=Object.keys(r).filter(i=>i!=="isRegistered");for(let i of o)n=ma(e,n,r,i);return n=ga(e,n.filter(i=>{let a=L(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function ma(e,t,r,n){let o=t.findIndex(i=>e.ts.isIdentifier(i.name)&&i.name.text===n);return o>-1?t[o]=e.ts.factory.updatePropertyAssignment(t[o],t[o].name,St(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,St(e,r[n]))),t}function pe(e,t){for(let r of t){let n=e.inputs.findIndex(o=>o.name===r.name);n>-1?(r.isRegistered||!e.inputs[n].isRegistered)&&(e.inputs[n]=r):e.inputs.push(r)}e.acceptsChildren=mn(e)}function fa(e){let t=ln(e.type),r={name:e.name.trim(),type:t.builderType};return re(e.friendlyName)&&e.friendlyName.trim()!==e.name.trim()&&(r.friendlyName=e.friendlyName),(re(e.defaultValue)||ht(e.defaultValue)||rt(e.defaultValue))&&(r.defaultValue=e.defaultValue),re(e.helperText)&&(r.helperText=e.helperText),rt(e.required)&&(r.required=e.required),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(r.meta=e.meta),Array.isArray(e.enum)&&e.enum.length>0&&(r.enum=e.enum),e.hideFromUI===!0&&(r.hideFromUI=!0),fn(r)}function mn(e){let t=e.inputs.some(n=>n.name==="children"),r=e.inputs.some(n=>n.meta?.ts==="ReactNode");return!!(t||r||e.acceptsChildren===!0)}function fn(e){if(e.name==="children"&&(e.hideFromUI=!0,delete e.required),e.type==="object"&&e.defaultValue==null&&(e.hideFromUI=!0),e.type==="list"&&e.defaultValue==null&&(e.hideFromUI=!0),e.meta){let t=e.meta.ts;typeof t=="string"&&(t=t.trim(),t.endsWith("ReactNode")&&(t="ReactNode"),e.meta.ts=t,t==="ReactNode"&&(e.hideFromUI=!0))}return e}function da(e,t){let r=[...t.properties].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz";if(i==="inputs")return 1;let s=Cr.indexOf(i),u=Cr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)});return e.ts.factory.updateObjectLiteralExpression(t,r)}var Cr=["component","name","description"];function ga(e,t){return[...t].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz",s=hr.indexOf(i),u=hr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var hr=["name","type"];function at(e,t){for(let r of t.properties){if(!e.ts.isPropertyAssignment(r)||!e.ts.isIdentifier(r.name))continue;if(L(e,r)==="canHaveChildren"){let{initializer:o}=r;return o.kind===e.ts.SyntaxKind.TrueKeyword}}return!1}function Er(e,t){let r=`Builder.registerComponent(
11
+ `}return""}function it(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=zi(e,t,r);return a>-1?n==null&&o?e.ts.factory.updateObjectLiteralExpression(t,i.filter((s,u)=>u!==a)):(i[a]=e.ts.factory.updatePropertyAssignment(i[a],i[a].name,St(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,St(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function zi(e,t,r){return t.properties.findIndex(n=>L(e,n)===r)}function At(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return Ji(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return qi(e,t);case e.ts.SyntaxKind.StringLiteral:return t.text;case e.ts.SyntaxKind.NumericLiteral:return Number(t.text);case e.ts.SyntaxKind.NoSubstitutionTemplateLiteral:return t.text;case e.ts.SyntaxKind.TrueKeyword:return!0;case e.ts.SyntaxKind.FalseKeyword:return!1;case e.ts.SyntaxKind.Identifier:switch(t.escapedText){case"undefined":return;case"null":return null;case"String":return String;case"Number":return Number;case"Boolean":return Boolean;case"NaN":return NaN}}}function qi(e,t){let r={};if(t&&e.ts.isObjectLiteralExpression(t)){for(let n of t.properties)if(e.ts.isPropertyAssignment(n)){let o=L(e,n);o&&(r[o]=At(e,n.initializer))}}return r}function Ji(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>At(e,r)):[]}function L(e,t){if(t&&e.ts.isPropertyAssignment(t)){let r=t.name;switch(r.kind){case e.ts.SyntaxKind.Identifier:return r.text;case e.ts.SyntaxKind.StringLiteral:case e.ts.SyntaxKind.NumericLiteral:return r.text;case e.ts.SyntaxKind.ComputedPropertyName:let n=r.expression;if(e.ts.isStringLiteral(n)||e.ts.isNumericLiteral(n))return r.expression.text}}}function St(e,t){return cn(e,t,new WeakSet)}function cn(e,t,r){return t===void 0?e.ts.factory.createIdentifier("undefined"):t===null?e.ts.factory.createIdentifier("null"):typeof t=="string"?e.ts.factory.createStringLiteral(t):typeof t=="number"?isNaN(t)?e.ts.factory.createIdentifier("NaN"):e.ts.factory.createNumericLiteral(t):t===!0?e.ts.factory.createTrue():t===!1?e.ts.factory.createFalse():t===String?e.ts.factory.createIdentifier("String"):t===Number?e.ts.factory.createIdentifier("Number"):t===Boolean?e.ts.factory.createIdentifier("Boolean"):Array.isArray(t)?Wi(e,t,r):typeof t=="object"?Qi(e,t,r):e.ts.factory.createIdentifier(t)}function Wi(e,t,r){let n=t.map(o=>cn(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Qi(e,t,r){if(r.has(t))return e.ts.factory.createIdentifier("undefined");r.add(t);let n=Object.keys(t).map(o=>e.ts.factory.createPropertyAssignment(o,cn(e,t[o],r)));return e.ts.factory.createObjectLiteralExpression(n,!0)}function Ge(e,t,r){let n=[];if(!r)return n;let o=null;if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r)){let i=r.parameters;if(i.length>0){let a=i[0],s=t.getTypeAtLocation(a);s.aliasTypeArguments&&s.aliasTypeArguments.length>0&&(s=s.aliasTypeArguments[0]),!!(s.flags&e.ts.TypeFlags.Object)&&(o=s.getProperties())}}else if(e.ts.isIdentifier(r)){let i=t.getTypeAtLocation(r),a=i.symbol?.valueDeclaration;if(a&&e.ts.isClassDeclaration(a)){let u=a.heritageClauses?.find(p=>p.token===e.ts.SyntaxKind.ExtendsKeyword)?.types;if(u){for(let p of u)if(t.getSymbolAtLocation(p.expression)?.name==="Component"){if(e.ts.isExpressionWithTypeArguments(p)){let m=p.typeArguments;if(m){let c=m[0];o=t.getTypeFromTypeNode(c).getProperties()}}break}}}if(!o){let s=i.getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}else if(e.ts.isExportSpecifier(r)){let i=t.getSymbolAtLocation(r.name);if(i){let s=t.getTypeOfSymbolAtLocation(i,r).getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}if(o)for(let i of o){let a=Hi(e,t,i);a&&n.push(a)}return n=n.filter(xr),n.length>0?n:Yi(e,r)}function Hi(e,t,r){let n=r.valueDeclaration,o=r.getName();if(n||(n=r.getDeclarations()?.[0]),n&&e.ts.isPropertySignature(n)){if(o!=="children"&&n.getSourceFile().fileName.includes("node_modules/@types/"))return null;let i="string",a;if(n?.type){let u=t.getTypeFromTypeNode(n.type),p=t.typeToString(u),f=ln(p);f.knownType?i=f.builderType:Xi(p)||u.flags&e.ts.TypeFlags.StringLike?i="string":u.flags&e.ts.TypeFlags.NumberLike?i="number":u.flags&e.ts.TypeFlags.IndexedAccess?i="list":u.flags&e.ts.TypeFlags.Object||u.isUnion()&&u.types.every(m=>m.flags&e.ts.TypeFlags.Object)||u.isIntersection()&&u.types.some(m=>m.flags&e.ts.TypeFlags.Object)?i="object":i="string",p!==i&&(a=p)}let s={name:o,type:i,isRegistered:!1};if(a&&n.type){let u=na(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(ea)?s.enum=u.map(ta):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function Yi(e,t){let r=[],n=e.ts.getJSDocCommentsAndTags(t);for(let o of n)if(!(!e.ts.isJSDoc(o)||!o.tags))for(let i of o.tags){if(!e.ts.isJSDocParameterTag(i)||i.tagName.text!=="param")continue;let s=i.typeExpression?.type;if(!s||!e.ts.isJSDocTypeLiteral(s))continue;let u=s.jsDocPropertyTags;if(u)for(let p of u){if(!e.ts.isJSDocPropertyLikeTag(p))continue;let f=p.name;if(!e.ts.isQualifiedName(f))continue;let m=p.typeExpression;if(!m)continue;let c="";switch(m.type.kind){case e.ts.SyntaxKind.StringKeyword:{c="string";break}case e.ts.SyntaxKind.NumberKeyword:{c="number";break}case e.ts.SyntaxKind.BooleanKeyword:{c="boolean";break}default:continue}let D={name:f.right.text,type:c,isRegistered:!1};r.push(D)}}return r.filter(xr)}var Gi=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function Xi(e){return typeof e!="string"?!1:!!Gi.some(t=>e.includes(t))}function ln(e){return typeof e=="string"&&(e=e.trim(),Zi.some(t=>t.value===e))?{builderType:e,knownType:!0}:{builderType:"string",knownType:!1}}var Zi=[{value:"boolean",text:"boolean"},{value:"color",text:"color (provides a color in hex or rgb)"},{value:"date",text:"date (same format as the Date constructor)"},{value:"email",text:"email"},{value:"file",text:"file (uploads a file and provides a url)"},{value:"list",text:"list (collection of items)"},{value:"longText",text:"longText (multiline text editor)"},{value:"number",text:"number"},{value:"object",text:"object (set of specific names and values)"},{value:"richText",text:"richText (provides value as html)"},{value:"string",text:"string"}];function ea(e){return/^['"].*['"]$/.test(e)}function ta(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var na=(e,t,r)=>{let n=new Set;Dr(e,t,r,n);let o=n.delete("true"),i=n.delete("false");(o||i)&&n.add("boolean");let a=Array.from(n.keys()).sort();if(a.length>1&&(a=a.map(s=>s.indexOf("=>")>=0?`(${s})`:s)),!(a.length>20))return a},ra=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},Dr=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{Dr(e,t,o,n)});else if(r.isLiteral()){let o=ra(e,t,r);n.add(o)}};function xr(e){let t=e?.name;if(typeof t!="string"||t===""||t.startsWith("aria")||t.startsWith("data-"))return!1;if(t.startsWith("on")&&t.length>2){let r=t.charAt(2);if(r.toUpperCase()===r)return!1}return!oa.has(t.toLowerCase())}var oa=new Set(["about","accessKey","accessKeyLabel","asChild","autoCapitalize","autoCorrect","autoFocus","autoSave","blur","contentEditable","contextMenu","dangerouslySetInnerHTML","datatype","defaultChecked","defaultValue","dir","draggable","enterKeyHint","focus","form","formAction","formEncType","formMethod","formNoValidate","formTarget","inlist","innerText","inputMode","is","isContentEditable","itemID","itemProp","itemRef","itemScope","itemType","lang","nonce","offsetHeight","offsetLeft","offsetTop","offsetWidth","outerText","prefix","property","radioGroup","rel","resource","results","rev","role","security","slot","spellCheck","suppressContentEditableWarning","suppressHydrationWarning","tabIndex","translate","typeof","unselectable","vocab"].map(e=>e.toLowerCase()));function se(e,t,r){for(let n of r.properties){if(!e.ts.isPropertyAssignment(n))continue;let o=L(e,n);if(o==="name"&&e.ts.isStringLiteral(n.initializer)){t.name=n.initializer.text;continue}if(o==="description"&&e.ts.isStringLiteral(n.initializer)){t.description=n.initializer.text;continue}if(o==="image"&&e.ts.isStringLiteral(n.initializer)){t.image=n.initializer.text;continue}if(o==="inputs"&&e.ts.isArrayLiteralExpression(n.initializer)){let i=ia(e,n.initializer);ce(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=At(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function ia(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(aa(e,n));return r}function aa(e,t){let r=At(e,t),n=fa(r);return n.isRegistered=!0,n}function W(e,t,r){let n=ua(r);return t=it(e,t,"name",n.name,!1),t=it(e,t,"description",n.description),t=it(e,t,"image",n.image),t=it(e,t,"meta",n.meta),t=sa(e,t,n),da(e,t)}function sa(e,t,r){let n=null,o=t.properties.filter(s=>e.ts.isPropertyAssignment(s)&&e.ts.isIdentifier(s.name)),i=o.findIndex(s=>e.ts.isIdentifier(s.name)&&s.name.text==="inputs"),a=[...r.inputs??[]];if(i>-1){if(a.length===0)return it(e,t,"inputs",null);let s=o[i];e.ts.isPropertyAssignment(s)&&e.ts.isArrayLiteralExpression(s.initializer)&&(n=s.initializer)}return a.length===0?t:(n=ca(e,n||e.ts.factory.createArrayLiteralExpression(),a),i>-1?o[i]=e.ts.factory.updatePropertyAssignment(o[i],o[i].name,n):o.push(e.ts.factory.createPropertyAssignment("inputs",n)),e.ts.factory.updateObjectLiteralExpression(t,o))}function ua(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(pa),...e.meta?{meta:{...e.meta}}:{}}}function pa(e){let t={name:e.name,type:e.type};return(re(e.defaultValue)||ht(e.defaultValue)||rt(e.defaultValue))&&(t.defaultValue=e.defaultValue),re(e.friendlyName)&&(t.friendlyName=e.friendlyName),re(e.helperText)&&(t.helperText=e.helperText),e.required===!0&&(t.required=!0),Array.isArray(e.enum)&&(t.enum=e.enum),e.hideFromUI===!0&&(t.hideFromUI=!0),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(t.meta=e.meta),t}function ca(e,t,r){let n=t.elements.filter(o=>{if(!e.ts.isObjectLiteralExpression(o))return!1;let i=o.properties.find(s=>L(e,s)==="name");if(!i)return!1;let a=i.initializer;return e.ts.isStringLiteral(a)?r.some(s=>s.name===a.text):!1});for(let o of r)n=la(e,n,o);return n.sort((o,i)=>{let a=o.properties.find(c=>L(e,c)==="name"),s=i.properties.find(c=>L(e,c)==="name"),u=a?.initializer,p=s?.initializer,f=u&&e.ts.isStringLiteral(u)?u.text:"zz",m=p&&e.ts.isStringLiteral(p)?p.text:"zz";return f.toLowerCase().localeCompare(m.toLowerCase())}),e.ts.factory.updateArrayLiteralExpression(t,n)}function la(e,t,r){let n=t.findIndex(o=>o.properties.some(i=>{let a=L(e,i);return e.ts.isPropertyAssignment(i)&&a==="name"&&e.ts.isStringLiteral(i.initializer)&&i.initializer.text===r.name}));if(n>-1)t[n]=Cr(e,t[n],r);else{let o=Cr(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function Cr(e,t,r){let n=t.properties.filter(i=>e.ts.isPropertyAssignment(i)),o=Object.keys(r).filter(i=>i!=="isRegistered");for(let i of o)n=ma(e,n,r,i);return n=ga(e,n.filter(i=>{let a=L(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function ma(e,t,r,n){let o=t.findIndex(i=>e.ts.isIdentifier(i.name)&&i.name.text===n);return o>-1?t[o]=e.ts.factory.updatePropertyAssignment(t[o],t[o].name,St(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,St(e,r[n]))),t}function ce(e,t){for(let r of t){let n=e.inputs.findIndex(o=>o.name===r.name);n>-1?(r.isRegistered||!e.inputs[n].isRegistered)&&(e.inputs[n]=r):e.inputs.push(r)}e.acceptsChildren=mn(e)}function fa(e){let t=ln(e.type),r={name:e.name.trim(),type:t.builderType};return re(e.friendlyName)&&e.friendlyName.trim()!==e.name.trim()&&(r.friendlyName=e.friendlyName),(re(e.defaultValue)||ht(e.defaultValue)||rt(e.defaultValue))&&(r.defaultValue=e.defaultValue),re(e.helperText)&&(r.helperText=e.helperText),rt(e.required)&&(r.required=e.required),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(r.meta=e.meta),Array.isArray(e.enum)&&e.enum.length>0&&(r.enum=e.enum),e.hideFromUI===!0&&(r.hideFromUI=!0),fn(r)}function mn(e){let t=e.inputs.some(n=>n.name==="children"),r=e.inputs.some(n=>n.meta?.ts==="ReactNode");return!!(t||r||e.acceptsChildren===!0)}function fn(e){if(e.name==="children"&&(e.hideFromUI=!0,delete e.required),e.type==="object"&&e.defaultValue==null&&(e.hideFromUI=!0),e.type==="list"&&e.defaultValue==null&&(e.hideFromUI=!0),e.meta){let t=e.meta.ts;typeof t=="string"&&(t=t.trim(),t.endsWith("ReactNode")&&(t="ReactNode"),e.meta.ts=t,t==="ReactNode"&&(e.hideFromUI=!0))}return e}function da(e,t){let r=[...t.properties].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz";if(i==="inputs")return 1;let s=hr.indexOf(i),u=hr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)});return e.ts.factory.updateObjectLiteralExpression(t,r)}var hr=["component","name","description"];function ga(e,t){return[...t].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz",s=Er.indexOf(i),u=Er.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var Er=["name","type"];function at(e,t){for(let r of t.properties){if(!e.ts.isPropertyAssignment(r)||!e.ts.isIdentifier(r.name))continue;if(L(e,r)==="canHaveChildren"){let{initializer:o}=r;return o.kind===e.ts.SyntaxKind.TrueKeyword}}return!1}function Sr(e,t){let r=`Builder.registerComponent(
12
12
  `;if(e.appDir)t.acceptsChildren?r+=` withChildren(${t.importName}),
13
13
  `:r+=` ${t.importName},
14
14
  `;else{let o=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath);t.exportName==="default"?t.acceptsChildren?r+=` withChildren(dynamic(() => import(${JSON.stringify(o)}))),
@@ -18,8 +18,8 @@ ${r}=${n}
18
18
  `}r+=` {
19
19
  name: "${t.name}",
20
20
  }
21
- `,r+=");";let n=Vt(e,r);return dn(e,n,t)}function dn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function Y(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let n=await ir(e,t[0]),o=e.join(n,"typescript","lib"),i=new Map,a={fileExists:s=>{if(s=e.normalize(s),s.includes("node_modules")){let u=Ft.get(s);if(!u){try{e.statSync(s).isFile()?u={exists:!0,content:e.readFileSync(s)}:u={exists:!1}}catch{u={exists:!1}}Ft.set(s,u)}return u.exists}if(!i.has(s))if(e.existsSync(s)){let p=e.statSync(s);i.set(s,p.isFile())}else i.set(s,!1);return i.get(s)},getCanonicalFileName:s=>e.normalize(s),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(o,"lib.d.ts"),getDefaultLibLocation:()=>o,getNewLine:()=>`
22
- `,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=Ft.get(s);if(p)return b(e,p.content)}let u;try{u=e.readFileSync(s)}catch{console.error(`Could not read: ${s}`),u==null}if(u==null){let p=e.basename(s),f=e.extname(p).toLowerCase();if(s.startsWith(o)&&f===".ts"&&(u=Ar.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new Kt(p)}return s.includes("node_modules")&&(u?Ft.set(s,{exists:!0,content:u}):Ft.set(s,{exists:!1})),b(e,u)},readFile:s=>{let u=e.readFileSync(s);return typeof u=="string"?u:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return Da(e,a,t,r)}catch(s){if(s instanceof Kt){await xa(e,s.libName);continue}throw e.Sentry?.captureException(s),new Error(`createTsProgram() Could not create program for: ${t[0]}`,{cause:s})}}function Da(e,t,r,n){let o={rootNames:[...r],host:t,options:{}},i=e.ts.findConfigFile(e.dirname(r[0]),a=>e.existsSync(a));if(i){let a=Sr.get(i);if(!a){let s=e.ts.readConfigFile(i,u=>{let p=e.readFileSync(u);return typeof p=="string"?p:void 0});s.error?e.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:s.error,tsConfigPath:i}}):(a=e.ts.parseJsonConfigFileContent(s.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(p,f)=>e.readdirSync(p),fileExists:p=>e.existsSync(p),readFile:p=>e.readFileSync(p)||void 0},e.dirname(i),void 0,i).options,Sr.set(i,a))}a&&(o.options=ue(a))}return o.options.noEmit=!0,o.options.isolatedModules=!1,o.options.strict=!1,o.options.jsx=e.ts.JsxEmit.Preserve,o.options.allowJs=!0,Object.assign(o.options,n),e.ts.createProgram(o)}async function st(e,t,r){r||(r=await Y(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var Kt=class{constructor(t){Me(this,"libName");this.libName=t}};async function xa(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;$t.has(t)||$t.set(t,fetch(r).then(n=>n.text()).then(n=>{Ar.set(t,n)})),await $t.get(t),$t.delete(t)}var Ar=new Map,$t=new Map,Ft=new Map,Sr=new Map;function I(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=Ca(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=ha(e,t,r.defaultImport,r.importPath,n)),t}function Ca(e,t,r,n,o,i){return i==="cjs"?Pr(e,t,null,r,n):Fr(e,t,null,r,n,o)}function ha(e,t,r,n,o){return o==="cjs"?Pr(e,t,r,null,n):Fr(e,t,r,null,n,!1)}function Fr(e,t,r,n,o,i){let a=[...t.statements],s=0,u=!1,p=!1;for(let d=0;d<a.length;d++){let D=a[d];if(!e.ts.isImportDeclaration(D)||(s=d,!D.moduleSpecifier||!e.ts.isStringLiteral(D.moduleSpecifier))||D.moduleSpecifier.text!==o||!!D.importClause?.isTypeOnly!==i)continue;let g=[],x=D.importClause?.namedBindings;if(x&&e.ts.isNamedImports(x)&&x.elements&&g.push(...x.elements),typeof n=="string"){if(g.some(C=>C.name.text===n))return t;g.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),g.sort((C,E)=>C.name.text.localeCompare(E.name.text)),u=!0}let l=D.importClause?D.importClause.name:void 0;if(typeof r=="string"){if(l&&l.text===r)return t;l=e.ts.factory.createIdentifier(r),p=!0}if(u||p)return a[d]=e.ts.factory.updateImportDeclaration(D,void 0,e.ts.factory.createImportClause(i,l,e.ts.factory.createNamedImports(g)),D.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let f,m;typeof r=="string"&&(f=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let c=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,f,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,c),e.ts.factory.updateSourceFile(t,a)}function Pr(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let u=i[s];if(e.ts.isVariableStatement(u))for(let p=0;p<u.declarationList.declarations.length;p++){let f=[...u.declarationList.declarations],m=f[p],c=m.initializer;if(!c||!e.ts.isCallExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="require"||c.arguments.length!==1)continue;let D=c.arguments[0];if(e.ts.isStringLiteral(D)&&(a=s,D.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let g=[...m.name.elements];return g.some(l=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)?!1:l.name.text===n)?t:(g.push(e.ts.factory.createBindingElement(void 0,void 0,n)),g.sort((l,C)=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:l.name.text.localeCompare(C.name.text)),f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(g),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function de(e,t,r="esm"){return r==="cjs"?Sa(e,t):Ea(e,t)}function Ea(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}else!n.exportClause&&n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:n});continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function Sa(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function Aa(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function we(e,t,r,n){let o=Aa(e,r,n);if(o){let i=await Pt(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getAppRootDir(),i);return{displayFilePath:O(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function ut(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function J(e,t,r){let n=ut(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function Mt(e,t){if(t){if(Fa(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Mt(e,n)&&(r=!0)}),r)return!0}return!1}function Fa(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Pt(e,t){let r=e.extname(t).toLowerCase();if(r===""||!gn.includes(r)){for(let n of gn){let o=t+n;if(await e.exists(o))return o}for(let n of gn){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var gn=[".tsx",".jsx",".ts",".js"];function pt(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=Pa(e,i);return a?[{name:a}]:void 0}function Pa(e,t){if(typeof t=="string"){t=e.normalize(he(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function ge(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}function yr(e,t,r="esm"){return r==="cjs"?va(e,t):wa(e,t)}var ya=/^(@\w|\w)/;function wa(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!ya.test(n.moduleSpecifier.text)||n.importClause?.isTypeOnly)continue;if(n.importClause&&n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings))for(let o of n.importClause.namedBindings.elements)o.isTypeOnly||r.push({isDefaultExport:!1,statement:n,node:o.name});n.importClause&&n.importClause.name&&r.push({isDefaultExport:!0,statement:n,node:n.importClause.name})}return r}function va(e,t){return[]}async function ct(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await Y(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let p=(await ze(e,o,a.filePath,s,!1)).find(f=>f.cmpInfo.id===a.id);p&&(a.inputs=Ge(e,o,p.node.fnNode))}return a}))}async function lt(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await st(e,t.cmpInfo.filePath,r),s=(await ze(e,i,t.cmpInfo.filePath,o,n)).find(u=>u.cmpInfo.id===t.cmpInfo.id);if(!s)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,s.node.fnNode)}return[]}async function vr(e,t,r){let n=e.extname(t).toLowerCase();if(n===".tsx"||n===".jsx"||n===".ts"||n===".js"){let o=await e.readFile(t);if(o)return Ta(e,t,o,r)}return null}function Ta(e,t,r,n=!1){let o=b(e,r);return ze(e,null,t,o,n)}async function ze(e,t,r,n,o){let i=[];for(let s of n.statements)if(e.ts.isExpressionStatement(s)&&e.ts.isStringLiteral(s.expression)&&s.expression.text==="use server")return i;let a=de(e,n);return o&&a.push(...yr(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await ba(e,t,r,s);i.push(...u)})),i}async function ba(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!ot(s.name.text))continue;let u=_e(e,t,s.initializer);if(u){let p=u.name||s.name.text,f=n.isDefaultExport?"default":p,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:K(p),inputs:[],exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}}return o}if(e.ts.isArrowFunction(n.node)){let s=_e(e,t,n.node);if(s){let u=le(e,r),p=n.isDefaultExport?"default":u,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:u,inputs:[],exportName:p,exportType:f,importName:Ye(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps,framework:"react"},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!ot(s))return o;let u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Ye(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}return o}if((e.ts.isExportSpecifier(n.node)||e.ts.isIdentifier(n.node))&&ot(n.node.getText())){let s,u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named",c=Ia(e,n.node)?.moduleSpecifier??Ra(e,n.node)?.moduleSpecifier;if(c&&e.ts.isStringLiteral(c)){let d=t?.getSymbolAtLocation(c);if(d&&d.declarations&&d.declarations.length>0){let D=d.declarations[0];(!e.ts.isSourceFile(D)||e.ts.isSourceFile(D)&&D.fileName.includes("node_modules"))&&(s=c.text)}}o.push({cmpInfo:{id:await V(e,r,f,s),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Ye(e,r),filePath:r,relFilePath:i,importPath:s||a,externalImportPath:s,dependencies:u.deps,framework:"react"},node:u})}return o}if(e.ts.isExportDeclaration(n.node)&&n.node.exportClause===void 0){let s=n.node.moduleSpecifier;if(s&&e.ts.isStringLiteral(s)){let u=await Ba(e,t,r,s);o.push(...u)}return o}return o}function Ia(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function Ra(e,t){for(;t;){if(e.ts.isImportDeclaration(t))return t;t=t.parent}return null}function _e(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return Mt(e,r.body)?{name:"",fnNode:r,deps:pt(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Mt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:pt(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(e.ts.isPropertyAccessExpression(n)){let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:_e(e,t,o[0])}else if(e.ts.isIdentifier(n)&&(n.text==="observer"||n.text==="forwardRef")){let o=r.arguments;return o.length===0?null:_e(e,t,o[0])}return null}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!ot(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:pt(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:pt(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:pt(e,t,r)};if(e.ts.isExpressionStatement(r)){let n=r.expression;if(e.ts.isAsExpression(n)&&e.ts.isIdentifier(n.type)&&n.type.text==="default")return _e(e,t,n.expression)}if(e.ts.isVariableStatement(r)){for(let n of r.declarationList.declarations)if(n.initializer&&e.ts.isAsExpression(n.initializer)){let o=n.initializer;if(e.ts.isIdentifier(o.type)&&o.type.text==="default"){let i=_e(e,t,o.expression);if(i&&e.ts.isIdentifier(n.name))return{name:n.name.text,fnNode:i.fnNode,deps:i.deps}}}}return null}async function Tr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(jt(e,Na,i.fileName)||a===e.reactConfigPath||a===e.builderComponentPath)return;let s=await ze(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Na=new Set(["node_modules","dist"]);async function Ba(e,t,r,n){let o=[],i=n.text;if(!t)return o;try{let a=t.getSymbolAtLocation(n);if(!a)return o;let s=t.getExportsOfModule(a);for(let u of s){let p=u.valueDeclaration||u.declarations?.[0];if(!p)continue;let f=u.name;if(!ot(f)&&f!=="default"||!br(e,t,p))continue;let m=_e(e,t,p);if(m){let c=u.name,d=c==="default"?"default":"named",D=K(c),g=c==="default"?Ye(e,r):c;o.push({cmpInfo:{id:await V(e,r,c,i),displayFilePath:O(e,r),name:D,inputs:[],exportName:c,exportType:d,importName:g,filePath:r,relFilePath:e.relative(e.getAppRootDir(),r),importPath:i,externalImportPath:i,dependencies:m.deps,framework:"react"},node:m})}}}catch(a){e.Sentry?.captureException(new Error(`Error processing module ${i}:`,{cause:a}),{extra:{modulePath:i,filePath:r}})}return o}function br(e,t,r){if(e.ts.isInterfaceDeclaration(r)||e.ts.isTypeAliasDeclaration(r))return!1;if(e.ts.isExportSpecifier(r)){let n=t.getSymbolAtLocation(r.name);if(n){let i=t.getAliasedSymbol(n).declarations?.[0];if(i)return br(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)){let n=t.getSignatureFromDeclaration(r);if(n){let o=t.getReturnTypeOfSignature(n);return wr(o,t)}}return e.ts.isClassDeclaration(r)?r.heritageClauses?.some(o=>o.types.some(i=>i.expression.getText()==="React.Component"||i.expression.getText()==="Component"))??!1:e.ts.isVariableDeclaration(r)?t.getTypeAtLocation(r).getCallSignatures().some(i=>wr(t.getReturnTypeOfSignature(i),t)):!1}function wr(e,t){let r=t.typeToString(e);return r==="JSX.Element"||r==="Element"||r.includes("ReactElement")||r.includes("React.ReactElement")||r.includes("ReactNode")}async function Ir(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&Oa.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.builderComponentPath)return;let u=await ze(e,o,s,i,s===e.registryPath||Ae(s));r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Oa=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ve(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let u=a.moduleSpecifier.text;if(!u.startsWith(".")&&!u.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...Dn(e,r),...Dn(e,n),...Dn(e,o),...i])}function De(e){let t=e.split(`
21
+ `,r+=");";let n=Vt(e,r);return dn(e,n,t)}function dn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function Y(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let n=await ar(e,t[0]),o=e.join(n,"typescript","lib"),i=new Map,a={fileExists:s=>{if(s=e.normalize(s),s.includes("node_modules")){let u=Ft.get(s);if(!u){try{e.statSync(s).isFile()?u={exists:!0,content:e.readFileSync(s)}:u={exists:!1}}catch{u={exists:!1}}Ft.set(s,u)}return u.exists}if(!i.has(s))if(e.existsSync(s)){let p=e.statSync(s);i.set(s,p.isFile())}else i.set(s,!1);return i.get(s)},getCanonicalFileName:s=>e.normalize(s),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(o,"lib.d.ts"),getDefaultLibLocation:()=>o,getNewLine:()=>`
22
+ `,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=Ft.get(s);if(p)return b(e,p.content)}let u;try{u=e.readFileSync(s)}catch{console.error(`Could not read: ${s}`),u==null}if(u==null){let p=e.basename(s),f=e.extname(p).toLowerCase();if(s.startsWith(o)&&f===".ts"&&(u=Fr.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new Kt(p)}return s.includes("node_modules")&&(u?Ft.set(s,{exists:!0,content:u}):Ft.set(s,{exists:!1})),b(e,u)},readFile:s=>{let u=e.readFileSync(s);return typeof u=="string"?u:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return Da(e,a,t,r)}catch(s){if(s instanceof Kt){await xa(e,s.libName);continue}throw e.Sentry?.captureException(s),new Error(`createTsProgram() Could not create program for: ${t[0]}`,{cause:s})}}function Da(e,t,r,n){let o={rootNames:[...r],host:t,options:{}},i=e.ts.findConfigFile(e.dirname(r[0]),a=>e.existsSync(a));if(i){let a=Ar.get(i);if(!a){let s=e.ts.readConfigFile(i,u=>{let p=e.readFileSync(u);return typeof p=="string"?p:void 0});s.error?e.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:s.error,tsConfigPath:i}}):(a=e.ts.parseJsonConfigFileContent(s.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(p,f)=>e.readdirSync(p),fileExists:p=>e.existsSync(p),readFile:p=>e.readFileSync(p)||void 0},e.dirname(i),void 0,i).options,Ar.set(i,a))}a&&(o.options=pe(a))}return o.options.noEmit=!0,o.options.isolatedModules=!1,o.options.strict=!1,o.options.jsx=e.ts.JsxEmit.Preserve,o.options.allowJs=!0,Object.assign(o.options,n),e.ts.createProgram(o)}async function st(e,t,r){r||(r=await Y(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var Kt=class{constructor(t){Me(this,"libName");this.libName=t}};async function xa(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;$t.has(t)||$t.set(t,fetch(r).then(n=>n.text()).then(n=>{Fr.set(t,n)})),await $t.get(t),$t.delete(t)}var Fr=new Map,$t=new Map,Ft=new Map,Ar=new Map;function I(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=Ca(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=ha(e,t,r.defaultImport,r.importPath,n)),t}function Ca(e,t,r,n,o,i){return i==="cjs"?yr(e,t,null,r,n):Pr(e,t,null,r,n,o)}function ha(e,t,r,n,o){return o==="cjs"?yr(e,t,r,null,n):Pr(e,t,r,null,n,!1)}function Pr(e,t,r,n,o,i){let a=[...t.statements],s=0,u=!1,p=!1;for(let d=0;d<a.length;d++){let D=a[d];if(!e.ts.isImportDeclaration(D)||(s=d,!D.moduleSpecifier||!e.ts.isStringLiteral(D.moduleSpecifier))||D.moduleSpecifier.text!==o||!!D.importClause?.isTypeOnly!==i)continue;let g=[],x=D.importClause?.namedBindings;if(x&&e.ts.isNamedImports(x)&&x.elements&&g.push(...x.elements),typeof n=="string"){if(g.some(C=>C.name.text===n))return t;g.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),g.sort((C,E)=>C.name.text.localeCompare(E.name.text)),u=!0}let l=D.importClause?D.importClause.name:void 0;if(typeof r=="string"){if(l&&l.text===r)return t;l=e.ts.factory.createIdentifier(r),p=!0}if(u||p)return a[d]=e.ts.factory.updateImportDeclaration(D,void 0,e.ts.factory.createImportClause(i,l,e.ts.factory.createNamedImports(g)),D.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let f,m;typeof r=="string"&&(f=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let c=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,f,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,c),e.ts.factory.updateSourceFile(t,a)}function yr(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let u=i[s];if(e.ts.isVariableStatement(u))for(let p=0;p<u.declarationList.declarations.length;p++){let f=[...u.declarationList.declarations],m=f[p],c=m.initializer;if(!c||!e.ts.isCallExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="require"||c.arguments.length!==1)continue;let D=c.arguments[0];if(e.ts.isStringLiteral(D)&&(a=s,D.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let g=[...m.name.elements];return g.some(l=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)?!1:l.name.text===n)?t:(g.push(e.ts.factory.createBindingElement(void 0,void 0,n)),g.sort((l,C)=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:l.name.text.localeCompare(C.name.text)),f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(g),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function de(e,t,r="esm"){return r==="cjs"?Sa(e,t):Ea(e,t)}function Ea(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}else!n.exportClause&&n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:n});continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function Sa(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function Aa(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function we(e,t,r,n){let o=Aa(e,r,n);if(o){let i=await Pt(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getAppRootDir(),i);return{displayFilePath:k(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function ut(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function J(e,t,r){let n=ut(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function Mt(e,t){if(t){if(Fa(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Mt(e,n)&&(r=!0)}),r)return!0}return!1}function Fa(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Pt(e,t){let r=e.extname(t).toLowerCase();if(r===""||!gn.includes(r)){for(let n of gn){let o=t+n;if(await e.exists(o))return o}for(let n of gn){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var gn=[".tsx",".jsx",".ts",".js"];function pt(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=Pa(e,i);return a?[{name:a}]:void 0}function Pa(e,t){if(typeof t=="string"){t=e.normalize(he(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function ge(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}function wr(e,t,r="esm"){return r==="cjs"?va(e,t):wa(e,t)}var ya=/^(@\w|\w)/;function wa(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!ya.test(n.moduleSpecifier.text)||n.importClause?.isTypeOnly)continue;if(n.importClause&&n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings))for(let o of n.importClause.namedBindings.elements)o.isTypeOnly||r.push({isDefaultExport:!1,statement:n,node:o.name});n.importClause&&n.importClause.name&&r.push({isDefaultExport:!0,statement:n,node:n.importClause.name})}return r}function va(e,t){return[]}async function ct(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await Y(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let p=(await ze(e,o,a.filePath,s,!1)).find(f=>f.cmpInfo.id===a.id);p&&(a.inputs=Ge(e,o,p.node.fnNode))}return a}))}async function lt(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await st(e,t.cmpInfo.filePath,r),s=(await ze(e,i,t.cmpInfo.filePath,o,n)).find(u=>u.cmpInfo.id===t.cmpInfo.id);if(!s)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,s.node.fnNode)}return[]}async function Tr(e,t,r){let n=e.extname(t).toLowerCase();if(n===".tsx"||n===".jsx"||n===".ts"||n===".js"){let o=await e.readFile(t);if(o)return Ta(e,t,o,r)}return null}function Ta(e,t,r,n=!1){let o=b(e,r);return ze(e,null,t,o,n)}async function ze(e,t,r,n,o){let i=[];for(let s of n.statements)if(e.ts.isExpressionStatement(s)&&e.ts.isStringLiteral(s.expression)&&s.expression.text==="use server")return i;let a=de(e,n);return o&&a.push(...wr(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await ba(e,t,r,s);i.push(...u)})),i}async function ba(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!ot(s.name.text))continue;let u=_e(e,t,s.initializer);if(u){let p=u.name||s.name.text,f=n.isDefaultExport?"default":p,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:k(e,r),name:K(p),inputs:[],exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}}return o}if(e.ts.isArrowFunction(n.node)){let s=_e(e,t,n.node);if(s){let u=le(e,r),p=n.isDefaultExport?"default":u,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,p),displayFilePath:k(e,r),name:u,inputs:[],exportName:p,exportType:f,importName:Ye(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps,framework:"react"},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!ot(s))return o;let u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:k(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Ye(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}return o}if((e.ts.isExportSpecifier(n.node)||e.ts.isIdentifier(n.node))&&ot(n.node.getText())){let s,u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named",c=Ia(e,n.node)?.moduleSpecifier??Ra(e,n.node)?.moduleSpecifier;if(c&&e.ts.isStringLiteral(c)){let d=t?.getSymbolAtLocation(c);if(d&&d.declarations&&d.declarations.length>0){let D=d.declarations[0];(!e.ts.isSourceFile(D)||e.ts.isSourceFile(D)&&D.fileName.includes("node_modules"))&&(s=c.text)}}o.push({cmpInfo:{id:await V(e,r,f,s),displayFilePath:k(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Ye(e,r),filePath:r,relFilePath:i,importPath:s||a,externalImportPath:s,dependencies:u.deps,framework:"react"},node:u})}return o}if(e.ts.isExportDeclaration(n.node)&&n.node.exportClause===void 0){let s=n.node.moduleSpecifier;if(s&&e.ts.isStringLiteral(s)){let u=await Ba(e,t,r,s);o.push(...u)}return o}return o}function Ia(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function Ra(e,t){for(;t;){if(e.ts.isImportDeclaration(t))return t;t=t.parent}return null}function _e(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return Mt(e,r.body)?{name:"",fnNode:r,deps:pt(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Mt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:pt(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(e.ts.isPropertyAccessExpression(n)){let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:_e(e,t,o[0])}else if(e.ts.isIdentifier(n)&&(n.text==="observer"||n.text==="forwardRef")){let o=r.arguments;return o.length===0?null:_e(e,t,o[0])}return null}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!ot(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:pt(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:pt(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:pt(e,t,r)};if(e.ts.isExpressionStatement(r)){let n=r.expression;if(e.ts.isAsExpression(n)&&e.ts.isIdentifier(n.type)&&n.type.text==="default")return _e(e,t,n.expression)}if(e.ts.isVariableStatement(r)){for(let n of r.declarationList.declarations)if(n.initializer&&e.ts.isAsExpression(n.initializer)){let o=n.initializer;if(e.ts.isIdentifier(o.type)&&o.type.text==="default"){let i=_e(e,t,o.expression);if(i&&e.ts.isIdentifier(n.name))return{name:n.name.text,fnNode:i.fnNode,deps:i.deps}}}}return null}async function br(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(jt(e,Na,i.fileName)||a===e.reactConfigPath||a===e.builderComponentPath)return;let s=await ze(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Na=new Set(["node_modules","dist"]);async function Ba(e,t,r,n){let o=[],i=n.text;if(!t)return o;try{let a=t.getSymbolAtLocation(n);if(!a)return o;let s=t.getExportsOfModule(a);for(let u of s){let p=u.valueDeclaration||u.declarations?.[0];if(!p)continue;let f=u.name;if(!ot(f)&&f!=="default"||!Ir(e,t,p))continue;let m=_e(e,t,p);if(m){let c=u.name,d=c==="default"?"default":"named",D=K(c),g=c==="default"?Ye(e,r):c;o.push({cmpInfo:{id:await V(e,r,c,i),displayFilePath:k(e,r),name:D,inputs:[],exportName:c,exportType:d,importName:g,filePath:r,relFilePath:e.relative(e.getAppRootDir(),r),importPath:i,externalImportPath:i,dependencies:m.deps,framework:"react"},node:m})}}}catch(a){e.Sentry?.captureException(new Error(`Error processing module ${i}:`,{cause:a}),{extra:{modulePath:i,filePath:r}})}return o}function Ir(e,t,r){if(e.ts.isInterfaceDeclaration(r)||e.ts.isTypeAliasDeclaration(r))return!1;if(e.ts.isExportSpecifier(r)){let n=t.getSymbolAtLocation(r.name);if(n){let i=t.getAliasedSymbol(n).declarations?.[0];if(i)return Ir(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)){let n=t.getSignatureFromDeclaration(r);if(n){let o=t.getReturnTypeOfSignature(n);return vr(o,t)}}return e.ts.isClassDeclaration(r)?r.heritageClauses?.some(o=>o.types.some(i=>i.expression.getText()==="React.Component"||i.expression.getText()==="Component"))??!1:e.ts.isVariableDeclaration(r)?t.getTypeAtLocation(r).getCallSignatures().some(i=>vr(t.getReturnTypeOfSignature(i),t)):!1}function vr(e,t){let r=t.typeToString(e);return r==="JSX.Element"||r==="Element"||r.includes("ReactElement")||r.includes("React.ReactElement")||r.includes("ReactNode")}async function Rr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&ka.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.builderComponentPath)return;let u=await ze(e,o,s,i,s===e.registryPath||Ae(s));r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var ka=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ve(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let u=a.moduleSpecifier.text;if(!u.startsWith(".")&&!u.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...Dn(e,r),...Dn(e,n),...Dn(e,o),...i])}function De(e){let t=e.split(`
23
23
  `).map(n=>n.trimEnd());e="";let r=!1;for(let n=t.length-1;n>=0;n--){let o=t[n];!r&&o.startsWith("import ")&&(r=!0,o=o+`
24
24
  `),/^builder.init(.*)$/.test(o)&&(o=o+`
25
25
  `),t[n-1]&&!t[n-1].includes("*/")&&(o.trim().startsWith("Builder.registerComponent")&&(o=`
@@ -28,8 +28,8 @@ ${r}=${n}
28
28
  `+o),o.trim().startsWith("export ")&&(o=`
29
29
  `+o)),e=o+`
30
30
  `+e}return e.trim()+`
31
- `}function Dn(e,t){return t.sort((r,n)=>{let o=Rr(e,r),i=Rr(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())})}function Rr(e,t){let r=t.importClause;if(r){let n=r.namedBindings;if(n&&e.ts.isNamedImports(n)&&n.elements.length>0)return n.elements[0].name.text;if(r.name)return r.name.text}return t.moduleSpecifier&&e.ts.isStringLiteral(t.moduleSpecifier)?t.moduleSpecifier.text:""}function Br(e){return typeof e=="string"&&!e.includes("'use client'")&&!e.includes(`"use client"'`)&&(e=`"use client"
32
- ${e}`),e}function Or(e,t){let r=t.statements.filter(n=>!(e.ts.isExpressionStatement(n)&&e.ts.isStringLiteral(n.expression)&&e.ts.isStringLiteral(n.expression)&&n.expression.text==="use client"));return e.ts.factory.updateSourceFile(t,r)}function Te(e,t){return t.sort((r,n)=>{if(e.ts.isObjectLiteralExpression(r)&&e.ts.isObjectLiteralExpression(n)){let o=Nr(e,r),i=Nr(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())}return 1})}function Nr(e,t){let r=t.properties.find(n=>L(e,n)==="name");return r&&e.ts.isPropertyAssignment(r)&&e.ts.isStringLiteral(r.initializer)?r.initializer.text:"zzzz"}async function kr(e){let t=await e.readFile(e.registryPath);return t?ka(e,t):{components:[],sourceFile:b(e,"")}}async function ka(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?_a(e,r):La(e,r)}async function La(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isCallExpression(m)){let c=e.ts.isIdentifier(m.expression)&&m.expression.text;if(c==="withChildren"){let D=hn(e,m.arguments[0]);if(e.ts.isCallExpression(D)){let g=await xn(e,n,D,f,!0);g&&r.push(g)}else{let g=D;if(e.ts.isIdentifier(g)){let x=await Cn(e,t,n,g,f,!0);x&&r.push(x)}}continue}if(c==="dynamic"){let D=await xn(e,n,m,f,!1);D&&r.push(D);continue}let d=hn(e,m.arguments[0]);if(e.ts.isCallExpression(d)&&e.ts.isIdentifier(d.expression)&&d.expression.text==="dynamic"){let D=await xn(e,n,d,f,!1);D&&r.push(D);continue}if(e.ts.isIdentifier(d)){let D=await Cn(e,t,n,d,f,!1);D&&r.push(D);continue}continue}if(e.ts.isIdentifier(m)){let c=await Cn(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}function hn(e,t){return e.ts.isCallExpression(t)?(e.ts.isIdentifier(t.expression)&&t.expression.text)==="dynamic"?t:hn(e,t.arguments[0]):t}async function xn(e,t,r,n,o){let i={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:t,acceptsChildren:o,framework:"react"},a=r.arguments;if(a.length===0)return null;let s=a[0];if(!e.ts.isArrowFunction(s))return null;let u=s.body;if(e.ts.isCallExpression(u)){if(u.expression.kind!==e.ts.SyntaxKind.ImportKeyword||u.arguments.length!==1)return null;let f=u.arguments[0];if(!e.ts.isStringLiteral(f))return null;let m=f.text,c=await mt(e,m);i.filePath=c,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(c)?i.importPath=M(e,i.filePath):(i.externalImportPath=m,i.importPath=i.externalImportPath),i.name=le(e,i.filePath),i.importName="default",i.exportName="default",i.exportType="default"}else if(e.ts.isPropertyAccessExpression(u)){let p=u.expression;if(!e.ts.isParenthesizedExpression(p))return null;let f=p.expression;if(!e.ts.isAwaitExpression(f))return null;let m=f.expression;if(!e.ts.isCallExpression(m)||m.expression.kind!==e.ts.SyntaxKind.ImportKeyword||m.arguments.length!==1)return null;let d=m.arguments[0];if(!e.ts.isStringLiteral(d)||!e.ts.isIdentifier(u.name))return null;let D=d.text,g=await mt(e,D);i.filePath=g,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(g)?i.importPath=M(e,i.filePath):(i.externalImportPath=D,i.importPath=i.externalImportPath),i.name=K(u.name.text),i.importName=u.name.text,i.exportName=u.name.text,i.exportType="named"}else return null;return i=se(e,i,n),i.displayFilePath=O(e,i.filePath),i.filePath&&i.exportName&&(i.id=await V(e,i.filePath,i.exportName,i.externalImportPath)),i}async function Cn(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;let f=await mt(e,p.text);a.filePath=f,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(f)?a.importPath=M(e,a.filePath):(a.externalImportPath=p.text,a.importPath=a.externalImportPath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await mt(e,f.text);a.filePath=m,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=O(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function mt(e,t){return Pt(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}function Lr(e,t,r){let n=!1,o=0,i=[...t.statements];for(let p=0;p<i.length;p++){let f=i[p];if(e.ts.isImportDeclaration(f)){o=p;continue}if(!e.ts.isExpressionStatement(f))continue;let m=f.expression;if(!e.ts.isCallExpression(m))continue;let c=m.expression;if(!e.ts.isPropertyAccessExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="builder")continue;if(c.name.text=="init"){n=!0;break}else continue}if(n)return t;let a=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("process"),e.ts.factory.createIdentifier("env")),e.ts.factory.createIdentifier(ye)),s=r?e.ts.factory.createNonNullExpression(a):a,u=e.ts.factory.createExpressionStatement(e.ts.factory.createCallExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("builder"),e.ts.factory.createIdentifier("init")),void 0,[s]));return i.splice(o+1,0,u),e.ts.factory.updateSourceFile(t,i)}async function _a(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await En(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function En(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};at(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isCallExpression(u)&&(e.ts.isIdentifier(u.expression)&&u.expression.text)==="dynamic"){let d=u.arguments;if(d.length===0)return null;let D=d[0];if(!e.ts.isArrowFunction(D))return null;let g=D.body;if(e.ts.isCallExpression(g)){if(g.expression.kind!==e.ts.SyntaxKind.ImportKeyword||g.arguments.length!==1)return null;let l=g.arguments[0];if(!e.ts.isStringLiteral(l))return null;let C=l.text,E=await mt(e,C);n.filePath=E,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(E)?n.importPath=M(e,n.filePath):(n.externalImportPath=C,n.importPath=n.externalImportPath),n.name=le(e,n.filePath),n.importName="default",n.exportName="default",n.exportType="default"}else if(e.ts.isPropertyAccessExpression(g)){let x=g.expression;if(!e.ts.isParenthesizedExpression(x))return null;let l=x.expression;if(!e.ts.isAwaitExpression(l))return null;let C=l.expression;if(!e.ts.isCallExpression(C)||C.expression.kind!==e.ts.SyntaxKind.ImportKeyword||C.arguments.length!==1)return null;let F=C.arguments[0];if(!e.ts.isStringLiteral(F)||!e.ts.isIdentifier(g.name))return null;let A=F.text,S=await mt(e,A);n.filePath=S,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(S)?n.importPath=M(e,n.filePath):(n.externalImportPath=A,n.importPath=n.externalImportPath),n.name=K(g.name.text),n.importName=g.name.text,n.exportName=g.name.text,n.exportType="named"}else return null;return n=se(e,n,r),n.displayFilePath=O(e,n.filePath),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.importPath=M(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}function be(e,t){let r=[...t.statements],n=!1;for(let o=t.statements.length-1;o>=0;o--){let i=t.statements[o];if(e.ts.isImportDeclaration(i)&&i.importClause){let a=!1,s=i.importClause.namedBindings;if(s&&e.ts.isNamedImports(s)&&s.elements){let u=[...s.elements];for(let p=u.length-1;p>=0;p--){let f=u[p];if(e.ts.isImportSpecifier(f)){let m=f.name;if(m&&e.ts.isIdentifier(m)){let c=m.text;_r(e,t,c)||u.splice(p,1)}}}if(u.length===0)a=!0;else if(s.elements.length!==u.length){let p=e.ts.factory.updateImportClause(i.importClause,!1,i.importClause.name,e.ts.factory.createNamedImports(u)),f=e.ts.factory.updateImportDeclaration(i,void 0,p,i.moduleSpecifier,void 0);r[o]=f,n=!0}}else if(i.importClause.name&&e.ts.isIdentifier(i.importClause.name)){let u=i.importClause.name.text;_r(e,t,u)||(a=!0)}a&&(r.splice(o,1),n=!0)}}return n?e.ts.factory.updateSourceFile(t,r):t}function _r(e,t,r){let n=!1;function o(i){if(!e.ts.isImportDeclaration(i)){if(e.ts.isIdentifier(i)&&i.text===r){n=!0;return}e.ts.forEachChild(i,o)}}return e.ts.forEachChild(t,o),n}function Ie(e,t,r,n,o,i,a){let s=null,u=null,p=null,f=-1;t=ue(t),r=ue(r);let m=t.find(d=>d.id===e),c=r.find(d=>d.id===e);if(n)c||(s={...ue(m),inputs:ue(m.inputs).map(d=>(d.isRegistered=!0,d))},f=r.length,r.push(s));else if(typeof c?.nodeIndex=="number"&&c.nodeIndex>-1){if(o)f=c.nodeIndex,u=ue(c),r=r.filter(d=>d.id!==e);else if(i!=null)ja(c,i),f=c.nodeIndex,p=c;else if(a!=null){let d=c.inputs.find(D=>D.name===a.name);d&&(a.registerInput===!1?d.isRegistered=!1:(Va(d,a),d.isRegistered=!0),p=c,f=c.nodeIndex)}}return{addCmpToRegistry:s,removeCmpFromRegistry:u,updateRegisteredCmp:p,nodeIndex:f,components:Ee(t,r)}}function Ee(e,t){let r=ae([...t.map(n=>(n.isRegistered=!0,n)),...e.filter(n=>!t.some(o=>o.id===n.id)).map(n=>(n.isRegistered=!1,n))]);return r.forEach(n=>{n.inputs=n.inputs.map(fn),n.inputs.sort((a,s)=>a.name.toLowerCase().localeCompare(s.name.toLowerCase()));let o=t.find(a=>a.id===n.id);o&&(o.acceptsChildren=mn(n));let i=e.find(a=>a.id===n.id&&a.externalImportPath);i&&(n.filePath=i.filePath,n.relFilePath=i.relFilePath)}),r}function ja(e,t){re(t.name)?e.name=t.name:t.name===null&&(e.name=e.importName),re(t.description)?e.description=t.description:t.description===null&&delete e.description,re(t.image)?e.image=t.image:t.image===null&&delete e.image}function Va(e,t){re(t.type)&&(e.type=t.type),re(t.friendlyName)?e.friendlyName=t.friendlyName:t.friendlyName===null&&delete e.friendlyName,re(t.defaultValue)||ht(t.defaultValue)||rt(t.defaultValue)?e.defaultValue=t.defaultValue:t.defaultValue===null&&delete e.defaultValue,re(t.helperText)?e.helperText=t.helperText:t.helperText===null&&delete e.helperText,t.required===!0?e.required=t.required:(t.required===null||t.required===!1)&&delete e.required}async function qe(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".jsx"||u===".ts"||u===".js"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await Y(e,[...t])}function Re(e,t,r){return ut(e,t,r.variableName)?t:$a(e,t,r)}function $a(e,t,r){let n=typeof r.arrayType=="string"?e.ts.factory.createArrayTypeNode(e.ts.factory.createTypeReferenceNode(r.arrayType,void 0)):void 0,o=e.ts.factory.createArrayLiteralExpression([]),i=e.ts.factory.createVariableDeclaration(r.variableName,void 0,n,o),a=e.ts.factory.createVariableDeclarationList([i],e.ts.NodeFlags.Const),s=e.ts.factory.createModifier(e.ts.SyntaxKind.ExportKeyword),u=e.ts.factory.createVariableStatement([s],a),p=[...t.statements,u];return e.ts.factory.updateSourceFile(t,p)}async function Ne(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m,c]=await Promise.all([Ir(e,u),kr(e),ne(e),Et(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await ct(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await Y(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await lt(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));pe(B,$);let k=d.findIndex(w=>w.id===S.cmpInfo.id);d[k].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:H,variableDeclaration:_}=await Ua(e,l,S);if(P.addCmpToRegistry)w.push(Ma(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[Vr(e,P.updateRegisteredCmp),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(H,H.modifiers,e.ts.factory.updateVariableDeclarationList(H.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=jr(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(He=>He.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(Er(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=dn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=Lr(e,l,m),l=jr(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l),e.appDir&&(l=Or(e,l));let E=j(e,l);E=De(E),e.appDir&&(E=Br(E)),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}function Vr(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.appDir?e.ts.factory.createPropertyAssignment("component",r):e.ts.factory.createPropertyAssignment("component",za(e,t))}function Ka(e){return e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())}function Ma(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([Vr(e,t),...t.acceptsChildren?[Ka(e)]:[]],!0),t)}async function Ua(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await En(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function jr(e,t,r){if(e.appDir){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}}else r=I(e,r,{defaultImport:"dynamic",importPath:"next/dynamic"});return r}function za(e,t){let r=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath),n=t.exportName!=="default",o;n?o=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createAwaitExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)])),e.ts.factory.createIdentifier(t.exportName)):o=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)]);let i=e.ts.factory.createArrowFunction(n?[e.ts.factory.createModifier(e.ts.SyntaxKind.AsyncKeyword)]:void 0,void 0,[],void 0,e.ts.factory.createToken(e.ts.SyntaxKind.EqualsGreaterThanToken),o);return e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("dynamic"),void 0,[i])}async function Kr(e){let t=[],r=await Ha(e,t);return await Jr(e,t,r),e.appDir?(e.debug(`ensure builder setup for next.js app ${e.appDir}`),await Ja(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure builder setup for next.js pages ${e.pagesDir}`),await Wa(e,e.pagesDir,t)),t}async function Mr(e){let t=[];return await Jr(e,t),e.appDir?(e.debug(`ensure figma-imports setup for next.js app ${e.appDir}`),await qa(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure figma-imports setup for next.js pages ${e.pagesDir}`),await Qa(e,e.pagesDir,t)),t}async function qa(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"figma-imports",n);if(!await e.exists(o)){let i=await e.formatCode(o,zr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,Ur(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}async function Ja(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"[...page]",n);if(!await e.exists(o)){let i=await e.formatCode(o,zr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,Ur(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}function Ur(e){let t=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
31
+ `}function Dn(e,t){return t.sort((r,n)=>{let o=Nr(e,r),i=Nr(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())})}function Nr(e,t){let r=t.importClause;if(r){let n=r.namedBindings;if(n&&e.ts.isNamedImports(n)&&n.elements.length>0)return n.elements[0].name.text;if(r.name)return r.name.text}return t.moduleSpecifier&&e.ts.isStringLiteral(t.moduleSpecifier)?t.moduleSpecifier.text:""}function kr(e){return typeof e=="string"&&!e.includes("'use client'")&&!e.includes(`"use client"'`)&&(e=`"use client"
32
+ ${e}`),e}function Or(e,t){let r=t.statements.filter(n=>!(e.ts.isExpressionStatement(n)&&e.ts.isStringLiteral(n.expression)&&e.ts.isStringLiteral(n.expression)&&n.expression.text==="use client"));return e.ts.factory.updateSourceFile(t,r)}function Te(e,t){return t.sort((r,n)=>{if(e.ts.isObjectLiteralExpression(r)&&e.ts.isObjectLiteralExpression(n)){let o=Br(e,r),i=Br(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())}return 1})}function Br(e,t){let r=t.properties.find(n=>L(e,n)==="name");return r&&e.ts.isPropertyAssignment(r)&&e.ts.isStringLiteral(r.initializer)?r.initializer.text:"zzzz"}async function Lr(e){let t=await e.readFile(e.registryPath);return t?Oa(e,t):{components:[],sourceFile:b(e,"")}}async function Oa(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?_a(e,r):La(e,r)}async function La(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isCallExpression(m)){let c=e.ts.isIdentifier(m.expression)&&m.expression.text;if(c==="withChildren"){let D=hn(e,m.arguments[0]);if(e.ts.isCallExpression(D)){let g=await xn(e,n,D,f,!0);g&&r.push(g)}else{let g=D;if(e.ts.isIdentifier(g)){let x=await Cn(e,t,n,g,f,!0);x&&r.push(x)}}continue}if(c==="dynamic"){let D=await xn(e,n,m,f,!1);D&&r.push(D);continue}let d=hn(e,m.arguments[0]);if(e.ts.isCallExpression(d)&&e.ts.isIdentifier(d.expression)&&d.expression.text==="dynamic"){let D=await xn(e,n,d,f,!1);D&&r.push(D);continue}if(e.ts.isIdentifier(d)){let D=await Cn(e,t,n,d,f,!1);D&&r.push(D);continue}continue}if(e.ts.isIdentifier(m)){let c=await Cn(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}function hn(e,t){return e.ts.isCallExpression(t)?(e.ts.isIdentifier(t.expression)&&t.expression.text)==="dynamic"?t:hn(e,t.arguments[0]):t}async function xn(e,t,r,n,o){let i={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:t,acceptsChildren:o,framework:"react"},a=r.arguments;if(a.length===0)return null;let s=a[0];if(!e.ts.isArrowFunction(s))return null;let u=s.body;if(e.ts.isCallExpression(u)){if(u.expression.kind!==e.ts.SyntaxKind.ImportKeyword||u.arguments.length!==1)return null;let f=u.arguments[0];if(!e.ts.isStringLiteral(f))return null;let m=f.text,c=await mt(e,m);i.filePath=c,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(c)?i.importPath=M(e,i.filePath):(i.externalImportPath=m,i.importPath=i.externalImportPath),i.name=le(e,i.filePath),i.importName="default",i.exportName="default",i.exportType="default"}else if(e.ts.isPropertyAccessExpression(u)){let p=u.expression;if(!e.ts.isParenthesizedExpression(p))return null;let f=p.expression;if(!e.ts.isAwaitExpression(f))return null;let m=f.expression;if(!e.ts.isCallExpression(m)||m.expression.kind!==e.ts.SyntaxKind.ImportKeyword||m.arguments.length!==1)return null;let d=m.arguments[0];if(!e.ts.isStringLiteral(d)||!e.ts.isIdentifier(u.name))return null;let D=d.text,g=await mt(e,D);i.filePath=g,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(g)?i.importPath=M(e,i.filePath):(i.externalImportPath=D,i.importPath=i.externalImportPath),i.name=K(u.name.text),i.importName=u.name.text,i.exportName=u.name.text,i.exportType="named"}else return null;return i=se(e,i,n),i.displayFilePath=k(e,i.filePath),i.filePath&&i.exportName&&(i.id=await V(e,i.filePath,i.exportName,i.externalImportPath)),i}async function Cn(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;let f=await mt(e,p.text);a.filePath=f,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(f)?a.importPath=M(e,a.filePath):(a.externalImportPath=p.text,a.importPath=a.externalImportPath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await mt(e,f.text);a.filePath=m,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=k(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function mt(e,t){return Pt(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}function _r(e,t,r){let n=!1,o=0,i=[...t.statements];for(let p=0;p<i.length;p++){let f=i[p];if(e.ts.isImportDeclaration(f)){o=p;continue}if(!e.ts.isExpressionStatement(f))continue;let m=f.expression;if(!e.ts.isCallExpression(m))continue;let c=m.expression;if(!e.ts.isPropertyAccessExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="builder")continue;if(c.name.text=="init"){n=!0;break}else continue}if(n)return t;let a=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("process"),e.ts.factory.createIdentifier("env")),e.ts.factory.createIdentifier(ye)),s=r?e.ts.factory.createNonNullExpression(a):a,u=e.ts.factory.createExpressionStatement(e.ts.factory.createCallExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("builder"),e.ts.factory.createIdentifier("init")),void 0,[s]));return i.splice(o+1,0,u),e.ts.factory.updateSourceFile(t,i)}async function _a(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await En(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function En(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};at(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isCallExpression(u)&&(e.ts.isIdentifier(u.expression)&&u.expression.text)==="dynamic"){let d=u.arguments;if(d.length===0)return null;let D=d[0];if(!e.ts.isArrowFunction(D))return null;let g=D.body;if(e.ts.isCallExpression(g)){if(g.expression.kind!==e.ts.SyntaxKind.ImportKeyword||g.arguments.length!==1)return null;let l=g.arguments[0];if(!e.ts.isStringLiteral(l))return null;let C=l.text,E=await mt(e,C);n.filePath=E,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(E)?n.importPath=M(e,n.filePath):(n.externalImportPath=C,n.importPath=n.externalImportPath),n.name=le(e,n.filePath),n.importName="default",n.exportName="default",n.exportType="default"}else if(e.ts.isPropertyAccessExpression(g)){let x=g.expression;if(!e.ts.isParenthesizedExpression(x))return null;let l=x.expression;if(!e.ts.isAwaitExpression(l))return null;let C=l.expression;if(!e.ts.isCallExpression(C)||C.expression.kind!==e.ts.SyntaxKind.ImportKeyword||C.arguments.length!==1)return null;let F=C.arguments[0];if(!e.ts.isStringLiteral(F)||!e.ts.isIdentifier(g.name))return null;let A=F.text,S=await mt(e,A);n.filePath=S,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(S)?n.importPath=M(e,n.filePath):(n.externalImportPath=A,n.importPath=n.externalImportPath),n.name=K(g.name.text),n.importName=g.name.text,n.exportName=g.name.text,n.exportType="named"}else return null;return n=se(e,n,r),n.displayFilePath=k(e,n.filePath),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.importPath=M(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}function be(e,t){let r=[...t.statements],n=!1;for(let o=t.statements.length-1;o>=0;o--){let i=t.statements[o];if(e.ts.isImportDeclaration(i)&&i.importClause){let a=!1,s=i.importClause.namedBindings;if(s&&e.ts.isNamedImports(s)&&s.elements){let u=[...s.elements];for(let p=u.length-1;p>=0;p--){let f=u[p];if(e.ts.isImportSpecifier(f)){let m=f.name;if(m&&e.ts.isIdentifier(m)){let c=m.text;jr(e,t,c)||u.splice(p,1)}}}if(u.length===0)a=!0;else if(s.elements.length!==u.length){let p=e.ts.factory.updateImportClause(i.importClause,!1,i.importClause.name,e.ts.factory.createNamedImports(u)),f=e.ts.factory.updateImportDeclaration(i,void 0,p,i.moduleSpecifier,void 0);r[o]=f,n=!0}}else if(i.importClause.name&&e.ts.isIdentifier(i.importClause.name)){let u=i.importClause.name.text;jr(e,t,u)||(a=!0)}a&&(r.splice(o,1),n=!0)}}return n?e.ts.factory.updateSourceFile(t,r):t}function jr(e,t,r){let n=!1;function o(i){if(!e.ts.isImportDeclaration(i)){if(e.ts.isIdentifier(i)&&i.text===r){n=!0;return}e.ts.forEachChild(i,o)}}return e.ts.forEachChild(t,o),n}function Ie(e,t,r,n,o,i,a){let s=null,u=null,p=null,f=-1;t=pe(t),r=pe(r);let m=t.find(d=>d.id===e),c=r.find(d=>d.id===e);if(n)c||(s={...pe(m),inputs:pe(m.inputs).map(d=>(d.isRegistered=!0,d))},f=r.length,r.push(s));else if(typeof c?.nodeIndex=="number"&&c.nodeIndex>-1){if(o)f=c.nodeIndex,u=pe(c),r=r.filter(d=>d.id!==e);else if(i!=null)ja(c,i),f=c.nodeIndex,p=c;else if(a!=null){let d=c.inputs.find(D=>D.name===a.name);d&&(a.registerInput===!1?d.isRegistered=!1:(Va(d,a),d.isRegistered=!0),p=c,f=c.nodeIndex)}}return{addCmpToRegistry:s,removeCmpFromRegistry:u,updateRegisteredCmp:p,nodeIndex:f,components:Ee(t,r)}}function Ee(e,t){let r=ae([...t.map(n=>(n.isRegistered=!0,n)),...e.filter(n=>!t.some(o=>o.id===n.id)).map(n=>(n.isRegistered=!1,n))]);return r.forEach(n=>{n.inputs=n.inputs.map(fn),n.inputs.sort((a,s)=>a.name.toLowerCase().localeCompare(s.name.toLowerCase()));let o=t.find(a=>a.id===n.id);o&&(o.acceptsChildren=mn(n));let i=e.find(a=>a.id===n.id&&a.externalImportPath);i&&(n.filePath=i.filePath,n.relFilePath=i.relFilePath)}),r}function ja(e,t){re(t.name)?e.name=t.name:t.name===null&&(e.name=e.importName),re(t.description)?e.description=t.description:t.description===null&&delete e.description,re(t.image)?e.image=t.image:t.image===null&&delete e.image}function Va(e,t){re(t.type)&&(e.type=t.type),re(t.friendlyName)?e.friendlyName=t.friendlyName:t.friendlyName===null&&delete e.friendlyName,re(t.defaultValue)||ht(t.defaultValue)||rt(t.defaultValue)?e.defaultValue=t.defaultValue:t.defaultValue===null&&delete e.defaultValue,re(t.helperText)?e.helperText=t.helperText:t.helperText===null&&delete e.helperText,t.required===!0?e.required=t.required:(t.required===null||t.required===!1)&&delete e.required}async function qe(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".jsx"||u===".ts"||u===".js"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await Y(e,[...t])}function Re(e,t,r){return ut(e,t,r.variableName)?t:$a(e,t,r)}function $a(e,t,r){let n=typeof r.arrayType=="string"?e.ts.factory.createArrayTypeNode(e.ts.factory.createTypeReferenceNode(r.arrayType,void 0)):void 0,o=e.ts.factory.createArrayLiteralExpression([]),i=e.ts.factory.createVariableDeclaration(r.variableName,void 0,n,o),a=e.ts.factory.createVariableDeclarationList([i],e.ts.NodeFlags.Const),s=e.ts.factory.createModifier(e.ts.SyntaxKind.ExportKeyword),u=e.ts.factory.createVariableStatement([s],a),p=[...t.statements,u];return e.ts.factory.updateSourceFile(t,p)}async function Ne(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m,c]=await Promise.all([Rr(e,u),Lr(e),ne(e),Et(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await ct(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await Y(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await lt(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));ce(B,$);let O=d.findIndex(w=>w.id===S.cmpInfo.id);d[O].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:H,variableDeclaration:_}=await Ua(e,l,S);if(P.addCmpToRegistry)w.push(Ma(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[$r(e,P.updateRegisteredCmp),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(H,H.modifiers,e.ts.factory.updateVariableDeclarationList(H.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=Vr(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(He=>He.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(Sr(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=dn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=_r(e,l,m),l=Vr(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l),e.appDir&&(l=Or(e,l));let E=j(e,l);E=De(E),e.appDir&&(E=kr(E)),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}function $r(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.appDir?e.ts.factory.createPropertyAssignment("component",r):e.ts.factory.createPropertyAssignment("component",za(e,t))}function Ka(e){return e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())}function Ma(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([$r(e,t),...t.acceptsChildren?[Ka(e)]:[]],!0),t)}async function Ua(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await En(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function Vr(e,t,r){if(e.appDir){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}}else r=I(e,r,{defaultImport:"dynamic",importPath:"next/dynamic"});return r}function za(e,t){let r=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath),n=t.exportName!=="default",o;n?o=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createAwaitExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)])),e.ts.factory.createIdentifier(t.exportName)):o=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)]);let i=e.ts.factory.createArrowFunction(n?[e.ts.factory.createModifier(e.ts.SyntaxKind.AsyncKeyword)]:void 0,void 0,[],void 0,e.ts.factory.createToken(e.ts.SyntaxKind.EqualsGreaterThanToken),o);return e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("dynamic"),void 0,[i])}async function Mr(e){let t=[],r=await Ha(e,t);return await Wr(e,t,r),e.appDir?(e.debug(`ensure builder setup for next.js app ${e.appDir}`),await Ja(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure builder setup for next.js pages ${e.pagesDir}`),await Wa(e,e.pagesDir,t)),t}async function Ur(e){let t=[];return await Wr(e,t),e.appDir?(e.debug(`ensure figma-imports setup for next.js app ${e.appDir}`),await qa(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure figma-imports setup for next.js pages ${e.pagesDir}`),await Qa(e,e.pagesDir,t)),t}async function qa(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"figma-imports",n);if(!await e.exists(o)){let i=await e.formatCode(o,qr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,zr(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}async function Ja(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"[...page]",n);if(!await e.exists(o)){let i=await e.formatCode(o,qr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,zr(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}function zr(e){let t=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
33
33
  "use client";
34
34
  import { ${t?"BuilderContent, ":""} isPreviewing, Content } from "@builder.io/sdk-react";
35
35
  import DefaultErrorPage from "next/error";
@@ -88,7 +88,7 @@ export function RenderBuilderContent({ content, model }${t?": BuilderPageProps":
88
88
  // DefaultErrorPage with a 404.
89
89
  return <DefaultErrorPage statusCode={404} />;
90
90
  }
91
- `.trimStart()}function $r(e){return e.features.asyncParams?`
91
+ `.trimStart()}function Kr(e){return e.features.asyncParams?`
92
92
  interface PageProps {
93
93
  params: Promise<{
94
94
  page: string[];
@@ -98,14 +98,14 @@ interface PageProps {
98
98
  params: {
99
99
  page: string[];
100
100
  };
101
- }`}function zr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.builderComponentPath);return e.sdkVersion===y.gen2?`
101
+ }`}function qr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.builderComponentPath);return e.sdkVersion===y.gen2?`
102
102
  import { fetchOneEntry } from "@builder.io/sdk-react";
103
103
  import { RenderBuilderContent } from ${JSON.stringify(o)};
104
104
 
105
105
  // Builder Public API Key set in .env file
106
106
  const PUBLIC_API_KEY = process.env.${ye}${n?"!":""};
107
107
 
108
- ${n?$r(e):""}
108
+ ${n?Kr(e):""}
109
109
 
110
110
  export default async function Page(props${n?": PageProps":""}) {
111
111
  const builderModelName = "${r}";
@@ -133,7 +133,7 @@ import { RenderBuilderContent } from ${JSON.stringify(o)};
133
133
 
134
134
  // Builder Public API Key set in .env file
135
135
  builder.init(process.env.${ye}${n?"!":""});
136
- ${n?$r(e):""}
136
+ ${n?Kr(e):""}
137
137
 
138
138
  export default async function Page(props${n?": PageProps":""}) {
139
139
  const builderModelName = "${r}";
@@ -156,7 +156,7 @@ export default async function Page(props${n?": PageProps":""}) {
156
156
  </>
157
157
  );
158
158
  }
159
- `.trimStart()}async function Wa(e,t,r){let n=`[...page].${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,qr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}async function Qa(e,t,r){let n=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,qr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}function qr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
159
+ `.trimStart()}async function Wa(e,t,r){let n=`[...page].${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,Jr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}async function Qa(e,t,r){let n=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,Jr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}function Jr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
160
160
  import React from "react";
161
161
  import { useRouter } from "next/router";
162
162
  ${n?'import type { BuilderContent } from "@builder.io/sdk-react";':""}
@@ -383,18 +383,18 @@ export default Counter;
383
383
  font-size: 42px;
384
384
  text-align: center;
385
385
  }
386
- `.trimStart();return{component:r,styles:n}}async function Jr(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=Ga(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await Ne(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await Ne(e,o.id,!0,!1,null,null,!0,!1)}function Ga(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
386
+ `.trimStart();return{component:r,styles:n}}async function Wr(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=Ga(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await Ne(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await Ne(e,o.id,!0,!1,null,null,!0,!1)}function Ga(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
387
387
 
388
388
  export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
389
389
  ];`:`export const CUSTOM_COMPONENTS = [
390
390
  ];
391
- `}async function ft(e){let t=await xt(e,e.getRepoRootDir());if(t&&typeof t=="object"){let r=new Set(Object.keys({...t.dependencies,...t.devDependencies}));if(r.has("@builder.io/sdk-react"))return y.gen2;if(r.has("@builder.io/react"))return y.gen1}return null}async function Wr(e){let t=await Xa(e);return{builderPageOptions:async()=>({templateContentId:"3de2f13211234071a4b19a17b4fbc5a7",pathname:"/builder-demo",title:"Builder + Next.js Demo Page"}),ensureBuilderSetup:()=>Kr(t),ensureFigmaImportPage:()=>Mr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Ne(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Ne(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Ne(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Ne(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Ne(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Ne(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Et(t),setPublicApiKey:n=>dr(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Xa(e){let t=e.getAppRootDir(),r=e.join(t,"src"),n=await Za(e),o=await ne(e),i=e.getFrameworks().find(p=>p.name==="next"),a={asyncParams:i?.version?.major!==void 0&&i.version.major>=15},s={},u={...e,addExternalPackage:p=>{s[e.join(t,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>s[p]??e.readFileSync(p),existsSync:p=>!!s[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},appDir:null,pagesDir:null,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",nextConfigPath:n,typescriptEnabled:o,features:a};if(e.sdkVersion?u.sdkVersion=e.sdkVersion:u.sdkVersion=await ft(u),await e.exists(r)){u.srcDir=r,u.componentsDir=e.join(r,"components");let p=e.join(r,"app");await e.exists(p)&&(u.appDir=p);let f=e.join(r,"pages");await e.exists(f)&&(u.pagesDir=f),u.registryPath=await ie(e,r)}else u.componentsDir=e.join(t,"components"),u.registryPath=await ie(e,t);if(u.builderComponentPath=e.join(u.componentsDir,`builder.${o?"tsx":"jsx"}`),!u.appDir){let p=e.join(t,"app");await e.exists(p)&&(u.appDir=p)}if(!u.pagesDir){let p=e.join(t,"pages");await e.exists(p)&&(u.pagesDir=p)}if(!u.appDir&&!u.pagesDir&&!e.ignoreMissingConfig)throw new Error(`Could not find Next.js "app" or "pages" directory. Searched in "${t}".`);return u}async function Za(e){let t=e.join(e.getAppRootDir(),"next.config.ts");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"next.config.mjs");if(await e.exists(r))return r;let n=e.join(e.getAppRootDir(),"next.config.js");if(await e.exists(n))return n;throw new Error(`Could not find Next.js config file. Searched for "next.config.ts", "next.config.mjs" and "next.config.js" in "${e.getAppRootDir()}".`)}async function yt(e){return await Fe(e,[".env"],Hr)}async function Qr(e,t){es(t);let r=await yt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}function es(e){typeof process<"u"&&(process.env[Hr]=e)}var Hr="PUBLIC_BUILDER_API_KEY";function Yr(e,t,r){if(r.length===0)return e;let n=e.split(`
391
+ `}async function ft(e){let t=await xt(e,e.getRepoRootDir());if(t&&typeof t=="object"){let r=new Set(Object.keys({...t.dependencies,...t.devDependencies}));if(r.has("@builder.io/sdk-react"))return y.gen2;if(r.has("@builder.io/react"))return y.gen1}return null}async function Qr(e){let t=await Xa(e);return{builderPageOptions:async()=>({templateContentId:"3de2f13211234071a4b19a17b4fbc5a7",pathname:"/builder-demo",title:"Builder + Next.js Demo Page"}),ensureBuilderSetup:()=>Mr(t),ensureFigmaImportPage:()=>Ur(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Ne(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Ne(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Ne(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Ne(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Ne(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Ne(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Et(t),setPublicApiKey:n=>gr(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Xa(e){let t=e.getAppRootDir(),r=e.join(t,"src"),n=await Za(e),o=await ne(e),i=e.getFrameworks().find(p=>p.name==="next"),a={asyncParams:i?.version?.major!==void 0&&i.version.major>=15},s={},u={...e,addExternalPackage:p=>{s[e.join(t,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>s[p]??e.readFileSync(p),existsSync:p=>!!s[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},appDir:null,pagesDir:null,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",nextConfigPath:n,typescriptEnabled:o,features:a};if(e.sdkVersion?u.sdkVersion=e.sdkVersion:u.sdkVersion=await ft(u),await e.exists(r)){u.srcDir=r,u.componentsDir=e.join(r,"components");let p=e.join(r,"app");await e.exists(p)&&(u.appDir=p);let f=e.join(r,"pages");await e.exists(f)&&(u.pagesDir=f),u.registryPath=await ie(e,r)}else u.componentsDir=e.join(t,"components"),u.registryPath=await ie(e,t);if(u.builderComponentPath=e.join(u.componentsDir,`builder.${o?"tsx":"jsx"}`),!u.appDir){let p=e.join(t,"app");await e.exists(p)&&(u.appDir=p)}if(!u.pagesDir){let p=e.join(t,"pages");await e.exists(p)&&(u.pagesDir=p)}if(!u.appDir&&!u.pagesDir&&!e.ignoreMissingConfig)throw new Error(`Could not find Next.js "app" or "pages" directory. Searched in "${t}".`);return u}async function Za(e){let t=e.join(e.getAppRootDir(),"next.config.ts");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"next.config.mjs");if(await e.exists(r))return r;let n=e.join(e.getAppRootDir(),"next.config.js");if(await e.exists(n))return n;throw new Error(`Could not find Next.js config file. Searched for "next.config.ts", "next.config.mjs" and "next.config.js" in "${e.getAppRootDir()}".`)}async function yt(e){return await Fe(e,[".env"],Yr)}async function Hr(e,t){es(t);let r=await yt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}function es(e){typeof process<"u"&&(process.env[Yr]=e)}var Yr="PUBLIC_BUILDER_API_KEY";function Gr(e,t,r){if(r.length===0)return e;let n=e.split(`
392
392
  `),o=n.findIndex(s=>s.includes(r));if(o===-1||n.some(s=>s.includes(t[0])))return e;let a=["/**",...t.map(s=>` * ${s.trim()}`)," */"];return n.splice(o,0,...a),n.join(`
393
- `)}async function Xr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(a.startsWith(".")||rs.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await Ut(e,o,s,i);r.push(...u)})),r}async function Zr(e,t){if(e.extname(t).toLowerCase()===".tsx"){let n=await e.readFile(t);if(n)return ts(e,t,n)}return null}function ts(e,t,r){let n=b(e,r);return Ut(e,null,t,n)}async function Ut(e,t,r,n){r=e.normalize(r);let o=[],i=de(e,n);return await Promise.all(i.map(async a=>{let s=await ns(e,t,r,a);s&&o.push(s)})),o}async function ns(e,t,r,n){let o=e.relative(e.getAppRootDir(),r),i=M(e,r);if(e.ts.isVariableStatement(n.node))for(let a of n.node.declarationList.declarations){let s=Gr(e,a.initializer);if(s&&e.ts.isIdentifier(a.name)){let u=a.name.text;return{cmpInfo:{id:await V(e,r,u),displayFilePath:O(e,r),name:K(u),inputs:[],exportName:n.isDefaultExport?"default":u,exportType:n.isDefaultExport?"default":"named",importName:u,filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:s}}}else if(e.ts.isCallExpression(n.node)){let a=Gr(e,n.node);if(a)return{cmpInfo:{id:await V(e,r,"default"),displayFilePath:O(e,r),name:le(e,r),inputs:[],exportName:"default",exportType:"default",importName:Ye(e,r),filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:a}}return null}function Gr(e,t){if(t&&e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)&&t.expression.text==="component$"&&t.arguments.length>0){let r=t.arguments[0];if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))return{callExpression:t,fnNode:r}}return null}var rs=new Set(["node_modules","layout.tsx","404.tsx","router-head.tsx"]);async function eo(e,t){let r=t.node.fnNode;if((e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))&&r.parameters.length>0){let{sourceFile:o,typeChecker:i}=await st(e,t.cmpInfo.filePath,null);if(!(await Ut(e,i,t.cmpInfo.filePath,o)).find(u=>u.cmpInfo.id===t.cmpInfo.id))throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,r)}return[]}async function to(e){return Sn(e)}async function Sn(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,os),t.push({filePath:e.registryPath,modifiedType:"create"})),t}var os=`import type { RegisteredComponent } from "@builder.io/sdk-qwik";
393
+ `)}async function Zr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(a.startsWith(".")||rs.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await Ut(e,o,s,i);r.push(...u)})),r}async function eo(e,t){if(e.extname(t).toLowerCase()===".tsx"){let n=await e.readFile(t);if(n)return ts(e,t,n)}return null}function ts(e,t,r){let n=b(e,r);return Ut(e,null,t,n)}async function Ut(e,t,r,n){r=e.normalize(r);let o=[],i=de(e,n);return await Promise.all(i.map(async a=>{let s=await ns(e,t,r,a);s&&o.push(s)})),o}async function ns(e,t,r,n){let o=e.relative(e.getAppRootDir(),r),i=M(e,r);if(e.ts.isVariableStatement(n.node))for(let a of n.node.declarationList.declarations){let s=Xr(e,a.initializer);if(s&&e.ts.isIdentifier(a.name)){let u=a.name.text;return{cmpInfo:{id:await V(e,r,u),displayFilePath:k(e,r),name:K(u),inputs:[],exportName:n.isDefaultExport?"default":u,exportType:n.isDefaultExport?"default":"named",importName:u,filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:s}}}else if(e.ts.isCallExpression(n.node)){let a=Xr(e,n.node);if(a)return{cmpInfo:{id:await V(e,r,"default"),displayFilePath:k(e,r),name:le(e,r),inputs:[],exportName:"default",exportType:"default",importName:Ye(e,r),filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:a}}return null}function Xr(e,t){if(t&&e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)&&t.expression.text==="component$"&&t.arguments.length>0){let r=t.arguments[0];if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))return{callExpression:t,fnNode:r}}return null}var rs=new Set(["node_modules","layout.tsx","404.tsx","router-head.tsx"]);async function to(e,t){let r=t.node.fnNode;if((e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))&&r.parameters.length>0){let{sourceFile:o,typeChecker:i}=await st(e,t.cmpInfo.filePath,null);if(!(await Ut(e,i,t.cmpInfo.filePath,o)).find(u=>u.cmpInfo.id===t.cmpInfo.id))throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,r)}return[]}async function no(e){return Sn(e)}async function Sn(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,os),t.push({filePath:e.registryPath,modifiedType:"create"})),t}var os=`import type { RegisteredComponent } from "@builder.io/sdk-qwik";
394
394
 
395
395
  export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
396
396
  ];
397
- `;async function no(e){await Sn(e);let t=await e.readFile(e.registryPath);return t?is(e,t):{components:[],sourceFile:b(e,"")}}async function is(e,t){let r=b(e,t);return as(e,r)}async function as(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await An(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function An(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"qwik"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"&&e.ts.isIdentifier(o.initializer)){let a=o.initializer.text;n.name===""&&(n.name=K(a)),n.importName=a;let s=await we(e,e.registryPath,t,a);if(!s)continue;n.filePath=s.filePath,n.relFilePath=s.relFilePath,n.importPath=M(e,s.filePath),n.displayFilePath=s.displayFilePath,n.exportType=s.exportType;let u=await Zr(e,s.filePath);if(u&&u.length>0)if(u.length===1)n.exportName=u[0].cmpInfo.exportName;else{let p=u.find(f=>f.cmpInfo.exportName===a);p&&(n.exportName=p.cmpInfo.exportName)}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName)),n}async function ro(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".ts"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await Y(e,[...t])}async function Xe(e,t,r,n,o,i,a,s){let u=await ro(e),[p,f,m]=await Promise.all([Xr(e,u),no(e),yt(e)]),c=p.map(g=>g.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D;if(t!=null){let g=p.find(P=>P.cmpInfo.id===t);if(!g)throw new Error(`Component ${t} not found`);let x=f.sourceFile,l=D.components.find(P=>P.id===t),C=await eo(e,g);pe(l,C),t=Array.isArray(t)?t[0]:t;let E=Ie(t,c,d,r,n,o,i),{elements:F,elmIndex:A,statementIndex:S,statement:B,variableDeclaration:$}=await us(e,x,g),k=!1;if(E.addCmpToRegistry?(F.push(ss(e,E.addCmpToRegistry)),k=!0):E.removeCmpFromRegistry?(F.splice(A,1),k=!0):E.updateRegisteredCmp&&(F[A]=W(e,F[A],E.updateRegisteredCmp),k=!0),k&&a){let P=[...x.statements];P[S]=e.ts.factory.updateVariableStatement(B,B.modifiers,e.ts.factory.updateVariableDeclarationList(B.declarationList,[e.ts.factory.updateVariableDeclaration($,$.name,$.exclamationToken,$.type,e.ts.factory.createArrayLiteralExpression(Te(e,F)))])),x=e.ts.factory.updateSourceFile(x,P),l.exportType==="named"?x=I(e,x,{namedImports:[l.importName],importPath:N(e,e.registryPath,l.filePath)}):x=I(e,x,{defaultImport:l.importName,importPath:N(e,e.registryPath,l.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-qwik",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),x=be(e,x),x=ve(e,x);let w=j(e,x);w=De(w),w=Yr(w,ps,"CUSTOM_COMPONENTS"),w=await e.formatCode(e.registryPath,w),await e.writeFile(e.registryPath,w)}D.components=E.components}return D}function ss(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName))],!0),t)}async function us(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await An(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}var ps=["This array is used to integrate custom components within Builder.","https://www.builder.io/c/docs/custom-components-intro","",'These components will be found the "Custom Components"',"section of Builder's visual editor.",'You can also turn on "components only mode" to limit',"editing to only these components.","https://www.builder.io/c/docs/guides/components-only-mode"];async function oo(e){let t=await cs(e);return{builderPageOptions:async()=>({templateContentId:"dc70f1d979ad416d8fd357137eb9ddfb",pathname:"/",title:"Builder + Qwik Demo Page"}),ensureBuilderSetup:()=>to(t),ensureFigmaImportPage:async()=>[],getRegistryPath:()=>t.registryPath,getRegistry:n=>Xe(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{},loadComponent:async n=>{let o=await Xe(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Xe(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Xe(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Xe(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Xe(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>yt(t),setPublicApiKey:n=>Qr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-qwik"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function cs(e){let t=await Ct(e,e.getAppRootDir(),"components");if(!t)throw new Error(`Could not find components directory within project: ${e.getAppRootDir()}`);let r=await ie(e,t),n=e.join(e.getAppRootDir(),".env");return{...e,componentsDir:t,registryPath:r,envPath:n}}async function wt(e){return await Fe(e,[".env"],vt)}async function io(e,t){let r=await wt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var vt="PUBLIC_BUILDER_KEY";var ls=new Set(["dist","node_modules"]);async function ao(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker(),i=e.join(e.getAppRootDir(),"build");return await Promise.all(n.map(async a=>{let s=e.basename(a.fileName);if(s.startsWith(".")||s==="node_modules"||jt(e,ls,a.fileName)||ms.has(s)||s.includes("$."))return;let u=e.normalize(a.fileName);if(u===e.remixConfigPath||u===i)return;let p=await ze(e,o,u,a,u===e.registryPath);r.push(...p)})),r}var ms=new Set(["root.tsx","root.ts","root.jsx","root.js","_index.tsx","_index.jsx","_index.ts","_index.js"]);async function so(e){await zt(e);let t=await e.readFile(e.registryPath);return t?fs(e,t):{components:[],sourceFile:b(e,"")}}async function fs(e,t){let r=b(e,t);return ds(e,r)}async function ds(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Fn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Fn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};e.sdkVersion===y.gen2&&at(e,r)&&(n.acceptsChildren=!0);for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){(e.ts.isIdentifier(s.expression)&&s.expression.text)==="withChildren"&&(n.acceptsChildren=!0);let f=s.arguments[0];e.ts.isIdentifier(f)&&(a=f.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await vr(e,u.filePath,e.registryPath===u.filePath||Ae(u.filePath));if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Be(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m]=await Promise.all([ao(e,u),so(e),wt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await ct(e,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await Y(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await lt(e,A,F,e.registryPath===A.cmpInfo.filePath||Ae(A.cmpInfo.filePath));pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:H}=await Ds(e,x,A);if(k.addCmpToRegistry)P.push(gs(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[uo(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(H,H.name,H.exclamationToken,H.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)});let te=e.sdkVersion===y.gen2?"@builder.io/sdk-react":"@builder.io/react";x=I(e,x,{namedImports:["RegisteredComponent"],importPath:te,isTypeOnly:!0}),S.acceptsChildren&&e.sdkVersion!==y.gen2&&(x=I(e,x,{namedImports:["withChildren"],importPath:"@builder.io/react"})),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(He=>He.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function uo(e,t){if(e.sdkVersion===y.gen2)return e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName));let r=e.ts.factory.createIdentifier(t.importName),n=t.acceptsChildren?e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[r]):r;return e.ts.factory.createPropertyAssignment("component",n)}function gs(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([uo(e,t),...t.acceptsChildren&&e.sdkVersion===y.gen2?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}async function Ds(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await Fn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function po(e){let t=[],r=await hs(e,t);return t.push(...await zt(e)),await Ss(e,r),await Cs(e,t),t}async function co(e){let t=[];return t.push(...await zt(e)),await xs(e,t),t}async function xs(e,t){let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureFigmaImportRoute, hasLocaleParam"),r=`($locale).${r}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureFigmaImportRoute, hasRoute: ${o}`);let i=await e.formatCode(n,lo({sys:e,routePath:n,modelName:"figma-imports"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}async function Cs(e,t){let r=`$.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureAppRoute, hasLocaleParam"),r=`($locale).${r}`),e.sdkVersion===y.gen2&&(r=`($slug)._index.${e.typescriptEnabled?"tsx":"jsx"}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureAppRoute, hasRoute: ${o}`);let i=await e.formatCode(n,lo({sys:e,routePath:n,modelName:"page"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}function lo({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.registryPath),i="",a="";n&&(i="import type { LoaderArgs } from '@remix-run/server-runtime';",a=": LoaderArgs");let s=`process.env.${vt}`,u="";return e.getFrameworks().some(p=>p.name==="@shopify/remix-oxygen")&&(s=`context.env.${vt}`,u=", context"),n&&(s+="!"),e.sdkVersion===y.gen2?`
397
+ `;async function ro(e){await Sn(e);let t=await e.readFile(e.registryPath);return t?is(e,t):{components:[],sourceFile:b(e,"")}}async function is(e,t){let r=b(e,t);return as(e,r)}async function as(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await An(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function An(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"qwik"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"&&e.ts.isIdentifier(o.initializer)){let a=o.initializer.text;n.name===""&&(n.name=K(a)),n.importName=a;let s=await we(e,e.registryPath,t,a);if(!s)continue;n.filePath=s.filePath,n.relFilePath=s.relFilePath,n.importPath=M(e,s.filePath),n.displayFilePath=s.displayFilePath,n.exportType=s.exportType;let u=await eo(e,s.filePath);if(u&&u.length>0)if(u.length===1)n.exportName=u[0].cmpInfo.exportName;else{let p=u.find(f=>f.cmpInfo.exportName===a);p&&(n.exportName=p.cmpInfo.exportName)}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName)),n}async function oo(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".ts"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await Y(e,[...t])}async function Xe(e,t,r,n,o,i,a,s){let u=await oo(e),[p,f,m]=await Promise.all([Zr(e,u),ro(e),yt(e)]),c=p.map(g=>g.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D;if(t!=null){let g=p.find(P=>P.cmpInfo.id===t);if(!g)throw new Error(`Component ${t} not found`);let x=f.sourceFile,l=D.components.find(P=>P.id===t),C=await to(e,g);ce(l,C),t=Array.isArray(t)?t[0]:t;let E=Ie(t,c,d,r,n,o,i),{elements:F,elmIndex:A,statementIndex:S,statement:B,variableDeclaration:$}=await us(e,x,g),O=!1;if(E.addCmpToRegistry?(F.push(ss(e,E.addCmpToRegistry)),O=!0):E.removeCmpFromRegistry?(F.splice(A,1),O=!0):E.updateRegisteredCmp&&(F[A]=W(e,F[A],E.updateRegisteredCmp),O=!0),O&&a){let P=[...x.statements];P[S]=e.ts.factory.updateVariableStatement(B,B.modifiers,e.ts.factory.updateVariableDeclarationList(B.declarationList,[e.ts.factory.updateVariableDeclaration($,$.name,$.exclamationToken,$.type,e.ts.factory.createArrayLiteralExpression(Te(e,F)))])),x=e.ts.factory.updateSourceFile(x,P),l.exportType==="named"?x=I(e,x,{namedImports:[l.importName],importPath:N(e,e.registryPath,l.filePath)}):x=I(e,x,{defaultImport:l.importName,importPath:N(e,e.registryPath,l.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-qwik",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),x=be(e,x),x=ve(e,x);let w=j(e,x);w=De(w),w=Gr(w,ps,"CUSTOM_COMPONENTS"),w=await e.formatCode(e.registryPath,w),await e.writeFile(e.registryPath,w)}D.components=E.components}return D}function ss(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName))],!0),t)}async function us(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await An(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}var ps=["This array is used to integrate custom components within Builder.","https://www.builder.io/c/docs/custom-components-intro","",'These components will be found the "Custom Components"',"section of Builder's visual editor.",'You can also turn on "components only mode" to limit',"editing to only these components.","https://www.builder.io/c/docs/guides/components-only-mode"];async function io(e){let t=await cs(e);return{builderPageOptions:async()=>({templateContentId:"dc70f1d979ad416d8fd357137eb9ddfb",pathname:"/",title:"Builder + Qwik Demo Page"}),ensureBuilderSetup:()=>no(t),ensureFigmaImportPage:async()=>[],getRegistryPath:()=>t.registryPath,getRegistry:n=>Xe(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{},loadComponent:async n=>{let o=await Xe(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Xe(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Xe(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Xe(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Xe(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>yt(t),setPublicApiKey:n=>Hr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-qwik"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function cs(e){let t=await Ct(e,e.getAppRootDir(),"components");if(!t)throw new Error(`Could not find components directory within project: ${e.getAppRootDir()}`);let r=await ie(e,t),n=e.join(e.getAppRootDir(),".env");return{...e,componentsDir:t,registryPath:r,envPath:n}}async function wt(e){return await Fe(e,[".env"],vt)}async function ao(e,t){let r=await wt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var vt="PUBLIC_BUILDER_KEY";var ls=new Set(["dist","node_modules"]);async function so(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker(),i=e.join(e.getAppRootDir(),"build");return await Promise.all(n.map(async a=>{let s=e.basename(a.fileName);if(s.startsWith(".")||s==="node_modules"||jt(e,ls,a.fileName)||ms.has(s)||s.includes("$."))return;let u=e.normalize(a.fileName);if(u===e.remixConfigPath||u===i)return;let p=await ze(e,o,u,a,u===e.registryPath);r.push(...p)})),r}var ms=new Set(["root.tsx","root.ts","root.jsx","root.js","_index.tsx","_index.jsx","_index.ts","_index.js"]);async function uo(e){await zt(e);let t=await e.readFile(e.registryPath);return t?fs(e,t):{components:[],sourceFile:b(e,"")}}async function fs(e,t){let r=b(e,t);return ds(e,r)}async function ds(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Fn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Fn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};e.sdkVersion===y.gen2&&at(e,r)&&(n.acceptsChildren=!0);for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){(e.ts.isIdentifier(s.expression)&&s.expression.text)==="withChildren"&&(n.acceptsChildren=!0);let f=s.arguments[0];e.ts.isIdentifier(f)&&(a=f.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await Tr(e,u.filePath,e.registryPath===u.filePath||Ae(u.filePath));if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Be(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m]=await Promise.all([so(e,u),uo(e),wt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await ct(e,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await Y(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await lt(e,A,F,e.registryPath===A.cmpInfo.filePath||Ae(A.cmpInfo.filePath));ce(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let O=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:H}=await Ds(e,x,A);if(O.addCmpToRegistry)P.push(gs(e,O.addCmpToRegistry)),g=!0;else if(O.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(O.updateRegisteredCmp){let _=W(e,P[w],O.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[po(e,O.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(H,H.name,H.exclamationToken,H.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)});let te=e.sdkVersion===y.gen2?"@builder.io/sdk-react":"@builder.io/react";x=I(e,x,{namedImports:["RegisteredComponent"],importPath:te,isTypeOnly:!0}),S.acceptsChildren&&e.sdkVersion!==y.gen2&&(x=I(e,x,{namedImports:["withChildren"],importPath:"@builder.io/react"})),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=O.components,d=O.components.filter(He=>He.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function po(e,t){if(e.sdkVersion===y.gen2)return e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName));let r=e.ts.factory.createIdentifier(t.importName),n=t.acceptsChildren?e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[r]):r;return e.ts.factory.createPropertyAssignment("component",n)}function gs(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([po(e,t),...t.acceptsChildren&&e.sdkVersion===y.gen2?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}async function Ds(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await Fn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function co(e){let t=[],r=await hs(e,t);return t.push(...await zt(e)),await Ss(e,r),await Cs(e,t),t}async function lo(e){let t=[];return t.push(...await zt(e)),await xs(e,t),t}async function xs(e,t){let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureFigmaImportRoute, hasLocaleParam"),r=`($locale).${r}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureFigmaImportRoute, hasRoute: ${o}`);let i=await e.formatCode(n,mo({sys:e,routePath:n,modelName:"figma-imports"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}async function Cs(e,t){let r=`$.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureAppRoute, hasLocaleParam"),r=`($locale).${r}`),e.sdkVersion===y.gen2&&(r=`($slug)._index.${e.typescriptEnabled?"tsx":"jsx"}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureAppRoute, hasRoute: ${o}`);let i=await e.formatCode(n,mo({sys:e,routePath:n,modelName:"page"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}function mo({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.registryPath),i="",a="";n&&(i="import type { LoaderArgs } from '@remix-run/server-runtime';",a=": LoaderArgs");let s=`process.env.${vt}`,u="";return e.getFrameworks().some(p=>p.name==="@shopify/remix-oxygen")&&(s=`context.env.${vt}`,u=", context"),n&&(s+="!"),e.sdkVersion===y.gen2?`
398
398
 
399
399
  import {
400
400
  Content,
@@ -572,12 +572,12 @@ export default Counter;
572
572
  export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
573
573
  ];`:`export const CUSTOM_COMPONENTS = [
574
574
  ];
575
- `}async function mo(e){let t=await Fs(e);return{builderPageOptions:async()=>{let n="/builder-demo",o=t.hasLocaleParam?`/en-us${n}`:void 0;return{templateContentId:"a5c9eef7909d4fc99554264a17de22c9",pathname:n,localePathname:o,title:"Builder + Remix Demo Page"}},ensureBuilderSetup:()=>po(t),ensureFigmaImportPage:()=>co(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Be(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Be(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Be(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Be(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Be(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Be(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>wt(t),setPublicApiKey:n=>io(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Fs(e){let t=await ys(e),r=e.getAppRootDir(),n=await ws(e),o=e.dirname(n),i=e.join(o,"components"),a=await ne(e),s=await ie(e,o),u={},p={...e,registryPath:s,remixConfigPath:t,typescriptEnabled:a,appDir:o,componentsDir:i,routesDir:n,hasLocaleParam:await Ps(e,n),addExternalPackage:f=>{u[e.join(r,f,"index.ts")]=`export * from "${f}";`},readFileSync:f=>u[f]??e.readFileSync(f),existsSync:f=>!!u[f]||e.existsSync(f),readdirSync:f=>{let m=e.readdirSync(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m},readdir:async f=>{let m=await e.readdir(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m}};return e.sdkVersion?p.sdkVersion=e.sdkVersion:p.sdkVersion=await ft(p),p}async function Ps(e,t){return(await e.readdir(t)).some(n=>n.startsWith("($locale)."))}async function ys(e){let t=["remix.config.ts","remix.config.js","vite.config.ts","vite.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Remix config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function ws(e){let t=await Ct(e,e.getAppRootDir(),"routes");if(t)return t;throw new Error(`Could not find Remix "routes" directory in "${e.getAppRootDir()}". Please ensure this command is ran from within your Remix project's directory.`)}async function Tt(e){let t=[".env"],r=e.configType==="vite"?bt:qt;return await Fe(e,t,r)}async function fo(e,t){let r=await Tt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var bt="VITE_PUBLIC_BUILDER_KEY",qt="PUBLIC_BUILDER_KEY";function go(e,t){let r=`Builder.registerComponent(
575
+ `}async function fo(e){let t=await Fs(e);return{builderPageOptions:async()=>{let n="/builder-demo",o=t.hasLocaleParam?`/en-us${n}`:void 0;return{templateContentId:"a5c9eef7909d4fc99554264a17de22c9",pathname:n,localePathname:o,title:"Builder + Remix Demo Page"}},ensureBuilderSetup:()=>co(t),ensureFigmaImportPage:()=>lo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Be(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Be(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Be(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Be(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Be(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Be(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>wt(t),setPublicApiKey:n=>ao(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Fs(e){let t=await ys(e),r=e.getAppRootDir(),n=await ws(e),o=e.dirname(n),i=e.join(o,"components"),a=await ne(e),s=await ie(e,o),u={},p={...e,registryPath:s,remixConfigPath:t,typescriptEnabled:a,appDir:o,componentsDir:i,routesDir:n,hasLocaleParam:await Ps(e,n),addExternalPackage:f=>{u[e.join(r,f,"index.ts")]=`export * from "${f}";`},readFileSync:f=>u[f]??e.readFileSync(f),existsSync:f=>!!u[f]||e.existsSync(f),readdirSync:f=>{let m=e.readdirSync(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m},readdir:async f=>{let m=await e.readdir(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m}};return e.sdkVersion?p.sdkVersion=e.sdkVersion:p.sdkVersion=await ft(p),p}async function Ps(e,t){return(await e.readdir(t)).some(n=>n.startsWith("($locale)."))}async function ys(e){let t=["remix.config.ts","remix.config.js","vite.config.ts","vite.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Remix config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function ws(e){let t=await Ct(e,e.getAppRootDir(),"routes");if(t)return t;throw new Error(`Could not find Remix "routes" directory in "${e.getAppRootDir()}". Please ensure this command is ran from within your Remix project's directory.`)}async function Tt(e){let t=[".env"],r=e.configType==="vite"?bt:qt;return await Fe(e,t,r)}async function go(e,t){let r=await Tt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var bt="VITE_PUBLIC_BUILDER_KEY",qt="PUBLIC_BUILDER_KEY";function Do(e,t){let r=`Builder.registerComponent(
576
576
  `;r+=` ${t.importName},
577
577
  `,r+=` {
578
578
  name: "${t.name}",
579
579
  }
580
- `,r+=");";let n=Vt(e,r);return Pn(e,n,t)}function Pn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function Do(e){let t=await e.readFile(e.registryPath);return t?vs(e,t):{components:[],sourceFile:b(e,"")}}async function vs(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?Is(e,r):Ts(e,r)}async function Ts(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isIdentifier(m)){let c=await bs(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}async function bs(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;a.filePath=await yn(e,p.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),a.importPath=M(e,a.filePath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await yn(e,f.text);a.filePath=await yn(e,f.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=O(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function yn(e,t){return Pt(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}async function Is(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await wn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function wn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};at(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Oe(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m,c]=await Promise.all([Tr(e,u),Do(e),ne(e),Tt(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await ct(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await Y(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await lt(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));pe(B,$);let k=d.findIndex(w=>w.id===S.cmpInfo.id);d[k].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:H,variableDeclaration:_}=await Rs(e,l,S);if(P.addCmpToRegistry)w.push(Ns(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp),He=e.ts.factory.createIdentifier(P.updateRegisteredCmp.importName);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[e.ts.factory.createPropertyAssignment("component",He),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(H,H.modifiers,e.ts.factory.updateVariableDeclarationList(H.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=xo(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(He=>He.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(go(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=Pn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=xo(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l);let E=j(e,l);E=De(E),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}async function Rs(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await wn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function Ns(e,t){let r=e.ts.factory.createIdentifier(t.importName);return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",r),...t.acceptsChildren?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}function xo(e,t,r){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}return r}async function Co(e){let t=[],r=await Bs(e,t);if(await So(e,t,r),!await e.exists(e.builderComponentPath)){let n=await e.formatCode(e.builderComponentPath,Eo(e,e.builderComponentPath));await e.writeFile(e.builderComponentPath,n),t.push({filePath:e.builderComponentPath,modifiedType:"create"})}return t}async function ho(e){let t=[];await So(e,t);let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,n=e.join(e.componentsDir,r);if(!await e.exists(n)){let o=await e.formatCode(n,Eo(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}function Eo(e,t,r="page"){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
580
+ `,r+=");";let n=Vt(e,r);return Pn(e,n,t)}function Pn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function xo(e){let t=await e.readFile(e.registryPath);return t?vs(e,t):{components:[],sourceFile:b(e,"")}}async function vs(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?Is(e,r):Ts(e,r)}async function Ts(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isIdentifier(m)){let c=await bs(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}async function bs(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;a.filePath=await yn(e,p.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),a.importPath=M(e,a.filePath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await yn(e,f.text);a.filePath=await yn(e,f.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=k(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function yn(e,t){return Pt(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}async function Is(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await wn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function wn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};at(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function ke(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m,c]=await Promise.all([br(e,u),xo(e),ne(e),Tt(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await ct(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await Y(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await lt(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));ce(B,$);let O=d.findIndex(w=>w.id===S.cmpInfo.id);d[O].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:H,variableDeclaration:_}=await Rs(e,l,S);if(P.addCmpToRegistry)w.push(Ns(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp),He=e.ts.factory.createIdentifier(P.updateRegisteredCmp.importName);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[e.ts.factory.createPropertyAssignment("component",He),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(H,H.modifiers,e.ts.factory.updateVariableDeclarationList(H.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=Co(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(He=>He.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(Do(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=Pn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=Co(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l);let E=j(e,l);E=De(E),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}async function Rs(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await wn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function Ns(e,t){let r=e.ts.factory.createIdentifier(t.importName);return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",r),...t.acceptsChildren?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}function Co(e,t,r){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}return r}async function ho(e){let t=[],r=await Bs(e,t);if(await Ao(e,t,r),!await e.exists(e.builderComponentPath)){let n=await e.formatCode(e.builderComponentPath,So(e,e.builderComponentPath));await e.writeFile(e.builderComponentPath,n),t.push({filePath:e.builderComponentPath,modifiedType:"create"})}return t}async function Eo(e){let t=[];await Ao(e,t);let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,n=e.join(e.componentsDir,r);if(!await e.exists(n)){let o=await e.formatCode(n,So(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}function So(e,t,r="page"){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
581
581
  import React from "react";
582
582
  import {
583
583
  Content,
@@ -687,7 +687,7 @@ export default function BuilderPage() {
687
687
  </>
688
688
  );
689
689
  }
690
- `.trimStart()}async function So(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=ks(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await Oe(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await Oe(e,o.id,!0,!1,null,null,!0,!1)}async function Bs(e,t){let n=e.typescriptEnabled?"tsx":"jsx",o=e.join(e.componentsDir,"Counter"),i=e.join(o,`Counter.${n}`),a=e.join(o,"styles.module.css"),{component:s,styles:u}=Os(e);if(!await e.exists(i)){let p=await e.formatCode(i,s);await e.writeFile(i,p),t.push({filePath:i,modifiedType:"create"})}return await e.exists(a)||(await e.writeFile(a,u),t.push({filePath:a,modifiedType:"create"})),i}function Os(e){let t=e.typescriptEnabled,r=`
690
+ `.trimStart()}async function Ao(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=Os(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await ke(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await ke(e,o.id,!0,!1,null,null,!0,!1)}async function Bs(e,t){let n=e.typescriptEnabled?"tsx":"jsx",o=e.join(e.componentsDir,"Counter"),i=e.join(o,`Counter.${n}`),a=e.join(o,"styles.module.css"),{component:s,styles:u}=ks(e);if(!await e.exists(i)){let p=await e.formatCode(i,s);await e.writeFile(i,p),t.push({filePath:i,modifiedType:"create"})}return await e.exists(a)||(await e.writeFile(a,u),t.push({filePath:a,modifiedType:"create"})),i}function ks(e){let t=e.typescriptEnabled,r=`
691
691
  "use client"
692
692
  import React, { useState } from "react";
693
693
  import styles from "./styles.module.css";
@@ -750,31 +750,31 @@ export default Counter;
750
750
  font-size: 42px;
751
751
  text-align: center;
752
752
  }
753
- `.trimStart();return{component:r,styles:n}}function ks(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
753
+ `.trimStart();return{component:r,styles:n}}function Os(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
754
754
 
755
755
  export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
756
756
  ];`:`export const CUSTOM_COMPONENTS = [
757
757
  ];
758
- `}async function Ao(e){let t=await Ls(e);return{builderPageOptions:async()=>({templateContentId:"2e36438034894a8abf279ea9e6d3596f",pathname:"/builder-demo",title:"Builder + React Demo Page"}),ensureBuilderSetup:()=>Co(t),ensureFigmaImportPage:()=>ho(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Oe(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Oe(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Oe(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Oe(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Oe(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Oe(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Tt(t),setPublicApiKey:n=>fo(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Ls(e){let t=await _s(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",reactConfigPath:t,typescriptEnabled:o,configType:"",addExternalPackage:s=>{i[e.join(r,s,"index.ts")]=`export * from "${s}";`},readFileSync:s=>i[s]??e.readFileSync(s),existsSync:s=>!!i[s]||e.existsSync(s),readdirSync:s=>{let u=e.readdirSync(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u},readdir:async s=>{let u=await e.readdir(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u}};return e.sdkVersion?a.sdkVersion=e.sdkVersion:a.sdkVersion=await ft(a),t.includes("webpack.config")&&(a.configType="webpack"),t.includes("vite.config")&&(a.configType="vite"),await e.exists(n)?(a.srcDir=n,a.componentsDir=e.join(n,"components"),a.registryPath=await ie(e,n),a.builderComponentPath=e.join(a.srcDir,`builder-page.${o?"tsx":"jsx"}`)):(a.componentsDir=e.join(r,"components"),a.registryPath=await ie(e,r),a.builderComponentPath=e.join(r,`builder-page.${o?"tsx":"jsx"}`)),a}async function _s(e){let t=["vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find React config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function It(e){return await js(e,["environment.ts"],Jt)}async function Fo(e,t){let r=await It(e),n=await Ms(e,r.file,r.envKey,t);return{...r,modifiedType:n}}async function js(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),"src","environments",o),a=await Vs(e,i);if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=i,n}return n.file=e.join(e.getAppRootDir(),"src","environments",t[t.length-1]),n}async function Vs(e,t){let r=await e.readFile(t);return r?$s(e,r):""}function $s(e,t){let r=b(e,t),n="",i=ut(e,r,"environment");if(i&&i.statement.declarationList.declarations.length>0){let s=i.statement.declarationList.declarations[0].initializer;s&&e.ts.isObjectLiteralExpression(s)&&s.properties.forEach(u=>{e.ts.isPropertyAssignment(u)&&e.ts.isIdentifier(u.name)&&u.name.text===Jt&&e.ts.isStringLiteral(u.initializer)&&(n=u.initializer.text)})}return n}async function Ks(e,t,r,n){let o=b(e,t),a=ut(e,o,"environment");if(a&&a.statement.declarationList.declarations.length>0){let s=a.statement.declarationList,u=s.declarations[0],p=u.initializer;if(p&&e.ts.isObjectLiteralExpression(p)){let f=e.ts.factory.createPropertyAssignment(e.ts.factory.createIdentifier(r),e.ts.factory.createStringLiteral(n)),m=e.ts.factory.createNodeArray([...p.properties,f]),c=e.ts.factory.updateObjectLiteralExpression(p,m),d=e.ts.factory.updateVariableDeclaration(u,u.name,u.exclamationToken,u.type,c),D=e.ts.factory.updateVariableDeclarationList(s,[d]);return e.ts.factory.updateVariableStatement(a.statement,a.statement.modifiers,D)}return null}return null}async function Ms(e,t,r,n){let o=await e.readFile(t);if(o)if(o.includes(r))e.debug(`"${r}" already set in ${t}`);else{e.debug(`Add "${r}" to ${t}`);let i=await Ks(e,o,r,n);if(i){let a=j(e,i),s=await e.formatCode(t,a);await e.writeFile(t,s)}return"update"}else{e.debug(`Creating new env file with "${r}" at ${t}`);let i=`
758
+ `}async function vn(e){let t=await Ls(e);return{builderPageOptions:async()=>({templateContentId:"2e36438034894a8abf279ea9e6d3596f",pathname:"/builder-demo",title:"Builder + React Demo Page"}),ensureBuilderSetup:()=>ho(t),ensureFigmaImportPage:()=>Eo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>ke(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await ke(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>ke(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>ke(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>ke(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>ke(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Tt(t),setPublicApiKey:n=>go(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Ls(e){let t=await _s(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",reactConfigPath:t,typescriptEnabled:o,configType:"",addExternalPackage:s=>{i[e.join(r,s,"index.ts")]=`export * from "${s}";`},readFileSync:s=>i[s]??e.readFileSync(s),existsSync:s=>!!i[s]||e.existsSync(s),readdirSync:s=>{let u=e.readdirSync(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u},readdir:async s=>{let u=await e.readdir(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u}};return e.sdkVersion?a.sdkVersion=e.sdkVersion:a.sdkVersion=await ft(a),t.includes("webpack.config")&&(a.configType="webpack"),t.includes("vite.config")&&(a.configType="vite"),await e.exists(n)?(a.srcDir=n,a.componentsDir=e.join(n,"components"),a.registryPath=await ie(e,n),a.builderComponentPath=e.join(a.srcDir,`builder-page.${o?"tsx":"jsx"}`)):(a.componentsDir=e.join(r,"components"),a.registryPath=await ie(e,r),a.builderComponentPath=e.join(r,`builder-page.${o?"tsx":"jsx"}`)),a}async function _s(e){let t=["vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find React config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function It(e){return await js(e,["environment.ts"],Jt)}async function Fo(e,t){let r=await It(e),n=await Ms(e,r.file,r.envKey,t);return{...r,modifiedType:n}}async function js(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),"src","environments",o),a=await Vs(e,i);if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=i,n}return n.file=e.join(e.getAppRootDir(),"src","environments",t[t.length-1]),n}async function Vs(e,t){let r=await e.readFile(t);return r?$s(e,r):""}function $s(e,t){let r=b(e,t),n="",i=ut(e,r,"environment");if(i&&i.statement.declarationList.declarations.length>0){let s=i.statement.declarationList.declarations[0].initializer;s&&e.ts.isObjectLiteralExpression(s)&&s.properties.forEach(u=>{e.ts.isPropertyAssignment(u)&&e.ts.isIdentifier(u.name)&&u.name.text===Jt&&e.ts.isStringLiteral(u.initializer)&&(n=u.initializer.text)})}return n}async function Ks(e,t,r,n){let o=b(e,t),a=ut(e,o,"environment");if(a&&a.statement.declarationList.declarations.length>0){let s=a.statement.declarationList,u=s.declarations[0],p=u.initializer;if(p&&e.ts.isObjectLiteralExpression(p)){let f=e.ts.factory.createPropertyAssignment(e.ts.factory.createIdentifier(r),e.ts.factory.createStringLiteral(n)),m=e.ts.factory.createNodeArray([...p.properties,f]),c=e.ts.factory.updateObjectLiteralExpression(p,m),d=e.ts.factory.updateVariableDeclaration(u,u.name,u.exclamationToken,u.type,c),D=e.ts.factory.updateVariableDeclarationList(s,[d]);return e.ts.factory.updateVariableStatement(a.statement,a.statement.modifiers,D)}return null}return null}async function Ms(e,t,r,n){let o=await e.readFile(t);if(o)if(o.includes(r))e.debug(`"${r}" already set in ${t}`);else{e.debug(`Add "${r}" to ${t}`);let i=await Ks(e,o,r,n);if(i){let a=j(e,i),s=await e.formatCode(t,a);await e.writeFile(t,s)}return"update"}else{e.debug(`Creating new env file with "${r}" at ${t}`);let i=`
759
759
  // https://www.builder.io/c/docs/using-your-api-key
760
760
  export const environment = {
761
761
  production: false,
762
762
  builderApiKey: "${n}",
763
763
  };
764
- `.trimStart(),a=await e.formatCode(t,i);return await e.writeFile(t,a),"create"}return null}var Jt="builderApiKey";async function yo(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(qs(e,i.fileName)||a.startsWith(".")||a==="node_modules"||Us.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await Wt(e,o,s,i);r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Us=new Set([]),zs=new Set(["node_modules"]);function qs(e,t){for(let r of zs)if(e.dirname(t).includes(r))return!0;return!1}async function wo(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Js(e,t,n)}return null}function Js(e,t,r){let n=b(e,r);return Wt(e,null,t,n)}async function Wt(e,t,r,n){let o=[],i={};r=e.normalize(r);let a=n.statements.filter(f=>e.ts.isClassDeclaration(f)&&Gs(e,f)),s=n.statements.find(f=>e.ts.isImportDeclaration(f)&&e.ts.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text==="@angular/core");if(s&&e.ts.isImportDeclaration(s)){let f=s.importClause?.namedBindings;if(f&&e.ts.isNamedImports(f)){let m=f.elements.find(c=>(c.propertyName??c.name).text==="input");m&&(i.inputSignalImportName=m.name.text)}}let u=await Qs(e,t,r,n),p=Xs(e,n);return await Promise.all(a.map(async f=>{let m=await Ws(e,t,r,f,p,i);o.push(...m)})),o.push(...u),o}async function vn(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await st(e,t.cmpInfo.filePath,r),a=(await Wt(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return a.cmpInfo.inputs}return[]}async function vo(e,t,r){let n=await Y(e,r.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(r.filter(a=>!(a.name.endsWith("Page")||a.name.endsWith("Module")||a.name==="AppComponent")).map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let p=(await Wt(e,o,a.filePath,s)).find(f=>f.cmpInfo.id===a.id);if(p){a.inputs=Ge(e,o,p.node.fnNode);let f=t.find(m=>m.cmpInfo.id===a.id);if(f){let m=await vn(e,f,n);pe(a,m)}}}}return a}))}async function Ws(e,t,r,n,o,i){let a=[],s=e.relative(e.getAppRootDir(),r),u=M(e,r),p=n.name?.text;if(!p)return a;let f=!1;n.modifiers&&(f=n.modifiers.some(D=>D.kind===e.ts.SyntaxKind.DefaultKeyword));let m=f?"default":p,c=f?"default":"named",d=[];return n.members.forEach(D=>{if(e.ts.isPropertyDeclaration(D)||e.ts.isGetAccessor(D)||e.ts.isSetAccessor(D)){let l=(e.ts.getDecorators(D)??[]).find(E=>Hs(e,E))!==void 0&&e.ts.isIdentifier(D.name),C=i?.inputSignalImportName!==void 0&&e.ts.isIdentifier(D.name)&&Ys(e,D,i.inputSignalImportName);if(l||C){let E="any";if(e.ts.isSetAccessor(D))E=Po(e,D.parameters[0].type);else if(D.type&&t){let A=t.getTypeAtLocation(D.type);E=t.typeToString(A)}else E=Po(e,D.type);let F={name:D.name.text,type:o[E]?"string":E};o[E]&&(F.enum=o[E]),d.push(F)}}}),a.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:K(p),inputs:d,exportName:m,exportType:c,importName:p,filePath:r,relFilePath:s,importPath:u,meta:{...eu(e,n)},framework:"angular"},node:{name:p,fnNode:n,deps:void 0}}),a}async function Qs(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);for(let s of n.statements)if(e.ts.isExportDeclaration(s)&&s.exportClause&&e.ts.isNamedExports(s.exportClause))for(let u of s.exportClause.elements){let p=u.name?.text;if(!p)continue;let f=p,m="named",c=[];if(t){let g=t.getSymbolAtLocation(u.name);if(g){let x=t.getDeclaredTypeOfSymbol(g);t.getPropertiesOfType(x).forEach(C=>{let E=C.getDeclarations();E&&E.forEach(F=>{if(e.ts.isPropertyDeclaration(F)){let A=t.getTypeAtLocation(F),S={name:C.getName(),type:Zs(e,t,A)};c.push(S)}})})}}let d=e.ts.isExportSpecifier(u)&&u.parent?u.parent.parent:void 0,D;if(d){let g=d.moduleSpecifier;if(g&&e.ts.isStringLiteral(g)){let x=t?.getSymbolAtLocation(g);if(x&&x.declarations&&x.declarations.length>0){let l=x.declarations[0];(!e.ts.isSourceFile(l)||e.ts.isSourceFile(l)&&l.fileName.includes("node_modules"))&&(D=g.text)}}}o.push({cmpInfo:{id:await V(e,r,p,D),displayFilePath:O(e,r),name:K(p),inputs:c,exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:D||a,externalImportPath:D,framework:"angular"},node:{name:p,fnNode:u,deps:void 0}})}else if(e.ts.isExportDeclaration(s)&&!s.exportClause&&s.moduleSpecifier&&e.ts.isStringLiteral(s.moduleSpecifier)){let u=s.moduleSpecifier.text;if(t)try{let p=t.getSymbolAtLocation(s.moduleSpecifier);if(p&&p.exports){let f=t.getExportsOfModule(p);for(let m of f)if(m.flags&e.ts.SymbolFlags.Class){let c=m.getName();if(c.startsWith("_"))continue;o.push({cmpInfo:{id:await V(e,r,c,u),displayFilePath:O(e,r),name:K(c),inputs:[],exportName:c,exportType:"named",importName:c,filePath:r,relFilePath:i,importPath:u,externalImportPath:u,framework:"angular"},node:{name:c,fnNode:s,deps:void 0}})}}}catch(p){console.warn(`Error processing star export from ${u}:`,p)}}return o}function Hs(e,t){return To(e,t,"Input")}function Ys(e,t,r){return e.ts.isPropertyDeclaration(t)&&t.initializer!==void 0&&e.ts.isCallExpression(t.initializer)&&e.ts.isIdentifier(t.initializer.expression)&&t.initializer.expression.text===r}function To(e,t,r){if(e.ts.isCallExpression(t.expression)){let n=t.expression;if(e.ts.isIdentifier(n.expression))return n.expression?.text===r}return!1}function Gs(e,t){return!!e.ts.getDecorators(t)?.some(o=>e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="Component")}function Po(e,t){if(!t)return"any";let r="any";switch(t.kind){case e.ts.SyntaxKind.StringKeyword:r="string";break;case e.ts.SyntaxKind.NumberKeyword:r="number";break;case e.ts.SyntaxKind.BooleanKeyword:r="boolean";break;case e.ts.SyntaxKind.TypeReference:e.ts.isTypeReferenceNode(t)&&e.ts.isIdentifier(t.typeName)&&(r=t.typeName.text);break}return r.includes("|")?"string":r}function Xs(e,t){let r={};return e.ts.forEachChild(t,n=>{e.ts.isTypeAliasDeclaration(n)&&e.ts.isUnionTypeNode(n.type)&&n.type.types.every(o=>e.ts.isLiteralTypeNode(o)&&e.ts.isStringLiteral(o.literal))&&(r[n.name.text]=n.type.types.map(o=>o.literal.text))}),r}function Zs(e,t,r){let n=t.typeToString(r);if(n==="any"){let o=r.getSymbol();if(o){let i=o.getDeclarations();if(i&&i.length>0){let a=i[0];if(e.ts.isVariableDeclaration(a)){let s=a.type;s&&(n=t.typeToString(t.getTypeAtLocation(s)))}}}}return n}function eu(e,t){let{getDecorators:r,isCallExpression:n,isIdentifier:o,isObjectLiteralExpression:i,isPropertyAssignment:a,isStringLiteral:s,SyntaxKind:u}=e.ts,p,f;return r(t)?.forEach(c=>{if(To(e,c,"Component")){let{expression:d}=c;if(n(d)){let[D]=d.arguments;i(D)&&D.properties.forEach(g=>{a(g)&&o(g.name)&&(g.name.escapedText==="selector"&&s(g.initializer)&&(p=g.initializer.text),g.name.escapedText==="standalone"&&(f=g.initializer.kind===u.TrueKeyword))})}}}),{selector:p,standalone:f}}async function Qt(e,t,r){let n=e.typescriptEnabled?".ts":".js",o=`app.module${n}`,i=e.join(e.appDir,o),a=await e.readFile(i);if(!a){e.Sentry?.captureException(new Error(`Unable to read app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}let s=await tu(e,i,t,r,a);if(!s){e.Sentry?.captureException(new Error(`Unable to update app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}return await e.writeFile(i,s),i}async function tu(e,t,r,n,o){let i=o,a=b(e,o),s=N(e,t,n);a=I(e,a,{namedImports:[r],importPath:s}),a=I(e,a,{namedImports:["Content"],importPath:"@builder.io/sdk-angular"});let u=[];for(let p of a.statements)if(e.ts.isClassDeclaration(p)&&p.name?.text==="AppModule"){let f=nu(e,r,p);u.push(f)}else u.push(p);return a=e.ts.factory.updateSourceFile(a,u),i=j(e,a),i}function nu(e,t,r){let n=e.ts.getDecorators(r);if(n){for(let o of n)if(e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="NgModule"){let i=o.expression.arguments;if(i.length===1&&e.ts.isObjectLiteralExpression(i[0])){let a=bo(e,i[0],"declarations",t);if(a){let s=bo(e,a,"imports","Content");if(s&&(a=s),a){let u=e.ts.factory.updateDecorator(o,e.ts.factory.updateCallExpression(o.expression,o.expression.expression,o.expression.typeArguments,[a])),f=[...n.map(m=>m===o?u:m),...e.ts.getModifiers(r)||[]];return e.ts.factory.updateClassDeclaration(r,f,r.name,r.typeParameters,r.heritageClauses,r.members)}}}}}return r}function bo(e,t,r,n){let o=[...t.properties],i=o.findIndex(s=>L(e,s)===r);if(i>-1){let s=o[i];if(e.ts.isPropertyAssignment(s)&&s.initializer&&e.ts.isArrayLiteralExpression(s.initializer)){let u=Io(e,s.initializer,n);return u?(o[i]=e.ts.factory.updatePropertyAssignment(s,s.name,u),e.ts.factory.updateObjectLiteralExpression(t,o)):null}return null}let a=Io(e,e.ts.factory.createArrayLiteralExpression([],!0),n);return a?e.ts.factory.updateObjectLiteralExpression(t,[...o,e.ts.factory.createPropertyAssignment(r,a)]):null}function Io(e,t,r){return t.elements.some(o=>e.ts.isIdentifier(o)?o.text===r:!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier(r)])}async function Tn(e,t,r,n){let i=`app.routes${e.typescriptEnabled?".ts":".js"}`,a=e.join(e.appDir,i);try{if(e.magicast){let s=await e.magicast.loadFile(a);Object.keys(s.exports).length===0&&(s.exports.routes=[]);let p=Object.keys(s.exports)[0],f=s.exports[p];if(f.find(c=>c.path===t))return;let m=e.magicast.builders.raw("{}");if(m.path=t,m.component=e.magicast.builders.raw(r),f.push(m),s.imports.$items.find(c=>c.imported===r))return;s.imports.$append({imported:r,from:n}),await e.magicast.writeFile(s,a)}}catch(s){let u=null;try{u=e.readFileSync(a)}catch(p){e.Sentry?.captureException(p,{level:"warning"})}e.Sentry?.captureException(s,{extra:{content:u,appRoutesPath:a,componentName:r,componentPath:n}})}}var ru=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ou=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,iu=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,bn={Space_Separator:ru,ID_Start:ou,ID_Continue:iu},q={isSpaceSeparator(e){return typeof e=="string"&&bn.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||bn.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="\u200C"||e==="\u200D"||bn.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}},Rn,oe,Ve,Yt,Je,Se,Q,On,Nt,au=function(t,r){Rn=String(t),oe="start",Ve=[],Yt=0,Je=1,Se=0,Q=void 0,On=void 0,Nt=void 0;do Q=su(),cu[oe]();while(Q.type!=="eof");return typeof r=="function"?Nn({"":Nt},"",r):Nt};function Nn(e,t,r){let n=e[t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let o=0;o<n.length;o++){let i=String(o),a=Nn(n,i,r);a===void 0?delete n[i]:Object.defineProperty(n,i,{value:a,writable:!0,enumerable:!0,configurable:!0})}else for(let o in n){let i=Nn(n,o,r);i===void 0?delete n[o]:Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0})}return r.call(e,t,n)}var T,v,Rt,je,R;function su(){for(T="default",v="",Rt=!1,je=1;;){R=$e();let e=No[T]();if(e)return e}}function $e(){if(Rn[Yt])return String.fromCodePoint(Rn.codePointAt(Yt))}function h(){let e=$e();return e===`
764
+ `.trimStart(),a=await e.formatCode(t,i);return await e.writeFile(t,a),"create"}return null}var Jt="builderApiKey";async function yo(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(qs(e,i.fileName)||a.startsWith(".")||a==="node_modules"||Us.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await Wt(e,o,s,i);r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Us=new Set([]),zs=new Set(["node_modules"]);function qs(e,t){for(let r of zs)if(e.dirname(t).includes(r))return!0;return!1}async function wo(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Js(e,t,n)}return null}function Js(e,t,r){let n=b(e,r);return Wt(e,null,t,n)}async function Wt(e,t,r,n){let o=[],i={};r=e.normalize(r);let a=n.statements.filter(f=>e.ts.isClassDeclaration(f)&&Gs(e,f)),s=n.statements.find(f=>e.ts.isImportDeclaration(f)&&e.ts.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text==="@angular/core");if(s&&e.ts.isImportDeclaration(s)){let f=s.importClause?.namedBindings;if(f&&e.ts.isNamedImports(f)){let m=f.elements.find(c=>(c.propertyName??c.name).text==="input");m&&(i.inputSignalImportName=m.name.text)}}let u=await Qs(e,t,r,n),p=Xs(e,n);return await Promise.all(a.map(async f=>{let m=await Ws(e,t,r,f,p,i);o.push(...m)})),o.push(...u),o}async function Tn(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await st(e,t.cmpInfo.filePath,r),a=(await Wt(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return a.cmpInfo.inputs}return[]}async function vo(e,t,r){let n=await Y(e,r.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(r.filter(a=>!(a.name.endsWith("Page")||a.name.endsWith("Module")||a.name==="AppComponent")).map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let p=(await Wt(e,o,a.filePath,s)).find(f=>f.cmpInfo.id===a.id);if(p){a.inputs=Ge(e,o,p.node.fnNode);let f=t.find(m=>m.cmpInfo.id===a.id);if(f){let m=await Tn(e,f,n);ce(a,m)}}}}return a}))}async function Ws(e,t,r,n,o,i){let a=[],s=e.relative(e.getAppRootDir(),r),u=M(e,r),p=n.name?.text;if(!p)return a;let f=!1;n.modifiers&&(f=n.modifiers.some(D=>D.kind===e.ts.SyntaxKind.DefaultKeyword));let m=f?"default":p,c=f?"default":"named",d=[];return n.members.forEach(D=>{if(e.ts.isPropertyDeclaration(D)||e.ts.isGetAccessor(D)||e.ts.isSetAccessor(D)){let l=(e.ts.getDecorators(D)??[]).find(E=>Hs(e,E))!==void 0&&e.ts.isIdentifier(D.name),C=i?.inputSignalImportName!==void 0&&e.ts.isIdentifier(D.name)&&Ys(e,D,i.inputSignalImportName);if(l||C){let E="any";if(e.ts.isSetAccessor(D))E=Po(e,D.parameters[0].type);else if(D.type&&t){let A=t.getTypeAtLocation(D.type);E=t.typeToString(A)}else E=Po(e,D.type);let F={name:D.name.text,type:o[E]?"string":E};o[E]&&(F.enum=o[E]),d.push(F)}}}),a.push({cmpInfo:{id:await V(e,r,p),displayFilePath:k(e,r),name:K(p),inputs:d,exportName:m,exportType:c,importName:p,filePath:r,relFilePath:s,importPath:u,meta:{...eu(e,n)},framework:"angular"},node:{name:p,fnNode:n,deps:void 0}}),a}async function Qs(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);for(let s of n.statements)if(e.ts.isExportDeclaration(s)&&s.exportClause&&e.ts.isNamedExports(s.exportClause))for(let u of s.exportClause.elements){let p=u.name?.text;if(!p)continue;let f=p,m="named",c=[];if(t){let g=t.getSymbolAtLocation(u.name);if(g){let x=t.getDeclaredTypeOfSymbol(g);t.getPropertiesOfType(x).forEach(C=>{let E=C.getDeclarations();E&&E.forEach(F=>{if(e.ts.isPropertyDeclaration(F)){let A=t.getTypeAtLocation(F),S={name:C.getName(),type:Zs(e,t,A)};c.push(S)}})})}}let d=e.ts.isExportSpecifier(u)&&u.parent?u.parent.parent:void 0,D;if(d){let g=d.moduleSpecifier;if(g&&e.ts.isStringLiteral(g)){let x=t?.getSymbolAtLocation(g);if(x&&x.declarations&&x.declarations.length>0){let l=x.declarations[0];(!e.ts.isSourceFile(l)||e.ts.isSourceFile(l)&&l.fileName.includes("node_modules"))&&(D=g.text)}}}o.push({cmpInfo:{id:await V(e,r,p,D),displayFilePath:k(e,r),name:K(p),inputs:c,exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:D||a,externalImportPath:D,framework:"angular"},node:{name:p,fnNode:u,deps:void 0}})}else if(e.ts.isExportDeclaration(s)&&!s.exportClause&&s.moduleSpecifier&&e.ts.isStringLiteral(s.moduleSpecifier)){let u=s.moduleSpecifier.text;if(t)try{let p=t.getSymbolAtLocation(s.moduleSpecifier);if(p&&p.exports){let f=t.getExportsOfModule(p);for(let m of f)if(m.flags&e.ts.SymbolFlags.Class){let c=m.getName();if(c.startsWith("_"))continue;o.push({cmpInfo:{id:await V(e,r,c,u),displayFilePath:k(e,r),name:K(c),inputs:[],exportName:c,exportType:"named",importName:c,filePath:r,relFilePath:i,importPath:u,externalImportPath:u,framework:"angular"},node:{name:c,fnNode:s,deps:void 0}})}}}catch(p){console.warn(`Error processing star export from ${u}:`,p)}}return o}function Hs(e,t){return To(e,t,"Input")}function Ys(e,t,r){return e.ts.isPropertyDeclaration(t)&&t.initializer!==void 0&&e.ts.isCallExpression(t.initializer)&&e.ts.isIdentifier(t.initializer.expression)&&t.initializer.expression.text===r}function To(e,t,r){if(e.ts.isCallExpression(t.expression)){let n=t.expression;if(e.ts.isIdentifier(n.expression))return n.expression?.text===r}return!1}function Gs(e,t){return!!e.ts.getDecorators(t)?.some(o=>e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="Component")}function Po(e,t){if(!t)return"any";let r="any";switch(t.kind){case e.ts.SyntaxKind.StringKeyword:r="string";break;case e.ts.SyntaxKind.NumberKeyword:r="number";break;case e.ts.SyntaxKind.BooleanKeyword:r="boolean";break;case e.ts.SyntaxKind.TypeReference:e.ts.isTypeReferenceNode(t)&&e.ts.isIdentifier(t.typeName)&&(r=t.typeName.text);break}return r.includes("|")?"string":r}function Xs(e,t){let r={};return e.ts.forEachChild(t,n=>{e.ts.isTypeAliasDeclaration(n)&&e.ts.isUnionTypeNode(n.type)&&n.type.types.every(o=>e.ts.isLiteralTypeNode(o)&&e.ts.isStringLiteral(o.literal))&&(r[n.name.text]=n.type.types.map(o=>o.literal.text))}),r}function Zs(e,t,r){let n=t.typeToString(r);if(n==="any"){let o=r.getSymbol();if(o){let i=o.getDeclarations();if(i&&i.length>0){let a=i[0];if(e.ts.isVariableDeclaration(a)){let s=a.type;s&&(n=t.typeToString(t.getTypeAtLocation(s)))}}}}return n}function eu(e,t){let{getDecorators:r,isCallExpression:n,isIdentifier:o,isObjectLiteralExpression:i,isPropertyAssignment:a,isStringLiteral:s,SyntaxKind:u}=e.ts,p,f;return r(t)?.forEach(c=>{if(To(e,c,"Component")){let{expression:d}=c;if(n(d)){let[D]=d.arguments;i(D)&&D.properties.forEach(g=>{a(g)&&o(g.name)&&(g.name.escapedText==="selector"&&s(g.initializer)&&(p=g.initializer.text),g.name.escapedText==="standalone"&&(f=g.initializer.kind===u.TrueKeyword))})}}}),{selector:p,standalone:f}}async function Qt(e,t,r){let n=e.typescriptEnabled?".ts":".js",o=`app.module${n}`,i=e.join(e.appDir,o),a=await e.readFile(i);if(!a){e.Sentry?.captureException(new Error(`Unable to read app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}let s=await tu(e,i,t,r,a);if(!s){e.Sentry?.captureException(new Error(`Unable to update app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}return await e.writeFile(i,s),i}async function tu(e,t,r,n,o){let i=o,a=b(e,o),s=N(e,t,n);a=I(e,a,{namedImports:[r],importPath:s}),a=I(e,a,{namedImports:["Content"],importPath:"@builder.io/sdk-angular"});let u=[];for(let p of a.statements)if(e.ts.isClassDeclaration(p)&&p.name?.text==="AppModule"){let f=nu(e,r,p);u.push(f)}else u.push(p);return a=e.ts.factory.updateSourceFile(a,u),i=j(e,a),i}function nu(e,t,r){let n=e.ts.getDecorators(r);if(n){for(let o of n)if(e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="NgModule"){let i=o.expression.arguments;if(i.length===1&&e.ts.isObjectLiteralExpression(i[0])){let a=bo(e,i[0],"declarations",t);if(a){let s=bo(e,a,"imports","Content");if(s&&(a=s),a){let u=e.ts.factory.updateDecorator(o,e.ts.factory.updateCallExpression(o.expression,o.expression.expression,o.expression.typeArguments,[a])),f=[...n.map(m=>m===o?u:m),...e.ts.getModifiers(r)||[]];return e.ts.factory.updateClassDeclaration(r,f,r.name,r.typeParameters,r.heritageClauses,r.members)}}}}}return r}function bo(e,t,r,n){let o=[...t.properties],i=o.findIndex(s=>L(e,s)===r);if(i>-1){let s=o[i];if(e.ts.isPropertyAssignment(s)&&s.initializer&&e.ts.isArrayLiteralExpression(s.initializer)){let u=Io(e,s.initializer,n);return u?(o[i]=e.ts.factory.updatePropertyAssignment(s,s.name,u),e.ts.factory.updateObjectLiteralExpression(t,o)):null}return null}let a=Io(e,e.ts.factory.createArrayLiteralExpression([],!0),n);return a?e.ts.factory.updateObjectLiteralExpression(t,[...o,e.ts.factory.createPropertyAssignment(r,a)]):null}function Io(e,t,r){return t.elements.some(o=>e.ts.isIdentifier(o)?o.text===r:!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier(r)])}async function bn(e,t,r,n){let i=`app.routes${e.typescriptEnabled?".ts":".js"}`,a=e.join(e.appDir,i);try{if(e.magicast){let s=await e.magicast.loadFile(a);Object.keys(s.exports).length===0&&(s.exports.routes=[]);let p=Object.keys(s.exports)[0],f=s.exports[p];if(f.find(c=>c.path===t))return;let m=e.magicast.builders.raw("{}");if(m.path=t,m.component=e.magicast.builders.raw(r),f.push(m),s.imports.$items.find(c=>c.imported===r))return;s.imports.$append({imported:r,from:n}),await e.magicast.writeFile(s,a)}}catch(s){let u=null;try{u=e.readFileSync(a)}catch(p){e.Sentry?.captureException(p,{level:"warning"})}e.Sentry?.captureException(s,{extra:{content:u,appRoutesPath:a,componentName:r,componentPath:n}})}}var ru=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ou=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,iu=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,In={Space_Separator:ru,ID_Start:ou,ID_Continue:iu},q={isSpaceSeparator(e){return typeof e=="string"&&In.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||In.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="\u200C"||e==="\u200D"||In.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}},Nn,oe,Ve,Yt,Je,Se,Q,On,Nt,au=function(t,r){Nn=String(t),oe="start",Ve=[],Yt=0,Je=1,Se=0,Q=void 0,On=void 0,Nt=void 0;do Q=su(),cu[oe]();while(Q.type!=="eof");return typeof r=="function"?Bn({"":Nt},"",r):Nt};function Bn(e,t,r){let n=e[t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let o=0;o<n.length;o++){let i=String(o),a=Bn(n,i,r);a===void 0?delete n[i]:Object.defineProperty(n,i,{value:a,writable:!0,enumerable:!0,configurable:!0})}else for(let o in n){let i=Bn(n,o,r);i===void 0?delete n[o]:Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0})}return r.call(e,t,n)}var T,v,Rt,je,R;function su(){for(T="default",v="",Rt=!1,je=1;;){R=$e();let e=No[T]();if(e)return e}}function $e(){if(Nn[Yt])return String.fromCodePoint(Nn.codePointAt(Yt))}function h(){let e=$e();return e===`
765
765
  `?(Je++,Se=0):e?Se+=e.length:Se++,e&&(Yt+=e.length),e}var No={default(){switch(R){case" ":case"\v":case"\f":case" ":case"\xA0":case"\uFEFF":case`
766
766
  `:case"\r":case"\u2028":case"\u2029":h();return;case"/":h(),T="comment";return;case void 0:return h(),U("eof")}if(q.isSpaceSeparator(R)){h();return}return No[oe]()},comment(){switch(R){case"*":h(),T="multiLineComment";return;case"/":h(),T="singleLineComment";return}throw z(h())},multiLineComment(){switch(R){case"*":h(),T="multiLineCommentAsterisk";return;case void 0:throw z(h())}h()},multiLineCommentAsterisk(){switch(R){case"*":h();return;case"/":h(),T="default";return;case void 0:throw z(h())}h(),T="multiLineComment"},singleLineComment(){switch(R){case`
767
- `:case"\r":case"\u2028":case"\u2029":h(),T="default";return;case void 0:return h(),U("eof")}h()},value(){switch(R){case"{":case"[":return U("punctuator",h());case"n":return h(),Ze("ull"),U("null",null);case"t":return h(),Ze("rue"),U("boolean",!0);case"f":return h(),Ze("alse"),U("boolean",!1);case"-":case"+":h()==="-"&&(je=-1),T="sign";return;case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Ze("nfinity"),U("numeric",1/0);case"N":return h(),Ze("aN"),U("numeric",NaN);case'"':case"'":Rt=h()==='"',v="",T="string";return}throw z(h())},identifierNameStartEscape(){if(R!=="u")throw z(h());h();let e=Bn();switch(e){case"$":case"_":break;default:if(!q.isIdStartChar(e))throw Ro();break}v+=e,T="identifierName"},identifierName(){switch(R){case"$":case"_":case"\u200C":case"\u200D":v+=h();return;case"\\":h(),T="identifierNameEscape";return}if(q.isIdContinueChar(R)){v+=h();return}return U("identifier",v)},identifierNameEscape(){if(R!=="u")throw z(h());h();let e=Bn();switch(e){case"$":case"_":case"\u200C":case"\u200D":break;default:if(!q.isIdContinueChar(e))throw Ro();break}v+=e,T="identifierName"},sign(){switch(R){case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Ze("nfinity"),U("numeric",je*(1/0));case"N":return h(),Ze("aN"),U("numeric",NaN)}throw z(h())},zero(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return;case"x":case"X":v+=h(),T="hexadecimal";return}return U("numeric",je*0)},decimalInteger(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalPointLeading(){if(q.isDigit(R)){v+=h(),T="decimalFraction";return}throw z(h())},decimalPoint(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h(),T="decimalFraction";return}return U("numeric",je*Number(v))},decimalFraction(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalExponent(){switch(R){case"+":case"-":v+=h(),T="decimalExponentSign";return}if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentSign(){if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentInteger(){if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},hexadecimal(){if(q.isHexDigit(R)){v+=h(),T="hexadecimalInteger";return}throw z(h())},hexadecimalInteger(){if(q.isHexDigit(R)){v+=h();return}return U("numeric",je*Number(v))},string(){switch(R){case"\\":h(),v+=uu();return;case'"':if(Rt)return h(),U("string",v);v+=h();return;case"'":if(!Rt)return h(),U("string",v);v+=h();return;case`
767
+ `:case"\r":case"\u2028":case"\u2029":h(),T="default";return;case void 0:return h(),U("eof")}h()},value(){switch(R){case"{":case"[":return U("punctuator",h());case"n":return h(),Ze("ull"),U("null",null);case"t":return h(),Ze("rue"),U("boolean",!0);case"f":return h(),Ze("alse"),U("boolean",!1);case"-":case"+":h()==="-"&&(je=-1),T="sign";return;case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Ze("nfinity"),U("numeric",1/0);case"N":return h(),Ze("aN"),U("numeric",NaN);case'"':case"'":Rt=h()==='"',v="",T="string";return}throw z(h())},identifierNameStartEscape(){if(R!=="u")throw z(h());h();let e=kn();switch(e){case"$":case"_":break;default:if(!q.isIdStartChar(e))throw Ro();break}v+=e,T="identifierName"},identifierName(){switch(R){case"$":case"_":case"\u200C":case"\u200D":v+=h();return;case"\\":h(),T="identifierNameEscape";return}if(q.isIdContinueChar(R)){v+=h();return}return U("identifier",v)},identifierNameEscape(){if(R!=="u")throw z(h());h();let e=kn();switch(e){case"$":case"_":case"\u200C":case"\u200D":break;default:if(!q.isIdContinueChar(e))throw Ro();break}v+=e,T="identifierName"},sign(){switch(R){case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Ze("nfinity"),U("numeric",je*(1/0));case"N":return h(),Ze("aN"),U("numeric",NaN)}throw z(h())},zero(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return;case"x":case"X":v+=h(),T="hexadecimal";return}return U("numeric",je*0)},decimalInteger(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalPointLeading(){if(q.isDigit(R)){v+=h(),T="decimalFraction";return}throw z(h())},decimalPoint(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h(),T="decimalFraction";return}return U("numeric",je*Number(v))},decimalFraction(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalExponent(){switch(R){case"+":case"-":v+=h(),T="decimalExponentSign";return}if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentSign(){if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentInteger(){if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},hexadecimal(){if(q.isHexDigit(R)){v+=h(),T="hexadecimalInteger";return}throw z(h())},hexadecimalInteger(){if(q.isHexDigit(R)){v+=h();return}return U("numeric",je*Number(v))},string(){switch(R){case"\\":h(),v+=uu();return;case'"':if(Rt)return h(),U("string",v);v+=h();return;case"'":if(!Rt)return h(),U("string",v);v+=h();return;case`
768
768
  `:case"\r":throw z(h());case"\u2028":case"\u2029":lu(R);break;case void 0:throw z(h())}v+=h()},start(){switch(R){case"{":case"[":return U("punctuator",h())}T="value"},beforePropertyName(){switch(R){case"$":case"_":v=h(),T="identifierName";return;case"\\":h(),T="identifierNameStartEscape";return;case"}":return U("punctuator",h());case'"':case"'":Rt=h()==='"',T="string";return}if(q.isIdStartChar(R)){v+=h(),T="identifierName";return}throw z(h())},afterPropertyName(){if(R===":")return U("punctuator",h());throw z(h())},beforePropertyValue(){T="value"},afterPropertyValue(){switch(R){case",":case"}":return U("punctuator",h())}throw z(h())},beforeArrayValue(){if(R==="]")return U("punctuator",h());T="value"},afterArrayValue(){switch(R){case",":case"]":return U("punctuator",h())}throw z(h())},end(){throw z(h())}};function U(e,t){return{type:e,value:t,line:Je,column:Se}}function Ze(e){for(let t of e){if($e()!==t)throw z(h());h()}}function uu(){switch($e()){case"b":return h(),"\b";case"f":return h(),"\f";case"n":return h(),`
769
- `;case"r":return h(),"\r";case"t":return h()," ";case"v":return h(),"\v";case"0":if(h(),q.isDigit($e()))throw z(h());return"\0";case"x":return h(),pu();case"u":return h(),Bn();case`
769
+ `;case"r":return h(),"\r";case"t":return h()," ";case"v":return h(),"\v";case"0":if(h(),q.isDigit($e()))throw z(h());return"\0";case"x":return h(),pu();case"u":return h(),kn();case`
770
770
  `:case"\u2028":case"\u2029":return h(),"";case"\r":return h(),$e()===`
771
- `&&h(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":throw z(h());case void 0:throw z(h())}return h()}function pu(){let e="",t=$e();if(!q.isHexDigit(t)||(e+=h(),t=$e(),!q.isHexDigit(t)))throw z(h());return e+=h(),String.fromCodePoint(parseInt(e,16))}function Bn(){let e="",t=4;for(;t-- >0;){let r=$e();if(!q.isHexDigit(r))throw z(h());e+=h()}return String.fromCodePoint(parseInt(e,16))}var cu={start(){if(Q.type==="eof")throw et();In()},beforePropertyName(){switch(Q.type){case"identifier":case"string":On=Q.value,oe="afterPropertyName";return;case"punctuator":Ht();return;case"eof":throw et()}},afterPropertyName(){if(Q.type==="eof")throw et();oe="beforePropertyValue"},beforePropertyValue(){if(Q.type==="eof")throw et();In()},beforeArrayValue(){if(Q.type==="eof")throw et();if(Q.type==="punctuator"&&Q.value==="]"){Ht();return}In()},afterPropertyValue(){if(Q.type==="eof")throw et();switch(Q.value){case",":oe="beforePropertyName";return;case"}":Ht()}},afterArrayValue(){if(Q.type==="eof")throw et();switch(Q.value){case",":oe="beforeArrayValue";return;case"]":Ht()}},end(){}};function In(){let e;switch(Q.type){case"punctuator":switch(Q.value){case"{":e={};break;case"[":e=[];break}break;case"null":case"boolean":case"numeric":case"string":e=Q.value;break}if(Nt===void 0)Nt=e;else{let t=Ve[Ve.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,On,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(e!==null&&typeof e=="object")Ve.push(e),Array.isArray(e)?oe="beforeArrayValue":oe="beforePropertyName";else{let t=Ve[Ve.length-1];t==null?oe="end":Array.isArray(t)?oe="afterArrayValue":oe="afterPropertyValue"}}function Ht(){Ve.pop();let e=Ve[Ve.length-1];e==null?oe="end":Array.isArray(e)?oe="afterArrayValue":oe="afterPropertyValue"}function z(e){return Gt(e===void 0?`JSON5: invalid end of input at ${Je}:${Se}`:`JSON5: invalid character '${Bo(e)}' at ${Je}:${Se}`)}function et(){return Gt(`JSON5: invalid end of input at ${Je}:${Se}`)}function Ro(){return Se-=5,Gt(`JSON5: invalid identifier character at ${Je}:${Se}`)}function lu(e){console.warn(`JSON5: '${Bo(e)}' in strings is not valid ECMAScript; consider escaping`)}function Bo(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let r=e.charCodeAt(0).toString(16);return"\\x"+("00"+r).substring(r.length)}return e}function Gt(e){let t=new SyntaxError(e);return t.lineNumber=Je,t.columnNumber=Se,t}var mu=function(t,r,n){let o=[],i="",a,s,u="",p;if(r!=null&&typeof r=="object"&&!Array.isArray(r)&&(n=r.space,p=r.quote,r=r.replacer),typeof r=="function")s=r;else if(Array.isArray(r)){a=[];for(let g of r){let x;typeof g=="string"?x=g:(typeof g=="number"||g instanceof String||g instanceof Number)&&(x=String(g)),x!==void 0&&a.indexOf(x)<0&&a.push(x)}}return n instanceof Number?n=Number(n):n instanceof String&&(n=String(n)),typeof n=="number"?n>0&&(n=Math.min(10,Math.floor(n)),u=" ".substr(0,n)):typeof n=="string"&&(u=n.substr(0,10)),f("",{"":t});function f(g,x){let l=x[g];switch(l!=null&&(typeof l.toJSON5=="function"?l=l.toJSON5(g):typeof l.toJSON=="function"&&(l=l.toJSON(g))),s&&(l=s.call(x,g,l)),l instanceof Number?l=Number(l):l instanceof String?l=String(l):l instanceof Boolean&&(l=l.valueOf()),l){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof l=="string")return m(l,!1);if(typeof l=="number")return String(l);if(typeof l=="object")return Array.isArray(l)?D(l):c(l)}function m(g){let x={"'":.1,'"':.2},l={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},C="";for(let F=0;F<g.length;F++){let A=g[F];switch(A){case"'":case'"':x[A]++,C+=A;continue;case"\0":if(q.isDigit(g[F+1])){C+="\\x00";continue}}if(l[A]){C+=l[A];continue}if(A<" "){let S=A.charCodeAt(0).toString(16);C+="\\x"+("00"+S).substring(S.length);continue}C+=A}let E=p||Object.keys(x).reduce((F,A)=>x[F]<x[A]?F:A);return C=C.replace(new RegExp(E,"g"),l[E]),E+C+E}function c(g){if(o.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");o.push(g);let x=i;i=i+u;let l=a||Object.keys(g),C=[];for(let F of l){let A=f(F,g);if(A!==void 0){let S=d(F)+":";u!==""&&(S+=" "),S+=A,C.push(S)}}let E;if(C.length===0)E="{}";else{let F;if(u==="")F=C.join(","),E="{"+F+"}";else{let A=`,
771
+ `&&h(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":throw z(h());case void 0:throw z(h())}return h()}function pu(){let e="",t=$e();if(!q.isHexDigit(t)||(e+=h(),t=$e(),!q.isHexDigit(t)))throw z(h());return e+=h(),String.fromCodePoint(parseInt(e,16))}function kn(){let e="",t=4;for(;t-- >0;){let r=$e();if(!q.isHexDigit(r))throw z(h());e+=h()}return String.fromCodePoint(parseInt(e,16))}var cu={start(){if(Q.type==="eof")throw et();Rn()},beforePropertyName(){switch(Q.type){case"identifier":case"string":On=Q.value,oe="afterPropertyName";return;case"punctuator":Ht();return;case"eof":throw et()}},afterPropertyName(){if(Q.type==="eof")throw et();oe="beforePropertyValue"},beforePropertyValue(){if(Q.type==="eof")throw et();Rn()},beforeArrayValue(){if(Q.type==="eof")throw et();if(Q.type==="punctuator"&&Q.value==="]"){Ht();return}Rn()},afterPropertyValue(){if(Q.type==="eof")throw et();switch(Q.value){case",":oe="beforePropertyName";return;case"}":Ht()}},afterArrayValue(){if(Q.type==="eof")throw et();switch(Q.value){case",":oe="beforeArrayValue";return;case"]":Ht()}},end(){}};function Rn(){let e;switch(Q.type){case"punctuator":switch(Q.value){case"{":e={};break;case"[":e=[];break}break;case"null":case"boolean":case"numeric":case"string":e=Q.value;break}if(Nt===void 0)Nt=e;else{let t=Ve[Ve.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,On,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(e!==null&&typeof e=="object")Ve.push(e),Array.isArray(e)?oe="beforeArrayValue":oe="beforePropertyName";else{let t=Ve[Ve.length-1];t==null?oe="end":Array.isArray(t)?oe="afterArrayValue":oe="afterPropertyValue"}}function Ht(){Ve.pop();let e=Ve[Ve.length-1];e==null?oe="end":Array.isArray(e)?oe="afterArrayValue":oe="afterPropertyValue"}function z(e){return Gt(e===void 0?`JSON5: invalid end of input at ${Je}:${Se}`:`JSON5: invalid character '${Bo(e)}' at ${Je}:${Se}`)}function et(){return Gt(`JSON5: invalid end of input at ${Je}:${Se}`)}function Ro(){return Se-=5,Gt(`JSON5: invalid identifier character at ${Je}:${Se}`)}function lu(e){console.warn(`JSON5: '${Bo(e)}' in strings is not valid ECMAScript; consider escaping`)}function Bo(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let r=e.charCodeAt(0).toString(16);return"\\x"+("00"+r).substring(r.length)}return e}function Gt(e){let t=new SyntaxError(e);return t.lineNumber=Je,t.columnNumber=Se,t}var mu=function(t,r,n){let o=[],i="",a,s,u="",p;if(r!=null&&typeof r=="object"&&!Array.isArray(r)&&(n=r.space,p=r.quote,r=r.replacer),typeof r=="function")s=r;else if(Array.isArray(r)){a=[];for(let g of r){let x;typeof g=="string"?x=g:(typeof g=="number"||g instanceof String||g instanceof Number)&&(x=String(g)),x!==void 0&&a.indexOf(x)<0&&a.push(x)}}return n instanceof Number?n=Number(n):n instanceof String&&(n=String(n)),typeof n=="number"?n>0&&(n=Math.min(10,Math.floor(n)),u=" ".substr(0,n)):typeof n=="string"&&(u=n.substr(0,10)),f("",{"":t});function f(g,x){let l=x[g];switch(l!=null&&(typeof l.toJSON5=="function"?l=l.toJSON5(g):typeof l.toJSON=="function"&&(l=l.toJSON(g))),s&&(l=s.call(x,g,l)),l instanceof Number?l=Number(l):l instanceof String?l=String(l):l instanceof Boolean&&(l=l.valueOf()),l){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof l=="string")return m(l,!1);if(typeof l=="number")return String(l);if(typeof l=="object")return Array.isArray(l)?D(l):c(l)}function m(g){let x={"'":.1,'"':.2},l={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},C="";for(let F=0;F<g.length;F++){let A=g[F];switch(A){case"'":case'"':x[A]++,C+=A;continue;case"\0":if(q.isDigit(g[F+1])){C+="\\x00";continue}}if(l[A]){C+=l[A];continue}if(A<" "){let S=A.charCodeAt(0).toString(16);C+="\\x"+("00"+S).substring(S.length);continue}C+=A}let E=p||Object.keys(x).reduce((F,A)=>x[F]<x[A]?F:A);return C=C.replace(new RegExp(E,"g"),l[E]),E+C+E}function c(g){if(o.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");o.push(g);let x=i;i=i+u;let l=a||Object.keys(g),C=[];for(let F of l){let A=f(F,g);if(A!==void 0){let S=d(F)+":";u!==""&&(S+=" "),S+=A,C.push(S)}}let E;if(C.length===0)E="{}";else{let F;if(u==="")F=C.join(","),E="{"+F+"}";else{let A=`,
772
772
  `+i;F=C.join(A),E=`{
773
773
  `+i+F+`,
774
774
  `+x+"}"}}return o.pop(),i=x,E}function d(g){if(g.length===0)return m(g,!0);let x=String.fromCodePoint(g.codePointAt(0));if(!q.isIdStartChar(x))return m(g,!0);for(let l=x.length;l<g.length;l++)if(!q.isIdContinueChar(String.fromCodePoint(g.codePointAt(l))))return m(g,!0);return g}function D(g){if(o.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");o.push(g);let x=i;i=i+u;let l=[];for(let E=0;E<g.length;E++){let F=f(String(E),g);l.push(F!==void 0?F:"null")}let C;if(l.length===0)C="[]";else if(u==="")C="["+l.join(",")+"]";else{let E=`,
775
775
  `+i,F=l.join(E);C=`[
776
776
  `+i+F+`,
777
- `+x+"]"}return o.pop(),i=x,C}},fu={parse:au,stringify:mu},du=fu,Oo=du;async function ko(e){let t=e.ts.findConfigFile(e.getAppRootDir(),e.existsSync);if(t){let r=await e.readFile(t);if(!r)return;let n=Oo.parse(r);if(!n||typeof n!="object"||Array.isArray(n))return;let o=n.compilerOptions;if(!o||typeof o!="object"||Array.isArray(o))return;let i=o.paths;(!i||typeof i!="object"||Array.isArray(i))&&(o.paths={},i=o.paths),Object.assign(o.paths,{"~/*":["./src/*"]}),await e.writeFile(t,JSON.stringify(n,null,2))}}async function Lo(e){let t=[],r=await xu(e,t);t.push(...await Xt(e)),await gu(e,r);let n="BuilderPage";if(!await e.exists(e.builderPageComponentPath)){let o=await e.formatCode(e.builderPageComponentPath,jo(e,n,e.builderPageComponentPath,"builder-page","page",!0));await e.writeFile(e.builderPageComponentPath,o),t.push({filePath:e.builderPageComponentPath,modifiedType:"create"})}if(e.hasAppModule){await Qt(e,"Counter",r);let o=await Qt(e,n,e.builderPageComponentPath);o&&t.push({filePath:o,modifiedType:"update"})}return await Tn(e,"**",n,"./components/builder-page.component"),t}async function _o(e){let t=[];t.push(...await Xt(e));let r="FigmaImportsPage",n="figma-imports.component",o=e.join(e.componentsDir,`${n}.${e.typescriptEnabled?"ts":"js"}`);if(!await e.exists(o)){let i=await e.formatCode(o,jo(e,r,o,"figma-imports","figma-imports",!1));await e.writeFile(o,i),t.push({filePath:o,modifiedType:"create"})}if(e.hasAppModule){let i=await Qt(e,r,o);i&&t.push({filePath:i,modifiedType:"update"})}return await Tn(e,"figma-imports",r,`./components/${n}`),await ko(e),t}async function Xt(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,Du(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}async function gu(e,t){let n=(await ke(e,null,!1,!1,null,null,!1,!1)).components.find(o=>o.filePath===t);n&&await ke(e,n.id,!0,!1,null,null,!0,!1)}function jo(e,t,r,n,o,i){let a=!e.hasAppModule,s=N(e,r,e.registryPath),u=e.join(e.getAppRootDir(),"src","environments","environment.ts"),p=N(e,r,u),f=i?` <ng-container *ngIf="content || isPreviewing; else notFound">
777
+ `+x+"]"}return o.pop(),i=x,C}},fu={parse:au,stringify:mu},du=fu,ko=du;async function Oo(e){let t=e.ts.findConfigFile(e.getAppRootDir(),e.existsSync);if(t){let r=await e.readFile(t);if(!r)return;let n=ko.parse(r);if(!n||typeof n!="object"||Array.isArray(n))return;let o=n.compilerOptions;if(!o||typeof o!="object"||Array.isArray(o))return;let i=o.paths;(!i||typeof i!="object"||Array.isArray(i))&&(o.paths={},i=o.paths),Object.assign(o.paths,{"~/*":["./src/*"]}),await e.writeFile(t,JSON.stringify(n,null,2))}}async function Lo(e){let t=[],r=await xu(e,t);t.push(...await Xt(e)),await gu(e,r);let n="BuilderPage";if(!await e.exists(e.builderPageComponentPath)){let o=await e.formatCode(e.builderPageComponentPath,jo(e,n,e.builderPageComponentPath,"builder-page","page",!0));await e.writeFile(e.builderPageComponentPath,o),t.push({filePath:e.builderPageComponentPath,modifiedType:"create"})}if(e.hasAppModule){await Qt(e,"Counter",r);let o=await Qt(e,n,e.builderPageComponentPath);o&&t.push({filePath:o,modifiedType:"update"})}return await bn(e,"**",n,"./components/builder-page.component"),t}async function _o(e){let t=[];t.push(...await Xt(e));let r="FigmaImportsPage",n="figma-imports.component",o=e.join(e.componentsDir,`${n}.${e.typescriptEnabled?"ts":"js"}`);if(!await e.exists(o)){let i=await e.formatCode(o,jo(e,r,o,"figma-imports","figma-imports",!1));await e.writeFile(o,i),t.push({filePath:o,modifiedType:"create"})}if(e.hasAppModule){let i=await Qt(e,r,o);i&&t.push({filePath:i,modifiedType:"update"})}return await bn(e,"figma-imports",r,`./components/${n}`),await Oo(e),t}async function Xt(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,Du(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}async function gu(e,t){let n=(await Oe(e,null,!1,!1,null,null,!1,!1)).components.find(o=>o.filePath===t);n&&await Oe(e,n.id,!0,!1,null,null,!0,!1)}function jo(e,t,r,n,o,i){let a=!e.hasAppModule,s=N(e,r,e.registryPath),u=e.join(e.getAppRootDir(),"src","environments","environment.ts"),p=N(e,r,u),f=i?` <ng-container *ngIf="content || isPreviewing; else notFound">
778
778
  <builder-content
779
779
  [model]="model"
780
780
  [content]="content"
@@ -913,7 +913,7 @@ export class Counter {
913
913
  }
914
914
  }
915
915
 
916
- `.trimStart()}async function Vo(e){await Xt(e);let t=await e.readFile(e.registryPath);return t?hu(e,t):{components:[],sourceFile:b(e,"")}}async function hu(e,t){let r=b(e,t);return Eu(e,r)}async function Eu(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await kn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function kn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"angular"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await wo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function ke(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m]=await Promise.all([yo(e,u),Vo(e),It(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await vo(e,p,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await Y(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await vn(e,A,F);pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:H}=await Au(e,x,A);if(k.addCmpToRegistry)P.push(Su(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[$o(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(H,H.name,H.exclamationToken,H.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(te=>te.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function $o(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function Su(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([$o(e,t)],!0),t)}async function Au(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await kn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Ko(e){let t=await Fu(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Lo(t),ensureFigmaImportPage:()=>_o(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>ke(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await ke(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>ke(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>ke(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>ke(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>ke(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>It(t),setPublicApiKey:n=>Fo(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Fu(e){let t=await Pu(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i=e.join(n,"app"),a=await ie(e,i),s={},u={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1,addExternalPackage:m=>{s[e.join(r,m,"index.ts")]=`export * from "${m}";`},readFileSync:m=>s[m]??e.readFileSync(m),existsSync:m=>!!s[m]||e.existsSync(m),readdirSync:m=>{let c=e.readdirSync(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c},readdir:async m=>{let c=await e.readdir(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c}};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);u.srcDir=n,u.appDir=i,u.componentsDir=e.join(u.appDir,"components"),u.builderPageComponentPath=e.join(u.componentsDir,`builder-page.component.${o?"ts":"js"}`);let p=`app.module.${o?"ts":"js"}`,f=e.join(u.appDir,p);return await e.exists(f)&&(u.hasAppModule=!0),u}async function Pu(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}async function Bt(e){let t=e.configType==="vite"?yu:wu;return await Fe(e,[".env"],t)}async function Mo(e,t){let r=await Bt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var yu="VITE_PUBLIC_BUILDER_KEY",wu="PUBLIC_BUILDER_KEY";async function zo(e,t,r){try{let n=await e.readFile(t);if(!n)return null;let o=e.relative(e.getAppRootDir(),t),i=t.split("/").pop()?.replace(".vue","")||"UnknownComponent",a=Iu(i),s=Tu(n,r),u=vu(n);return{id:Ru(t),name:a,filePath:o,relFilePath:o,inputs:s,framework:"vue",exportType:"default",exportName:"default",importName:a,importPath:o,vueApiType:u}}catch(n){return console.warn(`Failed to parse Vue component ${t}:`,n),null}}function vu(e){return/<script[^>]*\s+setup[^>]*>/.test(e)?"composition-setup":/import\s+\{[^}]*\b(ref|reactive|computed|watch|onMounted|defineComponent)\b[^}]*\}\s+from\s+['"]vue['"]/.test(e)||/setup\s*\([^)]*\)\s*\{/.test(e)?"composition":"options"}function Tu(e,t){if(!t)return[];let r=[],n=[/defineProps<\s*\{([^}]+)\}\s*>\s*\(\s*\)/g,/defineProps\s*\(\s*\{([^}]+)\}\s*\)/g,/defineProps\s*\(\s*\[([^\]]+)\]\s*\)/g];for(let u of n){let p;for(;(p=u.exec(e))!==null;){let f=p[1];f.includes(":")?r.push(...Ln(f)):r.push(...Uo(f))}}let o=/props\s*:\s*(\{[^}]+\}|\[[^\]]+\])/g,i;for(;(i=o.exec(e))!==null;){let u=i[1];if(u.startsWith("{")){let p=u.slice(1,-1);r.push(...Ln(p))}else{let p=u.slice(1,-1);r.push(...Uo(p))}}let a=/setup\s*\(\s*props\s*(?::\s*\{([^}]+)\})?\s*[,)]?/g,s;for(;(s=a.exec(e))!==null;)s[1]&&r.push(...Ln(s[1]));return bu(r)}function Ln(e){let t=[],r=/(\w+)\s*:\s*([^,;]+)/g,n;for(;(n=r.exec(e))!==null;){let[,a,s]=n;t.push({name:a.trim(),type:_n(s.trim()),required:!s.includes("?")&&!s.includes("undefined")})}let o=/(\w+)\s*:\s*\{([^}]+)\}/g;for(;(n=o.exec(e))!==null;){let[,a,s]=n,u=s.match(/type\s*:\s*(\w+)/),p=s.match(/required\s*:\s*(true|false)/),f=s.match(/default\s*:\s*([^,}]+)/);t.push({name:a.trim(),type:u?_n(u[1]):"any",required:p?p[1]==="true":!1,defaultValue:f?f[1].trim():void 0})}let i=/(\w+)\s*:\s*(\w+)(?=\s*[,}])/g;for(;(n=i.exec(e))!==null;){let[,a,s]=n;t.some(u=>u.name===a.trim())||t.push({name:a.trim(),type:_n(s.trim()),required:!1})}return t}function Uo(e){let t=[],r=e.split(",").map(n=>n.trim().replace(/['"]/g,"")).filter(n=>n.length>0);for(let n of r)t.push({name:n,type:"any",required:!1});return t}function _n(e){let t={String:"string",Number:"number",Boolean:"boolean",Array:"any[]",Object:"object",Function:"function",Date:"Date",Symbol:"symbol",string:"string",number:"number",boolean:"boolean",object:"object",function:"function"},r=e.replace(/\s*\|\s*undefined/g,"").replace(/\?$/,"");return t[r]||r||"any"}function bu(e){let t=new Set;return e.filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}function Iu(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^(.)/,(t,r)=>r?r.toUpperCase():"")}function Ru(e){return e.replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}async function tt(e,t){let r=await Nu(e,t.readAllInputTypes),n=await Bt(e);return{components:r,registryPath:e.registryPath,registryDisplayPath:e.relative(e.getAppRootDir(),e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(r),publicApiKey:n.envValue??void 0,devToolsVersion:e.version}}async function Nu(e,t){let r=[],n=await Bu(e,e.getAppRootDir());for(let o of n){let i=await zo(e,o,t);i&&r.push(i)}return r}async function Bu(e,t){let r=[],n=async i=>{try{let a=await e.readdir(i);for(let s of a){let u=e.join(i,s);(await e.stat(u)).isDirectory()?!s.startsWith(".")&&s!=="node_modules"&&s!=="dist"&&s!=="build"&&s!==".nuxt"&&s!==".output"&&await n(u):s.endsWith(".vue")&&r.push(u)}}catch{}};await n(t);let o=["components","pages","layouts"];for(let i of o){let a=e.join(t,i);try{(await e.stat(a)).isDirectory()&&await n(a)}catch{}}return r}async function qo(e){let t={errors:[]};try{await Wo(e)}catch(r){t.errors.push(r instanceof Error?r.message:String(r))}return t}async function Jo(e){let t=[];t.push(...await Wo(e));let n=e.join(e.componentsDir,"FigmaImports.vue");if(!await e.exists(n)){let o=await e.formatCode(n,Ou(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}async function Wo(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,Lu(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}function Ou(e,t,r="page"){let n=N(e,t,e.registryPath),o=e.typescriptEnabled;return e.isNuxt?`<template>
916
+ `.trimStart()}async function Vo(e){await Xt(e);let t=await e.readFile(e.registryPath);return t?hu(e,t):{components:[],sourceFile:b(e,"")}}async function hu(e,t){let r=b(e,t);return Eu(e,r)}async function Eu(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Ln(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Ln(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"angular"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await wo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Oe(e,t,r,n,o,i,a,s){let u=await qe(e),[p,f,m]=await Promise.all([yo(e,u),Vo(e),It(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await vo(e,p,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await Y(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await Tn(e,A,F);ce(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let O=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:H}=await Au(e,x,A);if(O.addCmpToRegistry)P.push(Su(e,O.addCmpToRegistry)),g=!0;else if(O.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(O.updateRegisteredCmp){let _=W(e,P[w],O.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[$o(e,O.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(H,H.name,H.exclamationToken,H.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=O.components,d=O.components.filter(te=>te.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function $o(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function Su(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([$o(e,t)],!0),t)}async function Au(e,t,r){let n=J(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await Ln(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Ko(e){let t=await Fu(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Lo(t),ensureFigmaImportPage:()=>_o(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Oe(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Oe(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Oe(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Oe(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Oe(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Oe(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>It(t),setPublicApiKey:n=>Fo(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Fu(e){let t=await Pu(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i=e.join(n,"app"),a=await ie(e,i),s={},u={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1,addExternalPackage:m=>{s[e.join(r,m,"index.ts")]=`export * from "${m}";`},readFileSync:m=>s[m]??e.readFileSync(m),existsSync:m=>!!s[m]||e.existsSync(m),readdirSync:m=>{let c=e.readdirSync(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c},readdir:async m=>{let c=await e.readdir(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c}};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);u.srcDir=n,u.appDir=i,u.componentsDir=e.join(u.appDir,"components"),u.builderPageComponentPath=e.join(u.componentsDir,`builder-page.component.${o?"ts":"js"}`);let p=`app.module.${o?"ts":"js"}`,f=e.join(u.appDir,p);return await e.exists(f)&&(u.hasAppModule=!0),u}async function Pu(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}async function Bt(e){let t=e.configType==="vite"?yu:wu;return await Fe(e,[".env"],t)}async function Mo(e,t){let r=await Bt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var yu="VITE_PUBLIC_BUILDER_KEY",wu="PUBLIC_BUILDER_KEY";async function zo(e,t,r){try{let n=await e.readFile(t);if(!n)return null;let o=e.relative(e.getAppRootDir(),t),i=t.split("/").pop()?.replace(".vue","")||"UnknownComponent",a=Iu(i),s=Tu(n,r),u=vu(n);return{id:Ru(t),name:a,filePath:o,relFilePath:o,inputs:s,framework:"vue",exportType:"default",exportName:"default",importName:a,importPath:o,vueApiType:u}}catch(n){return console.warn(`Failed to parse Vue component ${t}:`,n),null}}function vu(e){return/<script[^>]*\s+setup[^>]*>/.test(e)?"composition-setup":/import\s+\{[^}]*\b(ref|reactive|computed|watch|onMounted|defineComponent)\b[^}]*\}\s+from\s+['"]vue['"]/.test(e)||/setup\s*\([^)]*\)\s*\{/.test(e)?"composition":"options"}function Tu(e,t){if(!t)return[];let r=[],n=[/defineProps<\s*\{([^}]+)\}\s*>\s*\(\s*\)/g,/defineProps\s*\(\s*\{([^}]+)\}\s*\)/g,/defineProps\s*\(\s*\[([^\]]+)\]\s*\)/g];for(let u of n){let p;for(;(p=u.exec(e))!==null;){let f=p[1];f.includes(":")?r.push(..._n(f)):r.push(...Uo(f))}}let o=/props\s*:\s*(\{[^}]+\}|\[[^\]]+\])/g,i;for(;(i=o.exec(e))!==null;){let u=i[1];if(u.startsWith("{")){let p=u.slice(1,-1);r.push(..._n(p))}else{let p=u.slice(1,-1);r.push(...Uo(p))}}let a=/setup\s*\(\s*props\s*(?::\s*\{([^}]+)\})?\s*[,)]?/g,s;for(;(s=a.exec(e))!==null;)s[1]&&r.push(..._n(s[1]));return bu(r)}function _n(e){let t=[],r=/(\w+)\s*:\s*([^,;]+)/g,n;for(;(n=r.exec(e))!==null;){let[,a,s]=n;t.push({name:a.trim(),type:jn(s.trim()),required:!s.includes("?")&&!s.includes("undefined")})}let o=/(\w+)\s*:\s*\{([^}]+)\}/g;for(;(n=o.exec(e))!==null;){let[,a,s]=n,u=s.match(/type\s*:\s*(\w+)/),p=s.match(/required\s*:\s*(true|false)/),f=s.match(/default\s*:\s*([^,}]+)/);t.push({name:a.trim(),type:u?jn(u[1]):"any",required:p?p[1]==="true":!1,defaultValue:f?f[1].trim():void 0})}let i=/(\w+)\s*:\s*(\w+)(?=\s*[,}])/g;for(;(n=i.exec(e))!==null;){let[,a,s]=n;t.some(u=>u.name===a.trim())||t.push({name:a.trim(),type:jn(s.trim()),required:!1})}return t}function Uo(e){let t=[],r=e.split(",").map(n=>n.trim().replace(/['"]/g,"")).filter(n=>n.length>0);for(let n of r)t.push({name:n,type:"any",required:!1});return t}function jn(e){let t={String:"string",Number:"number",Boolean:"boolean",Array:"any[]",Object:"object",Function:"function",Date:"Date",Symbol:"symbol",string:"string",number:"number",boolean:"boolean",object:"object",function:"function"},r=e.replace(/\s*\|\s*undefined/g,"").replace(/\?$/,"");return t[r]||r||"any"}function bu(e){let t=new Set;return e.filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}function Iu(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^(.)/,(t,r)=>r?r.toUpperCase():"")}function Ru(e){return e.replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}async function tt(e,t){let r=await Nu(e,t.readAllInputTypes),n=await Bt(e);return{components:r,registryPath:e.registryPath,registryDisplayPath:e.relative(e.getAppRootDir(),e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(r),publicApiKey:n.envValue??void 0,devToolsVersion:e.version}}async function Nu(e,t){let r=[],n=await Bu(e,e.getAppRootDir());for(let o of n){let i=await zo(e,o,t);i&&r.push(i)}return r}async function Bu(e,t){let r=[],n=async i=>{try{let a=await e.readdir(i);for(let s of a){let u=e.join(i,s);(await e.stat(u)).isDirectory()?!s.startsWith(".")&&s!=="node_modules"&&s!=="dist"&&s!=="build"&&s!==".nuxt"&&s!==".output"&&await n(u):s.endsWith(".vue")&&r.push(u)}}catch{}};await n(t);let o=["components","pages","layouts"];for(let i of o){let a=e.join(t,i);try{(await e.stat(a)).isDirectory()&&await n(a)}catch{}}return r}async function qo(e){let t={errors:[]};try{await Wo(e)}catch(r){t.errors.push(r instanceof Error?r.message:String(r))}return t}async function Jo(e){let t=[];t.push(...await Wo(e));let n=e.join(e.componentsDir,"FigmaImports.vue");if(!await e.exists(n)){let o=await e.formatCode(n,ku(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}async function Wo(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,Lu(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}function ku(e,t,r="page"){let n=N(e,t,e.registryPath),o=e.typescriptEnabled;return e.isNuxt?`<template>
917
917
  <div>
918
918
  <div v-if="pending">Loading...</div>
919
919
  <div v-else-if="error">Error loading content</div>
@@ -969,7 +969,7 @@ export default defineComponent({
969
969
  },
970
970
  setup() {
971
971
  const model = '${r}'
972
- const apiKey = ${ku(e)}
972
+ const apiKey = ${Ou(e)}
973
973
  const content = ref${o?"<any>":""}(null)
974
974
  const loading = ref(true)
975
975
  const customComponents = CUSTOM_COMPONENTS
@@ -1002,7 +1002,7 @@ export default defineComponent({
1002
1002
  }
1003
1003
  }
1004
1004
  })
1005
- </script>`}function ku(e){return e.isNuxt?"useRuntimeConfig().public.builderApiKey":e.configType==="vite"?"import.meta.env.VITE_BUILDER_API_KEY":"process.env.VUE_APP_BUILDER_API_KEY"}function Lu(e){return`import type { RegisteredComponent } from "@builder.io/sdk-vue";
1005
+ </script>`}function Ou(e){return e.isNuxt?"useRuntimeConfig().public.builderApiKey":e.configType==="vite"?"import.meta.env.VITE_BUILDER_API_KEY":"process.env.VUE_APP_BUILDER_API_KEY"}function Lu(e){return`import type { RegisteredComponent } from "@builder.io/sdk-vue";
1006
1006
 
1007
1007
  export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
1008
1008
  // Add your Vue components here
@@ -1019,9 +1019,9 @@ export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
1019
1019
  // ]
1020
1020
  // }
1021
1021
  ];
1022
- `}async function Qo(e){let t=await _u(e);return{builderPageOptions:async()=>({templateContentId:"vue-demo-template-id",pathname:"/builder-demo",title:"Builder + Vue Demo Page"}),ensureBuilderSetup:async()=>(await qo(t)).errors.length>0?[]:[],ensureFigmaImportPage:()=>Jo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>tt(t,{readAllInputTypes:!!n?.readAllInputTypes}),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await tt(t,{readAllInputTypes:!1}),i=o.components.find(a=>a.id===n.cmpId);return{...o,component:i}},registerComponent:async n=>tt(t,{readAllInputTypes:!1}),setRegisteredComponentInfo:async n=>tt(t,{readAllInputTypes:!1}),setRegisteredComponentInput:async n=>tt(t,{readAllInputTypes:!1}),unregisterComponent:async n=>tt(t,{readAllInputTypes:!1}),getPublicApiKey:()=>Bt(t),setPublicApiKey:n=>Mo(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-vue"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/vue"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function _u(e){let t=await ju(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",vueConfigPath:t,typescriptEnabled:o,configType:"",isNuxt:await Vu(e),addExternalPackage:p=>{i[e.join(r,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>i[p]??e.readFileSync(p),existsSync:p=>!!i[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f}};t.includes("webpack.config")&&(a.configType="webpack"),(t.includes("vite.config")||t.includes("nuxt.config"))&&(a.configType="vite");let s=await e.exists(n);a.srcDir=s?n:null;let u=[e.join(r,"components"),e.join(r,"src","components"),e.join(r,"app","components")];for(let p of u)if(await e.exists(p)){a.componentsDir=p;break}return a.componentsDir||(a.componentsDir=s?e.join(n,"components"):e.join(r,"components")),a.registryPath=await ie(e,a.componentsDir),a}async function ju(e){let t=["nuxt.config.ts","nuxt.config.js","vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts","vue.config.js","vue.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Vue config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function Vu(e){let t=["nuxt.config.ts","nuxt.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return!0}try{let r=e.join(e.getAppRootDir(),"package.json");if(await e.exists(r)){let n=JSON.parse(await e.readFile(r)||"{}"),o={...n.dependencies,...n.devDependencies};return!!(o.nuxt||o["@nuxt/kit"]||o.nuxt3)}}catch{}return!1}var nn=rr(si(),1);async function ui(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:he(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:ue(i.inputs)};return ue(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,nn.compress)(n);return btoa(JSON.stringify(o))}async function pi(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,nn.decompress)(o),a=ue(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=he(e.normalize(s.filePath)),p=n.components.find(m=>he(m.filePath).endsWith(u)&&m.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let m of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:m.name,type:m.type,required:m.required,defaultValue:m.defaultValue,friendlyName:m.friendlyName,helperText:m.helperText});e.debug(`set input (${p.id}) info`);let f=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=ue(f)}return a}var ce={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik",vue:"vue"},Ag={[ce.react]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.remix]:[{version:y.gen1,recommended:!1},{version:y.gen2,recommended:!0}],[ce.angular]:[{version:y.gen2,recommended:!0}],[ce.next]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.qwik]:[{version:y.gen2,recommended:!0}],[ce.vue]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}]};async function ci(e,t){let r=[],n=new Set;async function o(i){let a=e.join(i,"package.json");try{if(!await e.exists(a))return null;let u=await e.readFile(a);if(u===null)throw new Error(`Failed to read package.json at ${a}`);let p=JSON.parse(u);if(typeof p.name!="string"||p.name.trim()===""||n.has(p.name))return null;n.add(p.name);let f={name:p.name,subPackages:[]},m=await e.readdir(i);for(let c of m)c!=="node_modules"&&(await e.stat(e.join(i,c))).isDirectory()&&f.subPackages.push(c);return r.push(f),f}catch(s){return e.Sentry?.captureException(s,{level:"warning"}),null}}try{let i=e.join(t,"package.json");if(await e.exists(i)){let s=await e.readFile(i);if(s!==null){let u=JSON.parse(s),p={...u.dependencies,...u.devDependencies};for(let f of Object.keys(p)){let m=e.join(t,"node_modules",f);await o(m)}if(Array.isArray(u.workspaces))for(let f of u.workspaces){let m=await e.readdir(e.join(t,f));for(let c of m){let d=e.join(t,f,c);await o(d)}}}}}catch(i){e.Sentry?.captureException(i,{level:"warning"})}return r}var pp={"@builder.io/qwik-city":oo,next:Wr,"@remix-run/react":mo,react:Ao,"@angular/core":Ko,vue:Qo},cp={"@builder.io/qwik-city":ce.qwik,next:ce.next,"@remix-run/react":ce.remix,react:ce.react,"@angular/core":ce.angular,vue:ce.vue};async function li(e){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await Ue(e)),e.frameworks.length===0)throw new Error("Supported Devtools framework for not found");for(let t of e.frameworks){let r=pp[t.name];if(r)try{let n=await r(e);return{...n,exportRegistry:()=>ui(e,n),importRegistry:i=>pi(e,n,i),framework:cp[t.name],findAllDependencies:async()=>await ci(e,e.getRepoRootDir())}}catch(n){e.Sentry?.captureException(n,{level:"warning"})}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}var rn=class{constructor(t){Me(this,"connections",new Set);Me(this,"maxConnections",1e3);Me(this,"sys");Me(this,"healthCheckInterval",null);Me(this,"HEALTH_CHECK_INTERVAL_MS",3e4);this.sys=t,this.startHealthMonitoring()}addConnection(t,r){if(this.connections.size>=this.maxConnections){let n=`Max connections (${this.maxConnections}) reached, rejecting new connection`;return console.error(`[ConnectionTracker] ${n}`),this.sys.Sentry?.captureMessage(n,{level:"error",tags:{component:"ConnectionTracker",maxConnections:this.maxConnections.toString(),currentConnections:this.connections.size.toString(),requestUrl:r?.url||"unknown",requestMethod:r?.method||"unknown",userAgent:r?.headers?.["user-agent"]||"unknown",origin:r?.headers?.origin||"unknown",referer:r?.headers?.referer||"unknown"},extra:{connectionLimit:this.maxConnections,activeConnections:this.connections.size,requestHeaders:r?.headers||{},requestUrl:r?.url}}),!1}return this.connections.add(t),t.on("close",()=>{this.removeConnection(t)}),t.on("error",()=>{this.removeConnection(t)}),!0}removeConnection(t){this.connections.delete(t)}getConnectionCount(){return this.connections.size}cleanup(){for(let t of this.connections)t.writable&&t.write(`HTTP/1.1 503 Service Unavailable\r
1022
+ `}async function Qo(e){let t=await _u(e);return{builderPageOptions:async()=>({templateContentId:"vue-demo-template-id",pathname:"/builder-demo",title:"Builder + Vue Demo Page"}),ensureBuilderSetup:async()=>(await qo(t)).errors.length>0?[]:[],ensureFigmaImportPage:()=>Jo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>tt(t,{readAllInputTypes:!!n?.readAllInputTypes}),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await tt(t,{readAllInputTypes:!1}),i=o.components.find(a=>a.id===n.cmpId);return{...o,component:i}},registerComponent:async n=>tt(t,{readAllInputTypes:!1}),setRegisteredComponentInfo:async n=>tt(t,{readAllInputTypes:!1}),setRegisteredComponentInput:async n=>tt(t,{readAllInputTypes:!1}),unregisterComponent:async n=>tt(t,{readAllInputTypes:!1}),getPublicApiKey:()=>Bt(t),setPublicApiKey:n=>Mo(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-vue"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/vue"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function _u(e){let t=await ju(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",vueConfigPath:t,typescriptEnabled:o,configType:"",isNuxt:await Vu(e),addExternalPackage:p=>{i[e.join(r,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>i[p]??e.readFileSync(p),existsSync:p=>!!i[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f}};t.includes("webpack.config")&&(a.configType="webpack"),(t.includes("vite.config")||t.includes("nuxt.config"))&&(a.configType="vite");let s=await e.exists(n);a.srcDir=s?n:null;let u=[e.join(r,"components"),e.join(r,"src","components"),e.join(r,"app","components")];for(let p of u)if(await e.exists(p)){a.componentsDir=p;break}return a.componentsDir||(a.componentsDir=s?e.join(n,"components"):e.join(r,"components")),a.registryPath=await ie(e,a.componentsDir),a}async function ju(e){let t=["nuxt.config.ts","nuxt.config.js","vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts","vue.config.js","vue.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Vue config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function Vu(e){let t=["nuxt.config.ts","nuxt.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return!0}try{let r=e.join(e.getAppRootDir(),"package.json");if(await e.exists(r)){let n=JSON.parse(await e.readFile(r)||"{}"),o={...n.dependencies,...n.devDependencies};return!!(o.nuxt||o["@nuxt/kit"]||o.nuxt3)}}catch{}return!1}var nn=or(si(),1);async function ui(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:he(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:pe(i.inputs)};return pe(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,nn.compress)(n);return btoa(JSON.stringify(o))}async function pi(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,nn.decompress)(o),a=pe(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=he(e.normalize(s.filePath)),p=n.components.find(m=>he(m.filePath).endsWith(u)&&m.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let m of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:m.name,type:m.type,required:m.required,defaultValue:m.defaultValue,friendlyName:m.friendlyName,helperText:m.helperText});e.debug(`set input (${p.id}) info`);let f=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=pe(f)}return a}var ue={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik",vue:"vue",native:"native"},Ag={[ue.react]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ue.remix]:[{version:y.gen1,recommended:!1},{version:y.gen2,recommended:!0}],[ue.angular]:[{version:y.gen2,recommended:!0}],[ue.next]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ue.qwik]:[{version:y.gen2,recommended:!0}],[ue.vue]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}]};async function ci(e,t){let r=[],n=new Set;async function o(i){let a=e.join(i,"package.json");try{if(!await e.exists(a))return null;let u=await e.readFile(a);if(u===null)throw new Error(`Failed to read package.json at ${a}`);let p=JSON.parse(u);if(typeof p.name!="string"||p.name.trim()===""||n.has(p.name))return null;n.add(p.name);let f={name:p.name,subPackages:[]},m=await e.readdir(i);for(let c of m)c!=="node_modules"&&(await e.stat(e.join(i,c))).isDirectory()&&f.subPackages.push(c);return r.push(f),f}catch(s){return e.Sentry?.captureException(s,{level:"warning"}),null}}try{let i=e.join(t,"package.json");if(await e.exists(i)){let s=await e.readFile(i);if(s!==null){let u=JSON.parse(s),p={...u.dependencies,...u.devDependencies};for(let f of Object.keys(p)){let m=e.join(t,"node_modules",f);await o(m)}if(Array.isArray(u.workspaces))for(let f of u.workspaces){let m=await e.readdir(e.join(t,f));for(let c of m){let d=e.join(t,f,c);await o(d)}}}}}catch(i){e.Sentry?.captureException(i,{level:"warning"})}return r}var pp={"@builder.io/qwik-city":io,next:Qr,"@remix-run/react":fo,react:vn,"@angular/core":Ko,vue:Qo,native:vn},cp={"@builder.io/qwik-city":ue.qwik,next:ue.next,"@remix-run/react":ue.remix,react:ue.react,"@angular/core":ue.angular,vue:ue.vue,native:ue.native};async function li(e,t=!1){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await Ue(e)),e.frameworks.length===0&&t&&e.frameworks.push({name:"native"}),e.frameworks.length===0)throw new Error("Supported Devtools framework for not found");for(let r of e.frameworks){let n=pp[r.name];if(n)try{let o=await n(e);return{...o,exportRegistry:()=>ui(e,o),importRegistry:a=>pi(e,o,a),framework:cp[r.name],findAllDependencies:async()=>await ci(e,e.getRepoRootDir())}}catch(o){e.Sentry?.captureException(o,{level:"warning"})}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}var rn=class{constructor(t){Me(this,"connections",new Set);Me(this,"maxConnections",1e3);Me(this,"sys");Me(this,"healthCheckInterval",null);Me(this,"HEALTH_CHECK_INTERVAL_MS",3e4);this.sys=t,this.startHealthMonitoring()}addConnection(t,r){if(this.connections.size>=this.maxConnections){let n=`Max connections (${this.maxConnections}) reached, rejecting new connection`;return console.error(`[ConnectionTracker] ${n}`),this.sys.Sentry?.captureMessage(n,{level:"error",tags:{component:"ConnectionTracker",maxConnections:this.maxConnections.toString(),currentConnections:this.connections.size.toString(),requestUrl:r?.url||"unknown",requestMethod:r?.method||"unknown",userAgent:r?.headers?.["user-agent"]||"unknown",origin:r?.headers?.origin||"unknown",referer:r?.headers?.referer||"unknown"},extra:{connectionLimit:this.maxConnections,activeConnections:this.connections.size,requestHeaders:r?.headers||{},requestUrl:r?.url}}),!1}return this.connections.add(t),t.on("close",()=>{this.removeConnection(t)}),t.on("error",()=>{this.removeConnection(t)}),!0}removeConnection(t){this.connections.delete(t)}getConnectionCount(){return this.connections.size}cleanup(){for(let t of this.connections)t.writable&&t.write(`HTTP/1.1 503 Service Unavailable\r
1023
1023
  \r
1024
- `),t.destroy();this.connections.clear(),this.stopHealthMonitoring()}startHealthMonitoring(){this.healthCheckInterval||(this.healthCheckInterval=setInterval(()=>{this.performHealthCheck()},this.HEALTH_CHECK_INTERVAL_MS))}stopHealthMonitoring(){this.healthCheckInterval&&(clearInterval(this.healthCheckInterval),this.healthCheckInterval=null)}performHealthCheck(){let t=[];for(let r of this.connections)if(r.destroyed||!r.writable){t.push(r);continue}for(let r of t){this.removeConnection(r);try{r.destroy()}catch{}}}};function mi(e){function t(m){if(typeof m!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(m))}function r(m,c){let d="",D=0,g=-1,x=0,l;for(let C=0;C<=m.length;++C){if(C<m.length)l=m.charCodeAt(C);else{if(l===47)break;l=47}if(l===47){if(!(g===C-1||x===1))if(g!==C-1&&x===2){if(d.length<2||D!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let E=d.lastIndexOf("/");if(E!==d.length-1){E===-1?(d="",D=0):(d=d.slice(0,E),D=d.length-1-d.lastIndexOf("/")),g=C,x=0;continue}}else if(d.length===2||d.length===1){d="",D=0,g=C,x=0;continue}}c&&(d.length>0?d+="/..":d="..",D=2)}else d.length>0?d+="/"+m.slice(g+1,C):d=m.slice(g+1,C),D=C-g-1;g=C,x=0}else l===46&&x!==-1?++x:x=-1}return d}let n=function(...c){let d="",D=!1;for(let g=c.length-1;g>=-1&&!D;g--){let x;g>=0?x=c[g]:e.cwd?x=e.cwd():x="/",t(x),x.length!==0&&(d=x+"/"+d,D=x.charCodeAt(0)===47)}return d=r(d,!D),D?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,D=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&D&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let D=1;for(;D<c.length&&c.charCodeAt(D)===47;++D);let g=c.length,x=g-D,l=1;for(;l<d.length&&d.charCodeAt(l)===47;++l);let E=d.length-l,F=x<E?x:E,A=-1,S=0;for(;S<=F;++S){if(S===F){if(E>F){if(d.charCodeAt(l+S)===47)return d.slice(l+S+1);if(S===0)return d.slice(l+S)}else x>F&&(c.charCodeAt(D+S)===47?A=S:S===0&&(A=0));break}let $=c.charCodeAt(D+S),k=d.charCodeAt(l+S);if($!==k)break;$===47&&(A=S)}let B="";for(S=D+A+1;S<=g;++S)(S===g||c.charCodeAt(S)===47)&&(B.length===0?B+="..":B+="/..");return B.length>0?B+d.slice(l+A):(l+=A,d.charCodeAt(l)===47&&++l,d.slice(l))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let D=0;D<c.length;++D){let g=c[D];t(g),g.length>0&&(d===void 0?d=g:d+="/"+g)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let D=0,g=-1,x=!0,l;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let C=d.length-1,E=-1;for(l=c.length-1;l>=0;--l){let F=c.charCodeAt(l);if(F===47){if(!x){D=l+1;break}}else E===-1&&(x=!1,E=l+1),C>=0&&(F===d.charCodeAt(C)?--C===-1&&(g=l):(C=-1,g=E))}return D===g?g=E:g===-1&&(g=c.length),c.slice(D,g)}else{for(l=c.length-1;l>=0;--l)if(c.charCodeAt(l)===47){if(!x){D=l+1;break}}else g===-1&&(x=!1,g=l+1);return g===-1?"":c.slice(D,g)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),D=d===47,g=-1,x=!0;for(let l=c.length-1;l>=1;--l)if(d=c.charCodeAt(l),d===47){if(!x){g=l;break}}else x=!1;return g===-1?D?"/":".":D&&g===1?"//":c.slice(0,g)},extname:function(c){t(c);let d=-1,D=0,g=-1,x=!0,l=0;for(let C=c.length-1;C>=0;--C){let E=c.charCodeAt(C);if(E===47){if(!x){D=C+1;break}continue}g===-1&&(x=!1,g=C+1),E===46?d===-1?d=C:l!==1&&(l=1):d!==-1&&(l=-1)}return d===-1||g===-1||l===0||l===1&&d===g-1&&d===D+1?"":c.slice(d,g)}}}async function fi(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=mi({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[C]of o)if((C+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let C=l===t()?l:l+"/",E=C.split("/").length-1,F=[];for(let[A]of o)if(A.split("/").slice(0,E).join("/")+"/"===C){let $=A.split("/")[E];$&&!F.includes($)&&F.push($)}return F.sort()},p=async(l,C=[])=>{l=i(l);let E=l===t()?l:l+"/",F=[],A=new Set(C);for(let[S]of o)S.startsWith(E)&&(S.slice(E.length).split("/").some(k=>A.has(k))||F.push(S));return F.sort()},f=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?C:null},m=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?new TextEncoder().encode(C):C instanceof Uint8Array?C:null},c=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l),size:a(l)?0:o.get(l)?.length??0}),d=async l=>{if(typeof crypto<"u"){let F=new TextEncoder().encode(l),A=await crypto.subtle.digest("SHA-256",F);return Array.from(new Uint8Array(A)).map(S=>S.toString(16).padStart(2,"0")).join("")}let C=0;for(let E=0;E<l.length;E++){let F=l.charCodeAt(E);C=(C<<5)-C+F,C|=0}return Number(Math.abs(C)).toString(36)},D=new Set,g={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readdirRecursive:p,readFile:async l=>f(l),readFileSync:f,readFileSyncBuffer:l=>m(l),stat:async l=>c(l),statSync:c,writeFile:async(l,C)=>{l=i(l),o.set(l,C);let E={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let F of D)await F(E)},unlink:async l=>{l=i(l),o.delete(l)},unlinkSync:l=>{l=i(l),o.delete(l)},hash:d,getDeviceId:async()=>typeof navigator<"u"?d(navigator.userAgent):"",getRepoInfo:async()=>({hasGit:!1,remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,C)=>C,on:(l,C)=>{l==="change"&&D.add(C)},off:(l,C)=>{l==="change"&&D.delete(C)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawnSync:void 0,Sentry:void 0,connectionTracker:null};g.connectionTracker=new rn(g);let x=await Ue(g);return g.getFrameworks=e.getFrameworks?e.getFrameworks:()=>x,g}async function di(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(await mr(e))return console.warn("Turbopack does not support the Builder.io devtools cli. Please disable Turbopack or manually integrate Builder.io into your Next.js project."),o;if(gi(e,n))return o;let s=de(e,n,"cjs"),u=de(e,n);if(s.length!==1&&u.length!==1)throw new Error("Expected an export from file");if(u.length===1){let m=u[0];if(!m.isDefaultExport)throw new Error("Expected a default export from file");let c=m.statement;if(!e.ts.isVariableStatement(c))throw new Error(`Unexpected export type in ${t}
1024
+ `),t.destroy();this.connections.clear(),this.stopHealthMonitoring()}startHealthMonitoring(){this.healthCheckInterval||(this.healthCheckInterval=setInterval(()=>{this.performHealthCheck()},this.HEALTH_CHECK_INTERVAL_MS))}stopHealthMonitoring(){this.healthCheckInterval&&(clearInterval(this.healthCheckInterval),this.healthCheckInterval=null)}performHealthCheck(){let t=[];for(let r of this.connections)if(r.destroyed||!r.writable){t.push(r);continue}for(let r of t){this.removeConnection(r);try{r.destroy()}catch{}}}};function mi(e){function t(m){if(typeof m!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(m))}function r(m,c){let d="",D=0,g=-1,x=0,l;for(let C=0;C<=m.length;++C){if(C<m.length)l=m.charCodeAt(C);else{if(l===47)break;l=47}if(l===47){if(!(g===C-1||x===1))if(g!==C-1&&x===2){if(d.length<2||D!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let E=d.lastIndexOf("/");if(E!==d.length-1){E===-1?(d="",D=0):(d=d.slice(0,E),D=d.length-1-d.lastIndexOf("/")),g=C,x=0;continue}}else if(d.length===2||d.length===1){d="",D=0,g=C,x=0;continue}}c&&(d.length>0?d+="/..":d="..",D=2)}else d.length>0?d+="/"+m.slice(g+1,C):d=m.slice(g+1,C),D=C-g-1;g=C,x=0}else l===46&&x!==-1?++x:x=-1}return d}let n=function(...c){let d="",D=!1;for(let g=c.length-1;g>=-1&&!D;g--){let x;g>=0?x=c[g]:e.cwd?x=e.cwd():x="/",t(x),x.length!==0&&(d=x+"/"+d,D=x.charCodeAt(0)===47)}return d=r(d,!D),D?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,D=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&D&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let D=1;for(;D<c.length&&c.charCodeAt(D)===47;++D);let g=c.length,x=g-D,l=1;for(;l<d.length&&d.charCodeAt(l)===47;++l);let E=d.length-l,F=x<E?x:E,A=-1,S=0;for(;S<=F;++S){if(S===F){if(E>F){if(d.charCodeAt(l+S)===47)return d.slice(l+S+1);if(S===0)return d.slice(l+S)}else x>F&&(c.charCodeAt(D+S)===47?A=S:S===0&&(A=0));break}let $=c.charCodeAt(D+S),O=d.charCodeAt(l+S);if($!==O)break;$===47&&(A=S)}let B="";for(S=D+A+1;S<=g;++S)(S===g||c.charCodeAt(S)===47)&&(B.length===0?B+="..":B+="/..");return B.length>0?B+d.slice(l+A):(l+=A,d.charCodeAt(l)===47&&++l,d.slice(l))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let D=0;D<c.length;++D){let g=c[D];t(g),g.length>0&&(d===void 0?d=g:d+="/"+g)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let D=0,g=-1,x=!0,l;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let C=d.length-1,E=-1;for(l=c.length-1;l>=0;--l){let F=c.charCodeAt(l);if(F===47){if(!x){D=l+1;break}}else E===-1&&(x=!1,E=l+1),C>=0&&(F===d.charCodeAt(C)?--C===-1&&(g=l):(C=-1,g=E))}return D===g?g=E:g===-1&&(g=c.length),c.slice(D,g)}else{for(l=c.length-1;l>=0;--l)if(c.charCodeAt(l)===47){if(!x){D=l+1;break}}else g===-1&&(x=!1,g=l+1);return g===-1?"":c.slice(D,g)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),D=d===47,g=-1,x=!0;for(let l=c.length-1;l>=1;--l)if(d=c.charCodeAt(l),d===47){if(!x){g=l;break}}else x=!1;return g===-1?D?"/":".":D&&g===1?"//":c.slice(0,g)},extname:function(c){t(c);let d=-1,D=0,g=-1,x=!0,l=0;for(let C=c.length-1;C>=0;--C){let E=c.charCodeAt(C);if(E===47){if(!x){D=C+1;break}continue}g===-1&&(x=!1,g=C+1),E===46?d===-1?d=C:l!==1&&(l=1):d!==-1&&(l=-1)}return d===-1||g===-1||l===0||l===1&&d===g-1&&d===D+1?"":c.slice(d,g)}}}async function fi(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=mi({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[C]of o)if((C+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let C=l===t()?l:l+"/",E=C.split("/").length-1,F=[];for(let[A]of o)if(A.split("/").slice(0,E).join("/")+"/"===C){let $=A.split("/")[E];$&&!F.includes($)&&F.push($)}return F.sort()},p=async(l,C=[])=>{l=i(l);let E=l===t()?l:l+"/",F=[],A=new Set(C);for(let[S]of o)S.startsWith(E)&&(S.slice(E.length).split("/").some(O=>A.has(O))||F.push(S));return F.sort()},f=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?C:null},m=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?new TextEncoder().encode(C):C instanceof Uint8Array?C:null},c=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l),size:a(l)?0:o.get(l)?.length??0}),d=async l=>{if(typeof crypto<"u"){let F=new TextEncoder().encode(l),A=await crypto.subtle.digest("SHA-256",F);return Array.from(new Uint8Array(A)).map(S=>S.toString(16).padStart(2,"0")).join("")}let C=0;for(let E=0;E<l.length;E++){let F=l.charCodeAt(E);C=(C<<5)-C+F,C|=0}return Number(Math.abs(C)).toString(36)},D=new Set,g={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readdirRecursive:p,readFile:async l=>f(l),readFileSync:f,readFileSyncBuffer:l=>m(l),stat:async l=>c(l),statSync:c,writeFile:async(l,C)=>{l=i(l),o.set(l,C);let E={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let F of D)await F(E)},unlink:async l=>{l=i(l),o.delete(l)},unlinkSync:l=>{l=i(l),o.delete(l)},hash:d,getDeviceId:async()=>typeof navigator<"u"?d(navigator.userAgent):"",getRepoInfo:async()=>({hasGit:!1,remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,C)=>C,on:(l,C)=>{l==="change"&&D.add(C)},off:(l,C)=>{l==="change"&&D.delete(C)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawnSync:void 0,Sentry:void 0,connectionTracker:null};g.connectionTracker=new rn(g);let x=await Ue(g);return g.getFrameworks=e.getFrameworks?e.getFrameworks:()=>x,g}async function di(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(await fr(e))return console.warn("Turbopack does not support the Builder.io devtools cli. Please disable Turbopack or manually integrate Builder.io into your Next.js project."),o;if(gi(e,n))return o;let s=de(e,n,"cjs"),u=de(e,n);if(s.length!==1&&u.length!==1)throw new Error("Expected an export from file");if(u.length===1){let m=u[0];if(!m.isDefaultExport)throw new Error("Expected a default export from file");let c=m.statement;if(!e.ts.isVariableStatement(c))throw new Error(`Unexpected export type in ${t}
1025
1025
  Found config content:
1026
1026
  ${r}
1027
1027
 
@@ -1050,7 +1050,7 @@ Detected export type: ${p?.statement.kind??"none"}
1050
1050
  Valid formats:
1051
1051
  1. module.exports = { ... }
1052
1052
  2. module.exports = (phase, config) => { return { ... } }
1053
- 3. export default { ... }`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let m=p.statement;if(!e.ts.isExpressionStatement(m))throw new Error("Expected an expression statement for the default export");let c=m.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let d=Zn(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(m);return D[g]=e.ts.factory.updateExpressionStatement(m,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c.right]))),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}let f=p.statement;if(e.ts.isVariableStatement(f)){let m=[...f.declarationList.declarations];if(m.length!==1)throw new Error("Expected a single variable declaration");let c=m[0];if(!c.initializer)throw new Error("Expected an initializer on the declaration");let d=c.initializer;if(e.ts.isObjectLiteralExpression(d)||e.ts.isCallExpression(d)){let D=Zn(e,n);n=D.sourceFile;let g=[...n.statements],x=g.indexOf(f);return g[x]=e.ts.factory.updateVariableStatement(f,f.modifiers,e.ts.factory.updateVariableDeclarationList(f.declarationList,[e.ts.factory.updateVariableDeclaration(c,c.name,c.exclamationToken,c.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(D.withFnVariableName),void 0,[d]))])),n=e.ts.factory.updateSourceFile(n,g),o.content=j(e,n),o.outcome="added",o}throw new Error(`Unexpected initializer on the variable statement in ${t}
1053
+ 3. export default { ... }`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let m=p.statement;if(!e.ts.isExpressionStatement(m))throw new Error("Expected an expression statement for the default export");let c=m.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let d=er(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(m);return D[g]=e.ts.factory.updateExpressionStatement(m,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c.right]))),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}let f=p.statement;if(e.ts.isVariableStatement(f)){let m=[...f.declarationList.declarations];if(m.length!==1)throw new Error("Expected a single variable declaration");let c=m[0];if(!c.initializer)throw new Error("Expected an initializer on the declaration");let d=c.initializer;if(e.ts.isObjectLiteralExpression(d)||e.ts.isCallExpression(d)){let D=er(e,n);n=D.sourceFile;let g=[...n.statements],x=g.indexOf(f);return g[x]=e.ts.factory.updateVariableStatement(f,f.modifiers,e.ts.factory.updateVariableDeclarationList(f.declarationList,[e.ts.factory.updateVariableDeclaration(c,c.name,c.exclamationToken,c.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(D.withFnVariableName),void 0,[d]))])),n=e.ts.factory.updateSourceFile(n,g),o.content=j(e,n),o.outcome="added",o}throw new Error(`Unexpected initializer on the variable statement in ${t}
1054
1054
  Found config content:
1055
1055
  ${r}
1056
1056
 
@@ -1059,11 +1059,11 @@ The config variable must be initialized with either:
1059
1059
  2. A function call: const nextConfig = withSomePlugin({ /* config */ })
1060
1060
 
1061
1061
  Current initializer type: ${d.kind}
1062
- Expected types: ${e.ts.SyntaxKind.ObjectLiteralExpression} or ${e.ts.SyntaxKind.CallExpression}`)}if(e.ts.isArrowFunction(p.node)){let m=p.node,c=p.statement;if(!e.ts.isExpressionStatement(c))throw new Error("Expected an expression statement for the default export");let d=c.expression;if(!e.ts.isBinaryExpression(d))throw new Error("Expected a binary expression for the default export");let g=p.node.body;if(!e.ts.isBlock(g))throw new Error("Expected a block body on the next config function");let x=[...g.statements],l=x.findIndex(S=>e.ts.isReturnStatement(S));if(l===-1)throw new Error("Expected a return statement on the next config function");let C=x[l],E=Zn(e,n);n=E.sourceFile,x[l]=e.ts.factory.updateReturnStatement(C,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(E.withFnVariableName),void 0,[C.expression]));let F=[...n.statements],A=F.indexOf(c);return F[A]=e.ts.factory.updateExpressionStatement(c,e.ts.factory.updateBinaryExpression(d,d.left,d.operatorToken,e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,e.ts.factory.updateBlock(g,x)))),n=e.ts.factory.updateSourceFile(n,F),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function gi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Zn(e,t){let r=gi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function Ci(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(hi(e,n))return o;let a=de(e,n,"cjs"),s=de(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let u=a[0];if(s.length===1){let f=s[0];if(!f.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let m=f.statement;if(!e.ts.isExportAssignment(m))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(m.expression)){let c="builderDevTools()",d=lp(e,m.expression);if(!d)return o;let D=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[d]),g=[...n.statements],x=g.indexOf(m);return g[x]=e.ts.factory.updateExportAssignment(m,m.modifiers,D),n=e.ts.factory.updateSourceFile(n,g),n=I(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=j(e,n),o.outcome="added",o}}if(!u.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(u.node)||e.ts.isCallExpression(u.node)){let f=u.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let m=f.expression;if(!e.ts.isBinaryExpression(m))throw new Error("Expected a binary expression for the default export");let c=Di(e,n);n=c.sourceFile;let d=[...n.statements],D=d.indexOf(f);return d[D]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(m,m.left,m.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[m.right]))),n=e.ts.factory.updateSourceFile(n,d),o.content=j(e,n),o.outcome="added",o}let p=u.statement;if(e.ts.isVariableStatement(p)){let f=[...p.declarationList.declarations];if(f.length!==1)throw new Error("Expected a single variable declaration");let m=f[0];if(!m.initializer)throw new Error("Expected an initializer on the declaration");let c=m.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let d=Di(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(p);return D[g]=e.ts.factory.updateVariableStatement(p,p.modifiers,e.ts.factory.updateVariableDeclarationList(p.declarationList,[e.ts.factory.updateVariableDeclaration(m,m.name,m.exclamationToken,m.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function hi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Di(e,t){let r=hi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function lp(e,t){let r=[...t.properties],n=r.findIndex(i=>L(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=xi(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=xi(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function xi(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Si(e,t,r){try{let n=await mp(e,t,r,"builderDevTools","@builder.io/dev-tools/vite");return{content:n.content,filePath:n.filePath,fileName:n.fileName,outcome:n.outcome}}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}async function mp(e,t,r,n,o){try{if(n==="builderDevTools"&&r.includes(n)&&r.includes(o)&&(r.includes(`plugins: [${n}()]`)||r.includes(`plugins: [ ${n}()]`)))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};if(n==="jsxLocPlugin"&&o==="@builder.io/vite-plugin-jsx-loc"&&r.includes(n)&&r.includes(o)&&b(e,r).statements.some(c=>{if(e.ts.isImportDeclaration(c)){let d=c.moduleSpecifier.text;if((d===o||d.includes(n))&&c.importClause?.namedBindings&&e.ts.isNamedImports(c.importClause.namedBindings))return c.importClause.namedBindings.elements.some(D=>D.name.text===n)}return!1}))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};let i=b(e,r),a=de(e,i);if(a.length!==1)throw new Error(`Expected an export from ${t}`);let s=a[0];if(!s.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let u=s.statement;if(!e.ts.isExportAssignment(u))throw new Error(`Expected an export assignment from ${t}`);let p={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(e.ts.isCallExpression(s.node)&&e.ts.isIdentifier(s.node.expression)&&s.node.expression.text==="defineConfig"){let f=[...s.node.arguments];if(f.length===0)throw new Error("Expected an argument in defineConfig()");let m=f[0];if(e.ts.isArrowFunction(m)){let c=fp(e,m,n);if(!c)return p;f[0]=e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,c);let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,f)),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}if(e.ts.isObjectLiteralExpression(m)){let c=on(e,m,n);if(!c)return p;let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,[c])),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(u.expression)){let f=on(e,u.expression,n);if(!f)return p;let m=[...i.statements],c=m.indexOf(u);return m[c]=e.ts.factory.updateExportAssignment(u,u.modifiers,f),i=e.ts.factory.updateSourceFile(i,m),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error(`Unable to parse ${t}`)}catch(i){throw e.Sentry?.captureException(i,{extra:{configFilePath:t,configContent:r},level:"warning"}),i}}function fp(e,t,r){let n=t.body;if(!e.ts.isBlock(n)){if(e.ts.isParenthesizedExpression(n)&&e.ts.isObjectLiteralExpression(n.expression)){let u=on(e,n.expression,r);if(u)return u}return null}let o=[...n.statements],i=o.findIndex(u=>e.ts.isReturnStatement(u));if(i===-1){let u=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());o.push(u),i=o.length-1}let a=o[i];if(!a.expression||!e.ts.isObjectLiteralExpression(a.expression))return null;let s=on(e,a.expression,r);return s?(o[i]=e.ts.factory.updateReturnStatement(a,s),e.ts.factory.updateBlock(n,o)):null}function on(e,t,r){if(Dp(e)){let a=dp(e,t);a&&(t=a)}let n=[...t.properties],o=n.findIndex(a=>an(e,a)==="plugins");if(o>-1){let a=n[o];if(e.ts.isPropertyAssignment(a)&&a.initializer)if(e.ts.isArrayLiteralExpression(a.initializer)){let s=Ei(e,a.initializer,r);if(s)return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,s),e.ts.factory.updateObjectLiteralExpression(t,n)}else{let s=e.ts.factory.createSpreadElement(a.initializer),u=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[]),p=e.ts.factory.createArrayLiteralExpression([s,u],!0);return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,p),e.ts.factory.updateObjectLiteralExpression(t,n)}return null}let i=Ei(e,e.ts.factory.createArrayLiteralExpression([],!0),r);return i?e.ts.factory.updateObjectLiteralExpression(t,[...n,e.ts.factory.createPropertyAssignment("plugins",i)]):null}function Ei(e,t,r){return t.elements.some(o=>{if(e.ts.isCallExpression(o)&&e.ts.isIdentifier(o.expression))return o.expression.text===r;if(e.ts.isBinaryExpression(o)&&o.operatorToken.kind===e.ts.SyntaxKind.AmpersandAmpersandToken){let i=o.right;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression))return i.expression.text===r}if(e.ts.isConditionalExpression(o)){let i=o.whenTrue,a=o.whenFalse;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression)&&i.expression.text===r||e.ts.isCallExpression(a)&&e.ts.isIdentifier(a.expression)&&a.expression.text===r)return!0}if(e.ts.isCallExpression(o)&&e.ts.isPropertyAccessExpression(o.expression)){let i=o.expression.expression;if(e.ts.isArrayLiteralExpression(i))return i.elements.some(a=>Lt(e,a,r))}return!1})?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[])])}function Lt(e,t,r){return e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)?t.expression.text===r:e.ts.isBinaryExpression(t)?Lt(e,t.left,r)||Lt(e,t.right,r):e.ts.isConditionalExpression(t)?Lt(e,t.whenTrue,r)||Lt(e,t.whenFalse,r):!1}function dp(e,t){let r=[...t.properties],n=r.findIndex(i=>an(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=gp(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=er(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=r.findIndex(u=>an(e,u)==="plugins"),a=[...r],s=e.ts.factory.createPropertyAssignment("ssr",e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]));return i>-1?a.splice(i,0,s):a.push(s),e.ts.factory.updateObjectLiteralExpression(t,a)}return null}function gp(e,t){let r=[...t.properties],n=r.findIndex(i=>an(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=er(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=er(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function er(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function an(e,t){return(e.ts.isPropertyAssignment(t)||e.ts.isMethodDeclaration(t))&&(e.ts.isIdentifier(t.name)||e.ts.isStringLiteral(t.name))?t.name.text:""}function Dp(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Ai(e,t,r){return e.debug("Updating Webpack config to include Builder.io plugin..."),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function Pi(e,t,r){e.debug("Angular config updates are currently in progress...");try{await hp(e)}catch(n){e.Sentry?.captureException(new Error("Unable to update package.json.",{cause:n}))}return await xp(e),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function xp(e){let t=e.getAppRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await Cp(e,o);await e.writeFile(n,i)}async function Cp(e,t){let r=t,n=b(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=I(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
1062
+ Expected types: ${e.ts.SyntaxKind.ObjectLiteralExpression} or ${e.ts.SyntaxKind.CallExpression}`)}if(e.ts.isArrowFunction(p.node)){let m=p.node,c=p.statement;if(!e.ts.isExpressionStatement(c))throw new Error("Expected an expression statement for the default export");let d=c.expression;if(!e.ts.isBinaryExpression(d))throw new Error("Expected a binary expression for the default export");let g=p.node.body;if(!e.ts.isBlock(g))throw new Error("Expected a block body on the next config function");let x=[...g.statements],l=x.findIndex(S=>e.ts.isReturnStatement(S));if(l===-1)throw new Error("Expected a return statement on the next config function");let C=x[l],E=er(e,n);n=E.sourceFile,x[l]=e.ts.factory.updateReturnStatement(C,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(E.withFnVariableName),void 0,[C.expression]));let F=[...n.statements],A=F.indexOf(c);return F[A]=e.ts.factory.updateExpressionStatement(c,e.ts.factory.updateBinaryExpression(d,d.left,d.operatorToken,e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,e.ts.factory.updateBlock(g,x)))),n=e.ts.factory.updateSourceFile(n,F),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function gi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function er(e,t){let r=gi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function Ci(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(hi(e,n))return o;let a=de(e,n,"cjs"),s=de(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let u=a[0];if(s.length===1){let f=s[0];if(!f.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let m=f.statement;if(!e.ts.isExportAssignment(m))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(m.expression)){let c="builderDevTools()",d=lp(e,m.expression);if(!d)return o;let D=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[d]),g=[...n.statements],x=g.indexOf(m);return g[x]=e.ts.factory.updateExportAssignment(m,m.modifiers,D),n=e.ts.factory.updateSourceFile(n,g),n=I(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=j(e,n),o.outcome="added",o}}if(!u.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(u.node)||e.ts.isCallExpression(u.node)){let f=u.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let m=f.expression;if(!e.ts.isBinaryExpression(m))throw new Error("Expected a binary expression for the default export");let c=Di(e,n);n=c.sourceFile;let d=[...n.statements],D=d.indexOf(f);return d[D]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(m,m.left,m.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[m.right]))),n=e.ts.factory.updateSourceFile(n,d),o.content=j(e,n),o.outcome="added",o}let p=u.statement;if(e.ts.isVariableStatement(p)){let f=[...p.declarationList.declarations];if(f.length!==1)throw new Error("Expected a single variable declaration");let m=f[0];if(!m.initializer)throw new Error("Expected an initializer on the declaration");let c=m.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let d=Di(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(p);return D[g]=e.ts.factory.updateVariableStatement(p,p.modifiers,e.ts.factory.updateVariableDeclarationList(p.declarationList,[e.ts.factory.updateVariableDeclaration(m,m.name,m.exclamationToken,m.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function hi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Di(e,t){let r=hi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function lp(e,t){let r=[...t.properties],n=r.findIndex(i=>L(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=xi(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=xi(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function xi(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Si(e,t,r){try{let n=await mp(e,t,r,"builderDevTools","@builder.io/dev-tools/vite");return{content:n.content,filePath:n.filePath,fileName:n.fileName,outcome:n.outcome}}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}async function mp(e,t,r,n,o){try{if(n==="builderDevTools"&&r.includes(n)&&r.includes(o)&&(r.includes(`plugins: [${n}()]`)||r.includes(`plugins: [ ${n}()]`)))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};if(n==="jsxLocPlugin"&&o==="@builder.io/vite-plugin-jsx-loc"&&r.includes(n)&&r.includes(o)&&b(e,r).statements.some(c=>{if(e.ts.isImportDeclaration(c)){let d=c.moduleSpecifier.text;if((d===o||d.includes(n))&&c.importClause?.namedBindings&&e.ts.isNamedImports(c.importClause.namedBindings))return c.importClause.namedBindings.elements.some(D=>D.name.text===n)}return!1}))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};let i=b(e,r),a=de(e,i);if(a.length!==1)throw new Error(`Expected an export from ${t}`);let s=a[0];if(!s.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let u=s.statement;if(!e.ts.isExportAssignment(u))throw new Error(`Expected an export assignment from ${t}`);let p={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(e.ts.isCallExpression(s.node)&&e.ts.isIdentifier(s.node.expression)&&s.node.expression.text==="defineConfig"){let f=[...s.node.arguments];if(f.length===0)throw new Error("Expected an argument in defineConfig()");let m=f[0];if(e.ts.isArrowFunction(m)){let c=fp(e,m,n);if(!c)return p;f[0]=e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,c);let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,f)),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}if(e.ts.isObjectLiteralExpression(m)){let c=on(e,m,n);if(!c)return p;let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,[c])),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(u.expression)){let f=on(e,u.expression,n);if(!f)return p;let m=[...i.statements],c=m.indexOf(u);return m[c]=e.ts.factory.updateExportAssignment(u,u.modifiers,f),i=e.ts.factory.updateSourceFile(i,m),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error(`Unable to parse ${t}`)}catch(i){throw e.Sentry?.captureException(i,{extra:{configFilePath:t,configContent:r},level:"warning"}),i}}function fp(e,t,r){let n=t.body;if(!e.ts.isBlock(n)){if(e.ts.isParenthesizedExpression(n)&&e.ts.isObjectLiteralExpression(n.expression)){let u=on(e,n.expression,r);if(u)return u}return null}let o=[...n.statements],i=o.findIndex(u=>e.ts.isReturnStatement(u));if(i===-1){let u=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());o.push(u),i=o.length-1}let a=o[i];if(!a.expression||!e.ts.isObjectLiteralExpression(a.expression))return null;let s=on(e,a.expression,r);return s?(o[i]=e.ts.factory.updateReturnStatement(a,s),e.ts.factory.updateBlock(n,o)):null}function on(e,t,r){if(Dp(e)){let a=dp(e,t);a&&(t=a)}let n=[...t.properties],o=n.findIndex(a=>an(e,a)==="plugins");if(o>-1){let a=n[o];if(e.ts.isPropertyAssignment(a)&&a.initializer)if(e.ts.isArrayLiteralExpression(a.initializer)){let s=Ei(e,a.initializer,r);if(s)return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,s),e.ts.factory.updateObjectLiteralExpression(t,n)}else{let s=e.ts.factory.createSpreadElement(a.initializer),u=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[]),p=e.ts.factory.createArrayLiteralExpression([s,u],!0);return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,p),e.ts.factory.updateObjectLiteralExpression(t,n)}return null}let i=Ei(e,e.ts.factory.createArrayLiteralExpression([],!0),r);return i?e.ts.factory.updateObjectLiteralExpression(t,[...n,e.ts.factory.createPropertyAssignment("plugins",i)]):null}function Ei(e,t,r){return t.elements.some(o=>{if(e.ts.isCallExpression(o)&&e.ts.isIdentifier(o.expression))return o.expression.text===r;if(e.ts.isBinaryExpression(o)&&o.operatorToken.kind===e.ts.SyntaxKind.AmpersandAmpersandToken){let i=o.right;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression))return i.expression.text===r}if(e.ts.isConditionalExpression(o)){let i=o.whenTrue,a=o.whenFalse;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression)&&i.expression.text===r||e.ts.isCallExpression(a)&&e.ts.isIdentifier(a.expression)&&a.expression.text===r)return!0}if(e.ts.isCallExpression(o)&&e.ts.isPropertyAccessExpression(o.expression)){let i=o.expression.expression;if(e.ts.isArrayLiteralExpression(i))return i.elements.some(a=>Lt(e,a,r))}return!1})?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[])])}function Lt(e,t,r){return e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)?t.expression.text===r:e.ts.isBinaryExpression(t)?Lt(e,t.left,r)||Lt(e,t.right,r):e.ts.isConditionalExpression(t)?Lt(e,t.whenTrue,r)||Lt(e,t.whenFalse,r):!1}function dp(e,t){let r=[...t.properties],n=r.findIndex(i=>an(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=gp(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=tr(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=r.findIndex(u=>an(e,u)==="plugins"),a=[...r],s=e.ts.factory.createPropertyAssignment("ssr",e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]));return i>-1?a.splice(i,0,s):a.push(s),e.ts.factory.updateObjectLiteralExpression(t,a)}return null}function gp(e,t){let r=[...t.properties],n=r.findIndex(i=>an(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=tr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=tr(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function tr(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function an(e,t){return(e.ts.isPropertyAssignment(t)||e.ts.isMethodDeclaration(t))&&(e.ts.isIdentifier(t.name)||e.ts.isStringLiteral(t.name))?t.name.text:""}function Dp(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Ai(e,t,r){return e.debug("Updating Webpack config to include Builder.io plugin..."),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function Pi(e,t,r){e.debug("Angular config updates are currently in progress...");try{await hp(e)}catch(n){e.Sentry?.captureException(new Error("Unable to update package.json.",{cause:n}))}return await xp(e),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function xp(e){let t=e.getAppRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await Cp(e,o);await e.writeFile(n,i)}async function Cp(e,t){let r=t,n=b(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=I(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
1063
1063
  builderDevTools().catch((err: Error) =>
1064
1064
  console.error("Error starting dev tools:", err)
1065
1065
  );`;return r=j(e,n),o||(r+=i),r}async function hp(e){let t=e.getRepoRootDir(),r=e.join(t,"package.json"),n=await e.readFile(r);if(!n)throw new Error(`Unable to read package.json at ${r}`);let o=Ep(e,n);o&&await e.writeFile(r,o)}function Ep(e,t){let r=JSON.parse(t);if(r.scripts=r.scripts||{},r.scripts[Fi])return;let n=r.scripts.start||r.scripts.dev||"ng serve";if(!n.includes("concurrently")){let o=e.getRepoRootDir(),i=e.getAppRootDir(),a=o===i?"":` --cwd ${e.relative(o,i)}`,s=`concurrently "${n}" "${Sp}${a}"`;r.scripts.start=s,r.scripts[Fi]=s}return JSON.stringify(r,null,2)+`
1066
- `}var Fi="builder-dev",Sp="npx builder-dev-tools";var wi=[{id:"next",configFileNames:["next.config.ts","next.config.js","next.config.mjs"],ensureConfigPlugin:di},{id:"vite",configFileNames:["vite.config.ts","vite.config.js"],ensureConfigPlugin:Si},{id:"remix",configFileNames:["remix.config.ts","remix.config.js"],ensureConfigPlugin:Ci},{id:"webpack",configFileNames:["webpack.config.ts","webpack.config.js"],ensureConfigPlugin:Ai},{id:"angular",configFileNames:["angular.json","project.json"],ensureConfigPlugin:Pi}];async function tr(e){let t=e.resolve("/");for(let n of wi)for(let o of n.configFileNames){let i=e.getAppRootDir();for(let a=0;a<10;a++)try{let s=e.join(i,o),u=e.readFileSync(s);if(typeof u=="string")return{id:n.id,filePath:s,content:u};if(i===t)break;i=e.dirname(i)}catch(s){if((s?.message??"").includes("Invalid path"))break;throw s}}if((await Ue(e)).some(n=>n.name==="next")){let n=e.join(e.getAppRootDir(),"next.config.js");return await e.writeFile(n,yi),{id:"next",filePath:n,content:yi}}return null}async function vi(e){let t=await tr(e);if(!t)throw new Error("Unable to find config file, such as next.config.js or vite.config.js.");let n=await wi.find(o=>o.id===t.id).ensureConfigPlugin(e,t.filePath,t.content);return(n.outcome==="added"||n.outcome==="already-exists")&&(e.debug(`Successfully updated ${t.filePath}`),n.content=De(n.content),n.content=await e.formatCode(n.filePath,n.content),await e.writeFile(t.filePath,n.content)),n}var yi=`
1066
+ `}var Fi="builder-dev",Sp="npx builder-dev-tools";var wi=[{id:"next",configFileNames:["next.config.ts","next.config.js","next.config.mjs"],ensureConfigPlugin:di},{id:"vite",configFileNames:["vite.config.ts","vite.config.js"],ensureConfigPlugin:Si},{id:"remix",configFileNames:["remix.config.ts","remix.config.js"],ensureConfigPlugin:Ci},{id:"webpack",configFileNames:["webpack.config.ts","webpack.config.js"],ensureConfigPlugin:Ai},{id:"angular",configFileNames:["angular.json","project.json"],ensureConfigPlugin:Pi}];async function nr(e){let t=e.resolve("/");for(let n of wi)for(let o of n.configFileNames){let i=e.getAppRootDir();for(let a=0;a<10;a++)try{let s=e.join(i,o),u=e.readFileSync(s);if(typeof u=="string")return{id:n.id,filePath:s,content:u};if(i===t)break;i=e.dirname(i)}catch(s){if((s?.message??"").includes("Invalid path"))break;throw s}}if((await Ue(e)).some(n=>n.name==="next")){let n=e.join(e.getAppRootDir(),"next.config.js");return await e.writeFile(n,yi),{id:"next",filePath:n,content:yi}}return null}async function vi(e){let t=await nr(e);if(!t)throw new Error("Unable to find config file, such as next.config.js or vite.config.js.");let n=await wi.find(o=>o.id===t.id).ensureConfigPlugin(e,t.filePath,t.content);return(n.outcome==="added"||n.outcome==="already-exists")&&(e.debug(`Successfully updated ${t.filePath}`),n.content=De(n.content),n.content=await e.formatCode(n.filePath,n.content),await e.writeFile(t.filePath,n.content)),n}var yi=`
1067
1067
  /** @type {import('next').NextConfig} */
1068
1068
  const nextConfig = {
1069
1069
  }
@@ -1082,4 +1082,4 @@ module.exports = nextConfig
1082
1082
  `,n+=` }
1083
1083
  `,n+=` }
1084
1084
  `,n+=`})();
1085
- `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var _t=or;
1085
+ `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var _t=ir;