@fugood/bricks-cli 2.25.1-beta.6 → 2.25.2-beta.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/lib/2486.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(1826),a.e(6645),a.e(4479),a.e(7648),a.e(6042),a.e(1010),a.e(7233)]).then(a.bind(a,63288)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),k=(e,r,a)=>({severity:e,code:r,message:a}),h=(o=t(function*({version:e="2.25.1-beta.6",mcpCheck:r=u}={}){var a=(0,p.getCurrentProfile)(),i=(0,p.getCurrentProfileSource)(),o=(0,n.getConnectionContext)(a),t=o.tokenInfo,h=o.auth,d=o.baseUrl,v=o.activityLogBaseUrl,m=[],w={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:p.CONFIG_PATH,baseUrl:d,activityLogBaseUrl:v},auth:{available:!!h,source:h?"config":"missing",kind:h?.kind||null,workspaceId:t?.workspaceId||null,workspaceName:t?.workspaceName||null,createdAt:t?.createdAt||null,tokenPreview:h?.kind==="token"?(0,l.$l)(h.token):null},connectivity:{workspace:{ok:!1,skipped:!h,error:null}},capabilities:{zeroArgMode:(0,c.isInteractiveTerminal)()?"interactive":"help",mcp:{available:!1,error:null}},issues:m};if(h)try{var b=yield(0,s.createClient)(d,h).workspace();w.connectivity.workspace={ok:!0,skipped:!1,error:null,id:b?._id||t.workspaceId||null,name:b?.name||t.workspaceName||null},w.auth.workspaceId=b?._id||w.auth.workspaceId,w.auth.workspaceName=b?.name||w.auth.workspaceName}catch(e){w.connectivity.workspace={ok:!1,skipped:!1,error:e.message},m.push(k("error","workspace_unreachable",`Workspace query failed for ${d}: ${e.message}`))}else m.push(k("warning","auth_missing","No usable credential for the current profile."));var f=yield r();return w.capabilities.mcp={available:f.available,error:f.error||null},f.available||m.push(k("warning","mcp_unavailable",`MCP stdio server is unavailable: ${f.error||"Unknown error"}`)),w.ok=0===m.length,w}),function(){return o.apply(this,arguments)}),d=(e,r,a)=>`${e.padEnd(14)} ${r}${a?` ${a}`:""}`,v=e=>{var r=[];if(r.push("BRICKS CLI Doctor"),r.push("─".repeat(60)),r.push(d("CLI","OK",`bricks v${e.cli.version}`)),r.push(d("Profile","OK",`${e.profile.name} (${e.profile.source})`)),r.push(d("BRICKS API","OK",e.config.baseUrl)),r.push(d("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace",i=[e.auth.source,e.auth.kind,e.auth.tokenPreview].filter(Boolean).join(", ");r.push(d("Auth","OK",i?`${a} (${i})`:a))}else r.push(d("Auth","WARN","No usable credential for the current profile"));if(e.connectivity.workspace.skipped)r.push(d("Workspace","WARN","Skipped because no credential is available"));else if(e.connectivity.workspace.ok){var o=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";r.push(d("Workspace","OK",o))}else r.push(d("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?r.push(d("MCP","OK","STDIO server import is available")):r.push(d("MCP","WARN",e.capabilities.mcp.error)),r.push(d("Zero-arg mode",((e,r=!1)=>e?"OK":r?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(r.push("─".repeat(60)),r.push("Issues"),e.issues.forEach(e=>{r.push(`- [${e.severity}] ${e.message}`)})),r.join("\n")}}};
1
+ export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(1826),a.e(6645),a.e(4479),a.e(7648),a.e(6042),a.e(1010),a.e(7233)]).then(a.bind(a,63288)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),k=(e,r,a)=>({severity:e,code:r,message:a}),h=(o=t(function*({version:e="2.25.2-beta.0",mcpCheck:r=u}={}){var a=(0,p.getCurrentProfile)(),i=(0,p.getCurrentProfileSource)(),o=(0,n.getConnectionContext)(a),t=o.tokenInfo,h=o.auth,d=o.baseUrl,v=o.activityLogBaseUrl,m=[],w={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:p.CONFIG_PATH,baseUrl:d,activityLogBaseUrl:v},auth:{available:!!h,source:h?"config":"missing",kind:h?.kind||null,workspaceId:t?.workspaceId||null,workspaceName:t?.workspaceName||null,createdAt:t?.createdAt||null,tokenPreview:h?.kind==="token"?(0,l.$l)(h.token):null},connectivity:{workspace:{ok:!1,skipped:!h,error:null}},capabilities:{zeroArgMode:(0,c.isInteractiveTerminal)()?"interactive":"help",mcp:{available:!1,error:null}},issues:m};if(h)try{var b=yield(0,s.createClient)(d,h).workspace();w.connectivity.workspace={ok:!0,skipped:!1,error:null,id:b?._id||t.workspaceId||null,name:b?.name||t.workspaceName||null},w.auth.workspaceId=b?._id||w.auth.workspaceId,w.auth.workspaceName=b?.name||w.auth.workspaceName}catch(e){w.connectivity.workspace={ok:!1,skipped:!1,error:e.message},m.push(k("error","workspace_unreachable",`Workspace query failed for ${d}: ${e.message}`))}else m.push(k("warning","auth_missing","No usable credential for the current profile."));var f=yield r();return w.capabilities.mcp={available:f.available,error:f.error||null},f.available||m.push(k("warning","mcp_unavailable",`MCP stdio server is unavailable: ${f.error||"Unknown error"}`)),w.ok=0===m.length,w}),function(){return o.apply(this,arguments)}),d=(e,r,a)=>`${e.padEnd(14)} ${r}${a?` ${a}`:""}`,v=e=>{var r=[];if(r.push("BRICKS CLI Doctor"),r.push("─".repeat(60)),r.push(d("CLI","OK",`bricks v${e.cli.version}`)),r.push(d("Profile","OK",`${e.profile.name} (${e.profile.source})`)),r.push(d("BRICKS API","OK",e.config.baseUrl)),r.push(d("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace",i=[e.auth.source,e.auth.kind,e.auth.tokenPreview].filter(Boolean).join(", ");r.push(d("Auth","OK",i?`${a} (${i})`:a))}else r.push(d("Auth","WARN","No usable credential for the current profile"));if(e.connectivity.workspace.skipped)r.push(d("Workspace","WARN","Skipped because no credential is available"));else if(e.connectivity.workspace.ok){var o=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";r.push(d("Workspace","OK",o))}else r.push(d("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?r.push(d("MCP","OK","STDIO server import is available")):r.push(d("MCP","WARN",e.capabilities.mcp.error)),r.push(d("Zero-arg mode",((e,r=!1)=>e?"OK":r?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(r.push("─".repeat(60)),r.push("Issues"),e.issues.forEach(e=>{r.push(`- [${e.severity}] ${e.message}`)})),r.join("\n")}}};
package/lib/3774.js CHANGED
@@ -1,8 +1,8 @@
1
- export const __rspack_esm_id=3774;export const __rspack_esm_ids=[3774];export const __webpack_modules__={79491(e){e.exports=import("oxfmt").then(function(e){return e})},48875(e,t){let r=["title","update_timestamp"],i=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),n=e=>void 0===e||"function"==typeof e||"symbol"==typeof e,a=e=>"number"!=typeof e||Number.isFinite(e)?e:null,s=e=>{if(!n(e))return Array.isArray(e)?e.map(e=>n(e)?null:s(e)):i(e)?Object.entries(e).reduce((e,[t,r])=>(n(r)||(e[t]=s(r)),e),{}):a(e)},o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)&&!n(e[t]),l=(e,t)=>{let r=e[t];return n(r)?null:r},d=(e,t)=>{if((e=a(e))===(t=a(t)))return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!d(l(e,r),l(t,r)))return!1;return!0}if(i(e)&&i(t)){let r=0;for(let i of Object.keys(e))if(!n(e[i])&&(r+=1,!o(t,i)||!d(e[i],t[i])))return!1;let i=0;for(let e of Object.keys(t))n(t[e])||(i+=1);return r===i}return!1},c=e=>{if(!i(e))return e;let t={...e};for(let e of r)delete t[e];return t},p=(e,t,r,n)=>{if(!d(e,t)){if(i(e)&&i(t)){for(let i of new Set([...Object.keys(e),...Object.keys(t)])){let a=o(e,i),l=o(t,i);if(!a&&!l)continue;let d=[...r,i];l?a?p(e[i],t[i],d,n):n.push({op:"set",path:d,value:s(t[i])}):n.push({op:"unset",path:d})}return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let i=0;i<t.length;i+=1)p(l(e,i),l(t,i),[...r,i],n);return}n.push({op:"set",path:r,value:s(t)})}};t.O2=(e,t)=>{let r=[];return p(c(e),c(t),[],r),r}},2985(e,t,r){r.d(t,{Re:()=>d,m4:()=>l});var i,n=r(99436),a=r(51455),s=r(76760),o=r(48875),l=(e,t)=>{if(null==e)return{status:"no_baseline"};if(null==t)return{status:"unavailable"};var r=(0,o.O2)(e,t);return{status:"ok",ops:r,opCount:r.length}},d=(i=n(function*(e){try{return JSON.parse((yield(0,a.readFile)(s.join(e,".bricks/build/application-config.json"),"utf8")))}catch{return null}}),function(e){return i.apply(this,arguments)})},3540(e,t,r){r.d(t,{S:()=>p,a:()=>c});var i,n,a=r(99436),s=r(51455),o=r(76760),l=".bricks/edits.jsonl",d=(i=a(function*(e){var t=o.join(e,".gitignore"),r=yield(0,s.readFile)(t,"utf8").catch(e=>{if(e?.code==="ENOENT")return"";throw e});if(!r.split(/\r?\n/).map(e=>e.trim()).some(e=>e===l||".bricks/"===e||".bricks"===e)){var i=r&&!r.endsWith("\n")?"\n":"";yield(0,s.writeFile)(t,`${r}${i}
1
+ export const __rspack_esm_id=3774;export const __rspack_esm_ids=[3774];export const __webpack_modules__={79491(e){e.exports=import("oxfmt").then(function(e){return e})},48875(e,t){let r=["title","update_timestamp"],i=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),n=e=>void 0===e||"function"==typeof e||"symbol"==typeof e,a=e=>"number"!=typeof e||Number.isFinite(e)?e:null,s=e=>{if(!n(e))return Array.isArray(e)?e.map(e=>n(e)?null:s(e)):i(e)?Object.entries(e).reduce((e,[t,r])=>(n(r)||(e[t]=s(r)),e),{}):a(e)},o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)&&!n(e[t]),l=(e,t)=>{let r=e[t];return n(r)?null:r},d=(e,t)=>{if((e=a(e))===(t=a(t)))return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!d(l(e,r),l(t,r)))return!1;return!0}if(i(e)&&i(t)){let r=0;for(let i of Object.keys(e))if(!n(e[i])&&(r+=1,!o(t,i)||!d(e[i],t[i])))return!1;let i=0;for(let e of Object.keys(t))n(t[e])||(i+=1);return r===i}return!1},p=e=>{if(!i(e))return e;let t={...e};for(let e of r)delete t[e];return t},c=(e,t,r,n)=>{if(!d(e,t)){if(i(e)&&i(t)){for(let i of new Set([...Object.keys(e),...Object.keys(t)])){let a=o(e,i),l=o(t,i);if(!a&&!l)continue;let d=[...r,i];l?a?c(e[i],t[i],d,n):n.push({op:"set",path:d,value:s(t[i])}):n.push({op:"unset",path:d})}return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let i=0;i<t.length;i+=1)c(l(e,i),l(t,i),[...r,i],n);return}n.push({op:"set",path:r,value:s(t)})}};t.O2=(e,t)=>{let r=[];return c(p(e),p(t),[],r),r}},2985(e,t,r){r.d(t,{Re:()=>d,m4:()=>l});var i,n=r(99436),a=r(51455),s=r(76760),o=r(48875),l=(e,t)=>{if(null==e)return{status:"no_baseline"};if(null==t)return{status:"unavailable"};var r=(0,o.O2)(e,t);return{status:"ok",ops:r,opCount:r.length}},d=(i=n(function*(e){try{return JSON.parse((yield(0,a.readFile)(s.join(e,".bricks/build/application-config.json"),"utf8")))}catch{return null}}),function(e){return i.apply(this,arguments)})},3540(e,t,r){r.d(t,{S:()=>c,a:()=>p});var i,n,a=r(99436),s=r(51455),o=r(76760),l=".bricks/edits.jsonl",d=(i=a(function*(e){var t=o.join(e,".gitignore"),r=yield(0,s.readFile)(t,"utf8").catch(e=>{if(e?.code==="ENOENT")return"";throw e});if(!r.split(/\r?\n/).map(e=>e.trim()).some(e=>e===l||".bricks/"===e||".bricks"===e)){var i=r&&!r.endsWith("\n")?"\n":"";yield(0,s.writeFile)(t,`${r}${i}
2
2
  # MCP entry-editing audit log
3
3
  ${l}
4
- `)}}),function(e){return i.apply(this,arguments)}),c=(n=a(function*(e,t){var r=o.join(e,".bricks");yield(0,s.mkdir)(r,{recursive:!0}),yield d(e),yield(0,s.appendFile)(o.join(r,"edits.jsonl"),`${JSON.stringify(t)}
5
- `)}),function(e,t){return n.apply(this,arguments)}),p=()=>({session:process.env.BRICKS_CTOR_SESSION_ID||process.env.CODEX_SESSION_ID,agent:process.env.BRICKS_CTOR_AGENT_ID||process.env.USER})},98009(e,t,r){r.d(t,{Gp:()=>v,HJ:()=>x,Hn:()=>c,JJ:()=>w,Kx:()=>j,LJ:()=>m,Pb:()=>g,RI:()=>u,bf:()=>b,jc:()=>_,u4:()=>p,z5:()=>y,zu:()=>h});var i,n,a=r(68832),s=r(99436),o=r(58135),l=r(51455),d=r(76760),c={trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100},p=e=>!!e&&"object"==typeof e&&!Array.isArray(e),u=(e,t)=>d.relative(e,t).replace(/\\/g,"/").replace(/^\.\/+/,""),f=(e,t)=>{var r=d.relative(e,t);return""!==r&&(r.startsWith(`..${d.sep}`)||".."===r||d.isAbsolute(r))?null:t},m=(i=s(function*(e,t){var r=a((yield Promise.all([(0,l.realpath)(e),(0,l.realpath)(t)])),2);return f(r[0],r[1])}),function(e,t){return i.apply(this,arguments)}),y=(n=s(function*(e,t){var r=yield(0,l.lstat)(t).catch(e=>{if(e?.code==="ENOENT")return null;throw e}),i=yield(0,l.realpath)(e);if(r){var n=yield(0,l.realpath)(t).catch(e=>{if(e?.code==="ENOENT")return null;throw e});return n?f(i,n):null}var a=yield(0,l.realpath)(d.dirname(t));return f(i,d.join(a,d.basename(t)))}),function(e,t){return n.apply(this,arguments)}),v=e=>o.isIdentifier(e)?e.name:o.isStringLiteral(e)||o.isNumericLiteral(e)?String(e.value):null,h=e=>/^[$A-Z_a-z][$\w]*$/.test(e)?o.identifier(e):o.stringLiteral(e),b=(e,t)=>e.properties.find(e=>!!o.isObjectProperty(e)&&v(e.key)===t),w=(e,t)=>{var r=b(e,t);if(r&&o.isStringLiteral(r.value))return r.value.value},x=(e,t,r)=>{var i=b(e,t);if(i){i.value=r;return}e.properties.push(o.objectProperty(h(t),r))},_=(e,t)=>{var r=e.properties.findIndex(e=>!!o.isObjectProperty(e)&&v(e.key)===t);r>=0&&e.properties.splice(r,1)},g=(e,t)=>{var r=e.program.body,i=r.findLastIndex(e=>o.isImportDeclaration(e));r.splice(i+1,0,t)},j=(e,t,r)=>{var i=new Set(Array.from(r).filter(Boolean));if(0!==i.size){var n,a=function(e){return o.isImportDeclaration(e)&&"bricks-ctor"===e.source.value&&"type"===t==("type"===e.importKind)?(e.specifiers.forEach(e=>{if(o.isImportSpecifier(e)){var t=e.imported;o.isIdentifier(t)&&i.delete(t.name),o.isStringLiteral(t)&&i.delete(t.value)}}),i.forEach(t=>{e.specifiers.push(o.importSpecifier(o.identifier(t),o.identifier(t)))}),{v:void 0}):0};for(var s of e.program.body)if(0!==(n=a(s))&&n)return n.v;var l=o.importDeclaration(Array.from(i).map(e=>o.importSpecifier(o.identifier(e),o.identifier(e))),o.stringLiteral("bricks-ctor"));"type"===t&&(l.importKind="type"),g(e,l)}}},54452(e,t,r){r.d(t,{H:()=>c});var i,n,a=r(99436),s=r(75720),o=r(2985),l={FORCE_COLOR:"0",NO_COLOR:"1"},d=(i=a(function*(e){var t=yield(0,o.Re)(e);try{yield(0,s.sh)`bun compile`.cwd(e).env({...l,BRICKS_CTOR_ENABLE_EDITING_TOOLS:"0"}).text()}catch(e){var r=[e.stdout?.toString()??"",e.stderr?.toString()??"",e.message].filter(Boolean).join("\n").trim();return{status:"compile:failed",errors:r?[r]:["bun compile failed"]}}var i=yield(0,o.Re)(e);return{status:"compile:ok",errors:[],configChange:(0,o.m4)(t,i)}}),function(e){return i.apply(this,arguments)}),c=(n=a(function*(e,t){return(void 0!==t?t:!["0","false","no","off"].includes((process.env.BRICKS_CTOR_MCP_EDIT_VERIFY??"true").toLowerCase()))?d(e):{status:"skipped",errors:[]}}),function(e,t){return n.apply(this,arguments)})},85949(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>tv,register:()=>ty});var n,a,s,o,l,d,c,p,u,f,m,y,v,h,b,w,x,_,g,j,P,k,E,S,$,A,I,O,C,N,T,R=r(68832),D=r(99436),F=r(44668),L=r(5018),B=r(63315),z=r(30409),K=r(40906),U=r(59410),q=r(2235),M=r(46773),Y=r(80004),J=r(58135),H=r(11978),V=r(79491),G=r(51455),W=r(77598),X=r(76760),Z=r(84867),Q=r(54452),ee=r(98009),et=r(3540),er=e([V]);function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}V=(er.then?(await er)():er)[0];var en=q.default||q,ea=Y.default||Y,es={"bricks.ts":{kind:"brick",namespace:"bricks",varPrefix:"b",idType:"brick",idPrefix:"BRICK_",typename:"Brick"},"generators.ts":{kind:"generator",namespace:"generators",varPrefix:"g",idType:"generator",idPrefix:"GENERATOR_",typename:"Generator"},"canvases.ts":{kind:"canvas",namespace:"canvases",varPrefix:"c",idType:"canvas",idPrefix:"CANVAS_",typename:"Canvas"},"data.ts":{kind:"data",namespace:"data",varPrefix:"d",idType:"data",idPrefix:"PROPERTY_BANK_DATA_NODE_",typename:"Data"},"animations.ts":{kind:"animation",namespace:"animations",varPrefix:"a",idType:"animation",idPrefix:"ANIMATION_",typename:"Animation"}},eo=function(e){function t(e,r,i,n=!1){var a,s,o;return L(this,t),s=t,o=[r],s=z(s),(a=B(this,ei()?Reflect.construct(s,o||[],z(this).constructor):s.apply(this,o))).name="EntryEditingError",a.code=e,a.details=i,a.isMcpError=n,a}return K(t,e),F(t)}(U(Error)),el=(e,t)=>{if(X.isAbsolute(t))throw new eo("invalid_file","File must be project-relative",{file:t});var r=X.resolve(e,t),i=X.relative(e,r);if(i.startsWith("..")||X.isAbsolute(i))throw new eo("invalid_file","File must stay inside the project directory",{file:t});return r},ed=(e,t)=>{try{return(0,M.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new eo("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},ec=(n=D(function*(e,t){var r=yield(0,ee.LJ)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});var i=yield(0,G.readFile)(r,"utf8"),n=(0,ee.RI)(e,t);return{source:i,ast:ed(i,n),projectDir:e,absPath:t,ioPath:r,relPath:n,kind:(e=>{var t=X.basename(e),r=es[t];if(!r)throw new eo("unsupported_file",`Unsupported entry file: ${t}`,{file:e,expected:Object.keys(es)});return r})(t)}}),function(e,t){return n.apply(this,arguments)}),ep=(a=D(function*(e,t){var r=yield(0,ee.z5)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});return r}),function(e,t){return a.apply(this,arguments)}),eu=e=>e.program.body.flatMap(e=>{if(!J.isExportNamedDeclaration(e)||!J.isVariableDeclaration(e.declaration))return[];var t=e.declaration;return t.declarations.flatMap(r=>{if(!J.isIdentifier(r.id))return[];var i,n=r.id.typeAnnotation;J.isTSTypeAnnotation(n)&&J.isTSTypeReference(n.typeAnnotation)&&J.isIdentifier(n.typeAnnotation.typeName)&&(i=n.typeAnnotation.typeName.name);var a=J.isObjectExpression(r.init)?r.init:void 0;return[{name:r.id.name,node:e,declaration:t,declarator:r,object:a,id:a?(0,ee.JJ)(a,"id"):void 0,alias:a?(0,ee.JJ)(a,"alias"):void 0,typeName:i}]})}),ef=(e,t)=>{var r=eu(e.ast);if(t.entry){var i=r.find(e=>e.name===t.entry);if(i)return i;var n=r.filter(e=>e.alias===t.entry);if(1===n.length)return n[0];if(n.length>1)throw new eo("ambiguous_reference",`Alias is ambiguous: ${t.entry}`,{file:e.relPath,entry:t.entry,matches:n.map(e=>e.name)});throw new eo("entry_not_found",`Entry not found (by name or alias): ${t.entry}`,{file:e.relPath,entry:t.entry})}if(t.id){var a=r.find(e=>e.id===t.id);if(!a)throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{file:e.relPath,id:t.id});return a}throw new eo("missing_target","Provide entry or id")},em=e=>e.split(X.sep).find(e=>/^subspace-\d+$/.test(e))||"unknown-subspace",ey=e=>{var t=e.split(X.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new eo("invalid_file","Entry file must be inside subspaces/subspace-N",{file:e});return t.slice(0,r+1).join(X.sep)},ev=(s=D(function*(e){var t=X.join(e,"subspaces");return(yield(0,G.readdir)(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&/^subspace-\d+$/.test(e.name)).map(e=>X.join(t,e.name)).sort()}),function(e){return s.apply(this,arguments)}),eh=(o=D(function*(e){var t=Object.keys(es),r=yield(0,G.readdir)(e,{withFileTypes:!0}).catch(()=>[]),i=new Set(r.filter(e=>e.isFile()).map(e=>e.name));return t.filter(e=>i.has(e)).map(t=>X.join(e,t))}),function(e){return o.apply(this,arguments)}),eb=(l=D(function*(e){var t=yield ev(e);return(yield Promise.all(t.map(eh))).flat()}),function(e){return l.apply(this,arguments)}),ew=(d=D(function*(e,t){if(t.file)return el(e,t.file);if(!t.id)throw new eo("missing_file","Provide file, or provide id for global lookup");for(var r of yield eb(e)){var i=yield ec(e,r);if(eu(i.ast).find(e=>e.id===t.id))return r}throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{id:t.id})}),function(e,t){return d.apply(this,arguments)}),ex=(c=D(function*(e,t){var r=yield ew(e,t),i=yield ec(e,r),n=ef(i,t),a=((e,t)=>{if(!e.object)throw new eo("fallback_recommended",`Entry ${e.name} in ${t} is not a top-level exported object literal. Edit this file directly for this one.`,{file:t,entry:e.name,check:"top-level export const object literal"});return e.object})(n,i.relPath);return{parsed:i,entry:n,object:a}}),function(e,t){return c.apply(this,arguments)}),e_=(e,t)=>J.callExpression(J.identifier("makeId"),t?[J.stringLiteral(e),J.stringLiteral(t)]:[J.stringLiteral(e)]),eg=e=>{var t=[];for(var r of e.split(".").filter(Boolean))for(var i=/([^\[\]]+)|\[(\d+)\]/g,n=void 0;n=i.exec(r);)n[1]&&t.push({key:n[1]}),n[2]&&t.push({index:Number(n[2])});if(0===t.length)throw new eo("invalid_path",`Invalid path: ${e}`,{path:e});return t},ej=e=>J.isTSAsExpression(e)||J.isTSSatisfiesExpression(e)||J.isTSNonNullExpression(e)||J.isParenthesizedExpression(e)?ej(e.expression):e,eP=(e,t)=>{var r=ej(e);if(!J.isObjectExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an object literal. Edit this file directly for this one.`,{path:t,expected:"object literal",actual:r.type});return r},ek=(e,t)=>{var r=ej(e);if(!J.isArrayExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an array literal. Edit this file directly for this one.`,{path:t,expected:"array literal",actual:r.type});return r},eE=e=>"array"==("index"in e?"array":"object")?J.arrayExpression([]):J.objectExpression([]),eS=(p=D(function*(e,t,r,i){for(var n=eg(t),a=e,s=0;s<n.length;s+=1){var o=n[s],l=s===n.length-1;if("key"in o){var d=eP(a,t);if(l)return void(0,ee.HJ)(d,o.key,(yield eB(r,i)));var c=n[s+1],p=(0,ee.bf)(d,o.key);p||(p=J.objectProperty((0,ee.zu)(o.key),eE(c)),d.properties.push(p)),a=p.value;continue}var u=ek(a,t);if(o.index<0||o.index>u.elements.length)throw new eo("invalid_path",`Array index out of range for ${t}`,{path:t,index:o.index});if(l){u.elements[o.index]=yield eB(r,i);return}u.elements[o.index]||(u.elements[o.index]=eE(n[s+1])),a=u.elements[o.index]}}),function(e,t,r,i){return p.apply(this,arguments)}),e$=(e,t)=>{for(var r=eg(t),i=e,n=0;n<r.length;n+=1){var a=r[n],s=n===r.length-1;if("key"in a){var o=eP(i,t);if(s)return void(0,ee.jc)(o,a.key);var l=(0,ee.bf)(o,a.key);if(!l)return;i=l.value;continue}var d=ek(i,t);if(a.index<0||a.index>=d.elements.length)return;if(s)return void d.elements.splice(a.index,1);var c=d.elements[a.index];if(!c)return;i=c}},eA=(e,t)=>{var r=(0,ee.bf)(e,"switches");if(!r)throw new eo("fallback_recommended","Entry has no switches array",{path:"switches"});var i=ek(r.value,"switches"),n="number"==typeof t?t:i.elements.findIndex(e=>J.isObjectExpression(e)&&(0,ee.JJ)(e,"id")===t);if(n<0||n>=i.elements.length)throw new eo("entry_not_found",`Switch not found: ${t}`,{switch:t});var a=i.elements[n];if(!J.isObjectExpression(a))throw new eo("fallback_recommended",`Switch ${String(t)} is not an object literal. Edit this file directly for this one.`,{switch:t});return a},eI=(e,t)=>{var r=t.replace(/\.[tj]sx?$/,""),i=X.relative(X.dirname(e),r).replace(/\\/g,"/");return i.startsWith(".")||(i=`./${i}`),i},eO=e=>{var t=new Set;return e.program.body.forEach(e=>{J.isImportDeclaration(e)?e.specifiers.forEach(e=>t.add(e.local.name)):J.isExportNamedDeclaration(e)&&J.isVariableDeclaration(e.declaration)&&e.declaration.declarations.forEach(e=>{J.isIdentifier(e.id)&&t.add(e.id.name)})}),t},eC=(e,t,r)=>{for(var i of e.ast.program.body)if(J.isImportDeclaration(i)&&i.source.value===t){var n=i.specifiers.find(e=>J.isImportDefaultSpecifier(e));if(n)return n.local.name}var a=eO(e.ast),s=r;if(a.has(s)){for(var o=1;a.has(`${s}${o}`);)o+=1;s=`${s}${o}`}var l=J.importDeclaration([J.importDefaultSpecifier(J.identifier(s))],J.stringLiteral(t));return(0,ee.Pb)(e.ast,l),s},eN=e=>{(0,ee.Kx)(e.parsed.ast,"type",e.typeImports),(0,ee.Kx)(e.parsed.ast,"value",e.valueImports)},eT=(u=D(function*(e,t,r){if(null==r||""===r)return t;if("number"==typeof r)return X.join(e,"subspaces",`subspace-${r}`);var i=String(r);if(/^\d+$/.test(i))return X.join(e,"subspaces",`subspace-${i}`);if(/^subspace-\d+$/.test(i))return X.join(e,"subspaces",i);if(i.includes("/"))return el(e,i);var n,a=yield ev(e),s=function*(){var t=X.join(o,"index.ts"),r=yield(0,G.readFile)(t,"utf8").catch(()=>"");if(!r)return 0;var n=ed(r,(0,ee.RI)(e,t)),a=!1;if(ea(n,{ObjectProperty(e){"id"===(0,ee.Gp)(e.node.key)&&J.isStringLiteral(e.node.value)&&e.node.value.value===i&&(a=!0,e.stop())}}),a)return{v:o}};for(var o of a)if(n=yield*s(),0!==n&&n)return n.v;throw new eo("reference_not_found",`Subspace not found: ${i}`,{subspace:i})}),function(e,t,r){return u.apply(this,arguments)}),eR=(f=D(function*(e,t){var r,i,n=ey(e.parsed.absPath),a=yield eT(e.projectDir,n,t),s=X.basename(a),o=/^subspace-(\d+)$/.exec(s);if(!o)throw new eo("invalid_subspace",`Not a subspace directory: ${s}`,{subspace:t});var l=X.join(a,"index.ts"),d=yield(0,G.readFile)(l,"utf8").catch(()=>null);if(null==d)throw new eo("reference_not_found",`Subspace not found: ${t}`,{subspace:t});var c=(r=ed(d,(0,ee.RI)(e.projectDir,l)),ea(r,{ObjectProperty(e){if("id"===(0,ee.Gp)(e.node.key)){var t=e.node.value;J.isStringLiteral(t)&&t.value.startsWith("SUBSPACE_")&&(i=t.value,e.stop())}}}),i);if(!c)throw new eo("invalid_subspace",`Subspace index has no SUBSPACE_ id: ${s}/index.ts`,{subspace:t});return{id:c,index:Number(o[1]),label:s,indexPath:l,isCurrent:X.resolve(a)===X.resolve(n)}}),function(e,t){return f.apply(this,arguments)}),eD=(m=D(function*(e,t){var r=yield eR(e,t);if(r.isCurrent)return e.references.push({input:t,id:r.id,sameFile:!1,display:`'${r.id}'`,targetAbsPath:r.indexPath}),{resolved:r,expression:J.stringLiteral(r.id)};var i=eC(e.parsed,`../${r.label}`,`subspace${r.index}`);return e.references.push({input:t,id:r.id,sameFile:!1,display:`() => ${i}`,targetAbsPath:r.indexPath}),{resolved:r,expression:J.arrowFunctionExpression([],J.identifier(i))}}),function(e,t){return m.apply(this,arguments)}),eF=(y=D(function*(e,t,r,i){var n=ey(t),a=yield eT(e,n,i),s=yield eh(a),o=[];for(var l of s){var d=yield ec(e,l),c=d.kind;for(var p of eu(d.ast))if(p.name===r||p.id===r||p.alias===r){var u=X.resolve(l)===X.resolve(t),f=X.basename(a);o.push({input:r,id:p.id,alias:p.alias,varName:p.name,namespace:c.namespace,display:`${c.namespace}.${p.name}`,targetAbsPath:l,sameFile:u,subspaceLabel:f,importSource:u?void 0:eI(t,l)})}}if(0===o.length)throw new eo("reference_not_found",`Reference not found: ${r}`,{ref:r,subspace:i??X.basename(n)});if(o.length>1)throw new eo("ambiguous_reference",`Reference is ambiguous: ${r}`,{ref:r,matches:o.map(t=>({file:(0,ee.RI)(e,t.targetAbsPath),entry:t.varName,id:t.id,alias:t.alias}))});return o[0]}),function(e,t,r,i){return y.apply(this,arguments)}),eL=(v=D(function*(e,t,r){var i=yield eF(t.projectDir,t.parsed.absPath,e,r);if(i.sameFile)return t.references.push(i),J.identifier(i.varName);var n=ey(t.parsed.absPath),a=ey(i.targetAbsPath),s=i.subspaceLabel.replace(/[^a-zA-Z0-9_$]/g,""),o=n===a?i.namespace:`${s}${i.namespace[0].toUpperCase()}${i.namespace.slice(1)}`,l=((e,t,r,i)=>{for(var n of e.ast.program.body)if(J.isImportDeclaration(n)&&n.source.value===r){var a=n.specifiers.find(J.isImportNamespaceSpecifier);if(a)return a.local.name}var s=eO(e.ast),o=i;if(s.has(o)){for(var l=1;s.has(`${o}${l}`);)l+=1;o=`${o}${l}`}var d=J.importDeclaration([J.importNamespaceSpecifier(J.identifier(o))],J.stringLiteral(r));return(0,ee.Pb)(e.ast,d),o})(t.parsed,i.namespace,i.importSource,o);return i.importLocal=l,t.references.push({...i,display:`${l}.${i.varName}`,importLocal:l}),J.memberExpression(J.identifier(l),J.identifier(i.varName))}),function(e,t,r){return v.apply(this,arguments)}),eB=(h=D(function*(e,t){if((0,ee.u4)(e)&&"string"==typeof e.expr&&1===Object.keys(e).length){var r=e.expr;try{return(0,M.parseExpression)(r,{plugins:["typescript"]})}catch(e){throw new eo("invalid_expr",`Invalid TypeScript expression: ${e.message}`,{expr:r})}}if((0,ee.u4)(e)&&"string"==typeof e.link){t.valueImports.add("linkData");var i=yield eL(e.link,t,e.subspace);return J.callExpression(J.identifier("linkData"),[J.arrowFunctionExpression([],i)])}if((0,ee.u4)(e)&&"string"==typeof e.ref){var n=yield eL(e.ref,t,e.subspace);return J.arrowFunctionExpression([],n)}if(Array.isArray(e))return J.arrayExpression((yield Promise.all(e.map(e=>eB(e,t)))));if((0,ee.u4)(e)){var a,s=yield Promise.all(Object.entries(e).map((a=D(function*([e,r]){return J.objectProperty((0,ee.zu)(e),(yield eB(r,t)))}),function(e){return a.apply(this,arguments)})));return J.objectExpression(s)}return void 0===e?J.identifier("undefined"):J.valueToNode(e)}),function(e,t){return h.apply(this,arguments)}),ez=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,resolved:e.importLocal?`${e.importLocal}.${e.varName}`:e.sameFile?e.varName:e.display,file:e.targetAbsPath})),eK=(b=D(function*(e){var t=en(e.ast,{comments:!0},e.source).code,r=yield(0,V.format)(e.absPath,t,ee.Hn);if(r.errors.length>0)throw new eo("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return b.apply(this,arguments)}),eU=(w=D(function*(e){var t=yield eK(e);return ed(t,e.relPath),yield(0,G.writeFile)(e.ioPath??(yield ep(e.projectDir,e.absPath)),t),t}),function(e){return w.apply(this,arguments)}),eq=(e,t)=>{if(e){var r=em(e.absPath);return`${t?.name||"entry"} (${e.kind.kind}, ${r})`}},eM=(x=D(function*(e,t,r,i){var n={ts:new Date().toISOString(),tool:t,op:r?.op||(r?.set?"set":r?.unset?"unset":t),target:{file:r?.file,entry:r?.entry,id:r?.id},provenance:(0,et.S)()};try{var a=yield i(),s={...n,...a};return yield(0,et.a)(e,s).catch(e=>{s.auditError=e.message}),s}catch(i){var o=i instanceof eo?i:new eo("error",i.message||String(i),void 0,!0),l="fallback_recommended"===o.code?"fallback_recommended":"error",d={...n,outcome:l,input:r,error:{code:o.code,message:o.message,details:o.details},summary:"fallback_recommended"===l?`${t} could not safely edit this standard path; edit the file directly`:`${t} failed: ${o.message}`,isError:o.isMcpError||"error"===l};return yield(0,et.a)(e,d).catch(e=>{d.auditError=e.message}),d}}),function(e,t,r,i){return x.apply(this,arguments)}),eY=(_=D(function*(e,t){return eM(e,"edit_entry",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eA(a,t.switch);for(var l of Object.entries(t.set||{})){var d=R(l,2),c=d[0],p=d[1];yield eS(o,c,p,s)}for(var u of[...t.unset||[]].sort((e,t)=>{for(var r=eg(e).map(e=>"index"in e?e.index:-1),i=eg(t).map(e=>"index"in e?e.index:-1),n=0;n<Math.min(r.length,i.length);n+=1)if(r[n]!==i[n])return i[n]-r[n];return i.length-r.length}))e$(o,u);eN(s),yield eU(i);var f=yield(0,Q.H)(e,t.verify),m=eq(i,n);return{file:i.relPath,entry:n.name,id:n.id,change:{set:t.set||{},unset:t.unset||[],references:ez(s.references)},outcome:"compile:failed"===f.status?"verify_failed":"ok",verify:f,summary:`edited ${m} -> ${f.status}`}}))}),function(e,t){return _.apply(this,arguments)}),eJ=e=>{switch(e){case"IfStatement":return"an if statement";case"ForStatement":case"ForOfStatement":case"ForInStatement":return"a for loop";case"WhileStatement":case"DoWhileStatement":return"a while loop";case"SwitchStatement":return"a switch statement";case"TryStatement":return"a try/catch block";case"FunctionDeclaration":return"a function declaration";case"ReturnStatement":return"a return before the final statement";default:return`a ${e}`}},eH=(e,t)=>{for(var r=0;r<e.length;r+=1){var i=e[r],n=r===e.length-1;if("ExpressionStatement"===i.type){var a=eV(i.expression);if(a)return a;continue}if("VariableDeclaration"===i.type){for(var s of i.declarations)if("Identifier"!==s.id.type||!s.init)return"a destructuring or uninitialized declaration";continue}if(t&&n&&"ReturnStatement"===i.type){var o=i.argument?eV(i.argument):null;if(o)return o;continue}return eJ(i.type)}return null},eV=e=>{if(e?.type!=="CallExpression"||e.arguments?.length||e.callee?.type!=="ArrowFunctionExpression"&&e.callee?.type!=="FunctionExpression")return null;var t=e.callee.body;return t?.type==="BlockStatement"?eH(t.body,!0):eV(t)},eG=(g=D(function*(e,t){if(e?.expr)return eB(e,t);var r,i=(e=>{if(!(0,ee.u4)(e)||!(0,ee.u4)(e.action))return e;var t=e.action,r={handler:e.handler,name:t.name??t.__actionName,waitAsync:e.waitAsync};if(t.cast&&(r.cast=t.cast),Array.isArray(t.params))for(var i of(r.params={},t.params)){if(!(0,ee.u4)(i)||"string"!=typeof i.input)throw new eo("invalid_action",'Compiled action params entries require { input: "name", value }',{param:i});r.params[i.input]=i.value}if(Array.isArray(t.dataParams))for(var n of(r.dataParams={},t.dataParams)){var a=(0,ee.u4)(n?.input)?n.input.ref:n?.input;if("string"!=typeof a||!a)throw new eo("invalid_action","Compiled action dataParams entries require { input: dataRef, value }",{param:n});r.dataParams[a]=n.value}return r})(e),n=i?.name;if(!n)throw new eo("invalid_action","Action requires name");if("PROPERTY_BANK_EXPRESSION"===n&&(0,ee.u4)(i.params)){var a=i.params.expression;"string"==typeof a&&(e=>{try{t=(0,H.qg)(e,{ecmaVersion:2020})}catch(t){throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION does not parse: ${t.message}`,{expression:e})}var t,r=eH(t.body,!1);if(r)throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION cannot evaluate ${r}: the runtime folds the expression into a single expression (expression statements, simple const/let declarations, and a final return inside an IIFE only). Use ternaries instead of statements, or move branching logic to a DataCalculationScript.`,{expression:e})})(a)}var s="System",o=i.cast;if("system"===i.handler||null==i.handler)r=J.stringLiteral("system"),o||=`SystemAction${n.toLowerCase().split("_").filter(Boolean).map(e=>`${e[0].toUpperCase()}${e.slice(1)}`).join("")}`;else if((0,ee.u4)(i.handler)&&"string"==typeof i.handler.ref){var l=yield eF(t.projectDir,t.parsed.absPath,i.handler.ref,i.handler.subspace);if("bricks"!==l.namespace&&"generators"!==l.namespace)throw new eo("invalid_action",`Action handler must be a brick or generator, got ${l.namespace}: ${i.handler.ref}`,{handler:i.handler});s="bricks"===l.namespace?"Brick":"Generator";var d=yield eL(i.handler.ref,t,i.handler.subspace);r=J.arrowFunctionExpression([],d)}else if((0,ee.u4)(i.handler)&&null!=i.handler.subspace)r=(yield eD(t,i.handler.subspace)).expression,s="Subspace";else throw new eo("invalid_action","Unsupported action handler",{handler:i.handler});var c=[J.objectProperty(J.identifier("__actionName"),J.stringLiteral(n)),J.objectProperty(J.identifier("parent"),J.stringLiteral(s)),J.objectProperty(J.identifier("name"),J.stringLiteral(n))];if(i.params){var p,u=yield Promise.all(Object.entries(i.params).map((p=D(function*([e,r]){return J.objectExpression([J.objectProperty(J.identifier("input"),J.stringLiteral(e)),J.objectProperty(J.identifier("value"),(yield eB(r,t)))])}),function(e){return p.apply(this,arguments)})));c.push(J.objectProperty(J.identifier("params"),J.arrayExpression(u)))}if(i.dataParams){var f,m=yield Promise.all(Object.entries(i.dataParams).map((f=D(function*([e,r]){var i=yield eL(e,t);return J.objectExpression([J.objectProperty(J.identifier("input"),J.arrowFunctionExpression([],i)),J.objectProperty(J.identifier("value"),(yield eB(r,t)))])}),function(e){return f.apply(this,arguments)})));c.push(J.objectProperty(J.identifier("dataParams"),J.arrayExpression(m)))}var y=J.objectExpression(c);return o&&(t.typeImports.add(o),y=J.tsAsExpression(y,J.tsTypeReference(J.identifier(o)))),J.objectExpression([J.objectProperty(J.identifier("handler"),r),J.objectProperty(J.identifier("action"),y),J.objectProperty(J.identifier("waitAsync"),J.booleanLiteral(!!i.waitAsync))])}),function(e,t){return g.apply(this,arguments)}),eW=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=J.objectProperty((0,ee.zu)(t),J.objectExpression([])),e.properties.push(i)),eP(i.value,r)},eX=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=J.objectProperty((0,ee.zu)(t),J.arrayExpression([])),e.properties.push(i)),ek(i.value,r)},eZ=(j=D(function*(e,t){return eM(e,"edit_events",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eA(a,t.switch),l=t.op;if("clear"===l||"remove"===l||"move"===l){var d=(0,ee.bf)(o,"events"),c=d?eP(d.value,"events"):null,p=c?(0,ee.bf)(c,t.event):null,u=p?ek(p.value,`events.${t.event}`):null;if("clear"===l)c&&(0,ee.jc)(c,t.event);else if("move"===l){if(null==t.index)throw new eo("invalid_index","move requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var f=Number(t.to);if(!Number.isFinite(f)||f<0||f>=u.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var m=u.elements.splice(t.index,1),y=R(m,1)[0];u.elements.splice(f,0,y)}else{if(null==t.index)throw new eo("invalid_index","remove requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});u.elements.splice(t.index,1),0===u.elements.length&&c&&(0,ee.jc)(c,t.event)}}else if("add"===l||"replace"===l){var v=yield eG(t.action,s),h=eW(o,"events","events"),b=eX(h,t.event,`events.${t.event}`),w=t.index??b.elements.length;if("replace"===l){if(w<0||w>=b.elements.length)throw new eo("invalid_index","replace index out of range",{index:w});b.elements[w]=v}else{if(w<0||w>b.elements.length)throw new eo("invalid_index","add index out of range",{index:w});b.elements.splice(w,0,v)}}else throw new eo("invalid_op",`Unsupported edit_events op: ${l}`);eN(s),yield eU(i);var x=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{event:t.event,op:l,index:t.index,references:ez(s.references)},outcome:"compile:failed"===x.status?"verify_failed":"ok",verify:x,summary:`${l} event ${t.event} on ${eq(i,n)} -> ${x.status}`}}))}),function(e,t){return j.apply(this,arguments)}),eQ=e=>{if((0,ee.u4)(e)&&"string"==typeof e.expr)return e;if(!(0,ee.u4)(e))throw new eo("invalid_item","Canvas item requires frame { x, y, width, height }");for(var t of["x","y","width","height"])if("number"!=typeof e[t])throw new eo("invalid_item",`Canvas item frame requires numeric ${t}`,{frame:e});return e},e0=(P=D(function*(e,t,r){if(!e?.ref&&e?.subspace==null)throw new eo("invalid_item","Canvas item requires ref (brick) or subspace (embed)");var i,n=eQ(e.frame??r);if(e.ref){var a=yield eL(e.ref,t,e.subspace);i=J.arrowFunctionExpression([],a)}else{var s=yield eD(t,e.subspace),o=s.resolved,l=s.expression;if(o.isCurrent)throw new eo("invalid_item","A subspace cannot embed itself",{subspace:e.subspace});i=l}return J.objectExpression([J.objectProperty(J.identifier("item"),i),J.objectProperty(J.identifier("frame"),(yield eB(n,t))),...null==e.hidden?[]:[J.objectProperty(J.identifier("hidden"),J.booleanLiteral(!!e.hidden))]])}),function(e,t,r){return P.apply(this,arguments)}),e1=(k=D(function*(e,t){return eM(e,"edit_canvas_items",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object;if("canvas"!==i.kind.kind)throw new eo("invalid_file","edit_canvas_items only edits canvases.ts entries",{file:i.relPath});var s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eX(a,"items","items"),l=t.op;if("add"===l||"replace"===l){var d=yield e0(t.item,s,t.frame),c=t.index??o.elements.length;if("replace"===l){if(c<0||c>=o.elements.length)throw new eo("invalid_index","replace index out of range",{index:c});o.elements[c]=d}else{if(c<0||c>o.elements.length)throw new eo("invalid_index","add index out of range",{index:c});o.elements.splice(c,0,d)}}else if("remove"===l){if(null==t.index)throw new eo("invalid_index","remove requires index");if(t.index<0||t.index>=o.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});o.elements.splice(t.index,1)}else if("move"===l){if(null==t.index)throw new eo("invalid_index","move requires index");if(!t.frame)throw new eo("invalid_item","move requires frame");if(t.index<0||t.index>=o.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var p=o.elements[t.index];if(!J.isObjectExpression(p))throw new eo("fallback_recommended","Canvas item is not an object literal",{index:t.index});(0,ee.HJ)(p,"frame",(yield eB(eQ(t.frame),s)))}else throw new eo("invalid_op",`Unsupported edit_canvas_items op: ${l}`);eN(s),yield eU(i);var u=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:ez(s.references)},outcome:"compile:failed"===u.status?"verify_failed":"ok",verify:u,summary:`${l} canvas item on ${eq(i,n)} -> ${u.status}`}}))}),function(e,t){return k.apply(this,arguments)}),e4=(E=D(function*(e,t){var r=(e=>{switch(e?.__typename){case"SwitchCondInnerStateCurrentCanvas":return{type:"inner_state",key:"current_canvas",value:e.value,subspace:e.subspace};case"SwitchCondInnerStateOutlet":return{type:"inner_state",outlet:e.outlet,value:e.value};case"SwitchCondData":return{type:"property_bank",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondPropertyBankByItemKey":return{type:"property_bank_by_item_key",ref:e.data??e.ref,value:e.value,subspace:e.subspace};default:return e}})(e);if(r?.expr)return eB(r,t);if(r?.type==="inner_state"&&"current_canvas"===r.key){var i=yield eL(r.value,t,r.subspace);return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral("SwitchCondInnerStateCurrentCanvas")),J.objectProperty(J.identifier("value"),J.arrowFunctionExpression([],i))])}if(r?.type==="inner_state"){var n=r.outlet||r.key;if(!n)throw new eo("invalid_switch","Switch inner-state outlet condition requires outlet or key");return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral("SwitchCondInnerStateOutlet")),J.objectProperty(J.identifier("outlet"),J.stringLiteral(n)),J.objectProperty(J.identifier("value"),(yield eB(r.value,t)))])}var a=r?.ref||r?.data||r?.key;if(!a)throw new eo("invalid_switch","Switch condition requires data ref");var s=yield eL(a,t,r.subspace);return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral(r?.type==="property_bank_by_item_key"?"SwitchCondPropertyBankByItemKey":"SwitchCondData")),J.objectProperty(J.identifier("data"),J.arrowFunctionExpression([],s)),J.objectProperty(J.identifier("value"),(yield eB(r.value,t)))])}),function(e,t){return E.apply(this,arguments)}),e5=new Set(["id","title","description","conds","override","property","outlets","animation","events","disabled","break"]),e9=(S=D(function*(e,t){for(var r of Object.keys(e))if(!e5.has(r))throw new eo("invalid_switch",`Unknown switch field: ${r}`,{field:r,supported:Array.from(e5)});if(void 0!==e.events)throw new eo("invalid_switch","Set switch events with edit_events using its switch parameter");if(e.id&&!/^BRICK_STATE_GROUP_[0-9a-fA-F-]{36}$/.test(e.id))throw new eo("invalid_switch","Switch id must match BRICK_STATE_GROUP_<uuid>; omit id to generate one",{id:e.id});var i,n=e.id?J.stringLiteral(e.id):e_("switch");e.id||t.valueImports.add("makeId");var a=[J.objectProperty(J.identifier("id"),n)];for(var s of(null!=e.title&&a.push(J.objectProperty(J.identifier("title"),J.stringLiteral(e.title))),null!=e.description&&a.push(J.objectProperty(J.identifier("description"),J.stringLiteral(e.description))),e.conds&&a.push(J.objectProperty(J.identifier("conds"),J.arrayExpression((yield Promise.all(e.conds.map((i=D(function*(e){return J.objectExpression([J.objectProperty(J.identifier("method"),J.stringLiteral(e.method||"==")),J.objectProperty(J.identifier("cond"),(yield e4(e.cond||e,t)))])}),function(e){return i.apply(this,arguments)}))))))),e.override&&a.push(J.objectProperty(J.identifier("override"),(yield eB(e.override,t)))),["property","outlets","animation"]))null!=e[s]&&a.push(J.objectProperty(J.identifier(s),(yield eB(e[s],t))));return null!=e.disabled&&a.push(J.objectProperty(J.identifier("disabled"),J.booleanLiteral(!!e.disabled))),null!=e.break&&a.push(J.objectProperty(J.identifier("break"),J.booleanLiteral(!!e.break))),J.objectExpression(a)}),function(e,t){return S.apply(this,arguments)}),e8=($=D(function*(e,t){return eM(e,"edit_switches",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eX(a,"switches","switches"),l=t.op,d=e=>"number"==typeof e?e:e?o.elements.findIndex(t=>J.isObjectExpression(t)&&(0,ee.JJ)(t,"id")===e):-1;if("add"===l||"replace"===l){var c=yield e9(t.switch||{},s),p=null==t.index?o.elements.length:d(t.index);if("replace"===l){if(p<0||p>=o.elements.length)throw new eo("invalid_index","replace index out of range",{index:p});o.elements[p]=c}else{if(p<0||p>o.elements.length)throw new eo("invalid_index","add requires a valid switch id or index",{index:t.index});o.elements.splice(p,0,c)}}else if("remove"===l){var u=d(t.index);if(u<0||u>=o.elements.length)throw new eo("invalid_index","remove requires a valid switch id or index",{index:t.index});o.elements.splice(u,1)}else if("move"===l){var f=d(t.index);if(f<0||f>=o.elements.length)throw new eo("invalid_index","move requires a valid switch id or index",{index:t.index});var m=Number(t.to);if(!Number.isFinite(m)||m<0||m>=o.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var y=o.elements.splice(f,1),v=R(y,1)[0];o.elements.splice(m,0,v)}else throw new eo("invalid_op",`Unsupported edit_switches op: ${l}`);eN(s),yield eU(i);var h=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:ez(s.references)},outcome:"compile:failed"===h.status?"verify_failed":"ok",verify:h,summary:`${l} switch on ${eq(i,n)} -> ${h.status}`}}))}),function(e,t){return $.apply(this,arguments)}),e6=(A=D(function*(e,t,r,i){var n=[J.objectProperty(J.identifier("__typename"),J.stringLiteral(e.typename)),J.objectProperty(J.identifier("id"),r)];return t.alias&&n.push(J.objectProperty(J.identifier("alias"),J.stringLiteral(t.alias))),null!=t.title&&n.push(J.objectProperty(J.identifier("title"),J.stringLiteral(t.title))),null!=t.description&&n.push(J.objectProperty(J.identifier("description"),J.stringLiteral(t.description))),"brick"===e.kind||"generator"===e.kind?(n.push(J.objectProperty(J.identifier("templateKey"),J.stringLiteral(t.templateKey||""))),n.push(J.objectProperty(J.identifier("property"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("outlets"),J.objectExpression([]))),"brick"===e.kind&&n.push(J.objectProperty(J.identifier("animation"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("switches"),J.arrayExpression([])))):"canvas"===e.kind?(n.push(J.objectProperty(J.identifier("property"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("switches"),J.arrayExpression([]))),n.push(J.objectProperty(J.identifier("items"),J.arrayExpression([])))):"data"===e.kind?(n.push(J.objectProperty(J.identifier("type"),J.stringLiteral(t.dataType||"any"))),n.push(J.objectProperty(J.identifier("schema"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("value"),J.identifier("undefined")))):"animation"===e.kind&&(n.push(J.objectProperty(J.identifier("runType"),J.stringLiteral("once"))),n.push(J.objectProperty(J.identifier("property"),J.stringLiteral("opacity"))),n.push(J.objectProperty(J.identifier("config"),(yield eB({__type:"AnimationTimingConfig",toValue:1,duration:300,easing:"",delay:0,isInteraction:!0},i))))),J.objectExpression(n)}),function(e,t,r,i){return A.apply(this,arguments)}),e7=(I=D(function*(e,t,r){var i=X.basename(t);for(var n of(yield eb(e)).filter(e=>X.basename(e)===i)){var a=yield ec(e,n);if(eu(a.ast).some(e=>e.alias===r))return!0}return!1}),function(e,t,r){return I.apply(this,arguments)}),e2=(O=D(function*(e,t){return eM(e,"new_entry",t,D(function*(){if(!t.file)throw new eo("missing_file","new_entry requires file");if(!t.type)throw new eo("missing_type","new_entry requires TypeScript type");var r=el(e,t.file),i=yield ec(e,r),n=new Set(eu(i.ast).map(e=>e.name)),a="string"==typeof t.id?t.id:void 0,s=a||"string"!=typeof t.alias||!t.alias||(yield e7(e,r,t.alias))?void 0:t.alias,o=a?J.stringLiteral(a):e_(i.kind.idType,s),l=t.entry||((e,t,r,i)=>{var n,a=(e=>{if(!e)return null;var t=e.replace(/[^a-zA-Z0-9_$]/g,"");return t?(/^[0-9]/.test(t)&&(t=`_${t}`),t):null})(i)||(r?`${t.varPrefix}${n=r.replace(/^[A-Z_]+/g,""),`${n.substr(15,3)}${n.substr(20,1)}`}`:`${t.varPrefix}Entry`);if(!e.has(a))return a;for(var s=1;e.has(`${a}${s}`);)s+=1;return`${a}${s}`})(n,i.kind,a,t.alias||t.title),d={projectDir:e,parsed:i,references:[],typeImports:new Set([t.type]),valueImports:new Set};a||d.valueImports.add("makeId");var c=yield e6(i.kind,t,o,d),p=J.variableDeclarator(J.identifier(l),c);for(var u of(p.id.typeAnnotation=J.tsTypeAnnotation(J.tsTypeReference(J.identifier(t.type))),i.ast.program.body.push(J.exportNamedDeclaration(J.variableDeclaration("const",[p]))),Object.entries(t.set||{}))){var f=R(u,2),m=f[0],y=f[1];yield eS(c,m,y,d)}for(var v of t.events||[]){if(!(0,ee.u4)(v)||"string"!=typeof v.event||!v.event||!v.action)throw new eo("invalid_action","events entries require { event, action }",{event:v});var h=eW(c,"events","events");eX(h,v.event,`events.${v.event}`).elements.push((yield eG(v.action,d)))}eN(d),yield eU(i);var b=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:l,id:a,idExpression:a??(s?`makeId('${i.kind.idType}', '${s}')`:`makeId('${i.kind.idType}')`),change:{set:t.set||{},events:t.events||[],references:ez(d.references)},outcome:"compile:failed"===b.status?"verify_failed":"ok",verify:b,summary:`created ${l} (${i.kind.kind}, ${em(i.absPath)}) -> ${b.status}`}}))}),function(e,t){return O.apply(this,arguments)}),e3=(e,t)=>{var r;return J.isArrowFunctionExpression(e)&&0===e.params.length&&(r=e.body,!!r&&(J.isIdentifier(r)?r.name===t.varName:!!J.isMemberExpression(r)&&!!J.isIdentifier(r.object)&&!!J.isIdentifier(r.property)&&r.object.name===t.namespace&&r.property.name===t.varName))},te=(e,t)=>J.isCallExpression(e)&&J.isIdentifier(e.callee,{name:"linkData"})&&e3(e.arguments[0],t),tt=(e,t)=>{if(!e)return!1;if(e3(e,t)||te(e,t))return!0;var r=!1;return ea(J.file(J.program([J.expressionStatement(J.cloneNode(e,!0))])),{ArrowFunctionExpression(e){e3(e.node,t)&&(r=!0,e.stop())},CallExpression(e){te(e.node,t)&&(r=!0,e.stop())}}),r},tr=(e,t,r,i=[],n={})=>{if(J.isProgram(e))return void e.body.forEach((e,a)=>tr(e,t,r,[...i,String(a)],n));if(J.isExportNamedDeclaration(e)&&e.declaration)return void tr(e.declaration,t,r,i,n);if(J.isVariableDeclaration(e))return void e.declarations.forEach((e,a)=>tr(e,t,r,[...i,String(a)],n));if(J.isVariableDeclarator(e)&&e.init)return void tr(e.init,t,r,i,n);if(J.isObjectExpression(e)){for(var a=e.properties.length-1;a>=0;a-=1){var s=e.properties[a];if(J.isObjectProperty(s)){var o=(0,ee.Gp)(s.key)||`property-${a}`,l=[...i,o];if(e3(s.value,t)||te(s.value,t)){i.includes("outlets")?(e.properties.splice(a,1),r.push({action:"drop_outlet",path:l.join(".")})):n.dataCalc&&("output"===o||"error"===o)?(s.value=J.nullLiteral(),r.push({action:"null_output",path:l.join(".")})):(s.value=J.identifier("undefined"),r.push({action:"null_link",path:l.join(".")}));continue}tr(s.value,t,r,l,n)}}return}if(J.isArrayExpression(e))for(var d=i[i.length-1],c=i.includes("events")&&"events"!==d,p=n.dataCalc?["items","params","dataParams","conds","switches","inputs","outputs"]:["items","params","dataParams","conds","switches"],u=e.elements.length-1;u>=0;u-=1){var f=e.elements[u];if(f){var m=[...i,String(u)];if(tt(f,t)&&(p.includes(d)||c||e3(f,t))){e.elements.splice(u,1),r.push({action:c?"delete_event_handler":n.dataCalc&&("inputs"===d||"outputs"===d)?"remove_io_item":"remove_reference_item",path:m.join(".")});continue}tr(f,t,r,m,n)}}},ti=(e,t)=>{var r=e.ast.program.body.indexOf(t.node);r>=0&&e.ast.program.body.splice(r,1)},tn=(C=D(function*(e,t,r){if("project"===r)return eb(e);var i=ey(t),n=yield eh(i),a=X.join(i,"data-calc"),s=yield(0,G.readdir)(a,{withFileTypes:!0}).catch(()=>[]);return[...n,...s.filter(e=>e.isFile()&&e.name.endsWith(".ts")).map(e=>X.join(a,e.name))]}),function(e,t,r){return C.apply(this,arguments)}),ta=(N=D(function*(e,t){return eM(e,"remove_entry",t,D(function*(){var r,i=yield ex(e,t),n=i.parsed,a=i.entry,s={varName:a.name,namespace:n.kind.namespace,id:a.id},o=yield tn(e,n.absPath,t.scope),l=[],d=yield Promise.all(o.map((r=D(function*(t){var r=yield(0,G.readFile)(t,"utf8");return{absPath:t,relPath:(0,ee.RI)(e,t),source:r,ast:ed(r,(0,ee.RI)(e,t)),kind:es[X.basename(t)]||n.kind}}),function(e){return r.apply(this,arguments)}))),c=function*(e){var t,r,i,o,d;(o=(e.absPath===n.absPath?(t=a.name,r=J.cloneNode(e.ast,!0),i={...e,ast:r},ti(i,ef(i,{entry:t})),i):e).ast,d=[],ea(o,{ArrowFunctionExpression(e){e3(e.node,s)&&d.push({type:"ref",loc:e.node.loc?.start})},CallExpression(e){te(e.node,s)&&d.push({type:"link",loc:e.node.loc?.start})}}),d).forEach(t=>l.push({file:e.relPath,...t}))};for(var p of d)yield*c(p);if(t.strict&&l.length>0)return{file:n.relPath,entry:a.name,id:a.id,outcome:"refused",touchedSites:l,verify:{status:"skipped",errors:[]},summary:`refused to remove ${eq(n,a)}; ${l.length} reference(s) found`};var u=function*(t){var r=[],i={dataCalc:t.absPath.split(X.sep).includes("data-calc")};if(t.absPath===n.absPath&&(ti(t,ef(t,{entry:a.name})),r.push({action:"remove_entry",path:a.name})),tr(t.ast.program,s,r,[],i),0===r.length)return 1;var o=yield eK(t);ed(o,t.relPath),yield(0,G.writeFile)((yield ep(e,t.absPath)),o),r.forEach(e=>l.push({file:t.relPath,...e}))};for(var f of d)if(yield*u(f))continue;var m=yield(0,Q.H)(e,t.verify);return{file:n.relPath,entry:a.name,id:a.id,outcome:"compile:failed"===m.status?"verify_failed":"ok",touchedSites:l,verify:m,summary:`removed ${eq(n,a)} with ${l.length} touched site(s) -> ${m.status}`}}))}),function(e,t){return N.apply(this,arguments)}),ts=(T=D(function*(e,t){return eM(e,"new_subspace",t,D(function*(){var r=X.join(e,"root.ts"),i=(0,ee.RI)(e,r),n=yield(0,G.readFile)(r,"utf8").catch(()=>null);if(null==n)throw new eo("invalid_file","Project has no root.ts to wire the subspace into");var a={source:n,ast:ed(n,i),projectDir:e,absPath:r,relPath:i},s=a.ast.program.body.find(e=>J.isExportDefaultDeclaration(e));if(!s||!J.isArrayExpression(s.declaration))throw new eo("fallback_recommended","root.ts default export is not a subspace array literal; wire the new subspace manually",{file:i});var o=(yield ev(e)).reduce((e,t)=>{var r=/^subspace-(\d+)$/.exec(X.basename(t));return r?Math.max(e,Number(r[1])):e},-1)+1,l=`subspace-${o}`,d=X.join(e,"subspaces",l),c=`SUBSPACE_${(0,W.randomUUID)()}`,p=`CANVAS_${(0,W.randomUUID)()}`,u=(({subspaceId:e,canvasId:t,title:r,description:i,layout:n,portal:a})=>{var s=[`width: ${n.width}`,`height: ${n.height}`,...n.resizeMode?[`resizeMode: '${n.resizeMode}'`]:[]];return{"data.ts":"import type { Data } from 'bricks-ctor'\n","bricks.ts":"import type { Brick } from 'bricks-ctor'\n","generators.ts":"import type { Generator } from 'bricks-ctor'\n","animations.ts":"import type { Animation } from 'bricks-ctor'\n","canvases.ts":`import type { Canvas } from 'bricks-ctor'
4
+ `)}}),function(e){return i.apply(this,arguments)}),p=(n=a(function*(e,t){var r=o.join(e,".bricks");yield(0,s.mkdir)(r,{recursive:!0}),yield d(e),yield(0,s.appendFile)(o.join(r,"edits.jsonl"),`${JSON.stringify(t)}
5
+ `)}),function(e,t){return n.apply(this,arguments)}),c=()=>({session:process.env.BRICKS_CTOR_SESSION_ID||process.env.CODEX_SESSION_ID,agent:process.env.BRICKS_CTOR_AGENT_ID||process.env.USER})},98009(e,t,r){r.d(t,{Gp:()=>v,HJ:()=>x,Hn:()=>p,JJ:()=>w,Kx:()=>j,LJ:()=>y,Pb:()=>g,RI:()=>u,bf:()=>b,jc:()=>_,u4:()=>c,z5:()=>m,zu:()=>h});var i,n,a=r(68832),s=r(99436),o=r(58135),l=r(51455),d=r(76760),p={trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100},c=e=>!!e&&"object"==typeof e&&!Array.isArray(e),u=(e,t)=>d.relative(e,t).replace(/\\/g,"/").replace(/^\.\/+/,""),f=(e,t)=>{var r=d.relative(e,t);return""!==r&&(r.startsWith(`..${d.sep}`)||".."===r||d.isAbsolute(r))?null:t},y=(i=s(function*(e,t){var r=a((yield Promise.all([(0,l.realpath)(e),(0,l.realpath)(t)])),2);return f(r[0],r[1])}),function(e,t){return i.apply(this,arguments)}),m=(n=s(function*(e,t){var r=yield(0,l.lstat)(t).catch(e=>{if(e?.code==="ENOENT")return null;throw e}),i=yield(0,l.realpath)(e);if(r){var n=yield(0,l.realpath)(t).catch(e=>{if(e?.code==="ENOENT")return null;throw e});return n?f(i,n):null}var a=yield(0,l.realpath)(d.dirname(t));return f(i,d.join(a,d.basename(t)))}),function(e,t){return n.apply(this,arguments)}),v=e=>o.isIdentifier(e)?e.name:o.isStringLiteral(e)||o.isNumericLiteral(e)?String(e.value):null,h=e=>/^[$A-Z_a-z][$\w]*$/.test(e)?o.identifier(e):o.stringLiteral(e),b=(e,t)=>e.properties.find(e=>!!o.isObjectProperty(e)&&v(e.key)===t),w=(e,t)=>{var r=b(e,t);if(r&&o.isStringLiteral(r.value))return r.value.value},x=(e,t,r)=>{var i=b(e,t);if(i){i.value=r;return}e.properties.push(o.objectProperty(h(t),r))},_=(e,t)=>{var r=e.properties.findIndex(e=>!!o.isObjectProperty(e)&&v(e.key)===t);r>=0&&e.properties.splice(r,1)},g=(e,t)=>{var r=e.program.body,i=r.findLastIndex(e=>o.isImportDeclaration(e));r.splice(i+1,0,t)},j=(e,t,r)=>{var i=new Set(Array.from(r).filter(Boolean));if(0!==i.size){var n,a=function(e){return o.isImportDeclaration(e)&&"bricks-ctor"===e.source.value&&"type"===t==("type"===e.importKind)?(e.specifiers.forEach(e=>{if(o.isImportSpecifier(e)){var t=e.imported;o.isIdentifier(t)&&i.delete(t.name),o.isStringLiteral(t)&&i.delete(t.value)}}),i.forEach(t=>{e.specifiers.push(o.importSpecifier(o.identifier(t),o.identifier(t)))}),{v:void 0}):0};for(var s of e.program.body)if(0!==(n=a(s))&&n)return n.v;var l=o.importDeclaration(Array.from(i).map(e=>o.importSpecifier(o.identifier(e),o.identifier(e))),o.stringLiteral("bricks-ctor"));"type"===t&&(l.importKind="type"),g(e,l)}}},54452(e,t,r){r.d(t,{H:()=>p});var i,n,a=r(99436),s=r(75720),o=r(2985),l={FORCE_COLOR:"0",NO_COLOR:"1"},d=(i=a(function*(e){var t=yield(0,o.Re)(e);try{yield(0,s.sh)`bun compile`.cwd(e).env({...l,BRICKS_CTOR_ENABLE_EDITING_TOOLS:"0"}).text()}catch(e){var r=[e.stdout?.toString()??"",e.stderr?.toString()??"",e.message].filter(Boolean).join("\n").trim();return{status:"compile:failed",errors:r?[r]:["bun compile failed"]}}var i=yield(0,o.Re)(e);return{status:"compile:ok",errors:[],configChange:(0,o.m4)(t,i)}}),function(e){return i.apply(this,arguments)}),p=(n=a(function*(e,t){return(void 0!==t?t:!["0","false","no","off"].includes((process.env.BRICKS_CTOR_MCP_EDIT_VERIFY??"true").toLowerCase()))?d(e):{status:"skipped",errors:[]}}),function(e,t){return n.apply(this,arguments)})},85949(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>tv,register:()=>tm});var n,a,s,o,l,d,p,c,u,f,y,m,v,h,b,w,x,_,g,j,P,k,E,S,$,A,I,O,C,N,T,R=r(68832),D=r(99436),L=r(44668),F=r(5018),B=r(63315),K=r(30409),z=r(40906),U=r(59410),M=r(2235),q=r(46773),Y=r(80004),J=r(58135),H=r(11978),V=r(79491),G=r(51455),W=r(77598),X=r(76760),Z=r(84867),Q=r(54452),ee=r(98009),et=r(3540),er=e([V]);function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}V=(er.then?(await er)():er)[0];var en=M.default||M,ea=Y.default||Y,es={"bricks.ts":{kind:"brick",namespace:"bricks",varPrefix:"b",idType:"brick",idPrefix:"BRICK_",typename:"Brick"},"generators.ts":{kind:"generator",namespace:"generators",varPrefix:"g",idType:"generator",idPrefix:"GENERATOR_",typename:"Generator"},"canvases.ts":{kind:"canvas",namespace:"canvases",varPrefix:"c",idType:"canvas",idPrefix:"CANVAS_",typename:"Canvas"},"data.ts":{kind:"data",namespace:"data",varPrefix:"d",idType:"data",idPrefix:"PROPERTY_BANK_DATA_NODE_",typename:"Data"},"animations.ts":{kind:"animation",namespace:"animations",varPrefix:"a",idType:"animation",idPrefix:"ANIMATION_",typename:"Animation"}},eo=function(e){function t(e,r,i,n=!1){var a,s,o;return F(this,t),s=t,o=[r],s=K(s),(a=B(this,ei()?Reflect.construct(s,o||[],K(this).constructor):s.apply(this,o))).name="EntryEditingError",a.code=e,a.details=i,a.isMcpError=n,a}return z(t,e),L(t)}(U(Error)),el=(e,t)=>{if(X.isAbsolute(t))throw new eo("invalid_file","File must be project-relative",{file:t});var r=X.resolve(e,t),i=X.relative(e,r);if(i.startsWith("..")||X.isAbsolute(i))throw new eo("invalid_file","File must stay inside the project directory",{file:t});return r},ed=(e,t)=>{try{return(0,q.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new eo("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},ep=(n=D(function*(e,t){var r=yield(0,ee.LJ)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});var i=yield(0,G.readFile)(r,"utf8"),n=(0,ee.RI)(e,t);return{source:i,ast:ed(i,n),projectDir:e,absPath:t,ioPath:r,relPath:n,kind:(e=>{var t=X.basename(e),r=es[t];if(!r)throw new eo("unsupported_file",`Unsupported entry file: ${t}`,{file:e,expected:Object.keys(es)});return r})(t)}}),function(e,t){return n.apply(this,arguments)}),ec=(a=D(function*(e,t){var r=yield(0,ee.z5)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});return r}),function(e,t){return a.apply(this,arguments)}),eu=e=>e.program.body.flatMap(e=>{if(!J.isExportNamedDeclaration(e)||!J.isVariableDeclaration(e.declaration))return[];var t=e.declaration;return t.declarations.flatMap(r=>{if(!J.isIdentifier(r.id))return[];var i,n=r.id.typeAnnotation;J.isTSTypeAnnotation(n)&&J.isTSTypeReference(n.typeAnnotation)&&J.isIdentifier(n.typeAnnotation.typeName)&&(i=n.typeAnnotation.typeName.name);var a=J.isObjectExpression(r.init)?r.init:void 0;return[{name:r.id.name,node:e,declaration:t,declarator:r,object:a,id:a?(0,ee.JJ)(a,"id"):void 0,alias:a?(0,ee.JJ)(a,"alias"):void 0,typeName:i}]})}),ef=(e,t)=>{var r=eu(e.ast);if(t.entry){var i=r.find(e=>e.name===t.entry);if(i)return i;var n=r.filter(e=>e.alias===t.entry);if(1===n.length)return n[0];if(n.length>1)throw new eo("ambiguous_reference",`Alias is ambiguous: ${t.entry}`,{file:e.relPath,entry:t.entry,matches:n.map(e=>e.name)});throw new eo("entry_not_found",`Entry not found (by name or alias): ${t.entry}`,{file:e.relPath,entry:t.entry})}if(t.id){var a=r.find(e=>e.id===t.id);if(!a)throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{file:e.relPath,id:t.id});return a}throw new eo("missing_target","Provide entry or id")},ey=e=>e.split(X.sep).find(e=>/^subspace-\d+$/.test(e))||"unknown-subspace",em=e=>{var t=e.split(X.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new eo("invalid_file","Entry file must be inside subspaces/subspace-N",{file:e});return t.slice(0,r+1).join(X.sep)},ev=(s=D(function*(e){var t=X.join(e,"subspaces");return(yield(0,G.readdir)(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&/^subspace-\d+$/.test(e.name)).map(e=>X.join(t,e.name)).sort()}),function(e){return s.apply(this,arguments)}),eh=(o=D(function*(e){var t=Object.keys(es),r=yield(0,G.readdir)(e,{withFileTypes:!0}).catch(()=>[]),i=new Set(r.filter(e=>e.isFile()).map(e=>e.name));return t.filter(e=>i.has(e)).map(t=>X.join(e,t))}),function(e){return o.apply(this,arguments)}),eb=(l=D(function*(e){var t=yield ev(e);return(yield Promise.all(t.map(eh))).flat()}),function(e){return l.apply(this,arguments)}),ew=(d=D(function*(e,t){if(t.file)return el(e,t.file);if(!t.id)throw new eo("missing_file","Provide file, or provide id for global lookup");for(var r of yield eb(e)){var i=yield ep(e,r);if(eu(i.ast).find(e=>e.id===t.id))return r}throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{id:t.id})}),function(e,t){return d.apply(this,arguments)}),ex=(p=D(function*(e,t){var r=yield ew(e,t),i=yield ep(e,r),n=ef(i,t),a=((e,t)=>{if(!e.object)throw new eo("fallback_recommended",`Entry ${e.name} in ${t} is not a top-level exported object literal. Edit this file directly for this one.`,{file:t,entry:e.name,check:"top-level export const object literal"});return e.object})(n,i.relPath);return{parsed:i,entry:n,object:a}}),function(e,t){return p.apply(this,arguments)}),e_=(e,t)=>J.callExpression(J.identifier("makeId"),t?[J.stringLiteral(e),J.stringLiteral(t)]:[J.stringLiteral(e)]),eg=e=>{var t=[];for(var r of e.split(".").filter(Boolean))for(var i=/([^\[\]]+)|\[(\d+)\]/g,n=void 0;n=i.exec(r);)n[1]&&t.push({key:n[1]}),n[2]&&t.push({index:Number(n[2])});if(0===t.length)throw new eo("invalid_path",`Invalid path: ${e}`,{path:e});return t},ej=e=>J.isTSAsExpression(e)||J.isTSSatisfiesExpression(e)||J.isTSNonNullExpression(e)||J.isParenthesizedExpression(e)?ej(e.expression):e,eP=(e,t)=>{var r=ej(e);if(!J.isObjectExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an object literal. Edit this file directly for this one.`,{path:t,expected:"object literal",actual:r.type});return r},ek=(e,t)=>{var r=ej(e);if(!J.isArrayExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an array literal. Edit this file directly for this one.`,{path:t,expected:"array literal",actual:r.type});return r},eE=e=>"array"==("index"in e?"array":"object")?J.arrayExpression([]):J.objectExpression([]),eS=(c=D(function*(e,t,r,i){for(var n=eg(t),a=e,s=0;s<n.length;s+=1){var o=n[s],l=s===n.length-1;if("key"in o){var d=eP(a,t);if(l)return void(0,ee.HJ)(d,o.key,(yield eB(r,i)));var p=n[s+1],c=(0,ee.bf)(d,o.key);c||(c=J.objectProperty((0,ee.zu)(o.key),eE(p)),d.properties.push(c)),a=c.value;continue}var u=ek(a,t);if(o.index<0||o.index>u.elements.length)throw new eo("invalid_path",`Array index out of range for ${t}`,{path:t,index:o.index});if(l){u.elements[o.index]=yield eB(r,i);return}u.elements[o.index]||(u.elements[o.index]=eE(n[s+1])),a=u.elements[o.index]}}),function(e,t,r,i){return c.apply(this,arguments)}),e$=(e,t)=>{for(var r=eg(t),i=e,n=0;n<r.length;n+=1){var a=r[n],s=n===r.length-1;if("key"in a){var o=eP(i,t);if(s)return void(0,ee.jc)(o,a.key);var l=(0,ee.bf)(o,a.key);if(!l)return;i=l.value;continue}var d=ek(i,t);if(a.index<0||a.index>=d.elements.length)return;if(s)return void d.elements.splice(a.index,1);var p=d.elements[a.index];if(!p)return;i=p}},eA=(e,t)=>{var r=(0,ee.bf)(e,"switches");if(!r)throw new eo("fallback_recommended","Entry has no switches array",{path:"switches"});var i=ek(r.value,"switches"),n="number"==typeof t?t:i.elements.findIndex(e=>J.isObjectExpression(e)&&(0,ee.JJ)(e,"id")===t);if(n<0||n>=i.elements.length)throw new eo("entry_not_found",`Switch not found: ${t}`,{switch:t});var a=i.elements[n];if(!J.isObjectExpression(a))throw new eo("fallback_recommended",`Switch ${String(t)} is not an object literal. Edit this file directly for this one.`,{switch:t});return a},eI=(e,t)=>{var r=t.replace(/\.[tj]sx?$/,""),i=X.relative(X.dirname(e),r).replace(/\\/g,"/");return i.startsWith(".")||(i=`./${i}`),i},eO=e=>{var t=new Set;return e.program.body.forEach(e=>{J.isImportDeclaration(e)?e.specifiers.forEach(e=>t.add(e.local.name)):J.isExportNamedDeclaration(e)&&J.isVariableDeclaration(e.declaration)&&e.declaration.declarations.forEach(e=>{J.isIdentifier(e.id)&&t.add(e.id.name)})}),t},eC=(e,t,r)=>{for(var i of e.ast.program.body)if(J.isImportDeclaration(i)&&i.source.value===t){var n=i.specifiers.find(e=>J.isImportDefaultSpecifier(e));if(n)return n.local.name}var a=eO(e.ast),s=r;if(a.has(s)){for(var o=1;a.has(`${s}${o}`);)o+=1;s=`${s}${o}`}var l=J.importDeclaration([J.importDefaultSpecifier(J.identifier(s))],J.stringLiteral(t));return(0,ee.Pb)(e.ast,l),s},eN=e=>{(0,ee.Kx)(e.parsed.ast,"type",e.typeImports),(0,ee.Kx)(e.parsed.ast,"value",e.valueImports)},eT=(u=D(function*(e,t,r){if(null==r||""===r)return t;if("number"==typeof r)return X.join(e,"subspaces",`subspace-${r}`);var i=String(r);if(/^\d+$/.test(i))return X.join(e,"subspaces",`subspace-${i}`);if(/^subspace-\d+$/.test(i))return X.join(e,"subspaces",i);if(i.includes("/"))return el(e,i);var n,a=yield ev(e),s=function*(){var t=X.join(o,"index.ts"),r=yield(0,G.readFile)(t,"utf8").catch(()=>"");if(!r)return 0;var n=ed(r,(0,ee.RI)(e,t)),a=!1;if(ea(n,{ObjectProperty(e){"id"===(0,ee.Gp)(e.node.key)&&J.isStringLiteral(e.node.value)&&e.node.value.value===i&&(a=!0,e.stop())}}),a)return{v:o}};for(var o of a)if(n=yield*s(),0!==n&&n)return n.v;throw new eo("reference_not_found",`Subspace not found: ${i}`,{subspace:i})}),function(e,t,r){return u.apply(this,arguments)}),eR=(f=D(function*(e,t){var r,i,n=em(e.parsed.absPath),a=yield eT(e.projectDir,n,t),s=X.basename(a),o=/^subspace-(\d+)$/.exec(s);if(!o)throw new eo("invalid_subspace",`Not a subspace directory: ${s}`,{subspace:t});var l=X.join(a,"index.ts"),d=yield(0,G.readFile)(l,"utf8").catch(()=>null);if(null==d)throw new eo("reference_not_found",`Subspace not found: ${t}`,{subspace:t});var p=(r=ed(d,(0,ee.RI)(e.projectDir,l)),ea(r,{ObjectProperty(e){if("id"===(0,ee.Gp)(e.node.key)){var t=e.node.value;J.isStringLiteral(t)&&t.value.startsWith("SUBSPACE_")&&(i=t.value,e.stop())}}}),i);if(!p)throw new eo("invalid_subspace",`Subspace index has no SUBSPACE_ id: ${s}/index.ts`,{subspace:t});return{id:p,index:Number(o[1]),label:s,indexPath:l,isCurrent:X.resolve(a)===X.resolve(n)}}),function(e,t){return f.apply(this,arguments)}),eD=(y=D(function*(e,t){var r=yield eR(e,t);if(r.isCurrent)return e.references.push({input:t,id:r.id,sameFile:!1,display:`'${r.id}'`,targetAbsPath:r.indexPath}),{resolved:r,expression:J.stringLiteral(r.id)};var i=eC(e.parsed,`../${r.label}`,`subspace${r.index}`);return e.references.push({input:t,id:r.id,sameFile:!1,display:`() => ${i}`,targetAbsPath:r.indexPath}),{resolved:r,expression:J.arrowFunctionExpression([],J.identifier(i))}}),function(e,t){return y.apply(this,arguments)}),eL=(m=D(function*(e,t,r,i){var n=em(t),a=yield eT(e,n,i),s=yield eh(a),o=[];for(var l of s){var d=yield ep(e,l),p=d.kind;for(var c of eu(d.ast))if(c.name===r||c.id===r||c.alias===r){var u=X.resolve(l)===X.resolve(t),f=X.basename(a);o.push({input:r,id:c.id,alias:c.alias,varName:c.name,namespace:p.namespace,display:`${p.namespace}.${c.name}`,targetAbsPath:l,sameFile:u,subspaceLabel:f,importSource:u?void 0:eI(t,l)})}}if(0===o.length)throw new eo("reference_not_found",`Reference not found: ${r}`,{ref:r,subspace:i??X.basename(n)});if(o.length>1)throw new eo("ambiguous_reference",`Reference is ambiguous: ${r}`,{ref:r,matches:o.map(t=>({file:(0,ee.RI)(e,t.targetAbsPath),entry:t.varName,id:t.id,alias:t.alias}))});return o[0]}),function(e,t,r,i){return m.apply(this,arguments)}),eF=(v=D(function*(e,t,r){var i=yield eL(t.projectDir,t.parsed.absPath,e,r);if(i.sameFile)return t.references.push(i),J.identifier(i.varName);var n=em(t.parsed.absPath),a=em(i.targetAbsPath),s=i.subspaceLabel.replace(/[^a-zA-Z0-9_$]/g,""),o=n===a?i.namespace:`${s}${i.namespace[0].toUpperCase()}${i.namespace.slice(1)}`,l=((e,t,r,i)=>{for(var n of e.ast.program.body)if(J.isImportDeclaration(n)&&n.source.value===r){var a=n.specifiers.find(J.isImportNamespaceSpecifier);if(a)return a.local.name}var s=eO(e.ast),o=i;if(s.has(o)){for(var l=1;s.has(`${o}${l}`);)l+=1;o=`${o}${l}`}var d=J.importDeclaration([J.importNamespaceSpecifier(J.identifier(o))],J.stringLiteral(r));return(0,ee.Pb)(e.ast,d),o})(t.parsed,i.namespace,i.importSource,o);return i.importLocal=l,t.references.push({...i,display:`${l}.${i.varName}`,importLocal:l}),J.memberExpression(J.identifier(l),J.identifier(i.varName))}),function(e,t,r){return v.apply(this,arguments)}),eB=(h=D(function*(e,t){if((0,ee.u4)(e)&&"string"==typeof e.expr&&1===Object.keys(e).length){var r=e.expr;try{return(0,q.parseExpression)(r,{plugins:["typescript"]})}catch(e){throw new eo("invalid_expr",`Invalid TypeScript expression: ${e.message}`,{expr:r})}}if((0,ee.u4)(e)&&"string"==typeof e.link){t.valueImports.add("linkData");var i=yield eF(e.link,t,e.subspace);return J.callExpression(J.identifier("linkData"),[J.arrowFunctionExpression([],i)])}if((0,ee.u4)(e)&&"string"==typeof e.ref){var n=yield eF(e.ref,t,e.subspace);return J.arrowFunctionExpression([],n)}if(Array.isArray(e))return J.arrayExpression((yield Promise.all(e.map(e=>eB(e,t)))));if((0,ee.u4)(e)){var a,s=yield Promise.all(Object.entries(e).map((a=D(function*([e,r]){return J.objectProperty((0,ee.zu)(e),(yield eB(r,t)))}),function(e){return a.apply(this,arguments)})));return J.objectExpression(s)}return void 0===e?J.identifier("undefined"):J.valueToNode(e)}),function(e,t){return h.apply(this,arguments)}),eK=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,resolved:e.importLocal?`${e.importLocal}.${e.varName}`:e.sameFile?e.varName:e.display,file:e.targetAbsPath})),ez=(b=D(function*(e){var t=en(e.ast,{comments:!0},e.source).code,r=yield(0,V.format)(e.absPath,t,ee.Hn);if(r.errors.length>0)throw new eo("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return b.apply(this,arguments)}),eU=(w=D(function*(e){var t=yield ez(e);return ed(t,e.relPath),yield(0,G.writeFile)(e.ioPath??(yield ec(e.projectDir,e.absPath)),t),t}),function(e){return w.apply(this,arguments)}),eM=(e,t)=>{if(e){var r=ey(e.absPath);return`${t?.name||"entry"} (${e.kind.kind}, ${r})`}},eq=(x=D(function*(e,t,r,i){var n={ts:new Date().toISOString(),tool:t,op:r?.op||(r?.set?"set":r?.unset?"unset":t),target:{file:r?.file,entry:r?.entry,id:r?.id},provenance:(0,et.S)()};try{var a=yield i(),s={...n,...a};return yield(0,et.a)(e,s).catch(e=>{s.auditError=e.message}),s}catch(i){var o=i instanceof eo?i:new eo("error",i.message||String(i),void 0,!0),l="fallback_recommended"===o.code?"fallback_recommended":"error",d={...n,outcome:l,input:r,error:{code:o.code,message:o.message,details:o.details},summary:"fallback_recommended"===l?`${t} could not safely edit this standard path; edit the file directly`:`${t} failed: ${o.message}`,isError:o.isMcpError||"error"===l};return yield(0,et.a)(e,d).catch(e=>{d.auditError=e.message}),d}}),function(e,t,r,i){return x.apply(this,arguments)}),eY=(_=D(function*(e,t){return eq(e,"edit_entry",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eA(a,t.switch);for(var l of Object.entries(t.set||{})){var d=R(l,2),p=d[0],c=d[1];yield eS(o,p,c,s)}for(var u of[...t.unset||[]].sort((e,t)=>{for(var r=eg(e).map(e=>"index"in e?e.index:-1),i=eg(t).map(e=>"index"in e?e.index:-1),n=0;n<Math.min(r.length,i.length);n+=1)if(r[n]!==i[n])return i[n]-r[n];return i.length-r.length}))e$(o,u);eN(s),yield eU(i);var f=yield(0,Q.H)(e,t.verify),y=eM(i,n);return{file:i.relPath,entry:n.name,id:n.id,change:{set:t.set||{},unset:t.unset||[],references:eK(s.references)},outcome:"compile:failed"===f.status?"verify_failed":"ok",verify:f,summary:`edited ${y} -> ${f.status}`}}))}),function(e,t){return _.apply(this,arguments)}),eJ=e=>{switch(e){case"IfStatement":return"an if statement";case"ForStatement":case"ForOfStatement":case"ForInStatement":return"a for loop";case"WhileStatement":case"DoWhileStatement":return"a while loop";case"SwitchStatement":return"a switch statement";case"TryStatement":return"a try/catch block";case"FunctionDeclaration":return"a function declaration";case"ReturnStatement":return"a return before the final statement";default:return`a ${e}`}},eH=(e,t)=>{for(var r=0;r<e.length;r+=1){var i=e[r],n=r===e.length-1;if("ExpressionStatement"===i.type){var a=eV(i.expression);if(a)return a;continue}if("VariableDeclaration"===i.type){for(var s of i.declarations)if("Identifier"!==s.id.type||!s.init)return"a destructuring or uninitialized declaration";continue}if(t&&n&&"ReturnStatement"===i.type){var o=i.argument?eV(i.argument):null;if(o)return o;continue}return eJ(i.type)}return null},eV=e=>{if(e?.type!=="CallExpression"||e.arguments?.length||e.callee?.type!=="ArrowFunctionExpression"&&e.callee?.type!=="FunctionExpression")return null;var t=e.callee.body;return t?.type==="BlockStatement"?eH(t.body,!0):eV(t)},eG=(g=D(function*(e,t){if(e?.expr)return eB(e,t);var r,i=(e=>{if(!(0,ee.u4)(e)||!(0,ee.u4)(e.action))return e;var t=e.action,r={handler:e.handler,name:t.name??t.__actionName,waitAsync:e.waitAsync};if(t.cast&&(r.cast=t.cast),Array.isArray(t.params))for(var i of(r.params={},t.params)){if(!(0,ee.u4)(i)||"string"!=typeof i.input)throw new eo("invalid_action",'Compiled action params entries require { input: "name", value }',{param:i});r.params[i.input]=i.value}if(Array.isArray(t.dataParams))for(var n of(r.dataParams={},t.dataParams)){var a=(0,ee.u4)(n?.input)?n.input.ref:n?.input;if("string"!=typeof a||!a)throw new eo("invalid_action","Compiled action dataParams entries require { input: dataRef, value }",{param:n});r.dataParams[a]=n.value}return r})(e),n=i?.name;if(!n)throw new eo("invalid_action","Action requires name");if("PROPERTY_BANK_EXPRESSION"===n&&(0,ee.u4)(i.params)){var a=i.params.expression;"string"==typeof a&&(e=>{try{t=(0,H.qg)(e,{ecmaVersion:2020})}catch(t){throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION does not parse: ${t.message}`,{expression:e})}var t,r=eH(t.body,!1);if(r)throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION cannot evaluate ${r}: the runtime folds the expression into a single expression (expression statements, simple const/let declarations, and a final return inside an IIFE only). Use ternaries instead of statements, or move branching logic to a DataCalculationScript.`,{expression:e})})(a)}var s="System",o=i.cast;if("system"===i.handler||null==i.handler)r=J.stringLiteral("system"),o||=`SystemAction${n.toLowerCase().split("_").filter(Boolean).map(e=>`${e[0].toUpperCase()}${e.slice(1)}`).join("")}`;else if((0,ee.u4)(i.handler)&&"string"==typeof i.handler.ref){var l=yield eL(t.projectDir,t.parsed.absPath,i.handler.ref,i.handler.subspace);if("bricks"!==l.namespace&&"generators"!==l.namespace)throw new eo("invalid_action",`Action handler must be a brick or generator, got ${l.namespace}: ${i.handler.ref}`,{handler:i.handler});s="bricks"===l.namespace?"Brick":"Generator";var d=yield eF(i.handler.ref,t,i.handler.subspace);r=J.arrowFunctionExpression([],d)}else if((0,ee.u4)(i.handler)&&null!=i.handler.subspace)r=(yield eD(t,i.handler.subspace)).expression,s="Subspace";else throw new eo("invalid_action","Unsupported action handler",{handler:i.handler});var p=[J.objectProperty(J.identifier("__actionName"),J.stringLiteral(n)),J.objectProperty(J.identifier("parent"),J.stringLiteral(s)),J.objectProperty(J.identifier("name"),J.stringLiteral(n))];if(i.params){var c,u=yield Promise.all(Object.entries(i.params).map((c=D(function*([e,r]){return J.objectExpression([J.objectProperty(J.identifier("input"),J.stringLiteral(e)),J.objectProperty(J.identifier("value"),(yield eB(r,t)))])}),function(e){return c.apply(this,arguments)})));p.push(J.objectProperty(J.identifier("params"),J.arrayExpression(u)))}if(i.dataParams){var f,y=yield Promise.all(Object.entries(i.dataParams).map((f=D(function*([e,r]){var i=yield eF(e,t);return J.objectExpression([J.objectProperty(J.identifier("input"),J.arrowFunctionExpression([],i)),J.objectProperty(J.identifier("value"),(yield eB(r,t)))])}),function(e){return f.apply(this,arguments)})));p.push(J.objectProperty(J.identifier("dataParams"),J.arrayExpression(y)))}var m=J.objectExpression(p);return o&&(t.typeImports.add(o),m=J.tsAsExpression(m,J.tsTypeReference(J.identifier(o)))),J.objectExpression([J.objectProperty(J.identifier("handler"),r),J.objectProperty(J.identifier("action"),m),J.objectProperty(J.identifier("waitAsync"),J.booleanLiteral(!!i.waitAsync))])}),function(e,t){return g.apply(this,arguments)}),eW=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=J.objectProperty((0,ee.zu)(t),J.objectExpression([])),e.properties.push(i)),eP(i.value,r)},eX=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=J.objectProperty((0,ee.zu)(t),J.arrayExpression([])),e.properties.push(i)),ek(i.value,r)},eZ=(j=D(function*(e,t){return eq(e,"edit_events",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eA(a,t.switch),l=t.op;if("clear"===l||"remove"===l||"move"===l){var d=(0,ee.bf)(o,"events"),p=d?eP(d.value,"events"):null,c=p?(0,ee.bf)(p,t.event):null,u=c?ek(c.value,`events.${t.event}`):null;if("clear"===l)p&&(0,ee.jc)(p,t.event);else if("move"===l){if(null==t.index)throw new eo("invalid_index","move requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var f=Number(t.to);if(!Number.isFinite(f)||f<0||f>=u.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var y=u.elements.splice(t.index,1),m=R(y,1)[0];u.elements.splice(f,0,m)}else{if(null==t.index)throw new eo("invalid_index","remove requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});u.elements.splice(t.index,1),0===u.elements.length&&p&&(0,ee.jc)(p,t.event)}}else if("add"===l||"replace"===l){var v=yield eG(t.action,s),h=eW(o,"events","events"),b=eX(h,t.event,`events.${t.event}`),w=t.index??b.elements.length;if("replace"===l){if(w<0||w>=b.elements.length)throw new eo("invalid_index","replace index out of range",{index:w});b.elements[w]=v}else{if(w<0||w>b.elements.length)throw new eo("invalid_index","add index out of range",{index:w});b.elements.splice(w,0,v)}}else throw new eo("invalid_op",`Unsupported edit_events op: ${l}`);eN(s),yield eU(i);var x=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{event:t.event,op:l,index:t.index,references:eK(s.references)},outcome:"compile:failed"===x.status?"verify_failed":"ok",verify:x,summary:`${l} event ${t.event} on ${eM(i,n)} -> ${x.status}`}}))}),function(e,t){return j.apply(this,arguments)}),eQ=e=>{if((0,ee.u4)(e)&&"string"==typeof e.expr)return e;if(!(0,ee.u4)(e))throw new eo("invalid_item","Canvas item requires frame { x, y, width, height }");for(var t of["x","y","width","height"])if("number"!=typeof e[t])throw new eo("invalid_item",`Canvas item frame requires numeric ${t}`,{frame:e});return e},e0=(P=D(function*(e,t,r){if(!e?.ref&&e?.subspace==null)throw new eo("invalid_item","Canvas item requires ref (brick) or subspace (embed)");var i,n=eQ(e.frame??r);if(e.ref){var a=yield eF(e.ref,t,e.subspace);i=J.arrowFunctionExpression([],a)}else{var s=yield eD(t,e.subspace),o=s.resolved,l=s.expression;if(o.isCurrent)throw new eo("invalid_item","A subspace cannot embed itself",{subspace:e.subspace});i=l}return J.objectExpression([J.objectProperty(J.identifier("item"),i),J.objectProperty(J.identifier("frame"),(yield eB(n,t))),...null==e.hidden?[]:[J.objectProperty(J.identifier("hidden"),J.booleanLiteral(!!e.hidden))]])}),function(e,t,r){return P.apply(this,arguments)}),e1=(k=D(function*(e,t){return eq(e,"edit_canvas_items",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object;if("canvas"!==i.kind.kind)throw new eo("invalid_file","edit_canvas_items only edits canvases.ts entries",{file:i.relPath});var s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eX(a,"items","items"),l=t.op;if("add"===l||"replace"===l){var d=yield e0(t.item,s,t.frame),p=t.index??o.elements.length;if("replace"===l){if(p<0||p>=o.elements.length)throw new eo("invalid_index","replace index out of range",{index:p});o.elements[p]=d}else{if(p<0||p>o.elements.length)throw new eo("invalid_index","add index out of range",{index:p});o.elements.splice(p,0,d)}}else if("remove"===l){if(null==t.index)throw new eo("invalid_index","remove requires index");if(t.index<0||t.index>=o.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});o.elements.splice(t.index,1)}else if("move"===l){if(null==t.index)throw new eo("invalid_index","move requires index");if(!t.frame)throw new eo("invalid_item","move requires frame");if(t.index<0||t.index>=o.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var c=o.elements[t.index];if(!J.isObjectExpression(c))throw new eo("fallback_recommended","Canvas item is not an object literal",{index:t.index});(0,ee.HJ)(c,"frame",(yield eB(eQ(t.frame),s)))}else throw new eo("invalid_op",`Unsupported edit_canvas_items op: ${l}`);eN(s),yield eU(i);var u=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:eK(s.references)},outcome:"compile:failed"===u.status?"verify_failed":"ok",verify:u,summary:`${l} canvas item on ${eM(i,n)} -> ${u.status}`}}))}),function(e,t){return k.apply(this,arguments)}),e4=(E=D(function*(e,t){var r=(e=>{switch(e?.__typename){case"SwitchCondInnerStateCurrentCanvas":return{type:"inner_state",key:"current_canvas",value:e.value,subspace:e.subspace};case"SwitchCondInnerStateOutlet":return{type:"inner_state",outlet:e.outlet,value:e.value};case"SwitchCondData":return{type:"property_bank",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondPropertyBankByItemKey":return{type:"property_bank_by_item_key",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondItemKeyMapping":return{type:"item_key_mapping",key:e.key,value:e.value};default:return e}})(e);if(r?.expr)return eB(r,t);if(r?.type==="inner_state"&&"current_canvas"===r.key){var i=yield eF(r.value,t,r.subspace);return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral("SwitchCondInnerStateCurrentCanvas")),J.objectProperty(J.identifier("value"),J.arrowFunctionExpression([],i))])}if(r?.type==="inner_state"){var n=r.outlet||r.key;if(!n)throw new eo("invalid_switch","Switch inner-state outlet condition requires outlet or key");return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral("SwitchCondInnerStateOutlet")),J.objectProperty(J.identifier("outlet"),J.stringLiteral(n)),J.objectProperty(J.identifier("value"),(yield eB(r.value,t)))])}if(r?.type==="item_key_mapping"){if(!r.key)throw new eo("invalid_switch","Switch item key mapping condition requires key");return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral("SwitchCondItemKeyMapping")),J.objectProperty(J.identifier("key"),J.stringLiteral(r.key)),J.objectProperty(J.identifier("value"),(yield eB(r.value,t)))])}var a=r?.ref||r?.data||r?.key;if(!a)throw new eo("invalid_switch","Switch condition requires data ref");var s=yield eF(a,t,r.subspace);return J.objectExpression([J.objectProperty(J.identifier("__typename"),J.stringLiteral(r?.type==="property_bank_by_item_key"?"SwitchCondPropertyBankByItemKey":"SwitchCondData")),J.objectProperty(J.identifier("data"),J.arrowFunctionExpression([],s)),J.objectProperty(J.identifier("value"),(yield eB(r.value,t)))])}),function(e,t){return E.apply(this,arguments)}),e5=new Set(["id","title","description","conds","override","property","outlets","animation","events","disabled","break"]),e9=(S=D(function*(e,t){for(var r of Object.keys(e))if(!e5.has(r))throw new eo("invalid_switch",`Unknown switch field: ${r}`,{field:r,supported:Array.from(e5)});if(void 0!==e.events)throw new eo("invalid_switch","Set switch events with edit_events using its switch parameter");if(e.id&&!/^BRICK_STATE_GROUP_[0-9a-fA-F-]{36}$/.test(e.id))throw new eo("invalid_switch","Switch id must match BRICK_STATE_GROUP_<uuid>; omit id to generate one",{id:e.id});var i,n=e.id?J.stringLiteral(e.id):e_("switch");e.id||t.valueImports.add("makeId");var a=[J.objectProperty(J.identifier("id"),n)];for(var s of(null!=e.title&&a.push(J.objectProperty(J.identifier("title"),J.stringLiteral(e.title))),null!=e.description&&a.push(J.objectProperty(J.identifier("description"),J.stringLiteral(e.description))),e.conds&&a.push(J.objectProperty(J.identifier("conds"),J.arrayExpression((yield Promise.all(e.conds.map((i=D(function*(e){return J.objectExpression([J.objectProperty(J.identifier("method"),J.stringLiteral(e.method||"==")),J.objectProperty(J.identifier("cond"),(yield e4(e.cond||e,t)))])}),function(e){return i.apply(this,arguments)}))))))),e.override&&a.push(J.objectProperty(J.identifier("override"),(yield eB(e.override,t)))),["property","outlets","animation"]))null!=e[s]&&a.push(J.objectProperty(J.identifier(s),(yield eB(e[s],t))));return null!=e.disabled&&a.push(J.objectProperty(J.identifier("disabled"),J.booleanLiteral(!!e.disabled))),null!=e.break&&a.push(J.objectProperty(J.identifier("break"),J.booleanLiteral(!!e.break))),J.objectExpression(a)}),function(e,t){return S.apply(this,arguments)}),e8=($=D(function*(e,t){return eq(e,"edit_switches",t,D(function*(){var r=yield ex(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eX(a,"switches","switches"),l=t.op,d=e=>"number"==typeof e?e:e?o.elements.findIndex(t=>J.isObjectExpression(t)&&(0,ee.JJ)(t,"id")===e):-1;if("add"===l||"replace"===l){var p=yield e9(t.switch||{},s),c=null==t.index?o.elements.length:d(t.index);if("replace"===l){if(c<0||c>=o.elements.length)throw new eo("invalid_index","replace index out of range",{index:c});o.elements[c]=p}else{if(c<0||c>o.elements.length)throw new eo("invalid_index","add requires a valid switch id or index",{index:t.index});o.elements.splice(c,0,p)}}else if("remove"===l){var u=d(t.index);if(u<0||u>=o.elements.length)throw new eo("invalid_index","remove requires a valid switch id or index",{index:t.index});o.elements.splice(u,1)}else if("move"===l){var f=d(t.index);if(f<0||f>=o.elements.length)throw new eo("invalid_index","move requires a valid switch id or index",{index:t.index});var y=Number(t.to);if(!Number.isFinite(y)||y<0||y>=o.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var m=o.elements.splice(f,1),v=R(m,1)[0];o.elements.splice(y,0,v)}else throw new eo("invalid_op",`Unsupported edit_switches op: ${l}`);eN(s),yield eU(i);var h=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:eK(s.references)},outcome:"compile:failed"===h.status?"verify_failed":"ok",verify:h,summary:`${l} switch on ${eM(i,n)} -> ${h.status}`}}))}),function(e,t){return $.apply(this,arguments)}),e6=(A=D(function*(e,t,r,i){var n=[J.objectProperty(J.identifier("__typename"),J.stringLiteral(e.typename)),J.objectProperty(J.identifier("id"),r)];return t.alias&&n.push(J.objectProperty(J.identifier("alias"),J.stringLiteral(t.alias))),null!=t.title&&n.push(J.objectProperty(J.identifier("title"),J.stringLiteral(t.title))),null!=t.description&&n.push(J.objectProperty(J.identifier("description"),J.stringLiteral(t.description))),"brick"===e.kind||"generator"===e.kind?(n.push(J.objectProperty(J.identifier("templateKey"),J.stringLiteral(t.templateKey||""))),n.push(J.objectProperty(J.identifier("property"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("outlets"),J.objectExpression([]))),"brick"===e.kind&&n.push(J.objectProperty(J.identifier("animation"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("switches"),J.arrayExpression([])))):"canvas"===e.kind?(n.push(J.objectProperty(J.identifier("property"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("switches"),J.arrayExpression([]))),n.push(J.objectProperty(J.identifier("items"),J.arrayExpression([])))):"data"===e.kind?(n.push(J.objectProperty(J.identifier("type"),J.stringLiteral(t.dataType||"any"))),n.push(J.objectProperty(J.identifier("schema"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("events"),J.objectExpression([]))),n.push(J.objectProperty(J.identifier("value"),J.identifier("undefined")))):"animation"===e.kind&&(n.push(J.objectProperty(J.identifier("runType"),J.stringLiteral("once"))),n.push(J.objectProperty(J.identifier("property"),J.stringLiteral("opacity"))),n.push(J.objectProperty(J.identifier("config"),(yield eB({__type:"AnimationTimingConfig",toValue:1,duration:300,easing:"",delay:0,isInteraction:!0},i))))),J.objectExpression(n)}),function(e,t,r,i){return A.apply(this,arguments)}),e7=(I=D(function*(e,t,r){var i=X.basename(t);for(var n of(yield eb(e)).filter(e=>X.basename(e)===i)){var a=yield ep(e,n);if(eu(a.ast).some(e=>e.alias===r))return!0}return!1}),function(e,t,r){return I.apply(this,arguments)}),e2=(O=D(function*(e,t){return eq(e,"new_entry",t,D(function*(){if(!t.file)throw new eo("missing_file","new_entry requires file");if(!t.type)throw new eo("missing_type","new_entry requires TypeScript type");var r=el(e,t.file),i=yield ep(e,r),n=new Set(eu(i.ast).map(e=>e.name)),a="string"==typeof t.id?t.id:void 0,s=a||"string"!=typeof t.alias||!t.alias||(yield e7(e,r,t.alias))?void 0:t.alias,o=a?J.stringLiteral(a):e_(i.kind.idType,s),l=t.entry||((e,t,r,i)=>{var n,a=(e=>{if(!e)return null;var t=e.replace(/[^a-zA-Z0-9_$]/g,"");return t?(/^[0-9]/.test(t)&&(t=`_${t}`),t):null})(i)||(r?`${t.varPrefix}${n=r.replace(/^[A-Z_]+/g,""),`${n.substr(15,3)}${n.substr(20,1)}`}`:`${t.varPrefix}Entry`);if(!e.has(a))return a;for(var s=1;e.has(`${a}${s}`);)s+=1;return`${a}${s}`})(n,i.kind,a,t.alias||t.title),d={projectDir:e,parsed:i,references:[],typeImports:new Set([t.type]),valueImports:new Set};a||d.valueImports.add("makeId");var p=yield e6(i.kind,t,o,d),c=J.variableDeclarator(J.identifier(l),p);for(var u of(c.id.typeAnnotation=J.tsTypeAnnotation(J.tsTypeReference(J.identifier(t.type))),i.ast.program.body.push(J.exportNamedDeclaration(J.variableDeclaration("const",[c]))),Object.entries(t.set||{}))){var f=R(u,2),y=f[0],m=f[1];yield eS(p,y,m,d)}for(var v of t.events||[]){if(!(0,ee.u4)(v)||"string"!=typeof v.event||!v.event||!v.action)throw new eo("invalid_action","events entries require { event, action }",{event:v});var h=eW(p,"events","events");eX(h,v.event,`events.${v.event}`).elements.push((yield eG(v.action,d)))}eN(d),yield eU(i);var b=yield(0,Q.H)(e,t.verify);return{file:i.relPath,entry:l,id:a,idExpression:a??(s?`makeId('${i.kind.idType}', '${s}')`:`makeId('${i.kind.idType}')`),change:{set:t.set||{},events:t.events||[],references:eK(d.references)},outcome:"compile:failed"===b.status?"verify_failed":"ok",verify:b,summary:`created ${l} (${i.kind.kind}, ${ey(i.absPath)}) -> ${b.status}`}}))}),function(e,t){return O.apply(this,arguments)}),e3=(e,t)=>{var r;return J.isArrowFunctionExpression(e)&&0===e.params.length&&(r=e.body,!!r&&(J.isIdentifier(r)?r.name===t.varName:!!J.isMemberExpression(r)&&!!J.isIdentifier(r.object)&&!!J.isIdentifier(r.property)&&r.object.name===t.namespace&&r.property.name===t.varName))},te=(e,t)=>J.isCallExpression(e)&&J.isIdentifier(e.callee,{name:"linkData"})&&e3(e.arguments[0],t),tt=(e,t)=>{if(!e)return!1;if(e3(e,t)||te(e,t))return!0;var r=!1;return ea(J.file(J.program([J.expressionStatement(J.cloneNode(e,!0))])),{ArrowFunctionExpression(e){e3(e.node,t)&&(r=!0,e.stop())},CallExpression(e){te(e.node,t)&&(r=!0,e.stop())}}),r},tr=(e,t,r,i=[],n={})=>{if(J.isProgram(e))return void e.body.forEach((e,a)=>tr(e,t,r,[...i,String(a)],n));if(J.isExportNamedDeclaration(e)&&e.declaration)return void tr(e.declaration,t,r,i,n);if(J.isVariableDeclaration(e))return void e.declarations.forEach((e,a)=>tr(e,t,r,[...i,String(a)],n));if(J.isVariableDeclarator(e)&&e.init)return void tr(e.init,t,r,i,n);if(J.isObjectExpression(e)){for(var a=e.properties.length-1;a>=0;a-=1){var s=e.properties[a];if(J.isObjectProperty(s)){var o=(0,ee.Gp)(s.key)||`property-${a}`,l=[...i,o];if(e3(s.value,t)||te(s.value,t)){i.includes("outlets")?(e.properties.splice(a,1),r.push({action:"drop_outlet",path:l.join(".")})):n.dataCalc&&("output"===o||"error"===o)?(s.value=J.nullLiteral(),r.push({action:"null_output",path:l.join(".")})):(s.value=J.identifier("undefined"),r.push({action:"null_link",path:l.join(".")}));continue}tr(s.value,t,r,l,n)}}return}if(J.isArrayExpression(e))for(var d=i[i.length-1],p=i.includes("events")&&"events"!==d,c=n.dataCalc?["items","params","dataParams","conds","switches","inputs","outputs"]:["items","params","dataParams","conds","switches"],u=e.elements.length-1;u>=0;u-=1){var f=e.elements[u];if(f){var y=[...i,String(u)];if(tt(f,t)&&(c.includes(d)||p||e3(f,t))){e.elements.splice(u,1),r.push({action:p?"delete_event_handler":n.dataCalc&&("inputs"===d||"outputs"===d)?"remove_io_item":"remove_reference_item",path:y.join(".")});continue}tr(f,t,r,y,n)}}},ti=(e,t)=>{var r=e.ast.program.body.indexOf(t.node);r>=0&&e.ast.program.body.splice(r,1)},tn=(C=D(function*(e,t,r){if("project"===r)return eb(e);var i=em(t),n=yield eh(i),a=X.join(i,"data-calc"),s=yield(0,G.readdir)(a,{withFileTypes:!0}).catch(()=>[]);return[...n,...s.filter(e=>e.isFile()&&e.name.endsWith(".ts")).map(e=>X.join(a,e.name))]}),function(e,t,r){return C.apply(this,arguments)}),ta=(N=D(function*(e,t){return eq(e,"remove_entry",t,D(function*(){var r,i=yield ex(e,t),n=i.parsed,a=i.entry,s={varName:a.name,namespace:n.kind.namespace,id:a.id},o=yield tn(e,n.absPath,t.scope),l=[],d=yield Promise.all(o.map((r=D(function*(t){var r=yield(0,G.readFile)(t,"utf8");return{absPath:t,relPath:(0,ee.RI)(e,t),source:r,ast:ed(r,(0,ee.RI)(e,t)),kind:es[X.basename(t)]||n.kind}}),function(e){return r.apply(this,arguments)}))),p=function*(e){var t,r,i,o,d;(o=(e.absPath===n.absPath?(t=a.name,r=J.cloneNode(e.ast,!0),i={...e,ast:r},ti(i,ef(i,{entry:t})),i):e).ast,d=[],ea(o,{ArrowFunctionExpression(e){e3(e.node,s)&&d.push({type:"ref",loc:e.node.loc?.start})},CallExpression(e){te(e.node,s)&&d.push({type:"link",loc:e.node.loc?.start})}}),d).forEach(t=>l.push({file:e.relPath,...t}))};for(var c of d)yield*p(c);if(t.strict&&l.length>0)return{file:n.relPath,entry:a.name,id:a.id,outcome:"refused",touchedSites:l,verify:{status:"skipped",errors:[]},summary:`refused to remove ${eM(n,a)}; ${l.length} reference(s) found`};var u=function*(t){var r=[],i={dataCalc:t.absPath.split(X.sep).includes("data-calc")};if(t.absPath===n.absPath&&(ti(t,ef(t,{entry:a.name})),r.push({action:"remove_entry",path:a.name})),tr(t.ast.program,s,r,[],i),0===r.length)return 1;var o=yield ez(t);ed(o,t.relPath),yield(0,G.writeFile)((yield ec(e,t.absPath)),o),r.forEach(e=>l.push({file:t.relPath,...e}))};for(var f of d)if(yield*u(f))continue;var y=yield(0,Q.H)(e,t.verify);return{file:n.relPath,entry:a.name,id:a.id,outcome:"compile:failed"===y.status?"verify_failed":"ok",touchedSites:l,verify:y,summary:`removed ${eM(n,a)} with ${l.length} touched site(s) -> ${y.status}`}}))}),function(e,t){return N.apply(this,arguments)}),ts=(T=D(function*(e,t){return eq(e,"new_subspace",t,D(function*(){var r=X.join(e,"root.ts"),i=(0,ee.RI)(e,r),n=yield(0,G.readFile)(r,"utf8").catch(()=>null);if(null==n)throw new eo("invalid_file","Project has no root.ts to wire the subspace into");var a={source:n,ast:ed(n,i),projectDir:e,absPath:r,relPath:i},s=a.ast.program.body.find(e=>J.isExportDefaultDeclaration(e));if(!s||!J.isArrayExpression(s.declaration))throw new eo("fallback_recommended","root.ts default export is not a subspace array literal; wire the new subspace manually",{file:i});var o=(yield ev(e)).reduce((e,t)=>{var r=/^subspace-(\d+)$/.exec(X.basename(t));return r?Math.max(e,Number(r[1])):e},-1)+1,l=`subspace-${o}`,d=X.join(e,"subspaces",l),p=`SUBSPACE_${(0,W.randomUUID)()}`,c=`CANVAS_${(0,W.randomUUID)()}`,u=(({subspaceId:e,canvasId:t,title:r,description:i,layout:n,portal:a})=>{var s=[`width: ${n.width}`,`height: ${n.height}`,...n.resizeMode?[`resizeMode: '${n.resizeMode}'`]:[]];return{"data.ts":"import type { Data } from 'bricks-ctor'\n","bricks.ts":"import type { Brick } from 'bricks-ctor'\n","generators.ts":"import type { Generator } from 'bricks-ctor'\n","animations.ts":"import type { Animation } from 'bricks-ctor'\n","canvases.ts":`import type { Canvas } from 'bricks-ctor'
6
6
 
7
7
  export const cMain: Canvas = {
8
8
  __typename: 'Canvas',
@@ -41,4 +41,4 @@ export default {
41
41
  } as Subspace
42
42
 
43
43
  export { bricks, generators, canvases, data }
44
- `}})({subspaceId:c,canvasId:p,title:t.title,description:t.description??"",layout:{width:t.layout?.width??96,height:t.layout?.height??54,resizeMode:t.layout?.resizeMode},portal:t.portal});yield(0,G.mkdir)(X.join(d,"data-calc"),{recursive:!0});var f=[];for(var m of Object.entries(u)){var y=R(m,2),v=y[0],h=y[1],b=X.join(d,v),w=yield(0,V.format)(b,h,ee.Hn);yield(0,G.writeFile)((yield ep(e,b)),w.errors.length>0?h:w.code),f.push((0,ee.RI)(e,b))}var x=eC(a,`./subspaces/${l}`,`subspace${o}`);s.declaration.elements.push(J.identifier(x)),yield eU(a);var _=yield(0,Q.H)(e,t.verify);return{subspace:l,id:c,index:o,files:f,change:{op:"new_subspace",rootImport:x},outcome:"compile:failed"===_.status?"verify_failed":"ok",verify:_,summary:`new_subspace ${l} (${t.title}) wired into root.ts -> ${_.status}`}}))}),function(e,t){return T.apply(this,arguments)}),to=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}],isError:e.isError||void 0}),tl=Z.bz().describe('Value grammar: JSON scalars/arrays/objects emit literals; { link: "dataIdOrAlias" } emits linkData(() => data.dX) for property/data-link values; { ref: "idOrAliasOrVar", subspace?: "subspace-1"|1|"SUBSPACE_id" } emits () => namespace.varName; { expr: "raw TypeScript expression" } is spliced verbatim.'),td=Z.Yj().describe("Dotted entry path to edit, for example title, property.url, outlets.response, animation.show, value, type, switches[0].property.text, or items[0].frame."),tc=Z.Yj().describe("Project-relative entry file path, for example subspaces/subspace-0/bricks.ts, generators.ts, canvases.ts, data.ts, or animations.ts."),tp=Z.Yj().describe("Exported const name or entity alias to edit, for example bWelcomeText, gApiClient, cMain, or an alias like welcomeText."),tu=Z.Yj().describe("Entry id fallback. When file is omitted, scans project subspaces for this id."),tf=Z.zM().describe("Override compile verification for this call. Defaults to BRICKS_CTOR_MCP_EDIT_VERIFY, otherwise true."),tm={file:tc.optional(),entry:tp.optional(),id:tu.optional(),verify:tf.optional()};function ty(e,t){var r,i,n,a,s,o,l;e.tool("edit_entry","Edit map-shaped facets on an existing bricks-ctor entry by source AST. Use set/unset with dotted paths and the shared value grammar.",{...tm,set:Z.g1(td,tl).describe("Map of dotted paths to values. Values use the shared grammar: JSON literals, { link }, { ref }, or { expr }.").optional(),unset:Z.YO(td).describe("Dotted paths to remove.").optional(),switch:Z.KC([Z.Yj(),Z.ai()]).describe("Optional switch id or zero-based switch index; edits that switch object instead of the entry root.").optional()},(r=D(function*(e){return to((yield eY(t,e)))}),function(e){return r.apply(this,arguments)})),e.tool("edit_events","Edit an event action array on an entry or switch. Adds/removes/replaces/moves/clears EventAction objects.",{...tm,event:Z.Yj().describe("Camel-case source event key such as onPress, showStart, update, enter, or firstEnter."),op:Z.k5(["add","remove","replace","move","clear"]).describe("Array operation. add inserts at index or appends; replace/remove require index; move reorders index to `to`; clear removes the event key."),index:Z.ai().describe("Zero-based event action index. For add this is the insertion position.").optional(),to:Z.ai().describe("Destination zero-based index for move.").optional(),action:tl.describe('For add/replace, the flattened form: { handler: "system"|{ref}|{subspace: "subspace-1"|1|"SUBSPACE_id"}, name: "ACTION_NAME", params?: { inputName: value }, dataParams?: { dataRef: value }, cast?: "TypeName", waitAsync?: boolean }. Cross-subspace {subspace} handlers emit a () => subspaceN getter; the emitting subspace itself stays a literal id. The compiled source form { handler, action: { name, params: [...], dataParams: [...] }, waitAsync } and { expr: "raw EventAction" } are also accepted.').optional(),switch:Z.KC([Z.Yj(),Z.ai()]).describe("Optional switch id or zero-based switch index; edits that switch events object.").optional()},(i=D(function*(e){return to((yield eZ(t,e)))}),function(e){return i.apply(this,arguments)})),e.tool("edit_canvas_items","Edit a Canvas entry items array. Use add/remove/replace to place bricks or move to update an item frame.",{...tm,op:Z.k5(["add","remove","replace","move"]).describe("Canvas item operation. add inserts/appends, replace/remove use index, move updates frame at index."),index:Z.ai().describe("Zero-based canvas item index.").optional(),item:tl.describe('For add/replace: { ref: "brickIdOrAliasOrVar", subspace?: ..., frame: { x, y, width, height, ... }, hidden?: boolean } places a brick; { subspace: "subspace-1"|1|"SUBSPACE_id", frame: ... } without ref embeds that subspace (emits a () => subspaceN getter). Frames require numeric x/y/width/height.').optional(),frame:tl.describe("Replacement frame such as { x, y, width, height }. Required for move; for add/replace it is used when item.frame is omitted.").optional()},(n=D(function*(e){return to((yield e1(t,e)))}),function(e){return n.apply(this,arguments)})),e.tool("edit_switches","Edit an entry switches array. Use edit_entry/edit_events with switch when changing switch facet bodies.",{...tm,op:Z.k5(["add","remove","replace","move"]).describe("Switch array operation. add inserts/appends, replace/remove use index, move reorders to `to`."),index:Z.KC([Z.Yj(),Z.ai()]).describe("Switch id or zero-based switch index. For add, this is optional insertion position.").optional(),to:Z.ai().describe("Destination zero-based index for move.").optional(),switch:tl.describe('For add/replace: { id? (BRICK_STATE_GROUP_<uuid>; omit to auto-generate), title?, description?, conds?: [{ method: "=="|"!="|">"|"<"|">="|"<=", cond }], override?: { animation?, event?, property?, outlet? }, property?, outlets?, animation?, disabled?, break? }. Cond forms: { type: "inner_state", key: "current_canvas", value: canvasRef }, { type: "inner_state", outlet: "outletName", value }, { type: "property_bank", ref: dataRef, value }, { type: "property_bank_by_item_key", ref: dataRef, value }, a compiled { __typename: "SwitchCond..." } object, or { expr }. Set switch events with edit_events using its switch parameter.').optional()},(a=D(function*(e){return to((yield e8(t,e)))}),function(e){return a.apply(this,arguments)})),e.tool("new_entry","Create a minimal standard-style exported entry skeleton in an entry file, then optionally apply set/events edits.",{file:tc,entry:tp.describe("Optional exported const name. Defaults from alias/title/id.").optional(),templateKey:Z.Yj().describe("Brick/generator templateKey such as BRICK_TEXT or GENERATOR_HTTP.").optional(),type:Z.Yj().describe("TypeScript type imported from bricks-ctor, for example BrickText, GeneratorHTTP, Canvas, Data, or Animation."),alias:Z.Yj().describe("Optional entry alias. Also influences default exported const name.").optional(),title:Z.Yj().describe("Optional entry title.").optional(),description:Z.Yj().describe("Optional entry description.").optional(),id:tu.describe("Optional explicit id. If omitted, the tool generates one with the file-kind prefix.").optional(),dataType:Z.Yj().describe("For data.ts only: initial Data.type value. Defaults to any.").optional(),set:Z.g1(td,tl).describe("Optional initial dotted-path values applied after creating the skeleton. Values use JSON literals, { link }, { ref }, or { expr }.").optional(),events:Z.YO(tl).describe("Optional initial event actions as objects with { event, action }.").optional(),verify:tf.optional()},(s=D(function*(e){return to((yield e2(t,e)))}),function(e){return s.apply(this,arguments)})),e.tool("remove_entry","Remove an entry. By default cascades same-subspace references in standard entry object/array shapes; strict mode refuses when references exist.",{...tm,strict:Z.zM().describe("When true, do not edit files; refuse and return reference sites if the entry is referenced.").optional(),scope:Z.k5(["subspace","project"]).describe("Reference scan scope. subspace is default; project scans all subspaces.").optional()},(o=D(function*(e){return to((yield ta(t,e)))}),function(e){return o.apply(this,arguments)})),e.tool("new_subspace","Scaffold a new subspaces/subspace-N directory (standard entry files + root canvas, fixed SUBSPACE_ id) and wire it into root.ts. Embed it afterwards with edit_canvas_items { subspace } or target it with edit_events { handler: { subspace } }.",{title:Z.Yj().describe("Subspace title shown in the editor."),description:Z.Yj().describe("Optional subspace description.").optional(),layout:Z.Ik({width:Z.ai(),height:Z.ai(),resizeMode:Z.k5(["cover","stretch"]).optional()}).describe("Subspace grid the embed frame scales; defaults to { width: 96, height: 54 }. Use a smaller grid plus resizeMode: 'stretch' for panel modules.").optional(),portal:Z.k5(["top","left","bottom","right"]).describe("Dock the subspace to a viewport edge as an always-on overlay instead of a canvas-embeddable module.").optional(),verify:tf.optional()},(l=D(function*(e){return to((yield ts(t,e)))}),function(e){return l.apply(this,arguments)}))}var tv={editEntry:eY,editEvents:eZ,editCanvasItems:e1,editSwitches:e8,newEntry:e2,newSubspace:ts,removeEntry:ta,resolveReference:eF};i()}catch(e){i(e)}})}};
44
+ `}})({subspaceId:p,canvasId:c,title:t.title,description:t.description??"",layout:{width:t.layout?.width??96,height:t.layout?.height??54,resizeMode:t.layout?.resizeMode},portal:t.portal});yield(0,G.mkdir)(X.join(d,"data-calc"),{recursive:!0});var f=[];for(var y of Object.entries(u)){var m=R(y,2),v=m[0],h=m[1],b=X.join(d,v),w=yield(0,V.format)(b,h,ee.Hn);yield(0,G.writeFile)((yield ec(e,b)),w.errors.length>0?h:w.code),f.push((0,ee.RI)(e,b))}var x=eC(a,`./subspaces/${l}`,`subspace${o}`);s.declaration.elements.push(J.identifier(x)),yield eU(a);var _=yield(0,Q.H)(e,t.verify);return{subspace:l,id:p,index:o,files:f,change:{op:"new_subspace",rootImport:x},outcome:"compile:failed"===_.status?"verify_failed":"ok",verify:_,summary:`new_subspace ${l} (${t.title}) wired into root.ts -> ${_.status}`}}))}),function(e,t){return T.apply(this,arguments)}),to=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}],isError:e.isError||void 0}),tl=Z.bz().describe('Value grammar: JSON scalars/arrays/objects emit literals; { link: "dataIdOrAlias" } emits linkData(() => data.dX) for property/data-link values; { ref: "idOrAliasOrVar", subspace?: "subspace-1"|1|"SUBSPACE_id" } emits () => namespace.varName; { expr: "raw TypeScript expression" } is spliced verbatim.'),td=Z.Yj().describe("Dotted entry path to edit, for example title, property.url, outlets.response, animation.show, value, type, switches[0].property.text, or items[0].frame."),tp=Z.Yj().describe("Project-relative entry file path, for example subspaces/subspace-0/bricks.ts, generators.ts, canvases.ts, data.ts, or animations.ts."),tc=Z.Yj().describe("Exported const name or entity alias to edit, for example bWelcomeText, gApiClient, cMain, or an alias like welcomeText."),tu=Z.Yj().describe("Entry id fallback. When file is omitted, scans project subspaces for this id."),tf=Z.zM().describe("Override compile verification for this call. Defaults to BRICKS_CTOR_MCP_EDIT_VERIFY, otherwise true."),ty={file:tp.optional(),entry:tc.optional(),id:tu.optional(),verify:tf.optional()};function tm(e,t){var r,i,n,a,s,o,l;e.tool("edit_entry","Edit map-shaped facets on an existing bricks-ctor entry by source AST. Use set/unset with dotted paths and the shared value grammar.",{...ty,set:Z.g1(td,tl).describe("Map of dotted paths to values. Values use the shared grammar: JSON literals, { link }, { ref }, or { expr }.").optional(),unset:Z.YO(td).describe("Dotted paths to remove.").optional(),switch:Z.KC([Z.Yj(),Z.ai()]).describe("Optional switch id or zero-based switch index; edits that switch object instead of the entry root.").optional()},(r=D(function*(e){return to((yield eY(t,e)))}),function(e){return r.apply(this,arguments)})),e.tool("edit_events","Edit an event action array on an entry or switch. Adds/removes/replaces/moves/clears EventAction objects.",{...ty,event:Z.Yj().describe("Camel-case source event key such as onPress, showStart, update, enter, or firstEnter."),op:Z.k5(["add","remove","replace","move","clear"]).describe("Array operation. add inserts at index or appends; replace/remove require index; move reorders index to `to`; clear removes the event key."),index:Z.ai().describe("Zero-based event action index. For add this is the insertion position.").optional(),to:Z.ai().describe("Destination zero-based index for move.").optional(),action:tl.describe('For add/replace, the flattened form: { handler: "system"|{ref}|{subspace: "subspace-1"|1|"SUBSPACE_id"}, name: "ACTION_NAME", params?: { inputName: value }, dataParams?: { dataRef: value }, cast?: "TypeName", waitAsync?: boolean }. Cross-subspace {subspace} handlers emit a () => subspaceN getter; the emitting subspace itself stays a literal id. The compiled source form { handler, action: { name, params: [...], dataParams: [...] }, waitAsync } and { expr: "raw EventAction" } are also accepted.').optional(),switch:Z.KC([Z.Yj(),Z.ai()]).describe("Optional switch id or zero-based switch index; edits that switch events object.").optional()},(i=D(function*(e){return to((yield eZ(t,e)))}),function(e){return i.apply(this,arguments)})),e.tool("edit_canvas_items","Edit a Canvas entry items array. Use add/remove/replace to place bricks or move to update an item frame.",{...ty,op:Z.k5(["add","remove","replace","move"]).describe("Canvas item operation. add inserts/appends, replace/remove use index, move updates frame at index."),index:Z.ai().describe("Zero-based canvas item index.").optional(),item:tl.describe('For add/replace: { ref: "brickIdOrAliasOrVar", subspace?: ..., frame: { x, y, width, height, ... }, hidden?: boolean } places a brick; { subspace: "subspace-1"|1|"SUBSPACE_id", frame: ... } without ref embeds that subspace (emits a () => subspaceN getter). Frames require numeric x/y/width/height.').optional(),frame:tl.describe("Replacement frame such as { x, y, width, height }. Required for move; for add/replace it is used when item.frame is omitted.").optional()},(n=D(function*(e){return to((yield e1(t,e)))}),function(e){return n.apply(this,arguments)})),e.tool("edit_switches","Edit an entry switches array. Use edit_entry/edit_events with switch when changing switch facet bodies.",{...ty,op:Z.k5(["add","remove","replace","move"]).describe("Switch array operation. add inserts/appends, replace/remove use index, move reorders to `to`."),index:Z.KC([Z.Yj(),Z.ai()]).describe("Switch id or zero-based switch index. For add, this is optional insertion position.").optional(),to:Z.ai().describe("Destination zero-based index for move.").optional(),switch:tl.describe('For add/replace: { id? (BRICK_STATE_GROUP_<uuid>; omit to auto-generate), title?, description?, conds?: [{ method: "=="|"!="|">"|"<"|">="|"<=", cond }], override?: { animation?, event?, property?, outlet? }, property?, outlets?, animation?, disabled?, break? }. Cond forms: { type: "inner_state", key: "current_canvas", value: canvasRef }, { type: "inner_state", outlet: "outletName", value }, { type: "property_bank", ref: dataRef, value }, { type: "property_bank_by_item_key", ref: dataRef, value }, { type: "item_key_mapping", key: "<item field path>", value }, a compiled { __typename: "SwitchCond..." } object, or { expr }. Set switch events with edit_events using its switch parameter.').optional()},(a=D(function*(e){return to((yield e8(t,e)))}),function(e){return a.apply(this,arguments)})),e.tool("new_entry","Create a minimal standard-style exported entry skeleton in an entry file, then optionally apply set/events edits.",{file:tp,entry:tc.describe("Optional exported const name. Defaults from alias/title/id.").optional(),templateKey:Z.Yj().describe("Brick/generator templateKey such as BRICK_TEXT or GENERATOR_HTTP.").optional(),type:Z.Yj().describe("TypeScript type imported from bricks-ctor, for example BrickText, GeneratorHTTP, Canvas, Data, or Animation."),alias:Z.Yj().describe("Optional entry alias. Also influences default exported const name.").optional(),title:Z.Yj().describe("Optional entry title.").optional(),description:Z.Yj().describe("Optional entry description.").optional(),id:tu.describe("Optional explicit id. If omitted, the tool generates one with the file-kind prefix.").optional(),dataType:Z.Yj().describe("For data.ts only: initial Data.type value. Defaults to any.").optional(),set:Z.g1(td,tl).describe("Optional initial dotted-path values applied after creating the skeleton. Values use JSON literals, { link }, { ref }, or { expr }.").optional(),events:Z.YO(tl).describe("Optional initial event actions as objects with { event, action }.").optional(),verify:tf.optional()},(s=D(function*(e){return to((yield e2(t,e)))}),function(e){return s.apply(this,arguments)})),e.tool("remove_entry","Remove an entry. By default cascades same-subspace references in standard entry object/array shapes; strict mode refuses when references exist.",{...ty,strict:Z.zM().describe("When true, do not edit files; refuse and return reference sites if the entry is referenced.").optional(),scope:Z.k5(["subspace","project"]).describe("Reference scan scope. subspace is default; project scans all subspaces.").optional()},(o=D(function*(e){return to((yield ta(t,e)))}),function(e){return o.apply(this,arguments)})),e.tool("new_subspace","Scaffold a new subspaces/subspace-N directory (standard entry files + root canvas, fixed SUBSPACE_ id) and wire it into root.ts. Embed it afterwards with edit_canvas_items { subspace } or target it with edit_events { handler: { subspace } }.",{title:Z.Yj().describe("Subspace title shown in the editor."),description:Z.Yj().describe("Optional subspace description.").optional(),layout:Z.Ik({width:Z.ai(),height:Z.ai(),resizeMode:Z.k5(["cover","stretch"]).optional()}).describe("Subspace grid the embed frame scales; defaults to { width: 96, height: 54 }. Use a smaller grid plus resizeMode: 'stretch' for panel modules.").optional(),portal:Z.k5(["top","left","bottom","right"]).describe("Dock the subspace to a viewport edge as an always-on overlay instead of a canvas-embeddable module.").optional(),verify:tf.optional()},(l=D(function*(e){return to((yield ts(t,e)))}),function(e){return l.apply(this,arguments)}))}var tv={editEntry:eY,editEvents:eZ,editCanvasItems:e1,editSwitches:e8,newEntry:e2,newSubspace:ts,removeEntry:ta,resolveReference:eL};i()}catch(e){i(e)}})}};
package/lib/6818.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=6818;export const __rspack_esm_ids=[6818];export const __webpack_modules__={53241(e,t,r){r.r(t),r.d(t,{detectChannel:()=>i,detectInstallMethod:()=>o});var a=r(73024),n=r(76760),s=r(48161),l=e=>{if(!e)return e;try{return a.realpathSync(e)}catch{return e}},i=({version:e,execPath:t}={})=>{var r=t||process.execPath;return r&&/[\\/]bricks-beta(?:\.exe)?$/i.test(r)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.1-beta.6")?"beta":"release"},o=({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:r=s.homedir(),realpath:a=l}={})=>{let i;var o=(i=e)?n.basename(i).replace(/\.exe$/i,""):"";if("bricks"===o||"bricks-beta"===o)return{method:"binary",execPath:e,installDir:n.dirname(e)};var c=a(t),p=((e,t)=>{if(!e)return null;var r=n.sep,a=`${r}node_modules${r}${t.replace(/\//g,r)}${r}`,s=e.indexOf(a);return -1===s?null:e.slice(0,s)})(c,"@fugood/bricks-cli");if(p){var b=n.sep,d=n.join(r,".bun","install","global");return p===d||p.startsWith(d+b)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${b}lib`)?p.slice(0,-`${b}lib`.length):p}}return{method:"unknown",execPath:e,scriptPath:c}}}};
1
+ export const __rspack_esm_id=6818;export const __rspack_esm_ids=[6818];export const __webpack_modules__={53241(e,t,r){r.r(t),r.d(t,{detectChannel:()=>i,detectInstallMethod:()=>o});var a=r(73024),n=r(76760),s=r(48161),l=e=>{if(!e)return e;try{return a.realpathSync(e)}catch{return e}},i=({version:e,execPath:t}={})=>{var r=t||process.execPath;return r&&/[\\/]bricks-beta(?:\.exe)?$/i.test(r)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.2-beta.0")?"beta":"release"},o=({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:r=s.homedir(),realpath:a=l}={})=>{let i;var o=(i=e)?n.basename(i).replace(/\.exe$/i,""):"";if("bricks"===o||"bricks-beta"===o)return{method:"binary",execPath:e,installDir:n.dirname(e)};var c=a(t),p=((e,t)=>{if(!e)return null;var r=n.sep,a=`${r}node_modules${r}${t.replace(/\//g,r)}${r}`,s=e.indexOf(a);return -1===s?null:e.slice(0,s)})(c,"@fugood/bricks-cli");if(p){var b=n.sep,d=n.join(r,".bun","install","global");return p===d||p.startsWith(d+b)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${b}lib`)?p.slice(0,-`${b}lib`.length):p}}return{method:"unknown",execPath:e,scriptPath:c}}}};