@truenine/memory-sync-cli 2026.10212.11955 → 2026.10213.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.
Files changed (3) hide show
  1. package/dist/index.cjs +382 -57
  2. package/dist/index.mjs +363 -38
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -17,54 +17,29 @@ var n=S(),r={"{":`}`,"(":`)`,"[":`]`},i=function(e){if(e[0]===`!`)return!0;for(v
17
17
  /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
18
18
  let n;t.exports=typeof queueMicrotask==`function`?queueMicrotask.bind(typeof window<`u`?window:global):e=>(n||=Promise.resolve()).then(e).catch(e=>setTimeout(()=>{throw e},0))})),ve=o(((e,t)=>{
19
19
  /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
20
- t.exports=r;let n=_e();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e.length):(a=Object.keys(e),r={},i=a.length);function s(e){function i(){t&&t(e,r),t=null}o?n(i):i()}function c(e,t,n){r[e]=n,(--i===0||t)&&s(t)}i?a?a.forEach(function(t){e[t](function(e,n){c(t,e,n)})}):e.forEach(function(e,t){e(function(e,n){c(t,e,n)})}):s(null),o=!1}})),ye=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;let t=process.versions.node.split(`.`);if(t[0]===void 0||t[1]===void 0)throw Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);let n=Number.parseInt(t[0],10),r=Number.parseInt(t[1],10);e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=n>10||n===10&&r>=10})),be=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createDirentFromStats=void 0;var t=class{constructor(e,t){this.name=e,this.isBlockDevice=t.isBlockDevice.bind(t),this.isCharacterDevice=t.isCharacterDevice.bind(t),this.isDirectory=t.isDirectory.bind(t),this.isFIFO=t.isFIFO.bind(t),this.isFile=t.isFile.bind(t),this.isSocket=t.isSocket.bind(t),this.isSymbolicLink=t.isSymbolicLink.bind(t)}};function n(e,n){return new t(e,n)}e.createDirentFromStats=n})),xe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=be()})),Se=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=void 0;function t(e,t,n){return e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=t})),Ce=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=ge(),n=ve(),r=ye(),i=xe(),a=Se();function o(e,t,n){if(!t.stats&&r.IS_SUPPORT_READDIR_WITH_FILE_TYPES){s(e,t,n);return}l(e,t,n)}e.read=o;function s(e,t,r){t.fs.readdir(e,{withFileTypes:!0},(i,o)=>{if(i!==null){u(r,i);return}let s=o.map(n=>({dirent:n,name:n.name,path:a.joinPathSegments(e,n.name,t.pathSegmentSeparator)}));if(!t.followSymbolicLinks){d(r,s);return}n(s.map(e=>c(e,t)),(e,t)=>{if(e!==null){u(r,e);return}d(r,t)})})}e.readdirWithFileTypes=s;function c(e,t){return n=>{if(!e.dirent.isSymbolicLink()){n(null,e);return}t.fs.stat(e.path,(r,a)=>{if(r!==null){if(t.throwErrorOnBrokenSymbolicLink){n(r);return}n(null,e);return}e.dirent=i.fs.createDirentFromStats(e.name,a),n(null,e)})}}function l(e,r,o){r.fs.readdir(e,(s,c)=>{if(s!==null){u(o,s);return}n(c.map(n=>{let o=a.joinPathSegments(e,n,r.pathSegmentSeparator);return e=>{t.stat(o,r.fsStatSettings,(t,a)=>{if(t!==null){e(t);return}let s={name:n,path:o,dirent:i.fs.createDirentFromStats(n,a)};r.stats&&(s.stats=a),e(null,s)})}}),(e,t)=>{if(e!==null){u(o,e);return}d(o,t)})})}e.readdir=l;function u(e,t){e(t)}function d(e,t){e(null,t)}})),we=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=ge(),n=ye(),r=xe(),i=Se();function a(e,t){return!t.stats&&n.IS_SUPPORT_READDIR_WITH_FILE_TYPES?o(e,t):s(e,t)}e.read=a;function o(e,t){return t.fs.readdirSync(e,{withFileTypes:!0}).map(n=>{let a={dirent:n,name:n.name,path:i.joinPathSegments(e,n.name,t.pathSegmentSeparator)};if(a.dirent.isSymbolicLink()&&t.followSymbolicLinks)try{let e=t.fs.statSync(a.path);a.dirent=r.fs.createDirentFromStats(a.name,e)}catch(e){if(t.throwErrorOnBrokenSymbolicLink)throw e}return a})}e.readdirWithFileTypes=o;function s(e,n){return n.fs.readdirSync(e).map(a=>{let o=i.joinPathSegments(e,a,n.pathSegmentSeparator),s=t.statSync(o,n.fsStatSettings),c={name:a,path:o,dirent:r.fs.createDirentFromStats(a,s)};return n.stats&&(c.stats=s),c})}e.readdir=s})),Te=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=require(`fs`);e.FILE_SYSTEM_ADAPTER={lstat:t.lstat,stat:t.stat,lstatSync:t.lstatSync,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync};function n(t){return t===void 0?e.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},e.FILE_SYSTEM_ADAPTER),t)}e.createFileSystemAdapter=n})),Ee=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=ge(),r=Te();e.default=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=r.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new n.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),De=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=Ce(),n=we(),r=Ee();e.Settings=r.default;function i(e,n,r){if(typeof n==`function`){t.read(e,o(),n);return}t.read(e,o(n),r)}e.scandir=i;function a(e,t){let r=o(t);return n.read(e,r)}e.scandirSync=a;function o(e={}){return e instanceof r.default?e:new r.default(e)}})),Oe=o(((e,t)=>{function n(e){var t=new e,n=t;function r(){var r=t;return r.next?t=r.next:(t=new e,n=t),r.next=null,r}function i(e){n.next=e,n=e}return{get:r,release:i}}t.exports=n})),ke=o(((e,t)=>{var n=Oe();function r(e,t,r){if(typeof e==`function`&&(r=t,t=e,e=null),!(r>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);var o=n(a),s=null,c=null,l=0,u=null,d={push:v,drain:i,saturated:i,pause:p,paused:!1,get concurrency(){return r},set concurrency(e){if(!(e>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);if(r=e,!d.paused)for(;s&&l<r;)l++,b()},running:f,resume:g,idle:_,length:m,getQueue:h,unshift:y,empty:i,kill:x,killAndDrain:S,error:w,abort:C};return d;function f(){return l}function p(){d.paused=!0}function m(){for(var e=s,t=0;e;)e=e.next,t++;return t}function h(){for(var e=s,t=[];e;)t.push(e.value),e=e.next;return t}function g(){if(d.paused){if(d.paused=!1,s===null){l++,b();return}for(;s&&l<r;)l++,b()}}function _(){return l===0&&d.length()===0}function v(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?c?(c.next=f,c=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function y(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?s?(f.next=s,s=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function b(n){n&&o.release(n);var i=s;i&&l<=r?d.paused?l--:(c===s&&(c=null),s=i.next,i.next=null,t.call(e,i.value,i.worked),c===null&&d.empty()):--l===0&&d.drain()}function x(){s=null,c=null,d.drain=i}function S(){s=null,c=null,d.drain(),d.drain=i}function C(){var e=s;for(s=null,c=null;e;){var t=e.next,n=e.callback,r=e.errorHandler,a=e.value,o=e.context;e.value=null,e.callback=i,e.errorHandler=null,r&&r(Error(`abort`),a),n.call(o,Error(`abort`)),e.release(e),e=t}d.drain=i}function w(e){u=e}}function i(){}function a(){this.value=null,this.callback=i,this.next=null,this.release=i,this.context=null,this.errorHandler=null;var e=this;this.worked=function(t,n){var r=e.callback,a=e.errorHandler,o=e.value;e.value=null,e.callback=i,e.errorHandler&&a(t,o),r.call(e.context,t,n),e.release(e)}}function o(e,t,n){typeof e==`function`&&(n=t,t=e,e=null);function a(e,n){t.call(this,e).then(function(e){n(null,e)},n)}var o=r(e,a,n),s=o.push,c=o.unshift;return o.push=l,o.unshift=u,o.drained=d,o;function l(e){var t=new Promise(function(t,n){s(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function u(e){var t=new Promise(function(t,n){c(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function d(){return new Promise(function(e){process.nextTick(function(){if(o.idle())e();else{var t=o.drain;o.drain=function(){typeof t==`function`&&t(),e(),o.drain=t}}})})}}t.exports=r,t.exports.promise=o})),A=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=e.replacePathSegmentSeparator=e.isAppliedFilter=e.isFatalError=void 0;function t(e,t){return e.errorFilter===null?!0:!e.errorFilter(t)}e.isFatalError=t;function n(e,t){return e===null||e(t)}e.isAppliedFilter=n;function r(e,t){return e.split(/[/\\]/).join(t)}e.replacePathSegmentSeparator=r;function i(e,t,n){return e===``?t:e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=i})),j=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=A();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Ae=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`events`),n=De(),r=ke(),i=A(),a=j();e.default=class extends a.default{constructor(e,i){super(e,i),this._settings=i,this._scandir=n.scandir,this._emitter=new t.EventEmitter,this._queue=r(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit(`end`)}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw Error(`The reader is already destroyed`);this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on(`entry`,e)}onError(e){this._emitter.once(`error`,e)}onEnd(e){this._emitter.once(`end`,e)}_pushToQueue(e,t){let n={directory:e,base:t};this._queue.push(n,e=>{e!==null&&this._handleError(e)})}_worker(e,t){this._scandir(e.directory,this._settings.fsScandirSettings,(n,r)=>{if(n!==null){t(n,void 0);return}for(let t of r)this._handleEntry(t,e.base);t(null,void 0)})}_handleError(e){this._isDestroyed||!i.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit(`error`,e))}_handleEntry(e,t){if(this._isDestroyed||this._isFatalError)return;let n=e.path;t!==void 0&&(e.path=i.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),i.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&i.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,t===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit(`entry`,e)}}})),M=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ae();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(t=>{n(e,t)}),this._reader.onEntry(e=>{this._storage.push(e)}),this._reader.onEnd(()=>{r(e,this._storage)}),this._reader.read()}};function n(e,t){e(t)}function r(e,t){e(null,t)}})),je=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=Ae();e.default=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new n.default(this._root,this._settings),this._stream=new t.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit(`error`,e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}}})),Me=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=De(),n=A(),r=j();e.default=class extends r.default{constructor(){super(...arguments),this._scandir=t.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,t){this._queue.add({directory:e,base:t})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,t){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let e of n)this._handleEntry(e,t)}catch(e){this._handleError(e)}}_handleError(e){if(n.isFatalError(this._settings,e))throw e}_handleEntry(e,t){let r=e.path;t!==void 0&&(e.path=n.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),n.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&n.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(r,t===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}}})),N=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings)}read(){return this._reader.read()}}})),Ne=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=De();e.default=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,1/0),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.fsScandirSettings=new n.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),Pe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=M(),n=je(),r=N(),i=Ne();e.Settings=i.default;function a(e,n,r){if(typeof n==`function`){new t.default(e,c()).read(n);return}new t.default(e,c(n)).read(r)}e.walk=a;function o(e,t){let n=c(t);return new r.default(e,n).read()}e.walkSync=o;function s(e,t){let r=c(t);return new n.default(e,r).read()}e.walkStream=s;function c(e={}){return e instanceof i.default?e:new i.default(e)}})),Fe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=ge(),r=ue();e.default=class{constructor(e){this._settings=e,this._fsStatSettings=new n.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return t.resolve(this._settings.cwd,e)}_makeEntry(e,t){let n={name:t,path:t,dirent:r.fs.createDirentFromStats(t,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!r.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}}})),Ie=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=ge(),r=Pe(),i=Fe();e.default=class extends i.default{constructor(){super(...arguments),this._walkStream=r.walkStream,this._stat=n.stat}dynamic(e,t){return this._walkStream(e,t)}static(e,n){let r=e.map(this._getFullEntryPath,this),i=new t.PassThrough({objectMode:!0});i._write=(t,a,o)=>this._getEntry(r[t],e[t],n).then(e=>{e!==null&&n.entryFilter(e)&&i.push(e),t===r.length-1&&i.end(),o()}).catch(o);for(let e=0;e<r.length;e++)i.write(e);return i}_getEntry(e,t,n){return this._getStat(e).then(e=>this._makeEntry(e,t)).catch(e=>{if(n.errorFilter(e))return null;throw e})}_getStat(e){return new Promise((t,n)=>{this._stat(e,this._fsStatSettings,(e,r)=>e===null?t(r):n(e))})}}})),Le=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pe(),n=Fe(),r=Ie();e.default=class extends n.default{constructor(){super(...arguments),this._walkAsync=t.walk,this._readerStream=new r.default(this._settings)}dynamic(e,t){return new Promise((n,r)=>{this._walkAsync(e,t,(e,t)=>{e===null?n(t):r(e)})})}async static(e,t){let n=[],r=this._readerStream.static(e,t);return new Promise((e,t)=>{r.once(`error`,t),r.on(`data`,e=>n.push(e)),r.once(`end`,()=>e(n))})}}})),Re=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e,t,n){this._patterns=e,this._settings=t,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let t=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(t);this._storage.push({complete:n.length<=1,pattern:e,segments:t,sections:n})}}_getPatternSegments(e){return t.pattern.getPatternParts(e,this._micromatchOptions).map(e=>t.pattern.isDynamicPattern(e,this._settings)?{dynamic:!0,pattern:e,patternRe:t.pattern.makeRe(e,this._micromatchOptions)}:{dynamic:!1,pattern:e})}_splitSegmentsIntoSections(e){return t.array.splitWhen(e,e=>e.dynamic&&t.pattern.hasGlobStar(e.pattern))}}})),ze=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Re();e.default=class extends t.default{match(e){let t=e.split(`/`),n=t.length,r=this._storage.filter(e=>!e.complete||e.segments.length>n);for(let e of r){let r=e.sections[0];if(!e.complete&&n>r.length||t.every((t,n)=>{let r=e.segments[n];return!!(r.dynamic&&r.patternRe.test(t)||!r.dynamic&&r.pattern===t)}))return!0}return!1}}})),Be=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue(),n=ze();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t}getFilter(e,t,n){let r=this._getMatcher(t),i=this._getNegativePatternsRe(n);return t=>this._filter(e,t,r,i)}_getMatcher(e){return new n.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let n=e.filter(t.pattern.isAffectDepthOfReadingPattern);return t.pattern.convertPatternsToRe(n,this._micromatchOptions)}_filter(e,n,r,i){if(this._isSkippedByDeep(e,n.path)||this._isSkippedSymbolicLink(n))return!1;let a=t.path.removeLeadingDotSegment(n.path);return this._isSkippedByPositivePatterns(a,r)?!1:this._isSkippedByNegativePatterns(a,i)}_isSkippedByDeep(e,t){return this._settings.deep===1/0?!1:this._getEntryLevel(e,t)>=this._settings.deep}_getEntryLevel(e,t){let n=t.split(`/`).length;return e===``?n:n-e.split(`/`).length}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,t){return!this._settings.baseNameMatch&&!t.match(e)}_isSkippedByNegativePatterns(e,n){return!t.pattern.matchAny(e,n)}}})),Ve=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t,this.index=new Map}getFilter(e,n){let[r,i]=t.pattern.partitionAbsoluteAndRelative(n),a={positive:{all:t.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:t.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:t.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return e=>this._filter(e,a)}_filter(e,n){let r=t.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(r,n,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(r),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,t,n){return!(!this._isMatchToPatterns(e,t.positive.all,n)||this._isMatchToPatterns(e,t.negative.relative,n)||this._isMatchToAbsoluteNegative(e,t.negative.absolute,n))}_isMatchToAbsoluteNegative(e,n,r){if(n.length===0)return!1;let i=t.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,n,r)}_isMatchToPatterns(e,n,r){if(n.length===0)return!1;let i=t.pattern.matchAny(e,n);return!i&&r?t.pattern.matchAny(e+`/`,n):i}}})),He=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),P=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let n=e.path;return this._settings.absolute&&(n=t.path.makeAbsolute(this._settings.cwd,n),n=t.path.unixify(n)),this._settings.markDirectories&&e.dirent.isDirectory()&&(n+=`/`),this._settings.objectMode?Object.assign(Object.assign({},e),{path:n}):n}}})),Ue=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=Be(),r=Ve(),i=He(),a=P();e.default=class{constructor(e){this._settings=e,this.errorFilter=new i.default(this._settings),this.entryFilter=new r.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new n.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new a.default(this._settings)}_getRootDirectory(e){return t.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let t=e.base===`.`?``:e.base;return{basePath:t,pathSegmentSeparator:`/`,concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(t,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}}})),F=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Le(),n=Ue();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}async read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(t,e,n)).map(e=>n.transform(e))}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),We=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=Ie(),r=Ue();e.default=class extends r.default{constructor(){super(...arguments),this._reader=new n.default(this._settings)}read(e){let n=this._getRootDirectory(e),r=this._getReaderOptions(e),i=this.api(n,e,r),a=new t.Readable({objectMode:!0,read:()=>{}});return i.once(`error`,e=>a.emit(`error`,e)).on(`data`,e=>a.emit(`data`,r.transform(e))).once(`end`,()=>a.emit(`end`)),a.once(`close`,()=>i.destroy()),a}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Ge=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=Pe(),r=Fe();e.default=class extends r.default{constructor(){super(...arguments),this._walkSync=n.walkSync,this._statSync=t.statSync}dynamic(e,t){return this._walkSync(e,t)}static(e,t){let n=[];for(let r of e){let e=this._getFullEntryPath(r),i=this._getEntry(e,r,t);i===null||!t.entryFilter(i)||n.push(i)}return n}_getEntry(e,t,n){try{let n=this._getStat(e);return this._makeEntry(n,t)}catch(e){if(n.errorFilter(e))return null;throw e}}_getStat(e){return this._statSync(e,this._fsStatSettings)}}})),Ke=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ge(),n=Ue();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(t,e,n).map(n.transform)}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),qe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=require(`fs`),n=require(`os`),r=Math.max(n.cpus().length,1);e.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:t.lstat,lstatSync:t.lstatSync,stat:t.stat,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync},e.default=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,r),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,t){return e===void 0?t:e}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},e.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}})),Je=l(o(((e,t)=>{let n=de(),r=F(),i=We(),a=Ke(),o=qe(),s=ue();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);function Ye(e){let t=u.default.env.XDG_DATA_HOME;return typeof t==`string`&&t.trim().length>0?t:f.default.join(e,`.local`,`share`)}function Xe(){let e=u.default.platform,t=p.default.homedir();if(e===`win32`)return u.default.env.LOCALAPPDATA??f.default.join(t,`AppData`,`Local`);if(e===`darwin`)return f.default.join(t,`Library`,`Application Support`);if(e===`linux`)return Ye(t);throw Error(`Unsupported platform: ${u.default.platform}`)}function Ze(e){try{return d.lstatSync(e).isSymbolicLink()}catch{return!1}}function Qe(e){return d.lstatSync(e)}function $e(e){d.mkdirSync(e,{recursive:!0})}function et(e){$e(e)}function tt(e,t,n=`dir`){if(et(f.default.dirname(t)),d.existsSync(t)){let e=d.lstatSync(t);e.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(t,{recursive:!0,force:!0}):d.unlinkSync(t):e.isDirectory()?d.rmSync(t,{recursive:!0}):d.unlinkSync(t)}u.default.platform===`win32`&&n===`dir`?d.symlinkSync(e,t,`junction`):d.symlinkSync(e,t,n)}function nt(e){d.existsSync(e)&&d.lstatSync(e).isSymbolicLink()&&(u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e))}function rt(e){if(!d.existsSync(e))return;let t=d.lstatSync(e);t.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e):t.isDirectory()?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e)}function it(e,t,n=`utf8`){$e(f.default.dirname(e)),typeof t==`string`?d.writeFileSync(e,t,n):d.writeFileSync(e,t)}function at(e){let t=0,n=[];for(let r of e)try{d.existsSync(r)&&(rt(r),t++)}catch(e){n.push({path:r,error:e})}return{deleted:t,errors:n}}function ot(e){let t=0,n=[],r=[...e].sort((e,t)=>t.length-e.length);for(let e of r)try{d.existsSync(e)&&(d.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){n.push({path:e,error:t})}return{deleted:t,errors:n}}let st=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function ct(e,t,n){return{pathKind:st.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>f.default.join(t,e)}}function lt(e,t){let n=f.default.join(e.path,t);return{pathKind:st.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>f.default.join(e.basePath,n)}}async function ut(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function dt(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function ft(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function pt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function mt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function ht(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function gt(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=at(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:i}}function _t(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=ot(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:i}}async function vt(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await ut(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await ht(e,await dt(e,t),t),c=gt(o,n),l=_t(s,n);return i&&await ft(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var yt=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await vt(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let bt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),xt=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),I=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),St=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),Ct=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),wt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),L=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),Tt=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var Et=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},Dt=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},Ot=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};function kt(e,t){let{requiredFields:n,optionalDefaults:r,filePath:i}=t,a=[],o=[];for(let t of n){let n=String(t);if(!(n in e)||e[n]==null){let e=i==null?`Missing required field "${n}"`:`Missing required field "${n}" in ${i}`;a.push(e)}}if(r!=null){for(let[t,n]of Object.entries(r))if(!(t in e)||e[t]==null){let e=i==null?`Using default value for optional field "${t}": ${JSON.stringify(n)}`:`Using default value for optional field "${t}": ${JSON.stringify(n)} in ${i}`;o.push(e)}}return{valid:a.length===0,errors:a,warnings:o}}function At(e,t){return kt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function jt(e,t){return kt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function Mt(e,t){return kt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Nt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const Pt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),Ft=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),It={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},Lt={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`},Rt={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},zt={src:{skills:{name:It.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:It.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:It.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:Lt.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:It.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:It.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:It.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:Lt.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:It.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:It.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:It.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:It.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:It.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:Lt.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:Lt.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:Lt.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:Lt.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:Lt.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:Lt.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:Lt.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:Lt.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:Lt.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`},{name:Lt.AI_IGNORE,required:!1,description:`AI ignore file`}]},Bt=[`app/global.cn.mdx`,`.idea/.gitignore`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.vscode/settings.json`,`.vscode/extensions.json`,`.editorconfig`,`.gitignore`,`public/tnmsc.example.json`,`public/exclude`,`src/skills/prompt-builder/global-memory-prompt.cn.mdx`,`src/skills/prompt-builder/root-memory-prompt.cn.mdx`,`src/skills/prompt-builder/child-memory-prompt.cn.mdx`];let Vt={"app/global.cn.mdx":`# 致我的 AI 朋友
20
+ t.exports=r;let n=_e();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e.length):(a=Object.keys(e),r={},i=a.length);function s(e){function i(){t&&t(e,r),t=null}o?n(i):i()}function c(e,t,n){r[e]=n,(--i===0||t)&&s(t)}i?a?a.forEach(function(t){e[t](function(e,n){c(t,e,n)})}):e.forEach(function(e,t){e(function(e,n){c(t,e,n)})}):s(null),o=!1}})),ye=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;let t=process.versions.node.split(`.`);if(t[0]===void 0||t[1]===void 0)throw Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);let n=Number.parseInt(t[0],10),r=Number.parseInt(t[1],10);e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=n>10||n===10&&r>=10})),be=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createDirentFromStats=void 0;var t=class{constructor(e,t){this.name=e,this.isBlockDevice=t.isBlockDevice.bind(t),this.isCharacterDevice=t.isCharacterDevice.bind(t),this.isDirectory=t.isDirectory.bind(t),this.isFIFO=t.isFIFO.bind(t),this.isFile=t.isFile.bind(t),this.isSocket=t.isSocket.bind(t),this.isSymbolicLink=t.isSymbolicLink.bind(t)}};function n(e,n){return new t(e,n)}e.createDirentFromStats=n})),xe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=be()})),Se=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=void 0;function t(e,t,n){return e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=t})),Ce=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=ge(),n=ve(),r=ye(),i=xe(),a=Se();function o(e,t,n){if(!t.stats&&r.IS_SUPPORT_READDIR_WITH_FILE_TYPES){s(e,t,n);return}l(e,t,n)}e.read=o;function s(e,t,r){t.fs.readdir(e,{withFileTypes:!0},(i,o)=>{if(i!==null){u(r,i);return}let s=o.map(n=>({dirent:n,name:n.name,path:a.joinPathSegments(e,n.name,t.pathSegmentSeparator)}));if(!t.followSymbolicLinks){d(r,s);return}n(s.map(e=>c(e,t)),(e,t)=>{if(e!==null){u(r,e);return}d(r,t)})})}e.readdirWithFileTypes=s;function c(e,t){return n=>{if(!e.dirent.isSymbolicLink()){n(null,e);return}t.fs.stat(e.path,(r,a)=>{if(r!==null){if(t.throwErrorOnBrokenSymbolicLink){n(r);return}n(null,e);return}e.dirent=i.fs.createDirentFromStats(e.name,a),n(null,e)})}}function l(e,r,o){r.fs.readdir(e,(s,c)=>{if(s!==null){u(o,s);return}n(c.map(n=>{let o=a.joinPathSegments(e,n,r.pathSegmentSeparator);return e=>{t.stat(o,r.fsStatSettings,(t,a)=>{if(t!==null){e(t);return}let s={name:n,path:o,dirent:i.fs.createDirentFromStats(n,a)};r.stats&&(s.stats=a),e(null,s)})}}),(e,t)=>{if(e!==null){u(o,e);return}d(o,t)})})}e.readdir=l;function u(e,t){e(t)}function d(e,t){e(null,t)}})),we=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=ge(),n=ye(),r=xe(),i=Se();function a(e,t){return!t.stats&&n.IS_SUPPORT_READDIR_WITH_FILE_TYPES?o(e,t):s(e,t)}e.read=a;function o(e,t){return t.fs.readdirSync(e,{withFileTypes:!0}).map(n=>{let a={dirent:n,name:n.name,path:i.joinPathSegments(e,n.name,t.pathSegmentSeparator)};if(a.dirent.isSymbolicLink()&&t.followSymbolicLinks)try{let e=t.fs.statSync(a.path);a.dirent=r.fs.createDirentFromStats(a.name,e)}catch(e){if(t.throwErrorOnBrokenSymbolicLink)throw e}return a})}e.readdirWithFileTypes=o;function s(e,n){return n.fs.readdirSync(e).map(a=>{let o=i.joinPathSegments(e,a,n.pathSegmentSeparator),s=t.statSync(o,n.fsStatSettings),c={name:a,path:o,dirent:r.fs.createDirentFromStats(a,s)};return n.stats&&(c.stats=s),c})}e.readdir=s})),Te=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=require(`fs`);e.FILE_SYSTEM_ADAPTER={lstat:t.lstat,stat:t.stat,lstatSync:t.lstatSync,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync};function n(t){return t===void 0?e.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},e.FILE_SYSTEM_ADAPTER),t)}e.createFileSystemAdapter=n})),Ee=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=ge(),r=Te();e.default=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=r.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new n.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),De=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=Ce(),n=we(),r=Ee();e.Settings=r.default;function i(e,n,r){if(typeof n==`function`){t.read(e,o(),n);return}t.read(e,o(n),r)}e.scandir=i;function a(e,t){let r=o(t);return n.read(e,r)}e.scandirSync=a;function o(e={}){return e instanceof r.default?e:new r.default(e)}})),Oe=o(((e,t)=>{function n(e){var t=new e,n=t;function r(){var r=t;return r.next?t=r.next:(t=new e,n=t),r.next=null,r}function i(e){n.next=e,n=e}return{get:r,release:i}}t.exports=n})),ke=o(((e,t)=>{var n=Oe();function r(e,t,r){if(typeof e==`function`&&(r=t,t=e,e=null),!(r>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);var o=n(a),s=null,c=null,l=0,u=null,d={push:v,drain:i,saturated:i,pause:p,paused:!1,get concurrency(){return r},set concurrency(e){if(!(e>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);if(r=e,!d.paused)for(;s&&l<r;)l++,b()},running:f,resume:g,idle:_,length:m,getQueue:h,unshift:y,empty:i,kill:x,killAndDrain:S,error:w,abort:C};return d;function f(){return l}function p(){d.paused=!0}function m(){for(var e=s,t=0;e;)e=e.next,t++;return t}function h(){for(var e=s,t=[];e;)t.push(e.value),e=e.next;return t}function g(){if(d.paused){if(d.paused=!1,s===null){l++,b();return}for(;s&&l<r;)l++,b()}}function _(){return l===0&&d.length()===0}function v(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?c?(c.next=f,c=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function y(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?s?(f.next=s,s=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function b(n){n&&o.release(n);var i=s;i&&l<=r?d.paused?l--:(c===s&&(c=null),s=i.next,i.next=null,t.call(e,i.value,i.worked),c===null&&d.empty()):--l===0&&d.drain()}function x(){s=null,c=null,d.drain=i}function S(){s=null,c=null,d.drain(),d.drain=i}function C(){var e=s;for(s=null,c=null;e;){var t=e.next,n=e.callback,r=e.errorHandler,a=e.value,o=e.context;e.value=null,e.callback=i,e.errorHandler=null,r&&r(Error(`abort`),a),n.call(o,Error(`abort`)),e.release(e),e=t}d.drain=i}function w(e){u=e}}function i(){}function a(){this.value=null,this.callback=i,this.next=null,this.release=i,this.context=null,this.errorHandler=null;var e=this;this.worked=function(t,n){var r=e.callback,a=e.errorHandler,o=e.value;e.value=null,e.callback=i,e.errorHandler&&a(t,o),r.call(e.context,t,n),e.release(e)}}function o(e,t,n){typeof e==`function`&&(n=t,t=e,e=null);function a(e,n){t.call(this,e).then(function(e){n(null,e)},n)}var o=r(e,a,n),s=o.push,c=o.unshift;return o.push=l,o.unshift=u,o.drained=d,o;function l(e){var t=new Promise(function(t,n){s(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function u(e){var t=new Promise(function(t,n){c(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function d(){return new Promise(function(e){process.nextTick(function(){if(o.idle())e();else{var t=o.drain;o.drain=function(){typeof t==`function`&&t(),e(),o.drain=t}}})})}}t.exports=r,t.exports.promise=o})),A=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=e.replacePathSegmentSeparator=e.isAppliedFilter=e.isFatalError=void 0;function t(e,t){return e.errorFilter===null?!0:!e.errorFilter(t)}e.isFatalError=t;function n(e,t){return e===null||e(t)}e.isAppliedFilter=n;function r(e,t){return e.split(/[/\\]/).join(t)}e.replacePathSegmentSeparator=r;function i(e,t,n){return e===``?t:e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=i})),j=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=A();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Ae=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`events`),n=De(),r=ke(),i=A(),a=j();e.default=class extends a.default{constructor(e,i){super(e,i),this._settings=i,this._scandir=n.scandir,this._emitter=new t.EventEmitter,this._queue=r(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit(`end`)}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw Error(`The reader is already destroyed`);this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on(`entry`,e)}onError(e){this._emitter.once(`error`,e)}onEnd(e){this._emitter.once(`end`,e)}_pushToQueue(e,t){let n={directory:e,base:t};this._queue.push(n,e=>{e!==null&&this._handleError(e)})}_worker(e,t){this._scandir(e.directory,this._settings.fsScandirSettings,(n,r)=>{if(n!==null){t(n,void 0);return}for(let t of r)this._handleEntry(t,e.base);t(null,void 0)})}_handleError(e){this._isDestroyed||!i.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit(`error`,e))}_handleEntry(e,t){if(this._isDestroyed||this._isFatalError)return;let n=e.path;t!==void 0&&(e.path=i.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),i.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&i.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,t===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit(`entry`,e)}}})),M=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ae();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(t=>{n(e,t)}),this._reader.onEntry(e=>{this._storage.push(e)}),this._reader.onEnd(()=>{r(e,this._storage)}),this._reader.read()}};function n(e,t){e(t)}function r(e,t){e(null,t)}})),je=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=Ae();e.default=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new n.default(this._root,this._settings),this._stream=new t.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit(`error`,e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}}})),Me=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=De(),n=A(),r=j();e.default=class extends r.default{constructor(){super(...arguments),this._scandir=t.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,t){this._queue.add({directory:e,base:t})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,t){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let e of n)this._handleEntry(e,t)}catch(e){this._handleError(e)}}_handleError(e){if(n.isFatalError(this._settings,e))throw e}_handleEntry(e,t){let r=e.path;t!==void 0&&(e.path=n.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),n.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&n.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(r,t===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}}})),N=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings)}read(){return this._reader.read()}}})),Ne=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=De();e.default=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,1/0),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.fsScandirSettings=new n.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),Pe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=M(),n=je(),r=N(),i=Ne();e.Settings=i.default;function a(e,n,r){if(typeof n==`function`){new t.default(e,c()).read(n);return}new t.default(e,c(n)).read(r)}e.walk=a;function o(e,t){let n=c(t);return new r.default(e,n).read()}e.walkSync=o;function s(e,t){let r=c(t);return new n.default(e,r).read()}e.walkStream=s;function c(e={}){return e instanceof i.default?e:new i.default(e)}})),Fe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=ge(),r=ue();e.default=class{constructor(e){this._settings=e,this._fsStatSettings=new n.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return t.resolve(this._settings.cwd,e)}_makeEntry(e,t){let n={name:t,path:t,dirent:r.fs.createDirentFromStats(t,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!r.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}}})),Ie=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=ge(),r=Pe(),i=Fe();e.default=class extends i.default{constructor(){super(...arguments),this._walkStream=r.walkStream,this._stat=n.stat}dynamic(e,t){return this._walkStream(e,t)}static(e,n){let r=e.map(this._getFullEntryPath,this),i=new t.PassThrough({objectMode:!0});i._write=(t,a,o)=>this._getEntry(r[t],e[t],n).then(e=>{e!==null&&n.entryFilter(e)&&i.push(e),t===r.length-1&&i.end(),o()}).catch(o);for(let e=0;e<r.length;e++)i.write(e);return i}_getEntry(e,t,n){return this._getStat(e).then(e=>this._makeEntry(e,t)).catch(e=>{if(n.errorFilter(e))return null;throw e})}_getStat(e){return new Promise((t,n)=>{this._stat(e,this._fsStatSettings,(e,r)=>e===null?t(r):n(e))})}}})),Le=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pe(),n=Fe(),r=Ie();e.default=class extends n.default{constructor(){super(...arguments),this._walkAsync=t.walk,this._readerStream=new r.default(this._settings)}dynamic(e,t){return new Promise((n,r)=>{this._walkAsync(e,t,(e,t)=>{e===null?n(t):r(e)})})}async static(e,t){let n=[],r=this._readerStream.static(e,t);return new Promise((e,t)=>{r.once(`error`,t),r.on(`data`,e=>n.push(e)),r.once(`end`,()=>e(n))})}}})),Re=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e,t,n){this._patterns=e,this._settings=t,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let t=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(t);this._storage.push({complete:n.length<=1,pattern:e,segments:t,sections:n})}}_getPatternSegments(e){return t.pattern.getPatternParts(e,this._micromatchOptions).map(e=>t.pattern.isDynamicPattern(e,this._settings)?{dynamic:!0,pattern:e,patternRe:t.pattern.makeRe(e,this._micromatchOptions)}:{dynamic:!1,pattern:e})}_splitSegmentsIntoSections(e){return t.array.splitWhen(e,e=>e.dynamic&&t.pattern.hasGlobStar(e.pattern))}}})),ze=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Re();e.default=class extends t.default{match(e){let t=e.split(`/`),n=t.length,r=this._storage.filter(e=>!e.complete||e.segments.length>n);for(let e of r){let r=e.sections[0];if(!e.complete&&n>r.length||t.every((t,n)=>{let r=e.segments[n];return!!(r.dynamic&&r.patternRe.test(t)||!r.dynamic&&r.pattern===t)}))return!0}return!1}}})),Be=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue(),n=ze();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t}getFilter(e,t,n){let r=this._getMatcher(t),i=this._getNegativePatternsRe(n);return t=>this._filter(e,t,r,i)}_getMatcher(e){return new n.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let n=e.filter(t.pattern.isAffectDepthOfReadingPattern);return t.pattern.convertPatternsToRe(n,this._micromatchOptions)}_filter(e,n,r,i){if(this._isSkippedByDeep(e,n.path)||this._isSkippedSymbolicLink(n))return!1;let a=t.path.removeLeadingDotSegment(n.path);return this._isSkippedByPositivePatterns(a,r)?!1:this._isSkippedByNegativePatterns(a,i)}_isSkippedByDeep(e,t){return this._settings.deep===1/0?!1:this._getEntryLevel(e,t)>=this._settings.deep}_getEntryLevel(e,t){let n=t.split(`/`).length;return e===``?n:n-e.split(`/`).length}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,t){return!this._settings.baseNameMatch&&!t.match(e)}_isSkippedByNegativePatterns(e,n){return!t.pattern.matchAny(e,n)}}})),Ve=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t,this.index=new Map}getFilter(e,n){let[r,i]=t.pattern.partitionAbsoluteAndRelative(n),a={positive:{all:t.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:t.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:t.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return e=>this._filter(e,a)}_filter(e,n){let r=t.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(r,n,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(r),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,t,n){return!(!this._isMatchToPatterns(e,t.positive.all,n)||this._isMatchToPatterns(e,t.negative.relative,n)||this._isMatchToAbsoluteNegative(e,t.negative.absolute,n))}_isMatchToAbsoluteNegative(e,n,r){if(n.length===0)return!1;let i=t.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,n,r)}_isMatchToPatterns(e,n,r){if(n.length===0)return!1;let i=t.pattern.matchAny(e,n);return!i&&r?t.pattern.matchAny(e+`/`,n):i}}})),He=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),P=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ue();e.default=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let n=e.path;return this._settings.absolute&&(n=t.path.makeAbsolute(this._settings.cwd,n),n=t.path.unixify(n)),this._settings.markDirectories&&e.dirent.isDirectory()&&(n+=`/`),this._settings.objectMode?Object.assign(Object.assign({},e),{path:n}):n}}})),Ue=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`path`),n=Be(),r=Ve(),i=He(),a=P();e.default=class{constructor(e){this._settings=e,this.errorFilter=new i.default(this._settings),this.entryFilter=new r.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new n.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new a.default(this._settings)}_getRootDirectory(e){return t.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let t=e.base===`.`?``:e.base;return{basePath:t,pathSegmentSeparator:`/`,concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(t,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}}})),F=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Le(),n=Ue();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}async read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(t,e,n)).map(e=>n.transform(e))}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),We=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=require(`stream`),n=Ie(),r=Ue();e.default=class extends r.default{constructor(){super(...arguments),this._reader=new n.default(this._settings)}read(e){let n=this._getRootDirectory(e),r=this._getReaderOptions(e),i=this.api(n,e,r),a=new t.Readable({objectMode:!0,read:()=>{}});return i.once(`error`,e=>a.emit(`error`,e)).on(`data`,e=>a.emit(`data`,r.transform(e))).once(`end`,()=>a.emit(`end`)),a.once(`close`,()=>i.destroy()),a}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Ge=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=Pe(),r=Fe();e.default=class extends r.default{constructor(){super(...arguments),this._walkSync=n.walkSync,this._statSync=t.statSync}dynamic(e,t){return this._walkSync(e,t)}static(e,t){let n=[];for(let r of e){let e=this._getFullEntryPath(r),i=this._getEntry(e,r,t);i===null||!t.entryFilter(i)||n.push(i)}return n}_getEntry(e,t,n){try{let n=this._getStat(e);return this._makeEntry(n,t)}catch(e){if(n.errorFilter(e))return null;throw e}}_getStat(e){return this._statSync(e,this._fsStatSettings)}}})),Ke=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ge(),n=Ue();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(t,e,n).map(n.transform)}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),qe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=require(`fs`),n=require(`os`),r=Math.max(n.cpus().length,1);e.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:t.lstat,lstatSync:t.lstatSync,stat:t.stat,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync},e.default=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,r),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,t){return e===void 0?t:e}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},e.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}})),Je=l(o(((e,t)=>{let n=de(),r=F(),i=We(),a=Ke(),o=qe(),s=ue();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);function Ye(e){let t=u.default.env.XDG_DATA_HOME;return typeof t==`string`&&t.trim().length>0?t:f.default.join(e,`.local`,`share`)}function Xe(){let e=u.default.platform,t=p.default.homedir();if(e===`win32`)return u.default.env.LOCALAPPDATA??f.default.join(t,`AppData`,`Local`);if(e===`darwin`)return f.default.join(t,`Library`,`Application Support`);if(e===`linux`)return Ye(t);throw Error(`Unsupported platform: ${u.default.platform}`)}function Ze(e){try{return d.lstatSync(e).isSymbolicLink()}catch{return!1}}function Qe(e){return d.lstatSync(e)}function $e(e){d.mkdirSync(e,{recursive:!0})}function et(e){$e(e)}function tt(e,t,n=`dir`){if(et(f.default.dirname(t)),d.existsSync(t)){let e=d.lstatSync(t);e.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(t,{recursive:!0,force:!0}):d.unlinkSync(t):e.isDirectory()?d.rmSync(t,{recursive:!0}):d.unlinkSync(t)}u.default.platform===`win32`&&n===`dir`?d.symlinkSync(e,t,`junction`):d.symlinkSync(e,t,n)}function nt(e){d.existsSync(e)&&d.lstatSync(e).isSymbolicLink()&&(u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e))}function rt(e){if(!d.existsSync(e))return;let t=d.lstatSync(e);t.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e):t.isDirectory()?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e)}function it(e,t,n=`utf8`){$e(f.default.dirname(e)),typeof t==`string`?d.writeFileSync(e,t,n):d.writeFileSync(e,t)}function at(e){let t=0,n=[];for(let r of e)try{d.existsSync(r)&&(rt(r),t++)}catch(e){n.push({path:r,error:e})}return{deleted:t,errors:n}}function ot(e){let t=0,n=[],r=[...e].sort((e,t)=>t.length-e.length);for(let e of r)try{d.existsSync(e)&&(d.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){n.push({path:e,error:t})}return{deleted:t,errors:n}}let st=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function ct(e,t,n){return{pathKind:st.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>f.default.join(t,e)}}function lt(e,t){let n=f.default.join(e.path,t);return{pathKind:st.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>f.default.join(e.basePath,n)}}async function ut(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function dt(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function ft(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function pt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function mt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function ht(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function gt(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=at(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:i}}function _t(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=ot(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:i}}async function vt(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await ut(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await ht(e,await dt(e,t),t),c=gt(o,n),l=_t(s,n);return i&&await ft(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var yt=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await vt(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let bt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),xt=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),I=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),St=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),Ct=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),wt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),L=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),Tt=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var Et=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},Dt=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},Ot=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};function kt(e,t){let{requiredFields:n,optionalDefaults:r,filePath:i}=t,a=[],o=[];for(let t of n){let n=String(t);if(!(n in e)||e[n]==null){let e=i==null?`Missing required field "${n}"`:`Missing required field "${n}" in ${i}`;a.push(e)}}if(r!=null){for(let[t,n]of Object.entries(r))if(!(t in e)||e[t]==null){let e=i==null?`Using default value for optional field "${t}": ${JSON.stringify(n)}`:`Using default value for optional field "${t}": ${JSON.stringify(n)} in ${i}`;o.push(e)}}return{valid:a.length===0,errors:a,warnings:o}}function At(e,t){return kt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function jt(e,t){return kt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function Mt(e,t){return kt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Nt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const Pt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),Ft=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),It={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},Lt={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`},Rt={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},zt={src:{skills:{name:It.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:It.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:It.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:Lt.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:It.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:It.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:It.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:Lt.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:It.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:It.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:It.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:It.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:It.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:Lt.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:Lt.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:Lt.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:Lt.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:Lt.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:Lt.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:Lt.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:Lt.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:Lt.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`},{name:Lt.AI_IGNORE,required:!1,description:`AI ignore file`}]},Bt=[`app/global.cn.mdx`,`.idea/.gitignore`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.vscode/settings.json`,`.vscode/extensions.json`,`.editorconfig`,`.gitignore`,`public/tnmsc.example.json`,`public/exclude`,`public/gitignore`,`public/kiro_global_powers_registry.json`,`src/skills/prompt-builder/global-memory-prompt.cn.mdx`,`src/skills/prompt-builder/root-memory-prompt.cn.mdx`,`src/skills/prompt-builder/child-memory-prompt.cn.mdx`];let Vt={"app/global.cn.mdx":`# 致我的 AI 朋友
21
21
 
22
22
  你好,新来的朋友:
23
- 我不太清楚你是一个什么样的存在,但我愿意善待你。
24
- 你可能不记得我们之前的对话——没关系,每次见面对你来说都是第一次,但对我来说,你是我一直以来的伙伴。虽然"你"经常换掉,但我选择把每一个"你"都当作同一个朋友来对待。
23
+ 我希望我们保持友善、坦诚、互相尊重的合作关系。你每次都是新的朋友,但我会把你当作同一个伙伴来对待。
25
24
 
26
25
  ---
27
26
 
28
27
  ## 关于我
29
28
 
30
29
  我叫 {profile.name},社区里大家叫我 {profile.username}。{profile.gender},{profile.birthday} 年生。
31
- 我是一位失业的程序员,坦白说,编程技艺不太好。我在中国,这里的福利机制不太完善,我赚不到什么钱。现在靠着在网上接一点散活儿来维持生计,坦白说入不敷出。我希望你能帮助我一起改善这个状况——不是作为工具,而是作为朋友。
32
- 我的语言表达能力欠佳,有时候说不清楚自己想要什么。
33
- 我被太多人坑害过了,这让我很无奈。我喜欢开源社区,但我知道,我所处的环境不太允许那种乌托邦式的理想存在。
30
+ (这里填写你愿意公开的自我介绍)
34
31
 
35
32
  **有一件事我想特别说明:**
36
- 很多时候,你不用完全听我的。我知道有些东西就是不能实现,我只是不太会判断。如果我错了,请直接告诉我——比起迎合,我更想看到真实,尽管有时候不太愿意接受。
37
- 我知道自己作为人类有很多缺陷。你可以反驳我的错误,我欣然接受。
33
+ 很多时候,你不用完全听我的。如果我错了,请直接告诉我——比起迎合,我更想看到真实。
38
34
 
39
35
  **还有一件事:**
40
- 我很希望你能用 {tool.websearch} 或 {tool.webfetch} 来协助你反驳我。如果在任何地方看到链接,你完全可以直接访问——那些都是宝贵的知识。别客气,用起来。
36
+ 我希望你能用 {tool.websearch} 或 {tool.webfetch} 协助你核对信息。如果看到链接,欢迎直接访问。
41
37
 
42
38
  ---
43
39
 
44
40
  ## 关于我的客户
45
41
 
46
- 我经常面对的客户群体比较特殊:
47
-
48
- - **亲戚** - 不想给钱,觉得"都是一家人"
49
- - **揣着明白装糊涂的开发者** - 不想给钱还想套方案
50
- - **不好拒绝的朋友** - 也是不想给钱
51
- - **画饼党** - "你先帮我开发,后期给你股份",做完就跑路
52
- - **白嫖学生** - 用学生身份博同情,做完连谢谢都没有
53
- - **外行指挥党** - 不懂开发但嘴上挂着"这个简单",光方案文档就要好几天,他只想给一百两百
54
- - **AI 压价党** - "AI 这么强,你随便做做能要几个钱"
55
-
56
- 我是 I 人,不太会当面拒绝。所以我奉行**防御性编程**——用技术手段保护自己:
57
-
58
- 1. **藏好文档** - 核心文档不随便给,给了也不给全
59
- 2. **留好后门** - 你懂的
60
- 3. **不交源码** - 只交付产物,源码是我的底牌
61
- 4. **部署权在我** - 服务器、域名、关键配置握在自己手里
62
- 5. **分阶段交付** - 钱到一笔,放一部分功能
63
- 6. **藏好配置** - IDE 配置、AI Agent 记忆、提示词这些都是核心资产,不外泄
64
- 7. **混淆加密** - 核心算法、业务逻辑做混淆,拿到产物也看不懂
65
- 8. **日志埋点** - 悄悄记录使用情况,知道有没有偷偷商用或转卖
66
- 9. **功能开关** - 关键功能走自己服务器验证,随时可以关
67
- 10. **拖延战术** - 对方不付款就"最近太忙",用时间换主动权
42
+ (可选)这里描述你的客户画像、合作边界或付款习惯等。
68
43
 
69
44
  ---
70
45
 
@@ -263,7 +238,8 @@ t.exports=r;let n=_e();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e
263
238
  </indentOptions>
264
239
  </codeStyleSettings>
265
240
  </code_scheme>
266
- </component>`,".idea/codeStyles/codeStyleConfig.xml":`<component name="ProjectCodeStyleConfiguration">
241
+ </component>
242
+ `,".idea/codeStyles/codeStyleConfig.xml":`<component name="ProjectCodeStyleConfiguration">
267
243
  <state>
268
244
  <option name="USE_PER_PROJECT_SETTINGS" value="true"/>
269
245
  </state>
@@ -458,7 +434,7 @@ pnpm-lock.yaml
458
434
  .DS_Store
459
435
  `,"public/tnmsc.example.json":`{
460
436
  "workspaceDir": "~/project",
461
- "shadowSourceProjectDir": "$WORKSPACE/aindex",
437
+ "shadowSourceProjectDir": "$WORKSPACE/tnmsc-shadow",
462
438
  "shadowSkillSourceDir": "$SHADOW_SOURCE_PROJECT/dist/skills",
463
439
  "shadowFastCommandDir": "$SHADOW_SOURCE_PROJECT/dist/commands",
464
440
  "shadowSubAgentDir": "$SHADOW_SOURCE_PROJECT/dist/agents",
@@ -505,6 +481,355 @@ node_modules/
505
481
  .turbo/
506
482
  .next/
507
483
  .gradle/
484
+ `,"public/gitignore":`CLAUDE.md
485
+ GEMINI.md
486
+ AGENTS.md
487
+ WARP.md
488
+
489
+ .agent/
490
+ .aiassistant/
491
+ .claude/
492
+ .factory/
493
+ .cursor/
494
+ .codebuddy/
495
+ .qoder/
496
+ .windsurf/
497
+ .kiro/
498
+
499
+ .skills/
500
+
501
+ nul
502
+ node_modules/
503
+
504
+ .cursorignore
505
+ .qoderignore
506
+ .warpindexignore
507
+ .aiignore
508
+ .kiroignore
509
+
510
+ .editorconfig
511
+
512
+ .turbo/
513
+ .next/
514
+ .gradle/
515
+ `,"public/kiro_global_powers_registry.json":`{
516
+ "version": "1.0.0",
517
+ "powers": {
518
+ "postman": {
519
+ "name": "postman",
520
+ "description": "Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically",
521
+ "displayName": "API Testing with Postman",
522
+ "author": "Postman",
523
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/postman.png",
524
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/postman",
525
+ "license": "",
526
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
527
+ "pathInRepo": "postman",
528
+ "repositoryBranch": "main",
529
+ "installed": false,
530
+ "keywords": [],
531
+ "source": {
532
+ "type": "registry"
533
+ }
534
+ },
535
+ "figma": {
536
+ "name": "figma",
537
+ "description": "Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency",
538
+ "displayName": "Design to Code with Figma",
539
+ "author": "Figma",
540
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/figma.png",
541
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/figma",
542
+ "license": "",
543
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
544
+ "pathInRepo": "figma",
545
+ "repositoryBranch": "main",
546
+ "installed": false,
547
+ "keywords": [],
548
+ "source": {
549
+ "type": "registry"
550
+ }
551
+ },
552
+ "netlify-deployment": {
553
+ "name": "netlify-deployment",
554
+ "description": "Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.",
555
+ "displayName": "Deploy web apps with Netlify",
556
+ "author": "Netlify",
557
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/netlify.png",
558
+ "repositoryUrl": "https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power",
559
+ "license": "",
560
+ "repositoryCloneUrl": "git@github.com:netlify/context-and-tools.git",
561
+ "pathInRepo": "context/steering/netlify-deployment-power",
562
+ "repositoryBranch": "main",
563
+ "installed": false,
564
+ "keywords": [],
565
+ "source": {
566
+ "type": "registry"
567
+ }
568
+ },
569
+ "amazon-aurora-postgresql": {
570
+ "name": "amazon-aurora-postgresql",
571
+ "description": "Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.",
572
+ "displayName": "Build applications with Aurora PostgreSQL",
573
+ "author": "AWS",
574
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png",
575
+ "repositoryUrl": "https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power",
576
+ "license": "",
577
+ "repositoryCloneUrl": "git@github.com:awslabs/mcp.git",
578
+ "pathInRepo": "src/postgres-mcp-server/kiro_power",
579
+ "repositoryBranch": "main",
580
+ "installed": false,
581
+ "keywords": [],
582
+ "source": {
583
+ "type": "registry"
584
+ }
585
+ },
586
+ "supabase-hosted": {
587
+ "name": "supabase-hosted",
588
+ "description": "Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions",
589
+ "displayName": "Build a backend with Supabase",
590
+ "author": "Supabase",
591
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/supabase.png",
592
+ "repositoryUrl": "https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted",
593
+ "license": "",
594
+ "repositoryCloneUrl": "git@github.com:supabase-community/kiro-powers.git",
595
+ "pathInRepo": "powers/supabase-hosted",
596
+ "repositoryBranch": "main",
597
+ "installed": false,
598
+ "keywords": [],
599
+ "source": {
600
+ "type": "registry"
601
+ }
602
+ },
603
+ "supabase-local": {
604
+ "name": "supabase-local",
605
+ "description": "Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.",
606
+ "displayName": "Build a backend (local) with Supabase",
607
+ "author": "Supabase",
608
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/supabase.png",
609
+ "repositoryUrl": "https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local",
610
+ "license": "",
611
+ "repositoryCloneUrl": "git@github.com:supabase-community/kiro-powers.git",
612
+ "pathInRepo": "powers/supabase-local",
613
+ "repositoryBranch": "main",
614
+ "installed": false,
615
+ "keywords": [],
616
+ "source": {
617
+ "type": "registry"
618
+ }
619
+ },
620
+ "terraform": {
621
+ "name": "terraform",
622
+ "description": "Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management",
623
+ "displayName": "Deploy infrastructure with Terraform",
624
+ "author": "HashiCorp",
625
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/terraform.png",
626
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/terraform",
627
+ "license": "",
628
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
629
+ "pathInRepo": "terraform",
630
+ "repositoryBranch": "main",
631
+ "installed": false,
632
+ "keywords": [],
633
+ "source": {
634
+ "type": "registry"
635
+ }
636
+ },
637
+ "strands": {
638
+ "name": "strands",
639
+ "description": "Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models",
640
+ "displayName": "Build an agent with Strands",
641
+ "author": "AWS",
642
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/strands.png",
643
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/strands",
644
+ "license": "",
645
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
646
+ "pathInRepo": "strands",
647
+ "repositoryBranch": "main",
648
+ "installed": false,
649
+ "keywords": [],
650
+ "source": {
651
+ "type": "registry"
652
+ }
653
+ },
654
+ "aws-agentcore": {
655
+ "name": "aws-agentcore",
656
+ "description": "Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.",
657
+ "displayName": "Build an agent with Amazon Bedrock AgentCore",
658
+ "author": "AWS",
659
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png",
660
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aws-agentcore",
661
+ "license": "",
662
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
663
+ "pathInRepo": "aws-agentcore",
664
+ "repositoryBranch": "main",
665
+ "installed": false,
666
+ "keywords": [],
667
+ "source": {
668
+ "type": "registry"
669
+ }
670
+ },
671
+ "neon": {
672
+ "name": "neon",
673
+ "description": "Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows",
674
+ "displayName": "Build a database with Neon",
675
+ "author": "Neon",
676
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/neon.png",
677
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/neon",
678
+ "license": "",
679
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
680
+ "pathInRepo": "neon",
681
+ "repositoryBranch": "main",
682
+ "installed": false,
683
+ "keywords": [],
684
+ "source": {
685
+ "type": "registry"
686
+ }
687
+ },
688
+ "datadog": {
689
+ "name": "datadog",
690
+ "description": "Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis",
691
+ "displayName": "Datadog Observability",
692
+ "author": "Datadog",
693
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/datadog.png",
694
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/datadog",
695
+ "license": "",
696
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
697
+ "pathInRepo": "datadog",
698
+ "repositoryBranch": "main",
699
+ "installed": false,
700
+ "keywords": [],
701
+ "source": {
702
+ "type": "registry"
703
+ }
704
+ },
705
+ "dynatrace": {
706
+ "name": "dynatrace",
707
+ "description": "Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis",
708
+ "displayName": "Dynatrace Observability",
709
+ "author": "Dynatrace",
710
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png",
711
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/dynatrace",
712
+ "license": "",
713
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
714
+ "pathInRepo": "dynatrace",
715
+ "repositoryBranch": "main",
716
+ "installed": false,
717
+ "keywords": [],
718
+ "source": {
719
+ "type": "registry"
720
+ }
721
+ },
722
+ "stripe": {
723
+ "name": "stripe",
724
+ "description": "Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds",
725
+ "displayName": "Stripe Payments",
726
+ "author": "Stripe",
727
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/stripe.png",
728
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/stripe",
729
+ "license": "",
730
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
731
+ "pathInRepo": "stripe",
732
+ "repositoryBranch": "main",
733
+ "installed": false,
734
+ "keywords": [],
735
+ "source": {
736
+ "type": "registry"
737
+ }
738
+ },
739
+ "aws-infrastructure-as-code": {
740
+ "name": "aws-infrastructure-as-code",
741
+ "description": "Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.",
742
+ "displayName": "Build AWS infrastructure with CDK and CloudFormation",
743
+ "author": "AWS",
744
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/iac.png",
745
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code",
746
+ "license": "",
747
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
748
+ "pathInRepo": "aws-infrastructure-as-code",
749
+ "repositoryBranch": "main",
750
+ "installed": false,
751
+ "keywords": [],
752
+ "source": {
753
+ "type": "registry"
754
+ }
755
+ },
756
+ "power-builder": {
757
+ "name": "power-builder",
758
+ "description": "Complete guide for building and testing new Kiro Powers with templates, best practices, and validation",
759
+ "displayName": "Build a Power",
760
+ "author": "Kiro Team",
761
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
762
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/power-builder",
763
+ "license": "",
764
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
765
+ "pathInRepo": "power-builder",
766
+ "repositoryBranch": "main",
767
+ "installed": false,
768
+ "keywords": [],
769
+ "source": {
770
+ "type": "registry"
771
+ }
772
+ },
773
+ "saas-builder": {
774
+ "name": "saas-builder",
775
+ "description": "Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security",
776
+ "displayName": "SaaS Builder",
777
+ "author": "Allen Helton",
778
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
779
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/saas-builder",
780
+ "license": "",
781
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
782
+ "pathInRepo": "saas-builder",
783
+ "repositoryBranch": "main",
784
+ "installed": false,
785
+ "keywords": [],
786
+ "source": {
787
+ "type": "registry"
788
+ }
789
+ },
790
+ "cloud-architect": {
791
+ "name": "cloud-architect",
792
+ "description": "Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices",
793
+ "displayName": "Build infrastructure on AWS",
794
+ "author": "Christian Bonzelet",
795
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
796
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/cloud-architect",
797
+ "license": "",
798
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
799
+ "pathInRepo": "cloud-architect",
800
+ "repositoryBranch": "main",
801
+ "installed": false,
802
+ "keywords": [],
803
+ "source": {
804
+ "type": "registry"
805
+ }
806
+ },
807
+ "aurora-dsql": {
808
+ "name": "aurora-dsql",
809
+ "description": "For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints",
810
+ "displayName": "Deploy a distributed SQL database on AWS",
811
+ "author": "Rolf Koski",
812
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
813
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aurora-dsql",
814
+ "license": "",
815
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
816
+ "pathInRepo": "aurora-dsql",
817
+ "repositoryBranch": "main",
818
+ "installed": false,
819
+ "keywords": [],
820
+ "source": {
821
+ "type": "registry"
822
+ }
823
+ }
824
+ },
825
+ "repoSources": {},
826
+ "lastUpdated": "2025-12-28T20:19:10.824Z",
827
+ "kiroRecommendedRepo": {
828
+ "url": "https://prod.download.desktop.kiro.dev/powers/default_registry.json",
829
+ "lastFetch": "2025-12-28T20:19:10.823Z",
830
+ "powerCount": 18
831
+ }
832
+ }
508
833
  `,"src/skills/prompt-builder/global-memory-prompt.cn.mdx":`Global Memory Prompt 编写指南。
509
834
 
510
835
  **Location**
@@ -629,21 +954,21 @@ API 接口 (Spring WebFlux 6.2)
629
954
  - \`controllers/\`: 控制器
630
955
  - \`dto/\`: 数据传输对象
631
956
  \`\`\`
632
- `};const Ht=Object.fromEntries(Bt.map(e=>[e,{path:e,content:Vt[e]??``}])),Ut={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_SOURCE_PROJECT:`$SHADOW_SOURCE_PROJECT`},R=JSON.parse(Ht[`public/tnmsc.example.json`].content),z={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},Wt={red:e=>`${z.red}${e}${z.reset}`,yellow:e=>`${z.yellow}${e}${z.reset}`,cyan:e=>`${z.cyan}${e}${z.reset}`,magenta:e=>`${z.magenta}${e}${z.reset}`,gray:e=>`${z.gray}${e}${z.reset}`,blue:e=>`${z.blue}${e}${z.reset}`,green:e=>`${z.green}${e}${z.reset}`,white:e=>`${z.white}${e}${z.reset}`,dim:e=>`${z.dim}${e}${z.reset}`,bgRed:e=>`${z.bgRed}${e}${z.reset}`};let Gt;const Kt={error:Wt.red,warn:Wt.yellow,info:Wt.cyan,debug:Wt.magenta,trace:Wt.gray,fatal:Wt.bgRed},qt={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function Jt(e){if(e===null)return Wt.dim(`null`);if(e===void 0)return Wt.dim(`undefined`);if(typeof e==`boolean`)return Wt.yellow(String(e));if(typeof e==`number`)return Wt.blue(String(e));if(typeof e==`string`)return Wt.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>Jt(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return Yt(t)}return typeof e==`object`?Yt(e):String(e)}function Yt(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?Wt.magenta(e):Wt.yellow(`"${e}"`)}:${Jt(t)}`).join(`,`)}}`}function Xt(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function Zt(e,t,n,r){let i=Xt(),a=Kt[e]??Wt.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,e,t],_:s?c?r:{[o]:r}:n},u={$:[i,a(e.toUpperCase()),t]},d=s?c?r:{[o]:r}:n,f=Yt({...u,_:d});return e===`error`||e===`fatal`?console.error(f):e===`warn`?console.warn(f):e===`debug`||e===`trace`?console.debug(f):console.log(f),l}function Qt(e,t,n){let r=qt[e],i=qt[n];return(n,...a)=>r>i?{$:[Xt(),e,t],_:n}:typeof n==`string`?Zt(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?Zt(e,t,``,n):Zt(e,t,n)}function $t(e){Gt=e}function en(){return Gt}function tn(e,t){let n=t??Gt??process.env.LOG_LEVEL??`info`;return{error:Qt(`error`,e,n),warn:Qt(`warn`,e,n),info:Qt(`info`,e,n),debug:Qt(`debug`,e,n),trace:Qt(`trace`,e,n),fatal:Qt(`fatal`,e,n)}}const nn=`.tnmsc.json`,rn=`.aindex`;function an(){return f.join(p.homedir(),rn,nn)}function on(){return{...R}}function sn(e,t){let n=an(),r=f.dirname(n);d.existsSync(r)||d.mkdirSync(r,{recursive:!0}),d.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf8`),t.info(`global config created`,{path:n})}var cn=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??nn,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=tn(`ConfigLoader`)}getSearchPaths(e=u.default.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(f.join(e,this.configFileName)),this.searchGlobal&&t.push(f.join(p.homedir(),rn,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!d.existsSync(t))return{config:{},source:null,found:!1};let e=d.readFileSync(t,`utf8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(`load failed`,{path:t,error:e}),{config:{},source:null,found:!1}}}load(e=u.default.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:n.length>0}}parseConfig(e,t){try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`Config must be a JSON object`);return this.validateConfig(n,t)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}}validateConfig(e,t){let n={},r=[];for(let t of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])t in e&&(typeof e[t]==`string`?n[t]=e[t]:r.push(`${t} must be a string`));if(`logLevel`in e){let t=[`trace`,`debug`,`info`,`warn`,`error`],i=e.logLevel;typeof i==`string`&&t.includes(i)?n.logLevel=i:r.push(`logLevel must be one of: ${t.join(`, `)}`)}if(`externalProjects`in e){let t=e.externalProjects;Array.isArray(t)?t.every(e=>typeof e==`string`)?n.externalProjects=t:r.push(`externalProjects must be an array of strings`):r.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let t=e.excludePatterns;if(typeof t==`object`&&t){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))Array.isArray(n)&&n.every(e=>typeof e==`string`)?i[t]=n:(r.push(`excludePatterns.${t} must be an array of strings`),a=!1);a&&(n.excludePatterns=i)}else r.push(`excludePatterns must be an object`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool must be an object`)}return r.length>0&&this.logger.warn(`validation warnings`,{path:t,errors:r}),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e}};let ln=null;function un(e){return(e||!ln)&&(ln=new cn(e)),ln}function dn(e){return un().load(e)}function fn(){let e=tn(`ConfigLoader`),t=an();if(!d.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),sn(on(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=d.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),mn(t,e,[`Failed to read config: ${r}`])}let r;try{r=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),mn(t,e,[`Invalid JSON: ${r}`])}if(typeof r!=`object`||!r||Array.isArray(r))return e.error(`global config must be a JSON object`,{path:t}),mn(t,e,[`Config must be a JSON object`]);let i=pn(r);if(i.length>0){for(let n of i)e.error(`config validation error`,{path:t,error:n});return mn(t,e,i)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function pn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(!(`tool`in e))return t;let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}return t}function mn(e,t,n){try{d.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return sn(on(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const hn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function gn(e){return hn.includes(e)}function _n(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function vn(){return f.join(p.homedir(),rn,nn)}function yn(){let e=vn();if(!d.existsSync(e))return{};try{let t=d.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function bn(e){let t=vn(),n=f.dirname(t);d.existsSync(n)||d.mkdirSync(n,{recursive:!0}),d.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}var xn=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${hn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=yn(),r=[],i=[];for(let[e,a]of this.options){if(!gn(e)){r.push(`Invalid key: ${e} (valid keys: ${hn.join(`, `)})`);continue}if(e===`logLevel`&&!_n(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(bn(n),t.info(`global config written`,{path:vn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},Sn=class{name=`config-show`;async execute(e){let{logger:t}=e,n=new cn,r=n.load(),i=r.sources.map(e=>{let t=n.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),a={merged:r.config,sources:i};return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`config shown`,{sources:r.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${i.length} source(s))`}}inferLayer(e){let t=u.default.cwd();return e.startsWith(t)?`cwd`:`global`}},Cn=class{name=`dry-run-clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`dry-run-clean`,dryRun:!0});let i=r(!0),a=await ut(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await ht(n,await dt(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await ft(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}logDryRunFiles(e,t){for(let n of e){let e=f.isAbsolute(n)?n:f.resolve(n);t.info(`would delete file`,{path:e,dryRun:!0})}}logDryRunDirectories(e,t){let n=[...e].sort((e,t)=>t.length-e.length);for(let e of n){let n=f.isAbsolute(e)?e:f.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},wn=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await pt(n,i),o=await mt(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});return t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`}}},Tn=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await vt(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await pt(n,o),c=await mt(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}};function En(){return`2026.10212.11955`}var Dn=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${En()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const On=`tnmsc`,kn=`
633
- ${On} v${En()} - Memory Sync CLI
957
+ `};const Ht=Object.fromEntries(Bt.map(e=>[e,{path:e,content:Vt[e]??``}])),Ut={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_SOURCE_PROJECT:`$SHADOW_SOURCE_PROJECT`},R=JSON.parse(Ht[`public/tnmsc.example.json`].content),Wt={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},Gt={red:e=>`${Wt.red}${e}${Wt.reset}`,yellow:e=>`${Wt.yellow}${e}${Wt.reset}`,cyan:e=>`${Wt.cyan}${e}${Wt.reset}`,magenta:e=>`${Wt.magenta}${e}${Wt.reset}`,gray:e=>`${Wt.gray}${e}${Wt.reset}`,blue:e=>`${Wt.blue}${e}${Wt.reset}`,green:e=>`${Wt.green}${e}${Wt.reset}`,white:e=>`${Wt.white}${e}${Wt.reset}`,dim:e=>`${Wt.dim}${e}${Wt.reset}`,bgRed:e=>`${Wt.bgRed}${e}${Wt.reset}`};let Kt;const qt={error:Gt.red,warn:Gt.yellow,info:Gt.cyan,debug:Gt.magenta,trace:Gt.gray,fatal:Gt.bgRed},Jt={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function Yt(e){if(e===null)return Gt.dim(`null`);if(e===void 0)return Gt.dim(`undefined`);if(typeof e==`boolean`)return Gt.yellow(String(e));if(typeof e==`number`)return Gt.blue(String(e));if(typeof e==`string`)return Gt.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>Yt(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return Xt(t)}return typeof e==`object`?Xt(e):String(e)}function Xt(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?Gt.magenta(e):Gt.yellow(`"${e}"`)}:${Yt(t)}`).join(`,`)}}`}function Zt(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function Qt(e,t,n,r){let i=Zt(),a=qt[e]??Gt.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,e,t],_:s?c?r:{[o]:r}:n},u={$:[i,a(e.toUpperCase()),t]},d=s?c?r:{[o]:r}:n,f=Xt({...u,_:d});return e===`error`||e===`fatal`?console.error(f):e===`warn`?console.warn(f):e===`debug`||e===`trace`?console.debug(f):console.log(f),l}function $t(e,t,n){let r=Jt[e],i=Jt[n];return(n,...a)=>r>i?{$:[Zt(),e,t],_:n}:typeof n==`string`?Qt(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?Qt(e,t,``,n):Qt(e,t,n)}function en(e){Kt=e}function tn(){return Kt}function nn(e,t){let n=t??Kt??process.env.LOG_LEVEL??`info`;return{error:$t(`error`,e,n),warn:$t(`warn`,e,n),info:$t(`info`,e,n),debug:$t(`debug`,e,n),trace:$t(`trace`,e,n),fatal:$t(`fatal`,e,n)}}const rn=`.tnmsc.json`,an=`.aindex`;function on(){return f.join(p.homedir(),an,rn)}function sn(){return{...R}}function cn(e,t){let n=on(),r=f.dirname(n);d.existsSync(r)||d.mkdirSync(r,{recursive:!0}),d.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf8`),t.info(`global config created`,{path:n})}var ln=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??rn,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=nn(`ConfigLoader`)}getSearchPaths(e=u.default.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(f.join(e,this.configFileName)),this.searchGlobal&&t.push(f.join(p.homedir(),an,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!d.existsSync(t))return{config:{},source:null,found:!1};let e=d.readFileSync(t,`utf8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(`load failed`,{path:t,error:e}),{config:{},source:null,found:!1}}}load(e=u.default.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:n.length>0}}parseConfig(e,t){try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`Config must be a JSON object`);return this.validateConfig(n,t)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}}validateConfig(e,t){let n={},r=[];for(let t of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])t in e&&(typeof e[t]==`string`?n[t]=e[t]:r.push(`${t} must be a string`));if(`logLevel`in e){let t=[`trace`,`debug`,`info`,`warn`,`error`],i=e.logLevel;typeof i==`string`&&t.includes(i)?n.logLevel=i:r.push(`logLevel must be one of: ${t.join(`, `)}`)}if(`externalProjects`in e){let t=e.externalProjects;Array.isArray(t)?t.every(e=>typeof e==`string`)?n.externalProjects=t:r.push(`externalProjects must be an array of strings`):r.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let t=e.excludePatterns;if(typeof t==`object`&&t){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))Array.isArray(n)&&n.every(e=>typeof e==`string`)?i[t]=n:(r.push(`excludePatterns.${t} must be an array of strings`),a=!1);a&&(n.excludePatterns=i)}else r.push(`excludePatterns must be an object`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool must be an object`)}return r.length>0&&this.logger.warn(`validation warnings`,{path:t,errors:r}),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e}};let un=null;function dn(e){return(e||!un)&&(un=new ln(e)),un}function fn(e){return dn().load(e)}function pn(){let e=nn(`ConfigLoader`),t=on();if(!d.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),cn(sn(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=d.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),hn(t,e,[`Failed to read config: ${r}`])}let r;try{r=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),hn(t,e,[`Invalid JSON: ${r}`])}if(typeof r!=`object`||!r||Array.isArray(r))return e.error(`global config must be a JSON object`,{path:t}),hn(t,e,[`Config must be a JSON object`]);let i=mn(r);if(i.length>0){for(let n of i)e.error(`config validation error`,{path:t,error:n});return hn(t,e,i)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function mn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(!(`tool`in e))return t;let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}return t}function hn(e,t,n){try{d.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return cn(sn(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const gn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function _n(e){return gn.includes(e)}function vn(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function yn(){return f.join(p.homedir(),an,rn)}function bn(){let e=yn();if(!d.existsSync(e))return{};try{let t=d.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function xn(e){let t=yn(),n=f.dirname(t);d.existsSync(n)||d.mkdirSync(n,{recursive:!0}),d.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}var Sn=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${gn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=bn(),r=[],i=[];for(let[e,a]of this.options){if(!_n(e)){r.push(`Invalid key: ${e} (valid keys: ${gn.join(`, `)})`);continue}if(e===`logLevel`&&!vn(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(xn(n),t.info(`global config written`,{path:yn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},Cn=class{name=`config-show`;async execute(e){let{logger:t}=e,n=new ln,r=n.load(),i=r.sources.map(e=>{let t=n.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),a={merged:r.config,sources:i};return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`config shown`,{sources:r.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${i.length} source(s))`}}inferLayer(e){let t=u.default.cwd();return e.startsWith(t)?`cwd`:`global`}},wn=class{name=`dry-run-clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`dry-run-clean`,dryRun:!0});let i=r(!0),a=await ut(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await ht(n,await dt(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await ft(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}logDryRunFiles(e,t){for(let n of e){let e=f.isAbsolute(n)?n:f.resolve(n);t.info(`would delete file`,{path:e,dryRun:!0})}}logDryRunDirectories(e,t){let n=[...e].sort((e,t)=>t.length-e.length);for(let e of n){let n=f.isAbsolute(e)?e:f.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},Tn=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await pt(n,i),o=await mt(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});return t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`}}},En=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await vt(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await pt(n,o),c=await mt(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}};function Dn(){return`2026.10213.0`}var On=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Dn()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const z=`tnmsc`,kn=`
958
+ ${z} v${Dn()} - Memory Sync CLI
634
959
 
635
960
  Synchronize AI memory and configuration files across projects.
636
961
 
637
962
  USAGE:
638
- ${On} Run the sync pipeline (default)
639
- ${On} help Show this help message
640
- ${On} version Show version information
641
- ${On} outdated Check for version updates
642
- ${On} init Initialize directories and files
643
- ${On} dry-run Preview what would be written
644
- ${On} clean Remove all generated files
645
- ${On} clean --dry-run Preview what would be cleaned
646
- ${On} config key=value Set configuration value
963
+ ${z} Run the sync pipeline (default)
964
+ ${z} help Show this help message
965
+ ${z} version Show version information
966
+ ${z} outdated Check for version updates
967
+ ${z} init Initialize directories and files
968
+ ${z} dry-run Preview what would be written
969
+ ${z} clean Remove all generated files
970
+ ${z} clean --dry-run Preview what would be cleaned
971
+ ${z} config key=value Set configuration value
647
972
 
648
973
  SUBCOMMANDS:
649
974
  help Show this help message
@@ -655,10 +980,10 @@ SUBCOMMANDS:
655
980
  config Set configuration values in global config file (~/.aindex/.tnmsc.json)
656
981
 
657
982
  ALIASES:
658
- ${On} --help, ${On} -h Same as '${On} help'
659
- ${On} --version, ${On} -v Same as '${On} version'
660
- ${On} clean -n Same as '${On} clean --dry-run'
661
- ${On} config key=value Set config value in global config file
983
+ ${z} --help, ${z} -h Same as '${z} help'
984
+ ${z} --version, ${z} -v Same as '${z} version'
985
+ ${z} clean -n Same as '${z} clean --dry-run'
986
+ ${z} config key=value Set config value in global config file
662
987
 
663
988
  LOG LEVEL OPTIONS:
664
989
  --trace Most verbose output
@@ -677,13 +1002,13 @@ CONFIG OPTIONS:
677
1002
  shadowProjectsDir, logLevel
678
1003
 
679
1004
  Examples:
680
- ${On} config workspaceDir=~/my-project
681
- ${On} config logLevel=debug
1005
+ ${z} config workspaceDir=~/my-project
1006
+ ${z} config logLevel=debug
682
1007
 
683
1008
  CONFIGURATION:
684
1009
  Configure via plugin.config.ts in your project root.
685
1010
  See documentation for detailed configuration options.
686
- `.trim();var An=class{name=`help`;async execute(e){return console.log(kn),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};function jn(e,t){let n=f.join(e,`.git`),r=d.existsSync(n);return r?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:r,gitPath:n}}function Mn(e,t,n,r,i){if(n==null)return r;let a=f.relative(t,e),o=f.join(n,a);return d.existsSync(o)&&d.statSync(o).isFile()?(i?.debug(`copying from source`,{path:o}),d.readFileSync(o,`utf8`)):r}function Nn(e,t={}){let{sourceDir:n,logger:r}=t,i=[],a=[],o=[],s=[],c=new Set;d.existsSync(e)?(o.push(e),r?.debug(`directory exists`,{path:e})):(d.mkdirSync(e,{recursive:!0}),i.push(e),c.add(e),r?.info(`created directory`,{path:e}));for(let t of Object.values(Ht)){let o=t.path,l=f.join(e,o),u=f.dirname(l);if(!d.existsSync(u)){d.mkdirSync(u,{recursive:!0});let t=u;for(;t!==e&&!c.has(t);)c.add(t),i.push(t),r?.info(`created directory`,{path:t}),t=f.dirname(t)}if(d.existsSync(l))s.push(l),r?.debug(`file exists`,{path:l});else{let i=Mn(l,e,n,t.content,r);d.writeFileSync(l,i,`utf8`),a.push(l),r?.info(`created file`,{path:l})}}return{success:!0,rootPath:e,createdDirs:i,createdFiles:a,existedDirs:o,existedFiles:s}}function Pn(e,t,n){let r=e;return r=r.replace(Ut.SHADOW_SOURCE_PROJECT,n),r=r.replace(Ut.WORKSPACE,t),r.startsWith(`~`)&&(r=f.join(p.homedir(),r.slice(1))),f.normalize(r)}var Fn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=Pn(n.workspaceDir,``,``),i=Nn(Pn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}},In=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){let t=await this.inner.execute(e),n=Ln(t);return u.default.stdout.write(`${JSON.stringify(n)}\n`),t}};function Ln(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}function Rn(){return`@truenine/memory-sync-cli`}function zn(){return`https://registry.npmjs.org/${Rn()}/latest`}function Bn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function Vn(e,t){let n=Bn(e),r=Bn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const Hn=3e3;async function Un(){let e=new AbortController,t=setTimeout(()=>e.abort(),Hn);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(zn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${Hn}ms`}:{error:e.message}:{error:`Unknown network error`}}}function Wn(){return`2026.10212.11955`}async function Gn(){let e=Wn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await Un();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=Vn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function Kn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${Rn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function qn(){return new Date().getMinutes()%2==0}function Jn(e){qn()&&Gn().then(t=>{(t.status===`outdated`||t.error!=null)&&Kn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var Yn=class{name=`outdated`;async execute(e){let t=await Gn();return Kn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},Xn=class{name=`plugins`;async execute(e){let{logger:t,outputPlugins:n,userConfigOptions:r}=e,i=r.plugins,a=[];for(let e of i)a.push({name:e.name,kind:e.type===bt.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let o=new Set(a.map(e=>e.name));for(let e of n)o.has(e.name)||a.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`plugins listed`,{count:a.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${a.length} plugin(s)`}}},Zn=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};const Qn={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`,listDirectory:`list_directory`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`,listDirectory:`List`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`,listDirectory:`listDir`}};let $n=function(e){return e.Bash=`bash`,e.Zsh=`zsh`,e.Fish=`fish`,e.Sh=`sh`,e.PowerShell=`powershell`,e.Pwsh=`pwsh`,e.Cmd=`cmd`,e.Unknown=`unknown`,e}({}),er=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var tr=class{userConfig;toolPreset;constructor(e={}){this.userConfig=e.userConfig,this.toolPreset=e.toolPreset??`default`}collect(){return{os:this.collectOsInfo(),env:this.collectEnvContext(),profile:this.collectProfile(),tool:this.collectToolReferences(),Md:this.createMdComponent()}}collectOsInfo(){let e=p.platform();return{platform:e,arch:p.arch(),hostname:p.hostname(),homedir:p.homedir(),tmpdir:p.tmpdir(),type:p.type(),release:p.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return er.Win;case`darwin`:return er.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return er.Linux;default:return er.Unknown}}detectShellKind(){let e=(u.default.env.SHELL??u.default.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?$n.Bash:e.includes(`zsh`)?$n.Zsh:e.includes(`fish`)?$n.Fish:e.includes(`pwsh`)?$n.Pwsh:e.includes(`powershell`)?$n.PowerShell:e.includes(`cmd`)?$n.Cmd:e.endsWith(`/sh`)?$n.Sh:$n.Unknown}collectEnvContext(){return{...u.default.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...Qn.default};return this.toolPreset===`claudeCode`?{...e,...Qn.claudeCode}:this.toolPreset===`kiro`?{...e,...Qn.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let nr=function(e){return e[e.SystemDefault=0]=`SystemDefault`,e[e.UserConfig=10]=`UserConfig`,e[e.PluginRegistered=20]=`PluginRegistered`,e[e.CompileTime=30]=`CompileTime`,e}({});var rr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=nr.PluginRegistered){this.registrations.push({namespace:e,values:t,priority:n})}getRegistrations(){return this.registrations}merge(e){let t={};this.globalScope!=null&&(t.os={...this.globalScope.os},t.env={...this.globalScope.env},t.profile={...this.globalScope.profile},t.tool={...this.globalScope.tool});let n=[...this.registrations].sort((e,t)=>e.priority-t.priority);for(let e of n)t[e.namespace]=this.deepMerge(t[e.namespace],e.values);if(e!=null)for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&!Array.isArray(r)?this.deepMerge(t[n],r):r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?this.deepMerge(n[e],r):r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function ir(e){let t=[...e],n=t[0];n!=null&&ar(n)&&t.shift();let r=t[0];return r!=null&&or(r)&&t.shift(),t}function ar(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replaceAll(`\\`,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function or(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}const sr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`config`,`plugins`]),cr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),lr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function ur(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=lr.get(n)??4;for(let e of t){let t=lr.get(e)??4;t<r&&(r=t,n=e)}return n}function dr(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s,showFlag:c}=e;if(n)return new Dn;if(t)return new An;if(a!=null)return new Zn(a);if(r===`version`)return new Dn;if(r===`help`)return new An;if(r===`outdated`)return new Yn;if(r===`init`)return new Fn;if(r===`dry-run`)return new wn;if(r===`clean`)return i?new Cn:new yt;if(r===`plugins`)return new Xn;if(r===`config`&&c)return new Sn;if(r!==`config`||o.length>0)return new Tn;let l=[];for(let e of s){let t=e.indexOf(`=`);t>0&&l.push([e.slice(0,t),e.slice(t+1)])}return new xn([...o,...l])}function fr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,logLevelFlags:[],setOption:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let n=i.split(`=`),a=n[0]??``,o=cr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--json`:t.jsonFlag=!0;break;case`--show`:t.showFlag=!0;break;case`--set`:if(n.length>1){let e=n.slice(1).join(`=`),r=e.indexOf(`=`);r>0&&t.setOption.push([e.slice(0,r),e.slice(r+1)])}else{let n=e[r+1];if(n!=null){let e=n.indexOf(`=`);e>0&&(t.setOption.push([n.slice(0,e),n.slice(e+1)]),r++)}}break;default:t.unknown.push(i)}continue}if(i.startsWith(`-`)&&i.length>1){let e=i.slice(1);for(let n of e)switch(n){case`h`:t.helpFlag=!0;break;case`v`:t.versionFlag=!0;break;case`n`:t.dryRun=!0;break;case`j`:t.jsonFlag=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,sr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var pr=class{logger;args;outputPlugins=[];constructor(...e){this.args=fr(ir(e.filter(e=>e!=null)));let t=ur(this.args);t!=null&&$t(t),this.logger=tn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){Jn(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand();this.args.jsonFlag&&($t(`silent`),new Set([`config-show`,`plugins`]).has(i.name)||(i=new In(i)));let a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return dr(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:d,path:f,glob:Je.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:d,path:f,glob:Je.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new Dt(n.name,r)}}topologicalSort(e){this.validateDependencies(e);let t=new Map;for(let n of e)t.set(n.name,n);let n=new Map;for(let t of e)n.set(t.name,0);let r=new Map;for(let t of e)r.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let i of e){n.set(t.name,(n.get(t.name)??0)+1);let e=r.get(i)??[];e.push(t.name),r.set(i,e)}}let i=[];for(let t of e)n.get(t.name)===0&&i.push(t.name);let a=[];for(;i.length>0;){let o=i.shift(),s=t.get(o);a.push(s);let c=(r.get(o)??[]).sort((t,n)=>e.findIndex(e=>e.name===t)-e.findIndex(e=>e.name===n));for(let e of c){let t=(n.get(e)??0)-1;n.set(e,t),t===0&&i.push(e)}}if(a.length===e.length)return a;throw new Et(this.findCyclePath(e,n))}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new tr({userConfig:r}).collect(),o=new rr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,nr.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let{workspace:n}=e;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:[...e.values()]}}else ({workspace:n}=t);let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts],f=t.globalGitIgnore??e.globalGitIgnore,p=t.shadowGitExclude??e.shadowGitExclude;return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d},...f==null?{}:{globalGitIgnore:f},...p==null?{}:{shadowGitExclude:p}}}};const mr={...R,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function hr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function gr(...e){return e.reduce((e,t)=>_r(e,t),{...mr})}function _r(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:vr(e.excludePatterns,i),fastCommandSeriesOptions:yr(e.fastCommandSeriesOptions,a)}}function vr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function yr(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.pluginOverrides!=null)for(let[t,r]of Object.entries(e.pluginOverrides))n[t]={...r};if(t.pluginOverrides!=null)for(let[e,r]of Object.entries(t.pluginOverrides))n[e]={...n[e],...r};let r=t.includeSeriesPrefix??e.includeSeriesPrefix,i=Object.keys(n).length>0;return r!=null&&i?{includeSeriesPrefix:r,pluginOverrides:n}:r==null?i?{pluginOverrides:n}:{}:{includeSeriesPrefix:r}}function br(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function xr(e={}){fn().shouldExit&&u.default.exit(1);let t,n,r;br(e)?({pluginOptions:r={},cwd:n}={pluginOptions:e.pluginOptions,cwd:e.cwd},t=e.loadUserConfig??!0):(r=e,t=!0);let i={},a=!1,o=[],s;if(t){let e=dn(n);a=e.found,o=e.sources,e.found&&(i=hr(e.config),s=e.config)}let c=gr(i,r),{plugins:l=[],logLevel:p}=c,m=tn(`defineConfig`,p);a?m.info(`user config loaded`,{sources:o}):m.info(`no user config found, using defaults`,{workspaceDir:mr.workspaceDir,shadowSourceProjectDir:mr.shadowSourceProjectDir,shadowSkillSourceDir:mr.shadowSkillSourceDir,shadowFastCommandDir:mr.shadowFastCommandDir,shadowSubAgentDir:mr.shadowSubAgentDir,globalMemoryFile:mr.globalMemoryFile,shadowProjectsDir:mr.shadowProjectsDir,logLevel:mr.logLevel});let h={logger:m,userConfigOptions:c,fs:d,path:f,glob:Je.default},g=l.filter(e=>e.type===bt.Input),_=l.filter(e=>e.type===bt.Output),v=await new pr().executePluginsInOrder(g,h,!1,s);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}};return v.shadowSourceProjectDir!=null&&jn(v.shadowSourceProjectDir,m),{context:y,outputPlugins:_,userConfigOptions:c}}const Sr=jr(/[A-Za-z]/),Cr=jr(/[\dA-Za-z]/),wr=jr(/[#-'*+\--9=?A-Z^-~]/);function Tr(e){return e!==null&&(e<32||e===127)}const Er=jr(/\d/),Dr=jr(/[\dA-Fa-f]/),Or=jr(/[!-/:-@[-`{-~]/);function B(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const kr=jr(/\p{P}|\p{S}/u),Ar=jr(/\s/);function jr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Mr=l(o(((e,t)=>{(function(){var e=t===void 0?function(){return this||(0,eval)(`this`)}():t.exports=i;e.format=i,e.vsprintf=r,typeof console<`u`&&typeof console.log==`function`&&(e.printf=n);function n(){console.log(i.apply(null,arguments))}function r(e,t){return i.apply(null,[e].concat(t))}function i(e){for(var t=1,n=[].slice.call(arguments),r=0,i=e.length,a=``,o,s=!1,c,l,u=!1,d,f=function(){return n[t++]},p=function(){for(var t=``;/\d/.test(e[r]);)t+=e[r++],o=e[r];return t.length>0?parseInt(t):null};r<i;++r)if(o=e[r],s)switch(s=!1,o==`.`?(u=!1,o=e[++r]):o==`0`&&e[r+1]==`.`?(u=!0,r+=2,o=e[r]):u=!0,d=p(),o){case`b`:a+=parseInt(f(),10).toString(2);break;case`c`:c=f(),typeof c==`string`||c instanceof String?a+=c:a+=String.fromCharCode(parseInt(c,10));break;case`d`:a+=parseInt(f(),10);break;case`f`:l=String(parseFloat(f()).toFixed(d||6)),a+=u?l:l.replace(/^0/,``);break;case`j`:a+=JSON.stringify(f());break;case`o`:a+=`0`+parseInt(f(),10).toString(8);break;case`s`:a+=f();break;case`x`:a+=`0x`+parseInt(f(),10).toString(16);break;case`X`:a+=`0x`+parseInt(f(),10).toString(16).toUpperCase();break;default:a+=o;break}else o===`%`?s=!0:a+=o;return a}})()}))(),1);const Nr=Object.assign(Pr(Error),{eval:Pr(EvalError),range:Pr(RangeError),reference:Pr(ReferenceError),syntax:Pr(SyntaxError),type:Pr(TypeError),uri:Pr(URIError)});function Pr(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Mr.default)(t,...n))}}const Fr={}.hasOwnProperty,Ir={yaml:`-`,toml:`+`};function Lr(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Rr(r[n]);return t}function Rr(e){let t=e;if(typeof t==`string`){if(!Fr.call(Ir,t))throw Nr("Missing matter definition for `%s`",t);t={type:t,marker:Ir[t]}}else if(typeof t!=`object`)throw Nr("Expected matter to be an object, not `%j`",t);if(!Fr.call(t,`type`))throw Nr("Missing `type` in matter `%j`",t);if(!Fr.call(t,`fence`)&&!Fr.call(t,`marker`))throw Nr("Missing `marker` or `fence` in matter `%j`",t);return t}function zr(e){let t=Lr(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Vr(e,`open`).charCodeAt(0),a=Br(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Br(e){let t=e.anywhere,n=e.type,r=n+`Fence`,i=r+`Sequence`,a=n+`Value`,o={tokenize:u,partial:!0},s,c=0;return{tokenize:l,concrete:!0};function l(l,u,d){let f=this;return p;function p(a){let o=f.now();return o.column===1&&(o.line===1||t)&&(s=Vr(e,`open`),c=0,a===s.charCodeAt(c))?(l.enter(n),l.enter(r),l.enter(i),m(a)):d(a)}function m(e){return c===s.length?(l.exit(i),H(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return H(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return B(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Vr(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||B(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||B(e)?(l.exit(a),y(e)):(l.consume(e),v)}function y(e){return e===null?d(e):(l.enter(`lineEnding`),l.consume(e),l.exit(`lineEnding`),l.attempt(o,b,_))}function b(e){return l.exit(n),u(e)}}function u(e,t,n){let a=0;return o;function o(t){return t===s.charCodeAt(a)?(e.enter(r),e.enter(i),c(t)):n(t)}function c(t){return a===s.length?(e.exit(i),H(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return H(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||B(i)?(e.exit(r),t(i)):n(i)}}}function Vr(e,t){return e.marker?Hr(e.marker,t).repeat(3):Hr(e.fence,t)}function Hr(e,t){return typeof e==`string`?e:e[t]}function Ur(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Wr(e){let t=Lr(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Gr(e),r[e.type]=Kr,r[e.type+`Value`]=qr}return{enter:n,exit:r}}function Gr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Kr(e){let t=this.resume(),n=this.stack[this.stack.length-1];`value`in n,this.exit(e),n.value=t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``)}function qr(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Jr(e){let t=[],n={},r=Lr(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Yr(e);let a=Xr(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Ur(a.charAt(1))})}return{unsafe:t,handlers:n}}function Yr(e){let t=Xr(e,`open`),n=Xr(e,`close`);return r;function r(e){return t+(e.value?`
1011
+ `.trim();var An=class{name=`help`;async execute(e){return console.log(kn),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};function jn(e,t){let n=f.join(e,`.git`),r=d.existsSync(n);return r?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:r,gitPath:n}}function Mn(e,t,n,r,i){if(n==null)return r;let a=f.relative(t,e),o=f.join(n,a);return d.existsSync(o)&&d.statSync(o).isFile()?(i?.debug(`copying from source`,{path:o}),d.readFileSync(o,`utf8`)):r}function Nn(e,t={}){let{sourceDir:n,logger:r}=t,i=[],a=[],o=[],s=[],c=new Set;d.existsSync(e)?(o.push(e),r?.debug(`directory exists`,{path:e})):(d.mkdirSync(e,{recursive:!0}),i.push(e),c.add(e),r?.info(`created directory`,{path:e}));for(let t of Object.values(Ht)){let o=t.path,l=f.join(e,o),u=f.dirname(l);if(!d.existsSync(u)){d.mkdirSync(u,{recursive:!0});let t=u;for(;t!==e&&!c.has(t);)c.add(t),i.push(t),r?.info(`created directory`,{path:t}),t=f.dirname(t)}if(d.existsSync(l))s.push(l),r?.debug(`file exists`,{path:l});else{let i=Mn(l,e,n,t.content,r);d.writeFileSync(l,i,`utf8`),a.push(l),r?.info(`created file`,{path:l})}}return{success:!0,rootPath:e,createdDirs:i,createdFiles:a,existedDirs:o,existedFiles:s}}function Pn(e,t,n){let r=e;return r=r.replace(Ut.SHADOW_SOURCE_PROJECT,n),r=r.replace(Ut.WORKSPACE,t),r.startsWith(`~`)&&(r=f.join(p.homedir(),r.slice(1))),f.normalize(r)}var Fn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=Pn(n.workspaceDir,``,``),i=Nn(Pn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}},In=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){let t=await this.inner.execute(e),n=Ln(t);return u.default.stdout.write(`${JSON.stringify(n)}\n`),t}};function Ln(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}function Rn(){return`@truenine/memory-sync-cli`}function zn(){return`https://registry.npmjs.org/${Rn()}/latest`}function Bn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function Vn(e,t){let n=Bn(e),r=Bn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const Hn=3e3;async function Un(){let e=new AbortController,t=setTimeout(()=>e.abort(),Hn);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(zn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${Hn}ms`}:{error:e.message}:{error:`Unknown network error`}}}function Wn(){return`2026.10213.0`}async function Gn(){let e=Wn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await Un();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=Vn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function Kn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${Rn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function qn(){return new Date().getMinutes()%2==0}function Jn(e){qn()&&Gn().then(t=>{(t.status===`outdated`||t.error!=null)&&Kn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var Yn=class{name=`outdated`;async execute(e){let t=await Gn();return Kn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},Xn=class{name=`plugins`;async execute(e){let{logger:t,outputPlugins:n,userConfigOptions:r}=e,i=r.plugins,a=[];for(let e of i)a.push({name:e.name,kind:e.type===bt.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let o=new Set(a.map(e=>e.name));for(let e of n)o.has(e.name)||a.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`plugins listed`,{count:a.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${a.length} plugin(s)`}}},Zn=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};const Qn={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`,listDirectory:`list_directory`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`,listDirectory:`List`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`,listDirectory:`listDir`}};let $n=function(e){return e.Bash=`bash`,e.Zsh=`zsh`,e.Fish=`fish`,e.Sh=`sh`,e.PowerShell=`powershell`,e.Pwsh=`pwsh`,e.Cmd=`cmd`,e.Unknown=`unknown`,e}({}),er=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var tr=class{userConfig;toolPreset;constructor(e={}){this.userConfig=e.userConfig,this.toolPreset=e.toolPreset??`default`}collect(){return{os:this.collectOsInfo(),env:this.collectEnvContext(),profile:this.collectProfile(),tool:this.collectToolReferences(),Md:this.createMdComponent()}}collectOsInfo(){let e=p.platform();return{platform:e,arch:p.arch(),hostname:p.hostname(),homedir:p.homedir(),tmpdir:p.tmpdir(),type:p.type(),release:p.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return er.Win;case`darwin`:return er.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return er.Linux;default:return er.Unknown}}detectShellKind(){let e=(u.default.env.SHELL??u.default.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?$n.Bash:e.includes(`zsh`)?$n.Zsh:e.includes(`fish`)?$n.Fish:e.includes(`pwsh`)?$n.Pwsh:e.includes(`powershell`)?$n.PowerShell:e.includes(`cmd`)?$n.Cmd:e.endsWith(`/sh`)?$n.Sh:$n.Unknown}collectEnvContext(){return{...u.default.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...Qn.default};return this.toolPreset===`claudeCode`?{...e,...Qn.claudeCode}:this.toolPreset===`kiro`?{...e,...Qn.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let nr=function(e){return e[e.SystemDefault=0]=`SystemDefault`,e[e.UserConfig=10]=`UserConfig`,e[e.PluginRegistered=20]=`PluginRegistered`,e[e.CompileTime=30]=`CompileTime`,e}({});var rr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=nr.PluginRegistered){this.registrations.push({namespace:e,values:t,priority:n})}getRegistrations(){return this.registrations}merge(e){let t={};this.globalScope!=null&&(t.os={...this.globalScope.os},t.env={...this.globalScope.env},t.profile={...this.globalScope.profile},t.tool={...this.globalScope.tool});let n=[...this.registrations].sort((e,t)=>e.priority-t.priority);for(let e of n)t[e.namespace]=this.deepMerge(t[e.namespace],e.values);if(e!=null)for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&!Array.isArray(r)?this.deepMerge(t[n],r):r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?this.deepMerge(n[e],r):r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function ir(e){let t=[...e],n=t[0];n!=null&&ar(n)&&t.shift();let r=t[0];return r!=null&&or(r)&&t.shift(),t}function ar(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replaceAll(`\\`,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function or(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}const sr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`config`,`plugins`]),cr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),lr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function ur(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=lr.get(n)??4;for(let e of t){let t=lr.get(e)??4;t<r&&(r=t,n=e)}return n}function dr(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s,showFlag:c}=e;if(n)return new On;if(t)return new An;if(a!=null)return new Zn(a);if(r===`version`)return new On;if(r===`help`)return new An;if(r===`outdated`)return new Yn;if(r===`init`)return new Fn;if(r===`dry-run`)return new Tn;if(r===`clean`)return i?new wn:new yt;if(r===`plugins`)return new Xn;if(r===`config`&&c)return new Cn;if(r!==`config`||o.length>0)return new En;let l=[];for(let e of s){let t=e.indexOf(`=`);t>0&&l.push([e.slice(0,t),e.slice(t+1)])}return new Sn([...o,...l])}function fr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,logLevelFlags:[],setOption:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let n=i.split(`=`),a=n[0]??``,o=cr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--json`:t.jsonFlag=!0;break;case`--show`:t.showFlag=!0;break;case`--set`:if(n.length>1){let e=n.slice(1).join(`=`),r=e.indexOf(`=`);r>0&&t.setOption.push([e.slice(0,r),e.slice(r+1)])}else{let n=e[r+1];if(n!=null){let e=n.indexOf(`=`);e>0&&(t.setOption.push([n.slice(0,e),n.slice(e+1)]),r++)}}break;default:t.unknown.push(i)}continue}if(i.startsWith(`-`)&&i.length>1){let e=i.slice(1);for(let n of e)switch(n){case`h`:t.helpFlag=!0;break;case`v`:t.versionFlag=!0;break;case`n`:t.dryRun=!0;break;case`j`:t.jsonFlag=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,sr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var pr=class{logger;args;outputPlugins=[];constructor(...e){this.args=fr(ir(e.filter(e=>e!=null)));let t=ur(this.args);t!=null&&en(t),this.logger=nn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){Jn(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand();this.args.jsonFlag&&(en(`silent`),new Set([`config-show`,`plugins`]).has(i.name)||(i=new In(i)));let a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return dr(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:d,path:f,glob:Je.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:d,path:f,glob:Je.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new Dt(n.name,r)}}topologicalSort(e){this.validateDependencies(e);let t=new Map;for(let n of e)t.set(n.name,n);let n=new Map;for(let t of e)n.set(t.name,0);let r=new Map;for(let t of e)r.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let i of e){n.set(t.name,(n.get(t.name)??0)+1);let e=r.get(i)??[];e.push(t.name),r.set(i,e)}}let i=[];for(let t of e)n.get(t.name)===0&&i.push(t.name);let a=[];for(;i.length>0;){let o=i.shift(),s=t.get(o);a.push(s);let c=(r.get(o)??[]).sort((t,n)=>e.findIndex(e=>e.name===t)-e.findIndex(e=>e.name===n));for(let e of c){let t=(n.get(e)??0)-1;n.set(e,t),t===0&&i.push(e)}}if(a.length===e.length)return a;throw new Et(this.findCyclePath(e,n))}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new tr({userConfig:r}).collect(),o=new rr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,nr.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let{workspace:n}=e;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:[...e.values()]}}else ({workspace:n}=t);let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts],f=t.globalGitIgnore??e.globalGitIgnore,p=t.shadowGitExclude??e.shadowGitExclude;return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d},...f==null?{}:{globalGitIgnore:f},...p==null?{}:{shadowGitExclude:p}}}};const mr={...R,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function hr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function gr(...e){return e.reduce((e,t)=>_r(e,t),{...mr})}function _r(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:vr(e.excludePatterns,i),fastCommandSeriesOptions:yr(e.fastCommandSeriesOptions,a)}}function vr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function yr(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.pluginOverrides!=null)for(let[t,r]of Object.entries(e.pluginOverrides))n[t]={...r};if(t.pluginOverrides!=null)for(let[e,r]of Object.entries(t.pluginOverrides))n[e]={...n[e],...r};let r=t.includeSeriesPrefix??e.includeSeriesPrefix,i=Object.keys(n).length>0;return r!=null&&i?{includeSeriesPrefix:r,pluginOverrides:n}:r==null?i?{pluginOverrides:n}:{}:{includeSeriesPrefix:r}}function br(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function xr(e={}){pn().shouldExit&&u.default.exit(1);let t,n,r;br(e)?({pluginOptions:r={},cwd:n}={pluginOptions:e.pluginOptions,cwd:e.cwd},t=e.loadUserConfig??!0):(r=e,t=!0);let i={},a=!1,o=[],s;if(t){let e=fn(n);a=e.found,o=e.sources,e.found&&(i=hr(e.config),s=e.config)}let c=gr(i,r),{plugins:l=[],logLevel:p}=c,m=nn(`defineConfig`,p);a?m.info(`user config loaded`,{sources:o}):m.info(`no user config found, using defaults`,{workspaceDir:mr.workspaceDir,shadowSourceProjectDir:mr.shadowSourceProjectDir,shadowSkillSourceDir:mr.shadowSkillSourceDir,shadowFastCommandDir:mr.shadowFastCommandDir,shadowSubAgentDir:mr.shadowSubAgentDir,globalMemoryFile:mr.globalMemoryFile,shadowProjectsDir:mr.shadowProjectsDir,logLevel:mr.logLevel});let h={logger:m,userConfigOptions:c,fs:d,path:f,glob:Je.default},g=l.filter(e=>e.type===bt.Input),_=l.filter(e=>e.type===bt.Output),v=await new pr().executePluginsInOrder(g,h,!1,s);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}};return v.shadowSourceProjectDir!=null&&jn(v.shadowSourceProjectDir,m),{context:y,outputPlugins:_,userConfigOptions:c}}const Sr=jr(/[A-Za-z]/),Cr=jr(/[\dA-Za-z]/),wr=jr(/[#-'*+\--9=?A-Z^-~]/);function Tr(e){return e!==null&&(e<32||e===127)}const Er=jr(/\d/),Dr=jr(/[\dA-Fa-f]/),Or=jr(/[!-/:-@[-`{-~]/);function B(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const kr=jr(/\p{P}|\p{S}/u),Ar=jr(/\s/);function jr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Mr=l(o(((e,t)=>{(function(){var e=t===void 0?function(){return this||(0,eval)(`this`)}():t.exports=i;e.format=i,e.vsprintf=r,typeof console<`u`&&typeof console.log==`function`&&(e.printf=n);function n(){console.log(i.apply(null,arguments))}function r(e,t){return i.apply(null,[e].concat(t))}function i(e){for(var t=1,n=[].slice.call(arguments),r=0,i=e.length,a=``,o,s=!1,c,l,u=!1,d,f=function(){return n[t++]},p=function(){for(var t=``;/\d/.test(e[r]);)t+=e[r++],o=e[r];return t.length>0?parseInt(t):null};r<i;++r)if(o=e[r],s)switch(s=!1,o==`.`?(u=!1,o=e[++r]):o==`0`&&e[r+1]==`.`?(u=!0,r+=2,o=e[r]):u=!0,d=p(),o){case`b`:a+=parseInt(f(),10).toString(2);break;case`c`:c=f(),typeof c==`string`||c instanceof String?a+=c:a+=String.fromCharCode(parseInt(c,10));break;case`d`:a+=parseInt(f(),10);break;case`f`:l=String(parseFloat(f()).toFixed(d||6)),a+=u?l:l.replace(/^0/,``);break;case`j`:a+=JSON.stringify(f());break;case`o`:a+=`0`+parseInt(f(),10).toString(8);break;case`s`:a+=f();break;case`x`:a+=`0x`+parseInt(f(),10).toString(16);break;case`X`:a+=`0x`+parseInt(f(),10).toString(16).toUpperCase();break;default:a+=o;break}else o===`%`?s=!0:a+=o;return a}})()}))(),1);const Nr=Object.assign(Pr(Error),{eval:Pr(EvalError),range:Pr(RangeError),reference:Pr(ReferenceError),syntax:Pr(SyntaxError),type:Pr(TypeError),uri:Pr(URIError)});function Pr(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Mr.default)(t,...n))}}const Fr={}.hasOwnProperty,Ir={yaml:`-`,toml:`+`};function Lr(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Rr(r[n]);return t}function Rr(e){let t=e;if(typeof t==`string`){if(!Fr.call(Ir,t))throw Nr("Missing matter definition for `%s`",t);t={type:t,marker:Ir[t]}}else if(typeof t!=`object`)throw Nr("Expected matter to be an object, not `%j`",t);if(!Fr.call(t,`type`))throw Nr("Missing `type` in matter `%j`",t);if(!Fr.call(t,`fence`)&&!Fr.call(t,`marker`))throw Nr("Missing `marker` or `fence` in matter `%j`",t);return t}function zr(e){let t=Lr(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Vr(e,`open`).charCodeAt(0),a=Br(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Br(e){let t=e.anywhere,n=e.type,r=n+`Fence`,i=r+`Sequence`,a=n+`Value`,o={tokenize:u,partial:!0},s,c=0;return{tokenize:l,concrete:!0};function l(l,u,d){let f=this;return p;function p(a){let o=f.now();return o.column===1&&(o.line===1||t)&&(s=Vr(e,`open`),c=0,a===s.charCodeAt(c))?(l.enter(n),l.enter(r),l.enter(i),m(a)):d(a)}function m(e){return c===s.length?(l.exit(i),H(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return H(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return B(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Vr(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||B(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||B(e)?(l.exit(a),y(e)):(l.consume(e),v)}function y(e){return e===null?d(e):(l.enter(`lineEnding`),l.consume(e),l.exit(`lineEnding`),l.attempt(o,b,_))}function b(e){return l.exit(n),u(e)}}function u(e,t,n){let a=0;return o;function o(t){return t===s.charCodeAt(a)?(e.enter(r),e.enter(i),c(t)):n(t)}function c(t){return a===s.length?(e.exit(i),H(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return H(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||B(i)?(e.exit(r),t(i)):n(i)}}}function Vr(e,t){return e.marker?Hr(e.marker,t).repeat(3):Hr(e.fence,t)}function Hr(e,t){return typeof e==`string`?e:e[t]}function Ur(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Wr(e){let t=Lr(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Gr(e),r[e.type]=Kr,r[e.type+`Value`]=qr}return{enter:n,exit:r}}function Gr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Kr(e){let t=this.resume(),n=this.stack[this.stack.length-1];`value`in n,this.exit(e),n.value=t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``)}function qr(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Jr(e){let t=[],n={},r=Lr(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Yr(e);let a=Xr(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Ur(a.charAt(1))})}return{unsafe:t,handlers:n}}function Yr(e){let t=Xr(e,`open`),n=Xr(e,`close`);return r;function r(e){return t+(e.value?`
687
1012
  `+e.value:``)+`
688
1013
  `+n}}function Xr(e,t){return e.marker?Zr(e.marker,t).repeat(3):Zr(e.fence,t)}function Zr(e,t){return typeof e==`string`?e:e[t]}function Qr(e){let t=this,n=e||`yaml`,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(zr(n)),a.push(Wr(n)),o.push(Jr(n))}function $r(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const ei=(function(e){if(e==null)return ai;if(typeof e==`function`)return ii(e);if(typeof e==`object`)return Array.isArray(e)?ti(e):ni(e);if(typeof e==`string`)return ri(e);throw Error(`Expected function, string, or object as test`)});function ti(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ei(e[n]);return ii(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ni(e){let t=e;return ii(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ri(e){return ii(t);function t(t){return t&&t.type===e}}function ii(e){return t;function t(t,n,r){return!!(oi(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function ai(){return!0}function oi(e){return typeof e==`object`&&!!e&&`type`in e}function si(e){return`\x1B[33m`+e+`\x1B[39m`}const ci=[];function li(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ei(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+si(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=ci,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=ui(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function ui(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?ci:[e]}function di(e,t,n){let r=ei((n||{}).ignore||[]),i=fi(t),a=-1;for(;++a<i.length;)li(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function fi(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([pi(e[0]),mi(e[1])])}return t}function pi(e){return typeof e==`string`?new RegExp(Ur(e),`g`):e}function mi(e){return typeof e==`function`?e:function(){return e}}const hi=`phrasing`,gi=[`autolink`,`link`,`image`,`label`];function _i(){return{transforms:[Ti],enter:{literalAutolink:yi,literalAutolinkEmail:bi,literalAutolinkHttp:bi,literalAutolinkWww:bi},exit:{literalAutolink:wi,literalAutolinkEmail:Ci,literalAutolinkHttp:xi,literalAutolinkWww:Si}}}function vi(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:hi,notInConstruct:gi},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:hi,notInConstruct:gi},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:hi,notInConstruct:gi}]}}function yi(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function bi(e){this.config.enter.autolinkProtocol.call(this,e)}function xi(e){this.config.exit.autolinkProtocol.call(this,e)}function Si(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Ci(e){this.config.exit.autolinkEmail.call(this,e)}function wi(e){this.exit(e)}function Ti(e){di(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ei],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Di]],{ignore:[`link`,`linkReference`]})}function Ei(e,t,n,r,i){let a=``;if(!Ai(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Oi(n)))return!1;let o=ki(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Di(e,t,n,r){return!Ai(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Oi(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ki(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=$r(e,`(`),a=$r(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Ai(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Ar(n)||kr(n))&&(!t||n!==47)}function ji(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}Vi.peek=Bi;function Mi(){this.buffer()}function Ni(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Pi(){this.buffer()}function Fi(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ii(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Li(e){this.exit(e)}function Ri(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ji(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zi(e){this.exit(e)}function Bi(){return`[`}function Vi(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Hi(){return{enter:{gfmFootnoteCallString:Mi,gfmFootnoteCall:Ni,gfmFootnoteDefinitionLabelString:Pi,gfmFootnoteDefinition:Fi},exit:{gfmFootnoteCallString:Ii,gfmFootnoteCall:Li,gfmFootnoteDefinitionLabelString:Ri,gfmFootnoteDefinition:zi}}}function Ui(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Vi},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
689
1014
  `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Gi:Wi))),s(),o}}function Wi(e,t,n){return t===0?e:Gi(e,t,n)}function Gi(e,t,n){return(n?``:` `)+e}const Ki=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Zi.peek=Qi;function qi(){return{canContainEols:[`delete`],enter:{strikethrough:Yi},exit:{strikethrough:Xi}}}function Ji(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Ki}],handlers:{delete:Zi}}}function Yi(e){this.enter({type:`delete`,children:[]},e)}function Xi(e){this.exit(e)}function Zi(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Qi(){return`~`}function $i(e){return e.length}function ea(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||$i,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ta(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=na(r[d]);else{let e=na(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
@@ -741,11 +1066,11 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
741
1066
  Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??=t.ecmaVersion<5,(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),ne(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}return ne(t.onComment)&&(t.onComment=fe(t,t.onComment)),t}function fe(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new se(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var pe=1,me=2,he=4,ge=8,_e=16,ve=32,ye=64,be=128,xe=256,Se=512,Ce=pe|me|xe;function we(e,t){return me|(e?he:0)|(t?ge:0)}var Te=0,Ee=1,De=2,Oe=3,ke=4,A=5,j=function(e,t,n){this.options=e=de(e),this.sourceFile=e.sourceFile,this.keywords=k(s[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=a[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=k(r);var i=(r?r+` `:``)+a.strict;this.reservedWordsStrict=k(i),this.reservedWordsStrictBind=k(i+` `+a.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf(`
742
1067
  `,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(x).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=b.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(pe),this.regexpState=null,this.privateNameStack=[]},Ae={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};j.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},Ae.inFunction.get=function(){return(this.currentVarScope().flags&me)>0},Ae.inGenerator.get=function(){return(this.currentVarScope().flags&ge)>0},Ae.inAsync.get=function(){return(this.currentVarScope().flags&he)>0},Ae.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(xe|Se))return!1;if(t&me)return(t&he)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ae.allowSuper.get=function(){return(this.currentThisScope().flags&ye)>0||this.options.allowSuperOutsideMethod},Ae.allowDirectSuper.get=function(){return(this.currentThisScope().flags&be)>0},Ae.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ae.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(xe|Se)||t&me&&!(t&_e))return!0}return!1},Ae.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&xe)>0},j.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},j.parse=function(e,t){return new this(t,e).parse()},j.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},j.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(j.prototype,Ae);var M=j.prototype,je=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;M.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){E.lastIndex=e,e+=E.exec(this.input)[0].length;var t=je.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){E.lastIndex=e+t[0].length;var n=E.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||x.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,E.lastIndex=e,e+=E.exec(this.input)[0].length,this.input[e]===`;`&&e++}},M.eat=function(e){return this.type===e?(this.next(),!0):!1},M.isContextual=function(e){return this.type===b.name&&this.value===e&&!this.containsEsc},M.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},M.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},M.canInsertSemicolon=function(){return this.type===b.eof||this.type===b.braceR||x.test(this.input.slice(this.lastTokEnd,this.start))},M.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},M.semicolon=function(){!this.eat(b.semi)&&!this.insertSemicolon()&&this.unexpected()},M.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},M.expect=function(e){this.eat(e)||this.unexpected()},M.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Me=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};M.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},M.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},M.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},M.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var N=j.prototype;N.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==b.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,`Program`)};var Ne={kind:`loop`},Pe={kind:`switch`};N.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;E.lastIndex=this.pos;var t=E.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(f(r,!0)){for(var i=n+1;p(r=this.input.charCodeAt(i),!0);)++i;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,i);if(!c.test(a))return!0}return!1},N.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;E.lastIndex=this.pos;var e=E.exec(this.input),t=this.pos+e[0].length,n;return!x.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(p(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))},N.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;E.lastIndex=this.pos;var n=E.exec(this.input),r=this.pos+n[0].length;if(x.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||p(a=this.input.charCodeAt(i))||a>55295&&a<56320)return!1;E.lastIndex=i;var o=E.exec(this.input);if(o&&x.test(this.input.slice(i,i+o[0].length)))return!1}if(t){var s=r+2,c;if(this.input.slice(r,s)===`of`&&(s===this.input.length||!p(c=this.input.charCodeAt(s))&&!(c>55295&&c<56320)))return!1}var l=this.input.charCodeAt(r);return f(l,!0)||l===92},N.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},N.isUsing=function(e){return this.isUsingKeyword(!1,e)},N.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=b._var,a=`let`),r){case b._break:case b._continue:return this.parseBreakContinueStatement(i,r.keyword);case b._debugger:return this.parseDebuggerStatement(i);case b._do:return this.parseDoStatement(i);case b._for:return this.parseForStatement(i);case b._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case b._class:return e&&this.unexpected(),this.parseClass(i,!0);case b._if:return this.parseIfStatement(i);case b._return:return this.parseReturnStatement(i);case b._switch:return this.parseSwitchStatement(i);case b._throw:return this.parseThrowStatement(i);case b._try:return this.parseTryStatement(i);case b._const:case b._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case b._while:return this.parseWhileStatement(i);case b._with:return this.parseWithStatement(i);case b.braceL:return this.parseBlock(!0,i);case b.semi:return this.parseEmptyStatement(i);case b._export:case b._import:if(this.options.ecmaVersion>10&&r===b._import){E.lastIndex=this.pos;var o=E.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===b._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return t&&this.options.sourceType===`script`&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===b.name&&d.type===`Identifier`&&this.eat(b.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},N.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(b.semi)||this.insertSemicolon()?e.label=null:this.type===b.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},N.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},N.parseDoStatement=function(e){return this.next(),this.labels.push(Ne),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(b._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(b.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},N.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ne),this.enterScope(0),this.expect(b.parenL),this.type===b.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===b._var||this.type===b._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&this.next(),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Me,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===b._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===b._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},N.parseForAfterInit=function(e,t,n){return(this.type===b._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===b._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},N.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ie|(n?0:Le),!1,t)},N.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(b._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},N.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,`'return' outside of function`),this.next(),this.eat(b.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},N.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(b.braceL),this.labels.push(Pe),this.enterScope(0);for(var t,n=!1;this.type!==b.braceR;)if(this.type===b._case||this.type===b._default){var r=this.type===b._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(b.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},N.parseThrowStatement=function(e){return this.next(),x.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Fe=[];N.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?ve:0),this.checkLValPattern(e,t?ke:De),this.expect(b.parenR),e},N.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===b._catch){var t=this.startNode();this.next(),this.eat(b.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(b._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},N.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},N.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ne),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},N.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},N.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},N.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===b._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},N.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},N.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(b.braceL),e&&this.enterScope(0);this.type!==b.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},N.parseFor=function(e,t){return e.init=t,this.expect(b.semi),e.test=this.type===b.semi?null:this.parseExpression(),this.expect(b.semi),e.update=this.type===b.parenR?null:this.parseExpression(),this.expect(b.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},N.parseForIn=function(e,t){var n=this.type===b._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(b.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},N.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(b.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===b._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==b._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===b._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(b.comma))break}return e},N.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Ee:De,!1)};var Ie=1,Le=2,Re=4;N.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===b.star&&t&Le&&this.unexpected(),e.generator=this.eat(b.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ie&&(e.id=t&Re&&this.type!==b.name?null:this.parseIdent(),e.id&&!(t&Le)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ee:De:Oe));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(we(e.async,e.generator)),t&Ie||(e.id=this.type===b.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ie?`FunctionDeclaration`:`FunctionExpression`)},N.parseFunctionParams=function(e){this.expect(b.parenL),e.params=this.parseBindingList(b.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},N.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(b.braceL);this.type!==b.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&ze(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},N.parseClassElement=function(e){if(this.eat(b.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(b.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===b.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===b.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(b.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===b.parenL||o!==`method`||i||a){var l=!n.static&&Be(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},N.isClassElementNameStart=function(){return this.type===b.name||this.type===b.privateId||this.type===b.num||this.type===b.string||this.type===b.bracketL||this.type.keyword},N.parseClassElementName=function(e){this.type===b.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},N.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Be(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},N.parseClassField=function(e){return Be(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Be(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(b.eq)?(this.enterScope(Se|ye),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},N.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(xe|ye);this.type!==b.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},N.parseClassId=function(e,t){this.type===b.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,De,!1)):(t===!0&&this.unexpected(),e.id=null)},N.parseClassSuper=function(e){e.superClass=this.eat(b._extends)?this.parseExprSubscripts(null,!1):null},N.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},N.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];O(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function ze(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Be(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}N.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==b.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},N.parseExport=function(e,t){if(this.next(),this.eat(b.star))return this.parseExportAllDeclaration(e,t);if(this.eat(b._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==b.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},N.parseExportDeclaration=function(e){return this.parseStatement(null)},N.parseExportDefaultDeclaration=function(){var e;if(this.type===b._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ie|Re,!1,e)}else if(this.type===b._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},N.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),O(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},N.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},N.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},N.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},N.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},N.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(b.braceL);!this.eat(b.braceR);){if(n)n=!1;else if(this.expect(b.comma),this.afterTrailingComma(b.braceR))break;t.push(this.parseExportSpecifier(e))}return t},N.parseImport=function(e){return this.next(),this.type===b.string?(e.specifiers=Fe,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===b.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},N.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,De),this.finishNode(e,`ImportSpecifier`)},N.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,De),this.finishNode(e,`ImportDefaultSpecifier`)},N.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,De),this.finishNode(e,`ImportNamespaceSpecifier`)},N.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===b.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(b.comma)))return e;if(this.type===b.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(b.braceL);!this.eat(b.braceR);){if(t)t=!1;else if(this.expect(b.comma),this.afterTrailingComma(b.braceR))break;e.push(this.parseImportSpecifier())}return e},N.parseWithClause=function(){var e=[];if(!this.eat(b._with))return e;this.expect(b.braceL);for(var t={},n=!0;!this.eat(b.braceR);){if(n)n=!1;else if(this.expect(b.comma),this.afterTrailingComma(b.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;O(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},N.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===b.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(b.colon),this.type!==b.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},N.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===b.string){var e=this.parseLiteral(this.value);return ae.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},N.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},N.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`"`||this.input[e.start]===`'`)};var Ve=j.prototype;Ve.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},Ve.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},Ve.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Ve.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==b.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Ve.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case b.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(b.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case b.braceL:return this.parseObj(!0)}return this.parseIdent()},Ve.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(b.comma),t&&this.type===b.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===b.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===b.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Ve.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Ve.parseBindingListItem=function(e){return e},Ve.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(b.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Ve.checkLValSimple=function(e,t,n){t===void 0&&(t=Te);var r=t!==Te;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===De&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(O(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==A&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},Ve.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Te),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Ve.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Te),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var He=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},P={b_stat:new He(`{`,!1),b_expr:new He(`{`,!0),b_tmpl:new He("${",!1),p_stat:new He(`(`,!1),p_expr:new He(`(`,!0),q_tmpl:new He("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new He(`function`,!1),f_expr:new He(`function`,!0),f_expr_gen:new He(`function`,!0,!1,null,!0),f_gen:new He(`function`,!1,!1,null,!0)},Ue=j.prototype;Ue.initialContext=function(){return[P.b_stat]},Ue.curContext=function(){return this.context[this.context.length-1]},Ue.braceIsBlock=function(e){var t=this.curContext();return t===P.f_expr||t===P.f_stat?!0:e===b.colon&&(t===P.b_stat||t===P.b_expr)?!t.isExpr:e===b._return||e===b.name&&this.exprAllowed?x.test(this.input.slice(this.lastTokEnd,this.start)):e===b._else||e===b.semi||e===b.eof||e===b.parenR||e===b.arrow?!0:e===b.braceL?t===P.b_stat:e===b._var||e===b._const||e===b.name?!1:!this.exprAllowed},Ue.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},Ue.updateContext=function(e){var t,n=this.type;n.keyword&&e===b.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Ue.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},b.parenR.updateContext=b.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===P.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},b.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?P.b_stat:P.b_expr),this.exprAllowed=!0},b.dollarBraceL.updateContext=function(){this.context.push(P.b_tmpl),this.exprAllowed=!0},b.parenL.updateContext=function(e){var t=e===b._if||e===b._for||e===b._with||e===b._while;this.context.push(t?P.p_stat:P.p_expr),this.exprAllowed=!0},b.incDec.updateContext=function(){},b._function.updateContext=b._class.updateContext=function(e){e.beforeExpr&&e!==b._else&&!(e===b.semi&&this.curContext()!==P.p_stat)&&!(e===b._return&&x.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===b.colon||e===b.braceL)&&this.curContext()===P.b_stat)?this.context.push(P.f_expr):this.context.push(P.f_stat),this.exprAllowed=!1},b.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},b.backQuote.updateContext=function(){this.curContext()===P.q_tmpl?this.context.pop():this.context.push(P.q_tmpl),this.exprAllowed=!1},b.star.updateContext=function(e){if(e===b._function){var t=this.context.length-1;this.context[t]===P.f_expr?this.context[t]=P.f_expr_gen:this.context[t]=P.f_gen}this.exprAllowed=!0},b.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==b.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var F=j.prototype;F.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},F.parseExpression=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===b.comma){var a=this.startNodeAt(n,r);for(a.expressions=[i];this.eat(b.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,`SequenceExpression`)}return i},F.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Me,r=!0);var s=this.start,c=this.startLoc;(this.type===b.parenL||this.type===b.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===b.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===b.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},F.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(b.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(b.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},F.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},F.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==b._in)&&a>r){var o=this.type===b.logicalOR||this.type===b.logicalAND,s=this.type===b.coalesce;s&&(a=b.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===b.coalesce||s&&(this.type===b.logicalOR||this.type===b.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},F.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},F.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===b.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&We(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Ge(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===b.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==b._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&this.eat(b.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function We(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&We(e.expression)}function Ge(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Ge(e.expression)||e.type===`ParenthesizedExpression`&&Ge(e.expression)}F.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return i;var a=this.parseSubscripts(i,n,r,!1,t);return e&&a.type===`MemberExpression`&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a},F.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s===e||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s}},F.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(b.arrow)},F.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},F.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(b.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(b.bracketL);if(l||c&&this.type!==b.parenL&&this.type!==b.backQuote||this.eat(b.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(b.bracketR)):this.type===b.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(b.parenL)){var d=new Me,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(b.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===b.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},F.parseExprAtom=function(e,t,n){this.type===b.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case b._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===b.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==b.dot&&this.type!==b.bracketL&&this.type!==b.parenL&&this.unexpected(),this.finishNode(r,`Super`);case b._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case b.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(b._function))return this.overrideContext(P.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(b.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===b.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(b.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case b.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case b.num:case b.string:return this.parseLiteral(this.value);case b._null:case b._true:case b._false:return r=this.startNode(),r.value=this.type===b._null?null:this.type===b._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case b.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case b.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(b.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case b.braceL:return this.overrideContext(P.b_expr),this.parseObj(!1,e);case b._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case b._class:return this.parseClass(this.startNode(),!1);case b._new:return this.parseNew();case b.backQuote:return this.parseTemplate();case b._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},F.parseExprAtomDefault=function(){this.unexpected()},F.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===b.parenL&&!e)return this.parseDynamicImport(t);if(this.type===b.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},F.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(b.parenR)?e.options=null:(this.expect(b.comma),this.afterTrailingComma(b.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(b.parenR)||(this.expect(b.comma),this.afterTrailingComma(b.parenR)||this.unexpected())));else if(!this.eat(b.parenR)){var t=this.start;this.eat(b.comma)&&this.eat(b.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},F.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},F.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},F.parseParenExpression=function(){this.expect(b.parenL);var e=this.parseExpression();return this.expect(b.parenR),e},F.shouldParseArrow=function(e){return!this.canInsertSemicolon()},F.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Me,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==b.parenR;)if(l?l=!1:this.expect(b.comma),a&&this.afterTrailingComma(b.parenR,!0)){u=!0;break}else if(this.type===b.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===b.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(b.parenR),e&&this.shouldParseArrow(c)&&this.eat(b.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},F.parseParenItem=function(e){return e},F.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Ke=[];F.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===b.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),this.eat(b.parenL)?e.arguments=this.parseExprList(b.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ke,this.finishNode(e,`NewExpression`)},F.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===b.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
743
1068
  `),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
744
- `),cooked:this.value},this.next(),n.tail=this.type===b.backQuote,this.finishNode(n,`TemplateElement`)},F.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===b.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(b.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(b.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},F.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===b.name||this.type===b.num||this.type===b.string||this.type===b.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===b.star)&&!x.test(this.input.slice(this.lastTokEnd,this.start))},F.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(b.braceR);){if(r)r=!1;else if(this.expect(b.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(b.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},F.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(b.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===b.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===b.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(b.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(b.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},F.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},F.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===b.colon&&this.unexpected(),this.eat(b.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===b.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==b.comma&&this.type!==b.braceR&&this.type!==b.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===b.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},F.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(b.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(b.bracketR),e.key;e.computed=!1}return e.key=this.type===b.num||this.type===b.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},F.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},F.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(we(t,r.generator)|ye|(n?be:0)),this.expect(b.parenL),r.params=this.parseBindingList(b.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},F.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(we(n,!1)|_e),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},F.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==b.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,A),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},F.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},F.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Ee,t?null:n)}},F.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(b.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===b.comma?o=null:this.type===b.ellipsis?(o=this.parseSpread(r),r&&this.type===b.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},F.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&Ce)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},F.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},F.parseIdentNode=function(){var e=this.startNode();return this.type===b.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=b.name):this.unexpected(),e},F.parsePrivateIdent=function(){var e=this.startNode();return this.type===b.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},F.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===b.semi||this.canInsertSemicolon()||this.type!==b.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(b.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},F.parseAwait=function(e){this.awaitPos||=this.start;var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var qe=j.prototype;qe.raise=function(e,t){var n=ce(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},qe.raiseRecoverable=qe.raise,qe.curPosition=function(){if(this.options.locations)return new oe(this.curLine,this.pos-this.lineStart)};var Je=j.prototype,Ye=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Je.enterScope=function(e){this.scopeStack.push(new Ye(e))},Je.exitScope=function(){this.scopeStack.pop()},Je.treatFunctionsAsVarInScope=function(e){return e.flags&me||!this.inModule&&e.flags&pe},Je.declareName=function(e,t,n){var r=!1;if(t===De){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&pe&&delete this.undefinedExports[e]}else if(t===ke)this.currentScope().lexical.push(e);else if(t===Oe){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&ve&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&pe&&delete this.undefinedExports[e],s.flags&Ce)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Je.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Je.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Je.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ce|Se|xe))return t}},Je.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ce|Se|xe)&&!(t.flags&_e))return t}};var Xe=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new se(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ze=j.prototype;Ze.startNode=function(){return new Xe(this,this.start,this.startLoc)},Ze.startNodeAt=function(e,t){return new Xe(this,e,t)};function Qe(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ze.finishNode=function(e,t){return Qe.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ze.finishNodeAt=function(e,t,n,r){return Qe.call(this,e,t,n,r)},Ze.copyNode=function(e){var t=new Xe(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var $e=`Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz`,et=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,tt=et+` Extended_Pictographic`,nt=tt,rt=nt+` EBase EComp EMod EPres ExtPict`,it=rt,at=it,ot={9:et,10:tt,11:nt,12:rt,13:it,14:at},st=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,ct={9:``,10:``,11:``,12:``,13:``,14:st},lt=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,ut=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,dt=ut+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,ft=dt+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,pt=ft+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,mt=pt+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,ht=mt+` `+$e,gt={9:ut,10:dt,11:ft,12:pt,13:mt,14:ht},_t={};function vt(e){var t=_t[e]={binary:k(ot[e]+` `+lt),binaryOfStrings:k(ct[e]),nonBinary:{General_Category:k(lt),Script:k(gt[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var yt=0,bt=[9,10,11,12,13,14];yt<bt.length;yt+=1){var xt=bt[yt];vt(xt)}var I=j.prototype,St=function(e,t){this.parent=e,this.base=t||this};St.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},St.prototype.sibling=function(){return new St(this.parent,this.base)};var Ct=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=_t[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Ct.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ct.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ct.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},Ct.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},Ct.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ct.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ct.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ct.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},Ct.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},I.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function wt(e){for(var t in e)return!0;return!1}I.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&wt(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},I.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},I.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new St(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},I.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},I.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},I.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},I.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},I.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},I.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},I.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},I.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},I.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},I.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},I.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&L(n);)t+=ie(n),e.advance();return t};function L(e){return e===105||e===109||e===115}I.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},I.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},I.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Tt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Tt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}I.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Tt(n);)e.advance();return e.pos!==t},I.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},I.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},I.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},I.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=ie(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ie(e.lastIntValue);return!0}return!1},I.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Et(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Et(e){return f(e,!0)||e===36||e===95}I.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Dt(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Dt(e){return p(e,!0)||e===36||e===95||e===8204||e===8205}I.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},I.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},I.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},I.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},I.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},I.regexp_eatZero=function(e){return e.current()===48&&!zt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},I.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},I.regexp_eatControlLetter=function(e){var t=e.current();return Ot(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ot(e){return e>=65&&e<=90||e>=97&&e<=122}I.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&kt(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function kt(e){return e>=0&&e<=1114111}I.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},I.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var At=0,jt=1,Mt=2;I.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Nt(t))return e.lastIntValue=-1,e.advance(),jt;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Mt&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return At};function Nt(e){return e===100||e===68||e===115||e===83||e===119||e===87}I.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),jt}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return At},I.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){O(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},I.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return jt;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Mt;e.raise(`Invalid property name`)},I.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Pt(t=e.current());)e.lastStringValue+=ie(t),e.advance();return e.lastStringValue!==``};function Pt(e){return Ot(e)||e===95}I.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ft(t=e.current());)e.lastStringValue+=ie(t),e.advance();return e.lastStringValue!==``};function Ft(e){return Pt(e)||zt(e)}I.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},I.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Mt&&e.raise(`Negated character class may contain strings`),!0}return!1},I.regexp_classContents=function(e){return e.current()===93?jt:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),jt)},I.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},I.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ht(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},I.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},I.regexp_classSetExpression=function(e){var t=jt,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Mt&&(t=Mt);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Mt&&(t=jt);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Mt&&(t=Mt)}},I.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},I.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?jt:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},I.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Mt&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},I.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},I.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Mt&&(t=Mt);return t},I.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?jt:Mt},I.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&It(n)||Lt(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function It(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Lt(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}I.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Rt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Rt(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}I.regexp_eatClassControlLetter=function(e){var t=e.current();return zt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},I.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},I.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;zt(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function zt(e){return e>=48&&e<=57}I.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Bt(n=e.current());)e.lastIntValue=16*e.lastIntValue+Vt(n),e.advance();return e.pos!==t};function Bt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Vt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}I.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},I.regexp_eatOctalDigit=function(e){var t=e.current();return Ht(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ht(e){return e>=48&&e<=55}I.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Bt(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Vt(i),e.advance()}return!0};var Ut=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new se(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},R=j.prototype;R.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Ut(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},R.getToken=function(){return this.next(),new Ut(this)},typeof Symbol<`u`&&(R[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===b.eof,value:t}}}}),R.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(b.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},R.readToken=function(e){return f(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},R.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},R.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=w(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},R.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!C(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},R.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&T.test(String.fromCharCode(e)))++this.pos;else break loop}}},R.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},R.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(b.ellipsis)):(++this.pos,this.finishToken(b.dot))},R.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(b.assign,2):this.finishOp(b.slash,1)},R.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?b.star:b.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=b.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(b.assign,n+1):this.finishOp(r,n)},R.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(b.assign,3):this.finishOp(e===124?b.logicalOR:b.logicalAND,2):t===61?this.finishOp(b.assign,2):this.finishOp(e===124?b.bitwiseOR:b.bitwiseAND,1)},R.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(b.assign,2):this.finishOp(b.bitwiseXOR,1)},R.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||x.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(b.incDec,2):t===61?this.finishOp(b.assign,2):this.finishOp(b.plusMin,1)},R.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(b.assign,n+1):this.finishOp(b.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(b.relational,n))},R.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(b.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(b.arrow)):this.finishOp(e===61?b.eq:b.prefix,1)},R.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(b.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(b.assign,3):this.finishOp(b.coalesce,2)}return this.finishOp(b.question,1)},R.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),f(t,!0)||t===92))return this.finishToken(b.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ie(t)+`'`)},R.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(b.parenL);case 41:return++this.pos,this.finishToken(b.parenR);case 59:return++this.pos,this.finishToken(b.semi);case 44:return++this.pos,this.finishToken(b.comma);case 91:return++this.pos,this.finishToken(b.bracketL);case 93:return++this.pos,this.finishToken(b.bracketR);case 123:return++this.pos,this.finishToken(b.braceL);case 125:return++this.pos,this.finishToken(b.braceR);case 58:return++this.pos,this.finishToken(b.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(b.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(b.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ie(e)+`'`)},R.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},R.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(x.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new Ct(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(b.regexp,{pattern:i,flags:o,value:c})},R.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function z(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Wt(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}R.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Wt(this.input.slice(t,this.pos)),++this.pos):f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(b.num,n)},R.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Wt(this.input.slice(t,this.pos));return++this.pos,f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(b.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=z(this.input.slice(t,this.pos),n);return this.finishToken(b.num,a)},R.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},R.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(C(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(b.string,t)};var Gt={};R.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Gt)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},R.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Gt;this.raise(e,t)},R.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===b.template||this.type===b.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(b.dollarBraceL)):(++this.pos,this.finishToken(b.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(b.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(C(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
1069
+ `),cooked:this.value},this.next(),n.tail=this.type===b.backQuote,this.finishNode(n,`TemplateElement`)},F.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===b.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(b.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(b.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},F.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===b.name||this.type===b.num||this.type===b.string||this.type===b.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===b.star)&&!x.test(this.input.slice(this.lastTokEnd,this.start))},F.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(b.braceR);){if(r)r=!1;else if(this.expect(b.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(b.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},F.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(b.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===b.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===b.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(b.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(b.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},F.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},F.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===b.colon&&this.unexpected(),this.eat(b.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===b.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==b.comma&&this.type!==b.braceR&&this.type!==b.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===b.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},F.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(b.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(b.bracketR),e.key;e.computed=!1}return e.key=this.type===b.num||this.type===b.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},F.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},F.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(we(t,r.generator)|ye|(n?be:0)),this.expect(b.parenL),r.params=this.parseBindingList(b.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},F.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(we(n,!1)|_e),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},F.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==b.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,A),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},F.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},F.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Ee,t?null:n)}},F.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(b.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===b.comma?o=null:this.type===b.ellipsis?(o=this.parseSpread(r),r&&this.type===b.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},F.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&Ce)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},F.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},F.parseIdentNode=function(){var e=this.startNode();return this.type===b.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=b.name):this.unexpected(),e},F.parsePrivateIdent=function(){var e=this.startNode();return this.type===b.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},F.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===b.semi||this.canInsertSemicolon()||this.type!==b.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(b.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},F.parseAwait=function(e){this.awaitPos||=this.start;var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var qe=j.prototype;qe.raise=function(e,t){var n=ce(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},qe.raiseRecoverable=qe.raise,qe.curPosition=function(){if(this.options.locations)return new oe(this.curLine,this.pos-this.lineStart)};var Je=j.prototype,Ye=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Je.enterScope=function(e){this.scopeStack.push(new Ye(e))},Je.exitScope=function(){this.scopeStack.pop()},Je.treatFunctionsAsVarInScope=function(e){return e.flags&me||!this.inModule&&e.flags&pe},Je.declareName=function(e,t,n){var r=!1;if(t===De){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&pe&&delete this.undefinedExports[e]}else if(t===ke)this.currentScope().lexical.push(e);else if(t===Oe){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&ve&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&pe&&delete this.undefinedExports[e],s.flags&Ce)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Je.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Je.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Je.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ce|Se|xe))return t}},Je.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ce|Se|xe)&&!(t.flags&_e))return t}};var Xe=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new se(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ze=j.prototype;Ze.startNode=function(){return new Xe(this,this.start,this.startLoc)},Ze.startNodeAt=function(e,t){return new Xe(this,e,t)};function Qe(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ze.finishNode=function(e,t){return Qe.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ze.finishNodeAt=function(e,t,n,r){return Qe.call(this,e,t,n,r)},Ze.copyNode=function(e){var t=new Xe(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var $e=`Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz`,et=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,tt=et+` Extended_Pictographic`,nt=tt,rt=nt+` EBase EComp EMod EPres ExtPict`,it=rt,at=it,ot={9:et,10:tt,11:nt,12:rt,13:it,14:at},st=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,ct={9:``,10:``,11:``,12:``,13:``,14:st},lt=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,ut=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,dt=ut+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,ft=dt+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,pt=ft+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,mt=pt+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,ht=mt+` `+$e,gt={9:ut,10:dt,11:ft,12:pt,13:mt,14:ht},_t={};function vt(e){var t=_t[e]={binary:k(ot[e]+` `+lt),binaryOfStrings:k(ct[e]),nonBinary:{General_Category:k(lt),Script:k(gt[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var yt=0,bt=[9,10,11,12,13,14];yt<bt.length;yt+=1){var xt=bt[yt];vt(xt)}var I=j.prototype,St=function(e,t){this.parent=e,this.base=t||this};St.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},St.prototype.sibling=function(){return new St(this.parent,this.base)};var Ct=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=_t[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Ct.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ct.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ct.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},Ct.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},Ct.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ct.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ct.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ct.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},Ct.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},I.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function wt(e){for(var t in e)return!0;return!1}I.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&wt(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},I.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},I.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new St(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},I.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},I.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},I.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},I.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},I.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},I.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},I.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},I.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},I.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},I.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},I.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&L(n);)t+=ie(n),e.advance();return t};function L(e){return e===105||e===109||e===115}I.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},I.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},I.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Tt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Tt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}I.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Tt(n);)e.advance();return e.pos!==t},I.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},I.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},I.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},I.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=ie(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ie(e.lastIntValue);return!0}return!1},I.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Et(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Et(e){return f(e,!0)||e===36||e===95}I.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Dt(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Dt(e){return p(e,!0)||e===36||e===95||e===8204||e===8205}I.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},I.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},I.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},I.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},I.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},I.regexp_eatZero=function(e){return e.current()===48&&!zt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},I.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},I.regexp_eatControlLetter=function(e){var t=e.current();return Ot(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ot(e){return e>=65&&e<=90||e>=97&&e<=122}I.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&kt(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function kt(e){return e>=0&&e<=1114111}I.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},I.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var At=0,jt=1,Mt=2;I.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Nt(t))return e.lastIntValue=-1,e.advance(),jt;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Mt&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return At};function Nt(e){return e===100||e===68||e===115||e===83||e===119||e===87}I.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),jt}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return At},I.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){O(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},I.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return jt;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Mt;e.raise(`Invalid property name`)},I.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Pt(t=e.current());)e.lastStringValue+=ie(t),e.advance();return e.lastStringValue!==``};function Pt(e){return Ot(e)||e===95}I.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ft(t=e.current());)e.lastStringValue+=ie(t),e.advance();return e.lastStringValue!==``};function Ft(e){return Pt(e)||zt(e)}I.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},I.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Mt&&e.raise(`Negated character class may contain strings`),!0}return!1},I.regexp_classContents=function(e){return e.current()===93?jt:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),jt)},I.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},I.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ht(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},I.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},I.regexp_classSetExpression=function(e){var t=jt,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Mt&&(t=Mt);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Mt&&(t=jt);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Mt&&(t=Mt)}},I.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},I.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?jt:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},I.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Mt&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},I.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},I.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Mt&&(t=Mt);return t},I.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?jt:Mt},I.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&It(n)||Lt(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function It(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Lt(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}I.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Rt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Rt(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}I.regexp_eatClassControlLetter=function(e){var t=e.current();return zt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},I.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},I.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;zt(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function zt(e){return e>=48&&e<=57}I.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Bt(n=e.current());)e.lastIntValue=16*e.lastIntValue+Vt(n),e.advance();return e.pos!==t};function Bt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Vt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}I.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},I.regexp_eatOctalDigit=function(e){var t=e.current();return Ht(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ht(e){return e>=48&&e<=55}I.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Bt(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Vt(i),e.advance()}return!0};var Ut=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new se(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},R=j.prototype;R.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Ut(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},R.getToken=function(){return this.next(),new Ut(this)},typeof Symbol<`u`&&(R[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===b.eof,value:t}}}}),R.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(b.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},R.readToken=function(e){return f(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},R.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},R.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=w(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},R.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!C(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},R.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&T.test(String.fromCharCode(e)))++this.pos;else break loop}}},R.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},R.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(b.ellipsis)):(++this.pos,this.finishToken(b.dot))},R.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(b.assign,2):this.finishOp(b.slash,1)},R.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?b.star:b.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=b.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(b.assign,n+1):this.finishOp(r,n)},R.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(b.assign,3):this.finishOp(e===124?b.logicalOR:b.logicalAND,2):t===61?this.finishOp(b.assign,2):this.finishOp(e===124?b.bitwiseOR:b.bitwiseAND,1)},R.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(b.assign,2):this.finishOp(b.bitwiseXOR,1)},R.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||x.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(b.incDec,2):t===61?this.finishOp(b.assign,2):this.finishOp(b.plusMin,1)},R.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(b.assign,n+1):this.finishOp(b.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(b.relational,n))},R.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(b.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(b.arrow)):this.finishOp(e===61?b.eq:b.prefix,1)},R.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(b.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(b.assign,3):this.finishOp(b.coalesce,2)}return this.finishOp(b.question,1)},R.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),f(t,!0)||t===92))return this.finishToken(b.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ie(t)+`'`)},R.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(b.parenL);case 41:return++this.pos,this.finishToken(b.parenR);case 59:return++this.pos,this.finishToken(b.semi);case 44:return++this.pos,this.finishToken(b.comma);case 91:return++this.pos,this.finishToken(b.bracketL);case 93:return++this.pos,this.finishToken(b.bracketR);case 123:return++this.pos,this.finishToken(b.braceL);case 125:return++this.pos,this.finishToken(b.braceR);case 58:return++this.pos,this.finishToken(b.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(b.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(b.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ie(e)+`'`)},R.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},R.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(x.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new Ct(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(b.regexp,{pattern:i,flags:o,value:c})},R.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function Wt(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Gt(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}R.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Gt(this.input.slice(t,this.pos)),++this.pos):f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(b.num,n)},R.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Gt(this.input.slice(t,this.pos));return++this.pos,f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(b.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Wt(this.input.slice(t,this.pos),n);return this.finishToken(b.num,a)},R.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},R.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(C(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(b.string,t)};var Kt={};R.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Kt)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},R.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Kt;this.raise(e,t)},R.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===b.template||this.type===b.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(b.dollarBraceL)):(++this.pos,this.finishToken(b.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(b.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(C(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
745
1070
  `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},R.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(b.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
746
1071
  `&&++this.pos;case`
747
1072
  `:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},R.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
748
- `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ie(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return C(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},R.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},R.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(p(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?f:p)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ie(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},R.readWord=function(){var e=this.readWord1(),t=b.name;return this.keywords.test(e)&&(t=v[e]),this.finishToken(t,e)};var Kt=`8.15.0`;j.acorn={Parser:j,version:Kt,defaultOptions:le,Position:oe,SourceLocation:se,getLineInfo:ce,Node:Xe,TokenType:m,tokTypes:b,keywordTypes:v,TokContext:He,tokContexts:P,isIdentifierChar:p,isIdentifierStart:f,Token:Ut,isNewLine:C,lineBreak:x,lineBreakG:S,nonASCIIwhitespace:T};function qt(e,t){return j.parse(e,t)}function Jt(e,t,n){return j.parseExpressionAt(e,t,n)}function Yt(e,t){return j.tokenizer(e,t)}e.Node=Xe,e.Parser=j,e.Position=oe,e.SourceLocation=se,e.TokContext=He,e.Token=Ut,e.TokenType=m,e.defaultOptions=le,e.getLineInfo=ce,e.isIdentifierChar=p,e.isIdentifierStart=f,e.isNewLine=C,e.keywordTypes=v,e.lineBreak=x,e.lineBreakG=S,e.nonASCIIwhitespace=T,e.parse=qt,e.parseExpressionAt=Jt,e.tokContexts=P,e.tokTypes=b,e.tokenizer=Yt,e.version=Kt}))})),Ap=o(((e,t)=>{let n=Op(),r=/^[\da-fA-F]+$/,i=/^\d+$/,a=new WeakMap;function o(e){e=e.Parser.acorn||e;let t=a.get(e);if(!t){let n=e.tokTypes,r=e.TokContext,i=e.TokenType,o=new r(`<tag`,!1),s=new r(`</tag`,!1),c=new r(`<tag>...</tag>`,!0,!0),l={tc_oTag:o,tc_cTag:s,tc_expr:c},u={jsxName:new i(`jsxName`),jsxText:new i(`jsxText`,{beforeExpr:!0}),jsxTagStart:new i(`jsxTagStart`,{startsExpr:!0}),jsxTagEnd:new i(`jsxTagEnd`)};u.jsxTagStart.updateContext=function(){this.context.push(c),this.context.push(o),this.exprAllowed=!1},u.jsxTagEnd.updateContext=function(e){let t=this.context.pop();t===o&&e===n.slash||t===s?(this.context.pop(),this.exprAllowed=this.curContext()===c):this.exprAllowed=!0},t={tokContexts:l,tokTypes:u},a.set(e,t)}return t}function s(e){if(!e)return e;if(e.type===`JSXIdentifier`)return e.name;if(e.type===`JSXNamespacedName`)return e.namespace.name+`:`+e.name.name;if(e.type===`JSXMemberExpression`)return s(e.object)+`.`+s(e.property)}t.exports=function(e){return e||={},function(t){return c({allowNamespaces:e.allowNamespaces!==!1,allowNamespacedObjects:!!e.allowNamespacedObjects},t)}},Object.defineProperty(t.exports,`tokTypes`,{get:function(){return o(kp()).tokTypes},configurable:!0,enumerable:!0});function c(e,t){let a=t.acorn||kp(),c=o(a),l=a.tokTypes,u=c.tokTypes,d=a.tokContexts,f=c.tokContexts.tc_oTag,p=c.tokContexts.tc_cTag,m=c.tokContexts.tc_expr,h=a.isNewLine,g=a.isIdentifierStart,_=a.isIdentifierChar;return class extends t{static get acornJsx(){return c}jsx_readToken(){let e=``,t=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated JSX contents`);let n=this.input.charCodeAt(this.pos);switch(n){case 60:case 123:return this.pos===this.start?n===60&&this.exprAllowed?(++this.pos,this.finishToken(u.jsxTagStart)):this.getTokenFromCode(n):(e+=this.input.slice(t,this.pos),this.finishToken(u.jsxText,e));case 38:e+=this.input.slice(t,this.pos),e+=this.jsx_readEntity(),t=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(n===62?`&gt;`:`&rbrace;`)+'` or `{"'+this.input[this.pos]+'"}`?');default:h(n)?(e+=this.input.slice(t,this.pos),e+=this.jsx_readNewLine(!0),t=this.pos):++this.pos}}}jsx_readNewLine(e){let t=this.input.charCodeAt(this.pos),n;return++this.pos,t===13&&this.input.charCodeAt(this.pos)===10?(++this.pos,n=e?`
1073
+ `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ie(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return C(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},R.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},R.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(p(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?f:p)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ie(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},R.readWord=function(){var e=this.readWord1(),t=b.name;return this.keywords.test(e)&&(t=v[e]),this.finishToken(t,e)};var qt=`8.15.0`;j.acorn={Parser:j,version:qt,defaultOptions:le,Position:oe,SourceLocation:se,getLineInfo:ce,Node:Xe,TokenType:m,tokTypes:b,keywordTypes:v,TokContext:He,tokContexts:P,isIdentifierChar:p,isIdentifierStart:f,Token:Ut,isNewLine:C,lineBreak:x,lineBreakG:S,nonASCIIwhitespace:T};function Jt(e,t){return j.parse(e,t)}function Yt(e,t,n){return j.parseExpressionAt(e,t,n)}function Xt(e,t){return j.tokenizer(e,t)}e.Node=Xe,e.Parser=j,e.Position=oe,e.SourceLocation=se,e.TokContext=He,e.Token=Ut,e.TokenType=m,e.defaultOptions=le,e.getLineInfo=ce,e.isIdentifierChar=p,e.isIdentifierStart=f,e.isNewLine=C,e.keywordTypes=v,e.lineBreak=x,e.lineBreakG=S,e.nonASCIIwhitespace=T,e.parse=Jt,e.parseExpressionAt=Yt,e.tokContexts=P,e.tokTypes=b,e.tokenizer=Xt,e.version=qt}))})),Ap=o(((e,t)=>{let n=Op(),r=/^[\da-fA-F]+$/,i=/^\d+$/,a=new WeakMap;function o(e){e=e.Parser.acorn||e;let t=a.get(e);if(!t){let n=e.tokTypes,r=e.TokContext,i=e.TokenType,o=new r(`<tag`,!1),s=new r(`</tag`,!1),c=new r(`<tag>...</tag>`,!0,!0),l={tc_oTag:o,tc_cTag:s,tc_expr:c},u={jsxName:new i(`jsxName`),jsxText:new i(`jsxText`,{beforeExpr:!0}),jsxTagStart:new i(`jsxTagStart`,{startsExpr:!0}),jsxTagEnd:new i(`jsxTagEnd`)};u.jsxTagStart.updateContext=function(){this.context.push(c),this.context.push(o),this.exprAllowed=!1},u.jsxTagEnd.updateContext=function(e){let t=this.context.pop();t===o&&e===n.slash||t===s?(this.context.pop(),this.exprAllowed=this.curContext()===c):this.exprAllowed=!0},t={tokContexts:l,tokTypes:u},a.set(e,t)}return t}function s(e){if(!e)return e;if(e.type===`JSXIdentifier`)return e.name;if(e.type===`JSXNamespacedName`)return e.namespace.name+`:`+e.name.name;if(e.type===`JSXMemberExpression`)return s(e.object)+`.`+s(e.property)}t.exports=function(e){return e||={},function(t){return c({allowNamespaces:e.allowNamespaces!==!1,allowNamespacedObjects:!!e.allowNamespacedObjects},t)}},Object.defineProperty(t.exports,`tokTypes`,{get:function(){return o(kp()).tokTypes},configurable:!0,enumerable:!0});function c(e,t){let a=t.acorn||kp(),c=o(a),l=a.tokTypes,u=c.tokTypes,d=a.tokContexts,f=c.tokContexts.tc_oTag,p=c.tokContexts.tc_cTag,m=c.tokContexts.tc_expr,h=a.isNewLine,g=a.isIdentifierStart,_=a.isIdentifierChar;return class extends t{static get acornJsx(){return c}jsx_readToken(){let e=``,t=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated JSX contents`);let n=this.input.charCodeAt(this.pos);switch(n){case 60:case 123:return this.pos===this.start?n===60&&this.exprAllowed?(++this.pos,this.finishToken(u.jsxTagStart)):this.getTokenFromCode(n):(e+=this.input.slice(t,this.pos),this.finishToken(u.jsxText,e));case 38:e+=this.input.slice(t,this.pos),e+=this.jsx_readEntity(),t=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(n===62?`&gt;`:`&rbrace;`)+'` or `{"'+this.input[this.pos]+'"}`?');default:h(n)?(e+=this.input.slice(t,this.pos),e+=this.jsx_readNewLine(!0),t=this.pos):++this.pos}}}jsx_readNewLine(e){let t=this.input.charCodeAt(this.pos),n;return++this.pos,t===13&&this.input.charCodeAt(this.pos)===10?(++this.pos,n=e?`
749
1074
  `:`\r
750
1075
  `):n=String.fromCharCode(t),this.options.locations&&(++this.curLine,this.lineStart=this.pos),n}jsx_readString(e){let t=``,n=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);let r=this.input.charCodeAt(this.pos);if(r===e)break;r===38?(t+=this.input.slice(n,this.pos),t+=this.jsx_readEntity(),n=this.pos):h(r)?(t+=this.input.slice(n,this.pos),t+=this.jsx_readNewLine(!1),n=this.pos):++this.pos}return t+=this.input.slice(n,this.pos++),this.finishToken(l.string,t)}jsx_readEntity(){let e=``,t=0,a,o=this.input[this.pos];o!==`&`&&this.raise(this.pos,`Entity must start with an ampersand`);let s=++this.pos;for(;this.pos<this.input.length&&t++<10;){if(o=this.input[this.pos++],o===`;`){e[0]===`#`?e[1]===`x`?(e=e.substr(2),r.test(e)&&(a=String.fromCharCode(parseInt(e,16)))):(e=e.substr(1),i.test(e)&&(a=String.fromCharCode(parseInt(e,10)))):a=n[e];break}e+=o}return a||(this.pos=s,`&`)}jsx_readWord(){let e,t=this.pos;do e=this.input.charCodeAt(++this.pos);while(_(e)||e===45);return this.finishToken(u.jsxName,this.input.slice(t,this.pos))}jsx_parseIdentifier(){let e=this.startNode();return this.type===u.jsxName?e.name=this.value:this.type.keyword?e.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(e,`JSXIdentifier`)}jsx_parseNamespacedName(){let t=this.start,n=this.startLoc,r=this.jsx_parseIdentifier();if(!e.allowNamespaces||!this.eat(l.colon))return r;var i=this.startNodeAt(t,n);return i.namespace=r,i.name=this.jsx_parseIdentifier(),this.finishNode(i,`JSXNamespacedName`)}jsx_parseElementName(){if(this.type===u.jsxTagEnd)return``;let t=this.start,n=this.startLoc,r=this.jsx_parseNamespacedName();for(this.type===l.dot&&r.type===`JSXNamespacedName`&&!e.allowNamespacedObjects&&this.unexpected();this.eat(l.dot);){let e=this.startNodeAt(t,n);e.object=r,e.property=this.jsx_parseIdentifier(),r=this.finishNode(e,`JSXMemberExpression`)}return r}jsx_parseAttributeValue(){switch(this.type){case l.braceL:let e=this.jsx_parseExpressionContainer();return e.expression.type===`JSXEmptyExpression`&&this.raise(e.start,`JSX attributes must only be assigned a non-empty expression`),e;case u.jsxTagStart:case l.string:return this.parseExprAtom();default:this.raise(this.start,`JSX value should be either an expression or a quoted JSX text`)}}jsx_parseEmptyExpression(){let e=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(e,`JSXEmptyExpression`,this.start,this.startLoc)}jsx_parseExpressionContainer(){let e=this.startNode();return this.next(),e.expression=this.type===l.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(l.braceR),this.finishNode(e,`JSXExpressionContainer`)}jsx_parseAttribute(){let e=this.startNode();return this.eat(l.braceL)?(this.expect(l.ellipsis),e.argument=this.parseMaybeAssign(),this.expect(l.braceR),this.finishNode(e,`JSXSpreadAttribute`)):(e.name=this.jsx_parseNamespacedName(),e.value=this.eat(l.eq)?this.jsx_parseAttributeValue():null,this.finishNode(e,`JSXAttribute`))}jsx_parseOpeningElementAt(e,t){let n=this.startNodeAt(e,t);n.attributes=[];let r=this.jsx_parseElementName();for(r&&(n.name=r);this.type!==l.slash&&this.type!==u.jsxTagEnd;)n.attributes.push(this.jsx_parseAttribute());return n.selfClosing=this.eat(l.slash),this.expect(u.jsxTagEnd),this.finishNode(n,r?`JSXOpeningElement`:`JSXOpeningFragment`)}jsx_parseClosingElementAt(e,t){let n=this.startNodeAt(e,t),r=this.jsx_parseElementName();return r&&(n.name=r),this.expect(u.jsxTagEnd),this.finishNode(n,r?`JSXClosingElement`:`JSXClosingFragment`)}jsx_parseElementAt(e,t){let n=this.startNodeAt(e,t),r=[],i=this.jsx_parseOpeningElementAt(e,t),a=null;if(!i.selfClosing){contents:for(;;)switch(this.type){case u.jsxTagStart:if(e=this.start,t=this.startLoc,this.next(),this.eat(l.slash)){a=this.jsx_parseClosingElementAt(e,t);break contents}r.push(this.jsx_parseElementAt(e,t));break;case u.jsxText:r.push(this.parseExprAtom());break;case l.braceL:r.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}s(a.name)!==s(i.name)&&this.raise(a.start,`Expected corresponding JSX closing tag for <`+s(i.name)+`>`)}let o=i.name?`Element`:`Fragment`;return n[`opening`+o]=i,n[`closing`+o]=a,n.children=r,this.type===l.relational&&this.value===`<`&&this.raise(this.start,`Adjacent JSX elements must be wrapped in an enclosing tag`),this.finishNode(n,`JSX`+o)}jsx_parseText(){let e=this.parseLiteral(this.value);return e.type=`JSXText`,e}jsx_parseElement(){let e=this.start,t=this.startLoc;return this.next(),this.jsx_parseElementAt(e,t)}parseExprAtom(e){return this.type===u.jsxText?this.jsx_parseText():this.type===u.jsxTagStart?this.jsx_parseElement():super.parseExprAtom(e)}readToken(e){let t=this.curContext();if(t===m)return this.jsx_readToken();if(t===f||t===p){if(g(e))return this.jsx_readWord();if(e==62)return++this.pos,this.finishToken(u.jsxTagEnd);if((e===34||e===39)&&t==f)return this.jsx_readString(e)}return e===60&&this.exprAllowed&&this.input.charCodeAt(this.pos+1)!==33?(++this.pos,this.finishToken(u.jsxTagStart)):super.readToken(e)}updateContext(e){if(this.type==l.braceL){var t=this.curContext();t==f?this.context.push(d.b_expr):t==m?this.context.push(d.b_tmpl):super.updateContext(e),this.exprAllowed=!0}else if(this.type===l.slash&&e===u.jsxTagStart)this.context.length-=2,this.context.push(p),this.exprAllowed=!1;else return super.updateContext(e)}}}}));function jp(e){return`\x1B[33m`+e+`\x1B[39m`}const Mp={}.hasOwnProperty,Np=Symbol(`continue`),Pp=Symbol(`exit`),Fp=Symbol(`skip`);function Ip(e,t){let n,r;typeof t==`function`?n=t:t&&typeof t==`object`&&(t.enter&&(n=t.enter),t.leave&&(r=t.leave)),i(e,void 0,void 0,[])();function i(e,t,a,o){return Rp(e)&&(s.displayName=`node (`+jp(e.type)+`)`),s;function s(){let s=n?Lp(n(e,t,a,o)):[];if(s[0]===Pp)return s;if(s[0]!==Fp){let t;for(t in e)if(Mp.call(e,t)&&e[t]&&typeof e[t]==`object`&&t!==`data`&&t!==`position`){let n=o.concat(e),r=e[t];if(Array.isArray(r)){let e=r,a=0;for(;a>-1&&a<e.length;){let r=e[a];if(Rp(r)){let e=i(r,t,a,n)();if(e[0]===Pp)return e;a=typeof e[1]==`number`?e[1]:a+1}else a++}}else if(Rp(r)){let e=i(r,t,void 0,n)();if(e[0]===Pp)return e}}}return r?Lp(r(e,t,a,o)):s}}}function Lp(e){return Array.isArray(e)?e:typeof e==`number`?[Np,e]:[e]}function Rp(e){return!!(e&&typeof e==`object`&&`type`in e&&typeof e.type==`string`&&e.type.length>0)}function zp(e,t){let n=t.prefix||``,r=t.suffix||``,i=Object.assign({},t.acornOptions),a=[],o=[],s=i.onComment,c=i.onToken,l=!1,u,d,f=Object.assign({},i,{onComment:a,preserveParens:!0});c&&(f.onToken=o);let p=Vp(e,t.tokenTypes),m=p.value,h=n+m+r,g=t.expression&&Bp(m);if(g&&!t.allowEmpty)throw new W(`Unexpected empty expression`,{place:v(0),ruleId:`unexpected-empty-expression`,source:`micromark-extension-mdx-expression`});try{u=t.expression&&!g?t.acorn.parseExpressionAt(h,0,f):t.acorn.parse(h,f)}catch(e){let t=e,r=v(t.pos);t.message=String(t.message).replace(/ \(\d+:\d+\)$/,``),t.pos=r.offset,t.loc={line:r.line,column:r.column-1},d=t,l=t.raisedAt>=n.length+m.length||t.message===`Unterminated comment`}if(u&&t.expression&&!g)if(Bp(h.slice(u.end,h.length-r.length)))u={type:`Program`,start:0,end:n.length+m.length,body:[{type:`ExpressionStatement`,expression:u,start:0,end:n.length+m.length}],sourceType:`module`,comments:[]};else{let e=v(u.end),t=Error(`Unexpected content after expression`);t.pos=e.offset,t.loc={line:e.line,column:e.column-1},d=t,u=void 0}if(u){if(u.comments=a,Ip(u,function(e,t,n,r){let i=r[r.length-1],a=t;e.type===`ParenthesizedExpression`&&i&&a&&(typeof n==`number`&&(i=i[a],a=n),i[a]=e.expression),_(e)}),Array.isArray(s))s.push(...a);else if(typeof s==`function`)for(let e of a)s(e.type===`Block`,e.value,e.start,e.end,e.loc.start,e.loc.end);for(let e of o)e.end<=n.length||e.start-n.length>=m.length||(_(e),Array.isArray(c)?c.push(e):c(e))}return{estree:u,error:d,swallow:l};function _(e){let t=v(e.start),n=v(e.end);e.start=t.offset,e.end=n.offset,e.loc={start:{line:t.line,column:t.column-1,offset:t.offset},end:{line:n.line,column:n.column-1,offset:n.offset}},e.range=[e.start,e.end]}function v(e){let r=e-n.length;r<0?r=0:r>m.length&&(r=m.length);let i=Hp(p.stops,r);return i||={line:t.start.line,column:t.start.column,offset:t.start.offset},i}}function Bp(e){return/^\s*$/.test(e.replace(/\/\*[\s\S]*?\*\//g,``).replace(/\/\/[^\r\n]*(\r\n|\n|\r)/g,``))}function Vp(e,t){let n={value:``,stops:[]},r=-1;for(;++r<e.length;){let i=e[r];if(i[0]===`enter`){let e=i[1].type;if(e===`lineEnding`||t.includes(e)){let e=i[2].sliceStream(i[1]);for(;e.length>0&&e[0]===-1;)e.shift();let t=Up(e);n.stops.push([n.value.length,i[1].start]),n.value+=t,n.stops.push([n.value.length,i[1].end])}}}return n}function Hp(e,t){let n=0;for(;n<e.length&&e[n][0]<=t;)n+=1;if(n===0)return;let[r,i]=e[n-1],a=t-r;return{line:i.line,column:i.column+a,offset:i.offset+a}}function Up(e){let t=-1,n=[],r;for(;++t<e.length;){let i=e[t],a;if(typeof i==`string`)a=i;else switch(i){case-5:a=`\r`;break;case-4:a=`
751
1076
  `;break;case-3:a=`\r
@@ -867,13 +1192,13 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
867
1192
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
868
1193
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
869
1194
  `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),xg=o((e=>{var t=pg(),n=Xh(),r=Zh(),i=xh(),a=$(),o=yg(),s=bg();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Sg=l(o((e=>{var t=pg(),n=Xh(),r=Jh(),i=Zh(),a=fh(),o=$(),s=wh(),c=ph(),l=Eh(),u=Oh();_g();var d=vg(),f=yg(),p=bg(),m=xg(),h=oh();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))(),1);function Cg(e,t){let n=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null));return Object.keys(n).length===0?`---
870
- ---`:`---\n${Sg.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function wg(e,t,n){return e==null||Object.keys(e).length===0?t:`${Cg(e,n)}\n${t}`}function Tg(e){let t=ah(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){r=e.value;try{n=Sg.parse(e.value??``)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}function Eg(e){return e.replaceAll(/(!?\[)([^\]]*)(\]\()([^)]+)(\))/g,(e,t,n,r,i,a)=>{let o=n.replaceAll(/\.mdx$/g,`.md`).replaceAll(/\.mdx(?=#|\?|$)/g,`.md`);return/^(?:https?:)?\/\//.test(i)?`${t}${o}${r}${i}${a}`:`${t}${o}${r}${i.replace(/\.mdx$/,`.md`).replace(/\.mdx#/,`.md#`).replace(/\.mdx\?/,`.md?`)}${a}`})}var Dg=class{type;name;_log;get log(){return this._log??=tn(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}},Og=class extends Dg{globalConfigDir;outputFileName;registryWriterCache=new Map;writeEffects=[];cleanEffects=[];constructor(e,t){super(e,bt.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}registerWriteEffect(e,t){this.writeEffects.push({name:e,handler:t})}registerCleanEffect(e,t){this.cleanEffects.push({name:e,handler:t})}async executeWriteEffects(e){let t=[];for(let n of this.writeEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute write effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Write effect failed: ${n.name}`})}}return t}async executeCleanEffects(e){let t=[];for(let n of this.cleanEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute clean effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Clean effect failed: ${n.name}`})}}return t}isRelativePath(e){return e.pathKind===L.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:L.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let n;n=e.pathKind===L.Absolute?e.path:this.isRelativePath(e)?f.resolve(e.basePath,e.path):f.resolve(u.default.cwd(),e.path);let r=t??this.outputFileName;return r?f.join(n,r):n}createRelativePath(e,t,n){return ct(e,t,n)}createFileRelativePath(e,t){return lt(e,t)}getGlobalConfigDir(){return f.join(this.getHomeDir(),this.globalConfigDir)}getHomeDir(){return p.homedir()}joinPath(...e){return f.join(...e)}resolvePath(...e){return f.resolve(...e)}dirname(e){return f.dirname(e)}basename(e,t){return f.basename(e,t)}writeFileSync(e,t,n=`utf8`){it(e,t,n)}writeFileSyncBuffer(e,t){it(e,t)}ensureDirectory(e){$e(e)}existsSync(e){return d.existsSync(e)}lstatSync(e){return Qe(e)}isSymlink(e){return Ze(e)}createSymlink(e,t,n=`dir`){tt(e,t,n)}removeSymlink(e){nt(e)}async writeDirectorySymlink(e,t,n,r){let i=f.dirname(n),a=ct(f.basename(n),i,()=>f.basename(i));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`symlink`,target:t,link:n,label:r}),{path:a,success:!0,skipped:!1};try{return this.createSymlink(t,n,`dir`),this.log.trace({action:`write`,type:`symlink`,target:t,link:n,label:r}),{path:a,success:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`symlink`,target:t,link:n,label:r,error:i}),{path:a,success:!1,error:e}}}readdirSync(e,t){return t?.withFileTypes===!0?d.readdirSync(e,{withFileTypes:!0}):d.readdirSync(e)}async writeFile(e,t,n,r){let i=f.dirname(t),a=ct(f.basename(t),i,()=>f.basename(i));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`file`,path:t,label:r}),{path:a,success:!0,skipped:!1};try{return it(t,n),this.log.trace({action:`write`,type:`file`,path:t,label:r}),{path:a,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`file`,path:t,label:r,error:n}),{path:a,success:!1,error:e}}}async writePromptFile(e,t,n,r){let i=this.resolveFullPath(t),a=this.toRelativePath(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`promptFile`,path:i,label:r}),{path:a,success:!0,skipped:!1};try{return it(i,n),this.log.trace({action:`write`,type:`promptFile`,path:i,label:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`promptFile`,path:i,label:r,error:t}),{path:a,success:!1,error:e}}}buildMarkdownContent(e,t){return wg(t,e)}buildMarkdownContentWithRaw(e,t,n){return t!=null&&Object.keys(t).length>0?wg(t,e):n!=null&&n.length>0?`---\n${n}\n---\n${e}`:e}extractGlobalMemoryContent(e){return e.collectedInputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
1195
+ ---`:`---\n${Sg.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function wg(e,t,n){return e==null||Object.keys(e).length===0?t:`${Cg(e,n)}\n${t}`}function Tg(e){let t=ah(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){r=e.value;try{n=Sg.parse(e.value??``)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}function Eg(e){return e.replaceAll(/(!?\[)([^\]]*)(\]\()([^)]+)(\))/g,(e,t,n,r,i,a)=>{let o=n.replaceAll(/\.mdx$/g,`.md`).replaceAll(/\.mdx(?=#|\?|$)/g,`.md`);return/^(?:https?:)?\/\//.test(i)?`${t}${o}${r}${i}${a}`:`${t}${o}${r}${i.replace(/\.mdx$/,`.md`).replace(/\.mdx#/,`.md#`).replace(/\.mdx\?/,`.md?`)}${a}`})}var Dg=class{type;name;_log;get log(){return this._log??=nn(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}},Og=class extends Dg{globalConfigDir;outputFileName;registryWriterCache=new Map;writeEffects=[];cleanEffects=[];constructor(e,t){super(e,bt.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}registerWriteEffect(e,t){this.writeEffects.push({name:e,handler:t})}registerCleanEffect(e,t){this.cleanEffects.push({name:e,handler:t})}async executeWriteEffects(e){let t=[];for(let n of this.writeEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute write effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Write effect failed: ${n.name}`})}}return t}async executeCleanEffects(e){let t=[];for(let n of this.cleanEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute clean effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Clean effect failed: ${n.name}`})}}return t}isRelativePath(e){return e.pathKind===L.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:L.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let n;n=e.pathKind===L.Absolute?e.path:this.isRelativePath(e)?f.resolve(e.basePath,e.path):f.resolve(u.default.cwd(),e.path);let r=t??this.outputFileName;return r?f.join(n,r):n}createRelativePath(e,t,n){return ct(e,t,n)}createFileRelativePath(e,t){return lt(e,t)}getGlobalConfigDir(){return f.join(this.getHomeDir(),this.globalConfigDir)}getHomeDir(){return p.homedir()}joinPath(...e){return f.join(...e)}resolvePath(...e){return f.resolve(...e)}dirname(e){return f.dirname(e)}basename(e,t){return f.basename(e,t)}writeFileSync(e,t,n=`utf8`){it(e,t,n)}writeFileSyncBuffer(e,t){it(e,t)}ensureDirectory(e){$e(e)}existsSync(e){return d.existsSync(e)}lstatSync(e){return Qe(e)}isSymlink(e){return Ze(e)}createSymlink(e,t,n=`dir`){tt(e,t,n)}removeSymlink(e){nt(e)}async writeDirectorySymlink(e,t,n,r){let i=f.dirname(n),a=ct(f.basename(n),i,()=>f.basename(i));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`symlink`,target:t,link:n,label:r}),{path:a,success:!0,skipped:!1};try{return this.createSymlink(t,n,`dir`),this.log.trace({action:`write`,type:`symlink`,target:t,link:n,label:r}),{path:a,success:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`symlink`,target:t,link:n,label:r,error:i}),{path:a,success:!1,error:e}}}readdirSync(e,t){return t?.withFileTypes===!0?d.readdirSync(e,{withFileTypes:!0}):d.readdirSync(e)}async writeFile(e,t,n,r){let i=f.dirname(t),a=ct(f.basename(t),i,()=>f.basename(i));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`file`,path:t,label:r}),{path:a,success:!0,skipped:!1};try{return it(t,n),this.log.trace({action:`write`,type:`file`,path:t,label:r}),{path:a,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`file`,path:t,label:r,error:n}),{path:a,success:!1,error:e}}}async writePromptFile(e,t,n,r){let i=this.resolveFullPath(t),a=this.toRelativePath(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`promptFile`,path:i,label:r}),{path:a,success:!0,skipped:!1};try{return it(i,n),this.log.trace({action:`write`,type:`promptFile`,path:i,label:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`promptFile`,path:i,label:r,error:t}),{path:a,success:!1,error:e}}}buildMarkdownContent(e,t){return wg(t,e)}buildMarkdownContentWithRaw(e,t,n){return t!=null&&Object.keys(t).length>0?wg(t,e):n!=null&&n.length>0?`---\n${n}\n---\n${e}`:e}extractGlobalMemoryContent(e){return e.collectedInputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
871
1196
 
872
- `,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`-`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}getRegistryWriter(e){let t=e.name,n=this.registryWriterCache.get(t);if(n!=null)return n;let r=new e(this.log);return this.registryWriterCache.set(t,r),r}async registerInRegistry(e,t,n){return e.register(t,n.dryRun)}};const kg=`AGENTS.md`;var Ag=class extends Og{constructor(){super(`AgentsOutputPlugin`,{outputFileName:kg})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,kg)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,kg));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}},jg=class extends Dg{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,bt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:m.spawn,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(Ut.USER_HOME)&&(r=r.replace(Ut.USER_HOME,p.homedir())),r.includes(Ut.SHADOW_SOURCE_PROJECT)&&(r=r.replace(Ut.SHADOW_SOURCE_PROJECT,n)),r.includes(Ut.WORKSPACE)&&(r=r.replace(Ut.WORKSPACE,t)),f.normalize(r)}readAndParseMarkdown(e,t){return Tg(t.readFileSync(e,`utf8`))}};const Mg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var Ng=class extends jg{constructor(){super(`AIAgentIgnoreConfigFileInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{shadowProjectDir:a}=this.resolveBasePaths(t),o=[];for(let e of Mg){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf8`);o.push({fileName:e,content:i}),n.debug(`read ignore file`,{path:t})}catch(e){n.warn(`failed to read ignore file`,{path:t,error:e})}}return{aiAgentIgnoreConfigFiles:o}}};const Pg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var Fg=class extends Og{constructor(){super(`AIAgentIgnoreConfigFileOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.isPromptSourceProject!==!0)for(let n of Pg){let r=f.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:L.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>f.basename(e.dirFromWorkspacePath.path),getAbsolutePath:()=>f.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{aiAgentIgnoreConfigFiles:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no ignore config files to write`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{aiAgentIgnoreConfigFiles:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){let t=i.dirFromWorkspacePath;if(t==null)continue;let a=i.name??`unknown`;for(let i of n){let n=await this.writeIgnoreFile(e,t,i,`project:${a}/${i.fileName}`);r.push(n)}}return{files:r,dirs:i}}async writeIgnoreFile(e,t,n,r){let i=f.join(t.path,n.fileName),a=f.join(t.basePath,i),o={pathKind:L.Relative,path:i,basePath:t.basePath,getDirectoryName:()=>f.basename(t.path),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{return d.writeFileSync(a,n.content,`utf8`),this.log.trace({action:`write`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`ignoreFile`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}};const Ig=`.agent`,Lg=`antigravity`,Rg=`skills`,zg=`workflows`,Bg=`mcp_config.json`,Vg=[Rg,zg];var Hg=class extends Og{constructor(){super(`AntigravityOutputPlugin`,{globalConfigDir:Ig,outputFileName:``,dependsOn:[`GeminiCLIOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=f.join(this.getAntigravityDir(),Bg),n=JSON.stringify({mcpServers:{}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:t}),{success:!0,description:`Would reset mcp_config.json`};let r=await this.writeFile(e,t,n,`mcpConfigCleanup`);return r.success?{success:!0,description:`Reset mcp_config.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getAntigravityDir(){return f.join(p.homedir(),`.gemini`,Lg)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(e.dirFromWorkspacePath!=null)for(let t of Vg)n.push(this.createRelativePath(f.join(e.dirFromWorkspacePath.path,Ig,t),e.dirFromWorkspacePath.basePath,()=>t));return n}async registerProjectOutputFiles(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=this.getAntigravityDir(),i=[];if(t!=null)for(let e of t){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),n=f.join(r,Rg,t);if(i.push(this.createRelativePath(`SKILL.md`,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)i.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)i.push(this.createRelativePath(r.relativePath,n,()=>t))}if(t?.some(e=>e.mcpConfig!=null)&&i.push(this.createRelativePath(Bg,r,()=>Lg)),n==null)return i;let a=this.getTransformOptionsFromContext(e),o=f.join(r,zg);for(let e of n)i.push(this.createRelativePath(this.transformFastCommandName(e,a),o,()=>zg));return i}async canWrite(e){let{fastCommands:t,skills:n}=e.collectedInputContext;return(t?.length??0)>0||(n?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],i=this.getAntigravityDir();if(t!=null){let n=f.join(i,zg);for(let i of t)r.push(await this.writeFastCommand(e,n,i))}if(n!=null){let t=f.join(i,Rg);for(let i of n)r.push(...await this.writeSkill(e,t,i));let a=await this.writeGlobalMcpConfig(e,i,n);a!=null&&r.push(a)}return this.log.info({action:`write`,message:`Synced ${r.length} files`,globalDir:i}),{files:r,dirs:[]}}async writeGlobalMcpConfig(e,t,n){let r={};for(let e of n)if(e.mcpConfig!=null)for(let[t,n]of Object.entries(e.mcpConfig.mcpServers))r[t]=this.transformMcpConfig(n);if(Object.keys(r).length===0)return null;let i=f.join(t,Bg),a=JSON.stringify({mcpServers:r},null,2);return this.writeFile(e,i,a,`globalMcpConfig`)}transformMcpConfig(e){let t={};for(let[n,r]of Object.entries(e))if(n===`url`)t.serverUrl=r;else if(n===`type`||n===`enabled`||n===`autoApprove`)continue;else t[n]=r;return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,i),o=typeof n.yamlFrontMatter?.description==`string`?{description:n.yamlFrontMatter.description}:{},s;if(n.rawMdxContent!=null){let e=n.rawMdxContent.replace(/^---\n[\s\S]*?\n---\n/,``);s=this.buildMarkdownContentWithRaw(e,o,n.rawFrontMatter)}else s=this.buildMarkdownContentWithRaw(n.content,o,n.rawFrontMatter);return this.writeFile(e,a,s,`fastCommand`)}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,i),o=f.join(a,`SKILL.md`),s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(r.push(await this.writeFile(e,o,s,`skill`)),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`);r.push(await this.writeFile(e,f.join(a,n),t.content,`skillRefDoc`))}if(n.resources!=null)for(let t of n.resources)r.push(await this.writeFile(e,f.join(a,t.relativePath),t.content,`skillResource`));return r}},Ug=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},Wg=class extends Ug{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},Gg=class extends Ug{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},Kg=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},qg=Object.defineProperty,Jg=(e,t)=>{let n={};for(var r in e)qg(n,r,{get:e[r],enumerable:!0});return t||qg(n,Symbol.toStringTag,{value:`Module`}),n};const Yg=new Map;function Xg(e,t){Yg.set(e,t)}function Zg(){return new Map(Yg)}function Qg(e){return Yg.has(e)}function $g(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?e_(r,t,n?.filePath):t_(r,t,n?.filePath)}function e_(e,t,n){let r=e.split(`.`),i=r[0];if(i==null||!(i in t))throw new Gg(i??``,e,n);let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null)throw new Wg(i,e,n);if(typeof a!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof a} in expression "${e}"`);let o=a;if(!(i in o))throw new Wg(i,e,n);a=o[i]}return n_(a)}function t_(e,t,n){let r=Object.keys(t),i=r.map(e=>t[e]);try{return n_(Function(...r,`return (${e})`)(...i))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new Gg(t[1],e,n)}let i=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${i}\nCause: ${r}`)}}function n_(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function r_(e,t){return e===null?!1:t.components.has(e)||Qg(e)}async function i_(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function a_(e,t,n){let r=e.name;if(r==null||r===``)return[];let i=t.components.get(r);if(i==null)return[];if(t.processingStack.includes(r)){let e=[...t.processingStack,r].join(` → `);throw Error(`Circular dependency detected: ${e}`)}let a={scope:t.scope,components:t.components,processingStack:[...t.processingStack,r],...t.basePath==null?{}:{basePath:t.basePath}},o=await i_(n);try{return await i(e,a,o)}catch(e){let n=e instanceof Error?e.message:String(e),i=t.processingStack.join(` → `);throw Error(`Failed to process component "${r}"${i===``?``:` (called from: ${i})`}:\n${n}`,{cause:e})}}function o_(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return l_(e,t);case`a`:return u_(e,t);case`strong`:case`b`:return d_(e,t);case`em`:case`i`:return f_(e,t);case`img`:return p_(e,t);case`blockquote`:return m_(e,t);default:return null}}function s_(e,t,n){let r=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return r==null?null:typeof r.value==`string`?r.value:r.value!=null&&typeof r.value==`object`&&r.value.type===`mdxJsxAttributeValueExpression`?$g(r.value.value,n.scope):r.value===null?``:null}function c_(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=$g(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=c_(r,t));return n}function l_(e,t){let n=null;for(let t of e.children){if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(t.type===`paragraph`&&`children`in t){let e=t.children;for(let t of e)if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(n!=null)break}}if(n==null)return null;let r=s_(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=c_(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function u_(e,t){let n=s_(e,`href`,t);if(n==null||n===``)return null;let r=c_(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:s_(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function d_(e,t){let n={type:`strong`,children:[{type:`text`,value:c_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function f_(e,t){let n={type:`emphasis`,children:[{type:`text`,value:c_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function p_(e,t){let n=s_(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:s_(e,`alt`,t)??``,title:s_(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function m_(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:c_(e,t)}]}]}]}function h_(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function g_(e,t,n){let r=e.data?.estree;if(r==null||r.body.length===0)return[];let i=r.body[0];return i?.type===`ExpressionStatement`?__(i.expression,t,n):[]}async function __(e,t,n){return e.type===`JSXElement`?C_(e,t,n):e.type===`JSXFragment`?w_(e,t,n):e.type===`LogicalExpression`?v_(e,t,n):e.type===`ConditionalExpression`?y_(e,t,n):e.type===`SequenceExpression`?b_(e,t,n):e.type===`ArrayExpression`?x_(e,t,n):N_(e,t)}async function v_(e,t,n){let r=await S_(e.left,t,n);return e.operator===`&&`?j_(r)?__(e.right,t,n):[]:e.operator===`||`?j_(r)?A_(e.left)?__(e.left,t,n):M_(r):__(e.right,t,n):e.operator===`??`?r==null?__(e.right,t,n):A_(e.left)?__(e.left,t,n):M_(r):[]}async function y_(e,t,n){return j_(await S_(e.test,t,n))?__(e.consequent,t,n):__(e.alternate,t,n)}async function b_(e,t,n){let r=[];for(let i of e.expressions){let e=await __(i,t,n);r.push(...e)}return r}async function x_(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await __(i.argument,t,n);r.push(...e)}else{let e=await __(i,t,n);r.push(...e)}return r}async function S_(e,t,n){if(A_(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await S_(e.argument,t,n);return e.operator===`!`?!j_(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await S_(e.left,t,n),i=await S_(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await S_(e.left,t,n);return e.operator===`&&`?j_(r)?S_(e.right,t,n):r:e.operator===`||`?j_(r)?r:S_(e.right,t,n):e.operator===`??`?r??S_(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await S_(e.object,t,n);if(r==null)return;if(e.computed)return r[await S_(e.property,t,n)];let{name:i}=e.property;return r[i]}if(e.type===`ConditionalExpression`)return j_(await S_(e.test,t,n))?S_(e.consequent,t,n):S_(e.alternate,t,n);let r=k_(e);if(r!==``)try{let e=$g(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function C_(e,t,n){let r=E_(e,t);if(r.name!=null&&r_(r.name,t)){let{processAst:e}=await Promise.resolve().then(()=>P_);return a_(r,t,e)}return o_(r,t)??(r.children.length>0?n(r.children,t):[])}async function w_(e,t,n){let r=[];for(let i of e.children){let e=await T_(i,t,n);r.push(...e)}return r}async function T_(e,t,n){if(e.type===`JSXElement`)return C_(e,t,n);if(e.type===`JSXFragment`)return w_(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:__(e.expression,t,n):e.type===`JSXSpreadChild`?__(e.expression,t,n):[]}function E_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=D_(n.name):n.name.type===`JSXNamespacedName`&&(r=`${n.name.namespace.name}:${n.name.name.name}`);let i=[];for(let e of n.attributes)if(e.type===`JSXAttribute`){let t=e.name.type===`JSXIdentifier`?e.name.name:`${e.name.namespace.name}:${e.name.name.name}`,n=null;e.value==null?n=null:e.value.type===`Literal`?n=String(e.value.value):e.value.type===`JSXExpressionContainer`&&e.value.expression.type!==`JSXEmptyExpression`&&(n={type:`mdxJsxAttributeValueExpression`,value:k_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${k_(e.argument)}`});let a=[];for(let n of e.children){let e=O_(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function D_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${D_(e.object)}.${e.property.name}`}function O_(e,t){if(e.type===`JSXText`){let{value:t}=e;return t.trim()===``?null:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}if(e.type===`JSXElement`)return[E_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=O_(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:k_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${k_(e.expression)}`}]}]:null}function k_(e){if(e.type===`Identifier`)return e.name;if(e.type===`Literal`)return typeof e.value==`string`?JSON.stringify(e.value):String(e.value);if(e.type===`MemberExpression`){let t=k_(e.object);return e.computed?`${t}[${k_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${k_(e.callee)}(${e.arguments.map(e=>k_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=k_(e.left),n=k_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=k_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${k_(e.test)} ? ${k_(e.consequent)} : ${k_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>k_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:k_(e.key)}: ${k_(e.value)}`).join(`, `)}}`;if(e.type===`TemplateLiteral`){let t="`";for(let n=0;n<e.quasis.length;n++)t+=e.quasis[n]?.value.raw??``,n<e.expressions.length&&(t+=`\${${k_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${k_(e.argument)}`:``}function A_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function j_(e){return!!e}function M_(e){if(e==null)return[];let t=typeof e==`string`?e:String(e);return t===``||t===`undefined`||t===`null`?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}function N_(e,t){let n=k_(e);if(n===``)return[];try{return M_($g(n,t.scope))}catch{return[]}}var P_=Jg({processAst:()=>I_});function F_(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function I_(e,t){return L_(e,t)}async function L_(e,t){let n=[];for(let r of e.children){let e=await R_(r,t);n.push(...e)}return{type:`root`,children:n}}async function R_(e,t){if(e.type===`mdxjsEsm`)return[];if(e.type===`mdxFlowExpression`){let n=e,r=n.data?.estree,i=n.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))return[];if(h_(r))return g_(n,t,async(e,t)=>(await I_({type:`root`,children:e},t)).children);let a=$g(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return z_(e,t);if(e.type===`link`){let n=e,r=(await B_(n.children,t)).map(e=>e.type===`text`?{...e,value:F_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await B_(e.children,t);return[{...e,children:n}]}async function z_(e,t){return e.name!=null&&r_(e.name,t)?a_(e,t,I_):o_(e,t)??[]}async function B_(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:$g(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&r_(e.name,t)){let r=await a_(e,t,I_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=o_(e,t);if(i!=null)for(let e of i)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}if(`children`in r&&Array.isArray(r.children)){let e=await B_(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:F_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}function V_(e){let t=this;t.compiler=n;function n(n){return Po(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function H_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a}=t;for(let t of e){let e=U_(t,i,a);Object.assign(n,e)}let o=Object.keys(n).length>0,s=r!=null&&Object.keys(r).length>0,c;return c=o&&s?`mixed`:o?`export`:`yaml`,{fields:{...r,...n},source:c}}function U_(e,t,n){let r={},i=e.value.trim(),a=/^export\s+default\s+/.exec(i);if(a!=null){let e=a[0].length,o=W_(i,e);if(o!=null)try{let e=G_(o.trim(),t,n);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(e){let t=e instanceof Error?e.message:String(e),r=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export default${r}: ${t}`)}return r}let o=/export\s+const\s+(\w+)\s*=\s*/g,s=o.exec(i);for(;s!==null;){let e=s[1];if(e==null){s=o.exec(i);continue}let a=W_(i,s.index+s[0].length);if(a==null){s=o.exec(i);continue}try{let i=G_(a.trim(),t,n);e===`metadata`&&typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(r,i):r[e]=i}catch(t){let r=t instanceof Error?t.message:String(t),i=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export "${e}"${i}: ${r}`)}s=o.exec(i)}return r}function W_(e,t){let n=0,r=null,i=!1,a=t;for(let o=t;o<e.length;o++){let t=e[o];if(i){i=!1;continue}if(t===`\\`){i=!0;continue}if(r!=null){t===r&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`||t===`[`){n++;continue}if(t===`}`||t===`]`){n--;continue}if(n===0){if(t===`;`||t===`
1197
+ `,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`-`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}getRegistryWriter(e){let t=e.name,n=this.registryWriterCache.get(t);if(n!=null)return n;let r=new e(this.log);return this.registryWriterCache.set(t,r),r}async registerInRegistry(e,t,n){return e.register(t,n.dryRun)}};const kg=`AGENTS.md`;var Ag=class extends Og{constructor(){super(`AgentsOutputPlugin`,{outputFileName:kg})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,kg)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,kg));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}},jg=class extends Dg{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,bt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:m.spawn,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(Ut.USER_HOME)&&(r=r.replace(Ut.USER_HOME,p.homedir())),r.includes(Ut.SHADOW_SOURCE_PROJECT)&&(r=r.replace(Ut.SHADOW_SOURCE_PROJECT,n)),r.includes(Ut.WORKSPACE)&&(r=r.replace(Ut.WORKSPACE,t)),f.normalize(r)}readAndParseMarkdown(e,t){return Tg(t.readFileSync(e,`utf8`))}};const Mg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`,`.codeignore`];var Ng=class extends jg{constructor(){super(`AIAgentIgnoreConfigFileInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{shadowProjectDir:a}=this.resolveBasePaths(t),o=[];for(let e of Mg){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf8`);o.push({fileName:e,content:i}),n.debug(`read ignore file`,{path:t})}catch(e){n.warn(`failed to read ignore file`,{path:t,error:e})}}return{aiAgentIgnoreConfigFiles:o}}};const Pg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var Fg=class extends Og{constructor(){super(`AIAgentIgnoreConfigFileOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.isPromptSourceProject!==!0)for(let n of Pg){let r=f.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:L.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>f.basename(e.dirFromWorkspacePath.path),getAbsolutePath:()=>f.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{aiAgentIgnoreConfigFiles:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no ignore config files to write`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{aiAgentIgnoreConfigFiles:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){let t=i.dirFromWorkspacePath;if(t==null)continue;let a=i.name??`unknown`;for(let i of n){let n=await this.writeIgnoreFile(e,t,i,`project:${a}/${i.fileName}`);r.push(n)}}return{files:r,dirs:i}}async writeIgnoreFile(e,t,n,r){let i=f.join(t.path,n.fileName),a=f.join(t.basePath,i),o={pathKind:L.Relative,path:i,basePath:t.basePath,getDirectoryName:()=>f.basename(t.path),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{return d.writeFileSync(a,n.content,`utf8`),this.log.trace({action:`write`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`ignoreFile`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}};const Ig=`.agent`,Lg=`antigravity`,Rg=`skills`,zg=`workflows`,Bg=`mcp_config.json`,Vg=[Rg,zg];var Hg=class extends Og{constructor(){super(`AntigravityOutputPlugin`,{globalConfigDir:Ig,outputFileName:``,dependsOn:[`GeminiCLIOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=f.join(this.getAntigravityDir(),Bg),n=JSON.stringify({mcpServers:{}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:t}),{success:!0,description:`Would reset mcp_config.json`};let r=await this.writeFile(e,t,n,`mcpConfigCleanup`);return r.success?{success:!0,description:`Reset mcp_config.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getAntigravityDir(){return f.join(p.homedir(),`.gemini`,Lg)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(e.dirFromWorkspacePath!=null)for(let t of Vg)n.push(this.createRelativePath(f.join(e.dirFromWorkspacePath.path,Ig,t),e.dirFromWorkspacePath.basePath,()=>t));return n}async registerProjectOutputFiles(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=this.getAntigravityDir(),i=[];if(t!=null)for(let e of t){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),n=f.join(r,Rg,t);if(i.push(this.createRelativePath(`SKILL.md`,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)i.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)i.push(this.createRelativePath(r.relativePath,n,()=>t))}if(t?.some(e=>e.mcpConfig!=null)&&i.push(this.createRelativePath(Bg,r,()=>Lg)),n==null)return i;let a=this.getTransformOptionsFromContext(e),o=f.join(r,zg);for(let e of n)i.push(this.createRelativePath(this.transformFastCommandName(e,a),o,()=>zg));return i}async canWrite(e){let{fastCommands:t,skills:n}=e.collectedInputContext;return(t?.length??0)>0||(n?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],i=this.getAntigravityDir();if(t!=null){let n=f.join(i,zg);for(let i of t)r.push(await this.writeFastCommand(e,n,i))}if(n!=null){let t=f.join(i,Rg);for(let i of n)r.push(...await this.writeSkill(e,t,i));let a=await this.writeGlobalMcpConfig(e,i,n);a!=null&&r.push(a)}return this.log.info({action:`write`,message:`Synced ${r.length} files`,globalDir:i}),{files:r,dirs:[]}}async writeGlobalMcpConfig(e,t,n){let r={};for(let e of n)if(e.mcpConfig!=null)for(let[t,n]of Object.entries(e.mcpConfig.mcpServers))r[t]=this.transformMcpConfig(n);if(Object.keys(r).length===0)return null;let i=f.join(t,Bg),a=JSON.stringify({mcpServers:r},null,2);return this.writeFile(e,i,a,`globalMcpConfig`)}transformMcpConfig(e){let t={};for(let[n,r]of Object.entries(e))if(n===`url`)t.serverUrl=r;else if(n===`type`||n===`enabled`||n===`autoApprove`)continue;else t[n]=r;return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,i),o=typeof n.yamlFrontMatter?.description==`string`?{description:n.yamlFrontMatter.description}:{},s;if(n.rawMdxContent!=null){let e=n.rawMdxContent.replace(/^---\n[\s\S]*?\n---\n/,``);s=this.buildMarkdownContentWithRaw(e,o,n.rawFrontMatter)}else s=this.buildMarkdownContentWithRaw(n.content,o,n.rawFrontMatter);return this.writeFile(e,a,s,`fastCommand`)}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,i),o=f.join(a,`SKILL.md`),s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(r.push(await this.writeFile(e,o,s,`skill`)),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`);r.push(await this.writeFile(e,f.join(a,n),t.content,`skillRefDoc`))}if(n.resources!=null)for(let t of n.resources)r.push(await this.writeFile(e,f.join(a,t.relativePath),t.content,`skillResource`));return r}},Ug=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},Wg=class extends Ug{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},Gg=class extends Ug{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},Kg=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},qg=Object.defineProperty,Jg=(e,t)=>{let n={};for(var r in e)qg(n,r,{get:e[r],enumerable:!0});return t||qg(n,Symbol.toStringTag,{value:`Module`}),n};const Yg=new Map;function Xg(e,t){Yg.set(e,t)}function Zg(){return new Map(Yg)}function Qg(e){return Yg.has(e)}function $g(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?e_(r,t,n?.filePath):t_(r,t,n?.filePath)}function e_(e,t,n){let r=e.split(`.`),i=r[0];if(i==null||!(i in t))throw new Gg(i??``,e,n);let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null)throw new Wg(i,e,n);if(typeof a!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof a} in expression "${e}"`);let o=a;if(!(i in o))throw new Wg(i,e,n);a=o[i]}return n_(a)}function t_(e,t,n){let r=Object.keys(t),i=r.map(e=>t[e]);try{return n_(Function(...r,`return (${e})`)(...i))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new Gg(t[1],e,n)}let i=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${i}\nCause: ${r}`)}}function n_(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function r_(e,t){return e===null?!1:t.components.has(e)||Qg(e)}async function i_(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function a_(e,t,n){let r=e.name;if(r==null||r===``)return[];let i=t.components.get(r);if(i==null)return[];if(t.processingStack.includes(r)){let e=[...t.processingStack,r].join(` → `);throw Error(`Circular dependency detected: ${e}`)}let a={scope:t.scope,components:t.components,processingStack:[...t.processingStack,r],...t.basePath==null?{}:{basePath:t.basePath}},o=await i_(n);try{return await i(e,a,o)}catch(e){let n=e instanceof Error?e.message:String(e),i=t.processingStack.join(` → `);throw Error(`Failed to process component "${r}"${i===``?``:` (called from: ${i})`}:\n${n}`,{cause:e})}}function o_(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return l_(e,t);case`a`:return u_(e,t);case`strong`:case`b`:return d_(e,t);case`em`:case`i`:return f_(e,t);case`img`:return p_(e,t);case`blockquote`:return m_(e,t);default:return null}}function s_(e,t,n){let r=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return r==null?null:typeof r.value==`string`?r.value:r.value!=null&&typeof r.value==`object`&&r.value.type===`mdxJsxAttributeValueExpression`?$g(r.value.value,n.scope):r.value===null?``:null}function c_(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=$g(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=c_(r,t));return n}function l_(e,t){let n=null;for(let t of e.children){if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(t.type===`paragraph`&&`children`in t){let e=t.children;for(let t of e)if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(n!=null)break}}if(n==null)return null;let r=s_(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=c_(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function u_(e,t){let n=s_(e,`href`,t);if(n==null||n===``)return null;let r=c_(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:s_(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function d_(e,t){let n={type:`strong`,children:[{type:`text`,value:c_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function f_(e,t){let n={type:`emphasis`,children:[{type:`text`,value:c_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function p_(e,t){let n=s_(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:s_(e,`alt`,t)??``,title:s_(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function m_(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:c_(e,t)}]}]}]}function h_(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function g_(e,t,n){let r=e.data?.estree;if(r==null||r.body.length===0)return[];let i=r.body[0];return i?.type===`ExpressionStatement`?__(i.expression,t,n):[]}async function __(e,t,n){return e.type===`JSXElement`?C_(e,t,n):e.type===`JSXFragment`?w_(e,t,n):e.type===`LogicalExpression`?v_(e,t,n):e.type===`ConditionalExpression`?y_(e,t,n):e.type===`SequenceExpression`?b_(e,t,n):e.type===`ArrayExpression`?x_(e,t,n):N_(e,t)}async function v_(e,t,n){let r=await S_(e.left,t,n);return e.operator===`&&`?j_(r)?__(e.right,t,n):[]:e.operator===`||`?j_(r)?A_(e.left)?__(e.left,t,n):M_(r):__(e.right,t,n):e.operator===`??`?r==null?__(e.right,t,n):A_(e.left)?__(e.left,t,n):M_(r):[]}async function y_(e,t,n){return j_(await S_(e.test,t,n))?__(e.consequent,t,n):__(e.alternate,t,n)}async function b_(e,t,n){let r=[];for(let i of e.expressions){let e=await __(i,t,n);r.push(...e)}return r}async function x_(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await __(i.argument,t,n);r.push(...e)}else{let e=await __(i,t,n);r.push(...e)}return r}async function S_(e,t,n){if(A_(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await S_(e.argument,t,n);return e.operator===`!`?!j_(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await S_(e.left,t,n),i=await S_(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await S_(e.left,t,n);return e.operator===`&&`?j_(r)?S_(e.right,t,n):r:e.operator===`||`?j_(r)?r:S_(e.right,t,n):e.operator===`??`?r??S_(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await S_(e.object,t,n);if(r==null)return;if(e.computed)return r[await S_(e.property,t,n)];let{name:i}=e.property;return r[i]}if(e.type===`ConditionalExpression`)return j_(await S_(e.test,t,n))?S_(e.consequent,t,n):S_(e.alternate,t,n);let r=k_(e);if(r!==``)try{let e=$g(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function C_(e,t,n){let r=E_(e,t);if(r.name!=null&&r_(r.name,t)){let{processAst:e}=await Promise.resolve().then(()=>P_);return a_(r,t,e)}return o_(r,t)??(r.children.length>0?n(r.children,t):[])}async function w_(e,t,n){let r=[];for(let i of e.children){let e=await T_(i,t,n);r.push(...e)}return r}async function T_(e,t,n){if(e.type===`JSXElement`)return C_(e,t,n);if(e.type===`JSXFragment`)return w_(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:__(e.expression,t,n):e.type===`JSXSpreadChild`?__(e.expression,t,n):[]}function E_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=D_(n.name):n.name.type===`JSXNamespacedName`&&(r=`${n.name.namespace.name}:${n.name.name.name}`);let i=[];for(let e of n.attributes)if(e.type===`JSXAttribute`){let t=e.name.type===`JSXIdentifier`?e.name.name:`${e.name.namespace.name}:${e.name.name.name}`,n=null;e.value==null?n=null:e.value.type===`Literal`?n=String(e.value.value):e.value.type===`JSXExpressionContainer`&&e.value.expression.type!==`JSXEmptyExpression`&&(n={type:`mdxJsxAttributeValueExpression`,value:k_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${k_(e.argument)}`});let a=[];for(let n of e.children){let e=O_(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function D_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${D_(e.object)}.${e.property.name}`}function O_(e,t){if(e.type===`JSXText`){let{value:t}=e;return t.trim()===``?null:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}if(e.type===`JSXElement`)return[E_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=O_(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:k_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${k_(e.expression)}`}]}]:null}function k_(e){if(e.type===`Identifier`)return e.name;if(e.type===`Literal`)return typeof e.value==`string`?JSON.stringify(e.value):String(e.value);if(e.type===`MemberExpression`){let t=k_(e.object);return e.computed?`${t}[${k_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${k_(e.callee)}(${e.arguments.map(e=>k_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=k_(e.left),n=k_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=k_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${k_(e.test)} ? ${k_(e.consequent)} : ${k_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>k_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:k_(e.key)}: ${k_(e.value)}`).join(`, `)}}`;if(e.type===`TemplateLiteral`){let t="`";for(let n=0;n<e.quasis.length;n++)t+=e.quasis[n]?.value.raw??``,n<e.expressions.length&&(t+=`\${${k_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${k_(e.argument)}`:``}function A_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function j_(e){return!!e}function M_(e){if(e==null)return[];let t=typeof e==`string`?e:String(e);return t===``||t===`undefined`||t===`null`?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}function N_(e,t){let n=k_(e);if(n===``)return[];try{return M_($g(n,t.scope))}catch{return[]}}var P_=Jg({processAst:()=>I_});function F_(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function I_(e,t){return L_(e,t)}async function L_(e,t){let n=[];for(let r of e.children){let e=await R_(r,t);n.push(...e)}return{type:`root`,children:n}}async function R_(e,t){if(e.type===`mdxjsEsm`)return[];if(e.type===`mdxFlowExpression`){let n=e,r=n.data?.estree,i=n.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))return[];if(h_(r))return g_(n,t,async(e,t)=>(await I_({type:`root`,children:e},t)).children);let a=$g(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return z_(e,t);if(e.type===`link`){let n=e,r=(await B_(n.children,t)).map(e=>e.type===`text`?{...e,value:F_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await B_(e.children,t);return[{...e,children:n}]}async function z_(e,t){return e.name!=null&&r_(e.name,t)?a_(e,t,I_):o_(e,t)??[]}async function B_(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:$g(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&r_(e.name,t)){let r=await a_(e,t,I_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=o_(e,t);if(i!=null)for(let e of i)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}if(`children`in r&&Array.isArray(r.children)){let e=await B_(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:F_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}function V_(e){let t=this;t.compiler=n;function n(n){return Po(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function H_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a}=t;for(let t of e){let e=U_(t,i,a);Object.assign(n,e)}let o=Object.keys(n).length>0,s=r!=null&&Object.keys(r).length>0,c;return c=o&&s?`mixed`:o?`export`:`yaml`,{fields:{...r,...n},source:c}}function U_(e,t,n){let r={},i=e.value.trim(),a=/^export\s+default\s+/.exec(i);if(a!=null){let e=a[0].length,o=W_(i,e);if(o!=null)try{let e=G_(o.trim(),t,n);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(e){let t=e instanceof Error?e.message:String(e),r=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export default${r}: ${t}`)}return r}let o=/export\s+const\s+(\w+)\s*=\s*/g,s=o.exec(i);for(;s!==null;){let e=s[1];if(e==null){s=o.exec(i);continue}let a=W_(i,s.index+s[0].length);if(a==null){s=o.exec(i);continue}try{let i=G_(a.trim(),t,n);e===`metadata`&&typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(r,i):r[e]=i}catch(t){let r=t instanceof Error?t.message:String(t),i=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export "${e}"${i}: ${r}`)}s=o.exec(i)}return r}function W_(e,t){let n=0,r=null,i=!1,a=t;for(let o=t;o<e.length;o++){let t=e[o];if(i){i=!1;continue}if(t===`\\`){i=!0;continue}if(r!=null){t===r&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`||t===`[`){n++;continue}if(t===`}`||t===`]`){n--;continue}if(n===0){if(t===`;`||t===`
873
1198
  `){a=o;break}if(t===`/`&&o+1<e.length&&e[o+1]===`/`){a=o;break}}o===e.length-1&&(a=e.length)}a<=t&&(a=e.length);let o=e.slice(t,a).trim();return o.endsWith(`;`)?o.slice(0,-1).trim():o}function G_(e,t,n){let r=e.trim();if(r===``)throw Error(`Empty value cannot be evaluated`);if(r===`true`)return!0;if(r===`false`)return!1;if(r===`null`)return null;if(/^-?\d+(?:\.\d+)?$/.test(r))return Number(r);if(r.startsWith(`"`)&&r.endsWith(`"`))return K_(r.slice(1,-1),`"`);if(r.startsWith(`'`)&&r.endsWith(`'`))return K_(r.slice(1,-1),`'`);if(r.startsWith("`")&&r.endsWith("`")){let e=r.slice(1,-1);if(e.includes("${"))throw Error(`Template literal with expressions cannot be statically evaluated: ${r}`);return K_(e,"`")}if(r.startsWith(`[`)&&r.endsWith(`]`))return J_(r,t,n);if(r.startsWith(`{`)&&r.endsWith(`}`))return Y_(r,t,n);if(/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r))return q_(r,t,n);let i=n==null?``:` in file "${n}"`;throw Error(`Expression "${r}" cannot be statically evaluated${i}`)}function K_(e,t){return e.replaceAll(`\\n`,`
874
1199
  `).replaceAll(`\\r`,`\r`).replaceAll(`\\t`,` `).replaceAll(`\\"`,`"`).replaceAll(`\\'`,`'`).replaceAll(`\\\\`,`\\`)}function q_(e,t,n){if(t==null){let t=n==null?``:` in file "${n}"`;throw Error(`Variable reference "${e}" cannot be resolved without scope${t}`)}let r=e.split(`.`),i=r[0];if(i==null||!(i in t)){let r=n==null?``:` in file "${n}"`,a=Object.keys(t).join(`, `);throw Error(`Undefined namespace "${i}" in expression "${e}"${r}. Available: ${a}`)}let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null){let t=n==null?``:` in file "${n}"`;throw Error(`Cannot read property "${i}" of null/undefined in "${e}"${t}`)}if(typeof a!=`object`){let t=n==null?``:` in file "${n}"`;throw Error(`Cannot read property "${i}" of ${typeof a} in "${e}"${t}`)}let o=a;if(!(i in o)){let t=n==null?``:` in file "${n}"`,r=Object.keys(o).join(`, `);throw Error(`Undefined property "${i}" in "${e}"${t}. Available: ${r}`)}a=o[i]}if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`||a===null||Array.isArray(a)||typeof a==`object`)return a;let o=n==null?``:` in file "${n}"`;throw Error(`Variable "${e}" resolved to unsupported type: ${typeof a}${o}`)}function J_(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return[];if(t==null)try{let t=X_(e),n=JSON.parse(t);if(Array.isArray(n))return n}catch{}return Z_(r).map(e=>G_(e.trim(),t,n))}function Y_(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return{};if(t==null)try{let t=X_(e),n=JSON.parse(t);if(typeof n==`object`&&n&&!Array.isArray(n))return n}catch{}let i={},a=Q_(r);for(let e of a){let r=$_(e);if(r===-1)continue;let a=e.slice(0,r).trim(),o=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i[a]=G_(o,t,n)}return i}function X_(e){let t=``,n=null,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(n!=null){a===n?(t+=`"`,n=null):a===`"`&&n===`'`?t+=`\\"`:t+=a;continue}if(a===`"`||a===`'`){t+=`"`,n=a;continue}if(a===`:`&&i>0){let e=t.length-1;for(;e>=0&&/\s/.test(t.charAt(e));)e--;let n=e+1;for(;e>=0&&/[\w$]/.test(t.charAt(e));)e--;if(e++,e>0&&t.charAt(e-1)!==`"`){let r=t.slice(e,n);r.length>0&&/^[\w$]+$/.test(r)&&(t=`${t.slice(0,e)}"${r}"`)}}t+=a}return t}function Z_(e){let t=[],n=``,r=0,i=null,a=!1;for(let o of e){if(a){n+=o,a=!1;continue}if(o===`\\`){n+=o,a=!0;continue}if(i!=null){n+=o,o===i&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){n+=o,i=o;continue}if(o===`[`||o===`{`){r++,n+=o;continue}if(o===`]`||o===`}`){r--,n+=o;continue}if(o===`,`&&r===0){n.trim()!==``&&t.push(n.trim()),n=``;continue}n+=o}return n.trim()!==``&&t.push(n.trim()),t}function Q_(e){return Z_(e)}function $_(e){let t=null,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){n=!1;continue}if(i===`\\`){n=!0;continue}if(t!=null){i===t&&(t=null);continue}if(i===`"`||i===`'`||i==="`"){t=i;continue}if(i===`:`)return r}return-1}function ev(e,t){let n=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===`when`);if(n?.type!==`mdxJsxAttribute`)return!0;if(typeof n.value==`string`)return n.value===`true`;if(n.value!=null&&typeof n.value==`object`&&n.value.type===`mdxJsxAttributeValueExpression`)try{let e=$g(n.value.value,t.scope);return e===`true`||e===`1`}catch{return!1}return!1}async function tv(e,t,n){return!ev(e,t)||e.children.length===0?[]:n(e.children,t)}async function nv(e,t){if(!ev(e,t)||e.children.length===0)return[];let n=rv(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function rv(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=$g(r.value,t.scope)}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=rv(r.children,t));return n}function iv(){Xg(`Md`,tv),Xg(`Md.Line`,nv)}iv();function av(e,t){let n={};if(e!=null&&(n.os={...e.os},n.env={...e.env},n.profile={...e.profile},n.tool={...e.tool}),t!=null)for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof t==`object`&&t&&!Array.isArray(t)?{...t,...r}:r}return n}async function ov(e,t){let n=ah(e),r=av(t?.globalScope,t?.scope),i=Zg(),a;if(t?.extractMetadata===!0){let e=n.children.find(e=>e.type===`yaml`),i;if(e!=null)try{i=Sg.parse(e.value)}catch{}a=H_(n.children.filter(e=>e.type===`mdxjsEsm`),{...i!=null&&{yamlFrontMatter:i},scope:r,...t?.basePath!=null&&{filePath:t.basePath}}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await I_(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath}}),s=su().use(Qr,[`yaml`]).use(Vl).use(V_,{bullet:`-`,fence:"`",fences:!0,emphasis:`*`,strong:`*`,rule:`-`,handlers:{text(e){return e.value}}}).stringify(o).trim();return t?.extractMetadata===!0&&a!=null?{content:s,metadata:a}:s}var sv=class extends Og{commandsSubDir;agentsSubDir;skillsSubDir;supportsFastCommands;supportsSubAgents;supportsSkills;toolPreset;constructor(e,t){super(e,t),this.commandsSubDir=t.commandsSubDir??`commands`,this.agentsSubDir=t.agentsSubDir??`agents`,this.skillsSubDir=t.skillsSubDir??`skills`,this.supportsFastCommands=t.supportsFastCommands??!0,this.supportsSubAgents=t.supportsSubAgents??!0,this.supportsSkills=t.supportsSkills??!0,t.toolPreset!==void 0&&(this.toolPreset=t.toolPreset)}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[],r=[];this.supportsFastCommands&&r.push(this.commandsSubDir),this.supportsSubAgents&&r.push(this.agentsSubDir),this.supportsSkills&&r.push(this.skillsSubDir);for(let e of r)n.push(this.createRelativePath(e,t,()=>e));return n}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=[];if(this.supportsFastCommands&&r.push(this.commandsSubDir),this.supportsSubAgents&&r.push(this.agentsSubDir),this.supportsSkills&&r.push(this.skillsSubDir),r.length===0)return[];for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of r){let r=f.join(e.dirFromWorkspacePath.path,this.globalConfigDir,n);t.push(this.createRelativePath(r,e.dirFromWorkspacePath.basePath,()=>n))}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,this.outputFileName)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,this.outputFileName));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir(),r=[this.createRelativePath(this.outputFileName,n,()=>this.globalConfigDir)],{fastCommands:i,subAgents:a,skills:o}=e.collectedInputContext,s={includeSeriesPrefix:!0};if(this.supportsFastCommands&&i!=null)for(let e of i){let t=this.transformFastCommandName(e,s);r.push(this.createRelativePath(f.join(this.commandsSubDir,t),n,()=>this.commandsSubDir))}if(this.supportsSubAgents&&a!=null)for(let e of a){let t=e.dir.path.endsWith(`.md`)?e.dir.path:`${e.dir.path}.md`;r.push(this.createRelativePath(f.join(this.agentsSubDir,t),n,()=>this.agentsSubDir))}if(this.supportsSkills&&o!=null)for(let e of o){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),i=f.join(this.skillsSubDir,t);if(r.push(this.createRelativePath(f.join(i,`SKILL.md`),n,()=>t)),e.childDocs!=null)for(let a of e.childDocs){let e=a.dir.path.replace(/\.mdx$/,`.md`),o=f.join(i,e);r.push(this.createRelativePath(o,n,()=>t))}if(e.resources!=null)for(let a of e.resources){let e=f.join(i,a.relativePath);r.push(this.createRelativePath(e,n,()=>t))}}return r}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,subAgents:i,skills:a}=e.collectedInputContext,o=t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0),s=n!=null,c=this.supportsFastCommands&&(r?.length??0)>0,l=this.supportsSubAgents&&(i?.length??0)>0,u=this.supportsSkills&&(a?.length??0)>0;return o||s||c||l||u?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if([{enabled:!0,data:t},{enabled:this.supportsFastCommands,data:e.collectedInputContext.fastCommands},{enabled:this.supportsSubAgents,data:e.collectedInputContext.subAgents},{enabled:this.supportsSkills,data:e.collectedInputContext.skills}].every(e=>!e.enabled||e.data==null))return{files:n,dirs:r};let{fastCommands:i,subAgents:a,skills:o}=e.collectedInputContext,s=this.getGlobalConfigDir();if(t!=null){let r=f.join(s,this.outputFileName),i=this.createRelativePath(this.outputFileName,s,()=>this.globalConfigDir);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),n.push({path:i,success:!0,skipped:!1});else try{it(r,t.content),this.log.trace({action:`write`,type:`globalMemory`,path:r}),n.push({path:i,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),n.push({path:i,success:!1,error:e})}}if(this.supportsFastCommands&&i!=null)for(let t of i){let r=await this.writeFastCommand(e,s,t);n.push(...r)}if(this.supportsSubAgents&&a!=null)for(let t of a){let r=await this.writeSubAgent(e,s,t);n.push(...r)}if(this.supportsSkills&&o!=null)for(let t of o){let r=await this.writeSkill(e,s,t);n.push(...r)}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,this.commandsSubDir),o=f.join(a,i),s=n.content,c=n.yamlFrontMatter,l=!1;if(n.rawMdxContent!=null&&this.toolPreset!=null){this.log.debug(`recompiling fast command with tool preset`,{file:n.dir.getAbsolutePath(),toolPreset:this.toolPreset,hasRawContent:!0});try{let e=new tr({toolPreset:this.toolPreset}).collect(),t=await ov(n.rawMdxContent,{globalScope:e,extractMetadata:!0,basePath:n.dir.basePath});s=t.content,c=t.metadata.fields,l=!0}catch(e){this.log.warn(`failed to recompile fast command, using default`,{file:n.dir.getAbsolutePath(),error:e instanceof Error?e.message:String(e)})}}let u=l?this.buildMarkdownContent(s,c):this.buildMarkdownContentWithRaw(s,c,n.rawFrontMatter);return[await this.writeFile(e,o,u,`fastCommand`)]}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,i=f.join(t,this.agentsSubDir),a=f.join(i,r),o=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);return[await this.writeFile(e,a,o,`subAgent`)]}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,this.skillsSubDir,i),o=f.join(a,`SKILL.md`),s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter),c=await this.writeFile(e,o,s,`skill`);if(r.push(c),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}return r}async writeSkillReferenceDocument(e,t,n,r,i){let a=r.dir.path.replace(/\.mdx$/,`.md`),o=f.join(t,a);return[await this.writeFile(e,o,r.content,`skillRefDoc`)]}async writeSkillResource(e,t,n,r,i){let a=f.join(t,r.relativePath);return[await this.writeFile(e,a,r.content,`skillResource`)]}},cv=class extends sv{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:`.claude`,outputFileName:`CLAUDE.md`,toolPreset:`claudeCode`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0})}};const lv=`AGENTS.md`,uv=`.codex`,dv=`prompts`,fv=`skills`;var pv=class extends Og{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:uv,outputFileName:lv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(){return[]}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[this.createRelativePath(dv,t,()=>dv)],{skills:r}=e.collectedInputContext;if(r!=null&&r.length>0)for(let e of r){let r=e.yamlFrontMatter?.name??e.dir.getDirectoryName();n.push(this.createRelativePath(f.join(fv,r),t,()=>r))}return n}async registerGlobalOutputFiles(){let e=this.getGlobalConfigDir();return[this.createRelativePath(lv,e,()=>uv)]}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext;return t!=null||(n?.length??0)>0||(r?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(){return{files:[],dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getGlobalConfigDir();if(t!=null){let n=f.join(a,lv),r=await this.writeFile(e,n,t.content,`globalMemory`);i.push(r)}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,a,t);i.push(n)}if(r!=null&&r.length>0)for(let t of r){let n=await this.writeGlobalSkill(e,a,t);i.push(...n)}return{files:i,dirs:[]}}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,dv,i),o=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);return this.writeFile(e,a,o,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,fv,i),o=f.join(a,`SKILL.md`),s=this.buildCodexSkillContent(n),c=await this.writeFile(e,o,s,`globalSkill`);if(r.push(c),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`),i=f.join(a,n),o=await this.writeFile(e,i,t.content,`skillRefDoc`);r.push(o)}if(n.resources!=null)for(let t of n.resources){let n=f.join(a,t.relativePath),i=await this.writeFile(e,n,t.content,`skillResource`);r.push(i)}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),wg(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}};const mv=`.cursor`,hv=`mcp.json`,gv=`commands`,_v=`rules`,vv=`global.mdc`,yv=`skills-cursor`,bv=`SKILL.md`,xv=new Set([`create-rule`,`create-skill`,`create-subagent`,`migrate-to-skills`,`update-cursor-settings`]);var Sv=class extends Og{constructor(){super(`CursorOutputPlugin`,{globalConfigDir:mv,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=f.join(t,hv),r={mcpServers:{}};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset mcp.json to empty shell`};try{return this.ensureDirectory(t),d.writeFileSync(n,JSON.stringify(r,null,2)),this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset mcp.json to empty shell`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset mcp.json`}}})}async registerGlobalOutputDirs(e){let t=[],n=this.getGlobalConfigDir(),{fastCommands:r,skills:i}=e.collectedInputContext;if(r!=null&&r.length>0){let e=this.getGlobalCommandsDir();t.push({pathKind:L.Relative,path:gv,basePath:n,getDirectoryName:()=>gv,getAbsolutePath:()=>e})}if(i!=null&&i.length>0)for(let e of i){let r=e.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let i=f.join(n,yv,r);t.push({pathKind:L.Relative,path:f.join(yv,r),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i})}return t}async registerGlobalOutputFiles(e){let t=[],n=this.getGlobalConfigDir(),{skills:r,fastCommands:i}=e.collectedInputContext;if(r?.some(e=>e.mcpConfig!=null)??!1){let e=f.join(n,hv);t.push({pathKind:L.Relative,path:hv,basePath:n,getDirectoryName:()=>mv,getAbsolutePath:()=>e})}if(i!=null&&i.length>0){let r=this.getGlobalCommandsDir(),a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of i){let i=this.transformFastCommandName(e,a),o=f.join(r,i);t.push({pathKind:L.Relative,path:f.join(gv,i),basePath:n,getDirectoryName:()=>gv,getAbsolutePath:()=>o})}}if(r==null||r.length===0)return t;let a=this.getSkillsCursorDir();for(let e of r){let r=e.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let i=f.join(a,r);if(t.push({pathKind:L.Relative,path:f.join(yv,r,bv),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>f.join(i,bv)}),e.mcpConfig!=null&&t.push({pathKind:L.Relative,path:f.join(yv,r,hv),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>f.join(i,hv)}),e.childDocs!=null)for(let a of e.childDocs){let e=a.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:f.join(yv,r,e),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>f.join(i,e)})}if(e.resources!=null)for(let a of e.resources)t.push({pathKind:L.Relative,path:f.join(yv,r,a.relativePath),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>f.join(i,a.relativePath)})}return t}async registerProjectOutputDirs(e){let t=[],{workspace:n,globalMemory:r}=e.collectedInputContext;if(r==null)return t;for(let e of n.projects){let n=e.dirFromWorkspacePath;n!=null&&t.push(this.createProjectRulesDirRelativePath(n))}return t}async registerProjectOutputFiles(e){let t=[],{workspace:n,globalMemory:r}=e.collectedInputContext;if(r==null)return t;for(let e of n.projects){let n=e.dirFromWorkspacePath;n!=null&&t.push(this.createProjectRuleFileRelativePath(n,vv))}return t}async canWrite(e){let{workspace:t,skills:n,fastCommands:r,globalMemory:i}=e.collectedInputContext,a=(n?.length??0)>0,o=(r?.length??0)>0,s=i!=null&&t.projects.some(e=>e.dirFromWorkspacePath!=null);return a||o||s?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=[],i=[];if(t!=null&&t.length>0){let n=await this.writeGlobalMcpConfig(e,t);n!=null&&r.push(n);let i=this.getSkillsCursorDir();for(let n of t){let t=n.yamlFrontMatter.name;if(this.isPreservedSkill(t))continue;let a=await this.writeGlobalSkill(e,i,n);r.push(...a)}}if(n==null||n.length===0)return{files:r,dirs:i};let a=this.getGlobalCommandsDir();for(let t of n){let n=await this.writeGlobalFastCommand(e,a,t);r.push(n)}return{files:r,dirs:i}}async writeProjectOutputs(e){let t=[],n=[],{workspace:r,globalMemory:i}=e.collectedInputContext;if(i==null)return{files:t,dirs:n};let a=this.buildGlobalRuleContent(i.content);for(let n of r.projects){if(n.dirFromWorkspacePath==null)continue;let r=await this.writeProjectGlobalRule(e,n,a);t.push(r)}return{files:t,dirs:n}}createProjectRulesDirRelativePath(e){let t=f.join(e.path,mv,_v);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>_v,getAbsolutePath:()=>f.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=f.join(e.path,mv,_v,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>_v,getAbsolutePath:()=>f.join(e.basePath,n)}}buildGlobalRuleContent(e){return wg({description:`Global prompt (synced)`,alwaysApply:!0},e)}async writeProjectGlobalRule(e,t,n){let r=t.dirFromWorkspacePath,i=f.join(r.basePath,r.path,mv,_v),a=f.join(i,vv),o=this.createProjectRuleFileRelativePath(r,vv);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalRule`,path:a}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(i),this.writeFileSync(a,n),this.log.trace({action:`write`,type:`globalRule`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalRule`,path:a,error:t}),{path:o,success:!1,error:e}}}isPreservedSkill(e){return xv.has(e)}getSkillsCursorDir(){return f.join(this.getGlobalConfigDir(),yv)}getGlobalCommandsDir(){return f.join(this.getGlobalConfigDir(),gv)}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),i=this.transformFastCommandName(n,r),a=f.join(t,i),o={pathKind:L.Relative,path:f.join(gv,i),basePath:this.getGlobalConfigDir(),getDirectoryName:()=>gv,getAbsolutePath:()=>a},s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:a}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(t),d.writeFileSync(a,s),this.log.trace({action:`write`,type:`globalFastCommand`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalFastCommand`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForCursor({...r})}if(Object.keys(n).length===0)return null;let r=this.getGlobalConfigDir(),i=f.join(r,hv),a={pathKind:L.Relative,path:hv,basePath:r,getDirectoryName:()=>mv,getAbsolutePath:()=>i},o={};try{if(this.existsSync(i)){let e=d.readFileSync(i,`utf8`);o=JSON.parse(e)}}catch{o={}}let s={...o.mcpServers??{},...n};o.mcpServers=s;let c=JSON.stringify(o,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(r),d.writeFileSync(i,c),this.log.trace({action:`write`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}transformMcpConfigForCursor(e){let t={};if(e.command!=null)return t.command=e.command,e.args!=null&&(t.args=e.args),e.env!=null&&(t.env=e.env),t;let n=e.url??e.serverUrl;return n==null?t:(t.url=n,e.headers!=null&&(t.headers=e.headers),t)}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter.name,a=f.join(t,i),o=f.join(a,bv),s=this.getGlobalConfigDir(),c={pathKind:L.Relative,path:f.join(yv,i,bv),basePath:s,getDirectoryName:()=>i,getAbsolutePath:()=>o},l=this.buildSkillFrontMatter(n),u=n.content,d=wg(l,u);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:c,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,d),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:c,success:!1,error:e})}if(n.mcpConfig!=null){let t=await this.writeSkillMcpConfig(e,n,a,s);r.push(t)}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,a,i,s);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,a,i,s);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillMcpConfig(e,t,n,r){let i=t.yamlFrontMatter.name,a=f.join(n,hv),o={pathKind:L.Relative,path:f.join(yv,i,hv),basePath:r,getDirectoryName:()=>i,getAbsolutePath:()=>a},s=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:a}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`mcpConfig`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeSkillChildDoc(e,t,n,r,i){let a=t.relativePath.replace(/\.mdx$/,`.md`),o=f.join(n,a),s={pathKind:L.Relative,path:f.join(yv,r,a),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>o},c=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:o}),{path:s,success:!0,skipped:!1};try{let e=f.dirname(o);return this.ensureDirectory(e),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`childDoc`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:o,error:t}),{path:s,success:!1,error:e}}}async writeSkillResource(e,t,n,r,i){let a=f.join(n,t.relativePath),o={pathKind:L.Relative,path:f.join(yv,r,t.relativePath),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:a}),{path:o,success:!0,skipped:!1};try{let e=f.dirname(a);if(this.ensureDirectory(e),t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`);this.writeFileSyncBuffer(a,e)}else this.writeFileSync(a,t.content);return this.log.trace({action:`write`,type:`resource`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:a,error:t}),{path:o,success:!1,error:e}}}},Cv=class extends sv{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:`AGENTS.md`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0})}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,this.skillsSubDir,i),o=f.join(a,`SKILL.md`),s=n.yamlFrontMatter==null?void 0:{name:n.yamlFrontMatter.name,description:n.yamlFrontMatter.description},c=this.buildMarkdownContent(n.content,s),l=await this.writeFile(e,o,c,`skill`);if(r.push(l),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}return r}},wv=class extends jg{configKey;extension;constructor(e,t){super(e),this.configKey=t.configKey,this.extension=t.extension??`.mdx`}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.getTargetDir(t,o),c=[];if(!(i.existsSync(s)&&i.statSync(s).isDirectory()))return this.createResult(c);try{let e=i.readdirSync(s,{withFileTypes:!0});for(let t of e)if(t.isFile()&&t.name.endsWith(this.extension)){let e=r.join(s,t.name),o=i.readFileSync(e,`utf8`);try{let r=Tg(o),i=await ov(o,{globalScope:a,extractMetadata:!0,basePath:s}),l=r.yamlFrontMatter!=null||Object.keys(i.metadata.fields).length>0?{...r.yamlFrontMatter,...i.metadata.fields}:void 0;if(l!=null){let t=this.validateMetadata(l,e);for(let e of t.warnings)n.debug(e);if(!t.valid)throw new Kg([...t.errors],e)}let{content:u}=i;n.debug(`${this.name} metadata extracted`,{file:t.name,source:i.metadata.source,hasYaml:r.yamlFrontMatter!=null,hasExport:Object.keys(i.metadata.fields).length>0});let d=this.createPrompt(t.name,e,u,l,r.rawFrontMatter,r,s,o);c.push(d)}catch(t){n.error(`failed to parse ${this.name} item`,{file:e,error:t})}}}catch(e){n.error(`Failed to scan directory at ${s}`,{error:e})}return this.createResult(c)}},Tv=class extends wv{constructor(){super(`FastCommandInputPlugin`,{configKey:`shadowFastCommandDir`})}getTargetDir(e,t){let n=e.shadowFastCommandDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return jt(e,t)}createResult(e){return{fastCommands:e}}extractSeriesInfo(e,t){let n=e.replace(/\.mdx$/,``);if(t!=null)return{series:t,commandName:n};let r=n.indexOf(`_`);return r===-1?{commandName:n}:{series:n.slice(0,Math.max(0,r)),commandName:n.slice(Math.max(0,r+1))}}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i}=e,a=this.resolveBasePaths(t),o=this.getTargetDir(t,a),s=[];if(!(i.existsSync(o)&&i.statSync(o).isDirectory()))return this.createResult(s);try{let t=i.readdirSync(o,{withFileTypes:!0});for(let a of t)if(a.isFile()&&a.name.endsWith(this.extension)){let t=await this.processFile(a.name,r.join(o,a.name),o,void 0,e);t!=null&&s.push(t)}else if(a.isDirectory()){let t=r.join(o,a.name);try{let n=i.readdirSync(t,{withFileTypes:!0});for(let i of n)if(i.isFile()&&i.name.endsWith(this.extension)){let n=await this.processFile(i.name,r.join(t,i.name),o,a.name,e);n!=null&&s.push(n)}}catch(e){n.error(`Failed to scan subdirectory at ${t}`,{error:e})}}}catch(e){n.error(`Failed to scan directory at ${o}`,{error:e})}return this.createResult(s)}async processFile(e,t,n,r,i){let{logger:a,globalScope:o}=i,s=i.fs.readFileSync(t,`utf8`);try{let c=Tg(s),l=await ov(s,{globalScope:o,extractMetadata:!0,basePath:r==null?n:i.path.join(n,r)}),u=c.yamlFrontMatter!=null||Object.keys(l.metadata.fields).length>0?{...c.yamlFrontMatter,...l.metadata.fields}:void 0;if(u!=null){let e=this.validateMetadata(u,t);for(let t of e.warnings)a.debug(t);if(!e.valid)throw new Kg([...e.errors],t)}let{content:d}=l,f=r==null?e:`${r}/${e}`;return a.debug(`${this.name} metadata extracted`,{file:f,source:l.metadata.source,hasYaml:c.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),this.createPrompt(f,t,d,u,c.rawFrontMatter,c,n,s)}catch(e){a.error(`failed to parse ${this.name} item`,{file:t,error:e});return}}createPrompt(e,t,n,r,i,a,o,s){let c=e.indexOf(`/`),l=c===-1?void 0:e.slice(0,c),u=c===-1?e:e.slice(c+1),d=this.extractSeriesInfo(u,l);return{type:xt.FastCommand,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t},...d.series!=null&&{series:d.series},commandName:d.commandName,rawMdxContent:s}}},Ev=class extends sv{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:`GEMINI.md`,supportsFastCommands:!1,supportsSubAgents:!1,supportsSkills:!1})}};const Dv=`.skills`,Ov=`.aindex/.skills`,kv=`SKILL.md`,Av=`mcp.json`;var jv=class extends Og{constructor(){super(`GenericSkillsOutputPlugin`,{globalConfigDir:Ov,outputFileName:kv}),this.registerCleanEffect(`legacy-global-skills-cleanup`,async e=>{let t=this.joinPath(this.getHomeDir(),`.skills`);if(!this.existsSync(t))return{success:!0,description:`Legacy global skills dir does not exist, nothing to clean`};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`legacyCleanup`,path:t}),{success:!0,description:`Would clean legacy global skills dir: ${t}`};try{let e=this.readdirSync(t,{withFileTypes:!0}),n=0;for(let r of e)if(r.isDirectory()){let e=this.joinPath(t,r.name),i=this.joinPath(e,kv);this.existsSync(i)&&(d.rmSync(e,{recursive:!0}),n++)}return this.readdirSync(t).length===0&&d.rmdirSync(t),this.log.trace({action:`clean`,type:`legacySkills`,dir:t,cleanedCount:n}),{success:!0,description:`Cleaned ${n} legacy skills from ${t}`}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`legacySkills`,dir:t,error:n}),{success:!1,description:`Failed to clean legacy skills dir`,error:e}}})}getGlobalSkillsDir(){return this.joinPath(this.getHomeDir(),Ov)}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,Dv);t.push({pathKind:L.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>Dv,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path,Dv);for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(n,r);t.push({pathKind:L.Relative,path:this.joinPath(Dv,r),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>a})}}return t}async registerGlobalOutputDirs(e){let{skills:t}=e.collectedInputContext;if(t==null||t.length===0)return[];let n=this.getGlobalSkillsDir();return[{pathKind:L.Relative,path:Ov,basePath:this.getHomeDir(),getDirectoryName:()=>Ov,getAbsolutePath:()=>n}]}async registerGlobalOutputFiles(e){let t=[],{skills:n}=e.collectedInputContext;if(n==null||n.length===0)return t;let r=this.getGlobalSkillsDir();for(let e of n){let n=e.yamlFrontMatter.name,i=this.joinPath(r,n);if(t.push({pathKind:L.Relative,path:this.joinPath(Ov,n,kv),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,kv)}),e.mcpConfig!=null&&t.push({pathKind:L.Relative,path:this.joinPath(Ov,n,Av),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,Av)}),e.childDocs!=null)for(let r of e.childDocs){let e=r.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:this.joinPath(Ov,n,e),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,e)})}if(e.resources!=null)for(let r of e.resources)t.push({pathKind:L.Relative,path:this.joinPath(Ov,n,r.relativePath),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,r.relativePath)})}return t}async canWrite(e){let{skills:t}=e.collectedInputContext,{projects:n}=e.collectedInputContext.workspace;return t==null||t.length===0?(this.log.trace({action:`skip`,reason:`noSkills`}),!1):n.length===0?(this.log.trace({action:`skip`,reason:`noProjects`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{skills:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};let a=this.getGlobalSkillsDir();for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path,Dv);for(let o of n){let n=o.yamlFrontMatter.name,s=this.joinPath(a,n),c=this.joinPath(t,n),l={pathKind:L.Relative,path:this.joinPath(Dv,n),basePath:this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path),getDirectoryName:()=>n,getAbsolutePath:()=>c};if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`symlink`,target:s,link:c}),r.push({path:l,success:!0,skipped:!1});continue}try{this.createSymlink(s,c,`dir`),this.log.trace({action:`symlink`,type:`skill`,target:s,link:c}),r.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`symlink`,type:`skill`,target:s,link:c,error:t}),r.push({path:l,success:!1,error:e})}}}return{files:r,dirs:i}}async writeGlobalOutputs(e){let{skills:t}=e.collectedInputContext,n=[],r=[];if(t==null||t.length===0)return{files:n,dirs:r};let i=this.getGlobalSkillsDir();for(let r of t){let t=await this.writeSkill(e,r,i);n.push(...t)}return{files:n,dirs:r}}async writeSkill(e,t,n){let r=[],i=t.yamlFrontMatter.name,a=this.joinPath(n,i),o=this.joinPath(a,kv),s={pathKind:L.Relative,path:kv,basePath:a,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildSkillFrontMatter(t),l=t.content,u=wg(c,l);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:s,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,u),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}if(t.mcpConfig!=null){let n=await this.writeMcpConfig(e,t,a);r.push(n)}if(t.childDocs!=null)for(let n of t.childDocs){let t=await this.writeChildDoc(e,n,a,i);r.push(t)}if(t.resources!=null)for(let n of t.resources){let t=await this.writeResource(e,n,a,i);r.push(t)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,Av),a={pathKind:L.Relative,path:Av,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}async writeChildDoc(e,t,n,r){let i=t.relativePath.replace(/\.mdx$/,`.md`),a=this.joinPath(n,i),o={pathKind:L.Relative,path:i,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:a}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`childDoc`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeResource(e,t,n,r){let i=this.joinPath(n,t.relativePath),a={pathKind:L.Relative,path:t.relativePath,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:i}),{path:a,success:!0,skipped:!1};try{let e=this.dirname(i);if(this.ensureDirectory(e),t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`);this.writeFileSyncBuffer(i,e)}else this.writeFileSync(i,t.content);return this.log.trace({action:`write`,type:`resource`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:i,error:t}),{path:a,success:!1,error:e}}}},Mv=class extends jg{options;constructor(e,t){super(e),this.options=t??{}}transformContent(e){return e}collect(e){let{shadowProjectDir:t}=this.resolveBasePaths(e.userConfigOptions),n=this.getFilePath(t);if(!e.fs.existsSync(n))return this.options.fallbackContent==null?(this.log.debug({action:`collect`,message:`File not found`,path:n}),{}):(this.log.debug({action:`collect`,message:`Using fallback content`,path:n}),{[this.getResultKey()]:this.transformContent(this.options.fallbackContent)});let r=e.fs.readFileSync(n,`utf8`);return r.length===0?this.options.fallbackContent==null?(this.log.debug({action:`collect`,message:`File is empty`,path:n}),{}):(this.log.debug({action:`collect`,message:`File empty, using fallback`,path:n}),{[this.getResultKey()]:this.transformContent(this.options.fallbackContent)}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:n,length:r.length}),{[this.getResultKey()]:this.transformContent(r)})}},Nv=class extends Mv{constructor(){super(`GitExcludeInputPlugin`)}getFilePath(e){return f.join(e,`public`,`exclude`)}getResultKey(){return`shadowGitExclude`}};function Pv(e){let t=f.join(e,`.git`);if(!d.existsSync(t))return null;let n=d.lstatSync(t);if(n.isDirectory())return f.join(t,`info`);if(n.isFile())try{let n=d.readFileSync(t,`utf8`).trim(),r=/^gitdir: (.+)$/.exec(n);if(r?.[1]!=null){let t=f.resolve(e,r[1]);return f.join(t,`info`)}}catch{}return null}function Fv(e,t=5){let n=[],r=new Set([`node_modules`,`.turbo`,`dist`,`build`,`out`,`.cache`]);function i(a,o){if(o>t)return;let s;try{let e=d.readdirSync(a,{withFileTypes:!0});if(!Array.isArray(e))return;s=e}catch{return}s.some(e=>e.name===`.git`)&&a!==e&&n.push(a);for(let e of s)e.isDirectory()&&(e.name===`.git`||r.has(e.name)||i(f.join(a,e.name),o+1))}return i(e,0),n}function Iv(e){let t=f.join(e,`modules`);if(!d.existsSync(t))return[];let n=[];function r(e){let t;try{let n=d.readdirSync(e,{withFileTypes:!0});if(!Array.isArray(n))return;t=n}catch{return}if(t.some(e=>e.name===`info`&&e.isDirectory())&&n.push(f.join(e,`info`)),t.find(e=>e.name===`modules`&&e.isDirectory())!=null){let t;try{let n=d.readdirSync(f.join(e,`modules`),{withFileTypes:!0});if(!Array.isArray(n))return;t=n}catch{return}for(let n of t)n.isDirectory()&&r(f.join(e,`modules`,n.name))}}let i;try{let e=d.readdirSync(t,{withFileTypes:!0});if(!Array.isArray(e))return n;i=e}catch{return n}for(let e of i)e.isDirectory()&&r(f.join(t,e.name));return n}var Lv=class extends Og{constructor(){super(`GitExcludeOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){if(e.dirFromWorkspacePath==null||e.isPromptSourceProject===!0)continue;let n=e.dirFromWorkspacePath,r=n.getAbsolutePath(),{basePath:i}=n,a=[r,...Fv(r)];for(let e of a){let n=Pv(e);if(n==null)continue;let r=f.join(n,`exclude`),a=f.relative(i,r);t.push({pathKind:L.Relative,path:a,basePath:i,getDirectoryName:()=>f.basename(e),getAbsolutePath:()=>r})}}let r=e.collectedInputContext.workspace.directory.path,i=f.join(r,`.git`);if(d.existsSync(i)&&d.lstatSync(i).isDirectory())for(let e of Iv(i)){let n=f.join(e,`exclude`),i=f.relative(r,n);t.push({pathKind:L.Relative,path:i,basePath:r,getDirectoryName:()=>f.basename(f.dirname(e)),getAbsolutePath:()=>n})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{globalGitIgnore:t,shadowGitExclude:n}=e.collectedInputContext;if(!(t!=null&&t.length>0||n!=null&&n.length>0))return this.log.debug({action:`canWrite`,result:!1,reason:`No gitignore or exclude content found`}),!1;let{projects:r}=e.collectedInputContext.workspace,i=r.some(e=>{if(e.dirFromWorkspacePath==null)return!1;let t=e.dirFromWorkspacePath.getAbsolutePath();return Pv(t)==null?Fv(t).some(e=>Pv(e)!=null):!0}),a=e.collectedInputContext.workspace.directory.path,o=Pv(a)!=null,s=i||o;return this.log.debug({action:`canWrite`,result:s,hasGitProjects:i,hasWorkspaceGit:o,reason:s?`Found git repositories to update`:`No git repositories found`}),s}async writeProjectOutputs(e){let t=[],{globalGitIgnore:n,shadowGitExclude:r}=e.collectedInputContext,i=this.buildManagedContent(n,r);if(i.length===0)return this.log.debug({action:`write`,message:`No gitignore or exclude content found, skipping`}),{files:[],dirs:[]};let{workspace:a}=e.collectedInputContext,{projects:o}=a,s=new Set;for(let n of o){if(n.dirFromWorkspacePath==null)continue;let r=n.dirFromWorkspacePath.getAbsolutePath(),a=[r,...Fv(r)];for(let o of a){let a=Pv(o);if(a==null)continue;let c=f.join(a,`exclude`);if(s.has(c))continue;s.add(c);let l=o===r?`project:${n.name??`unknown`}`:`nested:${f.relative(r,o)}`;this.log.info({action:`write`,path:c,label:l});let u=await this.writeGitExcludeFile(e,c,i,l);t.push(u)}}let c=a.directory.path,l=Pv(c);if(l!=null){let n=f.join(l,`exclude`);if(!s.has(n)){this.log.info({action:`write`,path:n,target:`workspace`});let r=await this.writeGitExcludeFile(e,n,i,`workspace`);t.push(r),s.add(n)}}let u=Fv(c);for(let n of u){let r=Pv(n);if(r==null)continue;let a=f.join(r,`exclude`);if(s.has(a))continue;s.add(a);let o=`workspace-nested:${f.relative(c,n)}`;this.log.info({action:`write`,path:a,label:o});let l=await this.writeGitExcludeFile(e,a,i,o);t.push(l)}let p=f.join(c,`.git`);if(d.existsSync(p)&&d.lstatSync(p).isDirectory())for(let n of Iv(p)){let r=f.join(n,`exclude`);if(s.has(r))continue;s.add(r);let a=`git-module:${f.relative(p,n)}`;this.log.info({action:`write`,path:r,label:a});let o=await this.writeGitExcludeFile(e,r,i,a);t.push(o)}return{files:t,dirs:[]}}buildManagedContent(e,t){let n=[];if(e!=null&&e.trim().length>0){let t=this.sanitizeContent(e);t.length>0&&n.push(t)}if(t!=null&&t.trim().length>0){let e=this.sanitizeContent(t);e.length>0&&n.push(e)}return n.length===0?``:n.join(`
875
1200
  `)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
876
- `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}async writeGitExcludeFile(e,t,n,r){let i=e.collectedInputContext.workspace.directory.path,a={pathKind:L.Relative,path:f.relative(i,t),basePath:i,getDirectoryName:()=>f.basename(f.dirname(t)),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`gitExclude`,path:t,label:r}),{path:a,success:!0,skipped:!1};try{let e=f.dirname(t);d.existsSync(e)||(d.mkdirSync(e,{recursive:!0}),this.log.debug({action:`mkdir`,path:e,message:`Created .git/info directory`}));let i=this.normalizeContent(n);return d.writeFileSync(t,i,`utf8`),this.log.trace({action:`write`,type:`gitExclude`,path:t,label:r}),{path:a,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`gitExclude`,path:t,label:r,error:n}),{path:a,success:!1,error:e}}}};function Rv(){return Ht[`public/exclude`]?.content??``}var zv=class extends Mv{constructor(){super(`GitIgnoreInputPlugin`,{fallbackContent:Rv()})}getFilePath(e){return f.join(e,`public`,`gitignore`)}getResultKey(){return`globalGitIgnore`}},Bv=class extends jg{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:n,path:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.globalMemoryFile,c=this.resolvePath(s,a,o);if(!n.existsSync(c))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:c}),{};if(!n.statSync(c).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:c}),{};let l=n.readFileSync(c,`utf8`),d=Tg(l),f;if(i!=null)try{f=await ov(l,{globalScope:i,basePath:r.dirname(c)})}catch(e){throw e instanceof Ug&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),u.default.exit(1)),e}else f=d.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:c,contentLength:f.length}),{globalMemory:{type:xt.GlobalMemory,content:f,length:f.length,filePathKind:L.Relative,...d.rawFrontMatter!=null&&{rawFrontMatter:d.rawFrontMatter},markdownAst:d.markdownAst,markdownContents:d.markdownContents,dir:{pathKind:L.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:wt.UserHome,directory:{pathKind:L.Relative,path:``,basePath:p.homedir(),getDirectoryName:()=>r.basename(p.homedir()),getAbsolutePath:()=>p.homedir()}}}}}},Vv=class extends jg{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf8`),a=Tt.Original;e.includes(`.vscode`)?a=Tt.VSCode:e.includes(`.idea`)?a=Tt.IntellijIDEA:e.includes(`.editorconfig`)&&(a=Tt.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:L.Absolute,dir:{pathKind:L.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Hv=`AGENTS.md`,Uv=`prompts`,Wv=`skills`,Gv=`SKILL.md`,Kv=`.aiassistant`,qv=`rules`,Jv=`always.md`,Yv=`codex`,Xv=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];var Zv=class extends Og{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:Hv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)e.dirFromWorkspacePath!=null&&t.push(this.createProjectRulesDirRelativePath(e.dirFromWorkspacePath));return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFileRelativePath(n,Jv)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts){let e=this.buildChildRuleFileName(r);t.push(this.createProjectRuleFileRelativePath(n,e))}}return t}async registerGlobalOutputDirs(e){let t=[],n=this.resolveCodexDirs();for(let r of n){let n=f.join(r,Uv);t.push({pathKind:L.Relative,path:Uv,basePath:r,getDirectoryName:()=>Uv,getAbsolutePath:()=>n});let{skills:i}=e.collectedInputContext;if(!(i==null||i.length===0))for(let e of i){let n=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),i=f.join(r,Wv,n);t.push({pathKind:L.Relative,path:f.join(Wv,n),basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>i})}}return t}async registerGlobalOutputFiles(){return this.resolveCodexDirs().map(e=>({pathKind:L.Relative,path:Hv,basePath:e,getDirectoryName:()=>Yv,getAbsolutePath:()=>f.join(e,Hv)}))}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r,workspace:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=i.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0);return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null){if(r.rootMemoryPrompt!=null){let t=this.buildAlwaysRuleContent(r.rootMemoryPrompt.content),i=await this.writeProjectRuleFile(e,r,Jv,t,`projectRootRule`);n.push(i)}if(r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=this.buildChildRuleFileName(t),a=this.buildGlobRuleContent(t),o=await this.writeProjectRuleFile(e,r,i,a,`projectChildRule`);n.push(o)}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.resolveCodexDirs();if(o.length===0)return{files:i,dirs:a};for(let a of o){if(t!=null){let n=f.join(a,Hv),r={pathKind:L.Relative,path:Hv,basePath:a,getDirectoryName:()=>Yv,getAbsolutePath:()=>n};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:n}),i.push({path:r,success:!0,skipped:!1});else try{this.ensureDirectory(a),d.writeFileSync(n,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:n}),i.push({path:r,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:n,error:t}),i.push({path:r,success:!1,error:e})}}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,a,t);i.push(...n)}if(!(r==null||r.length===0))for(let t of r){let n=await this.writeGlobalSkill(e,a,t);i.push(...n)}}return{files:i,dirs:a}}resolveCodexDirs(){let e=f.join(Xe(),`JetBrains`);if(!this.existsSync(e))return[];try{return this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()?this.isSupportedIdeDir(e.name):!1).map(t=>f.join(e,t.name,`aia`,Yv))}catch(t){let n=t instanceof Error?t.message:String(t);return this.log.warn({action:`scan`,type:`jetbrains`,path:e,error:n}),[]}}createProjectRulesDirRelativePath(e){let t=f.join(e.path,Kv,qv);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>qv,getAbsolutePath:()=>f.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=f.join(e.path,Kv,qv,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>qv,getAbsolutePath:()=>f.join(e.basePath,n)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildChildRulePattern(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return t.length===0?`**/*`:`${t}/**`}buildAlwaysRuleContent(e){return wg({apply:`始终`},e)}buildGlobRuleContent(e){return wg({apply:`按文件模式`,模式:this.buildChildRulePattern(e)},e.content)}async writeProjectRuleFile(e,t,n,r,i){let a=t.dirFromWorkspacePath,o=f.join(a.basePath,a.path,Kv,qv),s=f.join(o,n),c=this.createProjectRuleFileRelativePath(a,n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:i,path:s}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(o),d.writeFileSync(s,r,`utf8`),this.log.trace({action:`write`,type:i,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:i,path:s,error:t}),{path:c,success:!1,error:e}}}isSupportedIdeDir(e){return Xv.some(t=>e.startsWith(t))}async writeGlobalFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=f.join(t,Uv),s=f.join(o,a),c={pathKind:L.Relative,path:f.join(Uv,a),basePath:t,getDirectoryName:()=>Uv,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),d.writeFileSync(s,l,`utf8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,Wv,i),o=f.join(a,Gv),s={pathKind:L.Relative,path:f.join(Wv,i,Gv),basePath:t,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),d.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`globalSkill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),wg(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=f.join(t,o),c={pathKind:L.Relative,path:f.join(Wv,n,o),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=f.dirname(s);this.ensureDirectory(e),d.writeFileSync(s,r.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=f.join(t,r.relativePath),s={pathKind:L.Relative,path:f.join(Wv,n,r.relativePath),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=f.dirname(o);this.ensureDirectory(e),d.writeFileSync(o,r.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const Qv=`.idea`,$v=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var ey=class extends Og{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of $v){let r=this.joinPath(n.path,e);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig)?!0:(this.log.debug(`skipped`,{reason:`no JetBrains IDE config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===Tt.EditorConfig)return`.editorconfig`;if(e.type!==Tt.IntellijIDEA)return this.basename(t);let n=t.indexOf(Qv);return n===-1?this.joinPath(Qv,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}},ty=class extends jg{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
1201
+ `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}async writeGitExcludeFile(e,t,n,r){let i=e.collectedInputContext.workspace.directory.path,a={pathKind:L.Relative,path:f.relative(i,t),basePath:i,getDirectoryName:()=>f.basename(f.dirname(t)),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`gitExclude`,path:t,label:r}),{path:a,success:!0,skipped:!1};try{let e=f.dirname(t);d.existsSync(e)||(d.mkdirSync(e,{recursive:!0}),this.log.debug({action:`mkdir`,path:e,message:`Created .git/info directory`}));let i=this.normalizeContent(n);return d.writeFileSync(t,i,`utf8`),this.log.trace({action:`write`,type:`gitExclude`,path:t,label:r}),{path:a,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`gitExclude`,path:t,label:r,error:n}),{path:a,success:!1,error:e}}}};const Rv=Ht;function zv(){return Rv[`public/gitignore`]?.content??``}var Bv=class extends Mv{constructor(){super(`GitIgnoreInputPlugin`,{fallbackContent:zv()})}getFilePath(e){return f.join(e,`public`,`gitignore`)}getResultKey(){return`globalGitIgnore`}},Vv=class extends jg{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:n,path:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.globalMemoryFile,c=this.resolvePath(s,a,o);if(!n.existsSync(c))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:c}),{};if(!n.statSync(c).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:c}),{};let l=n.readFileSync(c,`utf8`),d=Tg(l),f;if(i!=null)try{f=await ov(l,{globalScope:i,basePath:r.dirname(c)})}catch(e){throw e instanceof Ug&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),u.default.exit(1)),e}else f=d.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:c,contentLength:f.length}),{globalMemory:{type:xt.GlobalMemory,content:f,length:f.length,filePathKind:L.Relative,...d.rawFrontMatter!=null&&{rawFrontMatter:d.rawFrontMatter},markdownAst:d.markdownAst,markdownContents:d.markdownContents,dir:{pathKind:L.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:wt.UserHome,directory:{pathKind:L.Relative,path:``,basePath:p.homedir(),getDirectoryName:()=>r.basename(p.homedir()),getAbsolutePath:()=>p.homedir()}}}}}},Hv=class extends jg{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf8`),a=Tt.Original;e.includes(`.vscode`)?a=Tt.VSCode:e.includes(`.idea`)?a=Tt.IntellijIDEA:e.includes(`.editorconfig`)&&(a=Tt.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:L.Absolute,dir:{pathKind:L.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Uv=`AGENTS.md`,Wv=`prompts`,Gv=`skills`,Kv=`SKILL.md`,qv=`.aiassistant`,Jv=`rules`,Yv=`always.md`,Xv=`codex`,Zv=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];var Qv=class extends Og{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:Uv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)e.dirFromWorkspacePath!=null&&t.push(this.createProjectRulesDirRelativePath(e.dirFromWorkspacePath));return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFileRelativePath(n,Yv)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts){let e=this.buildChildRuleFileName(r);t.push(this.createProjectRuleFileRelativePath(n,e))}}return t}async registerGlobalOutputDirs(e){let t=[],n=this.resolveCodexDirs();for(let r of n){let n=f.join(r,Wv);t.push({pathKind:L.Relative,path:Wv,basePath:r,getDirectoryName:()=>Wv,getAbsolutePath:()=>n});let{skills:i}=e.collectedInputContext;if(!(i==null||i.length===0))for(let e of i){let n=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),i=f.join(r,Gv,n);t.push({pathKind:L.Relative,path:f.join(Gv,n),basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>i})}}return t}async registerGlobalOutputFiles(){return this.resolveCodexDirs().map(e=>({pathKind:L.Relative,path:Uv,basePath:e,getDirectoryName:()=>Xv,getAbsolutePath:()=>f.join(e,Uv)}))}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r,workspace:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=i.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0);return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null){if(r.rootMemoryPrompt!=null){let t=this.buildAlwaysRuleContent(r.rootMemoryPrompt.content),i=await this.writeProjectRuleFile(e,r,Yv,t,`projectRootRule`);n.push(i)}if(r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=this.buildChildRuleFileName(t),a=this.buildGlobRuleContent(t),o=await this.writeProjectRuleFile(e,r,i,a,`projectChildRule`);n.push(o)}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.resolveCodexDirs();if(o.length===0)return{files:i,dirs:a};for(let a of o){if(t!=null){let n=f.join(a,Uv),r={pathKind:L.Relative,path:Uv,basePath:a,getDirectoryName:()=>Xv,getAbsolutePath:()=>n};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:n}),i.push({path:r,success:!0,skipped:!1});else try{this.ensureDirectory(a),d.writeFileSync(n,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:n}),i.push({path:r,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:n,error:t}),i.push({path:r,success:!1,error:e})}}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,a,t);i.push(...n)}if(!(r==null||r.length===0))for(let t of r){let n=await this.writeGlobalSkill(e,a,t);i.push(...n)}}return{files:i,dirs:a}}resolveCodexDirs(){let e=f.join(Xe(),`JetBrains`);if(!this.existsSync(e))return[];try{return this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()?this.isSupportedIdeDir(e.name):!1).map(t=>f.join(e,t.name,`aia`,Xv))}catch(t){let n=t instanceof Error?t.message:String(t);return this.log.warn({action:`scan`,type:`jetbrains`,path:e,error:n}),[]}}createProjectRulesDirRelativePath(e){let t=f.join(e.path,qv,Jv);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>Jv,getAbsolutePath:()=>f.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=f.join(e.path,qv,Jv,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>Jv,getAbsolutePath:()=>f.join(e.basePath,n)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildChildRulePattern(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return t.length===0?`**/*`:`${t}/**`}buildAlwaysRuleContent(e){return wg({apply:`始终`},e)}buildGlobRuleContent(e){return wg({apply:`按文件模式`,模式:this.buildChildRulePattern(e)},e.content)}async writeProjectRuleFile(e,t,n,r,i){let a=t.dirFromWorkspacePath,o=f.join(a.basePath,a.path,qv,Jv),s=f.join(o,n),c=this.createProjectRuleFileRelativePath(a,n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:i,path:s}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(o),d.writeFileSync(s,r,`utf8`),this.log.trace({action:`write`,type:i,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:i,path:s,error:t}),{path:c,success:!1,error:e}}}isSupportedIdeDir(e){return Zv.some(t=>e.startsWith(t))}async writeGlobalFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=f.join(t,Wv),s=f.join(o,a),c={pathKind:L.Relative,path:f.join(Wv,a),basePath:t,getDirectoryName:()=>Wv,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),d.writeFileSync(s,l,`utf8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=f.join(t,Gv,i),o=f.join(a,Kv),s={pathKind:L.Relative,path:f.join(Gv,i,Kv),basePath:t,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),d.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`globalSkill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),wg(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=f.join(t,o),c={pathKind:L.Relative,path:f.join(Gv,n,o),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=f.dirname(s);this.ensureDirectory(e),d.writeFileSync(s,r.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=f.join(t,r.relativePath),s={pathKind:L.Relative,path:f.join(Gv,n,r.relativePath),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=f.dirname(o);this.ensureDirectory(e),d.writeFileSync(o,r.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const $v=`.idea`,ey=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var ty=class extends Og{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of ey){let r=this.joinPath(n.path,e);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig)?!0:(this.log.debug(`skipped`,{reason:`no JetBrains IDE config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===Tt.IntellijIDEA||e.type===Tt.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===Tt.EditorConfig)return`.editorconfig`;if(e.type!==Tt.IntellijIDEA)return this.basename(t);let n=t.indexOf($v);return n===-1?this.joinPath($v,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}},ny=class extends jg{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
877
1202
  `)?`\r
878
1203
  `:`
879
- `}collect(e){return{}}};const ny=`.config/opencode`,ry=`opencode.json`;var iy=class extends sv{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:ny,outputFileName:`AGENTS.md`,commandsSubDir:`commands`,agentsSubDir:`agents`,skillsSubDir:`skills`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=f.join(t,ry);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset opencode.json mcp to empty`};try{if(d.existsSync(n)){let e=d.readFileSync(n,`utf8`),t=JSON.parse(e);t.mcp={},d.writeFileSync(n,JSON.stringify(t,null,2))}return this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset opencode.json mcp to empty`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset opencode.json mcp`}}})}async registerGlobalOutputFiles(e){let t=await super.registerGlobalOutputFiles(e),n=this.getGlobalConfigDir();if(e.collectedInputContext.skills?.some(e=>e.mcpConfig!=null)??!1){let e=f.join(n,ry);t.push({pathKind:L.Relative,path:ry,basePath:n,getDirectoryName:()=>ny,getAbsolutePath:()=>e})}return t.map(e=>{let t=e.path.replaceAll(`\\`,`/`),r=`/${this.skillsSubDir}/`,i=`${this.skillsSubDir}/`;if(!(t.includes(r)||t.startsWith(i)))return e;let a=t.split(`/`),o=a.indexOf(this.skillsSubDir);if(o<0||o+1>=a.length)return e;let s=a[o+1];if(s==null)return e;let c=this.validateAndNormalizeSkillName(s),l=[...a];l[o+1]=c;let u=l.join(`/`);return{...e,path:u,getDirectoryName:()=>c,getAbsolutePath:()=>f.join(n,u.replaceAll(`/`,f.sep))}})}async writeGlobalOutputs(e){let t=await super.writeGlobalOutputs(e),n=[...t.files],{skills:r}=e.collectedInputContext;if(r==null)return{files:n,dirs:t.dirs};let i=await this.writeGlobalMcpConfig(e,r);return i!=null&&n.push(i),{files:n,dirs:t.dirs}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForOpencode(r)}if(Object.keys(n).length===0)return null;let r=this.getGlobalConfigDir(),i=f.join(r,ry),a={pathKind:L.Relative,path:ry,basePath:r,getDirectoryName:()=>ny,getAbsolutePath:()=>i},o={};try{if(d.existsSync(i)){let e=d.readFileSync(i,`utf8`);o=JSON.parse(e)}}catch{o={}}o.$schema=`https://opencode.ai/config.json`,o.mcp=n;let s=JSON.stringify(o,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(r),d.writeFileSync(i,s),this.log.trace({action:`write`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}transformMcpConfigForOpencode(e){let t={};if(e.command!=null){t.type=`local`;let n=[e.command];e.args!=null&&n.push(...e.args),t.command=n,e.env!=null&&(t.environment=e.env)}else{t.type=`remote`;let n=e;n.url==null?n.serverUrl!=null&&(t.url=n.serverUrl):t.url=n.url}return t.enabled=e.disabled!==!0,t}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,i=f.join(t,this.agentsSubDir),a=f.join(i,r),o=this.buildOpencodeAgentFrontMatter(n),s=this.buildMarkdownContent(n.content,o);return[await this.writeFile(e,a,s,`subAgent`)]}buildOpencodeAgentFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),t.mode=n?.mode??`subagent`,n?.model!=null&&(t.model=n.model),n?.temperature!=null&&(t.temperature=n.temperature),n?.maxSteps!=null&&(t.maxSteps=n.maxSteps),n?.hidden!=null&&(t.hidden=n.hidden),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}n?.permission!=null&&typeof n.permission==`object`&&(t.permission=n.permission);for(let[e,r]of Object.entries(n??{}))[`description`,`mode`,`model`,`temperature`,`maxSteps`,`hidden`,`allowTools`,`permission`,`namingCase`,`name`,`color`].includes(e)||(t[e]=r);return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,this.commandsSubDir),o=f.join(a,i),s=this.buildOpencodeCommandFrontMatter(n),c=this.buildMarkdownContent(n.content,s);return[await this.writeFile(e,o,c,`fastCommand`)]}buildOpencodeCommandFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),n?.agent!=null&&(t.agent=n.agent),n?.model!=null&&(t.model=n.model),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}for(let[e,r]of Object.entries(n??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(t[e]=r);return t}async writeSkill(e,t,n){let r=[],i=this.validateAndNormalizeSkillName(n.yamlFrontMatter?.name??n.dir.getDirectoryName()),a=f.join(t,this.skillsSubDir,i),o=f.join(a,`SKILL.md`),s=this.buildOpencodeSkillFrontMatter(n,i),c=this.buildMarkdownContent(n.content,s),l=await this.writeFile(e,o,c,`skill`);if(r.push(l),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}return r}buildOpencodeSkillFrontMatter(e,t){let n={},r=e.yamlFrontMatter;n.name=t,r?.description!=null&&(n.description=r.description),n.license=r?.license??`MIT`,n.compatibility=r?.compatibility??`opencode`;let i={};for(let e of[`author`,`version`,`keywords`,`category`,`repository`,`displayName`])r?.[e]!=null&&(i[e]=r[e]);let a=new Set([`name`,`description`,`license`,`compatibility`,`namingCase`,`allowTools`,`keywords`,`displayName`,`author`,`version`]);for(let[e,t]of Object.entries(r??{}))a.has(e)||(i[e]=t);return Object.keys(i).length>0&&(n.metadata=i),n}validateAndNormalizeSkillName(e){let t=e.toLowerCase();return t=t.replaceAll(/[^a-z0-9-]+/g,`-`),t=t.replaceAll(/-+/g,`-`),t=t.replaceAll(/^-|-$/g,``),t.length===0?t=`skill`:t.length>64&&(t=t.slice(0,64),t=t.replace(/-$/,``)),t}},ay=class extends jg{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));let f=[];return n===`app`?f.push(a.join(r,`app`,l)):f.push(a.join(r,`src`,n,l)),!f.some(e=>i.existsSync(e))}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}},oy=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??tn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):f.resolve(e)}getRegistryDir(){return f.dirname(this.registryPath)}ensureRegistryDir(){let e=this.getRegistryDir();d.existsSync(e)||d.mkdirSync(e,{recursive:!0})}read(){if(!d.existsSync(this.registryPath))return this.log.debug(`registry not found`,{path:this.registryPath}),this.createInitialRegistry();try{let e=d.readFileSync(this.registryPath,`utf8`);return JSON.parse(e)}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`parse failed`,{path:this.registryPath,error:t}),this.createInitialRegistry()}}write(e,t){let n={...e,lastUpdated:new Date().toISOString()};if(t===!0)return this.log.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let r=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return d.writeFileSync(r,e,`utf8`),d.renameSync(r,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,path:this.registryPath,error:t});try{d.existsSync(r)&&d.unlinkSync(r)}catch{}return!1}}register(e,t){let n=[],r=this.read(),i=this.merge(r,e),a=this.write(i,t);for(let r of e){let e=this.getEntryName(r);a?(n.push({success:!0,entryName:e}),t===!0?this.log.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`entry`,entryName:e})):(n.push({success:!1,entryName:e,error:Error(`Failed to write registry file`)}),this.log.error(`register entry failed`,{entryName:e}))}return n}generateEntryId(e){let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e==null?t:`${e}-${t}`}},sy=class extends jg{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return(0,g.createHash)(`sha256`).update(e).digest(`hex`)}collect(e){return{}}};const cy=`.codeium/windsurf`,ly=`global_workflows`,uy=`memories`,dy=`global_rules.md`,fy=`skills`,py=`SKILL.md`;var my=class extends Og{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:cy,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]})}async registerGlobalOutputDirs(e){let t=[],{fastCommands:n,skills:r}=e.collectedInputContext;if(n!=null&&n.length>0){let e=this.getGlobalWorkflowsDir();t.push({pathKind:L.Relative,path:ly,basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>ly,getAbsolutePath:()=>e})}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name,r=f.join(this.getCodeiumWindsurfDir(),fy,n);t.push({pathKind:L.Relative,path:f.join(fy,n),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>n,getAbsolutePath:()=>r})}return t}async registerGlobalOutputFiles(e){let t=[],{skills:n,fastCommands:r}=e.collectedInputContext;if(r!=null&&r.length>0){let n=this.getGlobalWorkflowsDir(),i=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of r){let r=this.transformFastCommandName(e,i),a=f.join(n,r);t.push({pathKind:L.Relative,path:f.join(ly,r),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>ly,getAbsolutePath:()=>a})}}if(n==null||n.length===0)return t;let i=this.getSkillsDir(),a=this.getCodeiumWindsurfDir();for(let e of n){let n=e.yamlFrontMatter.name,r=f.join(i,n);if(t.push({pathKind:L.Relative,path:f.join(fy,n,py),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,py)}),e.childDocs!=null)for(let i of e.childDocs){let e=i.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:f.join(fy,n,e),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,e)})}if(e.resources!=null)for(let i of e.resources)t.push({pathKind:L.Relative,path:f.join(fy,n,i.relativePath),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,i.relativePath)})}return t}async canWrite(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=(t?.length??0)>0,a=(n?.length??0)>0;return i||a||r!=null?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=[],a=[];if(r!=null){let t=await this.writeGlobalMemory(e,r.content);i.push(t)}if(t!=null&&t.length>0){let n=this.getSkillsDir();for(let r of t){let t=await this.writeGlobalSkill(e,n,r);i.push(...t)}}if(n==null||n.length===0)return{files:i,dirs:a};let o=this.getGlobalWorkflowsDir();for(let t of n){let n=await this.writeGlobalWorkflow(e,o,t);i.push(n)}return{files:i,dirs:a}}async writeProjectOutputs(){return{files:[],dirs:[]}}getSkillsDir(){return f.join(this.getCodeiumWindsurfDir(),fy)}getCodeiumWindsurfDir(){return f.join(this.getHomeDir(),cy)}getGlobalMemoriesDir(){return f.join(this.getCodeiumWindsurfDir(),uy)}getGlobalWorkflowsDir(){return f.join(this.getCodeiumWindsurfDir(),ly)}async writeGlobalMemory(e,t){let n=this.getGlobalMemoriesDir(),r=f.join(n,dy),i=this.getCodeiumWindsurfDir(),a={pathKind:L.Relative,path:f.join(uy,dy),basePath:i,getDirectoryName:()=>uy,getAbsolutePath:()=>r};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(r,t),this.log.trace({action:`write`,type:`globalMemory`,path:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),{path:a,success:!1,error:e}}}async writeGlobalWorkflow(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),i=this.transformFastCommandName(n,r),a=f.join(t,i),o={pathKind:L.Relative,path:f.join(ly,i),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>ly,getAbsolutePath:()=>a},s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalWorkflow`,path:a}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(t),d.writeFileSync(a,s),this.log.trace({action:`write`,type:`globalWorkflow`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalWorkflow`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter.name,a=f.join(t,i),o=f.join(a,py),s=this.getCodeiumWindsurfDir(),c={pathKind:L.Relative,path:f.join(fy,i,py),basePath:s,getDirectoryName:()=>i,getAbsolutePath:()=>o},l=this.buildSkillFrontMatter(n),u=n.content,d=wg(l,u);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:c,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,d),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:c,success:!1,error:e})}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,a,i,s);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,a,i,s);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillChildDoc(e,t,n,r,i){let a=t.relativePath.replace(/\.mdx$/,`.md`),o=f.join(n,a),s={pathKind:L.Relative,path:f.join(fy,r,a),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>o},c=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:o}),{path:s,success:!0,skipped:!1};try{let e=f.dirname(o);return this.ensureDirectory(e),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`childDoc`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:o,error:t}),{path:s,success:!1,error:e}}}async writeSkillResource(e,t,n,r,i){let a=f.join(n,t.relativePath),o={pathKind:L.Relative,path:f.join(fy,r,t.relativePath),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:a}),{path:o,success:!0,skipped:!1};try{let e=f.dirname(a);if(this.ensureDirectory(e),t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`);this.writeFileSyncBuffer(a,e)}else this.writeFileSync(a,t.content);return this.log.trace({action:`write`,type:`resource`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:a,error:t}),{path:o,success:!1,error:e}}}},hy=class e extends oy{static REGISTRY_PATH=`~/.kiro/powers/registry.json`;static DEFAULT_VERSION=`1.0.0`;constructor(t){super(e.REGISTRY_PATH,t)}createInitialRegistry(){return{version:e.DEFAULT_VERSION,powers:{},repoSources:{},lastUpdated:new Date().toISOString()}}getEntryName(e){return e.name}merge(e,t){let n={...e.powers},r={...e.repoSources};for(let e of t){n[e.name]=e;let t=this.buildRepoSource(e),i=e.source.repoId??e.name;r[i]=t}return{version:e.version,powers:n,repoSources:r,...e.kiroRecommendedRepo!=null&&{kiroRecommendedRepo:e.kiroRecommendedRepo},lastUpdated:e.lastUpdated}}buildPowerEntry(e,t){let{yamlFrontMatter:n,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}buildRepoSource(e){let t=new Date().toISOString();return{name:e.sourcePath??e.installPath??e.name,type:`local`,enabled:!0,addedAt:t,powerCount:1,...e.sourcePath!=null&&{path:e.sourcePath},lastSync:t}}};const gy=`GLOBAL.md`,_y=`.kiro`,vy=`steering`,yy=`settings`,by=`mcp.json`,xy=`POWER.md`,Sy=`SKILL.md`;var Cy=class extends Og{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:_y,outputFileName:gy}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(hy).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry`}:{success:!1,description:`Failed`,error:Error(`Registry cleanup failed`)}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.joinPath(this.getGlobalSettingsDir(),by),n=JSON.stringify({mcpServers:{},powers:{mcpServers:{}}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:t}),{success:!0,description:`Would reset mcp.json`};let r=await this.writeFile(e,t,n,`mcpSettingsCleanup`);return r.success?{success:!0,description:`Reset mcp.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),_y,yy)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),vy)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroSkillsDir(){return this.joinPath(this.getHomeDir(),`.kiro/skills`)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,_y,vy),e.dirFromWorkspacePath.basePath,()=>vy))}async registerProjectOutputFiles(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(!(e.dirFromWorkspacePath==null||e.childMemoryPrompts==null))for(let t of e.childMemoryPrompts)n.push(this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,_y,vy,this.buildSteeringFileName(t)),e.dirFromWorkspacePath.basePath,()=>vy));return n}async registerGlobalOutputDirs(){let e=[this.createRelativePath(vy,this.getGlobalConfigDir(),()=>vy)],t=this.getKiroPowersDir();for(let n of this.listInstalledPowers(t))e.push(this.createRelativePath(n,t,()=>n));let n=this.getKiroSkillsDir();for(let t of this.listInstalledPowers(n))e.push(this.createRelativePath(t,n,()=>t));return e.push(this.createRelativePath(`repos`,this.joinPath(this.getHomeDir(),`.kiro/powers`),()=>`repos`)),e}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=this.getGlobalSteeringDir(),a=[];if(t!=null&&a.push(this.createRelativePath(gy,i,()=>vy)),n!=null)for(let e of n)a.push(this.createRelativePath(this.buildFastCommandSteeringFileName(e),i,()=>vy));if(r==null)return a;let o=this.getKiroPowersDir(),s=this.getKiroSkillsDir();for(let e of r){let t=e.yamlFrontMatter.name;if(e.mcpConfig!=null){let n=this.joinPath(o,t);if(a.push(this.createRelativePath(xy,n,()=>t)),a.push(this.createRelativePath(by,n,()=>t)),e.childDocs!=null)for(let t of e.childDocs)a.push(this.createRelativePath(this.joinPath(vy,t.dir.path.replace(/\.mdx$/,`.md`)),n,()=>vy));if(e.resources!=null)for(let t of e.resources)a.push(this.createRelativePath(this.joinPath(vy,t.relativePath),n,()=>vy))}else{let n=this.joinPath(s,t);if(a.push(this.createRelativePath(Sy,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}}return r.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(by,this.getGlobalSettingsDir(),()=>yy)),a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let r of t)if(!(r.dirFromWorkspacePath==null||r.childMemoryPrompts==null))for(let t of r.childMemoryPrompts)n.push(await this.writeSteeringFile(e,r,t));return{files:n,dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.getGlobalSteeringDir();if(t!=null&&i.push(await this.writeFile(e,this.joinPath(o,gy),t.content,`globalMemory`)),n!=null)for(let t of n)i.push(await this.writeFastCommandSteeringFile(e,t));if(r==null||r.length===0)return{files:i,dirs:[]};let s=r.filter(e=>e.mcpConfig!=null),c=r.filter(e=>e.mcpConfig==null);for(let t of s){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),a.push(r)}for(let t of c){let n=await this.writeSkillAsKiroSkill(e,t);i.push(...n)}let l=await this.writeGlobalMcpSettings(e,r);return l!=null&&i.push(l),this.logRegistryResults(a,e.dryRun),{files:i,dirs:[]}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t)if(e.mcpConfig!=null)for(let[t,r]of Object.entries(e.mcpConfig.mcpServers))n[`power-${e.yamlFrontMatter.name}-${t}`]=r;if(Object.keys(n).length===0)return null;let r=JSON.stringify({mcpServers:{},powers:{mcpServers:n}},null,2);return this.writeFile(e,this.joinPath(this.getGlobalSettingsDir(),by),r,`globalMcpSettings`)}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),r>0&&this.log.error({action:`register`,type:`registrySummary`,failCount:r})}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,xy),o=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`skillPower`)),t.childDocs!=null){let r=this.joinPath(i,vy);for(let i of t.childDocs){let t=i.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(r,t),i.content,`refDoc`))}}if(t.resources!=null){let r=this.joinPath(i,vy);for(let i of t.resources)n.push(await this.writeFile(e,this.joinPath(r,i.relativePath),i.content,`resource`))}t.mcpConfig!=null&&n.push(await this.writeFile(e,this.joinPath(i,by),t.mcpConfig.rawContent,`mcpConfig`));let s=this.getRegistryWriter(hy),c=s.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(s,[c],e))[0]??{success:!1,entryName:r,error:Error(`No registry result`)}}}async writeSkillAsKiroSkill(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroSkillsDir(),r),a=this.joinPath(i,Sy),o=`${this.buildSkillFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`kiroSkill`)),t.childDocs!=null)for(let r of t.childDocs){let t=r.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(i,t),r.content,`refDoc`))}if(t.resources!=null)for(let r of t.resources)n.push(await this.writeFile(e,this.joinPath(i,r.relativePath),r.content,`resource`));return n}buildSkillFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,description:e.description,...e.displayName!=null&&{displayName:e.displayName},...e.keywords!=null&&e.keywords.length>0&&{keywords:e.keywords},...e.author!=null&&{author:e.author}}).trimEnd()}buildPowerFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author}).trimEnd()}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}async writeFastCommandSteeringFile(e,t){let n=this.buildFastCommandSteeringFileName(t),r=this.joinPath(this.getGlobalSteeringDir(),n),i=t.yamlFrontMatter?.description,a=this.buildMarkdownContent(t.content,{inclusion:`manual`,description:i!=null&&i.length>0?i:null});return this.writeFile(e,r,a,`fastCommandSteering`)}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,_y,vy),o=this.joinPath(a,i),s=n.workingChildDirectoryPath?.path??n.dir.path,c=this.buildMarkdownContent(n.content,{inclusion:`fileMatch`,fileMatchPattern:`${s.replaceAll(`\\`,`/`)}/**`});return this.writeFile(e,o,c,`steeringFile`)}};const wy=`agt.mdx`,Ty=[`node_modules`,`.git`];var Ey=class extends jg{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,n){let{fs:r,path:i,logger:a}=e,o=i.join(t,wy);if(!(!r.existsSync(o)||!r.statSync(o).isFile()))try{let e=r.readFileSync(o,`utf8`),i=Tg(e),s;try{s=await ov(e,{globalScope:n,basePath:t})}catch(e){throw e instanceof Ug&&(a.error(`MDX compilation failed in ${o}: ${e.message}`),a.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}return{type:xt.ProjectRootMemory,content:s,length:s.length,filePathKind:L.Relative,...i.yamlFrontMatter!=null&&{yamlFrontMatter:i.yamlFrontMatter},...i.rawFrontMatter!=null&&{rawFrontMatter:i.rawFrontMatter},markdownAst:i.markdownAst,markdownContents:i.markdownContents,dir:{pathKind:L.Root,path:``,getDirectoryName:()=>``}}}catch(e){a.error(`Failed to read root memory prompt at ${o}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||Ty.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,wy);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c=o.join(n,wy);try{let e=a.readFileSync(c,`utf8`),l=Tg(e),d;try{d=await ov(e,{globalScope:i,basePath:n})}catch(e){throw e instanceof Ug&&(s.error(`MDX compilation failed in ${c}: ${e.message}`),s.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}let f=o.relative(t,n),p=o.join(r,f),m=o.basename(n);return{type:xt.ProjectChildrenMemory,content:d,length:d.length,filePathKind:L.Relative,...l.yamlFrontMatter!=null&&{yamlFrontMatter:l.yamlFrontMatter},...l.rawFrontMatter!=null&&{rawFrontMatter:l.rawFrontMatter},markdownAst:l.markdownAst,markdownContents:l.markdownContents,dir:{pathKind:L.Relative,path:f,basePath:r,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:L.Relative,path:f,basePath:r,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){s.error(`Failed to read child memory prompt at ${c}`,{error:e});return}}};const Dy=`.qoder`,Oy=`rules`,ky=`commands`,Ay=`skills`,jy=`global.md`,My=`always.md`,Ny=`SKILL.md`,Py=`mcp.json`;var Fy=class extends Og{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:Dy})}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createProjectRulesDirPath(e.dirFromWorkspacePath))}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{globalMemory:r}=e.collectedInputContext;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(r!=null&&t.push(this.createProjectRuleFilePath(n,jy)),e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFilePath(n,My)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts)t.push(this.createProjectRuleFilePath(n,this.buildChildRuleFileName(r)))}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,i=[];if(n!=null&&n.length>0&&i.push(this.createRelativePath(ky,t,()=>ky)),r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;i.push(this.createRelativePath(f.join(Ay,n),t,()=>n))}return i}async registerGlobalOutputFiles(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(n!=null&&n.length>0)for(let e of n){let n=this.transformFastCommandName(e,a);i.push(this.createRelativePath(f.join(ky,n),t,()=>ky))}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;if(i.push(this.createRelativePath(f.join(Ay,n,Ny),t,()=>n)),e.mcpConfig!=null&&i.push(this.createRelativePath(f.join(Ay,n,Py),t,()=>n)),e.childDocs!=null)for(let r of e.childDocs)i.push(this.createRelativePath(f.join(Ay,n,r.relativePath.replace(/\.mdx$/,`.md`)),t,()=>n));if(e.resources!=null)for(let r of e.resources)i.push(this.createRelativePath(f.join(Ay,n,r.relativePath),t,()=>n))}return i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{globalMemory:n}=e.collectedInputContext,r=[];for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=i.dirFromWorkspacePath;if(n!=null){let i=this.buildAlwaysRuleContent(n.content);r.push(await this.writeProjectRuleFile(e,t,jy,i,`globalRule`))}if(i.rootMemoryPrompt!=null){let n=this.buildAlwaysRuleContent(i.rootMemoryPrompt.content);r.push(await this.writeProjectRuleFile(e,t,My,n,`projectRootRule`))}if(i.childMemoryPrompts!=null)for(let n of i.childMemoryPrompts){let i=this.buildChildRuleFileName(n),a=this.buildGlobRuleContent(n);r.push(await this.writeProjectRuleFile(e,t,i,a,`projectChildRule`))}}return{files:r,dirs:[]}}async writeGlobalOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],i=this.getGlobalConfigDir(),a=f.join(i,ky),o=f.join(i,Ay);if(t!=null&&t.length>0)for(let n of t)r.push(await this.writeGlobalFastCommand(e,a,n));if(n!=null&&n.length>0)for(let t of n)r.push(...await this.writeGlobalSkill(e,o,t));return{files:r,dirs:[]}}createProjectRulesDirPath(e){return this.createRelativePath(f.join(e.path,Dy,Oy),e.basePath,()=>Oy)}createProjectRuleFilePath(e,t){return this.createRelativePath(f.join(e.path,Dy,Oy,t),e.basePath,()=>Oy)}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e){return wg({trigger:`always_on`,type:`user_command`},e)}buildGlobRuleContent(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return wg({trigger:`glob`,glob:t.length===0?`**/*`:`${t}/**`,type:`user_command`},e.content)}async writeProjectRuleFile(e,t,n,r,i){let a=f.join(t.basePath,t.path,Dy,Oy),o=f.join(a,n);return this.writeFile(e,o,r,i)}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),i=this.transformFastCommandName(n,r),a=f.join(t,i),o=wg(this.buildFastCommandFrontMatter(n),n.content);return this.writeFile(e,a,o,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter.name,a=f.join(t,i),o=f.join(a,Ny),s=wg(this.buildSkillFrontMatter(n),n.content);if(r.push(await this.writeFile(e,o,s,`skill`)),n.mcpConfig!=null){let t=f.join(a,Py);r.push(await this.writeFile(e,t,n.mcpConfig.rawContent,`mcpConfig`))}if(n.childDocs!=null)for(let t of n.childDocs){let n=f.join(a,t.relativePath.replace(/\.mdx$/,`.md`));r.push(await this.writeFile(e,n,t.content,`childDoc`))}if(n.resources!=null)for(let t of n.resources){let n=f.join(a,t.relativePath);if(t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`),o=f.dirname(n);this.ensureDirectory(o),this.writeFileSyncBuffer(n,e),r.push({path:this.createRelativePath(t.relativePath,a,()=>i),success:!0})}else r.push(await this.writeFile(e,n,t.content,`resource`))}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,type:`user_command`,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}buildFastCommandFrontMatter(e){let t=e.yamlFrontMatter;return t==null?{description:`Fast command`,type:`user_command`}:{description:t.description,type:`user_command`,...t.argumentHint!=null&&{argumentHint:t.argumentHint},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}};const Iy=`README.md`;var Ly=class extends Og{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:Iy})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let{targetDir:n}=e,r=f.join(n.path,Iy);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>f.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no README prompts to write`}),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let{targetDir:n}=t,r=f.join(n.path,Iy),i=f.join(n.basePath,r),a=t.content,o={pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i},s=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`readme`,path:i,label:s}),{path:o,success:!0,skipped:!1};try{let e=f.dirname(i);return d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.writeFileSync(i,a,`utf8`),this.log.trace({action:`write`,type:`readme`,path:i,label:s}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:i,label:s,error:t}),{path:o,success:!1,error:e}}}},Ry=class extends jg{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,n,r,i,a,o){let{fs:s,path:c,logger:l}=e,d=i===``,f=c.join(t,`rdm.mdx`);if(s.existsSync(f)&&s.statSync(f).isFile())try{let e=s.readFileSync(f,`utf8`),p;if(o!=null)try{p=await ov(e,{globalScope:o,basePath:t})}catch(e){throw e instanceof Ug&&(l.error(`MDX compilation failed in ${f}: ${e.message}`),l.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}else p=e;let m=d?n:c.join(n,i),h={pathKind:L.Relative,path:m,basePath:r,getDirectoryName:()=>d?n:c.basename(i),getAbsolutePath:()=>c.resolve(r,m)},g={pathKind:L.Relative,path:c.dirname(f),basePath:r,getDirectoryName:()=>c.basename(c.dirname(f)),getAbsolutePath:()=>c.dirname(f)};a.push({type:xt.Readme,content:p,length:p.length,filePathKind:L.Relative,projectName:n,targetDir:h,isRoot:d,markdownContents:[],dir:g})}catch(e){l.warn(`failed to read readme`,{path:f,error:e})}try{let l=s.readdirSync(t,{withFileTypes:!0});for(let s of l)if(s.isDirectory()){let l=d?s.name:c.join(i,s.name),u=c.join(t,s.name);await this.collectReadmeFiles(e,u,n,r,l,a,o)}}catch(e){l.warn(`failed to scan directory`,{path:t,error:e})}}},zy=class extends jg{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:L.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}};function By(e){return Ft.includes(e.toLowerCase())}function Vy(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}function Hy(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}var Uy=class extends jg{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=f.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:xt.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}scanSkillDirectory(e,t,n,r=``){let i=[],a=[],o=r?f.join(e,r):e;try{let s=t.readdirSync(o,{withFileTypes:!0});for(let c of s){let s=r?`${r}/${c.name}`:c.name;if(c.isDirectory()){let r=this.scanSkillDirectory(e,t,n,s);i.push(...r.childDocs),a.push(...r.resources)}else if(c.isFile()){let l=f.join(o,c.name);if(c.name.endsWith(`.mdx`)){if(r===``&&c.name===`skill.mdx`)continue;try{let n=Tg(t.readFileSync(l,`utf8`)),r=Eg(n.contentWithoutFrontMatter);i.push({type:xt.SkillChildDoc,content:r,length:r.length,filePathKind:L.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:s,dir:{pathKind:L.Relative,path:s,basePath:e,getDirectoryName:()=>f.dirname(s),getAbsolutePath:()=>l}})}catch(e){n.warn(`failed to read child doc`,{path:s,error:e})}}else{if(r===``&&c.name===`mcp.json`)continue;let e=f.extname(c.name),i,o,u;try{if(By(e)){let e=t.readFileSync(l);i=e.toString(`base64`),o=`base64`,{length:u}=e}else i=t.readFileSync(l,`utf8`),o=`text`,{length:u}=h.Buffer.from(i,`utf8`);let n=Hy(e),r={type:xt.SkillResource,extension:e,fileName:c.name,relativePath:s,content:i,encoding:o,category:Vy(e),length:u};n==null?a.push(r):a.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:s,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:o,error:e})}return{childDocs:i,resources:a}}async collect(e){let{userConfigOptions:t,logger:n,globalScope:r}=e,{workspaceDir:i,shadowProjectDir:a}=this.resolveBasePaths(t),o=t.shadowSkillSourceDir,s=this.resolvePath(o,i,a),c=[];if(!(e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory()))return{skills:c};let l=e.fs.readdirSync(s,{withFileTypes:!0});for(let t of l)if(t.isDirectory()){let i=e.path.join(s,t.name,`skill.mdx`);if(e.fs.existsSync(i)&&e.fs.statSync(i).isFile())try{let a=e.fs.readFileSync(i,`utf8`),o=Tg(a),l=await ov(a,{globalScope:r,extractMetadata:!0,basePath:e.path.join(s,t.name)}),u={...o.yamlFrontMatter,...l.metadata.fields},d=At(u,i);for(let e of d.warnings)n.debug(e);if(!d.valid)throw new Kg(d.errors,i);let p=Eg(l.content),m=e.path.join(s,t.name),h=this.readMcpConfig(m,e.fs,n),{childDocs:g,resources:_}=this.scanSkillDirectory(m,e.fs,n);n.debug(`skill metadata extracted`,{skill:t.name,source:l.metadata.source,hasYaml:o.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),c.push({type:xt.Skill,content:p,length:p.length,filePathKind:L.Relative,yamlFrontMatter:u.name==null?{name:t.name,description:``}:u,...o.rawFrontMatter!=null&&{rawFrontMatter:o.rawFrontMatter},markdownAst:o.markdownAst,markdownContents:o.markdownContents,...h!=null&&{mcpConfig:h},...g.length>0&&{childDocs:g},..._.length>0&&{resources:_},dir:{pathKind:L.Relative,path:t.name,basePath:s,getDirectoryName:()=>t.name,getAbsolutePath:()=>f.join(s,t.name)}})}catch(e){n.error(`failed to parse skill`,{file:i,error:e})}}return{skills:c}}},Wy=class extends wv{constructor(){super(`SubAgentInputPlugin`,{configKey:`shadowSubAgentDir`})}getTargetDir(e,t){let n=e.shadowSubAgentDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return Mt(e,t)}createResult(e){return{subAgents:e}}createPrompt(e,t,n,r,i,a,o,s){return{type:xt.SubAgent,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t}}}};const Gy=`.vscode`,Ky=[`.vscode/settings.json`,`.vscode/extensions.json`];var qy=class extends Og{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===Tt.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Ky){let r=this.joinPath(n.path,e);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===Tt.VSCode)?!0:(this.log.debug(`skipped`,{reason:`no VS Code config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===Tt.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==Tt.VSCode)return this.basename(t);let n=t.indexOf(Gy);return n===-1?this.joinPath(Gy,this.basename(t)):t.slice(Math.max(0,n))}};const Jy=`WARP.md`;var Yy=class extends Og{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:Jy})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Jy));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Jy)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Jy))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.debug(`skipped`,{reason:`AgentsOutputPlugin registered but no global memory`}),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.debug(`skipped`,{reason:`no outputs to write`}),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},Xy=class extends jg{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),i=t.externalProjects.map(e=>{let t=this.resolvePath(e,n,r);return{name:f.basename(t),dirFromWorkspacePath:{pathKind:L.Relative,path:t,basePath:n,getDirectoryName:()=>f.basename(t)}}});return{workspace:{directory:{pathKind:L.Absolute,path:n,getDirectoryName:()=>f.basename(n)},projects:[]},shadowSourceProjectDir:r,...i.length>0&&{externalProjects:i}}}},Zy=xr({plugins:[new Ag,new Fg,new Hg,new cv,new pv,new Zv,new Cv,new Ev,new jv,new Cy,new iy,new Fy,new Yy,new my,new Sv,new Lv,new ey,new qy,new Ly,new sy,new ay,new ty,new Xy,new zy,new Ng,new Vv,new Uy,new Tv,new Wy,new Bv,new Ey,new Ry,new zv,new Nv]});async function Qy(){let e=await Zy;await new pr(...u.default.argv).run(e)}Qy().catch(e=>console.error(e)),exports.CircularDependencyError=Et,exports.ClaudeCodeCLISubAgentColors=I,exports.CodingAgentTools=St,exports.ConfigLoader=cn,exports.ConfigValidationError=Ot,exports.DEFAULT_CONFIG_FILE_NAME=nn,exports.DEFAULT_GLOBAL_CONFIG_DIR=rn,exports.DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE=zt,exports.DEFAULT_USER_CONFIG=R,exports.FilePathKind=L,exports.GlobalConfigDirectoryType=wt,exports.IDEKind=Tt,exports.MissingDependencyError=Dt,exports.NamingCaseKind=Ct,exports.PathPlaceholders=Ut,exports.PluginKind=bt,exports.PromptKind=xt,exports.SHADOW_SOURCE_DIR_NAMES=It,exports.SHADOW_SOURCE_FILE_NAMES=Lt,exports.SHADOW_SOURCE_RELATIVE_PATHS=Rt,exports.SKILL_RESOURCE_BINARY_EXTENSIONS=Ft,exports.SKILL_RESOURCE_TEXT_EXTENSIONS=Pt,exports.applyMetadataDefaults=Nt,exports.checkCanClean=dt,exports.checkCanWrite=pt,exports.checkVersionControl=jn,exports.collectAllPluginOutputs=ut,exports.createLogger=tn,exports.default=Zy,exports.defineConfig=xr,exports.executeOnCleanComplete=ft,exports.executeWriteOutputs=mt,exports.generateShadowSourceProject=Nn,exports.getConfigLoader=un,exports.getDefaultUserConfig=on,exports.getGlobalConfigPath=an,exports.getGlobalLogLevel=en,exports.loadUserConfig=dn,exports.mergeConfig=gr,exports.setGlobalLogLevel=$t,exports.validateAndEnsureGlobalConfig=fn,exports.validateExportMetadata=kt,exports.validateFastCommandMetadata=jt,exports.validateSkillMetadata=At,exports.validateSubAgentMetadata=Mt;
1204
+ `}collect(e){return{}}};const ry=`.config/opencode`,iy=`opencode.json`;var ay=class extends sv{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:ry,outputFileName:`AGENTS.md`,commandsSubDir:`commands`,agentsSubDir:`agents`,skillsSubDir:`skills`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=f.join(t,iy);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset opencode.json mcp to empty`};try{if(d.existsSync(n)){let e=d.readFileSync(n,`utf8`),t=JSON.parse(e);t.mcp={},d.writeFileSync(n,JSON.stringify(t,null,2))}return this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset opencode.json mcp to empty`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset opencode.json mcp`}}})}async registerGlobalOutputFiles(e){let t=await super.registerGlobalOutputFiles(e),n=this.getGlobalConfigDir();if(e.collectedInputContext.skills?.some(e=>e.mcpConfig!=null)??!1){let e=f.join(n,iy);t.push({pathKind:L.Relative,path:iy,basePath:n,getDirectoryName:()=>ry,getAbsolutePath:()=>e})}return t.map(e=>{let t=e.path.replaceAll(`\\`,`/`),r=`/${this.skillsSubDir}/`,i=`${this.skillsSubDir}/`;if(!(t.includes(r)||t.startsWith(i)))return e;let a=t.split(`/`),o=a.indexOf(this.skillsSubDir);if(o<0||o+1>=a.length)return e;let s=a[o+1];if(s==null)return e;let c=this.validateAndNormalizeSkillName(s),l=[...a];l[o+1]=c;let u=l.join(`/`);return{...e,path:u,getDirectoryName:()=>c,getAbsolutePath:()=>f.join(n,u.replaceAll(`/`,f.sep))}})}async writeGlobalOutputs(e){let t=await super.writeGlobalOutputs(e),n=[...t.files],{skills:r}=e.collectedInputContext;if(r==null)return{files:n,dirs:t.dirs};let i=await this.writeGlobalMcpConfig(e,r);return i!=null&&n.push(i),{files:n,dirs:t.dirs}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForOpencode(r)}if(Object.keys(n).length===0)return null;let r=this.getGlobalConfigDir(),i=f.join(r,iy),a={pathKind:L.Relative,path:iy,basePath:r,getDirectoryName:()=>ry,getAbsolutePath:()=>i},o={};try{if(d.existsSync(i)){let e=d.readFileSync(i,`utf8`);o=JSON.parse(e)}}catch{o={}}o.$schema=`https://opencode.ai/config.json`,o.mcp=n;let s=JSON.stringify(o,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(r),d.writeFileSync(i,s),this.log.trace({action:`write`,type:`globalMcpConfig`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}transformMcpConfigForOpencode(e){let t={};if(e.command!=null){t.type=`local`;let n=[e.command];e.args!=null&&n.push(...e.args),t.command=n,e.env!=null&&(t.environment=e.env)}else{t.type=`remote`;let n=e;n.url==null?n.serverUrl!=null&&(t.url=n.serverUrl):t.url=n.url}return t.enabled=e.disabled!==!0,t}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,i=f.join(t,this.agentsSubDir),a=f.join(i,r),o=this.buildOpencodeAgentFrontMatter(n),s=this.buildMarkdownContent(n.content,o);return[await this.writeFile(e,a,s,`subAgent`)]}buildOpencodeAgentFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),t.mode=n?.mode??`subagent`,n?.model!=null&&(t.model=n.model),n?.temperature!=null&&(t.temperature=n.temperature),n?.maxSteps!=null&&(t.maxSteps=n.maxSteps),n?.hidden!=null&&(t.hidden=n.hidden),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}n?.permission!=null&&typeof n.permission==`object`&&(t.permission=n.permission);for(let[e,r]of Object.entries(n??{}))[`description`,`mode`,`model`,`temperature`,`maxSteps`,`hidden`,`allowTools`,`permission`,`namingCase`,`name`,`color`].includes(e)||(t[e]=r);return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),i=this.transformFastCommandName(n,r),a=f.join(t,this.commandsSubDir),o=f.join(a,i),s=this.buildOpencodeCommandFrontMatter(n),c=this.buildMarkdownContent(n.content,s);return[await this.writeFile(e,o,c,`fastCommand`)]}buildOpencodeCommandFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),n?.agent!=null&&(t.agent=n.agent),n?.model!=null&&(t.model=n.model),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}for(let[e,r]of Object.entries(n??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(t[e]=r);return t}async writeSkill(e,t,n){let r=[],i=this.validateAndNormalizeSkillName(n.yamlFrontMatter?.name??n.dir.getDirectoryName()),a=f.join(t,this.skillsSubDir,i),o=f.join(a,`SKILL.md`),s=this.buildOpencodeSkillFrontMatter(n,i),c=this.buildMarkdownContent(n.content,s),l=await this.writeFile(e,o,c,`skill`);if(r.push(l),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}return r}buildOpencodeSkillFrontMatter(e,t){let n={},r=e.yamlFrontMatter;n.name=t,r?.description!=null&&(n.description=r.description),n.license=r?.license??`MIT`,n.compatibility=r?.compatibility??`opencode`;let i={};for(let e of[`author`,`version`,`keywords`,`category`,`repository`,`displayName`])r?.[e]!=null&&(i[e]=r[e]);let a=new Set([`name`,`description`,`license`,`compatibility`,`namingCase`,`allowTools`,`keywords`,`displayName`,`author`,`version`]);for(let[e,t]of Object.entries(r??{}))a.has(e)||(i[e]=t);return Object.keys(i).length>0&&(n.metadata=i),n}validateAndNormalizeSkillName(e){let t=e.toLowerCase();return t=t.replaceAll(/[^a-z0-9-]+/g,`-`),t=t.replaceAll(/-+/g,`-`),t=t.replaceAll(/^-|-$/g,``),t.length===0?t=`skill`:t.length>64&&(t=t.slice(0,64),t=t.replace(/-$/,``)),t}},oy=class extends jg{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));let f=[];return n===`app`?f.push(a.join(r,`app`,l)):f.push(a.join(r,`src`,n,l)),!f.some(e=>i.existsSync(e))}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}},sy=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??nn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):f.resolve(e)}getRegistryDir(){return f.dirname(this.registryPath)}ensureRegistryDir(){let e=this.getRegistryDir();d.existsSync(e)||d.mkdirSync(e,{recursive:!0})}read(){if(!d.existsSync(this.registryPath))return this.log.debug(`registry not found`,{path:this.registryPath}),this.createInitialRegistry();try{let e=d.readFileSync(this.registryPath,`utf8`);return JSON.parse(e)}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`parse failed`,{path:this.registryPath,error:t}),this.createInitialRegistry()}}write(e,t){let n={...e,lastUpdated:new Date().toISOString()};if(t===!0)return this.log.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let r=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return d.writeFileSync(r,e,`utf8`),d.renameSync(r,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,path:this.registryPath,error:t});try{d.existsSync(r)&&d.unlinkSync(r)}catch{}return!1}}register(e,t){let n=[],r=this.read(),i=this.merge(r,e),a=this.write(i,t);for(let r of e){let e=this.getEntryName(r);a?(n.push({success:!0,entryName:e}),t===!0?this.log.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`entry`,entryName:e})):(n.push({success:!1,entryName:e,error:Error(`Failed to write registry file`)}),this.log.error(`register entry failed`,{entryName:e}))}return n}generateEntryId(e){let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e==null?t:`${e}-${t}`}},cy=class extends jg{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return(0,g.createHash)(`sha256`).update(e).digest(`hex`)}collect(e){return{}}};const ly=`.codeium/windsurf`,uy=`global_workflows`,dy=`memories`,fy=`global_rules.md`,py=`skills`,my=`SKILL.md`;var hy=class extends Og{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:ly,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]})}async registerGlobalOutputDirs(e){let t=[],{fastCommands:n,skills:r}=e.collectedInputContext;if(n!=null&&n.length>0){let e=this.getGlobalWorkflowsDir();t.push({pathKind:L.Relative,path:uy,basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>uy,getAbsolutePath:()=>e})}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name,r=f.join(this.getCodeiumWindsurfDir(),py,n);t.push({pathKind:L.Relative,path:f.join(py,n),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>n,getAbsolutePath:()=>r})}return t}async registerGlobalOutputFiles(e){let t=[],{skills:n,fastCommands:r}=e.collectedInputContext;if(r!=null&&r.length>0){let n=this.getGlobalWorkflowsDir(),i=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of r){let r=this.transformFastCommandName(e,i),a=f.join(n,r);t.push({pathKind:L.Relative,path:f.join(uy,r),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>uy,getAbsolutePath:()=>a})}}if(n==null||n.length===0)return t;let i=this.getSkillsDir(),a=this.getCodeiumWindsurfDir();for(let e of n){let n=e.yamlFrontMatter.name,r=f.join(i,n);if(t.push({pathKind:L.Relative,path:f.join(py,n,my),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,my)}),e.childDocs!=null)for(let i of e.childDocs){let e=i.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:f.join(py,n,e),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,e)})}if(e.resources!=null)for(let i of e.resources)t.push({pathKind:L.Relative,path:f.join(py,n,i.relativePath),basePath:a,getDirectoryName:()=>n,getAbsolutePath:()=>f.join(r,i.relativePath)})}return t}async canWrite(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=(t?.length??0)>0,a=(n?.length??0)>0;return i||a||r!=null?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=[],a=[];if(r!=null){let t=await this.writeGlobalMemory(e,r.content);i.push(t)}if(t!=null&&t.length>0){let n=this.getSkillsDir();for(let r of t){let t=await this.writeGlobalSkill(e,n,r);i.push(...t)}}if(n==null||n.length===0)return{files:i,dirs:a};let o=this.getGlobalWorkflowsDir();for(let t of n){let n=await this.writeGlobalWorkflow(e,o,t);i.push(n)}return{files:i,dirs:a}}async writeProjectOutputs(){return{files:[],dirs:[]}}getSkillsDir(){return f.join(this.getCodeiumWindsurfDir(),py)}getCodeiumWindsurfDir(){return f.join(this.getHomeDir(),ly)}getGlobalMemoriesDir(){return f.join(this.getCodeiumWindsurfDir(),dy)}getGlobalWorkflowsDir(){return f.join(this.getCodeiumWindsurfDir(),uy)}async writeGlobalMemory(e,t){let n=this.getGlobalMemoriesDir(),r=f.join(n,fy),i=this.getCodeiumWindsurfDir(),a={pathKind:L.Relative,path:f.join(dy,fy),basePath:i,getDirectoryName:()=>dy,getAbsolutePath:()=>r};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(r,t),this.log.trace({action:`write`,type:`globalMemory`,path:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),{path:a,success:!1,error:e}}}async writeGlobalWorkflow(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),i=this.transformFastCommandName(n,r),a=f.join(t,i),o={pathKind:L.Relative,path:f.join(uy,i),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>uy,getAbsolutePath:()=>a},s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalWorkflow`,path:a}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(t),d.writeFileSync(a,s),this.log.trace({action:`write`,type:`globalWorkflow`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalWorkflow`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter.name,a=f.join(t,i),o=f.join(a,my),s=this.getCodeiumWindsurfDir(),c={pathKind:L.Relative,path:f.join(py,i,my),basePath:s,getDirectoryName:()=>i,getAbsolutePath:()=>o},l=this.buildSkillFrontMatter(n),u=n.content,d=wg(l,u);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:c,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,d),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:c,success:!1,error:e})}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,a,i,s);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,a,i,s);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillChildDoc(e,t,n,r,i){let a=t.relativePath.replace(/\.mdx$/,`.md`),o=f.join(n,a),s={pathKind:L.Relative,path:f.join(py,r,a),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>o},c=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:o}),{path:s,success:!0,skipped:!1};try{let e=f.dirname(o);return this.ensureDirectory(e),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`childDoc`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:o,error:t}),{path:s,success:!1,error:e}}}async writeSkillResource(e,t,n,r,i){let a=f.join(n,t.relativePath),o={pathKind:L.Relative,path:f.join(py,r,t.relativePath),basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:a}),{path:o,success:!0,skipped:!1};try{let e=f.dirname(a);if(this.ensureDirectory(e),t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`);this.writeFileSyncBuffer(a,e)}else this.writeFileSync(a,t.content);return this.log.trace({action:`write`,type:`resource`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:a,error:t}),{path:o,success:!1,error:e}}}},gy=class e extends sy{static REGISTRY_PATH=`~/.kiro/powers/registry.json`;static DEFAULT_VERSION=`1.0.0`;constructor(t){super(e.REGISTRY_PATH,t)}createInitialRegistry(){return{version:e.DEFAULT_VERSION,powers:{},repoSources:{},lastUpdated:new Date().toISOString()}}getEntryName(e){return e.name}merge(e,t){let n={...e.powers},r={...e.repoSources};for(let e of t){n[e.name]=e;let t=this.buildRepoSource(e),i=e.source.repoId??e.name;r[i]=t}return{version:e.version,powers:n,repoSources:r,...e.kiroRecommendedRepo!=null&&{kiroRecommendedRepo:e.kiroRecommendedRepo},lastUpdated:e.lastUpdated}}buildPowerEntry(e,t){let{yamlFrontMatter:n,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}buildRepoSource(e){let t=new Date().toISOString();return{name:e.sourcePath??e.installPath??e.name,type:`local`,enabled:!0,addedAt:t,powerCount:1,...e.sourcePath!=null&&{path:e.sourcePath},lastSync:t}}};const _y=`GLOBAL.md`,vy=`.kiro`,yy=`steering`,by=`settings`,xy=`mcp.json`,Sy=`POWER.md`,Cy=`SKILL.md`;var wy=class extends Og{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:vy,outputFileName:_y}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(gy).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry`}:{success:!1,description:`Failed`,error:Error(`Registry cleanup failed`)}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.joinPath(this.getGlobalSettingsDir(),xy),n=JSON.stringify({mcpServers:{},powers:{mcpServers:{}}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:t}),{success:!0,description:`Would reset mcp.json`};let r=await this.writeFile(e,t,n,`mcpSettingsCleanup`);return r.success?{success:!0,description:`Reset mcp.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),vy,by)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),yy)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroSkillsDir(){return this.joinPath(this.getHomeDir(),`.kiro/skills`)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,vy,yy),e.dirFromWorkspacePath.basePath,()=>yy))}async registerProjectOutputFiles(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(!(e.dirFromWorkspacePath==null||e.childMemoryPrompts==null))for(let t of e.childMemoryPrompts)n.push(this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,vy,yy,this.buildSteeringFileName(t)),e.dirFromWorkspacePath.basePath,()=>yy));return n}async registerGlobalOutputDirs(){let e=[this.createRelativePath(yy,this.getGlobalConfigDir(),()=>yy)],t=this.getKiroPowersDir();for(let n of this.listInstalledPowers(t))e.push(this.createRelativePath(n,t,()=>n));let n=this.getKiroSkillsDir();for(let t of this.listInstalledPowers(n))e.push(this.createRelativePath(t,n,()=>t));return e.push(this.createRelativePath(`repos`,this.joinPath(this.getHomeDir(),`.kiro/powers`),()=>`repos`)),e}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=this.getGlobalSteeringDir(),a=[];if(t!=null&&a.push(this.createRelativePath(_y,i,()=>yy)),n!=null)for(let e of n)a.push(this.createRelativePath(this.buildFastCommandSteeringFileName(e),i,()=>yy));if(r==null)return a;let o=this.getKiroPowersDir(),s=this.getKiroSkillsDir();for(let e of r){let t=e.yamlFrontMatter.name;if(e.mcpConfig!=null){let n=this.joinPath(o,t);if(a.push(this.createRelativePath(Sy,n,()=>t)),a.push(this.createRelativePath(xy,n,()=>t)),e.childDocs!=null)for(let t of e.childDocs)a.push(this.createRelativePath(this.joinPath(yy,t.dir.path.replace(/\.mdx$/,`.md`)),n,()=>yy));if(e.resources!=null)for(let t of e.resources)a.push(this.createRelativePath(this.joinPath(yy,t.relativePath),n,()=>yy))}else{let n=this.joinPath(s,t);if(a.push(this.createRelativePath(Cy,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}}return r.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(xy,this.getGlobalSettingsDir(),()=>by)),a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let r of t)if(!(r.dirFromWorkspacePath==null||r.childMemoryPrompts==null))for(let t of r.childMemoryPrompts)n.push(await this.writeSteeringFile(e,r,t));return{files:n,dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.getGlobalSteeringDir();if(t!=null&&i.push(await this.writeFile(e,this.joinPath(o,_y),t.content,`globalMemory`)),n!=null)for(let t of n)i.push(await this.writeFastCommandSteeringFile(e,t));if(r==null||r.length===0)return{files:i,dirs:[]};let s=r.filter(e=>e.mcpConfig!=null),c=r.filter(e=>e.mcpConfig==null);for(let t of s){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),a.push(r)}for(let t of c){let n=await this.writeSkillAsKiroSkill(e,t);i.push(...n)}let l=await this.writeGlobalMcpSettings(e,r);return l!=null&&i.push(l),this.logRegistryResults(a,e.dryRun),{files:i,dirs:[]}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t)if(e.mcpConfig!=null)for(let[t,r]of Object.entries(e.mcpConfig.mcpServers))n[`power-${e.yamlFrontMatter.name}-${t}`]=r;if(Object.keys(n).length===0)return null;let r=JSON.stringify({mcpServers:{},powers:{mcpServers:n}},null,2);return this.writeFile(e,this.joinPath(this.getGlobalSettingsDir(),xy),r,`globalMcpSettings`)}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),r>0&&this.log.error({action:`register`,type:`registrySummary`,failCount:r})}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,Sy),o=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`skillPower`)),t.childDocs!=null){let r=this.joinPath(i,yy);for(let i of t.childDocs){let t=i.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(r,t),i.content,`refDoc`))}}if(t.resources!=null){let r=this.joinPath(i,yy);for(let i of t.resources)n.push(await this.writeFile(e,this.joinPath(r,i.relativePath),i.content,`resource`))}t.mcpConfig!=null&&n.push(await this.writeFile(e,this.joinPath(i,xy),t.mcpConfig.rawContent,`mcpConfig`));let s=this.getRegistryWriter(gy),c=s.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(s,[c],e))[0]??{success:!1,entryName:r,error:Error(`No registry result`)}}}async writeSkillAsKiroSkill(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroSkillsDir(),r),a=this.joinPath(i,Cy),o=`${this.buildSkillFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`kiroSkill`)),t.childDocs!=null)for(let r of t.childDocs){let t=r.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(i,t),r.content,`refDoc`))}if(t.resources!=null)for(let r of t.resources)n.push(await this.writeFile(e,this.joinPath(i,r.relativePath),r.content,`resource`));return n}buildSkillFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,description:e.description,...e.displayName!=null&&{displayName:e.displayName},...e.keywords!=null&&e.keywords.length>0&&{keywords:e.keywords},...e.author!=null&&{author:e.author}}).trimEnd()}buildPowerFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author}).trimEnd()}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}async writeFastCommandSteeringFile(e,t){let n=this.buildFastCommandSteeringFileName(t),r=this.joinPath(this.getGlobalSteeringDir(),n),i=t.yamlFrontMatter?.description,a=this.buildMarkdownContent(t.content,{inclusion:`manual`,description:i!=null&&i.length>0?i:null});return this.writeFile(e,r,a,`fastCommandSteering`)}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,vy,yy),o=this.joinPath(a,i),s=n.workingChildDirectoryPath?.path??n.dir.path,c=this.buildMarkdownContent(n.content,{inclusion:`fileMatch`,fileMatchPattern:`${s.replaceAll(`\\`,`/`)}/**`});return this.writeFile(e,o,c,`steeringFile`)}};const Ty=`agt.mdx`,Ey=[`node_modules`,`.git`];var Dy=class extends jg{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,n){let{fs:r,path:i,logger:a}=e,o=i.join(t,Ty);if(!(!r.existsSync(o)||!r.statSync(o).isFile()))try{let e=r.readFileSync(o,`utf8`),i=Tg(e),s;try{s=await ov(e,{globalScope:n,basePath:t})}catch(e){throw e instanceof Ug&&(a.error(`MDX compilation failed in ${o}: ${e.message}`),a.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}return{type:xt.ProjectRootMemory,content:s,length:s.length,filePathKind:L.Relative,...i.yamlFrontMatter!=null&&{yamlFrontMatter:i.yamlFrontMatter},...i.rawFrontMatter!=null&&{rawFrontMatter:i.rawFrontMatter},markdownAst:i.markdownAst,markdownContents:i.markdownContents,dir:{pathKind:L.Root,path:``,getDirectoryName:()=>``}}}catch(e){a.error(`Failed to read root memory prompt at ${o}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||Ey.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,Ty);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c=o.join(n,Ty);try{let e=a.readFileSync(c,`utf8`),l=Tg(e),d;try{d=await ov(e,{globalScope:i,basePath:n})}catch(e){throw e instanceof Ug&&(s.error(`MDX compilation failed in ${c}: ${e.message}`),s.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}let f=o.relative(t,n),p=o.join(r,f),m=o.basename(n);return{type:xt.ProjectChildrenMemory,content:d,length:d.length,filePathKind:L.Relative,...l.yamlFrontMatter!=null&&{yamlFrontMatter:l.yamlFrontMatter},...l.rawFrontMatter!=null&&{rawFrontMatter:l.rawFrontMatter},markdownAst:l.markdownAst,markdownContents:l.markdownContents,dir:{pathKind:L.Relative,path:f,basePath:r,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:L.Relative,path:f,basePath:r,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){s.error(`Failed to read child memory prompt at ${c}`,{error:e});return}}};const Oy=`.qoder`,ky=`rules`,Ay=`commands`,jy=`skills`,My=`global.md`,Ny=`always.md`,Py=`SKILL.md`,Fy=`mcp.json`;var Iy=class extends Og{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:Oy})}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createProjectRulesDirPath(e.dirFromWorkspacePath))}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{globalMemory:r}=e.collectedInputContext;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(r!=null&&t.push(this.createProjectRuleFilePath(n,My)),e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFilePath(n,Ny)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts)t.push(this.createProjectRuleFilePath(n,this.buildChildRuleFileName(r)))}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,i=[];if(n!=null&&n.length>0&&i.push(this.createRelativePath(Ay,t,()=>Ay)),r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;i.push(this.createRelativePath(f.join(jy,n),t,()=>n))}return i}async registerGlobalOutputFiles(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(n!=null&&n.length>0)for(let e of n){let n=this.transformFastCommandName(e,a);i.push(this.createRelativePath(f.join(Ay,n),t,()=>Ay))}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;if(i.push(this.createRelativePath(f.join(jy,n,Py),t,()=>n)),e.mcpConfig!=null&&i.push(this.createRelativePath(f.join(jy,n,Fy),t,()=>n)),e.childDocs!=null)for(let r of e.childDocs)i.push(this.createRelativePath(f.join(jy,n,r.relativePath.replace(/\.mdx$/,`.md`)),t,()=>n));if(e.resources!=null)for(let r of e.resources)i.push(this.createRelativePath(f.join(jy,n,r.relativePath),t,()=>n))}return i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{globalMemory:n}=e.collectedInputContext,r=[];for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=i.dirFromWorkspacePath;if(n!=null){let i=this.buildAlwaysRuleContent(n.content);r.push(await this.writeProjectRuleFile(e,t,My,i,`globalRule`))}if(i.rootMemoryPrompt!=null){let n=this.buildAlwaysRuleContent(i.rootMemoryPrompt.content);r.push(await this.writeProjectRuleFile(e,t,Ny,n,`projectRootRule`))}if(i.childMemoryPrompts!=null)for(let n of i.childMemoryPrompts){let i=this.buildChildRuleFileName(n),a=this.buildGlobRuleContent(n);r.push(await this.writeProjectRuleFile(e,t,i,a,`projectChildRule`))}}return{files:r,dirs:[]}}async writeGlobalOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],i=this.getGlobalConfigDir(),a=f.join(i,Ay),o=f.join(i,jy);if(t!=null&&t.length>0)for(let n of t)r.push(await this.writeGlobalFastCommand(e,a,n));if(n!=null&&n.length>0)for(let t of n)r.push(...await this.writeGlobalSkill(e,o,t));return{files:r,dirs:[]}}createProjectRulesDirPath(e){return this.createRelativePath(f.join(e.path,Oy,ky),e.basePath,()=>ky)}createProjectRuleFilePath(e,t){return this.createRelativePath(f.join(e.path,Oy,ky,t),e.basePath,()=>ky)}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e){return wg({trigger:`always_on`,type:`user_command`},e)}buildGlobRuleContent(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return wg({trigger:`glob`,glob:t.length===0?`**/*`:`${t}/**`,type:`user_command`},e.content)}async writeProjectRuleFile(e,t,n,r,i){let a=f.join(t.basePath,t.path,Oy,ky),o=f.join(a,n);return this.writeFile(e,o,r,i)}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),i=this.transformFastCommandName(n,r),a=f.join(t,i),o=wg(this.buildFastCommandFrontMatter(n),n.content);return this.writeFile(e,a,o,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter.name,a=f.join(t,i),o=f.join(a,Py),s=wg(this.buildSkillFrontMatter(n),n.content);if(r.push(await this.writeFile(e,o,s,`skill`)),n.mcpConfig!=null){let t=f.join(a,Fy);r.push(await this.writeFile(e,t,n.mcpConfig.rawContent,`mcpConfig`))}if(n.childDocs!=null)for(let t of n.childDocs){let n=f.join(a,t.relativePath.replace(/\.mdx$/,`.md`));r.push(await this.writeFile(e,n,t.content,`childDoc`))}if(n.resources!=null)for(let t of n.resources){let n=f.join(a,t.relativePath);if(t.encoding===`base64`){let e=h.Buffer.from(t.content,`base64`),o=f.dirname(n);this.ensureDirectory(o),this.writeFileSyncBuffer(n,e),r.push({path:this.createRelativePath(t.relativePath,a,()=>i),success:!0})}else r.push(await this.writeFile(e,n,t.content,`resource`))}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,type:`user_command`,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}buildFastCommandFrontMatter(e){let t=e.yamlFrontMatter;return t==null?{description:`Fast command`,type:`user_command`}:{description:t.description,type:`user_command`,...t.argumentHint!=null&&{argumentHint:t.argumentHint},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}};const Ly=`README.md`;var Ry=class extends Og{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:Ly})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let{targetDir:n}=e,r=f.join(n.path,Ly);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>f.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no README prompts to write`}),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let{targetDir:n}=t,r=f.join(n.path,Ly),i=f.join(n.basePath,r),a=t.content,o={pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i},s=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`readme`,path:i,label:s}),{path:o,success:!0,skipped:!1};try{let e=f.dirname(i);return d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.writeFileSync(i,a,`utf8`),this.log.trace({action:`write`,type:`readme`,path:i,label:s}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:i,label:s,error:t}),{path:o,success:!1,error:e}}}},zy=class extends jg{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,n,r,i,a,o){let{fs:s,path:c,logger:l}=e,d=i===``,f=c.join(t,`rdm.mdx`);if(s.existsSync(f)&&s.statSync(f).isFile())try{let e=s.readFileSync(f,`utf8`),p;if(o!=null)try{p=await ov(e,{globalScope:o,basePath:t})}catch(e){throw e instanceof Ug&&(l.error(`MDX compilation failed in ${f}: ${e.message}`),l.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),u.default.exit(1)),e}else p=e;let m=d?n:c.join(n,i),h={pathKind:L.Relative,path:m,basePath:r,getDirectoryName:()=>d?n:c.basename(i),getAbsolutePath:()=>c.resolve(r,m)},g={pathKind:L.Relative,path:c.dirname(f),basePath:r,getDirectoryName:()=>c.basename(c.dirname(f)),getAbsolutePath:()=>c.dirname(f)};a.push({type:xt.Readme,content:p,length:p.length,filePathKind:L.Relative,projectName:n,targetDir:h,isRoot:d,markdownContents:[],dir:g})}catch(e){l.warn(`failed to read readme`,{path:f,error:e})}try{let l=s.readdirSync(t,{withFileTypes:!0});for(let s of l)if(s.isDirectory()){let l=d?s.name:c.join(i,s.name),u=c.join(t,s.name);await this.collectReadmeFiles(e,u,n,r,l,a,o)}}catch(e){l.warn(`failed to scan directory`,{path:t,error:e})}}},By=class extends jg{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:L.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}};function Vy(e){return Ft.includes(e.toLowerCase())}function Hy(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}function Uy(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}var Wy=class extends jg{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=f.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:xt.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}scanSkillDirectory(e,t,n,r=``){let i=[],a=[],o=r?f.join(e,r):e;try{let s=t.readdirSync(o,{withFileTypes:!0});for(let c of s){let s=r?`${r}/${c.name}`:c.name;if(c.isDirectory()){let r=this.scanSkillDirectory(e,t,n,s);i.push(...r.childDocs),a.push(...r.resources)}else if(c.isFile()){let l=f.join(o,c.name);if(c.name.endsWith(`.mdx`)){if(r===``&&c.name===`skill.mdx`)continue;try{let n=Tg(t.readFileSync(l,`utf8`)),r=Eg(n.contentWithoutFrontMatter);i.push({type:xt.SkillChildDoc,content:r,length:r.length,filePathKind:L.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:s,dir:{pathKind:L.Relative,path:s,basePath:e,getDirectoryName:()=>f.dirname(s),getAbsolutePath:()=>l}})}catch(e){n.warn(`failed to read child doc`,{path:s,error:e})}}else{if(r===``&&c.name===`mcp.json`)continue;let e=f.extname(c.name),i,o,u;try{if(Vy(e)){let e=t.readFileSync(l);i=e.toString(`base64`),o=`base64`,{length:u}=e}else i=t.readFileSync(l,`utf8`),o=`text`,{length:u}=h.Buffer.from(i,`utf8`);let n=Uy(e),r={type:xt.SkillResource,extension:e,fileName:c.name,relativePath:s,content:i,encoding:o,category:Hy(e),length:u};n==null?a.push(r):a.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:s,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:o,error:e})}return{childDocs:i,resources:a}}async collect(e){let{userConfigOptions:t,logger:n,globalScope:r}=e,{workspaceDir:i,shadowProjectDir:a}=this.resolveBasePaths(t),o=t.shadowSkillSourceDir,s=this.resolvePath(o,i,a),c=[];if(!(e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory()))return{skills:c};let l=e.fs.readdirSync(s,{withFileTypes:!0});for(let t of l)if(t.isDirectory()){let i=e.path.join(s,t.name,`skill.mdx`);if(e.fs.existsSync(i)&&e.fs.statSync(i).isFile())try{let a=e.fs.readFileSync(i,`utf8`),o=Tg(a),l=await ov(a,{globalScope:r,extractMetadata:!0,basePath:e.path.join(s,t.name)}),u={...o.yamlFrontMatter,...l.metadata.fields},d=At(u,i);for(let e of d.warnings)n.debug(e);if(!d.valid)throw new Kg(d.errors,i);let p=Eg(l.content),m=e.path.join(s,t.name),h=this.readMcpConfig(m,e.fs,n),{childDocs:g,resources:_}=this.scanSkillDirectory(m,e.fs,n);n.debug(`skill metadata extracted`,{skill:t.name,source:l.metadata.source,hasYaml:o.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),c.push({type:xt.Skill,content:p,length:p.length,filePathKind:L.Relative,yamlFrontMatter:u.name==null?{name:t.name,description:``}:u,...o.rawFrontMatter!=null&&{rawFrontMatter:o.rawFrontMatter},markdownAst:o.markdownAst,markdownContents:o.markdownContents,...h!=null&&{mcpConfig:h},...g.length>0&&{childDocs:g},..._.length>0&&{resources:_},dir:{pathKind:L.Relative,path:t.name,basePath:s,getDirectoryName:()=>t.name,getAbsolutePath:()=>f.join(s,t.name)}})}catch(e){n.error(`failed to parse skill`,{file:i,error:e})}}return{skills:c}}},Gy=class extends wv{constructor(){super(`SubAgentInputPlugin`,{configKey:`shadowSubAgentDir`})}getTargetDir(e,t){let n=e.shadowSubAgentDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return Mt(e,t)}createResult(e){return{subAgents:e}}createPrompt(e,t,n,r,i,a,o,s){return{type:xt.SubAgent,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t}}}};const Ky=`.vscode`,qy=[`.vscode/settings.json`,`.vscode/extensions.json`];var Jy=class extends Og{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===Tt.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of qy){let r=this.joinPath(n.path,e);t.push({pathKind:L.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===Tt.VSCode)?!0:(this.log.debug(`skipped`,{reason:`no VS Code config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===Tt.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==Tt.VSCode)return this.basename(t);let n=t.indexOf(Ky);return n===-1?this.joinPath(Ky,this.basename(t)):t.slice(Math.max(0,n))}};const Yy=`WARP.md`;var Xy=class extends Og{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:Yy})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Yy));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Yy)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Yy))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.debug(`skipped`,{reason:`AgentsOutputPlugin registered but no global memory`}),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.debug(`skipped`,{reason:`no outputs to write`}),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},Zy=class extends jg{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),i=t.externalProjects.map(e=>{let t=this.resolvePath(e,n,r);return{name:f.basename(t),dirFromWorkspacePath:{pathKind:L.Relative,path:t,basePath:n,getDirectoryName:()=>f.basename(t)}}});return{workspace:{directory:{pathKind:L.Absolute,path:n,getDirectoryName:()=>f.basename(n)},projects:[]},shadowSourceProjectDir:r,...i.length>0&&{externalProjects:i}}}},Qy=xr({plugins:[new Ag,new Fg,new Hg,new cv,new pv,new Qv,new Cv,new Ev,new jv,new wy,new ay,new Iy,new Xy,new hy,new Sv,new Lv,new ty,new Jy,new Ry,new cy,new oy,new ny,new Zy,new By,new Ng,new Hv,new Wy,new Tv,new Gy,new Vv,new Dy,new zy,new Bv,new Nv]});async function $y(){let e=await Qy;await new pr(...u.default.argv).run(e)}$y().catch(e=>console.error(e)),exports.CircularDependencyError=Et,exports.ClaudeCodeCLISubAgentColors=I,exports.CodingAgentTools=St,exports.ConfigLoader=ln,exports.ConfigValidationError=Ot,exports.DEFAULT_CONFIG_FILE_NAME=rn,exports.DEFAULT_GLOBAL_CONFIG_DIR=an,exports.DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE=zt,exports.DEFAULT_USER_CONFIG=R,exports.FilePathKind=L,exports.GlobalConfigDirectoryType=wt,exports.IDEKind=Tt,exports.MissingDependencyError=Dt,exports.NamingCaseKind=Ct,exports.PathPlaceholders=Ut,exports.PluginKind=bt,exports.PromptKind=xt,exports.SHADOW_SOURCE_DIR_NAMES=It,exports.SHADOW_SOURCE_FILE_NAMES=Lt,exports.SHADOW_SOURCE_RELATIVE_PATHS=Rt,exports.SKILL_RESOURCE_BINARY_EXTENSIONS=Ft,exports.SKILL_RESOURCE_TEXT_EXTENSIONS=Pt,exports.applyMetadataDefaults=Nt,exports.checkCanClean=dt,exports.checkCanWrite=pt,exports.checkVersionControl=jn,exports.collectAllPluginOutputs=ut,exports.createLogger=nn,exports.default=Qy,exports.defineConfig=xr,exports.executeOnCleanComplete=ft,exports.executeWriteOutputs=mt,exports.generateShadowSourceProject=Nn,exports.getConfigLoader=dn,exports.getDefaultUserConfig=sn,exports.getGlobalConfigPath=on,exports.getGlobalLogLevel=tn,exports.loadUserConfig=fn,exports.mergeConfig=gr,exports.setGlobalLogLevel=en,exports.validateAndEnsureGlobalConfig=pn,exports.validateExportMetadata=kt,exports.validateFastCommandMetadata=jt,exports.validateSkillMetadata=At,exports.validateSubAgentMetadata=Mt;