UNPKG

@builder.io/dev-tools

Version:

Builder.io Visual CMS Devtools

23 lines (21 loc) 221 kB
import { createRequire } from 'module'; const require = createRequire(import.meta.url); var Fi=Object.create;var Gn=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var yi=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,vi=Object.prototype.hasOwnProperty;var Le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ti=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yi(t))!vi.call(e,o)&&o!==r&&Gn(e,o,{get:()=>t[o],enumerable:!(n=Pi(t,o))||n.enumerable});return e};var Hn=(e,t,r)=>(r=e!=null?Fi(wi(e)):{},Ti(t||!e||!e.__esModule?Gn(r,"default",{value:e,enumerable:!0}):r,e));var tr=Le((Ep,er)=>{"use strict";er.exports=function(){if(process.env.npm_config_user_agent)return Ri(process.env.npm_config_user_agent)};function Ri(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 Bn=Le(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.throwUnsupportedData=qe.throwUnknownDataType=qe.getType=void 0;function qo(e){return Object.prototype.toString.call(e)}qe.getType=qo;function Ru(e){throw new TypeError("unsupported data type: "+qo(e))}qe.throwUnknownDataType=Ru;function Nu(e){throw new TypeError("unsupported data type: "+e)}qe.throwUnsupportedData=Nu});var jn=Le(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.s_to_num=H.int_str_to_s=H.num_to_s=H.big_int_to_s=H.int_to_s=H.s_to_big_int=H.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 ft=Ke.length,kn={};for(let e=0;e<ft;e++){let t=Ke[e];kn[t]=e}function Ln(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*=ft}return t}H.s_to_int=Ln;function Jo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(ft);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}H.s_to_big_int=Jo;function _n(e){if(e===0)return Ke[0];let t=[];for(;e!==0;){let r=e%ft,n=Ke[r];t.push(n),e-=r,e/=ft}return t.reverse().join("")}H.int_to_s=_n;function Wo(e){let t=BigInt(0),r=BigInt(ft);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("")}H.big_int_to_s=Wo;function Qo(e){return e.split("").reverse().join("")}function Yo(e){if(e<0)return"-"+Yo(-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 _n(e);let n;r&&([r,n]=r.split("e")),t=Gt(t),r=Qo(r),r=Gt(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=Gt(n),o+=n}return o}H.num_to_s=Yo;function Gt(e){let t=+e;return t.toString()===e&&t+1!==t&&t-1!==t?_n(t):":"+Wo(BigInt(e))}H.int_str_to_s=Gt;function On(e){return e[0]===":"?Jo(e.substring(1)).toString():Ln(e).toString()}function Go(e){if(e[0]==="-")return-Go(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Ln(t);t=On(t),r=On(r),r=Qo(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=On(n),o+=i?-n:+n}return+o}H.s_to_num=Go});var $n=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 Vn=jn();function Bu(e){return"n|"+(0,Vn.num_to_s)(e)}X.encodeNum=Bu;function Ou(e){return e=e.replace("n|",""),(0,Vn.s_to_num)(e)}X.decodeNum=Ou;function ku(e){return typeof e=="number"?e:(0,Vn.s_to_int)(e)}X.decodeKey=ku;function Lu(e){return e?"b|T":"b|F"}X.encodeBool=Lu;function _u(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}X.decodeBool=_u;function ju(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}X.encodeStr=ju;function Vu(e){return e[0]+e[1]==="s|"?e.substr(2):e}X.decodeStr=Vu});var Kn=Le(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.config=void 0;Ht.config={sort_key:!1,error_on_nan:!1,error_on_infinite:!1}});var qn=Le(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.addValue=xe.makeInMemoryMemory=xe.makeInMemoryCache=xe.makeInMemoryStore=xe.memToValues=void 0;var zn=Kn(),Mn=Bn(),Un=$n(),$u=jn();function Ku(e){return e.store.toArray()}xe.memToValues=Ku;function Ho(){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=Ho;function Xo(){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=Xo;function Mu(){return{store:Ho(),cache:Xo(),keyCount:0}}xe.makeInMemoryMemory=Mu;function tt(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=(0,$u.num_to_s)(r);return e.store.add(t),e.cache.setValue(t,n),n}function Uu(e,t){zn.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=Nt(e,t,void 0);return e.cache.setSchema(r,n),n}function Nt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return Nt(e,null,r);break;case"object":if(t===null)return tt(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":Nt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),tt(e,n)}else{let n=Object.keys(t);if(n.length===0)return tt(e,"o|");let o="o",i=Uu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=Nt(e,s,t);o+="|"+u}return tt(e,o)}case"boolean":return tt(e,(0,Un.encodeBool)(t));case"number":return Number.isNaN(t)?(zn.config.error_on_nan&&(0,Mn.throwUnsupportedData)("[number NaN]"),""):Number.POSITIVE_INFINITY===t||Number.NEGATIVE_INFINITY===t?(zn.config.error_on_infinite&&(0,Mn.throwUnsupportedData)("[number Infinity]"),""):tt(e,(0,Un.encodeNum)(t));case"string":return tt(e,(0,Un.encodeStr)(t))}return(0,Mn.throwUnknownDataType)(t)}xe.addValue=Nt});var Wn=Le(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.decompress=Je.decode=Je.compress=void 0;var zu=Bn(),Xt=$n(),Jn=qn();function qu(e){let t=(0,Jn.makeInMemoryMemory)(),r=(0,Jn.addValue)(t,e,void 0);return[(0,Jn.memToValues)(t),r]}Je.compress=qu;function Ju(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=Bt(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=Bt(e,p),r[u]=p}return r}function Wu(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=Bt(e,a),o[i]=a}return o}function Bt(e,t){if(t===""||t==="_")return null;let r=(0,Xt.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,Xt.decodeBool)(n);case"o|":return Ju(e,n);case"n|":return(0,Xt.decodeNum)(n);case"a|":return Wu(e,n);default:return(0,Xt.decodeStr)(n)}}return(0,zu.throwUnknownDataType)(n)}Je.decode=Bt;function Qu(e){let[t,r]=e;return Bt(t,r)}Je.decompress=Qu});var ei=Le(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.trimUndefinedRecursively=dt.trimUndefined=void 0;function Yu(e){for(let t in e)e[t]===void 0&&delete e[t]}dt.trimUndefined=Yu;function Gu(e){Zo(e,new Set)}dt.trimUndefinedRecursively=Gu;function Zo(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)&&Zo(n,t)}}});var ri=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 ti=Wn();Object.defineProperty(Z,"compress",{enumerable:!0,get:function(){return ti.compress}});Object.defineProperty(Z,"decompress",{enumerable:!0,get:function(){return ti.decompress}});var Hu=Wn();Object.defineProperty(Z,"decode",{enumerable:!0,get:function(){return Hu.decode}});var Xu=qn();Object.defineProperty(Z,"addValue",{enumerable:!0,get:function(){return Xu.addValue}});var ni=ei();Object.defineProperty(Z,"trimUndefined",{enumerable:!0,get:function(){return ni.trimUndefined}});Object.defineProperty(Z,"trimUndefinedRecursively",{enumerable:!0,get:function(){return ni.trimUndefinedRecursively}});var Zu=Kn();Object.defineProperty(Z,"config",{enumerable:!0,get:function(){return Zu.config}})});var bi="1.6.124",Xn=process.env.OVERRIDE_VERSION??bi;function ne(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var Ii=["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(Ii.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 gt(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 Zn(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 Dt(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 Dt(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var rr=Hn(tr(),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 Qe(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return nr(o==="index"?e.basename(e.dirname(t)):o)}function nr(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 xt(e){return typeof e=="number"}function nt(e){return typeof e=="boolean"}function re(e){return typeof e=="string"}function rt(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function ue(e){return JSON.parse(JSON.stringify(e))}function kt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function or(){try{let e=(0,rr.default)();if(e?.name)return e.name}catch{}return"npm"}async function Ye(e){let t=[],r=await gt(e,e.getRepoRootDir());if(r){let n=await sr(r,e);t.push(...n)}return t}async function ar(e){let t=await gt(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function sr(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Ni)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};ir.has(o)&&(i.version=await ir.get(o)(t)),r.push(i)}}return r}function rn(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var ir=new Map([["next",async e=>{if(!e.spawnSync)return;let t=or(),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:rn(a),minor:rn(s),patch:rn(u)}}]]),Ni=["@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=ur(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=ur(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function ur(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 Bi(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 Bi(e,t){let r=await e.readFile(t);return typeof r=="string"?pr(r):null}function pr(e){let t={},r=e.replace(/\r\n?/gm,` `),n;for(;(n=Oi.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,` `),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var Oi=/(?:^|^)\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+=` ${o} ${r}=${n} `,await e.writeFile(t,i),"update";else return e.debug(`Creating new .env file with "${r}" at ${t}`),i=[o,`${r}=${n}`,""].join(` `),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 Ct(e){return await Fe(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],ye)}async function cr(e,t){let r=await Ct(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 Lt(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()+` `:n.printNode(e.ts.EmitHint.Unspecified,t,e.ts.createSourceFile("module.tsx","",e.ts.ScriptTarget.Latest)).trim()+` `}return""}function ot(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=ki(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,ht(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,ht(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function ki(e,t,r){return t.properties.findIndex(n=>L(e,n)===r)}function Et(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return _i(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return Li(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 Li(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]=Et(e,n.initializer))}}return r}function _i(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>Et(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 ht(e,t){return on(e,t,new WeakSet)}function on(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)?ji(e,t,r):typeof t=="object"?Vi(e,t,r):e.ts.factory.createIdentifier(t)}function ji(e,t,r){let n=t.map(o=>on(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Vi(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,on(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=$i(e,t,i);a&&n.push(a)}return n=n.filter(mr),n.length>0?n:Ki(e,r)}function $i(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=an(p);f.knownType?i=f.builderType:Ui(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=Wi(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(qi)?s.enum=u.map(Ji):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function Ki(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(mr)}var Mi=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function Ui(e){return typeof e!="string"?!1:!!Mi.some(t=>e.includes(t))}function an(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 qi(e){return/^['"].*['"]$/.test(e)}function Ji(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var Wi=(e,t,r)=>{let n=new Set;lr(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},Qi=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},lr=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{lr(e,t,o,n)});else if(r.isLiteral()){let o=Qi(e,t,r);n.add(o)}};function mr(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!Yi.has(t.toLowerCase())}var Yi=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=Gi(e,n.initializer);pe(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=Et(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function Gi(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(Hi(e,n));return r}function Hi(e,t){let r=Et(e,t),n=oa(r);return n.isRegistered=!0,n}function W(e,t,r){let n=Zi(r);return t=ot(e,t,"name",n.name,!1),t=ot(e,t,"description",n.description),t=ot(e,t,"image",n.image),t=ot(e,t,"meta",n.meta),t=Xi(e,t,n),ia(e,t)}function Xi(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 ot(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=ta(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 Zi(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(ea),...e.meta?{meta:{...e.meta}}:{}}}function ea(e){let t={name:e.name,type:e.type};return(re(e.defaultValue)||xt(e.defaultValue)||nt(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 ta(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=na(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 na(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]=fr(e,t[n],r);else{let o=fr(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function fr(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=ra(e,n,r,i);return n=aa(e,n.filter(i=>{let a=L(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function ra(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,ht(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,ht(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=sn(e)}function oa(e){let t=an(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)||xt(e.defaultValue)||nt(e.defaultValue))&&(r.defaultValue=e.defaultValue),re(e.helperText)&&(r.helperText=e.helperText),nt(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),un(r)}function sn(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 un(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 ia(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=dr.indexOf(i),u=dr.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 dr=["component","name","description"];function aa(e,t){return[...t].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz",s=gr.indexOf(i),u=gr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var gr=["name","type"];function it(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 Dr(e,t){let r=`Builder.registerComponent( `;if(e.appDir)t.acceptsChildren?r+=` withChildren(${t.importName}), `:r+=` ${t.importName}, `;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)}))), `:r+=` dynamic(() => import(${JSON.stringify(o)})), `:t.acceptsChildren?r+=` withChildren(dynamic(async () => (await import(${JSON.stringify(o)})).${t.exportName})), `:r+=` dynamic(async () => (await import(${JSON.stringify(o)})).${t.exportName}), `}r+=` { name: "${t.name}", } `,r+=");";let n=Lt(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;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 G(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let n=await Zn(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=St.get(s);if(!u){try{e.statSync(s).isFile()?u={exists:!0,content:e.readFileSync(s)}:u={exists:!1}}catch{u={exists:!1}}St.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:()=>` `,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=St.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=Cr.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new jt(p)}return s.includes("node_modules")&&(u?St.set(s,{exists:!0,content:u}):St.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 sa(e,a,t,r)}catch(s){if(s instanceof jt){await ua(e,s.libName);continue}throw e.Sentry?.captureException(s),new Error(`createTsProgram() Could not create program for: ${t[0]}`,{cause:s})}}function sa(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=xr.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,xr.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 at(e,t,r){r||(r=await G(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 jt=class{constructor(t){this.libName=t}};async function ua(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=>{Cr.set(t,n)})),await _t.get(t),_t.delete(t)}var Cr=new Map,_t=new Map,St=new Map,xr=new Map;function I(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=pa(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=ca(e,t,r.defaultImport,r.importPath,n)),t}function pa(e,t,r,n,o,i){return i==="cjs"?Er(e,t,null,r,n):hr(e,t,null,r,n,o)}function ca(e,t,r,n,o){return o==="cjs"?Er(e,t,r,null,n):hr(e,t,r,null,n,!1)}function hr(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 Er(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"?ma(e,t):la(e,t)}function la(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 ma(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 fa(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=fa(e,r,n);if(o){let i=await At(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 st(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=st(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 Vt(e,t){if(t){if(da(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Vt(e,n)&&(r=!0)}),r)return!0}return!1}function da(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 At(e,t){let r=e.extname(t).toLowerCase();if(r===""||!cn.includes(r)){for(let n of cn){let o=t+n;if(await e.exists(o))return o}for(let n of cn){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var cn=[".tsx",".jsx",".ts",".js"];function ut(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=ga(e,i);return a?[{name:a}]:void 0}function ga(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 Sr(e,t,r="esm"){return r==="cjs"?Ca(e,t):xa(e,t)}var Da=/^(@\w|\w)/;function xa(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!Da.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 Ca(e,t){return[]}async function pt(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await G(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 Me(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 ct(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await at(e,t.cmpInfo.filePath,r),s=(await Me(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 Fr(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 ha(e,t,o,r)}return null}function ha(e,t,r,n=!1){let o=b(e,r);return Me(e,null,t,o,n)}async function Me(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(...Sr(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await Ea(e,t,r,s);i.push(...u)})),i}async function Ea(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)||!rt(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:Qe(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&&!rt(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||Qe(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))&&rt(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=Sa(e,n.node)?.moduleSpecifier??Aa(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||Qe(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 Pa(e,t,r,s);o.push(...u)}return o}return o}function Sa(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function Aa(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 Vt(e,r.body)?{name:"",fnNode:r,deps:ut(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Vt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:ut(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)||!rt(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:ut(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:ut(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:ut(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 Pr(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(kt(e,Fa,i.fileName)||a===e.reactConfigPath||a===e.builderComponentPath)return;let s=await Me(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Fa=new Set(["node_modules","dist"]);async function Pa(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(!rt(f)&&f!=="default"||!yr(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"?Qe(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 yr(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 yr(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowF