buddy-agent-harness 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/dist/cli.mjs +14193 -24818
- package/dist/index.d.mts +11 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +183 -772
- package/dist/index.mjs.map +1 -1
- package/dist/skill-scripts/doctor.mjs +122 -180
- package/dist/skill-scripts/init.mjs +122 -180
- package/dist/skill-scripts/mcp.mjs +122 -180
- package/llms.txt +11 -8
- package/package.json +4 -4
- package/plugin.json +2 -2
- package/skills/doctor-buddy-agent-harness/README.md +1 -1
- package/skills/doctor-buddy-agent-harness/SKILL.md +3 -3
- package/skills/doctor-buddy-agent-harness/references/bridges.md +2 -2
- package/skills/doctor-buddy-agent-harness/references/configuration.md +4 -4
- package/skills/doctor-buddy-agent-harness/references/instructions.md +6 -6
- package/skills/doctor-buddy-agent-harness/references/judgment/claude-code.md +64 -0
- package/skills/doctor-buddy-agent-harness/references/judgment/codex.md +19 -0
- package/skills/doctor-buddy-agent-harness/references/judgment/copilot-cli.md +16 -0
- package/skills/doctor-buddy-agent-harness/references/judgment/cursor.md +36 -0
- package/skills/doctor-buddy-agent-harness/references/judgment/devin-desktop.md +19 -0
- package/skills/doctor-buddy-agent-harness/references/judgment/gemini-cli.md +30 -0
- package/skills/doctor-buddy-agent-harness/references/mcp.md +4 -4
- package/skills/doctor-buddy-agent-harness/references/nonstandard.md +4 -4
- package/skills/doctor-buddy-agent-harness/scripts/doctor.mjs +122 -180
- package/skills/enhance/SKILL.md +5 -5
- package/skills/enhance/references/agents-md.md +150 -0
- package/skills/enhance/references/detection.md +36 -0
- package/skills/enhance/references/global-instructions.md +33 -0
- package/skills/enhance/scripts/doctor.mjs +122 -180
- package/skills/init-buddy-agent-harness/SKILL.md +1 -1
- package/skills/init-buddy-agent-harness/scripts/doctor.mjs +122 -180
- package/skills/init-buddy-agent-harness/scripts/init.mjs +122 -180
- package/skills/repair/SKILL.md +3 -3
- package/skills/repair/references/agents-md.md +150 -0
- package/skills/repair/references/classes.md +2 -2
- package/skills/repair/scripts/doctor.mjs +122 -180
- package/skills/repair/scripts/mcp.mjs +122 -180
- package/src/cli.ts +22 -4
- package/src/command-output/command-output.ts +15 -55
- package/src/dep-plugins/dep-plugins.command.ts +8 -14
- package/src/dep-plugins/dep-plugins.ts +1 -1
- package/src/dep-plugins/resolve.ts +1 -1
- package/src/diagnose-bridges/doctor-guidance.ts +64 -54
- package/src/diagnose-bridges/doctor.command.ts +12 -22
- package/src/governance-overrides/governance-overrides.ts +18 -8
- package/src/governance-overrides/governance.command.ts +19 -37
- package/src/harness-registry/harness-registry.ts +3 -4
- package/src/index.ts +5 -8
- package/src/initialize-harnesses/init.command.ts +9 -19
- package/src/initialize-harnesses/initialize-harnesses.ts +2 -2
- package/src/project-mcp/mcp.command.ts +14 -25
- package/src/reconcile-mcp/reconcile.command.ts +15 -26
- package/src/references/references.ts +6 -6
- package/dist/dist-ktNZ1sJo.mjs +0 -2966
- package/dist/esm-BMqwcD7W.mjs +0 -87
- package/dist/esm-CVacKtt6.mjs +0 -64
|
@@ -4,99 +4,43 @@
|
|
|
4
4
|
// Runs `buddy-agent-harness init` from this bundle against the current working
|
|
5
5
|
// directory. Nothing outside this file is read.
|
|
6
6
|
|
|
7
|
-
import{createRequire as e}from"node:module";import t,{cpSync as n,existsSync as r,lstatSync as i,mkdirSync as a,readFileSync as o,readdirSync as s,readlinkSync as c,realpathSync as l,rmSync as u,rmdirSync as d,statSync as p,symlinkSync as m,writeFileSync as h}from"node:fs";import g,{dirname as _,extname as v,join as y,parse as b,posix as x,relative as S,resolve as C,sep as w,win32 as T}from"node:path";import{fileURLToPath as E,pathToFileURL as D}from"node:url";import{homedir as ee,platform as te}from"node:os";import{readFile as ne,readdir as re}from"node:fs/promises";import{execFileSync as ie}from"node:child_process";var ae=Object.create,oe=Object.defineProperty,__name=(e,t)=>oe(e,`name`,{value:t,configurable:!0}),se=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyNames,le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty,__esmMin=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),__exportAll=(e,t)=>{let n={};for(var r in e)oe(n,r,{get:e[r],enumerable:!0});return t||oe(n,Symbol.toStringTag,{value:`Module`}),n},__copyProps=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ce(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ue.call(e,s)&&s!==n&&oe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=se(t,s))||r.enumerable});return e},__toESM=(e,t,n)=>(n=e==null?{}:ae(le(e)),__copyProps(t||!e||!e.__esModule||!ue.call(e,`default`)?oe(n,`default`,{value:e,enumerable:!0}):n,e)),O=e(import.meta.url);const k={success:0,error:1,usage:2},de=Symbol.for(`clibuilder.CliError`);function isCliError(e){return!!e&&typeof e==`object`&&e[de]===!0}const fe={maxLength:120,references:[]};function hasTersifyFn(e){return typeof e.tersify==`function`}function isBuffer(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function trim({raw:e,noTrim:t},n,r){if(t||e||n.length<=r)return n;let i=n.slice(0,Math.max(r,0)),a=i.length===0?``:i.length<=3?`.`:i.length===4?`..`:`...`;return i.slice(0,i.length-a.length)+a}const A=new Map;A.set(`!`,16),A.set(`~`,16),A.set(`+`,16),A.set(`-`,16),A.set(`++`,16),A.set(`--`,16),A.set(`**`,15),A.set(`*`,14),A.set(`/`,14),A.set(`%`,14),A.set(`+`,13),A.set(`-`,13),A.set(`<<`,12),A.set(`>>`,12),A.set(`>>>`,12),A.set(`<`,11),A.set(`<=`,11),A.set(`>`,11),A.set(`>=`,11),A.set(`&`,9),A.set(`^`,8),A.set(`|`,7),A.set(`&&`,6),A.set(`||`,5);function isHigherOperatorOrder(e,t){return A.get(e)>A.get(t)}var pe=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],me=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],he=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,ge=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,_e={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},ve=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,ye={5:ve,"5module":ve+` export import`,6:ve+` const class extends export import super`},be=/^in(stanceof)?$/,xe=RegExp(`[`+ge+`]`),Se=RegExp(`[`+ge+he+`]`);function isInAstralSet(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function isIdentifierStart(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&xe.test(String.fromCharCode(e)):t!==!1&&isInAstralSet(e,me)}function isIdentifierChar(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Se.test(String.fromCharCode(e)):t===!1?!1:isInAstralSet(e,me)||isInAstralSet(e,pe)}var j=function TokenType(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function binop(e,t){return new j(e,{beforeExpr:!0,binop:t})}var Ce={beforeExpr:!0},we={startsExpr:!0},Te={};function kw(e,t){return t===void 0&&(t={}),t.keyword=e,Te[e]=new j(e,t)}var M={num:new j(`num`,we),regexp:new j(`regexp`,we),string:new j(`string`,we),name:new j(`name`,we),privateId:new j(`privateId`,we),eof:new j(`eof`),bracketL:new j(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new j(`]`),braceL:new j(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new j(`}`),parenL:new j(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new j(`)`),comma:new j(`,`,Ce),semi:new j(`;`,Ce),colon:new j(`:`,Ce),dot:new j(`.`),question:new j(`?`,Ce),questionDot:new j(`?.`),arrow:new j(`=>`,Ce),template:new j(`template`),invalidTemplate:new j(`invalidTemplate`),ellipsis:new j(`...`,Ce),backQuote:new j("`",we),dollarBraceL:new j("${",{beforeExpr:!0,startsExpr:!0}),eq:new j(`=`,{beforeExpr:!0,isAssign:!0}),assign:new j(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new j(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new j(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop(`||`,1),logicalAND:binop(`&&`,2),bitwiseOR:binop(`|`,3),bitwiseXOR:binop(`^`,4),bitwiseAND:binop(`&`,5),equality:binop(`==/!=/===/!==`,6),relational:binop(`</>/<=/>=`,7),bitShift:binop(`<</>>/>>>`,8),plusMin:new j(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop(`%`,10),star:binop(`*`,10),slash:binop(`/`,10),starstar:new j(`**`,{beforeExpr:!0}),coalesce:binop(`??`,1),_break:kw(`break`),_case:kw(`case`,Ce),_catch:kw(`catch`),_continue:kw(`continue`),_debugger:kw(`debugger`),_default:kw(`default`,Ce),_do:kw(`do`,{isLoop:!0,beforeExpr:!0}),_else:kw(`else`,Ce),_finally:kw(`finally`),_for:kw(`for`,{isLoop:!0}),_function:kw(`function`,we),_if:kw(`if`),_return:kw(`return`,Ce),_switch:kw(`switch`),_throw:kw(`throw`,Ce),_try:kw(`try`),_var:kw(`var`),_const:kw(`const`),_while:kw(`while`,{isLoop:!0}),_with:kw(`with`),_new:kw(`new`,{beforeExpr:!0,startsExpr:!0}),_this:kw(`this`,we),_super:kw(`super`,we),_class:kw(`class`,we),_extends:kw(`extends`,Ce),_export:kw(`export`),_import:kw(`import`,we),_null:kw(`null`,we),_true:kw(`true`,we),_false:kw(`false`,we),_in:kw(`in`,{beforeExpr:!0,binop:7}),_instanceof:kw(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:kw(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Ee=/\r\n?|\n|\u2028|\u2029/,De=new RegExp(Ee.source,`g`);function isNewLine(e){return e===10||e===13||e===8232||e===8233}function nextLineBreak(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(isNewLine(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Oe=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,N=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ke=Object.prototype,Ae=ke.hasOwnProperty,je=ke.toString,Me=Object.hasOwn||(function(e,t){return Ae.call(e,t)}),Ne=Array.isArray||(function(e){return je.call(e)===`[object Array]`}),Pe=Object.create(null);function wordsRegexp(e){return Pe[e]||(Pe[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Fe=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Ie=function Position(e,t){this.line=e,this.column=t};Ie.prototype.offset=function offset(e){return new Ie(this.line,this.column+e)};var Le=function SourceLocation(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function getLineInfo(e,t){for(var n=1,r=0;;){var i=nextLineBreak(e,r,t);if(i<0)return new Ie(n,t-r);++n,r=i}}var Re={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ze=!1;function getOptions(e){var t={};for(var n in Re)t[n]=e&&Me(e,n)?e[n]:Re[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ze&&typeof console==`object`&&console.warn&&(ze=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
8
|
-
|
|
9
|
-
`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Ee).length)):this.lineStart=0,this.type=M.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||e.strict===!0||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(this.options.sourceType===`commonjs`?Ve:Be),this.regexpState=null,this.privateNameStack=[]},it={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};P.prototype.parse=function parse(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},it.inFunction.get=function(){return(this.currentVarScope().flags&Ve)>0},it.inGenerator.get=function(){return(this.currentVarScope().flags&Ue)>0},it.inAsync.get=function(){return(this.currentVarScope().flags&He)>0},it.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Je|Ye))return!1;if(t&Ve)return(t&He)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},it.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Be)},it.allowSuper.get=function(){return(this.currentThisScope().flags&Ke)>0||this.options.allowSuperOutsideMethod},it.allowDirectSuper.get=function(){return(this.currentThisScope().flags&qe)>0},it.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},it.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Je|Ye)||t&Ve&&!(t&We))return!0}return!1},it.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Xe||!this.inModule&&e&Be)},it.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Je)>0},P.extend=function extend(){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},P.parse=function parse(e,t){return new this(t,e).parse()},P.parseExpressionAt=function parseExpressionAt(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},P.tokenizer=function tokenizer(e,t){return new this(t,e)},Object.defineProperties(P.prototype,it);var F=P.prototype,ot=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;F.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){N.lastIndex=e,e+=N.exec(this.input)[0].length;var t=ot.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){N.lastIndex=e+t[0].length;var n=N.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Ee.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,N.lastIndex=e,e+=N.exec(this.input)[0].length,this.input[e]===`;`&&e++}},F.eat=function(e){return this.type===e&&(this.next(),!0)},F.isContextual=function(e){return this.type===M.name&&this.value===e&&!this.containsEsc},F.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},F.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},F.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},F.canInsertSemicolon=function(){return this.type===M.eof||this.type===M.braceR||Ee.test(this.input.slice(this.lastTokEnd,this.start))},F.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},F.semicolon=function(){!this.eat(M.semi)&&!this.insertSemicolon()&&this.unexpected()},F.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},F.expect=function(e){this.eat(e)||this.unexpected()},F.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var st=function DestructuringErrors(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};F.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`)}},F.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`)},F.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`)},F.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var I=P.prototype;I.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==M.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===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var ct={kind:`loop`},lt={kind:`switch`};I.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;N.lastIndex=this.pos;var t=N.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(isIdentifierStart(r)){var i=n;do n+=r<=65535?1:2;while(isIdentifierChar(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!be.test(a))return!0}return!1},I.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;N.lastIndex=this.pos;var e=N.exec(this.input),t=this.pos+e[0].length,n;return!Ee.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(isIdentifierChar(n=this.fullCharCodeAt(t+8))||n===92))},I.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;N.lastIndex=this.pos;var n=N.exec(this.input),r=this.pos+n[0].length;if(Ee.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||isIdentifierChar(a=this.fullCharCodeAt(i))||a===92)return!1;N.lastIndex=i;var o=N.exec(this.input);if(r=i+o[0].length,o&&Ee.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!isIdentifierStart(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(isIdentifierChar(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(be.test(l))return!1;if(t&&!e&&l===`of`){N.lastIndex=r;var u=N.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},I.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},I.isUsing=function(e){return this.isUsingKeyword(!1,e)},I.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=M._var,a=`let`),r){case M._break:case M._continue:return this.parseBreakContinueStatement(i,r.keyword);case M._debugger:return this.parseDebuggerStatement(i);case M._do:return this.parseDoStatement(i);case M._for:return this.parseForStatement(i);case M._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case M._class:return e&&this.unexpected(),this.parseClass(i,!0);case M._if:return this.parseIfStatement(i);case M._return:return this.parseReturnStatement(i);case M._switch:return this.parseSwitchStatement(i);case M._throw:return this.parseThrowStatement(i);case M._try:return this.parseTryStatement(i);case M._const:case M._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case M._while:return this.parseWhileStatement(i);case M._with:return this.parseWithStatement(i);case M.braceL:return this.parseBlock(!0,i);case M.semi:return this.parseEmptyStatement(i);case M._export:case M._import:if(this.options.ecmaVersion>10&&r===M._import){N.lastIndex=this.pos;var o=N.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===M._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 this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),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===M.name&&d.type===`Identifier`&&this.eat(M.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},I.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(M.semi)||this.insertSemicolon()?e.label=null:this.type===M.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`)},I.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},I.parseDoStatement=function(e){return this.next(),this.labels.push(ct),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(M._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(M.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},I.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(ct),this.enterScope(0),this.expect(M.parenL),this.type===M.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===M._var||this.type===M._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.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new st,d=this.start,p=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===M._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===M._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(p.start===d&&!l&&p.type===`Identifier`&&p.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(p.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(p,!1,u),this.checkLValPattern(p),this.parseForIn(e,p)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,p))},I.parseForAfterInit=function(e,t,n){return(this.type===M._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===M._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},I.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,dt|(n?0:ft),!1,t)},I.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(M._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},I.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(M.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},I.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(M.braceL),this.labels.push(lt),this.enterScope(Xe);for(var t,n=!1;this.type!==M.braceR;)if(this.type===M._case||this.type===M._default){var r=this.type===M._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(M.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`)},I.parseThrowStatement=function(e){return this.next(),Ee.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 ut=[];I.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?Ge:0),this.checkLValPattern(e,t?nt:et),this.expect(M.parenR),e},I.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===M._catch){var t=this.startNode();this.next(),this.eat(M.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(M._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},I.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},I.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ct),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},I.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`)},I.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},I.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===M._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`)},I.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},I.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(M.braceL),e&&this.enterScope(0);this.type!==M.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},I.parseFor=function(e,t){return e.init=t,this.expect(M.semi),e.test=this.type===M.semi?null:this.parseExpression(),this.expect(M.semi),e.update=this.type===M.parenR?null:this.parseExpression(),this.expect(M.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},I.parseForIn=function(e,t){var n=this.type===M._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(M.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},I.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(M.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===M._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==M._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&(!t||this.type!==M._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(M.comma))break}return e},I.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?$e:et,!1)};var dt=1,ft=2,pt=4;I.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===M.star&&t&ft&&this.unexpected(),e.generator=this.eat(M.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&dt&&(e.id=t&pt&&this.type!==M.name?null:this.parseIdent(),e.id&&!(t&ft)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?$e:et:tt));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(functionFlags(e.async,e.generator)),t&dt||(e.id=this.type===M.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&dt?`FunctionDeclaration`:`FunctionExpression`)},I.parseFunctionParams=function(e){this.expect(M.parenL),e.params=this.parseBindingList(M.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},I.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(M.braceL);this.type!==M.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`&&isPrivateNameConflicted(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`)},I.parseClassElement=function(e){if(this.eat(M.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(M.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===M.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===M.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(M.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===M.parenL||o!==`method`||i||a){var l=!n.static&&checkKeyName(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},I.isClassElementNameStart=function(){return this.type===M.name||this.type===M.privateId||this.type===M.num||this.type===M.string||this.type===M.bracketL||this.type.keyword},I.parseClassElementName=function(e){this.type===M.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)},I.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&&checkKeyName(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`)},I.parseClassField=function(e){return checkKeyName(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&checkKeyName(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(M.eq)?(this.enterScope(Ye|Ke),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},I.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Je|Ke);this.type!==M.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},I.parseClassId=function(e,t){this.type===M.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,et,!1)):(t===!0&&this.unexpected(),e.id=null)},I.parseClassSuper=function(e){e.superClass=this.eat(M._extends)?this.parseExprSubscripts(null,!1):null},I.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},I.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];Me(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function isPrivateNameConflicted(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 checkKeyName(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}I.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!==M.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},I.parseExport=function(e,t){if(this.next(),this.eat(M.star))return this.parseExportAllDeclaration(e,t);if(this.eat(M._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!==M.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`)},I.parseExportDeclaration=function(e){return this.parseStatement(null)},I.parseExportDefaultDeclaration=function(){var e;if(this.type===M._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,dt|pt,!1,e)}if(this.type===M._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},I.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Me(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},I.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)},I.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)}},I.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},I.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`)},I.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(M.braceL);!this.eat(M.braceR);){if(n)n=!1;else if(this.expect(M.comma),this.afterTrailingComma(M.braceR))break;t.push(this.parseExportSpecifier(e))}return t},I.parseImport=function(e){return this.next(),this.type===M.string?(e.specifiers=ut,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===M.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},I.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,et),this.finishNode(e,`ImportSpecifier`)},I.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,et),this.finishNode(e,`ImportDefaultSpecifier`)},I.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,et),this.finishNode(e,`ImportNamespaceSpecifier`)},I.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===M.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(M.comma)))return e;if(this.type===M.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(M.braceL);!this.eat(M.braceR);){if(t)t=!1;else if(this.expect(M.comma),this.afterTrailingComma(M.braceR))break;e.push(this.parseImportSpecifier())}return e},I.parseWithClause=function(){var e=[];if(!this.eat(M._with))return e;this.expect(M.braceL);for(var t={},n=!0;!this.eat(M.braceR);){if(n)n=!1;else if(this.expect(M.comma),this.afterTrailingComma(M.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Me(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},I.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===M.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(M.colon),this.type!==M.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},I.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===M.string){var e=this.parseLiteral(this.value);return Fe.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},I.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)},I.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 mt=P.prototype;mt.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},mt.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},mt.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},mt.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==M.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},mt.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case M.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(M.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case M.braceL:return this.parseObj(!0)}return this.parseIdent()},mt.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(M.comma),t&&this.type===M.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===M.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===M.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},mt.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},mt.parseBindingListItem=function(e){return e},mt.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(M.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},mt.checkLValSimple=function(e,t,n){t===void 0&&(t=Qe);var r=t!==Qe;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===et&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Me(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==rt&&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`)}},mt.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Qe),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)}},mt.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Qe),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 ht=function TokContext(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},L={b_stat:new ht(`{`,!1),b_expr:new ht(`{`,!0),b_tmpl:new ht("${",!1),p_stat:new ht(`(`,!1),p_expr:new ht(`(`,!0),q_tmpl:new ht("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ht(`function`,!1),f_expr:new ht(`function`,!0),f_expr_gen:new ht(`function`,!0,!1,null,!0),f_gen:new ht(`function`,!1,!1,null,!0)},gt=P.prototype;gt.initialContext=function(){return[L.b_stat]},gt.curContext=function(){return this.context[this.context.length-1]},gt.braceIsBlock=function(e){var t=this.curContext();return t===L.f_expr||t===L.f_stat?!0:e===M.colon&&(t===L.b_stat||t===L.b_expr)?!t.isExpr:e===M._return||e===M.name&&this.exprAllowed?Ee.test(this.input.slice(this.lastTokEnd,this.start)):e===M._else||e===M.semi||e===M.eof||e===M.parenR||e===M.arrow?!0:e===M.braceL?t===L.b_stat:e===M._var||e===M._const||e===M.name?!1:!this.exprAllowed},gt.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},gt.updateContext=function(e){var t,n=this.type;n.keyword&&e===M.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},gt.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},M.parenR.updateContext=M.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===L.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},M.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?L.b_stat:L.b_expr),this.exprAllowed=!0},M.dollarBraceL.updateContext=function(){this.context.push(L.b_tmpl),this.exprAllowed=!0},M.parenL.updateContext=function(e){var t=e===M._if||e===M._for||e===M._with||e===M._while;this.context.push(t?L.p_stat:L.p_expr),this.exprAllowed=!0},M.incDec.updateContext=function(){},M._function.updateContext=M._class.updateContext=function(e){e.beforeExpr&&e!==M._else&&(e!==M.semi||this.curContext()===L.p_stat)&&!(e===M._return&&Ee.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==M.colon&&e!==M.braceL||this.curContext()!==L.b_stat)?this.context.push(L.f_expr):this.context.push(L.f_stat),this.exprAllowed=!1},M.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},M.backQuote.updateContext=function(){this.curContext()===L.q_tmpl?this.context.pop():this.context.push(L.q_tmpl),this.exprAllowed=!1},M.star.updateContext=function(e){if(e===M._function){var t=this.context.length-1;this.context[t]===L.f_expr?this.context[t]=L.f_expr_gen:this.context[t]=L.f_gen}this.exprAllowed=!0},M.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==M.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var R=P.prototype;R.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}},R.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===M.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(M.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},R.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 st,r=!0);var s=this.start,c=this.startLoc;(this.type===M.parenL||this.type===M.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===M.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===M.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`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},R.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat(M.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(M.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},R.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)},R.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==M._in)&&a>r){var o=this.type===M.logicalOR||this.type===M.logicalAND,s=this.type===M.coalesce;s&&(a=M.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),p=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===M.coalesce||s&&(this.type===M.logicalOR||this.type===M.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(p,t,n,r,i)}return e},R.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`)},R.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===M.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`&&isLocalVariableAccess(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&isPrivateFieldAccess(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===M.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==M._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&&(o.type!==`ArrowFunctionExpression`||o.start!==i)&&this.eat(M.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 isLocalVariableAccess(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&isLocalVariableAccess(e.expression)}function isPrivateFieldAccess(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&isPrivateFieldAccess(e.expression)||e.type===`ParenthesizedExpression`&&isPrivateFieldAccess(e.expression)}R.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},R.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}},R.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(M.arrow)},R.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},R.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(M.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(M.bracketL);if(l||c&&this.type!==M.parenL&&this.type!==M.backQuote||this.eat(M.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(M.bracketR)):u.property=this.type===M.privateId&&e.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(M.parenL)){var d=new st,p=this.yieldPos,m=this.awaitPos,h=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(M.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=p,this.awaitPos=m,this.awaitIdentPos=h,this.parseSubscriptAsyncArrow(t,n,g,o);this.checkExpressionErrors(d,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=h||this.awaitIdentPos;var _=this.startNodeAt(t,n);_.callee=e,_.arguments=g,s&&(_.optional=c),e=this.finishNode(_,`CallExpression`)}else if(this.type===M.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var v=this.startNodeAt(t,n);v.tag=e,v.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(v,`TaggedTemplateExpression`)}return e},R.parseExprAtom=function(e,t,n){this.type===M.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case M._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===M.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==M.dot&&this.type!==M.bracketL&&this.type!==M.parenL&&this.unexpected(),this.finishNode(r,`Super`);case M._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case M.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(M._function))return this.overrideContext(L.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(M.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===M.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(M.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case M.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case M.num:case M.string:return this.parseLiteral(this.value);case M._null:case M._true:case M._false:return r=this.startNode(),r.value=this.type===M._null?null:this.type===M._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case M.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 M.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(M.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case M.braceL:return this.overrideContext(L.b_expr),this.parseObj(!1,e);case M._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case M._class:return this.parseClass(this.startNode(),!1);case M._new:return this.parseNew();case M.backQuote:return this.parseTemplate();case M._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},R.parseExprAtomDefault=function(){this.unexpected()},R.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===M.parenL&&!e)return this.parseDynamicImport(t);if(this.type===M.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)}this.unexpected()},R.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(M.parenR)?e.options=null:(this.expect(M.comma),this.afterTrailingComma(M.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(M.parenR)||(this.expect(M.comma),this.afterTrailingComma(M.parenR)||this.unexpected())));else if(!this.eat(M.parenR)){var t=this.start;this.eat(M.comma)&&this.eat(M.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},R.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`)},R.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`)},R.parseParenExpression=function(){this.expect(M.parenL);var e=this.parseExpression();return this.expect(M.parenR),e},R.shouldParseArrow=function(e){return!this.canInsertSemicolon()},R.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 st,p=this.yieldPos,m=this.awaitPos,h;for(this.yieldPos=0,this.awaitPos=0;this.type!==M.parenR;){if(l?l=!1:this.expect(M.comma),a&&this.afterTrailingComma(M.parenR,!0)){u=!0;break}if(this.type===M.ellipsis){h=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===M.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}c.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var g=this.lastTokEnd,_=this.lastTokEndLoc;if(this.expect(M.parenR),e&&this.shouldParseArrow(c)&&this.eat(M.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=m,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),h&&this.unexpected(h),this.checkExpressionErrors(d,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=m||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,g,_)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(n,r);return v.expression=i,this.finishNode(v,`ParenthesizedExpression`)}return i},R.parseParenItem=function(e){return e},R.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var _t=[];R.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===M.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),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),e.arguments=this.eat(M.parenL)?this.parseExprList(M.parenR,this.options.ecmaVersion>=8,!1):_t,this.finishNode(e,`NewExpression`)},R.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===M.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
10
|
-
`)
|
|
11
|
-
`),cooked:this.value},this.next(),n.tail=this.type===M.backQuote,this.finishNode(n,`TemplateElement`)},R.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===M.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(M.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(M.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},R.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===M.name||this.type===M.num||this.type===M.string||this.type===M.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===M.star)&&!Ee.test(this.input.slice(this.lastTokEnd,this.start))},R.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(M.braceR);){if(r)r=!1;else if(this.expect(M.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(M.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`)},R.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(M.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===M.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===M.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(M.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(M.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},R.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`)},R.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===M.colon&&this.unexpected(),this.eat(M.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===M.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!==M.comma&&this.type!==M.braceR&&this.type!==M.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===M.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()},R.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(M.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(M.bracketR),e.key;e.computed=!1}return e.key=this.type===M.num||this.type===M.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},R.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},R.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(functionFlags(t,r.generator)|Ke|(n?qe:0)),this.expect(M.parenL),r.params=this.parseBindingList(M.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`)},R.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(functionFlags(n,!1)|We),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`)},R.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==M.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,rt),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},R.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},R.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,$e,t?null:n)}},R.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(M.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===M.comma?o=null:this.type===M.ellipsis?(o=this.parseSpread(r),r&&this.type===M.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},R.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&Ze)&&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`))},R.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},R.parseIdentNode=function(){var e=this.startNode();return this.type===M.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=M.name):this.unexpected(),e},R.parsePrivateIdent=function(){var e=this.startNode();return this.type===M.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},R.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===M.semi||this.canInsertSemicolon()||this.type!==M.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(M.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},R.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 vt=P.prototype;vt.raise=function(e,t){var n=getLineInfo(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},vt.raiseRecoverable=vt.raise,vt.curPosition=function(){if(this.options.locations)return new Ie(this.curLine,this.pos-this.lineStart)};var yt=P.prototype,bt=function Scope(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};yt.enterScope=function(e){this.scopeStack.push(new bt(e))},yt.exitScope=function(){this.scopeStack.pop()},yt.treatFunctionsAsVarInScope=function(e){return e.flags&Ve||!this.inModule&&e.flags&Be},yt.declareName=function(e,t,n){var r=!1;if(t===et){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&Be&&delete this.undefinedExports[e]}else if(t===nt)this.currentScope().lexical.push(e);else if(t===tt){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&Ge&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&Be&&delete this.undefinedExports[e],s.flags&Ze)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},yt.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},yt.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},yt.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ze|Ye|Je))return t}},yt.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ze|Ye|Je)&&!(t.flags&We))return t}};var xt=function Node(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new Le(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},St=P.prototype;St.startNode=function(){return new xt(this,this.start,this.startLoc)},St.startNodeAt=function(e,t){return new xt(this,e,t)};function finishNodeAt(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}St.finishNode=function(e,t){return finishNodeAt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},St.finishNodeAt=function(e,t,n,r){return finishNodeAt.call(this,e,t,n,r)},St.copyNode=function(e){var t=new xt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Ct=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,wt=`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=wt+` Extended_Pictographic`,Et=Tt,Dt=Et+` EBase EComp EMod EPres ExtPict`,Ot=Dt,kt={9:wt,10:Tt,11:Et,12:Dt,13:Ot,14:Ot},At={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},jt=`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`,Mt=`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`,Nt=Mt+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,Pt=Nt+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,Ft=Pt+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,It=Ft+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,Lt={9:Mt,10:Nt,11:Pt,12:Ft,13:It,14:It+` `+Ct},Rt={};function buildUnicodeData(e){var t=Rt[e]={binary:wordsRegexp(kt[e]+` `+jt),binaryOfStrings:wordsRegexp(At[e]),nonBinary:{General_Category:wordsRegexp(jt),Script:wordsRegexp(Lt[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 zt=0,Bt=[9,10,11,12,13,14];zt<Bt.length;zt+=1){var Vt=Bt[zt];buildUnicodeData(Vt)}var z=P.prototype,Ht=function BranchID(e,t){this.parent=e,this.base=t||this};Ht.prototype.separatedFrom=function separatedFrom(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},Ht.prototype.sibling=function sibling(){return new Ht(this.parent,this.base)};var Ut=function RegExpValidationState(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=Rt[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};Ut.prototype.reset=function reset(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)},Ut.prototype.raise=function raise(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ut.prototype.at=function at(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},Ut.prototype.nextIndex=function nextIndex(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},Ut.prototype.current=function current(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ut.prototype.lookahead=function lookahead(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ut.prototype.advance=function advance(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ut.prototype.eat=function eat(e,t){return t===void 0&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Ut.prototype.eatChars=function eatChars(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},z.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 hasProp(e){for(var t in e)return!0;return!1}z.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&hasProp(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},z.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`)}},z.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Ht(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`)},z.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},z.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},z.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},z.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},z.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},z.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},z.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)},z.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},z.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},z.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},z.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&isRegularExpressionModifier(n);)t+=codePointToString(n),e.advance();return t};function isRegularExpressionModifier(e){return e===105||e===109||e===115}z.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)},z.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},z.regexp_eatSyntaxCharacter=function(e){var t=e.current();return isSyntaxCharacter(t)?(e.lastIntValue=t,e.advance(),!0):!1};function isSyntaxCharacter(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}z.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!isSyntaxCharacter(n);)e.advance();return e.pos!==t},z.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)},z.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}},z.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},z.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=codePointToString(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=codePointToString(e.lastIntValue);return!0}return!1},z.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),isRegExpIdentifierStart(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function isRegExpIdentifierStart(e){return isIdentifierStart(e,!0)||e===36||e===95}z.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),isRegExpIdentifierPart(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function isRegExpIdentifierPart(e){return isIdentifierChar(e,!0)||e===36||e===95||e===8204||e===8205}z.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)},z.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},z.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},z.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)},z.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},z.regexp_eatZero=function(e){return e.current()===48&&!isDecimalDigit(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},z.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)},z.regexp_eatControlLetter=function(e){var t=e.current();return isControlLetter(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function isControlLetter(e){return e>=65&&e<=90||e>=97&&e<=122}z.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)&&isValidUnicode(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function isValidUnicode(e){return e>=0&&e<=1114111}z.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)},z.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 Wt=0,Gt=1,Kt=2;z.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(isCharacterClassEscape(t))return e.lastIntValue=-1,e.advance(),Gt;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===Kt&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Wt};function isCharacterClassEscape(e){return e===100||e===68||e===115||e===83||e===119||e===87}z.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),Gt}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Wt},z.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Me(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},z.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Gt;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Kt;e.raise(`Invalid property name`)},z.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;isUnicodePropertyNameCharacter(t=e.current());)e.lastStringValue+=codePointToString(t),e.advance();return e.lastStringValue!==``};function isUnicodePropertyNameCharacter(e){return isControlLetter(e)||e===95}z.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;isUnicodePropertyValueCharacter(t=e.current());)e.lastStringValue+=codePointToString(t),e.advance();return e.lastStringValue!==``};function isUnicodePropertyValueCharacter(e){return isUnicodePropertyNameCharacter(e)||isDecimalDigit(e)}z.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},z.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===Kt&&e.raise(`Negated character class may contain strings`),!0}return!1},z.regexp_classContents=function(e){return e.current()===93?Gt:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Gt)},z.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`)}}},z.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||isOctalDigit(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r!==93&&(e.lastIntValue=r,e.advance(),!0)},z.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)},z.regexp_classSetExpression=function(e){var t=Gt,n;if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e)){n===Kt&&(t=Kt);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Kt&&(t=Gt);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===Kt&&(t=Kt)}},z.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},z.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Gt:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},z.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===Kt&&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},z.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},z.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Kt&&(t=Kt);return t},z.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Gt:Kt},z.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()&&isClassSetReservedDoublePunctuatorCharacter(n)||isClassSetSyntaxCharacter(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function isClassSetReservedDoublePunctuatorCharacter(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 isClassSetSyntaxCharacter(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}z.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return isClassSetReservedPunctuator(t)?(e.lastIntValue=t,e.advance(),!0):!1};function isClassSetReservedPunctuator(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}z.regexp_eatClassControlLetter=function(e){var t=e.current();return isDecimalDigit(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},z.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},z.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;isDecimalDigit(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function isDecimalDigit(e){return e>=48&&e<=57}z.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;isHexDigit(n=e.current());)e.lastIntValue=16*e.lastIntValue+hexToInt(n),e.advance();return e.pos!==t};function isHexDigit(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function hexToInt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}z.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;e.lastIntValue=t<=3&&this.regexp_eatOctalDigit(e)?t*64+n*8+e.lastIntValue:t*8+n}else e.lastIntValue=t;return!0}return!1},z.regexp_eatOctalDigit=function(e){var t=e.current();return isOctalDigit(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function isOctalDigit(e){return e>=48&&e<=55}z.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!isHexDigit(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+hexToInt(i),e.advance()}return!0};var qt=function Token(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new Le(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},B=P.prototype;B.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 qt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},B.getToken=function(){return this.next(),new qt(this)},typeof Symbol<`u`&&(B[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===M.eof,value:t}}}}),B.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(M.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},B.readToken=function(e){return isIdentifierStart(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},B.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},B.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},B.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=nextLineBreak(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())},B.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&&!isNewLine(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())},B.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&&Oe.test(String.fromCharCode(e)))++this.pos;else break loop}}},B.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)},B.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(M.ellipsis)):(++this.pos,this.finishToken(M.dot))},B.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(M.assign,2):this.finishOp(M.slash,1)},B.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?M.star:M.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=M.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(M.assign,n+1):this.finishOp(r,n)},B.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(M.assign,3):this.finishOp(e===124?M.logicalOR:M.logicalAND,2):t===61?this.finishOp(M.assign,2):this.finishOp(e===124?M.bitwiseOR:M.bitwiseAND,1)},B.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(M.assign,2):this.finishOp(M.bitwiseXOR,1)},B.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||Ee.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(M.incDec,2):t===61?this.finishOp(M.assign,2):this.finishOp(M.plusMin,1)},B.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(M.assign,n+1):this.finishOp(M.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(M.relational,n))},B.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(M.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(M.arrow)):this.finishOp(e===61?M.eq:M.prefix,1)},B.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(M.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(M.assign,3):this.finishOp(M.coalesce,2)}return this.finishOp(M.question,1)},B.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),isIdentifierStart(t,!0)||t===92))return this.finishToken(M.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+codePointToString(t)+`'`)},B.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(M.parenL);case 41:return++this.pos,this.finishToken(M.parenR);case 59:return++this.pos,this.finishToken(M.semi);case 44:return++this.pos,this.finishToken(M.comma);case 91:return++this.pos,this.finishToken(M.bracketL);case 93:return++this.pos,this.finishToken(M.bracketR);case 123:return++this.pos,this.finishToken(M.braceL);case 125:return++this.pos,this.finishToken(M.braceR);case 58:return++this.pos,this.finishToken(M.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(M.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(M.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+codePointToString(e)+`'`)},B.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},B.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(Ee.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 Ut(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(M.regexp,{pattern:i,flags:o,value:c})},B.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 stringToNumber(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function stringToBigInt(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}B.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=stringToBigInt(this.input.slice(t,this.pos)),++this.pos):isIdentifierStart(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(M.num,n)},B.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=stringToBigInt(this.input.slice(t,this.pos));return++this.pos,isIdentifierStart(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(M.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`)),isIdentifierStart(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=stringToNumber(this.input.slice(t,this.pos),n);return this.finishToken(M.num,a)},B.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},B.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)):(isNewLine(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(M.string,t)};var Jt={};B.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Jt)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},B.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Jt;this.raise(e,t)},B.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===M.template||this.type===M.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(M.dollarBraceL)):(++this.pos,this.finishToken(M.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(M.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(isNewLine(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+=`
|
|
12
|
-
`;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},B.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(M.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
|
|
13
|
-
`&&++this.pos;case`
|
|
14
|
-
`:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},B.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
15
|
-
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(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 isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},B.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},B.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(isIdentifierChar(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?isIdentifierStart:isIdentifierChar)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=codePointToString(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},B.readWord=function(){var e=this.readWord1(),t=M.name;return this.keywords.test(e)&&(t=Te[e]),this.finishToken(t,e)},P.acorn={Parser:P,version:`8.18.0`,defaultOptions:Re,Position:Ie,SourceLocation:Le,getLineInfo,Node:xt,TokenType:j,tokTypes:M,keywordTypes:Te,TokContext:ht,tokContexts:L,isIdentifierChar,isIdentifierStart,Token:qt,isNewLine,lineBreak:Ee,lineBreakG:De,nonASCIIwhitespace:Oe};function parseExpressionAt(e,t,n){return P.parseExpressionAt(e,t,n)}function tersifyAcorn(e,t,n){let r=getFunctionString(t),i=parseExpressionAt(`(${r})`,0,{ecmaVersion:2020});return tersifyAcornNode({...e,rawString:r},i,n)}function getFunctionString(e){let t=e.toString(),n=t.startsWith(`async `),r=n?t.slice(6):t,i=/^([^\s\\)]+)\s?\(/.exec(r);return i&&i[1]!==`function`&&i[1]!==`function*`?`${n?`async `:``}function ${t}`:t}function tersifyAcornNode(e,t,n){if(!t)return``;switch(t.type){case`Identifier`:return tersifyIdentifierNode(e,t,n);case`Literal`:return tersifyLiteralNode(e,t,n);case`AssignmentPattern`:return tersifyAssignmentPatternNode(e,t,n);case`RestElement`:case`SpreadElement`:return tersifyRestElementNode(e,t,n);case`ArrowFunctionExpression`:return tersifyArrowExpressionNode(e,t,n);case`ExpressionStatement`:return tersifyExpressionStatementNode(e,t,n);case`CallExpression`:return tersifyCallExpressionNode(e,t,n);case`MemberExpression`:return tersifyMemberExpressionNode(e,t,n);case`FunctionDeclaration`:case`FunctionExpression`:return tersifyFunctionExpressionNode(e,t,n);case`BlockStatement`:case`ClassBody`:return tersifyBlockStatementNode(e,t,n);case`ReturnStatement`:return tersifyReturnStatementNode(e,t,n);case`VariableDeclaration`:return tersifyVariableDeclarationNode(e,t,n);case`VariableDeclarator`:return tersifyVariableDeclaratorNode(e,t,n);case`NewExpression`:return tersifyNewExpressionNode(e,t,n);case`BinaryExpression`:case`LogicalExpression`:return tersifyBinaryExpressionNode(e,t,n);case`ConditionalExpression`:return tersifyConditionalExpressionNode(e,t,n);case`UnaryExpression`:return tersifyUnaryExpressionNode(e,t,n);case`UpdateExpression`:return tersifyUpdateExpressionNode(e,t,n);case`IfStatement`:return tersifyIfStatementNode(e,t,n);case`WhileStatement`:return tersifyWhileStatementNode(e,t,n);case`AssignmentExpression`:return tersifyAssignmentExpressionNode(e,t,n);case`DoWhileStatement`:return tersifyDoWhileStatementNode(e,t,n);case`EmptyStatement`:return tersifyEmptyStatementNode(e,t,n);case`ForStatement`:return tersifyForStatementNode(e,t,n);case`BreakStatement`:return tersifyBreakStatementNode(e,t,n);case`LabeledStatement`:return tersifyLabeledStatementNode(e,t,n);case`ContinueStatement`:return tersifyContinueStatementNode(e,t,n);case`SwitchStatement`:return tersifySwitchStatementNode(e,t,n);case`SwitchCase`:return tersifySwitchCaseNode(e,t,n);case`ForInStatement`:return tersifyForInStatementNode(e,t,n);case`ForOfStatement`:return tersifyForOfStatementNode(e,t,n);case`ObjectExpression`:return tersifyObjectExpressionNode(e,t,n);case`Property`:return tersifyPropertyNode(e,t,n);case`YieldExpression`:return tersifyYieldExpressionNode(e,t,n);case`AwaitExpression`:return tersifyAwaitExpressionNode(e,t,n);case`ArrayExpression`:return tersifyArrayExpressionNode(e,t,n);case`ThrowStatement`:return tersifyThrowStatementNode(e,t,n);case`TryStatement`:return tersifyTryStatementNode(e,t,n);case`CatchClause`:return tersifyCatchClauseNode(e,t,n);case`ThisExpression`:return tersifyThisExpression(e,t,n);case`ClassExpression`:return tersifyClassExpression(e,t,n);case`MethodDefinition`:return tersifyMethodDefinition(e,t,n);case`ObjectPattern`:return tersifyObjectPattern(e,t,n);case`SequenceExpression`:return tersifySequenceExpression(e,t,n);case`TemplateLiteral`:return tersifyTemplateLiteral(e,t,n);case`TaggedTemplateExpression`:return tersifyTaggedTemplateExpression(e,t,n);case`ChainExpression`:return tersifyChainExpression(e,t,n);case`MetaProperty`:return tersifyMetaProperty(e,t,n);case`Super`:return tersifySuperNode(e,t,n);default:return tersifyUnknown(t,e.rawString)}}function tersifyUnknown(e,t){let n=e.type;return console.warn(`tersify received unsupported type: ${n}. Please open an issue at https://github.com/cyberuni/tersify/issues
|
|
16
|
-
node detail:
|
|
17
|
-
${JSON.stringify(e,void 0,2)}
|
|
7
|
+
import{createRequire as e}from"node:module";import{cpSync as t,existsSync as n,lstatSync as r,mkdirSync as i,readFileSync as a,readdirSync as o,readlinkSync as s,realpathSync as c,rmSync as l,rmdirSync as u,statSync as d,symlinkSync as f,writeFileSync as p}from"node:fs";import{inspect as m,styleText as h}from"node:util";import{homedir as g,platform as _}from"node:os";import{basename as v,dirname as y,join as b,posix as x,relative as S,resolve as C,sep as w,win32 as T}from"node:path";import{readFile as E,readdir as ee}from"node:fs/promises";import{fileURLToPath as te}from"node:url";import{execFileSync as ne}from"node:child_process";var re=Object.defineProperty,__name=(e,t)=>re(e,`name`,{value:t,configurable:!0}),ie;const D={success:0,error:1,usage:2},ae=Symbol.for(`clibuilder.CliError`),oe=Symbol.for(`clibuilder.CliError.reported`),se=[`error`,`code`,`help`];var O=class CliError extends Error{static reported(e=D.error,t=`the error was already reported`){let n=new CliError(t,{exitCode:e});return n[oe]=!0,n}constructor(e,t){let n=typeof e==`string`?{...t,message:e}:e;super(n.message),this.name=`CliError`,this[ie]=!0,this.exitCode=validateExitCode(n.exitCode??D.error),this.code=validateCode(n.code??`error`),this.details=validateDetails(n.details??{}),this.help=n.help===void 0?[]:typeof n.help==`string`?[n.help]:[...n.help],this.cause=n.cause}};ie=ae;function isCliError(e){return!!e&&typeof e==`object`&&e[ae]===!0}function isReportedCliError(e){return e[oe]===!0}function validateExitCode(e){if(Number.isInteger(e)&&e>=1&&e<=255)return e;throw RangeError(`CliError exitCode must be an integer from 1 to 255, received ${e}`)}function validateCode(e){if(/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))return e;throw RangeError(`CliError code must be a kebab-case string such as "not-found", received "${e}"`)}function validateDetails(e){for(let t of se)if(t in e)throw RangeError(`CliError details may not have the key "${t}"`);return{...e}}function command(e){return e}function takesValue$1(e){let t=e.kind===`array`?e.element:e;return!(t.kind===`boolean`||t.kind===`literal`&&typeof t.value==`boolean`)}__name(takesValue$1,`takesValue`);function describeConstraint(e){switch(e.kind){case`string`:return e.pattern?`string ${e.pattern}`:`string`;case`number`:case`int`:return`${e.kind}${describeRange(e.min,e.max)}`;case`boolean`:case`json`:return e.kind;case`literal`:return String(e.value);case`enum`:return e.values.join(`|`);case`custom`:return`value`;case`array`:return describeConstraint(e.element)}}function describeRange(e,t){return e!==void 0&&t!==void 0?` ${e}..${t}`:e===void 0?t===void 0?``:` <=${t}`:` >=${e}`}const ce={optional(){return create({...this,isOptional:!0})},check(e){let t=typeof e==`function`?{type:`fn`,fn:e}:{type:`schema`,schema:e};if(typeof e!=`function`&&!isStandardSchema(e))throw TypeError(`check() takes a function or a Standard Schema`);return create({...this,checks:[...this.checks,t]})}};function create(e){return Object.freeze(Object.assign(Object.create(ce),e))}function make(e){return create({...e,isOptional:!1,checks:Object.freeze([])})}function isStandardSchema(e){let t=e?.[`~standard`];return typeof t==`object`&&!!t&&typeof t.validate==`function`}function checkBounds(e,t,n){let{min:r,max:i}=t??{};for(let[t,a]of[[`min`,r],[`max`,i]])if(a!==void 0){if(typeof a!=`number`||Number.isNaN(a))throw TypeError(`${e}: ${t} must be a number`);if(n&&Number.isFinite(a)&&!Number.isInteger(a))throw RangeError(`${e}: ${t} must be an integer, got ${a}`)}if(r!==void 0&&i!==void 0&&r>i)throw RangeError(`${e}: min (${r}) is greater than max (${i})`);return{...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}}function string(e){let t=e?.pattern;if(t!==void 0&&!(t instanceof RegExp))throw TypeError(`t.string: pattern must be a RegExp`);return make(t===void 0?{kind:`string`}:{kind:`string`,pattern:t})}function json(e){if(e===void 0)return make({kind:`json`});if(!isStandardSchema(e))throw TypeError(`t.json: schema must be a Standard Schema`);return make({kind:`json`,schema:e})}const k={string,number(e){return make({kind:`number`,...checkBounds(`t.number`,e,!1)})},int(e){return make({kind:`int`,...checkBounds(`t.int`,e,!0)})},boolean(){return make({kind:`boolean`})},literal(e){let t=typeof e;if(!(t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)))throw TypeError(`t.literal: value must be a string, a finite number or a boolean, got ${String(e)}`);return make({kind:`literal`,value:e})},enum(e){if(!Array.isArray(e)||e.length===0)throw TypeError(`t.enum: values must be a non-empty array`);for(let t of e)if(typeof t!=`string`)throw TypeError(`t.enum: values must be strings, got ${String(t)}`);return make({kind:`enum`,values:Object.freeze([...e])})},array(e){let t=e;if(typeof t?.kind!=`string`||!Object.prototype.isPrototypeOf.call(ce,t))throw TypeError(`t.array: element must be a descriptor`);if(t.kind===`array`)throw TypeError(`t.array: element cannot be an array`);if(t.isOptional)throw TypeError(`t.array: element cannot be optional`);return make({kind:`array`,element:e})},custom(e){if(typeof e!=`function`)throw TypeError(`t.custom: convert must be a function`);return make({kind:`custom`,convert:e})},json};function isDescriptor(e){return typeof e==`object`&&!!e&&Object.prototype.isPrototypeOf.call(ce,e)}String.prototype.charCodeAt;const le=String.prototype.slice;Array.prototype.forEach,Array.prototype.map,Array.prototype.reduce;const ue=Array.prototype.slice,de=Array.prototype.push,fe={modifiers:`-`,terminator:`--`};function resolveGrammar(e){let t=new Set,n=e?.modifiers??fe.modifiers;for(let e of typeof n==`string`?Array.from(n):n){if(e.length!==1||e===`=`)throw Error(`Invalid modifier '${e}': a modifier must be a single character other than '='`);t.add(e)}if(t.size===0)throw Error(`At least one modifier is required`);let r=e?.terminator??fe.terminator;if(r===``)throw Error(`The terminator must not be empty`);return{modifiers:t,terminator:r}}function trimModifiers(e,t){let n=0;for(;n<e.length&&t.has(e[n]);)n++;return[le.call(e,n),n]}function tokenizeArgs(e,t){let{modifiers:n,terminator:r}=resolveGrammar(t),i=[],a=0,o=ue.call(e);for(;o.length>0;){let e=o.shift();if(e===r){de.call(i,{kind:`option-terminator`,index:a}),a++,de.apply(i,o.map((e,t)=>({kind:`positional`,index:a+t,value:e})));break}let[t,s]=trimModifiers(e,n);if(s===0||!t)de.call(i,{kind:`positional`,index:a,value:t||e});else{let n=t.indexOf(`=`),[r,o]=n===-1?[t,void 0]:[le.call(t,0,n),le.call(t,n+1)];de.call(i,{kind:`option`,index:a,name:r,dashes:s,raw:e,value:o})}a++}return i}var ParseArgsError=class extends Error{constructor(e,t,n,r={}){super(e),Object.defineProperty(this,"option",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"input",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"kind",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"issues",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"detail",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=`ParseArgsError`,this.kind=r.kind??`invalid-value`,this.index=r.index,this.issues=r.issues,this.value=r.value,this.detail=r.detail??e}};function parseArgs(e){let t=parse$1(e),n=t.next();for(;!n.done;){let{value:e,option:r}=n.value;if(isThenable(e))throw e.then(void 0,()=>{}),t.return(void 0),Error(`Option '${r}' has an asynchronous converter or check: use parseArgsAsync() to parse it`);n=t.next(e)}return n.value}async function parseArgsAsync(e){let t=parse$1(e),n=t.next();for(;!n.done;)n=await Promise.resolve(n.value.value).then(e=>t.next(e),e=>t.throw(e));return n.value}function isThenable(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function*parse$1(e){let t=tokenizeArgs(e.args,e.grammar),n=e.options;checkDeclarations(n);let r=canonicalNames(n),i=Object.create(null),a=Object.create(null),o=[],s=[],c=t.slice();for(;c.length>0;){let t=c.shift();switch(t.kind){case`positional`:checkPositional(e,t.value),o.push(t.value);break;case`option`:{let o=t.dashes===1?Array.from(t.name):[t.name];for(let s=0;s<o.length;s++){let l=o[s],u=s===o.length-1,d=r.get(l)??l,f=n?.[d];if(e.strict&&!f)throw new ParseArgsError(`Unknown option '${l}' (from '${t.raw}')`,l,t.raw,{kind:`unknown-option`});if(!u&&f&&takesValue(f))throw new ParseArgsError(`Invalid option group '${t.raw}': '${l}' takes a value, so it can only be the last option in a group`,d,t.raw,{kind:`invalid-group`,detail:`takes a value, so it can only be the last option in a group`});let p=u?t.value??takeFollowingValue(f,c):void 0;if(f&&isDescriptor(f.type)){let e=f.type;if(e.kind===`array`){let n=i[d]??(i[d]=[]);(a[d]??(a[d]=[])).push(t.raw);let r={name:d,label:`${d}[${n.length}]`,index:n.length,token:t};n.push(yield*convertAndCheck(e.element,p,r))}else i[d]=yield*convertAndCheck(e,p,{name:d,label:d,index:void 0,token:t});continue}let m=convert(f,d,p,t);f?.multiple?(i[d]??(i[d]=[])).push(m):i[d]=m}break}case`option-terminator`:for(let t of c)checkPositional(e,t.value);s.push(...c.map(e=>e.value)),c.length=0}}for(let[e,t]of Object.entries(n??{})){let n=isDescriptor(t.type)?t.type:void 0;if(i[e]!==void 0){if(n?.kind===`array`){let t=a[e].join(` `);yield*runChecks(n,i[e],e,(n,r)=>usageError(e,e,t,n,{issues:r}))}continue}if(t.default!==void 0)n&&(yield*checkDefault(t,e)),i[e]=Array.isArray(t.default)?[...t.default]:t.default;else if(n&&!n.isOptional)throw new ParseArgsError(`Missing required option '${e}'`,e,``,{kind:`missing-option`,detail:`a value is required`})}let l={_:o,__:s,options:i};return e.tokens&&(l.tokens=t),l}__name(parse$1,`parse`);function checkDeclarations(e){for(let[t,n]of Object.entries(e??{})){let e=n.type;if(typeof e==`object`&&e&&!isDescriptor(e))throw TypeError(`Option '${t}' has a type that is neither a type name nor a descriptor from t`);if(isDescriptor(e)&&n.multiple!==void 0)throw TypeError(`Option '${t}' cannot set 'multiple' with a descriptor: use t.array(element)`)}}function checkPositional(e,t){if(e.allowPositionals===!1)throw new ParseArgsError(`Unexpected positional argument '${t}'`,void 0,t,{kind:`unexpected-positional`})}function canonicalNames(e){let t=new Map;if(!e)return t;for(let n of Object.keys(e))t.set(n,n);for(let[n,r]of Object.entries(e)){let e=r.alias;for(let r of e===void 0?[]:Array.isArray(e)?e:[e]){let e=t.get(r);if(e!==void 0&&e!==n)throw Error(`Alias '${r}' of option '${n}' is already used by option '${e}'`);t.set(r,n)}}return t}function elementOf(e){return e.kind===`array`?e.element:e}function takesValue(e){if(!isDescriptor(e.type))return e.type!==`boolean`;let t=elementOf(e.type);return!(t.kind===`boolean`||t.kind===`literal`&&typeof t.value==`boolean`)}function isNumeric(e){if(!isDescriptor(e.type))return e.type===`number`;let t=elementOf(e.type);return t.kind===`number`||t.kind===`int`||t.kind===`literal`&&typeof t.value==`number`}function takeFollowingValue(e,t){if(!e||!takesValue(e))return;let n=t[0];if(n){if(n.kind===`positional`)return t.shift(),n.value;if(n.kind===`option`&&isNumeric(e)&&Number.isFinite(toNumber(n.raw)))return t.shift(),n.raw}}function convert(e,t,n,r){if(!e)return n??!0;switch(e.type){case`boolean`:return convertBoolean(t,n,r);case`number`:return convertNumber(t,n,r);default:if(n===void 0)throw invalid(t,`a value is required`,r,`missing-value`);return n}}function invalid(e,t,n,r,i){return new ParseArgsError(`Invalid value for option '${e}': ${t} (from '${n.raw}')`,e,n.raw,{kind:r,value:i,detail:t})}function toNumber(e){return e.trim()===``?NaN:Number(e)}function convertNumber(e,t,n){if(t===void 0)throw invalid(e,`a number is required`,n,`missing-value`);let r=toNumber(t);if(!Number.isFinite(r))throw invalid(e,t,n,`invalid-value`,t);return r}function convertBoolean(e,t,n){if(t===void 0)return!0;if(t===`false`||t===`f`||t===`0`)return!1;if(t===`true`||t===`t`)return!0;let r=toNumber(t);if(!Number.isNaN(r))return r>0;throw invalid(e,t,n,`invalid-value`,t)}function usageError(e,t,n,r,i,a=r){return new ParseArgsError(`Invalid value for option '${t}': ${a} (from '${n}')`,e,n,{...i,detail:r})}function*convertAndCheck(e,t,n){let fail=(e,r,i)=>usageError(n.name,n.label,n.token.raw,e,{index:n.index,issues:r,value:t},i),r=yield*convertDescriptor(e,t,n,fail);return yield*runChecks(e,r,n.label,fail),r}function quote$1(e){return`'${e}'`}__name(quote$1,`quote`);function describeExpected(e){switch(e.kind){case`string`:return`a string matching ${e.pattern}`;case`number`:case`int`:{let t=e.kind===`int`?`an integer`:`a number`;return e.min!==void 0&&e.max!==void 0?`${t} from ${e.min} to ${e.max}`:e.min===void 0?e.max===void 0?t:`${t} of at most ${e.max}`:`${t} of at least ${e.min}`}case`boolean`:return`no value, true or false`;case`literal`:return typeof e.value==`string`?quote$1(e.value):String(e.value);case`enum`:return`one of ${e.values.map(quote$1).join(`, `)}`}}function*convertDescriptor(e,t,n,r){let expected=e=>r(`expected ${describeExpected(e)}`,void 0,`expected ${describeExpected(e)}, got ${quote$1(t)}`);if(e.kind===`boolean`||e.kind===`literal`&&typeof e.value==`boolean`){let n=t===void 0||t===`true`||t!==`false`&&void 0;if(n===void 0||e.kind===`literal`&&n!==e.value)throw t===void 0?r(`expected ${describeExpected(e)}`,void 0,`expected ${describeExpected(e)}, got no value`):expected(e);return n}if(t===void 0)throw usageError(n.name,n.label,n.token.raw,`a value is required`,{kind:`missing-value`,index:n.index});switch(e.kind){case`string`:if(e.pattern&&(e.pattern.lastIndex=0,!e.pattern.test(t)))throw expected(e);return t;case`number`:case`int`:{let n=toNumber(t);if(!Number.isFinite(n)||e.kind===`int`&&!Number.isInteger(n)||e.min!==void 0&&n<e.min||e.max!==void 0&&n>e.max)throw expected(e);return n}case`literal`:{let n=typeof e.value==`number`?toNumber(t):t;if(n!==e.value)throw expected(e);return n}case`enum`:if(!e.values.includes(t))throw expected(e);return t;case`custom`:try{return yield{value:e.convert(t),option:n.label}}catch(e){throw usageFailure(e,r)}case`json`:{let i;try{i=JSON.parse(t)}catch{throw r(`not valid JSON`,void 0,`${quote$1(t)} is not valid JSON`)}if(!e.schema)return i;let a=yield{value:e.schema[`~standard`].validate(i),option:n.label};if(a.issues)throw r(`does not match the expected shape`,a.issues);return a.value}}}function usageFailure(e,t){return e instanceof Error&&e.constructor===Error?t(e.message):e}function*runChecks(e,t,n,r){for(let i of e.checks)if(i.type===`fn`){let e=yield{value:i.fn(t),option:n};if(e===!1)throw r(`failed a check`);if(typeof e==`string`)throw r(e)}else{let e=yield{value:i.schema[`~standard`].validate(t),option:n};if(e.issues)throw r(`failed a check`,e.issues)}}const pe=new WeakMap;function*checkDefault(e,t){if(pe.has(e))return;let n=e.type,failFor=e=>t=>Error(`The default of option '${e}' failed a check${t===`failed a check`?``:`: ${t}`}`);if(n.kind===`array`){let r=e.default;for(let e=0;e<r.length;e++){let i=`${t}[${e}]`;yield*runChecks(n.element,r[e],i,failFor(i))}}yield*runChecks(n,e.default,t,failFor(t)),pe.set(e,!0)}const me=new WeakMap;function lookupCommand(e,t,n){let r=matchCommand(e,createPathCursor(t,n)),[i,a]=assignOptionValues(t,r,n);return processCommand(r,i,a)}function matchCommand(e,t){if(e.commands){let n=e.commands,r=t.peek(e);for(let e=n.length-1;e>=0;e--){let i=n[e];if(!i.name)return i;if(r===i.name||i.alias?.includes(r))return t.consume(),i.commands?matchCommand(i,t):i}}return e}function createPathCursor(e,t){let n=me.get(e)??[],r,i=-1,a=0;return{peek(o){if(r=void 0,i<0){if(a<e._.length)return(r=[e._,a])[0][a];i=0,a=-1}for(;t&&i<n.length;){let e=n[i];if(a<0){let n=lookupOptions(t,e.key)[1];if(!n)return;a=countFollowing(lookupOptions(o,e.key)[1]??n,e)}if(a<e.following.length)return(r=[e.following,a])[0][a];i++,a=-1}},consume(){r[0].splice(r[1],1)}}}function assignOptionValues(e,t,n){let r=me.get(e);if(!r)return[e,void 0];let i={},a=[],o=[];for(let e of r){let r=lookupOptions(t,e.key)[1],s=countFollowing(r??(n&&lookupOptions(n,e.key)[1]),e),c=e.following.slice(0,s);r&&o.push({key:e.key,tokens:[e.raw,...c]}),a.push(...e.following.slice(s));let l=e.inline.length+c.length>0?[...e.inline,...c]:[`true`];i[e.key]=[...i[e.key]??[],...l]}let s={...e,_:[...e._,...a]};for(let t of Object.keys(i))e[t]&&(s[t]=i[t]);return[s,o]}function countFollowing(e,t){return e?t.inline.length===0&&takesValue$1(optionType(e))?1:0:t.following.length}const he=k.boolean().optional(),ge=k.string();function optionType(e){return e.type??he}function processCommand(e,t,n){return collectDescriptorOptions(checkConflicts(fillInputOptions(fillArguments({command:e,rawArgs:t,args:{_:[]},errors:[],descriptors:[]}))),n)}function fillArguments(e){let t=e.command,n=[...e.rawArgs._],r=t.arguments||[];for(let t of r){let r=t.type??ge;if(n.length===0){r.isOptional||e.errors.push({type:`missing-argument`,name:t.name});continue}let i=r.kind===`array`?n.splice(0):[n.shift()];e.descriptors.push({type:`argument`,name:t.name,descriptor:r,values:i})}return n.length>0&&e.errors.push({type:`extra-arguments`,name:t.name,values:n}),e}function fillInputOptions(e){for(let t of Object.keys(e.rawArgs)){if(t===`_`)continue;if(/^-/.test(t)){e.errors.push({type:`invalid-key`,key:t});continue}let[n,r]=lookupOptions(e.command,t);if(!n){e.errors.push({type:`invalid-key`,key:t});continue}let i=optionType(r),a=e.rawArgs[t];i.kind!==`array`&&a.length>1&&e.errors.push({type:`expect-single`,key:t,keyKind:i.kind,value:a})}return e}function checkConflicts(e){let t=e.command.options;if(!t)return e;let n=new Map;for(let t of Object.keys(e.rawArgs)){let[r]=lookupOptions(e.command,t);r&&!n.has(r)&&n.set(r,t)}let r=[...n.keys()];for(let i=0;i<r.length;i++)for(let a=i+1;a<r.length;a++){let[o,s]=[r[i],r[a]];if(!t[o].conflicts?.includes(s)&&!t[s].conflicts?.includes(o))continue;let[c,l]=t[o].conflicts?.includes(s)?[o,s]:[s,o];e.errors.push({type:`conflicting-options`,key:n.get(c),conflictsWith:n.get(l)})}return e}function collectDescriptorOptions(e,t){let n=e.command.options??{};for(let r of Object.keys(n)){let i=n[r],a=Object.keys(e.rawArgs).filter(t=>t!==`_`&&lookupOptions(e.command,t)[0]===r);e.errors.some(e=>e.type===`expect-single`&&a.includes(e.key))||e.descriptors.push({type:`option`,name:r,entry:{...i,type:optionType(i)},occurrences:t?t.filter(e=>a.includes(e.key)):a.flatMap(t=>e.rawArgs[t].map(e=>({key:t,tokens:[`--${r}=${e}`]})))})}return e}function lookupOptions(e,t){let n=e.options;if(!n)return[];let r=n[t];if(r)return[t,r];let i=Object.keys(n).find(e=>{let r=n[e];return r.alias?r.alias.some(e=>e===t||e.alias===t):!1});return i?[i,n[i]]:[]}const _e={comma:`,`,tab:` `,pipe:`|`},ve=_e.comma;function escapeString(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`).replace(/[\u0000-\u001F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function isBooleanOrNullLiteral(e){return e===`true`||e===`false`||e===`null`}function setOwnProperty(e,t,n){if(t===`__proto__`){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});return}e[t]=n}const ye=RegExp(`(?:^?|\\n) *#`);var RawString=class{constructor(e){if(ye.test(e))throw TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(e)}`);this.value=e}};function isRawString(e){return e instanceof RawString}const be=/[\uD800-\uDFFF]/;function normalizeValue(e){if(e===null)return null;if(isRawString(e))return e;if(typeof e==`object`&&e&&`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();if(t!==e)return normalizeValue(t)}if(typeof e==`string`)return assertNoLoneSurrogate(e,`string value`),e;if(typeof e==`boolean`)return e;if(typeof e==`number`)return Object.is(e,-0)?0:Number.isFinite(e)?e:null;if(typeof e==`bigint`)return e>=-(2**53-1)&&e<=2**53-1?Number(e):e.toString();if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(normalizeValue);if(e instanceof Set)return Array.from(e).map(normalizeValue);if(e instanceof Map)return Object.fromEntries(Array.from(e,([e,t])=>[String(e),normalizeValue(t)]));if(isPlainObject(e)){let t={};for(let n in e)Object.hasOwn(e,n)&&(assertNoLoneSurrogate(n,`object key`),setOwnProperty(t,n,normalizeValue(e[n])));return t}return null}function assertNoLoneSurrogate(e,t){if(be.test(e))for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<55296||r>57343)continue;let i=r<=56319,a=e.charCodeAt(n+1);if(i&&a>=56320&&a<=57343){n++;continue}throw TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${r.toString(16).toUpperCase()} at index ${n}`)}}function isJsonPrimitive(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function isEncodablePrimitive(e){return isJsonPrimitive(e)||isRawString(e)}function isJsonArray(e){return Array.isArray(e)}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!isRawString(e)}function isEmptyObject(e){return Object.keys(e).length===0}function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function isArrayOfPrimitives(e){return e.length===0||e.every(e=>isEncodablePrimitive(e))}function isArrayOfArrays(e){return e.length===0||e.every(e=>isJsonArray(e))}function isArrayOfObjects(e){return e.length===0||e.every(e=>isJsonObject(e))}const xe=/^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;function assertValidDelimiter(e){if(!Object.values(_e).includes(e))throw TypeError(`Invalid delimiter ${JSON.stringify(e)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`)}function isValidUnquotedKey(e){return/^[A-Z_][\w.]*$/i.test(e)}function isSafeUnquoted(e,t=ve){return!(!e||/^[ \t]|[ \t]$/.test(e)||isBooleanOrNullLiteral(e)||isNumericLike(e)||e.includes(`:`)||e.includes(`"`)||e.includes(`\\`)||/[[\]{}]/.test(e)||/[\u0000-\u001F]/.test(e)||e.includes(t)||e.startsWith(`-`)||e.startsWith(`#`))}function isNumericLike(e){return xe.test(e)}function encodePrimitive(e,t){return isRawString(e)?e.value:e===null?`null`:typeof e==`boolean`||typeof e==`number`?String(e):encodeStringLiteral(e,t)}function encodeStringLiteral(e,t=ve){return isSafeUnquoted(e,t)?e:`"${escapeString(e)}"`}function encodeKey(e){return isValidUnquotedKey(e)?e:`"${escapeString(e)}"`}function encodeAndJoinPrimitives(e,t=ve){return e.map(e=>encodePrimitive(e,t)).join(t)}function formatHeader(e,t){let n=t?.key,r=t?.fields,i=t?.delimiter??`,`,a=``;return n!=null&&(a+=encodeKey(n)),a+=`[${e}${t?.keyed?`:`:``}${i===ve?``:i}]`,r&&(a+=`{${formatFieldSegment(r,i)}}`),a+=`:`,a}function formatFieldSegment(e,t){return e.map(e=>encodeKey(e.name)+(e.children?`{${formatFieldSegment(e.children,t)}}`:``)).join(t)}function extractTabularFields(e){if(e.length===0)return;let t=Object.keys(e[0]);if(t.length===0)return;for(let n of e){if(Object.keys(n).length!==t.length)return;for(let e of t)if(!Object.hasOwn(n,e))return}let n=[];for(let r of t){let t=classifyColumn(r,e.map(e=>e[r]));if(!t)return;n.push(t)}return n}function extractKeyedTabularFields(e){let t=Object.values(e);if(!(t.length<2)&&t.every(e=>isJsonObject(e)&&!isEmptyObject(e)))return extractTabularFields(t)}function collectRowLeaves(e,t){let n=[];return collectLeafValues(e,t,n),n}function classifyColumn(e,t){if(t.every(e=>isEncodablePrimitive(e)))return{name:e};if(!t.every(e=>isJsonObject(e)&&!isEmptyObject(e)))return;let n=extractTabularFields(t);if(n)return{name:e,children:n}}function collectLeafValues(e,t,n){for(let r of t){let t=e[r.name];r.children?collectLeafValues(t,r.children,n):n.push(t)}}function*encodeJsonValue(e,t,n){if(isEncodablePrimitive(e)){let n=encodePrimitive(e,t.delimiter);n!==``&&(yield n);return}if(isJsonArray(e))yield*encodeArrayLines(void 0,e,n,t);else if(isJsonObject(e)){let r=extractKeyedTabularFields(e);if(r){yield*encodeKeyedObjectLines(void 0,e,r,n,t);return}yield*encodeObjectLines(e,n,t)}}function*encodeObjectLines(e,t,n){for(let[r,i]of Object.entries(e))yield*encodeKeyValuePairLines(r,i,t,n)}function*encodeKeyValuePairLines(e,t,n,r){let i=encodeKey(e);if(isEncodablePrimitive(t))yield indentedLine(n,`${i}: ${encodePrimitive(t,r.delimiter)}`,r.indentSize);else if(isJsonArray(t))yield*encodeArrayLines(e,t,n,r);else if(isJsonObject(t)){let a=extractKeyedTabularFields(t);if(a){yield*encodeKeyedObjectLines(e,t,a,n,r);return}yield indentedLine(n,`${i}:`,r.indentSize),isEmptyObject(t)||(yield*encodeObjectLines(t,n+1,r))}}function*encodeKeyedObjectLines(e,t,n,r,i){let a=Object.entries(t);yield indentedLine(r,formatHeader(a.length,{key:e,fields:n,delimiter:i.delimiter,keyed:!0}),i.indentSize),yield*encodeKeyedEntryRowsLines(a,n,r+1,i)}function*encodeKeyedEntryRowsLines(e,t,n,r){for(let[i,a]of e){let e=collectRowLeaves(a,t);yield indentedLine(n,`${encodeKey(i)}: ${encodeAndJoinPrimitives(e,r.delimiter)}`,r.indentSize)}}function*encodeArrayLines(e,t,n,r){if(t.length===0){yield indentedLine(n,e==null?`[]`:`${encodeKey(e)}: []`,r.indentSize);return}if(isArrayOfPrimitives(t)){yield indentedLine(n,encodeInlineArrayLine(t,r.delimiter,e),r.indentSize);return}if(isArrayOfArrays(t)&&t.every(e=>isArrayOfPrimitives(e))){yield*encodeArrayOfArraysAsListItemsLines(e,t,n,r);return}if(isArrayOfObjects(t)){let i=extractTabularFields(t);i?yield*encodeArrayOfObjectsAsTabularLines(e,t,i,n,r):yield*encodeMixedArrayAsListItemsLines(e,t,n,r);return}yield*encodeMixedArrayAsListItemsLines(e,t,n,r)}function*encodeArrayOfArraysAsListItemsLines(e,t,n,r){yield indentedLine(n,formatHeader(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)if(isArrayOfPrimitives(e)){let t=encodeInlineArrayLine(e,r.delimiter);yield indentedListItem(n+1,t,r.indentSize)}}function encodeInlineArrayLine(e,t,n){let r=formatHeader(e.length,{key:n,delimiter:t}),i=encodeAndJoinPrimitives(e,t);return e.length===0?r:`${r} ${i}`}function*encodeArrayOfObjectsAsTabularLines(e,t,n,r,i){yield indentedLine(r,formatHeader(t.length,{key:e,fields:n,delimiter:i.delimiter}),i.indentSize),yield*writeTabularRowsLines(t,n,r+1,i)}function*writeTabularRowsLines(e,t,n,r){for(let i of e)yield indentedLine(n,encodeAndJoinPrimitives(collectRowLeaves(i,t),r.delimiter),r.indentSize)}function*encodeMixedArrayAsListItemsLines(e,t,n,r){yield indentedLine(n,formatHeader(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)yield*encodeListItemValueLines(e,n+1,r)}function*encodeObjectAsListItemLines(e,t,n){if(isEmptyObject(e)){yield indentedLine(t,`-`,n.indentSize);return}let r=Object.entries(e),[i,a]=r[0],o=r.slice(1);if(isJsonArray(a)&&isArrayOfObjects(a)){let e=extractTabularFields(a);if(e){yield indentedListItem(t,formatHeader(a.length,{key:i,fields:e,delimiter:n.delimiter}),n.indentSize),yield*writeTabularRowsLines(a,e,t+2,n),o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n));return}}if(isJsonObject(a)){let e=extractKeyedTabularFields(a);if(e){let r=Object.entries(a);yield indentedListItem(t,formatHeader(r.length,{key:i,fields:e,delimiter:n.delimiter,keyed:!0}),n.indentSize),yield*encodeKeyedEntryRowsLines(r,e,t+2,n),o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n));return}}let s=encodeKey(i);if(isEncodablePrimitive(a))yield indentedListItem(t,`${s}: ${encodePrimitive(a,n.delimiter)}`,n.indentSize);else if(isJsonArray(a)){if(a.length===0)yield indentedListItem(t,`${s}: []`,n.indentSize);else if(isArrayOfPrimitives(a))yield indentedListItem(t,`${s}${encodeInlineArrayLine(a,n.delimiter)}`,n.indentSize);else{yield indentedListItem(t,`${s}${formatHeader(a.length,{delimiter:n.delimiter})}`,n.indentSize);for(let e of a)yield*encodeListItemValueLines(e,t+2,n)}}else isJsonObject(a)&&(yield indentedListItem(t,`${s}:`,n.indentSize),isEmptyObject(a)||(yield*encodeObjectLines(a,t+2,n)));o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n))}function*encodeListItemValueLines(e,t,n){if(isEncodablePrimitive(e))yield indentedListItem(t,encodePrimitive(e,n.delimiter),n.indentSize);else if(isJsonArray(e)){if(isArrayOfPrimitives(e))yield indentedListItem(t,encodeInlineArrayLine(e,n.delimiter),n.indentSize);else{yield indentedListItem(t,formatHeader(e.length,{delimiter:n.delimiter}),n.indentSize);for(let r of e)yield*encodeListItemValueLines(r,t+1,n)}}else isJsonObject(e)&&(yield*encodeObjectAsListItemLines(e,t,n))}function indentedLine(e,t,n){return` `.repeat(n*e)+t}function indentedListItem(e,t,n){return indentedLine(e,`- `+t,n)}function applyReplacer(e,t){let n=t(``,e,[]);return n===void 0?transformChildren(e,t,[]):transformReplaced(e,n,t,[])}function transformReplaced(e,t,n,r){return isRawString(t)&&!isEncodablePrimitive(e)?transformChildren(e,n,r):transformChildren(normalizeValue(t),n,r)}function transformChildren(e,t,n){return isJsonObject(e)?transformObject(e,t,n):isJsonArray(e)?transformArray(e,t,n):e}function transformObject(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=[...n,i],o=t(i,a,e);o!==void 0&&setOwnProperty(r,i,transformReplaced(a,o,t,e))}return r}function transformArray(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=[...n,i],s=t(String(i),a,o);s!==void 0&&r.push(transformReplaced(a,s,t,o))}return r}function encode$1(e,t){return Array.from(encodeLines(e,t)).join(`
|
|
8
|
+
`)}__name(encode$1,`encode`);function encodeLines(e,t){let n=normalizeValue(e),r=resolveOptions(t);return encodeJsonValue(r.replacer?applyReplacer(n,r.replacer):n,r,0)}function resolveOptions(e){let t=e?.delimiter??ve;return assertValidDelimiter(t),{indentSize:e?.indentSize??e?.indent??2,delimiter:t,replacer:e?.replacer}}function isRecord$2(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}__name(isRecord$2,`isRecord`);function cell(e){return e===void 0?``:String(e)}function table(e){let t=[...new Set(e.flatMap(e=>Object.keys(e)))],n=t.map(t=>Math.max(t.length,...e.map(e=>cell(e[t]).length))),line=e=>` ${e.map((e,t)=>e.padEnd(n[t])).join(` `)}`.trimEnd();return[line(t),...e.map(e=>line(t.map(t=>cell(e[t]))))]}function renderText(e){let t=Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>{if(!Array.isArray(t))return[`${e}: ${isRecord$2(t)?JSON.stringify(t):String(t)}`];if(!t.length)return[`${e}: (none)`];let n=t.every(isRecord$2)?table(t):t.map(e=>` - ${String(e)}`);return[`${e}:`,...n]});return t.flatMap((e,n)=>{let r=t[n-1];return r&&(r.length>1||e.length>1)?[``,...e]:e}).join(`
|
|
9
|
+
`)}const Se=[`toon`,`json`,`text`];function encode(e,t){return t===`json`?JSON.stringify(e):t===`text`?renderText(e):encode$1(e)}function errorOutput({message:e,code:t,details:n,help:r}){let i={error:e,code:t,...n};return r&&r.length>0&&(i.help=[...r]),i}const Ce=Symbol.for(`clibuilder.global-format`),we=Symbol.for(`clibuilder.defers-to-global-format`);function getBaseCommand(e,t){return command({name:``,description:e,options:{help:{type:k.boolean().optional(),description:`Print help message`,alias:[`h`]},version:{type:k.boolean().optional(),description:`Print the CLI version`,alias:[`v`]},verbose:{type:k.boolean().optional(),description:`Turn on verbose logging`,alias:[`V`]},silent:{type:k.boolean().optional(),description:`Turn off logging`},"debug-cli":{type:k.boolean().optional(),description:`Display clibuilder debug messages`},...t?.options,format:formatEntry(t?.format??`toon`)},commands:[]})}function formatEntry(e){return Object.defineProperty({type:k.enum(Se),description:`Output format: 'toon' for agents, 'json' to pipe, 'text' for humans`,default:e},Ce,{value:!0})}function isGlobalFormatEntry(e){return!!e&&e[Ce]===!0}function yieldToGlobalFormat(e){let[t,n]=lookupOptions(e,`format`);if(!t||isGlobalFormatEntry(n))return e;if(!n[we]){let n=e.name?`command '${e.name}'`:`the default command`;throw Error(`${n} declares its own option '${t}', which conflicts with the global --format option. Delete the local declaration and read this.format in run() instead. See docs/rfcs/axi-native.md section 3.4: https://github.com/clibuilder/clibuilder/blob/main/docs/rfcs/axi-native.md#34---format-is-not-first-class-6394`)}let{[t]:r,...i}=e.options;return{...e,options:i}}function defineKey(e){return{id:e,kind:`value`}}function createRegistry(){let e=new Map,t=new Map;function get(n){return n.kind===`collection`?t.get(n.id)??[]:e.get(n.id)?.value}return{register(n,r,i){if(r.kind===`collection`){let e=t.get(r.id)??[];return e.push({source:n,value:i}),t.set(r.id,e),{accepted:!0}}let a=e.get(r.id);return a?{accepted:!1,source:a.source}:(e.set(r.id,{source:n,value:i}),{accepted:!0})},get,has(n){return n.kind===`collection`?t.has(n.id):e.has(n.id)},describe(n){if(n.kind===`collection`)return(t.get(n.id)??[]).map(({source:e})=>e);let r=e.get(n.id)?.source;return r?[r]:[]}}}const Te=defineKey(`clibuilder.config`);function parseArgv(e){let t=[],n=e.slice(2).reduce((e,n)=>(e.args.__?e.args.__.push(n):isOption(n)?(isInOptionState(e)&&(e=endOption(e)),e=startOption(e,n,t)):isInOptionState(e)?(e.values.push(n),t[t.length-1].following.push(n)):n===`--`?e.args.__=[]:e.args._.push(n),e),{args:{_:[]},key:``,values:[]}),r=(isInOptionState(n)?endOption(n):n).args;return me.set(r,t),r}function isInOptionState(e){return!!e.key}function isOption(e){return e.startsWith(`-`)&&/\w+/.test(e)}function startOption(e,t,n){return e=/^-\w+/.test(t)?startSingleCharacterOptions(e,t,n):startMultiCharacterOptions(e,t),n.push({key:e.key,raw:t,inline:[...e.values],following:[]}),e}function startSingleCharacterOptions(e,t,n){let r=t.indexOf(`=`),[i,a]=r>0?[t.slice(1,r),[t.slice(r+1)]]:[t.slice(1),[]],o=i.split(``),s=o.pop();for(let e of o)n.push({key:e,raw:t,inline:[`true`],following:[]});return e=addBooleanOptions(e,o),e.key=s,e.values=a,e}function addBooleanOptions(e,t){return t.length<=0?e:(e.key=t.pop(),e.values=[`true`],addBooleanOptions(endOption(e),t))}function startMultiCharacterOptions(e,t){let n=t.indexOf(`=`);return n>0?(e.key=t.slice(2,n),e.values=[t.slice(n+1)]):(e.key=t.slice(2),e.values=[]),e}function endOption(e){let{key:t,values:n}=e,r={...e.args};return r[t]||(r[t]=[]),n.length===0?r[t].push(`true`):r[t].push(...n),{args:r,key:``,values:[]}}const Ee=new WeakMap;async function convertDescriptors(e){for(let t of e.descriptors)try{assign(e,t,await parseArgsAsync(configOf(t)))}catch(n){report(e,t,n)}}function convertDescriptorsSync(e){for(let t of e.descriptors)try{assign(e,t,parseArgs(configOf(t)))}catch(n){report(e,t,n)}}function peekFlags(e,t){let n={...e,args:{...e.args},errors:[],descriptors:e.descriptors.filter(e=>e.type===`option`&&t.includes(e.name)&&e.entry.type.kind===`boolean`&&e.entry.type.checks.length===0)};return convertDescriptorsSync(n),n.args}function configOf(e){return e.type===`option`?{args:e.occurrences.flatMap(e=>e.tokens),options:{[e.name]:declarationOf(e.entry)}}:{args:e.values.map(t=>`--${e.name}=${t}`),options:{[e.name]:{type:e.descriptor}}}}function assign(e,t,{options:n}){n[t.name]!==void 0&&(e.args[t.name]=n[t.name])}function report(e,t,n){if(!(n instanceof ParseArgsError))throw n;e.errors.push(toUsageError(n,t))}function declarationOf(e){let t=Ee.get(e);if(!t){let n=e.alias?.map(e=>typeof e==`string`?e:e.alias);t={type:e.type,...n?{alias:n}:{},...e.default===void 0?{}:{default:e.default}},Ee.set(e,t)}return t}function toUsageError(e,t){if(e.kind===`missing-option`)return{type:`missing-argument`,name:t.name};let n=t.type===`option`?t.entry.type:t.descriptor,r=n.kind===`array`?n.element:n;return{type:`invalid-value`,key:keyOf(e,t),message:e.detail,value:e.value??(e.kind===`invalid-value`?rawValues(t):void 0),keyKind:n.kind,constraint:describeConstraint(r),...r.kind===`enum`?{allowed:r.values}:{},...e.index===void 0?{}:{index:e.index}}}function keyOf(e,t){if(t.type===`argument`)return t.name;let n=t.occurrences;return(e.index===void 0?n[n.length-1]:n[e.index])?.key??t.name}function rawValues(e){return e.type===`argument`?e.values:e.occurrences.map(e=>e.tokens.join(` `))}const De=Symbol.for(`clibuilder.answer`);function result(e,t={}){return{[De]:`result`,value:e,help:helpLines(t.help),render:t.render}}function document(e){return{[De]:`document`,value:String(e)}}function isAnswer(e){return typeof e==`object`&&!!e&&typeof e[De]==`string`}function answerValue(e){return isAnswer(e)?e.value:e}function printAnswer(e,t){if(e!==void 0){if(!isAnswer(e))return print(e,[],t);switch(e[De]){case`written`:return;case`document`:return line(e.value);case`empty`:return line(encode(withHelp({empty:e.value},e.help),t));case`result`:{let n=e.render?.[t];return n?withRenderedHelp(n(e.value),e.help,t):print(e.value,e.help,t)}}}}function print(e,t,n){return typeof e==`string`?withRenderedHelp(e,t,n):line(encode(withHelp(toRecord(e),t),n))}function withRenderedHelp(e,t,n){return t.length===0?line(e):line(`${e}${e.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:`
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
${t}`),`<unsupported: ${n}>`}function tersifyCatchClauseNode(e,t,n){let r=tersifyAcornNode(e,t.param,n),i=tersifyAcornNode(e,t.body,n);return`catch${r?` (${r})`:``}${i?` ${i}`:``}`}function tersifyTryStatementNode(e,t,n){let r=tersifyAcornNode(e,t.block,n),i=tersifyAcornNode(e,t.handler,n),a=tersifyAcornNode(e,t.finalizer,n);return`try ${r}${i?` ${i}`:``}${a?` finally ${a}`:``}`}function tersifyThrowStatementNode(e,t,n){return`throw ${tersifyAcornNode(e,t.argument,n)}`}function tersifyArrayExpressionNode(e,t,n){return trim(e,`[${t.elements.map(t=>tersifyAcornNode(e,t,n)).join(`, `)}]`,n)}function tersifyAwaitExpressionNode(e,t,n){return`await ${tersifyAcornNode(e,t.argument,n)}`}function tersifyYieldExpressionNode(e,t,n){return`yield ${tersifyAcornNode(e,t.argument,n)}`}function tersifyMetaProperty(e,t,n){return`${tersifyAcornNode(e,t.meta,n)}.${tersifyAcornNode(e,t.property,n)}`}function tersifyPropertyNode(e,t,n){let r=tersifyAcornNode(e,t.key,n),i=t.value;if(i.type===`FunctionExpression`)return`${i.async?`async `:``}${i.generator?`*`:``}${r}${tersifyFunctionParams(e,i.params)} ${tersifyFunctionBody(e,i.body)}`;if(i.type===`AssignmentPattern`)return tersifyAcornNode(e,i,n);let a=tersifyAcornNode(e,i,n);return t.computed?`[${r}]: ${a}`:r===a?r:`${r}: ${a}`}function tersifyObjectExpressionNode(e,t,n){return`{ ${t.properties.map(t=>tersifyAcornNode(e,t,n)).join(`, `)} }`}function tersifyForOfStatementNode(e,t,n){return`for (${tersifyAcornNode(e,t.left,n)} of ${tersifyAcornNode(e,t.right,n)}) ${tersifyAcornNode(e,t.body,n)}`}function tersifyForInStatementNode(e,t,n){return`for (${tersifyAcornNode(e,t.left,n)} in ${tersifyAcornNode(e,t.right,n)}) ${tersifyAcornNode(e,t.body,n)}`}function tersifySwitchCaseNode(e,t,n){let r=tersifyAcornNode(e,t.test,n),i=t.consequent.map(t=>tersifyAcornNode(e,t,n));return t.test?`case ${r}: ${i.join(` `)}`:`default: ${i.join(` `)}`}function tersifySwitchStatementNode(e,t,n){return`switch (${tersifyAcornNode(e,t.discriminant,n)}) { ${t.cases.map(t=>tersifyAcornNode(e,t,n)).join(`; `)} }`}function tersifyContinueStatementNode(e,t,n){let r=tersifyAcornNode(e,t.label,n);return r?`continue ${r}`:`continue`}function tersifyLabeledStatementNode(e,t,n){return`${tersifyAcornNode(e,t.label,n)}: ${tersifyAcornNode(e,t.body,n)}`}function tersifyEmptyStatementNode(e,t,n){return``}function tersifyBreakStatementNode(e,t,n){let r=tersifyAcornNode(e,t.label,n);return r?`break ${r}`:`break`}function tersifyForStatementNode(e,t,n){let r=tersifyAcornNode(e,t.test,n),i=tersifyAcornNode(e,t.init,n),a=tersifyAcornNode(e,t.update,n),o=tersifyAcornNode(e,t.body,n),s=(r||``).trim(),c=(a||``).trim();return`for (${i};${s?` ${r}`:``};${c?` ${a}`:``}) ${o}`.replace(/;\s+;/g,`;;`).replace(/;;\s+\)/g,`;;)`)}function tersifyAssignmentExpressionNode(e,t,n){let r=tersifyAcornNode(e,t.left,n),i=tersifyAcornNode(e,t.right,n);return`${r} ${t.operator} ${i}`}function tersifyWhileStatementNode(e,t,n){return`while (${tersifyAcornNode(e,t.test,n)}) ${tersifyAcornNode(e,t.body,n)}`}function tersifyDoWhileStatementNode(e,t,n){let r=tersifyAcornNode(e,t.test,n),i=tersifyAcornNode(e,t.body,n);return t.body.type===`BlockStatement`?`do ${i} while (${r})`:`do ${i}; while (${r})`}function tersifyUnaryExpressionNode(e,t,n){if(t.operator===`void`){let r=tersifyAcornNode(e,t.argument,n);return r===`0`&&t.argument?.type===`Literal`&&t.argument.value===0?`undefined`:`void ${r}`}return t.operator===`typeof`?`typeof ${tersifyAcornNode(e,t.argument,n)}`:t.prefix?`${t.operator}${tersifyAcornNode(e,t.argument,n)}`:`${tersifyAcornNode(e,t.argument,n)}${t.operator}`}function tersifyUpdateExpressionNode(e,t,n){return t.prefix?`${t.operator}${tersifyAcornNode(e,t.argument,n)}`:`${tersifyAcornNode(e,t.argument,n)}${t.operator}`}function tersifyConditionalExpressionNode(e,t,n){return`${tersifyAcornNode(e,t.test,n)} ? ${tersifyAcornNode(e,t.consequent,n)} : ${tersifyAcornNode(e,t.alternate,n)}`}function tersifyIfStatementNode(e,t,n){let r=tersifyAcornNode(e,t.test,n),i=tersifyAcornNode(e,t.consequent,n),a=tersifyAcornNode(e,t.alternate,n);return a?t.consequent.type===`BlockStatement`?`if (${r}) ${i} else ${a}`:`if (${r}) ${i}; else ${a}`:`if (${r}) ${i}`}function tersifyBinaryExpressionNode(e,t,n){(t.left.type===`BinaryExpression`||t.left.type===`LogicalExpression`)&&isHigherOperatorOrder(t.operator,t.left.operator)&&(t.left.needParen=!0);let r=tersifyAcornNode(e,t.left,n);(t.right.type===`BinaryExpression`||t.right.type===`LogicalExpression`)&&isHigherOperatorOrder(t.operator,t.right.operator)&&(t.right.needParen=!0);let i=tersifyAcornNode(e,t.right,n);return t.needParen?`(${r} ${t.operator} ${i})`:`${r} ${t.operator} ${i}`}function tersifyNewExpressionNode(e,t,n){return tersifyNewDate(t)||`new ${tersifyAcornNode(e,t.callee,n)}(${t.arguments.map(t=>tersifyAcornNode(e,t,n)).join(`, `)})`}function tersifyNewDate(e){if(e.callee.type===`Identifier`&&e.callee.name===`Date`){let t=e.arguments;if(t.length>0&&!t.some(e=>e.type!==`Literal`)){let e=t;if(e.length===1){let t=e[0];if(typeof t.value==`string`)return new Date(t.value).toISOString()}let n=e.map(e=>e.value);return new Date(...n).toISOString()}}}function tersifyVariableDeclaratorNode(e,t,n){return`${t.id.name}${t.init?` = ${tersifyAcornNode(e,t.init,n)}`:``}`}function tersifyVariableDeclarationNode(e,t,n){return`${t.kind} ${t.declarations.map(t=>tersifyAcornNode(e,t,n)).join(`, `)}`}function tersifyIdentifierNode(e,t,n){return t.name===`Symbol`?`Sym`:t.name}function tersifyLiteralNode(e,t,n){return typeof t.value==`string`?`'`+t.value.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)+`'`:t.raw}function tersifyRestElementNode(e,t,n){return`...${t.argument.name}`}function tersifyAssignmentPatternNode(e,t,n){return`${t.left.name} = ${tersifyAcornNode(e,t.right,n-t.left.name.length-3)}`}function tersifyArrowExpressionNode(e,t,n){let r=t.async?`async `:``,i=t.generator?`*`:``,a=` => `,o=t.params.length===1&&t.params[0].type!==`ObjectPattern`,s=tersifyParamsBody(e,t.params),c=o?s:`(${s})`,l=getSingleStatementBodyNode(e,t.body),u=l?tersifyArrowBodyAsSingleStatement(e,l):tersifyFunctionBody(e,t.body),d=l&&l.type===`ObjectExpression`;if(d&&(u=`(${u})`),r.length+i.length+c.length+4+u.length<=n)return`${r}${i}${c}${a}${u}`;let p=Math.max(o?1:3,n-(r.length+i.length+4+u.length)),m=o?trim(e,s,p):`(${trim(e,s,p-2)})`;if(r.length+i.length+p+4+u.length<=n)return`${r}${i}${m}${a}${u}`;let h=d?6:l?0:4,g=Math.max(3,n-(r.length+i.length+m.length+4+h));return trim(e,`${r}${i}${m}${a}${d?`({ ${trim(e,u.slice(2,u.length-2),g-4)} })`:l?trim(e,u,g):`{ ${trim(e,u.slice(2,u.length-1),g)} }`}`,n)}function getSingleStatementBodyNode(e,t){if(t.type!==`BlockStatement`)return t;if(t.body.length===1&&t.body[0].type===`ReturnStatement`)return t.body[0]}function tersifyArrowBodyAsSingleStatement(e,t){return t.type===`ReturnStatement`?t.argument?t.argument.type===`ObjectExpression`?`(${tersifyAcornNode(e,t.argument,1/0)})`:tersifyAcornNode(e,t.argument,1/0):`{}`:tersifyAcornNode(e,t,1/0)}function tersifyExpressionStatementNode(e,t,n){return tersifyAcornNode(e,t.expression,n)}function tersifyMemberExpressionNode(e,t,n){let r=t.property.type===`Identifier`?tersifyAcornNode(e,t.property,n):`[${tersifyAcornNode(e,t.property,n)}]`;return`${tersifyAcornNode(e,t.object,n)}${t.optional?`?`:``}.${r}`}function tersifyCallExpressionNode(e,t,n){if(isSymbolForNode(t))return`Sym(${t.arguments[0].value})`;if(isDefineThisProperty(t)){let r=t.arguments[1].value;return`this.${r} = ${tersifyAcornNode(e,t.arguments[2],n-5-r.length-3)}`}let r=tersifyAcornNode(e,t.callee,n),i=tersifyFunctionParams(e,t.arguments);return`${r}${t.optional?`?.`:``}${i}`}function isSymbolForNode(e){return e.callee.type===`MemberExpression`&&e.callee.object.type===`Identifier`&&e.callee.object.name===`Symbol`&&e.callee.property.type===`Identifier`&&e.callee.property.name===`for`}function isDefineThisProperty(e){return e.callee.type===`Identifier`&&e.callee.name===`_defineProperty`&&e.arguments.length===3&&e.arguments[0].type===`ThisExpression`}function tersifyParamsBody(e,t){return t.reduce((t,n)=>(t.push(tersifyAcornNode(e,n,1/0)),t),[]).join(`, `)}function tersifyFunctionExpressionNode(e,t,n){let r=e.raw?`function`:`fn`,i=t.async?`async `:``,a=t.generator?`*`:``,o=t.id?` ${t.id.name}`:``,s=t.params.length>0?tersifyFunctionParams(e,t.params):`()`,c=i.length+r.length+a.length+o.length+1,l=s.slice(1,s.length-1),u=l.length>3?`(${trim(e,l,3)})`:s,d=c+u.length,p=c+s.length,m=tersifyFunctionBody(e,t.body);if(d+m.length>n){if(d+5>n)return trim(e,`${i}${r}${a}${o}${u} ${m}`,n);let t=m.slice(2,m.length-2),s=`${i}${r}${a}${o}${u} ${t.length===0?`{}`:`{ ${trim(e,t,n-d-4)} }`}`;return s.length>n?trim(e,s,n):s}return p+m.length>n?d+m.length<n?`${i}${r}${a}${o}(${trim(e,l,n-m.length-c-2)}) ${m}`:trim(e,`${i}${r}${a}${o}${u} ${m}`,n):trim(e,`${i}${r}${a}${o}${s} ${m}`,n)}function tersifyFunctionParams(e,t){return`(${tersifyParamsBody(e,t)})`}function tersifyFunctionBody(e,t){return tersifyAcornNode(e,t,1/0)}function tersifyBlockStatementNode(e,t,n){if(n<=3&&t.body.length>0)return trim(e,`...`,n);if(n<=4&&t.body.length>0)return trim(e,`{...`,n);let r=n-4,i=[];t.body.forEach(t=>{if(r){let n=tersifyAcornNode(e,t,r);r-=n.length,n&&n!==`return`&&i.push(n)}});let a=i.join(`; `);return`{${a?` ${a} `:``}}`}function tersifyReturnStatementNode(e,t,n){return t.argument?`return ${tersifyAcornNode(e,t.argument,n)}`:`return`}function tersifyThisExpression(e,t,n){return`this`}function tersifyClassExpression(e,t,n){let r=trim(e,`class${t.id?` ${t.id.name}`:` `}{}`,n),i=r.slice(0,Math.max(3,r.length-2)),a=tersifyAcornNode(e,t.body,n-i.length);return`${i}${n>=i.length+a.length||a.length>3?a:trim(e,`...`,n-i.length)}`}function tersifyMethodDefinition(e,t,n){let r=t.static?`static `:``,i=t.value,a=i.async?`async `:``,o=i.generator?`*`:``,s=t.key.name??`[${tersifyAcornNode(e,t.key,n)}]`,c=i.params.length>0?tersifyFunctionParams(e,i.params):`()`,l=r.length+a.length+o.length+s.length+1,u=c.slice(1,c.length-1),d=u.length>3?`(${trim(e,u,3)})`:c,p=l+d.length,m=l+c.length,h=tersifyFunctionBody(e,i.body);if(p+h.length>n){if(p+5>n)return trim(e,`${r}${a}${o}${s}${d} ${h}`,n);let t=h.slice(2,h.length-2),i=`${r}${a}${o}${s}${d} ${t.length===0?`{}`:`{ ${trim(e,t,n-p-4)} }`}`;return i.length>n?trim(e,i,n):i}return m+h.length>n?p+h.length<n?`${r}${a}${o}${s}(${trim(e,u,n-h.length-l-2)}) ${h}`:trim(e,`${r}${a}${o}${s}${d} ${h}`,n):trim(e,`${r}${a}${o}${s}${c} ${h}`,n)}function tersifyObjectPattern(e,t,n){return`${trim(e,`{ ${t.properties.map(t=>tersifyAcornNode(e,t,n)).join(`, `)} }`,n-2)}`}function tersifySequenceExpression(e,t,n){return`(${t.expressions.map(t=>tersifyAcornNode(e,t,n)).join(`, `)})`}function tersifyTemplateLiteral(e,t,n){return"`"+t.expressions.concat(t.quasis).sort((e,t)=>e.start-t.start).reduce((t,r)=>{if(n<=0)return t;if(r.type===`TemplateElement`)n-=r.value.raw.length,t+=r.value.raw;else{let i=tersifyAcornNode(e,r,n);n-=i.length,t+="${"+i+`}`}return t},``)+"`"}function tersifyTaggedTemplateExpression(e,t,n){let r=t.tag.name;return r+tersifyAcornNode(e,t.quasi,n-r.length)}function tersifyChainExpression(e,t,n){switch(t.expression.type){case`MemberExpression`:return tersifyMemberExpressionNode(e,t.expression,n);case`CallExpression`:return tersifyCallExpressionNode(e,t.expression,n);default:return tersifyUnknown(t,e.rawString)}}function tersifySuperNode(e,t,n){return`Super`}function tersifyFunctionByString(e,t){let n=e.toString();if(t.raw)return normalizeRawOutput(n);let r=parseFn(n);switch(r.type){case`function`:return formatFn2(r,t.maxLength);case`arrow`:return formatArrow2(r,t.maxLength);default:return formatUnknown(r,t.maxLength)}}const Yt=/^(async\s+)?function\s*(\*?)\s*(\w*)\s*\(([^)]*)\)\s*(\{.*\})$/ms,Xt=/^(async\s*)?\(([^)]*)\)\s*=>(.*)$/ms,Zt=/^(async\s+)?(\w+)\s*=>(.*)$/ms;function parseFn(e){let t=Yt.exec(e);if(t){let e=getEnclosedBody((t[5]??``).trim()).trim();return{type:`function`,async:!!t[1],generator:!!t[2],name:(t[3]??``).trim(),params:(t[4]??``).trim(),body:e}}if(t=Xt.exec(e),t){let e=(t[2]??``).trim(),n=(t[3]??``).trim(),r=isSingleLineBody(n);return n=removeLineBreaks(r?getSingleLineBody(n,1/0):getEnclosedBody(n)).trim(),!r&&n.startsWith(`return `)&&n.endsWith(`;`)&&(r=!0,n=n.slice(7,-1),n.startsWith(`{`)&&(n=`(${n})`)),{type:`arrow`,async:!!t[1],params:e,body:n,singleParam:e.length>0&&e.indexOf(`,`)===-1,singleLineBody:r}}if(t=Zt.exec(e),t){let e=(t[3]??``).trim(),n=isSingleLineBody(e);return e=removeLineBreaks(n?getSingleLineBody(e,1/0):getEnclosedBody(e)).trim(),!n&&e.startsWith(`return `)&&e.endsWith(`;`)&&(n=!0,e=e.slice(7,-1),e.startsWith(`{`)&&(e=`(${e})`)),{type:`arrow`,async:!!t[1],params:`${t[2]}`,body:e,singleParam:!0,singleLineBody:n}}return{type:`unknown`,value:e}}function normalizeBody(e){return e.replace(/\bfunction\s*\*\s*\(/g,`function* (`).replace(/\bfunction\s*\(/g,`function (`).replace(/\basync\s+function\s*\*\s*\(/g,`async function* (`).replace(/\basync\s+function\s*\(/g,`async function (`).replace(/\)=>/g,`) =>`).replace(/=>\s*\{/g,`=> {`).replace(/\bwhile\s*\(/g,`while (`).replace(/\bfor\s*\(/g,`for (`).replace(/\bswitch\s*\(/g,`switch (`).replace(/\}\s*while\s*\(/g,`} while (`).replace(/(\}\s*while\s*\([^)]+\))\s*\}/g,`$1; }`).replace(/(\}\s*while\s*\([^)]+\))\s*$/g,`$1;`).replace(/(while\s*\([^)]+\))\s*$/g,`$1;`).replace(/\b(while\s*\([^)]+\))(\s*)(\w)/g,(e,t,n,r)=>n?e:`${t} ${r}`).replace(/\b(for\s*\([^)]+\))(\s*)(\w)/g,(e,t,n,r)=>n?e:`${t} ${r}`).replace(/\b(switch\s*\([^)]+\))(\s*)(\w)/g,(e,t,n,r)=>n?e:`${t} ${r}`).replace(/\b(in\s+\w+)\)(\w)/g,`$1) $2`).replace(/\b(of\s+\w+)\)(\w)/g,`$1) $2`).replace(/\bfinally\s*\{/g,`finally {`).replace(/\bcatch\s*\{/g,`catch {`).replace(/\)\s*\{/g,`) {`).replace(/(\{\s*|,\s*)((?:async\s+)?)(\*\s*)?(\w+)\s+\(/g,(e,t,n,r,i)=>t+n+(r?`*`:``)+i+`(`).replace(/\[\s*;/g,`[`).replace(/\[\s+/g,`[`).replace(/\s+\]/g,`]`).replace(/;\s+;/g,`;;`).replace(/;;\s+\)/g,`;;)`).replace(/;\s+\)/g,`;)`).replace(/\}\s*;\s*(?=\s*return\b)/g,`} `).replace(/\bvoid\s+0\b/g,`undefined`).replace(/\/\*\s*@__PURE__\s*\*\/\s*/g,``).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(e,t,n)=>`'`+t.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)+`'`)}function normalizeRawOutput(e){return e.replace(/\)=>/g,`) =>`).replace(/=>(\S)/g,`=> $1`)}function normalizeStringQuotes(e){return e.replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(e,t)=>`'`+t.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)+`'`)}function formatFn2(e,t){e.params&&=normalizeStringQuotes(e.params),e.body&&=normalizeBody(e.body);let n=`${e.async?`async `:``}fn${e.generator?`*`:``}${e.name?` `+e.name:``}(${e.params?`%1`:``}) {${e.body?` %2 `:``}}`,r=e.params&&e.body?n.length-4:e.params||e.body?n.length-2:n.length;return e.params=trim({raw:!1,noTrim:!1},e.params,Math.max(3,t-r-e.body.length)),e.body=trim({raw:!1,noTrim:!1},e.body,Math.max(3,t-r-e.params.length)),trim({raw:!1,noTrim:!1},applyTemplate(n,e),t)}function formatArrow2(e,t){e.params&&=normalizeStringQuotes(e.params),e.body&&=normalizeBody(e.body);let n=`${e.async?`async `:``}${e.singleParam?`%1`:`(${e.params?`%1`:``})`} => ${e.singleLineBody?`%2`:`{${e.body?` %2 `:``}}`}`,r=e.params&&e.body?n.length-4:e.params||e.body?n.length-2:n.length;return e.params=trim({raw:!1,noTrim:!1},e.params,Math.max(3,t-r-e.body.length)),e.body=trim({raw:!1,noTrim:!1},e.body,Math.max(3,t-r-e.params.length)),trim({raw:!1,noTrim:!1},applyTemplate(n,e),t)}function formatUnknown(e,t){return trim({noTrim:!1},e.value,t)}function isSingleLineBody(e){return!e.startsWith(`{`)}function getSingleLineBody(e,t){let n=parseFn(e);switch(n.type){case`function`:return formatFn2(n,t);case`arrow`:return formatArrow2(n,t);default:return e.replace(/return;/g,``).replace(/([\s([{])Symbol\(\)/g,`$1Sym()`).replace(/([\s([{])Symbol\.for\('([\w_]*)'\)/g,`$1Sym($2)`).replace(/([\s([{])Symbol\.for\("([\w_]*)"\)/g,`$1Sym($2)`).replace(/([\s([{])Symbol\.for\(`([\w_]*)`\)/g,`$1Sym($2)`).replace(/{\s+}/g,`{}`)}}function getEnclosedBody(e){let t=1;e=e.slice(1);for(let n=0;n<=e.length;n++)if(e[n]===`}`&&t--,e[n]===`{`&&t++,t===0){e=removeLineBreaks(e.slice(0,n)).replace(/return;/g,``).replace(/([\s([{])Symbol\(\)/g,`$1Sym()`).replace(/([\s([{])Symbol\.for\('([\w_]*)'\)/g,`$1Sym($2)`).replace(/([\s([{])Symbol\.for\("([\w_]*)"\)/g,`$1Sym($2)`).replace(/([\s([{])Symbol\.for\(`([\w_]*)`\)/g,`$1Sym($2)`).replace(/{\s+}/g,`{}`);break}return e}function removeLineBreaks(e){return e.split(`
|
|
21
|
-
`)
|
|
22
|
-
`)
|
|
23
|
-
`)
|
|
24
|
-
`)}\n${getIndent(e,r)}}`}let[a,o]=n<i.length+1+2?[n-1-2,2]:[i.length,n-i.length-1],s=a?`${trim(e,i,a)} `:``,c=o,l=Object.keys(t),u=l.reduce((n,r,i)=>{if(c>0){let a=i===l.length-1,o=getPropStr(e,t,r,c,a);c-=o.length,n.push(o)}return n},[]),d=trim(e,l.length>u.length?u.join(`, `)+` `:u.join(`, `),o-2-2);return l.length===0?`${s}{}`:d.length===0?trim(e,`${s}{ }`,n):`${s}{ ${d} }`}function getPropStr(e,t,n,r,i){let a=i?0:2,o=[...e.path,n],s=Object.getOwnPropertyDescriptor(t,n),c=[];if(s.get&&c.push(`Get`),s.set&&c.push(`Set`),c.length>0)return`${getPropKey(n)}: [${c.join(`/`)}]`;let l=t[n];if(typeof l==`function`){if(/^(.*)\s?=>\s?/.test(l.toString())){let t=tersifyValue({...e,path:o},l,r-n.length-a-2);return`${getPropKey(n)}: ${t}`}let t=tersifyValue({...e,path:o},l,r-n.length-a+2);return`${/^async fn/.test(t)?`async `:``}${/^(async )?fn\*/.test(t)?`*`:``}${getPropKey(n)}${t.slice(t.indexOf(`(`))}`}let u=tersifyValue({...e,path:o,noTrim:!0},l,r-n.length-2-a);return`${getPropKey(n)}: ${u}`}function getPropKey(e){return e.indexOf(`-`)>=0?`'${e}'`:e}function findKey(e,t,n){return Object.keys(e).find(function(n,r,i){return t.apply(this,[n,r,i,e])},n)}function forEachKey(e,t,n){Object.keys(e).forEach(t,n)}function mapKey(e,t,n){return Object.keys(e).map(function(n,r,i){return t.apply(this,[n,r,i,e])},n)}function reduceByKey(e,t,n){return Object.keys(e).reduce((n,r,i,a)=>t(n,r,i,a,e),n)}const $t=reduceByKey;function record(e){let t=Object.create(null);return e?Object.assign(t,e):t}function someKey(e,t,n){return Object.keys(e).some(function(n,r,i){return t.apply(this,[n,r,i,e])},n)}function command(e){return e}var V;(function(e){e.assertEqual=e=>{};function assertIs(e){}e.assertIs=assertIs;function assertNever(e){throw Error()}e.assertNever=assertNever,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function joinValues(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=joinValues,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(V||={});var en;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(en||={});const H=V.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),getParsedType=e=>{switch(typeof e){case`undefined`:return H.undefined;case`string`:return H.string;case`number`:return Number.isNaN(e)?H.nan:H.number;case`boolean`:return H.boolean;case`function`:return H.function;case`bigint`:return H.bigint;case`symbol`:return H.symbol;case`object`:return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?H.promise:typeof Map<`u`&&e instanceof Map?H.map:typeof Set<`u`&&e instanceof Set?H.set:typeof Date<`u`&&e instanceof Date?H.date:H.object;default:return H.unknown}},U=V.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var tn=class ZodError extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},processError=e=>{for(let r of e.issues)if(r.code===`invalid_union`)r.unionErrors.map(processError);else if(r.code===`invalid_return_type`)processError(r.returnTypeError);else if(r.code===`invalid_arguments`)processError(r.argumentsError);else if(r.path.length===0)n._errors.push(t(r));else{let e=n,i=0;for(;i<r.path.length;){let n=r.path[i];i===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return processError(this),n}static assert(e){if(!(e instanceof ZodError))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};tn.create=e=>new tn(e);const errorMap=(e,t)=>{let n;switch(e.code){case U.invalid_type:n=e.received===H.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case U.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,V.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(e.keys,`, `)}`;break;case U.invalid_union:n=`Invalid input`;break;case U.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(e.options)}`;break;case U.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(e.options)}, received '${e.received}'`;break;case U.invalid_arguments:n=`Invalid function arguments`;break;case U.invalid_return_type:n=`Invalid function return type`;break;case U.invalid_date:n=`Invalid date`;break;case U.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:V.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case U.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case U.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case U.custom:n=`Invalid input`;break;case U.invalid_intersection_types:n=`Intersection results could not be merged`;break;case U.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case U.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,V.assertNever(e)}return{message:n}};let nn=errorMap;function getErrorMap(){return nn}const makeIssue=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function addIssueToContext(e,t){let n=getErrorMap(),r=makeIssue({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===errorMap?void 0:errorMap].filter(e=>!!e)});e.common.issues.push(r)}var rn=class ParseStatus{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return W;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let e of t){let t=await e.key,r=await e.value;n.push({key:t,value:r})}return ParseStatus.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return W;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const W=Object.freeze({status:`aborted`}),DIRTY=e=>({status:`dirty`,value:e}),OK=e=>({status:`valid`,value:e}),isAborted=e=>e.status===`aborted`,isDirty=e=>e.status===`dirty`,isValid=e=>e.status===`valid`,isAsync=e=>typeof Promise<`u`&&e instanceof Promise;var G;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(G||={});var ParseInputLazyPath=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const handleResult=(e,t)=>{if(isValid(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new tn(e.common.issues);return this._error=t,this._error}}};function processCreateParams(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:i};let customMap=(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}};return{errorMap:customMap,description:i}}var ZodType=class{get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new rn,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(isAsync(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parseSync({data:e,path:n.path,parent:n});return handleResult(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return isValid(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>isValid(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(isAsync(r)?r:Promise.resolve(r));return handleResult(n,i)}refine(e,t){let getIssueProperties=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,n)=>{let r=e(t),setError=()=>n.addIssue({code:U.custom,...getIssueProperties(t)});return typeof Promise<`u`&&r instanceof Promise?r.then(e=>e?!0:(setError(),!1)):r?!0:(setError(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ZodEffects({schema:this,typeName:K.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return En.create(this)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:K.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:K.ZodDefault})}brand(){return new ZodBranded({typeName:K.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:K.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Pn.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const an=/^c[^\s-]{8,}$/i,on=/^[0-9a-z]+$/,sn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ln=/^[a-z0-9_-]{21}$/i,un=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,dn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let pn;const mn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,gn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,_n=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,xn=RegExp(`^${bn}$`);function timeRegexSource(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function timeRegex(e){return RegExp(`^${timeRegexSource(e)}$`)}function datetimeRegex(e){let t=`${bn}T${timeRegexSource(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function isValidIP(e,t){return!((t!==`v4`&&t||!mn.test(e))&&(t!==`v6`&&t||!gn.test(e)))}function isValidJWT(e,t){if(!un.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function isValidCidr(e,t){return!((t!==`v4`&&t||!hn.test(e))&&(t!==`v6`&&t||!_n.test(e)))}var Sn=class ZodString extends ZodType{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.string,received:t.parsedType}),W}let t=new rn,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?addIssueToContext(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&addIssueToContext(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)fn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`email`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)pn||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),pn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`emoji`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)cn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`uuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)ln.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`nanoid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)an.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`cuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)on.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`cuid2`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)sn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`ulid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`url`,code:U.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`regex`,code:U.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?datetimeRegex(r).test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?xn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?timeRegex(r).test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?dn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`duration`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?isValidIP(e.data,r.version)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`ip`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?isValidJWT(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`jwt`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?isValidCidr(e.data,r.version)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`cidr`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?vn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`base64`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?yn.test(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{validation:`base64url`,code:U.invalid_string,message:r.message}),t.dirty()):V.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:U.invalid_string,...G.errToObj(n)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...G.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...G.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...G.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...G.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...G.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...G.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...G.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...G.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...G.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...G.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...G.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...G.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...G.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...G.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...G.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...G.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...G.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...G.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...G.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...G.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...G.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...G.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...G.errToObj(t)})}nonempty(e){return this.min(1,G.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Sn.create=e=>new Sn({checks:[],typeName:K.ZodString,coerce:e?.coerce??!1,...processCreateParams(e)});function floatSafeRemainder(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Cn=class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==H.number){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.number,received:t.parsedType}),W}let t,n=new rn;for(let r of this._def.checks)r.kind===`int`?V.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?floatSafeRemainder(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.not_finite,message:r.message}),n.dirty()):V.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,G.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,G.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,G.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,G.toString(t))}setLimit(e,t,n,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:G.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:G.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:G.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:G.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:G.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:G.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:G.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&V.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Cn.create=e=>new Cn({checks:[],typeName:K.ZodNumber,coerce:e?.coerce||!1,...processCreateParams(e)});var wn=class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==H.bigint)return this._getInvalidInput(e);let t,n=new rn;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):V.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.bigint,received:t.parsedType}),W}gte(e,t){return this.setLimit(`min`,e,!0,G.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,G.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,G.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,G.toString(t))}setLimit(e,t,n,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:G.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:G.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:G.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};wn.create=e=>new wn({checks:[],typeName:K.ZodBigInt,coerce:e?.coerce??!1,...processCreateParams(e)});var ZodBoolean=class extends ZodType{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.boolean,received:t.parsedType}),W}return OK(e.data)}};ZodBoolean.create=e=>new ZodBoolean({typeName:K.ZodBoolean,coerce:e?.coerce||!1,...processCreateParams(e)});var Tn=class ZodDate extends ZodType{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.date,received:t.parsedType}),W}if(Number.isNaN(e.data.getTime()))return addIssueToContext(this._getOrReturnCtx(e),{code:U.invalid_date}),W;let t=new rn,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:U.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):V.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:G.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:G.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Tn.create=e=>new Tn({checks:[],coerce:e?.coerce||!1,typeName:K.ZodDate,...processCreateParams(e)});var ZodSymbol=class extends ZodType{_parse(e){if(this._getType(e)!==H.symbol){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.symbol,received:t.parsedType}),W}return OK(e.data)}};ZodSymbol.create=e=>new ZodSymbol({typeName:K.ZodSymbol,...processCreateParams(e)});var ZodUndefined=class extends ZodType{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.undefined,received:t.parsedType}),W}return OK(e.data)}};ZodUndefined.create=e=>new ZodUndefined({typeName:K.ZodUndefined,...processCreateParams(e)});var ZodNull=class extends ZodType{_parse(e){if(this._getType(e)!==H.null){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.null,received:t.parsedType}),W}return OK(e.data)}};ZodNull.create=e=>new ZodNull({typeName:K.ZodNull,...processCreateParams(e)});var ZodAny=class extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}};ZodAny.create=e=>new ZodAny({typeName:K.ZodAny,...processCreateParams(e)});var ZodUnknown=class extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}};ZodUnknown.create=e=>new ZodUnknown({typeName:K.ZodUnknown,...processCreateParams(e)});var ZodNever=class extends ZodType{_parse(e){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.never,received:t.parsedType}),W}};ZodNever.create=e=>new ZodNever({typeName:K.ZodNever,...processCreateParams(e)});var ZodVoid=class extends ZodType{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.void,received:t.parsedType}),W}return OK(e.data)}};ZodVoid.create=e=>new ZodVoid({typeName:K.ZodVoid,...processCreateParams(e)});var En=class ZodArray extends ZodType{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==H.array)return addIssueToContext(t,{code:U.invalid_type,expected:H.array,received:t.parsedType}),W;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(addIssueToContext(t,{code:e?U.too_big:U.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(addIssueToContext(t,{code:U.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(addIssueToContext(t,{code:U.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,n)))).then(e=>rn.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,n)));return rn.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:G.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:G.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:G.toString(t)}})}nonempty(e){return this.min(1,e)}};En.create=(e,t)=>new En({type:e,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...processCreateParams(t)});function deepPartialify(e){if(e instanceof Dn){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=ZodOptional.create(deepPartialify(r))}return new Dn({...e._def,shape:()=>t})}return e instanceof En?new En({...e._def,type:deepPartialify(e.element)}):e instanceof ZodOptional?ZodOptional.create(deepPartialify(e.unwrap())):e instanceof ZodNullable?ZodNullable.create(deepPartialify(e.unwrap())):e instanceof kn?kn.create(e.items.map(e=>deepPartialify(e))):e}var Dn=class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=V.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),W}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ParseInputLazyPath(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ZodNever){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(addIssueToContext(n,{code:U.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ParseInputLazyPath(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>rn.mergeObjectSync(t,e)):rn.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return G.errToObj,new ZodObject({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:G.errToObj(e).message??r}:{message:r}}}})}strip(){return new ZodObject({...this._def,unknownKeys:`strip`})}passthrough(){return new ZodObject({...this._def,unknownKeys:`passthrough`})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:K.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){let t={};for(let n of V.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new ZodObject({...this._def,shape:()=>t})}omit(e){let t={};for(let n of V.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){let t={};for(let n of V.objectKeys(this.shape)){let r=this.shape[n];t[n]=e&&!e[n]?r:r.optional()}return new ZodObject({...this._def,shape:()=>t})}required(e){let t={};for(let n of V.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof ZodOptional;)e=e._def.innerType;t[n]=e}return new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(V.objectKeys(this.shape))}};Dn.create=(e,t)=>new Dn({shape:()=>e,unknownKeys:`strip`,catchall:ZodNever.create(),typeName:K.ZodObject,...processCreateParams(t)}),Dn.strictCreate=(e,t)=>new Dn({shape:()=>e,unknownKeys:`strict`,catchall:ZodNever.create(),typeName:K.ZodObject,...processCreateParams(t)}),Dn.lazycreate=(e,t)=>new Dn({shape:e,unknownKeys:`strip`,catchall:ZodNever.create(),typeName:K.ZodObject,...processCreateParams(t)});var ZodUnion=class extends ZodType{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function handleResults(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new tn(e.ctx.common.issues));return addIssueToContext(t,{code:U.invalid_union,unionErrors:n}),W}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(handleResults);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new tn(e));return addIssueToContext(t,{code:U.invalid_union,unionErrors:i}),W}}get options(){return this._def.options}};ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:K.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>e instanceof ZodLazy?getDiscriminator(e.schema):e instanceof ZodEffects?getDiscriminator(e.innerType()):e instanceof ZodLiteral?[e.value]:e instanceof Nn?e.options:e instanceof ZodNativeEnum?V.objectValues(e.enum):e instanceof ZodDefault?getDiscriminator(e._def.innerType):e instanceof ZodUndefined?[void 0]:e instanceof ZodNull?[null]:e instanceof ZodOptional?[void 0,...getDiscriminator(e.unwrap())]:e instanceof ZodNullable?[null,...getDiscriminator(e.unwrap())]:e instanceof ZodBranded||e instanceof ZodReadonly?getDiscriminator(e.unwrap()):e instanceof ZodCatch?getDiscriminator(e._def.innerType):[];var On=class ZodDiscriminatedUnion extends ZodType{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return addIssueToContext(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),W;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(addIssueToContext(t,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let r=new Map;for(let n of t){let t=getDiscriminator(n.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(r.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,n)}}return new ZodDiscriminatedUnion({typeName:K.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(n)})}};function mergeValues(e,t){let n=getParsedType(e),r=getParsedType(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&r===H.object){let n=V.objectKeys(t),r=V.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=mergeValues(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===H.array&&r===H.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=mergeValues(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===H.date&&r===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var ZodIntersection=class extends ZodType{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),handleParsed=(e,r)=>{if(isAborted(e)||isAborted(r))return W;let i=mergeValues(e.value,r.value);return i.valid?((isDirty(e)||isDirty(r))&&t.dirty(),{status:t.value,value:i.data}):(addIssueToContext(n,{code:U.invalid_intersection_types}),W)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>handleParsed(e,t)):handleParsed(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ZodIntersection.create=(e,t,n)=>new ZodIntersection({left:e,right:t,typeName:K.ZodIntersection,...processCreateParams(n)});var kn=class ZodTuple extends ZodType{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return addIssueToContext(n,{code:U.invalid_type,expected:H.array,received:n.parsedType}),W;if(n.data.length<this._def.items.length)return addIssueToContext(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),W;!this._def.rest&&n.data.length>this._def.items.length&&(addIssueToContext(n,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ParseInputLazyPath(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>rn.mergeArray(t,e)):rn.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}};kn.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new kn({items:e,typeName:K.ZodTuple,rest:null,...processCreateParams(t)})};var An=class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.object)return addIssueToContext(n,{code:U.invalid_type,expected:H.object,received:n.parsedType}),W;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ParseInputLazyPath(n,e,n.path,e)),value:a._parse(new ParseInputLazyPath(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?rn.mergeObjectAsync(t,r):rn.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ZodType?new ZodRecord({keyType:e,valueType:t,typeName:K.ZodRecord,...processCreateParams(n)}):new ZodRecord({keyType:Sn.create(),valueType:e,typeName:K.ZodRecord,...processCreateParams(t)})}},ZodMap=class extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.map)return addIssueToContext(n,{code:U.invalid_type,expected:H.map,received:n.parsedType}),W;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ParseInputLazyPath(n,e,n.path,[a,`key`])),value:i._parse(new ParseInputLazyPath(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return W;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return W;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};ZodMap.create=(e,t,n)=>new ZodMap({valueType:t,keyType:e,typeName:K.ZodMap,...processCreateParams(n)});var jn=class ZodSet extends ZodType{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return addIssueToContext(n,{code:U.invalid_type,expected:H.set,received:n.parsedType}),W;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(addIssueToContext(n,{code:U.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(addIssueToContext(n,{code:U.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function finalizeSet(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return W;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let a=[...n.data.values()].map((e,t)=>i._parse(new ParseInputLazyPath(n,e,n.path,t)));return n.common.async?Promise.all(a).then(e=>finalizeSet(e)):finalizeSet(a)}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:G.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:G.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};jn.create=(e,t)=>new jn({valueType:e,minSize:null,maxSize:null,typeName:K.ZodSet,...processCreateParams(t)});var Mn=class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return addIssueToContext(t,{code:U.invalid_type,expected:H.function,received:t.parsedType}),W;function makeArgsIssue(e,n){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter(e=>!!e),issueData:{code:U.invalid_arguments,argumentsError:n}})}function makeReturnsIssue(e,n){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter(e=>!!e),issueData:{code:U.invalid_return_type,returnTypeError:n}})}let n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof ZodPromise){let e=this;return OK(async function(...t){let i=new tn([]),a=await e._def.args.parseAsync(t,n).catch(e=>{throw i.addIssue(makeArgsIssue(t,e)),i}),o=await Reflect.apply(r,this,a);return await e._def.returns._def.type.parseAsync(o,n).catch(e=>{throw i.addIssue(makeReturnsIssue(o,e)),i})})}{let e=this;return OK(function(...t){let i=e._def.args.safeParse(t,n);if(!i.success)throw new tn([makeArgsIssue(t,i.error)]);let a=Reflect.apply(r,this,i.data),o=e._def.returns.safeParse(a,n);if(!o.success)throw new tn([makeReturnsIssue(a,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:kn.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ZodFunction({args:e||kn.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:K.ZodFunction,...processCreateParams(n)})}},ZodLazy=class extends ZodType{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:K.ZodLazy,...processCreateParams(t)});var ZodLiteral=class extends ZodType{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{received:t.data,code:U.invalid_literal,expected:this._def.value}),W}return{status:`valid`,value:e.data}}get value(){return this._def.value}};ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:K.ZodLiteral,...processCreateParams(t)});function createZodEnum(e,t){return new Nn({values:e,typeName:K.ZodEnum,...processCreateParams(t)})}var Nn=class ZodEnum extends ZodType{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return addIssueToContext(t,{expected:V.joinValues(n),received:t.parsedType,code:U.invalid_type}),W}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return addIssueToContext(t,{received:t.data,code:U.invalid_enum_value,options:n}),W}return OK(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ZodEnum.create(e,{...this._def,...t})}exclude(e,t=this._def){return ZodEnum.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}};Nn.create=createZodEnum;var ZodNativeEnum=class extends ZodType{_parse(e){let t=V.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){let e=V.objectValues(t);return addIssueToContext(n,{expected:V.joinValues(e),received:n.parsedType,code:U.invalid_type}),W}if(this._cache||=new Set(V.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=V.objectValues(t);return addIssueToContext(n,{received:n.data,code:U.invalid_enum_value,options:e}),W}return OK(e.data)}get enum(){return this._def.values}};ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:K.ZodNativeEnum,...processCreateParams(t)});var ZodPromise=class extends ZodType{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.promise&&t.common.async===!1)return addIssueToContext(t,{code:U.invalid_type,expected:H.promise,received:t.parsedType}),W;let n=t.parsedType===H.promise?t.data:Promise.resolve(t.data);return OK(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:K.ZodPromise,...processCreateParams(t)});var ZodEffects=class extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{addIssueToContext(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return W;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?W:r.status===`dirty`||t.value===`dirty`?DIRTY(r.value):r});{if(t.value===`aborted`)return W;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?W:r.status===`dirty`||t.value===`dirty`?DIRTY(r.value):r}}if(r.type===`refinement`){let executeRefinement=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?W:(e.status===`dirty`&&t.dirty(),executeRefinement(e.value),{status:t.value,value:e.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>e.status===`aborted`?W:(e.status===`dirty`&&t.dirty(),executeRefinement(e.value).then(()=>({status:t.value,value:e.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!isValid(e))return W;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>isValid(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):W)}V.assertNever(r)}};ZodEffects.create=(e,t,n)=>new ZodEffects({schema:e,typeName:K.ZodEffects,effect:t,...processCreateParams(n)}),ZodEffects.createWithPreprocess=(e,t,n)=>new ZodEffects({schema:t,effect:{type:`preprocess`,transform:e},typeName:K.ZodEffects,...processCreateParams(n)});var ZodOptional=class extends ZodType{_parse(e){return this._getType(e)===H.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:K.ZodOptional,...processCreateParams(t)});var ZodNullable=class extends ZodType{_parse(e){return this._getType(e)===H.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:K.ZodNullable,...processCreateParams(t)});var ZodDefault=class extends ZodType{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:K.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...processCreateParams(t)});var ZodCatch=class extends ZodType{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return isAsync(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new tn(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new tn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:K.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...processCreateParams(t)});var ZodNaN=class extends ZodType{_parse(e){if(this._getType(e)!==H.nan){let t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:U.invalid_type,expected:H.nan,received:t.parsedType}),W}return{status:`valid`,value:e.data}}};ZodNaN.create=e=>new ZodNaN({typeName:K.ZodNaN,...processCreateParams(e)});var ZodBranded=class extends ZodType{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Pn=class ZodPipeline extends ZodType{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){let handleAsync=async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?W:e.status===`dirty`?(t.dirty(),DIRTY(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})};return handleAsync()}{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?W:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:K.ZodPipeline})}},ZodReadonly=class extends ZodType{_parse(e){let t=this._def.innerType._parse(e),freeze=e=>(isValid(e)&&(e.value=Object.freeze(e.value)),e);return isAsync(t)?t.then(e=>freeze(e)):freeze(t)}unwrap(){return this._def.innerType}};ZodReadonly.create=(e,t)=>new ZodReadonly({innerType:e,typeName:K.ZodReadonly,...processCreateParams(t)}),Dn.lazycreate;var K;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(K||={});const q=Sn.create;Cn.create,ZodNaN.create,wn.create;const Fn=ZodBoolean.create;Tn.create,ZodSymbol.create,ZodUndefined.create,ZodNull.create,ZodAny.create,ZodUnknown.create,ZodNever.create,ZodVoid.create;const In=En.create;Dn.create,Dn.strictCreate,ZodUnion.create,On.create,ZodIntersection.create,kn.create,An.create,ZodMap.create,jn.create,Mn.create,ZodLazy.create,ZodLiteral.create;const Ln=Nn.create;ZodNativeEnum.create,ZodPromise.create,ZodEffects.create;const J=ZodOptional.create;ZodNullable.create,ZodEffects.createWithPreprocess,Pn.create;function isZodObject(e){return e.shape}function isZodArray(e){return e&&e.element}function isZodOptional(e){return!!e&&e.isOptional()}function isZodBoolean(e){return isZodType(e,`ZodBoolean`)}function isZodNumber(e){return isZodType(e,`ZodNumber`)}function isZodString(e){return isZodType(e,`ZodString`)}function isZodEnum(e){return isZodType(e,`ZodEnum`)}function isZodType(e,t){return Object.getPrototypeOf(e).constructor.name===t}function getBaseCommand(e,t){return command({name:``,description:e,options:{help:{type:J(Fn()),description:`Print help message`,alias:[`h`]},version:{type:J(Fn()),description:`Print the CLI version`,alias:[`v`]},verbose:{type:J(Fn()),description:`Turn on verbose logging`,alias:[`V`]},silent:{type:J(Fn()),description:`Turn off logging`},"debug-cli":{type:J(Fn()),description:`Display clibuilder debug messages`},...t?.config?{"show-config":{type:J(Fn()),description:`Print the resolved config and where it was loaded from`}}:{}},commands:[]})}const Rn={type:J(Ln([`toon`,`text`,`json`])),description:`Output format: 'toon' for agents, 'text' for humans, 'json' to pipe`,default:`toon`};function toonValue(e){return/["\\,]|^\s|\s$/.test(e)?JSON.stringify(e):e}function toonArray(e,t){return`${e}[${t.length}]: ${t.map(toonValue).join(`,`)}`}function toonTable(e,t,n){return[`${e}[${n.length}]{${t.join(`,`)}}:`,...n.map(e=>` ${e.map(toonValue).join(`,`)}`)]}function toonHelp(e){return`help[1]: ${e}`}function reportProse(e,{noun:t,plural:n},r,i,a){if(r.length===0){e.info(`no ${t} with keywords: ${a.join(`, `)}`);return}if(r.length===1){e.info(`found one ${t}: ${i(r[0])}`);return}e.info(`found the following ${n}:`),e.info(``),r.forEach(t=>{e.info(` ${i(t)}`)})}function required(e,t,n){return merge$1([e,t,n],(e,t)=>({...e,...t}))}function merge$1(e,t){return e[0]===void 0||e[0]===null?e[0]:e.filter(e=>!!e).reduce(t,{})}function unpartial(e,t,n){return e==null?e:[e,t,n].filter(notNil).reduce((e,t)=>({...e,...trimNilProps(t)}),{})}function trimNilProps(e){return Object.keys(e).reduce((t,n)=>(notNil(e[n])&&(t[n]=e[n]),t),{})}function notNil(e){return e!=null}var zn=__esmMin((()=>{__name(merge$1,`merge`)})),Bn=__commonJSMin((e=>{var t=O(`path`),n=process.platform===`win32`,r=O(`fs`),i=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var e;if(i){var t=Error();e=debugCallback}else e=missingCallback;return e;function debugCallback(e){e&&(t.message=e.message,e=t,missingCallback(e))}function missingCallback(e){if(e){if(process.throwDeprecation)throw e;if(!process.noDeprecation){var t=`fs: missing callback `+(e.stack||e.message);process.traceDeprecation?console.trace(t):console.error(t)}}}}function maybeCallback(e){return typeof e==`function`?e:rethrow()}if(t.normalize,n)var a=/(.*?)(?:[\/\\]+|$)/g;else var a=/(.*?)(?:[\/]+|$)/g;if(n)var o=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else var o=/^[\/]*/;e.realpathSync=function realpathSync(e,i){if(e=t.resolve(e),i&&Object.prototype.hasOwnProperty.call(i,e))return i[e];var s=e,c={},l={},u,d,p,m;start();function start(){var t=o.exec(e);u=t[0].length,d=t[0],p=t[0],m=``,n&&!l[p]&&(r.lstatSync(p),l[p]=!0)}for(;u<e.length;){a.lastIndex=u;var h=a.exec(e);if(m=d,d+=h[0],p=m+h[1],u=a.lastIndex,!(l[p]||i&&i[p]===p)){var g;if(i&&Object.prototype.hasOwnProperty.call(i,p))g=i[p];else{var _=r.lstatSync(p);if(!_.isSymbolicLink()){l[p]=!0,i&&(i[p]=p);continue}var v=null;if(!n){var y=_.dev.toString(32)+`:`+_.ino.toString(32);c.hasOwnProperty(y)&&(v=c[y])}v===null&&(r.statSync(p),v=r.readlinkSync(p)),g=t.resolve(m,v),i&&(i[p]=g),n||(c[y]=v)}e=t.resolve(g,e.slice(u)),start()}}return i&&(i[s]=e),e},e.realpath=function realpath(e,i,s){if(typeof s!=`function`&&(s=maybeCallback(i),i=null),e=t.resolve(e),i&&Object.prototype.hasOwnProperty.call(i,e))return process.nextTick(s.bind(null,null,i[e]));var c=e,l={},u={},d,p,m,h;start();function start(){var t=o.exec(e);d=t[0].length,p=t[0],m=t[0],h=``,n&&!u[m]?r.lstat(m,function(e){if(e)return s(e);u[m]=!0,LOOP()}):process.nextTick(LOOP)}function LOOP(){if(d>=e.length)return i&&(i[c]=e),s(null,e);a.lastIndex=d;var t=a.exec(e);return h=p,p+=t[0],m=h+t[1],d=a.lastIndex,u[m]||i&&i[m]===m?process.nextTick(LOOP):i&&Object.prototype.hasOwnProperty.call(i,m)?gotResolvedLink(i[m]):r.lstat(m,gotStat)}function gotStat(e,t){if(e)return s(e);if(!t.isSymbolicLink())return u[m]=!0,i&&(i[m]=m),process.nextTick(LOOP);if(!n){var a=t.dev.toString(32)+`:`+t.ino.toString(32);if(l.hasOwnProperty(a))return gotTarget(null,l[a],m)}r.stat(m,function(e){if(e)return s(e);r.readlink(m,function(e,t){n||(l[a]=t),gotTarget(e,t)})})}function gotTarget(e,n,r){if(e)return s(e);var a=t.resolve(h,n);i&&(i[r]=a),gotResolvedLink(a)}function gotResolvedLink(n){e=t.resolve(n,e.slice(d)),start()}}})),Vn=__commonJSMin(((e,t)=>{t.exports=realpath,realpath.realpath=realpath,realpath.sync=realpathSync,realpath.realpathSync=realpathSync,realpath.monkeypatch=monkeypatch,realpath.unmonkeypatch=unmonkeypatch;var n=O(`fs`),r=n.realpath,i=n.realpathSync,a=process.version,o=/^v[0-5]\./.test(a),s=Bn();function newError(e){return e&&e.syscall===`realpath`&&(e.code===`ELOOP`||e.code===`ENOMEM`||e.code===`ENAMETOOLONG`)}function realpath(e,t,n){if(o)return r(e,t,n);typeof t==`function`&&(n=t,t=null),r(e,t,function(r,i){newError(r)?s.realpath(e,t,n):n(r,i)})}function realpathSync(e,t){if(o)return i(e,t);try{return i(e,t)}catch(n){if(newError(n))return s.realpathSync(e,t);throw n}}function monkeypatch(){n.realpath=realpath,n.realpathSync=realpathSync}function unmonkeypatch(){n.realpath=r,n.realpathSync=i}})),Hn=__commonJSMin(((e,t)=>{t.exports=function(e,t){for(var r=[],i=0;i<e.length;i++){var a=t(e[i],i);n(a)?r.push.apply(r,a):r.push(a)}return r};var n=Array.isArray||function(e){return Object.prototype.toString.call(e)===`[object Array]`}})),Un=__commonJSMin(((e,t)=>{t.exports=balanced;function balanced(e,t,n){e instanceof RegExp&&(e=maybeMatch(e,n)),t instanceof RegExp&&(t=maybeMatch(t,n));var r=range(e,t,n);return r&&{start:r[0],end:r[1],pre:n.slice(0,r[0]),body:n.slice(r[0]+e.length,r[1]),post:n.slice(r[1]+t.length)}}function maybeMatch(e,t){var n=t.match(e);return n?n[0]:null}balanced.range=range;function range(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i<a&&(a=i,o=l),l=n.indexOf(t,u+1)),u=c<l&&c>=0?c:l;r.length&&(s=[a,o])}return s}})),Wn=__commonJSMin(((e,t)=>{Hn();var n=Un();t.exports=expandTop;var r=`\0SLASH`+Math.random()+`\0`,i=`\0OPEN`+Math.random()+`\0`,a=`\0CLOSE`+Math.random()+`\0`,o=`\0COMMA`+Math.random()+`\0`,s=`\0PERIOD`+Math.random()+`\0`,c=1e5,l=4e6;function numeric(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function escapeBraces(e){return e.split(`\\\\`).join(r).split(`\\{`).join(i).split(`\\}`).join(a).split(`\\,`).join(o).split(`\\.`).join(s)}function unescapeBraces(e){return e.split(r).join(`\\`).split(i).join(`{`).split(a).join(`}`).split(o).join(`,`).split(s).join(`.`)}function parseCommaParts(e){if(!e)return[``];var t=[],r=n(`{`,`}`,e);if(!r)return e.split(`,`);var i=r.pre,a=r.body,o=r.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=parseCommaParts(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function expandTop(e,t){if(!e)return[];t||={};var n=t.max==null?c:t.max,r=t.maxLength==null?l:t.maxLength;return e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),expand(escapeBraces(e),n,r,!0).map(unescapeBraces)}function embrace(e){return`{`+e+`}`}function isPadded(e){return/^-?0\d/.test(e)}function lte(e,t){return e<=t}function gte(e,t){return e>=t}function combine(e,t,n,r,i,a,o,s){for(var c=[],l=0,u=0;u<e.length;u++)for(var d=0;d<r.length;d++){if(c.length>=i)return c;var p=e[u]+n+r[d];if(!(o&&p.length===t[u])){if(l+p.length>a)return c;c.push(p),s.push(t[u]),l+=p.length}}return c}function expandSequence(e,t,n,r){var i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;var o=numeric(i[0]),s=numeric(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(numeric(i[2])),1):1,u=lte;s<o&&(l*=-1,u=gte);for(var d=i.some(isPadded),p=0,m=o;u(m,s)&&a.length<n;m+=l){var h;if(t)h=String.fromCharCode(m),h===`\\`&&(h=``);else if(h=String(m),d){var g=c-h.length;if(g>0){var _=Array(g+1).join(`0`);h=m<0?`-`+_+h.slice(1):_+h}}if(p+h.length>r)break;a.push(h),p+=h.length}return a}function expand(e,t,r,i){for(var o=[``],s=[0],c=!1,l=!0,u;;){var d=n(`{`,`}`,e);if(!d)return combine(o,s,e,[``],t,r,c,[]);var p=d.pre;if(/\$$/.test(p))return combine(o,s,e,[``],t,r,c,[]);var m=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(d.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(d.body),g=m||h,_=d.body.indexOf(`,`)>=0;if(!g&&!_){if(d.post.match(/,(?!,).*\}/)){e=d.pre+`{`+d.body+a+d.post,i=!0,l=!0,c=!1,s=[];for(var v=0;v<o.length;v++)s.push(o[v].length);continue}return combine(o,s,p+`{`+d.body+`}`+d.post,[``],t,r,c,[])}l&&=(c=i&&!g,!1);var y;if(g)y=expandSequence(d.body,h,t,r);else{var b=parseCommaParts(d.body);if(b.length===1&&b[0]!==void 0&&(b=expand(b[0],t,r,!1).map(embrace),b.length===1)){if(u=[],o=combine(o,s,p+b[0],[``],t,r,c&&!d.post.length,u),s=u,!d.post.length)break;e=d.post;continue}for(var x=c&&!d.post.length&&!p,S=0;x&&S<o.length;S++)o[S].length!==s[S]&&(x=!1);y=[];var C=0;outer:for(var w=0;w<b.length;w++)for(var T=expand(b[w],t,r,!1),E=0;E<T.length;E++){var D=T[E];if(!x||D){if(y.length>=t||C+D.length>r)break outer;y.push(D),C+=D.length}}}if(u=[],o=combine(o,s,p,y,t,r,c&&!d.post.length,u),s=u,!d.post.length)break;e=d.post}return o}})),Gn=__commonJSMin(((e,t)=>{t.exports=minimatch,minimatch.Minimatch=Minimatch;var n=function(){try{return O(`path`)}catch{}}()||{sep:`/`};minimatch.sep=n.sep;var r=minimatch.GLOBSTAR=Minimatch.GLOBSTAR={},i=Wn(),a={"!":{open:`(?:(?!(?:`,close:`))[^/]*?)`},"?":{open:`(?:`,close:`)?`},"+":{open:`(?:`,close:`)+`},"*":{open:`(?:`,close:`)*`},"@":{open:`(?:`,close:`)`}},o=`[^/]`,s=o+`*?`,c=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,l=`(?:(?!(?:\\/|^)\\.).)*?`,u=charSet(`().*{}+?[]^$\\!`);function charSet(e){return e.split(``).reduce(function(e,t){return e[t]=!0,e},{})}var d=/\/+/;minimatch.filter=filter;function filter(e,t){return t||={},function(n,r,i){return minimatch(n,e,t)}}function ext(e,t){t||={};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}minimatch.defaults=function(e){if(!e||typeof e!=`object`||!Object.keys(e).length)return minimatch;var t=minimatch,n=function minimatch(n,r,i){return t(n,r,ext(e,i))};return n.Minimatch=function Minimatch(n,r){return new t.Minimatch(n,ext(e,r))},n.Minimatch.defaults=function defaults(n){return t.defaults(ext(e,n)).Minimatch},n.filter=function filter(n,r){return t.filter(n,ext(e,r))},n.defaults=function defaults(n){return t.defaults(ext(e,n))},n.makeRe=function makeRe(n,r){return t.makeRe(n,ext(e,r))},n.braceExpand=function braceExpand(n,r){return t.braceExpand(n,ext(e,r))},n.match=function(n,r,i){return t.match(n,r,ext(e,i))},n},Minimatch.defaults=function(e){return minimatch.defaults(e).Minimatch};function minimatch(e,t,n){return assertValidPattern(t),n||={},!n.nocomment&&t.charAt(0)===`#`?!1:new Minimatch(t,n).match(e)}function Minimatch(e,t){if(!(this instanceof Minimatch))return new Minimatch(e,t);assertValidPattern(e),t||={},e=e.trim(),!t.allowWindowsEscape&&n.sep!==`/`&&(e=e.split(n.sep).join(`/`)),this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion===void 0?200:t.maxGlobstarRecursion,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}Minimatch.prototype.debug=function(){},Minimatch.prototype.make=make;function make(){var e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate();var n=this.globSet=this.braceExpand();t.debug&&(this.debug=function debug(){console.error.apply(console,arguments)}),this.debug(this.pattern,n),n=this.globParts=n.map(function(e){return e.split(d)}),this.debug(this.pattern,n),n=n.map(function(e,t,n){return e.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(e){return e.indexOf(!1)===-1}),this.debug(this.pattern,n),this.set=n}Minimatch.prototype.parseNegate=parseNegate;function parseNegate(){var e=this.pattern,t=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,a=e.length;i<a&&e.charAt(i)===`!`;i++)t=!t,r++;r&&(this.pattern=e.substr(r)),this.negate=t}}minimatch.braceExpand=function(e,t){return braceExpand(e,t)},Minimatch.prototype.braceExpand=braceExpand;function braceExpand(e,t){return t||=this instanceof Minimatch?this.options:{},e=e===void 0?this.pattern:e,assertValidPattern(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:i(e)}var p=65536,assertValidPattern=function(e){if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>p)throw TypeError(`pattern is too long`)};Minimatch.prototype.parse=parse;var m={};function parse(e,t){assertValidPattern(e);var n=this.options;if(e===`**`){if(n.noglobstar)e=`*`;else return r}if(e===``)return``;var i=``,c=!!n.nocase,l=!1,d=[],p=[],h,g=!1,_=-1,v=-1,y=e.charAt(0)===`.`?``:n.dot?`(?!(?:^|\\/)\\.{1,2}(?:$|\\/))`:`(?!\\.)`,b=this;function clearStateChar(){if(h){switch(h){case`*`:i+=s,c=!0;break;case`?`:i+=o,c=!0;break;default:i+=`\\`+h}b.debug(`clearStateChar %j %j`,h,i),h=!1}}for(var x=0,S=e.length,C;x<S&&(C=e.charAt(x));x++){if(this.debug(`%s %s %s %j`,e,x,i,C),l&&u[C]){i+=`\\`+C,l=!1;continue}switch(C){case`/`:return!1;case`\\`:clearStateChar(),l=!0;continue;case`?`:case`*`:case`+`:case`@`:case`!`:if(this.debug(`%s %s %s %j <-- stateChar`,e,x,i,C),g){this.debug(` in class`),C===`!`&&x===v+1&&(C=`^`),i+=C;continue}if(C===`*`&&h===`*`)continue;b.debug(`call clearStateChar %j`,h),clearStateChar(),h=C,n.noext&&clearStateChar();continue;case`(`:if(g){i+=`(`;continue}if(!h){i+=`\\(`;continue}d.push({type:h,start:x-1,reStart:i.length,open:a[h].open,close:a[h].close}),i+=h===`!`?`(?:(?!(?:`:`(?:`,this.debug(`plType %j %j`,h,i),h=!1;continue;case`)`:if(g||!d.length){i+=`\\)`;continue}clearStateChar(),c=!0;var w=d.pop();i+=w.close,w.type===`!`&&p.push(w),w.reEnd=i.length;continue;case`|`:if(g||!d.length||l){i+=`\\|`,l=!1;continue}clearStateChar(),i+=`|`;continue;case`[`:if(clearStateChar(),g){i+=`\\`+C;continue}g=!0,v=x,_=i.length,i+=C;continue;case`]`:if(x===v+1||!g){i+=`\\`+C,l=!1;continue}var T=e.substring(v+1,x);try{RegExp(`[`+T+`]`)}catch{var E=this.parse(T,m);i=i.substr(0,_)+`\\[`+E[0]+`\\]`,c||=E[1],g=!1;continue}c=!0,g=!1,i+=C;continue;default:clearStateChar(),l?l=!1:u[C]&&!(C===`^`&&g)&&(i+=`\\`),i+=C}}for(g&&(T=e.substr(v+1),E=this.parse(T,m),i=i.substr(0,_)+`\\[`+E[0],c||=E[1]),w=d.pop();w;w=d.pop()){var D=i.slice(w.reStart+w.open.length);this.debug(`setting tail`,i,w),D=D.replace(/((?:\\{2}){0,64})(\\?)\|/g,function(e,t,n){return n||=`\\`,t+t+n+`|`}),this.debug(`tail=%j
|
|
25
|
-
|
|
26
|
-
See: https://github.com/isaacs/node-glob/issues/167`);return new GlobSync(e,t).found}function GlobSync(e,t){if(!e)throw Error(`must provide pattern`);if(typeof t==`function`||arguments.length===3)throw TypeError(`callback provided to sync glob
|
|
27
|
-
See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof GlobSync))return new GlobSync(e,t);if(c(this,e,t),this.noprocess)return this;var n=this.minimatch.set.length;this.matches=Array(n);for(var r=0;r<n;r++)this._process(this.minimatch.set[r],r,!1);this._finish()}GlobSync.prototype._finish=function(){if(a.ok(this instanceof GlobSync),this.realpath){var e=this;this.matches.forEach(function(t,r){var i=e.matches[r]=Object.create(null);for(var a in t)try{a=e._makeAbs(a);var o=n.realpathSync(a,e.realpathCache);i[o]=!0}catch(t){if(t.syscall===`stat`)i[e._makeAbs(a)]=!0;else throw t}})}s.finish(this)},GlobSync.prototype._process=function(e,t,n){a.ok(this instanceof GlobSync);for(var i=0;typeof e[i]==`string`;)i++;var s;switch(i){case e.length:this._processSimple(e.join(`/`),t);return;case 0:s=null;break;default:s=e.slice(0,i).join(`/`)}var c=e.slice(i),l;s===null?l=`.`:((o(s)||o(e.map(function(e){return typeof e==`string`?e:`[*]`}).join(`/`)))&&(!s||!o(s))&&(s=`/`+s),l=s);var d=this._makeAbs(l);u(this,l)||(c[0]===r.GLOBSTAR?this._processGlobStar(s,l,d,c,t,n):this._processReaddir(s,l,d,c,t,n))},GlobSync.prototype._processReaddir=function(e,t,n,r,a,o){var s=this._readdir(n,o);if(s){for(var c=r[0],l=!!this.minimatch.negate,u=c._glob,d=this.dot||u.charAt(0)===`.`,p=[],m=0;m<s.length;m++){var h=s[m];(h.charAt(0)!==`.`||d)&&(l&&!e?!h.match(c):h.match(c))&&p.push(h)}var g=p.length;if(g!==0){if(r.length===1&&!this.mark&&!this.stat){this.matches[a]||(this.matches[a]=Object.create(null));for(var m=0;m<g;m++){var h=p[m];e&&(h=e.slice(-1)===`/`?e+h:e+`/`+h),h.charAt(0)===`/`&&!this.nomount&&(h=i.join(this.root,h)),this._emitMatch(a,h)}return}r.shift();for(var m=0;m<g;m++){var h=p[m],_=e?[e,h]:[h];this._process(_.concat(r),a,o)}}}},GlobSync.prototype._emitMatch=function(e,t){if(!d(this,t)){var n=this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=n),!this.matches[e][t]){if(this.nodir){var r=this.cache[n];if(r===`DIR`||Array.isArray(r))return}this.matches[e][t]=!0,this.stat&&this._stat(t)}}},GlobSync.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var t,n;try{n=this.fs.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return null}var r=n&&n.isSymbolicLink();return this.symlinks[e]=r,!r&&n&&!n.isDirectory()?this.cache[e]=`FILE`:t=this._readdir(e,!1),t},GlobSync.prototype._readdir=function(e,t){if(t&&!l(this.symlinks,e))return this._readdirInGlobStar(e);if(l(this.cache,e)){var n=this.cache[e];if(!n||n===`FILE`)return null;if(Array.isArray(n))return n}try{return this._readdirEntries(e,this.fs.readdirSync(e))}catch(t){return this._readdirError(e,t),null}},GlobSync.prototype._readdirEntries=function(e,t){if(!this.mark&&!this.stat)for(var n=0;n<t.length;n++){var r=t[n];r=e===`/`?e+r:e+`/`+r,this.cache[r]=!0}return this.cache[e]=t,t},GlobSync.prototype._readdirError=function(e,t){switch(t.code){case`ENOTSUP`:case`ENOTDIR`:var n=this._makeAbs(e);if(this.cache[n]=`FILE`,n===this.cwdAbs){var r=Error(t.code+` invalid cwd `+this.cwd);throw r.path=this.cwd,r.code=t.code,r}break;case`ENOENT`:case`ELOOP`:case`ENAMETOOLONG`:case`UNKNOWN`:this.cache[this._makeAbs(e)]=!1;break;default:if(this.cache[this._makeAbs(e)]=!1,this.strict)throw t;this.silent||console.error(`glob error`,t)}},GlobSync.prototype._processGlobStar=function(e,t,n,r,i,a){var o=this._readdir(n,a);if(o){var s=r.slice(1),c=e?[e]:[],l=c.concat(s);this._process(l,i,!1);var u=o.length;if(!(this.symlinks[n]&&a)){for(var d=0;d<u;d++)if(o[d].charAt(0)!==`.`||this.dot){var p=c.concat(o[d],s);this._process(p,i,!0);var m=c.concat(o[d],r);this._process(m,i,!0)}}}},GlobSync.prototype._processSimple=function(e,t){var n=this._stat(e);if(this.matches[t]||(this.matches[t]=Object.create(null)),n){if(e&&o(e)&&!this.nomount){var r=/[\/\\]$/.test(e);e.charAt(0)===`/`?e=i.join(this.root,e):(e=i.resolve(this.root,e),r&&(e+=`/`))}process.platform===`win32`&&(e=e.replace(/\\/g,`/`)),this._emitMatch(t,e)}},GlobSync.prototype._stat=function(e){var t=this._makeAbs(e),n=e.slice(-1)===`/`;if(e.length>this.maxLength)return!1;if(!this.stat&&l(this.cache,t)){var r=this.cache[t];if(Array.isArray(r)&&(r=`DIR`),!n||r===`DIR`)return r;if(n&&r===`FILE`)return!1}var i=this.statCache[t];if(!i){var a;try{a=this.fs.lstatSync(t)}catch(e){if(e&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return this.statCache[t]=!1,!1}if(a&&a.isSymbolicLink())try{i=this.fs.statSync(t)}catch{i=a}else i=a}this.statCache[t]=i;var r=!0;return i&&(r=i.isDirectory()?`DIR`:`FILE`),this.cache[t]=this.cache[t]||r,n&&r===`FILE`?!1:r},GlobSync.prototype._mark=function(e){return s.mark(this,e)},GlobSync.prototype._makeAbs=function(e){return s.makeAbs(this,e)}})),Zn=__commonJSMin(((e,t)=>{t.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=`function`)throw TypeError(`need wrapper function`);return Object.keys(e).forEach(function(t){wrapper[t]=e[t]}),wrapper;function wrapper(){for(var t=Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),i=t[t.length-1];return typeof r==`function`&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}}})),Qn=__commonJSMin(((e,t)=>{var n=Zn();t.exports=n(once),t.exports.strict=n(onceStrict),once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})});function once(e){var f=function(){return f.called?f.value:(f.called=!0,f.value=e.apply(this,arguments))};return f.called=!1,f}function onceStrict(e){var f=function(){if(f.called)throw Error(f.onceError);return f.called=!0,f.value=e.apply(this,arguments)};return f.onceError=(e.name||"Function wrapped with `once`")+` shouldn't be called more than once`,f.called=!1,f}})),$n=__commonJSMin(((e,t)=>{var n=Zn(),r=Object.create(null),i=Qn();t.exports=n(inflight);function inflight(e,t){return r[e]?(r[e].push(t),null):(r[e]=[t],makeres(e))}function makeres(e){return i(function RES(){var t=r[e],n=t.length,i=slice(arguments);try{for(var a=0;a<n;a++)t[a].apply(null,i)}finally{t.length>n?(t.splice(0,n),process.nextTick(function(){RES.apply(null,i)})):delete r[e]}})}function slice(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r]=e[r];return n}})),er=__commonJSMin(((e,t)=>{t.exports=glob;var n=Vn(),r=Gn();r.Minimatch;var i=qn(),a=O(`events`).EventEmitter,o=O(`path`),s=O(`assert`),c=Jn(),l=Xn(),u=Yn(),d=u.setopts,p=u.ownProp,m=$n();O(`util`);var h=u.childrenIgnored,g=u.isIgnored,_=Qn();function glob(e,t,n){if(typeof t==`function`&&(n=t,t={}),t||={},t.sync){if(n)throw TypeError(`callback provided to sync glob`);return l(e,t)}return new Glob(e,t,n)}glob.sync=l;var v=glob.GlobSync=l.GlobSync;glob.glob=glob;function extend(e,t){if(typeof t!=`object`||!t)return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}glob.hasMagic=function(e,t){var n=extend({},t);n.noprocess=!0;var r=new Glob(e,n).minimatch.set;if(!e)return!1;if(r.length>1)return!0;for(var i=0;i<r[0].length;i++)if(typeof r[0][i]!=`string`)return!0;return!1},glob.Glob=Glob,i(Glob,a);function Glob(e,t,n){if(typeof t==`function`&&(n=t,t=null),t&&t.sync){if(n)throw TypeError(`callback provided to sync glob`);return new v(e,t)}if(!(this instanceof Glob))return new Glob(e,t,n);d(this,e,t),this._didRealPath=!1;var r=this.minimatch.set.length;this.matches=Array(r),typeof n==`function`&&(n=_(n),this.on(`error`,n),this.on(`end`,function(e){n(null,e)}));var i=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(r===0)return done();for(var a=!0,o=0;o<r;o++)this._process(this.minimatch.set[o],o,!1,done);a=!1;function done(){--i._processing,i._processing<=0&&(a?process.nextTick(function(){i._finish()}):i._finish())}}Glob.prototype._finish=function(){if(s(this instanceof Glob),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();u.finish(this),this.emit(`end`,this.found)}},Glob.prototype._realpath=function(){if(this._didRealpath)return;this._didRealpath=!0;var e=this.matches.length;if(e===0)return this._finish();for(var t=this,n=0;n<this.matches.length;n++)this._realpathSet(n,next);function next(){--e===0&&t._finish()}},Glob.prototype._realpathSet=function(e,t){var r=this.matches[e];if(!r)return t();var i=Object.keys(r),a=this,o=i.length;if(o===0)return t();var s=this.matches[e]=Object.create(null);i.forEach(function(r,i){r=a._makeAbs(r),n.realpath(r,a.realpathCache,function(n,i){n?n.syscall===`stat`?s[r]=!0:a.emit(`error`,n):s[i]=!0,--o===0&&(a.matches[e]=s,t())})})},Glob.prototype._mark=function(e){return u.mark(this,e)},Glob.prototype._makeAbs=function(e){return u.makeAbs(this,e)},Glob.prototype.abort=function(){this.aborted=!0,this.emit(`abort`)},Glob.prototype.pause=function(){this.paused||(this.paused=!0,this.emit(`pause`))},Glob.prototype.resume=function(){if(this.paused){if(this.emit(`resume`),this.paused=!1,this._emitQueue.length){var e=this._emitQueue.slice(0);this._emitQueue.length=0;for(var t=0;t<e.length;t++){var n=e[t];this._emitMatch(n[0],n[1])}}if(this._processQueue.length){var r=this._processQueue.slice(0);this._processQueue.length=0;for(var t=0;t<r.length;t++){var i=r[t];this._processing--,this._process(i[0],i[1],i[2],i[3])}}}},Glob.prototype._process=function(e,t,n,i){if(s(this instanceof Glob),s(typeof i==`function`),!this.aborted){if(this._processing++,this.paused){this._processQueue.push([e,t,n,i]);return}for(var a=0;typeof e[a]==`string`;)a++;var o;switch(a){case e.length:this._processSimple(e.join(`/`),t,i);return;case 0:o=null;break;default:o=e.slice(0,a).join(`/`)}var l=e.slice(a),u;o===null?u=`.`:((c(o)||c(e.map(function(e){return typeof e==`string`?e:`[*]`}).join(`/`)))&&(!o||!c(o))&&(o=`/`+o),u=o);var d=this._makeAbs(u);if(h(this,u))return i();l[0]===r.GLOBSTAR?this._processGlobStar(o,u,d,l,t,n,i):this._processReaddir(o,u,d,l,t,n,i)}},Glob.prototype._processReaddir=function(e,t,n,r,i,a,o){var s=this;this._readdir(n,a,function(c,l){return s._processReaddir2(e,t,n,r,i,a,l,o)})},Glob.prototype._processReaddir2=function(e,t,n,r,i,a,s,c){if(!s)return c();for(var l=r[0],u=!!this.minimatch.negate,d=l._glob,p=this.dot||d.charAt(0)===`.`,m=[],h=0;h<s.length;h++){var g=s[h];(g.charAt(0)!==`.`||p)&&(u&&!e?!g.match(l):g.match(l))&&m.push(g)}var _=m.length;if(_===0)return c();if(r.length===1&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(var h=0;h<_;h++){var g=m[h];e&&(g=e===`/`?e+g:e+`/`+g),g.charAt(0)===`/`&&!this.nomount&&(g=o.join(this.root,g)),this._emitMatch(i,g)}return c()}r.shift();for(var h=0;h<_;h++){var g=m[h];e&&(g=e===`/`?e+g:e+`/`+g),this._process([g].concat(r),i,a,c)}c()},Glob.prototype._emitMatch=function(e,t){if(!this.aborted&&!g(this,t)){if(this.paused){this._emitQueue.push([e,t]);return}var n=c(t)?t:this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=n),!this.matches[e][t]){if(this.nodir){var r=this.cache[n];if(r===`DIR`||Array.isArray(r))return}this.matches[e][t]=!0;var i=this.statCache[n];i&&this.emit(`stat`,t,i),this.emit(`match`,t)}}},Glob.prototype._readdirInGlobStar=function(e,t){if(this.aborted)return;if(this.follow)return this._readdir(e,!1,t);var n=`lstat\0`+e,r=this,i=m(n,lstatcb_);i&&r.fs.lstat(e,i);function lstatcb_(n,i){if(n&&n.code===`ENOENT`)return t();var a=i&&i.isSymbolicLink();r.symlinks[e]=a,!a&&i&&!i.isDirectory()?(r.cache[e]=`FILE`,t()):r._readdir(e,!1,t)}},Glob.prototype._readdir=function(e,t,n){if(!this.aborted&&(n=m(`readdir\0`+e+`\0`+t,n),n)){if(t&&!p(this.symlinks,e))return this._readdirInGlobStar(e,n);if(p(this.cache,e)){var r=this.cache[e];if(!r||r===`FILE`)return n();if(Array.isArray(r))return n(null,r)}this.fs.readdir(e,readdirCb(this,e,n))}};function readdirCb(e,t,n){return function(r,i){r?e._readdirError(t,r,n):e._readdirEntries(t,i,n)}}Glob.prototype._readdirEntries=function(e,t,n){if(!this.aborted){if(!this.mark&&!this.stat)for(var r=0;r<t.length;r++){var i=t[r];i=e===`/`?e+i:e+`/`+i,this.cache[i]=!0}return this.cache[e]=t,n(null,t)}},Glob.prototype._readdirError=function(e,t,n){if(!this.aborted){switch(t.code){case`ENOTSUP`:case`ENOTDIR`:var r=this._makeAbs(e);if(this.cache[r]=`FILE`,r===this.cwdAbs){var i=Error(t.code+` invalid cwd `+this.cwd);i.path=this.cwd,i.code=t.code,this.emit(`error`,i),this.abort()}break;case`ENOENT`:case`ELOOP`:case`ENAMETOOLONG`:case`UNKNOWN`:this.cache[this._makeAbs(e)]=!1;break;default:this.cache[this._makeAbs(e)]=!1,this.strict&&(this.emit(`error`,t),this.abort()),this.silent||console.error(`glob error`,t)}return n()}},Glob.prototype._processGlobStar=function(e,t,n,r,i,a,o){var s=this;this._readdir(n,a,function(c,l){s._processGlobStar2(e,t,n,r,i,a,l,o)})},Glob.prototype._processGlobStar2=function(e,t,n,r,i,a,o,s){if(!o)return s();var c=r.slice(1),l=e?[e]:[],u=l.concat(c);this._process(u,i,!1,s);var d=this.symlinks[n],p=o.length;if(d&&a)return s();for(var m=0;m<p;m++)if(o[m].charAt(0)!==`.`||this.dot){var h=l.concat(o[m],c);this._process(h,i,!0,s);var g=l.concat(o[m],r);this._process(g,i,!0,s)}s()},Glob.prototype._processSimple=function(e,t,n){var r=this;this._stat(e,function(i,a){r._processSimple2(e,t,i,a,n)})},Glob.prototype._processSimple2=function(e,t,n,r,i){if(this.matches[t]||(this.matches[t]=Object.create(null)),!r)return i();if(e&&c(e)&&!this.nomount){var a=/[\/\\]$/.test(e);e.charAt(0)===`/`?e=o.join(this.root,e):(e=o.resolve(this.root,e),a&&(e+=`/`))}process.platform===`win32`&&(e=e.replace(/\\/g,`/`)),this._emitMatch(t,e),i()},Glob.prototype._stat=function(e,t){var n=this._makeAbs(e),r=e.slice(-1)===`/`;if(e.length>this.maxLength)return t();if(!this.stat&&p(this.cache,n)){var i=this.cache[n];if(Array.isArray(i)&&(i=`DIR`),!r||i===`DIR`)return t(null,i);if(r&&i===`FILE`)return t()}var a=this.statCache[n];if(a!==void 0){if(a===!1)return t(null,a);var o=a.isDirectory()?`DIR`:`FILE`;return r&&o===`FILE`?t():t(null,o,a)}var s=this,c=m(`stat\0`+n,lstatcb_);c&&s.fs.lstat(n,c);function lstatcb_(r,i){if(i&&i.isSymbolicLink())return s.fs.stat(n,function(r,a){r?s._stat2(e,n,null,i,t):s._stat2(e,n,r,a,t)});s._stat2(e,n,r,i,t)}},Glob.prototype._stat2=function(e,t,n,r,i){if(n&&(n.code===`ENOENT`||n.code===`ENOTDIR`))return this.statCache[t]=!1,i();var a=e.slice(-1)===`/`;if(this.statCache[t]=r,t.slice(-1)===`/`&&r&&!r.isDirectory())return i(null,!1,r);var o=!0;return r&&(o=r.isDirectory()?`DIR`:`FILE`),this.cache[t]=this.cache[t]||o,a&&o===`FILE`?i():i(null,o,r)}})),tr=__commonJSMin(((e,t)=>{t.exports=rimraf,rimraf.sync=rimrafSync;var n=O(`assert`),r=O(`path`),i=O(`fs`),a=er(),o=438,s={nosort:!0,silent:!0},c=0,l=process.platform===`win32`;function defaults(e){[`unlink`,`chmod`,`stat`,`lstat`,`rmdir`,`readdir`].forEach(function(t){e[t]=e[t]||i[t],t+=`Sync`,e[t]=e[t]||i[t]}),e.maxBusyTries=e.maxBusyTries||3,e.emfileWait=e.emfileWait||1e3,e.glob===!1&&(e.disableGlob=!0),e.disableGlob=e.disableGlob||!1,e.glob=e.glob||s}function rimraf(e,t,r){typeof t==`function`&&(r=t,t={}),n(e,`rimraf: missing path`),n.equal(typeof e,`string`,`rimraf: path should be a string`),n.equal(typeof r,`function`,`rimraf: callback function required`),n(t,`rimraf: invalid options argument provided`),n.equal(typeof t,`object`,`rimraf: options should be object`),defaults(t);var i=0,o=null,s=0;if(t.disableGlob||!a.hasMagic(e))return afterGlob(null,[e]);t.lstat(e,function(n,r){if(!n)return afterGlob(null,[e]);a(e,t.glob,afterGlob)});function next(e){o||=e,--s===0&&r(o)}function afterGlob(e,n){if(e)return r(e);if(s=n.length,s===0)return r();n.forEach(function(e){rimraf_(e,t,function CB(n){if(n){if((n.code===`EBUSY`||n.code===`ENOTEMPTY`||n.code===`EPERM`)&&i<t.maxBusyTries){i++;var r=i*100;return setTimeout(function(){rimraf_(e,t,CB)},r)}if(n.code===`EMFILE`&&c<t.emfileWait)return setTimeout(function(){rimraf_(e,t,CB)},c++);n.code===`ENOENT`&&(n=null)}c=0,next(n)})})}}function rimraf_(e,t,r){n(e),n(t),n(typeof r==`function`),t.lstat(e,function(n,i){if(n&&n.code===`ENOENT`)return r(null);if(n&&n.code===`EPERM`&&l&&fixWinEPERM(e,t,n,r),i&&i.isDirectory())return rmdir(e,t,n,r);t.unlink(e,function(n){if(n){if(n.code===`ENOENT`)return r(null);if(n.code===`EPERM`)return l?fixWinEPERM(e,t,n,r):rmdir(e,t,n,r);if(n.code===`EISDIR`)return rmdir(e,t,n,r)}return r(n)})})}function fixWinEPERM(e,t,r,i){n(e),n(t),n(typeof i==`function`),r&&n(r instanceof Error),t.chmod(e,o,function(n){n?i(n.code===`ENOENT`?null:r):t.stat(e,function(n,a){n?i(n.code===`ENOENT`?null:r):a.isDirectory()?rmdir(e,t,r,i):t.unlink(e,i)})})}function fixWinEPERMSync(e,t,r){n(e),n(t),r&&n(r instanceof Error);try{t.chmodSync(e,o)}catch(e){if(e.code===`ENOENT`)return;throw r}try{var i=t.statSync(e)}catch(e){if(e.code===`ENOENT`)return;throw r}i.isDirectory()?rmdirSync(e,t,r):t.unlinkSync(e)}function rmdir(e,t,r,i){n(e),n(t),r&&n(r instanceof Error),n(typeof i==`function`),t.rmdir(e,function(n){n&&(n.code===`ENOTEMPTY`||n.code===`EEXIST`||n.code===`EPERM`)?rmkids(e,t,i):n&&n.code===`ENOTDIR`?i(r):i(n)})}function rmkids(e,t,i){n(e),n(t),n(typeof i==`function`),t.readdir(e,function(n,a){if(n)return i(n);var o=a.length;if(o===0)return t.rmdir(e,i);var s;a.forEach(function(n){rimraf(r.join(e,n),t,function(n){if(!s){if(n)return i(s=n);--o===0&&t.rmdir(e,i)}})})})}function rimrafSync(e,t){t||={},defaults(t),n(e,`rimraf: missing path`),n.equal(typeof e,`string`,`rimraf: path should be a string`),n(t,`rimraf: missing options`),n.equal(typeof t,`object`,`rimraf: options should be object`);var r;if(t.disableGlob||!a.hasMagic(e))r=[e];else try{t.lstatSync(e),r=[e]}catch{r=a.sync(e,t.glob)}if(r.length)for(var i=0;i<r.length;i++){var e=r[i];try{var o=t.lstatSync(e)}catch(n){if(n.code===`ENOENT`)return;n.code===`EPERM`&&l&&fixWinEPERMSync(e,t,n)}try{o&&o.isDirectory()?rmdirSync(e,t,null):t.unlinkSync(e)}catch(n){if(n.code===`ENOENT`)return;if(n.code===`EPERM`)return l?fixWinEPERMSync(e,t,n):rmdirSync(e,t,n);if(n.code!==`EISDIR`)throw n;rmdirSync(e,t,n)}}}function rmdirSync(e,t,r){n(e),n(t),r&&n(r instanceof Error);try{t.rmdirSync(e)}catch(n){if(n.code===`ENOENT`)return;if(n.code===`ENOTDIR`)throw r;(n.code===`ENOTEMPTY`||n.code===`EEXIST`||n.code===`EPERM`)&&rmkidsSync(e,t)}}function rmkidsSync(e,t){n(e),n(t),t.readdirSync(e).forEach(function(n){rimrafSync(r.join(e,n),t)});var i=l?100:1,a=0;do{var o=!0;try{var s=t.rmdirSync(e,t);return o=!1,s}finally{if(++a<i&&o)continue}}while(1)}})),nr=__commonJSMin(((e,t)=>{var n=O(`path`),r=O(`fs`),i=511;t.exports=mkdirP.mkdirp=mkdirP.mkdirP=mkdirP;function mkdirP(e,t,a,o){typeof t==`function`?(a=t,t={}):(!t||typeof t!=`object`)&&(t={mode:t});var s=t.mode,c=t.fs||r;s===void 0&&(s=i),o||=null;var l=a||function(){};e=n.resolve(e),c.mkdir(e,s,function(r){if(!r)return o||=e,l(null,o);switch(r.code){case`ENOENT`:if(n.dirname(e)===e)return l(r);mkdirP(n.dirname(e),t,function(n,r){n?l(n,r):mkdirP(e,t,l,r)});break;default:c.stat(e,function(e,t){e||!t.isDirectory()?l(r,o):l(null,o)})}})}mkdirP.sync=function sync(e,t,a){(!t||typeof t!=`object`)&&(t={mode:t});var o=t.mode,s=t.fs||r;o===void 0&&(o=i),a||=null,e=n.resolve(e);try{s.mkdirSync(e,o),a||=e}catch(r){switch(r.code){case`ENOENT`:a=sync(n.dirname(e),t,a),sync(e,t,a);break;default:var c;try{c=s.statSync(e)}catch{throw r}if(!c.isDirectory())throw r}}return a}})),rr=__commonJSMin(((e,t)=>{let n=O(`fs`),r=O(`path`),i=O(`constants`),a=O(`os`),o=tr(),s=nr();O(`os`).tmpdir();let c=o.sync,l=r.resolve(a.tmpdir()),u=i.O_CREAT|i.O_TRUNC|i.O_RDWR|i.O_EXCL,promisify=function(e){if(typeof e==`function`)return[void 0,e];var promiseCallback;return[new Promise(function(e,t){promiseCallback=function(){var n=Array.from(arguments),r=n.shift();process.nextTick(function(){r?t(r):n.length===1?e(n[0]):e(n)})}}),promiseCallback]};var generateName=function(e,t){var n=parseAffixes(e,t),i=new Date,a=[n.prefix,i.getFullYear(),i.getMonth(),i.getDate(),`-`,process.pid,`-`,(Math.random()*4294967296+1).toString(36),n.suffix].join(``);return r.join(n.dir||l,a)},parseAffixes=function(e,t){var n={prefix:null,suffix:null};if(e)switch(typeof e){case`string`:n.prefix=e;break;case`object`:n=e;break;default:throw Error(`Unknown affix declaration: `+n)}else n.prefix=t;return n},d=!1,track=function(e){return d=e!==!1,t.exports},p=!1,m=[],h=[];function deleteFileOnExit(e){if(!d)return!1;attachExitListener(),m.push(e)}function deleteDirOnExit(e){if(!d)return!1;attachExitListener(),h.push(e)}function attachExitListener(){if(!d)return!1;p||=(process.addListener(`exit`,function(){try{cleanupSync()}catch(e){throw console.warn(`Fail to clean temporary files on exit : `,e),e}}),!0)}function cleanupFilesSync(){if(!d)return!1;for(var e=0,t;(t=m.shift())!==void 0;)c(t,{maxBusyTries:6}),e++;return e}function cleanupFiles(e){var t=promisify(e),n=t[0];if(e=t[1],!d)return e(Error(`not tracking`)),n;var r=0,i=m.length;if(!i)return e(null,r),n;for(var a,rimrafCallback=function(t){if(i){if(t){e(t),i=0;return}r++,i--,i||e(null,r)}};(a=m.shift())!==void 0;)o(a,{maxBusyTries:6},rimrafCallback);return n}function cleanupDirsSync(){if(!d)return!1;for(var e=0,t;(t=h.shift())!==void 0;)c(t,{maxBusyTries:6}),e++;return e}function cleanupDirs(e){var t=promisify(e),n=t[0];if(e=t[1],!d)return e(Error(`not tracking`)),n;var r=0,i=h.length;if(!i)return e(null,r),n;for(var a,rimrafCallback=function(t){if(i){if(t){e(t,r),i=0;return}r++,i--,i||e(null,r)}};(a=h.shift())!==void 0;)o(a,{maxBusyTries:6},rimrafCallback);return n}function cleanupSync(){return d?{files:cleanupFilesSync(),dirs:cleanupDirsSync()}:!1}function cleanup(e){var t=promisify(e),n=t[0];return e=t[1],d?(cleanupFiles(function(t,n){t?e(t,{files:n}):cleanupDirs(function(t,r){e(t,{files:n,dirs:r})})}),n):(e(Error(`not tracking`)),n)}let mkdir=(e,t)=>{let n=promisify(t),r=n[0];t=n[1];let i=generateName(e,`d-`);return s(i,448,e=>{e||deleteDirOnExit(i),t(e,i)}),r},mkdirSync=e=>{let t=generateName(e,`d-`);return s.sync(t,448),deleteDirOnExit(t),t},open=(e,t)=>{let r=promisify(t),i=r[0];t=r[1];let a=generateName(e,`f-`);return n.open(a,u,384,(e,n)=>{e||deleteFileOnExit(a),t(e,{path:a,fd:n})}),i},openSync=e=>{let t=generateName(e,`f-`),r=n.openSync(t,u,384);return deleteFileOnExit(t),{path:t,fd:r}},createWriteStream=e=>{let t=generateName(e,`s-`),r=n.createWriteStream(t,{flags:u,mode:384});return deleteFileOnExit(t),r};e.dir=l,e.track=track,e.mkdir=mkdir,e.mkdirSync=mkdirSync,e.open=open,e.openSync=openSync,e.path=generateName,e.cleanup=cleanup,e.cleanupSync=cleanupSync,e.createWriteStream=createWriteStream})),ir,ar=__esmMin((()=>{ir={"aube-lock.yaml":`aube`,"aube-workspace.yaml":`aube`,"bun.lock":`bun`,"bun.lockb":`bun`,"deno.lock":`deno`,"nub.lock":`nub`,"pnpm-lock.yaml":`pnpm`,"pnpm-workspace.yaml":`pnpm`,"yarn.lock":`yarn`,"package-lock.json":`npm`,"npm-shrinkwrap.json":`npm`}})),or=__exportAll({findByKeywords:()=>findByKeywords$1});function getCacheFilepath(){return g.join(sr.dir,cr)}function getCacheKey(e,t){return JSON.stringify({cwd:g.resolve(t),keywords:[...e].sort()})}function getCachedPackages(e,t){let n=loadCache(),r=n[e];if(r){if(typeof r.fingerprint!=`number`||r.fingerprint<t){delete n[e],saveCache(n);return}return r.packages}}function setCachedPackages(e,t,n){let r=loadCache();r[e]={fingerprint:t,packages:n},saveCache(r)}function loadCache(){if(lr)return lr;let e=getCacheFilepath();if(!t.existsSync(e))return lr={},lr;try{return lr=JSON.parse(t.readFileSync(e,{encoding:`utf-8`})),lr}catch{return lr={},lr}}function saveCache(e){lr=e;let n=getCacheFilepath();t.writeFileSync(n,JSON.stringify(e))}async function findPackagesInfo(e){try{await t.promises.access(e)}catch{return[]}return recurseFind(e,{})}async function recurseFind(e,n){let r=g.join(e,`node_modules`);if(n[r])return[];n[r]=!0;try{await t.promises.access(r)}catch{return[]}let i=await t.promises.readdir(r),a=[];return await Promise.all(i.map(async e=>{let i=g.join(r,e),o=await tryStatAsync(i);if(o&&o.isDirectory()){if(n[i]=!0,e.startsWith(`@`)){if(e===`@types`)return;let o=await t.promises.readdir(i);await Promise.all(o.map(async t=>{let i=g.join(r,e,t);if(n[i])return;let o=await tryStatAsync(i);if(!o||!o.isDirectory())return;n[i]=!0,a.push({name:`${e}/${t}`,ctimeMs:o.ctimeMs,path:i});let s=await recurseFind(i,n);a.push(...s)}))}else{a.push({name:e,ctimeMs:o.ctimeMs,path:i});let t=await recurseFind(i,n);a.push(...t)}}})),a}async function tryStatAsync(e){try{return await t.promises.stat(e)}catch{return}}async function getFingerprint(e){let t=g.resolve(e),n=0,bump=e=>{e&&e.mtimeMs>n&&(n=e.mtimeMs)};bump(await statSafe(g.join(t,`package.json`))),bump(await statSafe(g.join(t,`node_modules`)));let r=t;for(;;){let e=(await Promise.all(ur.map(e=>statSafe(g.join(r,e))))).filter(e=>!!e);if(e.length>0){e.forEach(bump);break}let t=g.dirname(r);if(t===r)break;r=t}return n}async function statSafe(e){try{return await t.promises.stat(e)}catch{return}}function hasAllKeywords$1(e,t){let n=new Set(e);return!t.find(e=>!n.has(e))}async function readFileSafe(e){try{return await t.promises.readFile(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}async function readManifest$1(e){try{let t=await readFileSafe(g.resolve(e,`package.json`));if(!t)return;let n=JSON.parse(t);return n&&typeof n==`object`?n:void 0}catch{return}}function dependencyNames(e,t){let n=[...keysOf(e.dependencies),...keysOf(e.optionalDependencies),...keysOf(e.peerDependencies),...t?keysOf(e.devDependencies):[]];return Array.from(new Set(n))}function keysOf(e){return e&&typeof e==`object`&&!Array.isArray(e)?Object.keys(e):[]}async function resolvePackagesInfo(e){let t=g.resolve(e),n=await readManifest$1(t);if(!n)return;let r=dependencyNames(n,!0);if(r.length===0)return;let i=[];return await walk(t,r,new Set([t]),i),i}async function walk(e,t,n,r){await Promise.all(t.map(async t=>{if(t.indexOf(`@types/`)===0)return;let i=resolvePackageDir(t,e);if(!i||n.has(i))return;n.add(i);let a=await readManifest$1(i);a&&(a.name&&r.push({name:a.name,path:i,manifest:a}),await walk(i,dependencyNames(a,!1),n,r))}))}function resolvePackageDir(n,r){let i=e(g.join(r,`package.json`));try{return g.dirname(i.resolve(`${n}/package.json`))}catch{}try{let e=i.resolve.paths(n);if(e)for(let r of e){let e=g.join(r,n);if(t.existsSync(g.join(e,`package.json`)))return e}}catch{}try{let e=g.dirname(i.resolve(n));for(;;){if(readNameSync(e)===n)return e;let t=g.dirname(e);if(t===e)return;e=t}}catch{}}function readNameSync(e){try{return JSON.parse(t.readFileSync(g.join(e,`package.json`),`utf8`)).name}catch{return}}async function findByKeywords$1(e,t){let{cwd:n}=unpartial({cwd:`.`},t);return getPackages(e,n)}async function getPackages(e,t){let n=getCacheKey(e,t),r=await getFingerprint(t),i=getCachedPackages(n,r);if(i)return i;let a=(await collectManifests(t)).filter(t=>t.name&&hasAllKeywords$1(t.keywords,e)).map(e=>e.name),o=Array.from(new Set(a));return setCachedPackages(n,r,o),o}async function collectManifests(e){let t=await resolvePackagesInfo(e);if(t)return t.map(e=>e.manifest);let n=await findPackagesInfo(e);return(await Promise.all(n.map(e=>readManifest$1(e.path)))).filter(e=>!!e)}var sr,cr,lr,ur,dr=__esmMin((()=>{zn(),sr=__toESM(rr(),1),ar(),cr=`.find-installed-packages.cache`,ur=Object.keys(ir).concat([`.pnp.cjs`,`.pnp.data.json`]),__name(hasAllKeywords$1,`hasAllKeywords`),__name(readManifest$1,`readManifest`),__name(findByKeywords$1,`findByKeywords`)}));function hasAllKeywords(e,t){let n=new Set(e);return!t.find(e=>!n.has(e))}var fr=__esmMin((()=>{}));function pickPackagesWithKeywords(e,t,n){let r=e.filter(e=>hasAllKeywords(e.keywords,t));return n?r.map(e=>n.reduce((t,n)=>(t[n]=e[n],t),{name:e.name})):r.map(e=>e.name)}var pr=__esmMin((()=>{fr()}));async function fetchPackagesByKeywords(e,t={}){let{registry:n=mr,maxResults:r=hr,signal:i,fetch:a=globalThis.fetch}=t;if(e.length===0)return{packages:[],truncated:!1};if(typeof a!=`function`)throw new RegistrySearchError(`global fetch is not available; Node 18 or later is required`);let o=`keywords:${e.join(`,`)}`,s=[],c=1/0;for(;s.length<r&&s.length<c;){let e=Math.min(250,r-s.length),t=await a(`${trimTrailingSlash(n)}/-/v1/search?text=${encodeURIComponent(o)}&size=${e}&from=${s.length}`,{signal:i});if(!t.ok)throw new RegistrySearchError(`npm registry search failed: ${t.status} ${t.statusText}`,t.status);let l=await t.json(),u=l?.objects??[];if(c=typeof l?.total==`number`?l.total:s.length+u.length,u.length===0)return{packages:s,truncated:!1};for(let e of u)e?.package&&s.push(e.package)}return{packages:s,truncated:c>s.length}}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}var mr,hr,RegistrySearchError,gr=__esmMin((()=>{mr=`https://registry.npmjs.org`,hr=1e3,RegistrySearchError=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`RegistrySearchError`}}}));async function searchByKeywords$1(e,t,n){let{packages:r}=await fetchPackagesByKeywords(e,n);return pickPackagesWithKeywords(r,e,t)}var _r=__esmMin((()=>{pr(),gr(),__name(searchByKeywords$1,`searchByKeywords`)})),vr=__exportAll({DEFAULT_MAX_RESULTS:()=>hr,DEFAULT_REGISTRY:()=>mr,MAX_PAGE_SIZE:()=>250,RegistrySearchError:()=>RegistrySearchError,fetchPackagesByKeywords:()=>fetchPackagesByKeywords,hasAllKeywords:()=>hasAllKeywords,pickPackagesWithKeywords:()=>pickPackagesWithKeywords,searchByKeywords:()=>searchByKeywords$1}),yr=__esmMin((()=>{fr(),pr(),gr(),_r()}));const findByKeywords=async(...e)=>(await Promise.resolve().then(()=>(dr(),or))).findByKeywords(...e),searchByKeywords=async(...e)=>(await Promise.resolve().then(()=>(yr(),vr))).searchByKeywords(...e),br=command({name:`list`,alias:[`ls`],description:`List installed plugins`,options:{format:Rn},context:{findByKeywords},async run(e){let t=await this.context.findByKeywords(this.keywords,this);return reportPlugins(this.ui,e.format,t,this.keywords),t}});function reportPlugins(e,t,n,r){if(t===`json`){e.info(JSON.stringify({plugins:n},void 0,2));return}if(t===`text`){reportProse(e,{noun:`plugin`,plural:`plugins`},n,e=>e,r);return}if(n.length===0){e.info(`plugins: 0 installed plugins found with keywords: ${r.join(`, `)}`),e.info(toonHelp("Run `plugins search` to find plugins to install"));return}e.info(toonArray(`plugins`,n)),e.info(toonHelp("Run `plugins search` to find more plugins on npm"))}const xr=command({name:`search`,description:`Search only for available plugins`,options:{format:Rn,fields:{type:J(q()),description:`Extra fields to report, comma separated. Only 'keywords' is available`}},context:{searchByKeywords},async run(e){let t=parseFields(e.fields);if(!t){this.ui.info(`error: unknown value for --fields: ${e.fields}`),this.ui.info(toonHelp("The only extra field is `keywords`. Run `plugins search --fields keywords`"));return}let n=await Promise.all(this.keywords.map(e=>this.context.searchByKeywords([e]))),r=new Map;n.forEach((e,t)=>{e.forEach(e=>{let n=r.get(e);n?n.push(this.keywords[t]):r.set(e,[this.keywords[t]])})}),reportPackages(this.ui,e.format,t,[...r].map(toPackage),this.keywords)}});function toPackage([e,t]){return{name:e,keywords:t}}function parseFields(e){if(e===void 0)return{keywords:!1};let t=e.split(`,`).map(e=>e.trim());if(!t.some(e=>e!==`keywords`&&e!==`name`))return{keywords:t.includes(`keywords`)}}function reportPackages(e,t,n,r,i){if(t===`json`){let t=n.keywords?r:r.map(e=>e.name);e.info(JSON.stringify({packages:t},void 0,2));return}if(t===`text`){let describe=e=>n.keywords?`${e.name} (${e.keywords.join(`, `)})`:e.name;reportProse(e,{noun:`package`,plural:`packages`},r,describe,i);return}if(r.length===0){e.info(`packages: 0 packages found with keywords: ${i.join(`, `)}`);return}n.keywords?toonTable(`packages`,[`name`,`keywords`],r.map(e=>[e.name,e.keywords.join(` `)])).forEach(t=>{e.info(t)}):e.info(toonArray(`packages`,r.map(e=>e.name))),e.info(toonHelp("Run `plugins list` to see which of them are installed"))}const Sr=command({name:`plugins`,description:`Commands related to the plugins of the cli`,commands:[br,xr]});function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Cr={},wr={},Tr={},Er;function requireCommon(){if(Er)return Tr;Er=1;function isNothing(e){return e==null}function isObject(e){return typeof e==`object`&&!!e}function toArray(e){return Array.isArray(e)?e:isNothing(e)?[]:[e]}function extend(e,t){if(t){let n=Object.keys(t);for(let r=0,i=n.length;r<i;r+=1){let i=n[r];e[i]=t[i]}}return e}function repeat(e,t){let n=``;for(let r=0;r<t;r+=1)n+=e;return n}function isNegativeZero(e){return e===0&&1/e==-1/0}return Tr.isNothing=isNothing,Tr.isObject=isObject,Tr.toArray=toArray,Tr.repeat=repeat,Tr.isNegativeZero=isNegativeZero,Tr.extend=extend,Tr}var Dr,Or;function requireException(){if(Or)return Dr;Or=1;function formatError(e,t){let n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
|
|
28
|
-
|
|
29
|
-
`+e.mark.snippet),r+` `+n):r}function YAMLException2(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=formatError(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}return YAMLException2.prototype=Object.create(Error.prototype),YAMLException2.prototype.constructor=YAMLException2,YAMLException2.prototype.toString=function toString(e){return this.name+`: `+formatError(this,e)},Dr=YAMLException2,Dr}var kr,Ar;function requireSnippet(){if(Ar)return kr;Ar=1;let e=requireCommon();function getLine(e,t,n,r,i){let a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function padStart(t,n){return e.repeat(` `,n-t.length)+t}function makeSnippet(t,n){if(n=Object.create(n||null),!t.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!=`number`&&(n.indent=1),typeof n.linesBefore!=`number`&&(n.linesBefore=3),typeof n.linesAfter!=`number`&&(n.linesAfter=2);let r=/\r?\n|\r|\0/g,i=[0],a=[],o,s=-1;for(;o=r.exec(t.buffer);)a.push(o.index),i.push(o.index+o[0].length),t.position<=o.index&&s<0&&(s=i.length-2);s<0&&(s=i.length-1);let c=``,l=Math.min(t.line+n.linesAfter,a.length).toString().length,u=n.maxLength-(n.indent+l+3);for(let r=1;r<=n.linesBefore&&!(s-r<0);r++){let o=getLine(t.buffer,i[s-r],a[s-r],t.position-(i[s]-i[s-r]),u);c=e.repeat(` `,n.indent)+padStart((t.line-r+1).toString(),l)+` | `+o.str+`
|
|
30
|
-
`+c}let d=getLine(t.buffer,i[s],a[s],t.position,u);c+=e.repeat(` `,n.indent)+padStart((t.line+1).toString(),l)+` | `+d.str+`
|
|
31
|
-
`,c+=e.repeat(`-`,n.indent+l+3+d.pos)+`^
|
|
32
|
-
`;for(let r=1;r<=n.linesAfter&&!(s+r>=a.length);r++){let o=getLine(t.buffer,i[s+r],a[s+r],t.position-(i[s]-i[s+r]),u);c+=e.repeat(` `,n.indent)+padStart((t.line+r+1).toString(),l)+` | `+o.str+`
|
|
33
|
-
`}return c.replace(/\n$/,``)}return kr=makeSnippet,kr}var jr,Mr;function requireType(){if(Mr)return jr;Mr=1;let e=requireException(),t=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],n=[`scalar`,`sequence`,`mapping`];function compileStyleAliases(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function Type2(r,i){if(i||={},Object.keys(i).forEach(function(n){if(t.indexOf(n)===-1)throw new e(`Unknown option "`+n+`" is met in definition of "`+r+`" YAML type.`)}),this.options=i,this.tag=r,this.kind=i.kind||null,this.resolve=i.resolve||function(){return!0},this.construct=i.construct||function(e){return e},this.instanceOf=i.instanceOf||null,this.predicate=i.predicate||null,this.represent=i.represent||null,this.representName=i.representName||null,this.defaultStyle=i.defaultStyle||null,this.multi=i.multi||!1,this.styleAliases=compileStyleAliases(i.styleAliases||null),n.indexOf(this.kind)===-1)throw new e(`Unknown kind "`+this.kind+`" is specified for "`+r+`" YAML type.`)}return jr=Type2,jr}var Nr,Pr;function requireSchema(){if(Pr)return Nr;Pr=1;let e=requireException(),t=requireType();function compileList(e,t){let n=[];return e[t].forEach(function(e){let t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function compileMap(){let e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function collectType(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(collectType);return e}function Schema2(e){return this.extend(e)}return Schema2.prototype.extend=function extend(n){let r=[],i=[];if(n instanceof t)i.push(n);else if(Array.isArray(n))i=i.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(r=r.concat(n.implicit)),n.explicit&&(i=i.concat(n.explicit));else throw new e(`Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })`);r.forEach(function(n){if(!(n instanceof t))throw new e(`Specified list of YAML types (or a single Type object) contains a non-Type object.`);if(n.loadKind&&n.loadKind!==`scalar`)throw new e(`There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.`);if(n.multi)throw new e(`There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.`)}),i.forEach(function(n){if(!(n instanceof t))throw new e(`Specified list of YAML types (or a single Type object) contains a non-Type object.`)});let a=Object.create(Schema2.prototype);return a.implicit=(this.implicit||[]).concat(r),a.explicit=(this.explicit||[]).concat(i),a.compiledImplicit=compileList(a,`implicit`),a.compiledExplicit=compileList(a,`explicit`),a.compiledTypeMap=compileMap(a.compiledImplicit,a.compiledExplicit),a},Nr=Schema2,Nr}var Fr,Ir;function requireStr(){return Ir?Fr:(Ir=1,Fr=new(requireType())(`tag:yaml.org,2002:str`,{kind:`scalar`,construct:function(e){return e===null?``:e}}),Fr)}var Lr,Rr;function requireSeq(){return Rr?Lr:(Rr=1,Lr=new(requireType())(`tag:yaml.org,2002:seq`,{kind:`sequence`,construct:function(e){return e===null?[]:e}}),Lr)}var zr,Br;function requireMap(){return Br?zr:(Br=1,zr=new(requireType())(`tag:yaml.org,2002:map`,{kind:`mapping`,construct:function(e){return e===null?{}:e}}),zr)}var Vr,Hr;function requireFailsafe(){return Hr?Vr:(Hr=1,Vr=new(requireSchema())({explicit:[requireStr(),requireSeq(),requireMap()]}),Vr)}var Ur,Wr;function require_null$1(){if(Wr)return Ur;Wr=1;let e=requireType();function resolveYamlNull(e){if(e===null)return!0;let t=e.length;return t===1&&e===`~`||t===4&&(e===`null`||e===`Null`||e===`NULL`)}function constructYamlNull(){return null}function isNull(e){return e===null}return Ur=new e(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:resolveYamlNull,construct:constructYamlNull,predicate:isNull,represent:{canonical:function(){return`~`},lowercase:function(){return`null`},uppercase:function(){return`NULL`},camelcase:function(){return`Null`},empty:function(){return``}},defaultStyle:`lowercase`}),Ur}__name(require_null$1,`require_null`);var Gr,Kr;function requireBool(){if(Kr)return Gr;Kr=1;let e=requireType();function resolveYamlBoolean(e){if(e===null)return!1;let t=e.length;return t===4&&(e===`true`||e===`True`||e===`TRUE`)||t===5&&(e===`false`||e===`False`||e===`FALSE`)}function constructYamlBoolean(e){return e===`true`||e===`True`||e===`TRUE`}function isBoolean(e){return Object.prototype.toString.call(e)===`[object Boolean]`}return Gr=new e(`tag:yaml.org,2002:bool`,{kind:`scalar`,resolve:resolveYamlBoolean,construct:constructYamlBoolean,predicate:isBoolean,represent:{lowercase:function(e){return e?`true`:`false`},uppercase:function(e){return e?`TRUE`:`FALSE`},camelcase:function(e){return e?`True`:`False`}},defaultStyle:`lowercase`}),Gr}var qr,Jr;function requireInt(){if(Jr)return qr;Jr=1;let e=requireCommon(),t=requireType();function isHexCode(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function isOctCode(e){return e>=48&&e<=55}function isDecCode(e){return e>=48&&e<=57}function resolveYamlInteger(e){if(e===null)return!1;let t=e.length,n=0,r=!1;if(!t)return!1;let i=e[n];if((i===`-`||i===`+`)&&(i=e[++n]),i===`0`){if(n+1===t)return!0;if(i=e[++n],i===`b`){for(n++;n<t;n++){if(i=e[n],i!==`0`&&i!==`1`)return!1;r=!0}return r&&isFinite(parseYamlInteger(e))}if(i===`x`){for(n++;n<t;n++){if(!isHexCode(e.charCodeAt(n)))return!1;r=!0}return r&&isFinite(parseYamlInteger(e))}if(i===`o`){for(n++;n<t;n++){if(!isOctCode(e.charCodeAt(n)))return!1;r=!0}return r&&isFinite(parseYamlInteger(e))}}for(;n<t;n++){if(!isDecCode(e.charCodeAt(n)))return!1;r=!0}return r?isFinite(parseYamlInteger(e)):!1}function parseYamlInteger(e){let t=e,n=1,r=t[0];if((r===`-`||r===`+`)&&(r===`-`&&(n=-1),t=t.slice(1),r=t[0]),t===`0`)return 0;if(r===`0`){if(t[1]===`b`)return n*parseInt(t.slice(2),2);if(t[1]===`x`)return n*parseInt(t.slice(2),16);if(t[1]===`o`)return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function constructYamlInteger(e){return parseYamlInteger(e)}function isInteger(t){return Object.prototype.toString.call(t)===`[object Number]`&&t%1==0&&!e.isNegativeZero(t)}return qr=new t(`tag:yaml.org,2002:int`,{kind:`scalar`,resolve:resolveYamlInteger,construct:constructYamlInteger,predicate:isInteger,represent:{binary:function(e){return e>=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}}),qr}var Yr,Xr;function requireFloat(){if(Xr)return Yr;Xr=1;let e=requireCommon(),t=requireType(),n=RegExp(`^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),r=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function resolveYamlFloat(e){return e===null||!n.test(e)?!1:isFinite(parseFloat(e,10))?!0:r.test(e)}function constructYamlFloat(e){let t=e.toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}let i=/^[-+]?[0-9]+e/;function representYamlFloat(t,n){if(isNaN(t))switch(n){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(t===1/0)switch(n){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(t===-1/0)switch(n){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(e.isNegativeZero(t))return`-0.0`;let r=t.toString(10);return i.test(r)?r.replace(`e`,`.e`):r}function isFloat(t){return Object.prototype.toString.call(t)===`[object Number]`&&(t%1!=0||e.isNegativeZero(t))}return Yr=new t(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:resolveYamlFloat,construct:constructYamlFloat,predicate:isFloat,represent:representYamlFloat,defaultStyle:`lowercase`}),Yr}var Zr,Qr;function requireJson(){return Qr?Zr:(Qr=1,Zr=requireFailsafe().extend({implicit:[require_null$1(),requireBool(),requireInt(),requireFloat()]}),Zr)}var $r,ei;function requireCore(){return ei?$r:(ei=1,$r=requireJson(),$r)}var ti,ni;function requireTimestamp(){if(ni)return ti;ni=1;let e=requireType(),t=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),n=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function resolveYamlTimestamp(e){return e===null?!1:t.exec(e)!==null||n.exec(e)!==null}function constructYamlTimestamp(e){let r=0,i=null,a=t.exec(e);if(a===null&&(a=n.exec(e)),a===null)throw Error(`Date resolve error`);let o=+a[1],s=a[2]-1,c=+a[3];if(!a[4])return new Date(Date.UTC(o,s,c));let l=+a[4],u=+a[5],d=+a[6];if(a[7]){for(r=a[7].slice(0,3);r.length<3;)r+=`0`;r=+r}if(a[9]){let e=+a[10],t=+(a[11]||0);i=(e*60+t)*6e4,a[9]===`-`&&(i=-i)}let p=new Date(Date.UTC(o,s,c,l,u,d,r));return i&&p.setTime(p.getTime()-i),p}function representYamlTimestamp(e){return e.toISOString()}return ti=new e(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:resolveYamlTimestamp,construct:constructYamlTimestamp,instanceOf:Date,represent:representYamlTimestamp}),ti}var ri,ii;function requireMerge(){if(ii)return ri;ii=1;let e=requireType();function resolveYamlMerge(e){return e===`<<`||e===null}return ri=new e(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:resolveYamlMerge}),ri}var ai,oi;function requireBinary(){if(oi)return ai;oi=1;let e=requireType();function resolveYamlBinary(e){if(e===null)return!1;let t=0,n=e.length;for(let r=0;r<n;r++){let n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
34
|
-
\r`.indexOf(e.charAt(r));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0}function constructYamlBinary(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,r=0,i=[];for(let e=0;e<n;e++)e%4==0&&e&&(i.push(r>>16&255),i.push(r>>8&255),i.push(r&255)),r=r<<6|`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
35
|
-
\r`.indexOf(t.charAt(e));let a=n%4*6;return a===0?(i.push(r>>16&255),i.push(r>>8&255),i.push(r&255)):a===18?(i.push(r>>10&255),i.push(r>>2&255)):a===12&&i.push(r>>4&255),new Uint8Array(i)}function representYamlBinary(e){let t=``,n=0,r=e.length,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
36
|
-
\r`;for(let a=0;a<r;a++)a%3==0&&a&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[a];let a=r%3;return a===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):a===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):a===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function isBinary(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}return ai=new e(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:resolveYamlBinary,construct:constructYamlBinary,predicate:isBinary,represent:representYamlBinary}),ai}var si,ci;function requireOmap(){if(ci)return si;ci=1;let e=requireType(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function resolveYamlOmap(e){if(e===null)return!0;let r={},i=e;for(let e=0,a=i.length;e<a;e+=1){let a=i[e],o=!1;if(n.call(a)!==`[object Object]`)return!1;let s;for(s in a)if(t.call(a,s)){if(!o)o=!0;else return!1}if(!o||t.call(r,s))return!1;Object.defineProperty(r,s,{value:!0})}return!0}function constructYamlOmap(e){return e===null?[]:e}return si=new e(`tag:yaml.org,2002:omap`,{kind:`sequence`,resolve:resolveYamlOmap,construct:constructYamlOmap}),si}var li,ui;function requirePairs(){if(ui)return li;ui=1;let e=requireType(),t=Object.prototype.toString;function resolveYamlPairs(e){if(e===null)return!0;let n=e,r=Array(n.length);for(let e=0,i=n.length;e<i;e+=1){let i=n[e];if(t.call(i)!==`[object Object]`)return!1;let a=Object.keys(i);if(a.length!==1)return!1;r[e]=[a[0],i[a[0]]]}return!0}function constructYamlPairs(e){if(e===null)return[];let t=e,n=Array(t.length);for(let e=0,r=t.length;e<r;e+=1){let r=t[e],i=Object.keys(r);n[e]=[i[0],r[i[0]]]}return n}return li=new e(`tag:yaml.org,2002:pairs`,{kind:`sequence`,resolve:resolveYamlPairs,construct:constructYamlPairs}),li}var di,fi;function requireSet(){if(fi)return di;fi=1;let e=requireType(),t=Object.prototype.hasOwnProperty;function resolveYamlSet(e){if(e===null)return!0;let n=e;for(let e in n)if(t.call(n,e)&&n[e]!==null)return!1;return!0}function constructYamlSet(e){return e===null?{}:e}return di=new e(`tag:yaml.org,2002:set`,{kind:`mapping`,resolve:resolveYamlSet,construct:constructYamlSet}),di}var pi,mi;function require_default(){return mi?pi:(mi=1,pi=requireCore().extend({implicit:[requireTimestamp(),requireMerge()],explicit:[requireBinary(),requireOmap(),requirePairs(),requireSet()]}),pi)}var hi;function requireLoader(){if(hi)return wr;hi=1;let e=requireCommon(),t=requireException(),n=requireSnippet(),r=require_default(),i=Object.prototype.hasOwnProperty,a=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o=/[\x85\u2028\u2029]/,s=/[,\[\]{}]/,c=/^(?:!|!!|![0-9A-Za-z-]+!)$/,l=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function _class(e){return Object.prototype.toString.call(e)}function isEol(e){return e===10||e===13}function isWhiteSpace(e){return e===9||e===32}function isWsOrEol(e){return e===9||e===32||e===10||e===13}function isFlowIndicator(e){return e===44||e===91||e===93||e===123||e===125}function fromHexCode(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function escapedHexLen(e){return e===120?2:e===117?4:e===85?8:0}function fromDecimalCode(e){return e>=48&&e<=57?e-48:-1}function simpleEscapeSequence(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return`
|
|
37
|
-
`;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return`
`;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function charFromCodepoint(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function setProperty(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}let u=Array(256),d=Array(256);for(let e=0;e<256;e++)u[e]=+!!simpleEscapeSequence(e),d[e]=simpleEscapeSequence(e);function State(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||r,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxTotalMergeKeys=typeof t.maxTotalMergeKeys==`number`?t.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function generateError(e,r){let i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=n(i),new t(r,i)}function throwError(e,t){throw generateError(e,t)}function throwWarning(e,t){e.onWarning&&e.onWarning.call(null,generateError(e,t))}function storeAnchor(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];i.call(n,t)||(n[t]={existed:i.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function beginAnchorTransaction(e){e.anchorMapTransactions.push(Object.create(null))}function commitAnchorTransaction(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],a=Object.keys(t);for(let e=0,n=a.length;e<n;e+=1){let n=a[e];i.call(r,n)||(r[n]=t[n])}}function rollbackAnchorTransaction(e){let t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let r=n.length-1;r>=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function snapshotState(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function restoreState(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}let p={YAML:function handleYamlDirective(e,t,n){e.version!==null&&throwError(e,`duplication of %YAML directive`),n.length!==1&&throwError(e,`YAML directive accepts exactly one argument`);let r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&throwError(e,`ill-formed argument of the YAML directive`);let i=parseInt(r[1],10),a=parseInt(r[2],10);i!==1&&throwError(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&throwWarning(e,`unsupported YAML version of the document`)},TAG:function handleTagDirective(e,t,n){let r;n.length!==2&&throwError(e,`TAG directive accepts exactly two arguments`);let a=n[0];r=n[1],c.test(a)||throwError(e,`ill-formed tag handle (first argument) of the TAG directive`),i.call(e.tagMap,a)&&throwError(e,`there is a previously declared suffix for "`+a+`" tag handle`),l.test(r)||throwError(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{r=decodeURIComponent(r)}catch{throwError(e,`tag prefix is malformed: `+r)}e.tagMap[a]=r}};function captureSegment(e,t,n,r){if(t<n){let i=e.input.slice(t,n);if(r)for(let t=0,n=i.length;t<n;t+=1){let n=i.charCodeAt(t);n===9||n>=32&&n<=1114111||throwError(e,`expected valid JSON character`)}else a.test(i)&&throwError(e,`the stream contains non-printable characters`);e.result+=i}}function chargeMergeWork(e){e.totalMergeKeys++,e.maxTotalMergeKeys!==-1&&e.totalMergeKeys>e.maxTotalMergeKeys&&throwError(e,`merge keys exceeded maxTotalMergeKeys (`+e.maxTotalMergeKeys+`)`)}function mergeMappings(t,n,r,a){e.isObject(r)||throwError(t,`cannot merge mappings; the provided source object is unacceptable`),chargeMergeWork(t);let o=Object.keys(r);for(let e=0,s=o.length;e<s;e+=1){let s=o[e];chargeMergeWork(t),i.call(n,s)||(setProperty(n,s,r[s]),a[s]=!0)}}function storeMappingPair(e,t,n,r,a,o,s,c,l){if(Array.isArray(a)){a=Array.prototype.slice.call(a);for(let t=0,n=a.length;t<n;t+=1)Array.isArray(a[t])&&throwError(e,`nested arrays are not supported inside keys`),typeof a==`object`&&_class(a[t])===`[object Object]`&&(a[t]=`[object Object]`)}if(typeof a==`object`&&_class(a)===`[object Object]`&&(a=`[object Object]`),a=String(a),t===null&&(t={}),r===`tag:yaml.org,2002:merge`){if(Array.isArray(o)){o.length>100&&throwError(e,`abnormal merge sequence size`);for(let r=0,i=o.length;r<i;r+=1)mergeMappings(e,t,o[r],n)}else mergeMappings(e,t,o,n)}else!e.json&&!i.call(n,a)&&i.call(t,a)&&(e.line=s||e.line,e.lineStart=c||e.lineStart,e.position=l||e.position,throwError(e,`duplicated mapping key`)),setProperty(t,a,o),delete n[a];return t}function readLineBreak(e){let t=e.input.charCodeAt(e.position);t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):throwError(e,`a line break is expected`),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function skipSeparationSpace(e,t,n){let r=0,i=e.input.charCodeAt(e.position);for(;i!==0;){for(;isWhiteSpace(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(isEol(i))for(readLineBreak(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&throwWarning(e,`deficient indentation`),r}function testDocumentSeparator(e){let t=e.position,n=e.input.charCodeAt(t);return!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||isWsOrEol(n)))}function writeFoldedLines(t,n){n===1?t.result+=` `:n>1&&(t.result+=e.repeat(`
|
|
38
|
-
`,n-1))}function readPlainScalar(e,t,n){let r,i,a,o,s,c,l=e.kind,u=e.result,d=e.input.charCodeAt(e.position);if(isWsOrEol(d)||isFlowIndicator(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96)return!1;if(d===63||d===45){let t=e.input.charCodeAt(e.position+1);if(isWsOrEol(t)||n&&isFlowIndicator(t))return!1}for(e.kind=`scalar`,e.result=``,r=i=e.position,a=!1;d!==0;){if(d===58){let t=e.input.charCodeAt(e.position+1);if(isWsOrEol(t)||n&&isFlowIndicator(t))break}else if(d===35){if(isWsOrEol(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&testDocumentSeparator(e)||n&&isFlowIndicator(d))break;else if(isEol(d)){if(o=e.line,s=e.lineStart,c=e.lineIndent,skipSeparationSpace(e,!1,-1),e.lineIndent>=t){a=!0,d=e.input.charCodeAt(e.position);continue}e.position=i,e.line=o,e.lineStart=s,e.lineIndent=c;break}a&&=(captureSegment(e,r,i,!1),writeFoldedLines(e,e.line-o),r=i=e.position,!1),isWhiteSpace(d)||(i=e.position+1),d=e.input.charCodeAt(++e.position)}return captureSegment(e,r,i,!1),e.result?!0:(e.kind=l,e.result=u,!1)}function readSingleQuotedScalar(e,t){let n,r,i=e.input.charCodeAt(e.position);if(i!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39){if(captureSegment(e,n,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)n=e.position,e.position++,r=e.position;else return!0}else isEol(i)?(captureSegment(e,n,r,!0),writeFoldedLines(e,skipSeparationSpace(e,!1,t)),n=r=e.position):e.position===e.lineStart&&testDocumentSeparator(e)?throwError(e,`unexpected end of the document within a single quoted scalar`):(e.position++,isWhiteSpace(i)||(r=e.position));throwError(e,`unexpected end of the stream within a single quoted scalar`)}function readDoubleQuotedScalar(e,t){let n,r,i,a=e.input.charCodeAt(e.position);if(a!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===34)return captureSegment(e,n,e.position,!0),e.position++,!0;else if(a===92){if(captureSegment(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),isEol(a))skipSeparationSpace(e,!1,t);else if(a<256&&u[a])e.result+=d[a],e.position++;else if((i=escapedHexLen(a))>0){let t=i,n=0;for(;t>0;t--)a=e.input.charCodeAt(++e.position),(i=fromHexCode(a))>=0?n=(n<<4)+i:throwError(e,`expected hexadecimal character`);e.result+=charFromCodepoint(n),e.position++}else throwError(e,`unknown escape sequence`);n=r=e.position}else isEol(a)?(captureSegment(e,n,r,!0),writeFoldedLines(e,skipSeparationSpace(e,!1,t)),n=r=e.position):e.position===e.lineStart&&testDocumentSeparator(e)?throwError(e,`unexpected end of the document within a double quoted scalar`):(e.position++,isWhiteSpace(a)||(r=e.position));throwError(e,`unexpected end of the stream within a double quoted scalar`)}function readFlowCollection(e,t){let n=!0,r,i,a,o=e.tag,s,c=e.anchor,l,u,d,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)l=93,p=!1,s=[];else if(v===123)l=125,p=!0,s={};else return!1;for(e.anchor!==null&&storeAnchor(e,e.anchor,s),v=e.input.charCodeAt(++e.position);v!==0;){if(skipSeparationSpace(e,!0,t),v=e.input.charCodeAt(e.position),v===l)return e.position++,e.tag=o,e.anchor=c,e.kind=p?`mapping`:`sequence`,e.result=s,!0;n?v===44&&throwError(e,`expected the node content, but found ','`):throwError(e,`missed comma between flow collection entries`),g=h=_=null,u=d=!1,v===63&&isWsOrEol(e.input.charCodeAt(e.position+1))&&(u=d=!0,e.position++,skipSeparationSpace(e,!0,t)),r=e.line,i=e.lineStart,a=e.position,composeNode(e,t,1,!1,!0),g=e.tag,h=e.result,skipSeparationSpace(e,!0,t),v=e.input.charCodeAt(e.position),(d||e.line===r)&&v===58&&(u=!0,v=e.input.charCodeAt(++e.position),skipSeparationSpace(e,!0,t),composeNode(e,t,1,!1,!0),_=e.result),p?storeMappingPair(e,s,m,g,h,_,r,i,a):u?s.push(storeMappingPair(e,null,m,g,h,_,r,i,a)):s.push(h),skipSeparationSpace(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}throwError(e,`unexpected end of the stream within a flow collection`)}function readBlockScalar(t,n){let r,i=1,a=!1,o=!1,s=n,c=0,l=!1,u,d=t.input.charCodeAt(t.position);if(d===124)r=!1;else if(d===62)r=!0;else return!1;for(t.kind=`scalar`,t.result=``;d!==0;)if(d=t.input.charCodeAt(++t.position),d===43||d===45)i===1?i=d===43?3:2:throwError(t,`repeat of a chomping mode identifier`);else if((u=fromDecimalCode(d))>=0)u===0?throwError(t,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?throwError(t,`repeat of an indentation width identifier`):(s=n+u-1,o=!0);else break;if(isWhiteSpace(d)){do d=t.input.charCodeAt(++t.position);while(isWhiteSpace(d));if(d===35)do d=t.input.charCodeAt(++t.position);while(!isEol(d)&&d!==0)}for(;d!==0;){for(readLineBreak(t),t.lineIndent=0,d=t.input.charCodeAt(t.position);(!o||t.lineIndent<s)&&d===32;)t.lineIndent++,d=t.input.charCodeAt(++t.position);if(!o&&t.lineIndent>s&&(s=t.lineIndent),isEol(d)){c++;continue}if(!o&&s===0&&throwError(t,`missing indentation for block scalar`),t.lineIndent<s){i===3?t.result+=e.repeat(`
|
|
39
|
-
`,a?1+c:c):i===1&&a&&(t.result+=`
|
|
40
|
-
`);break}r?isWhiteSpace(d)?(l=!0,t.result+=e.repeat(`
|
|
41
|
-
`,a?1+c:c)):l?(l=!1,t.result+=e.repeat(`
|
|
42
|
-
`,c+1)):c===0?a&&(t.result+=` `):t.result+=e.repeat(`
|
|
43
|
-
`,c):t.result+=e.repeat(`
|
|
44
|
-
`,a?1+c:c),a=!0,o=!0,c=0;let n=t.position;for(;!isEol(d)&&d!==0;)d=t.input.charCodeAt(++t.position);captureSegment(t,n,t.position,!1)}return!0}function readBlockSequence(e,t){let n=e.tag,r=e.anchor,i=[],a=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&storeAnchor(e,e.anchor,i);let o=e.input.charCodeAt(e.position);for(;o!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,throwError(e,`tab characters must not be used in indentation`)),o===45&&isWsOrEol(e.input.charCodeAt(e.position+1)));){if(a=!0,e.position++,skipSeparationSpace(e,!0,-1)&&e.lineIndent<=t){i.push(null),o=e.input.charCodeAt(e.position);continue}let n=e.line;if(composeNode(e,t,3,!1,!0),i.push(e.result),skipSeparationSpace(e,!0,-1),o=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&o!==0)throwError(e,`bad indentation of a sequence entry`);else if(e.lineIndent<t)break}return a?(e.tag=n,e.anchor=r,e.kind=`sequence`,e.result=i,!0):!1}function readBlockMapping(e,t,n){let r,i,a,o,s=e.tag,c=e.anchor,l={},u=Object.create(null),d=null,p=null,m=null,h=!1,g=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&storeAnchor(e,e.anchor,l);let _=e.input.charCodeAt(e.position);for(;_!==0;){!h&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,throwError(e,`tab characters must not be used in indentation`));let v=e.input.charCodeAt(e.position+1),y=e.line;if((_===63||_===58)&&isWsOrEol(v))_===63?(h&&(storeMappingPair(e,l,u,d,p,null,i,a,o),d=p=m=null),g=!0,h=!0,r=!0):h?(h=!1,r=!0):throwError(e,`incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line`),e.position+=1,_=v;else{if(i=e.line,a=e.lineStart,o=e.position,!composeNode(e,n,2,!1,!0))break;if(e.line===y){for(_=e.input.charCodeAt(e.position);isWhiteSpace(_);)_=e.input.charCodeAt(++e.position);if(_===58)_=e.input.charCodeAt(++e.position),isWsOrEol(_)||throwError(e,`a whitespace character is expected after the key-value separator within a block mapping`),h&&(storeMappingPair(e,l,u,d,p,null,i,a,o),d=p=m=null),g=!0,h=!1,r=!1,d=e.tag,p=e.result;else if(g)throwError(e,`can not read an implicit mapping pair; a colon is missed`);else return e.tag=s,e.anchor=c,!0}else if(g)throwError(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return e.tag=s,e.anchor=c,!0}if((e.line===y||e.lineIndent>t)&&(h&&(i=e.line,a=e.lineStart,o=e.position),composeNode(e,t,4,!0,r)&&(h?p=e.result:m=e.result),h||(storeMappingPair(e,l,u,d,p,m,i,a,o),d=p=m=null),skipSeparationSpace(e,!0,-1),_=e.input.charCodeAt(e.position)),(e.line===y||e.lineIndent>t)&&_!==0)throwError(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return h&&storeMappingPair(e,l,u,d,p,null,i,a,o),g&&(e.tag=s,e.anchor=c,e.kind=`mapping`,e.result=l),g}function readTagProperty(e){let t=!1,n=!1,r,a,o=e.input.charCodeAt(e.position);if(o!==33)return!1;e.tag!==null&&throwError(e,`duplication of a tag property`),o=e.input.charCodeAt(++e.position),o===60?(t=!0,o=e.input.charCodeAt(++e.position)):o===33?(n=!0,r=`!!`,o=e.input.charCodeAt(++e.position)):r=`!`;let u=e.position;if(t){do o=e.input.charCodeAt(++e.position);while(o!==0&&o!==62);e.position<e.length?(a=e.input.slice(u,e.position),o=e.input.charCodeAt(++e.position)):throwError(e,`unexpected end of the stream within a verbatim tag`)}else{for(;o!==0&&!isWsOrEol(o);)o===33&&(n?throwError(e,`tag suffix cannot contain exclamation marks`):(r=e.input.slice(u-1,e.position+1),c.test(r)||throwError(e,`named tag handle cannot contain such characters`),n=!0,u=e.position+1)),o=e.input.charCodeAt(++e.position);a=e.input.slice(u,e.position),s.test(a)&&throwError(e,`tag suffix cannot contain flow indicator characters`)}a&&!l.test(a)&&throwError(e,`tag name cannot contain such characters: `+a);try{a=decodeURIComponent(a)}catch{throwError(e,`tag name is malformed: `+a)}return t?e.tag=a:i.call(e.tagMap,r)?e.tag=e.tagMap[r]+a:r===`!`?e.tag=`!`+a:r===`!!`?e.tag=`tag:yaml.org,2002:`+a:throwError(e,`undeclared tag handle "`+r+`"`),!0}function readAnchorProperty(e){let t=e.input.charCodeAt(e.position);if(t!==38)return!1;e.anchor!==null&&throwError(e,`duplication of an anchor property`),t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!isWsOrEol(t)&&!isFlowIndicator(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&throwError(e,`name of an anchor node must contain at least one character`),e.anchor=e.input.slice(n,e.position),!0}function readAlias(e){let t=e.input.charCodeAt(e.position);if(t!==42)return!1;t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!isWsOrEol(t)&&!isFlowIndicator(t);)t=e.input.charCodeAt(++e.position);e.position===n&&throwError(e,`name of an alias node must contain at least one character`);let r=e.input.slice(n,e.position);return i.call(e.anchorMap,r)||throwError(e,`unidentified alias "`+r+`"`),e.result=e.anchorMap[r],skipSeparationSpace(e,!0,-1),!0}function tryReadBlockMappingFromProperty(e,t,n,r){let i=snapshotState(e);return beginAnchorTransaction(e),restoreState(e,t),e.tag=null,e.anchor=null,e.kind=null,e.result=null,readBlockMapping(e,n,r)&&e.kind===`mapping`?(commitAnchorTransaction(e),!0):(rollbackAnchorTransaction(e),restoreState(e,i),!1)}function composeNode(e,t,n,r,a){let o,s,c=1,l=!1,u=!1,d=null,p,m,h;e.depth>=e.maxDepth&&throwError(e,`nesting exceeded maxDepth (`+e.maxDepth+`)`),e.depth+=1,e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let g=o=s=n===4||n===3;if(r&&skipSeparationSpace(e,!0,-1)&&(l=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;;){let n=e.input.charCodeAt(e.position),r=snapshotState(e);if(l&&(n===33&&e.tag!==null||n===38&&e.anchor!==null)||!readTagProperty(e)&&!readAnchorProperty(e))break;d===null&&(d=r),skipSeparationSpace(e,!0,-1)?(l=!0,s=g,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):s=!1}if(s&&=l||a,c===1||n===4){if(m=n===1||n===2?t:t+1,h=e.position-e.lineStart,c===1){if(s&&(readBlockSequence(e,h)||readBlockMapping(e,h,m))||readFlowCollection(e,m))u=!0;else{let t=e.input.charCodeAt(e.position);d!==null&&g&&!s&&t!==124&&t!==62&&tryReadBlockMappingFromProperty(e,d,d.position-d.lineStart,m)||o&&readBlockScalar(e,m)||readSingleQuotedScalar(e,m)||readDoubleQuotedScalar(e,m)?u=!0:readAlias(e)?(u=!0,(e.tag!==null||e.anchor!==null)&&throwError(e,`alias node should not have any properties`)):readPlainScalar(e,m,n===1)&&(u=!0,e.tag===null&&(e.tag=`?`)),e.anchor!==null&&storeAnchor(e,e.anchor,e.result)}}else c===0&&(u=s&&readBlockSequence(e,h))}if(e.tag===null)e.anchor!==null&&storeAnchor(e,e.anchor,e.result);else if(e.tag===`?`){e.result!==null&&e.kind!==`scalar`&&throwError(e,`unacceptable node kind for !<?> tag; it should be "scalar", not "`+e.kind+`"`);for(let t=0,n=e.implicitTypes.length;t<n;t+=1)if(p=e.implicitTypes[t],p.resolve(e.result)){e.result=p.construct(e.result),e.tag=p.tag,e.anchor!==null&&storeAnchor(e,e.anchor,e.result);break}}else if(e.tag!==`!`){if(i.call(e.typeMap[e.kind||`fallback`],e.tag))p=e.typeMap[e.kind||`fallback`][e.tag];else{p=null;let t=e.typeMap.multi[e.kind||`fallback`];for(let n=0,r=t.length;n<r;n+=1)if(e.tag.slice(0,t[n].tag.length)===t[n].tag){p=t[n];break}}p||throwError(e,`unknown tag !<`+e.tag+`>`),e.result!==null&&p.kind!==e.kind&&throwError(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+p.kind+`", not "`+e.kind+`"`),p.resolve(e.result,e.tag)?(e.result=p.construct(e.result,e.tag),e.anchor!==null&&storeAnchor(e,e.anchor,e.result)):throwError(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),--e.depth,e.tag!==null||e.anchor!==null||u}function readDocument(e){let t=e.position,n=!1,r;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(r=e.input.charCodeAt(e.position))!==0&&(skipSeparationSpace(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||r!==37));){n=!0,r=e.input.charCodeAt(++e.position);let t=e.position;for(;r!==0&&!isWsOrEol(r);)r=e.input.charCodeAt(++e.position);let a=e.input.slice(t,e.position),o=[];for(a.length<1&&throwError(e,`directive name must not be less than one character in length`);r!==0;){for(;isWhiteSpace(r);)r=e.input.charCodeAt(++e.position);if(r===35){do r=e.input.charCodeAt(++e.position);while(r!==0&&!isEol(r));break}if(isEol(r))break;for(t=e.position;r!==0&&!isWsOrEol(r);)r=e.input.charCodeAt(++e.position);o.push(e.input.slice(t,e.position))}r!==0&&readLineBreak(e),i.call(p,a)?p[a](e,a,o):throwWarning(e,`unknown document directive "`+a+`"`)}if(skipSeparationSpace(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,skipSeparationSpace(e,!0,-1)):n&&throwError(e,`directives end mark is expected`),composeNode(e,e.lineIndent-1,4,!1,!0),skipSeparationSpace(e,!0,-1),e.checkLineBreaks&&o.test(e.input.slice(t,e.position))&&throwWarning(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&testDocumentSeparator(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,skipSeparationSpace(e,!0,-1));return}e.position<e.length-1&&throwError(e,`end of the stream or a document separator is expected`)}function loadDocuments(e,t){e=String(e),t||={},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
45
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));let n=new State(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,throwError(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)readDocument(n);return n.documents}function loadAll2(e,t,n){typeof t==`object`&&t&&n===void 0&&(n=t,t=null);let r=loadDocuments(e,n);if(typeof t!=`function`)return r;for(let e=0,n=r.length;e<n;e+=1)t(r[e])}function load2(e,n){let r=loadDocuments(e,n);if(r.length!==0){if(r.length===1)return r[0];throw new t(`expected a single document in the stream, but found more`)}}return wr.loadAll=loadAll2,wr.load=load2,wr}var gi={},_i;function requireDumper(){if(_i)return gi;_i=1;let e=requireCommon(),t=requireException(),n=require_default(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,a=65279,o={};o[0]=`\\0`,o[7]=`\\a`,o[8]=`\\b`,o[9]=`\\t`,o[10]=`\\n`,o[11]=`\\v`,o[12]=`\\f`,o[13]=`\\r`,o[27]=`\\e`,o[34]=`\\"`,o[92]=`\\\\`,o[133]=`\\N`,o[160]=`\\_`,o[8232]=`\\L`,o[8233]=`\\P`;let s=[`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],c=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function compileStyleMap(e,t){if(t===null)return{};let n={},r=Object.keys(t);for(let a=0,o=r.length;a<o;a+=1){let o=r[a],s=String(t[o]);o.slice(0,2)===`!!`&&(o=`tag:yaml.org,2002:`+o.slice(2));let c=e.compiledTypeMap.fallback[o];c&&i.call(c.styleAliases,s)&&(s=c.styleAliases[s]),n[o]=s}return n}function encodeHex(n){let r,i,a=n.toString(16).toUpperCase();if(n<=255)r=`x`,i=2;else if(n<=65535)r=`u`,i=4;else if(n<=4294967295)r=`U`,i=8;else throw new t(`code point within a string may not be greater than 0xFFFFFFFF`);return`\\`+r+e.repeat(`0`,i-a.length)+a}function State(t){this.schema=t.schema||n,this.indent=Math.max(1,t.indent||2),this.noArrayIndent=t.noArrayIndent||!1,this.skipInvalid=t.skipInvalid||!1,this.flowLevel=e.isNothing(t.flowLevel)?-1:t.flowLevel,this.styleMap=compileStyleMap(this.schema,t.styles||null),this.sortKeys=t.sortKeys||!1,this.lineWidth=t.lineWidth||80,this.noRefs=t.noRefs||!1,this.noCompatMode=t.noCompatMode||!1,this.condenseFlow=t.condenseFlow||!1,this.quotingType=t.quotingType===`"`?2:1,this.forceQuotes=t.forceQuotes||!1,this.replacer=typeof t.replacer==`function`?t.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result=``,this.duplicates=[],this.usedDuplicates=null}function indentString(t,n){let r=e.repeat(` `,n),i=0,a=``,o=t.length;for(;i<o;){let e,n=t.indexOf(`
|
|
46
|
-
`,i);n===-1?(e=t.slice(i),i=o):(e=t.slice(i,n+1),i=n+1),e.length&&e!==`
|
|
47
|
-
`&&(a+=r),a+=e}return a}function generateNextLine(t,n){return`
|
|
48
|
-
`+e.repeat(` `,t.indent*n)}function testImplicitResolving(e,t){for(let n=0,r=e.implicitTypes.length;n<r;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}function isWhitespace(e){return e===32||e===9}function isPrintable(e){return e>=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==a||e>=65536&&e<=1114111}function isNsCharOrWhitespace(e){return isPrintable(e)&&e!==a&&e!==13&&e!==10}function isPlainSafe(e,t,n){let r=isNsCharOrWhitespace(e),i=r&&!isWhitespace(e);return(n?r:r&&e!==44&&e!==91&&e!==93&&e!==123&&e!==125)&&e!==35&&!(t===58&&!i)||isNsCharOrWhitespace(t)&&!isWhitespace(t)&&e===35||t===58&&i}function isPlainSafeFirst(e){return isPrintable(e)&&e!==a&&!isWhitespace(e)&&e!==45&&e!==63&&e!==58&&e!==44&&e!==91&&e!==93&&e!==123&&e!==125&&e!==35&&e!==38&&e!==42&&e!==33&&e!==124&&e!==61&&e!==62&&e!==39&&e!==34&&e!==37&&e!==64&&e!==96}function isPlainSafeLast(e){return!isWhitespace(e)&&e!==58}function codePointAt(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function needIndentIndicator(e){return/^\n* /.test(e)}function chooseScalarStyle(e,t,n,r,i,a,o,s){let c,l=0,u=null,d=!1,p=!1,m=r!==-1,h=-1,g=isPlainSafeFirst(codePointAt(e,0))&&isPlainSafeLast(codePointAt(e,e.length-1));if(t||o)for(c=0;c<e.length;l>=65536?c+=2:c++){if(l=codePointAt(e,c),!isPrintable(l))return 5;g&&=isPlainSafe(l,u,s),u=l}else{for(c=0;c<e.length;l>=65536?c+=2:c++){if(l=codePointAt(e,c),l===10)d=!0,m&&(p||=c-h-1>r&&e[h+1]!==` `,h=c);else if(!isPrintable(l))return 5;g&&=isPlainSafe(l,u,s),u=l}p||=m&&c-h-1>r&&e[h+1]!==` `}return!d&&!p?g&&!o&&!i(e)?1:a===2?5:2:n>9&&needIndentIndicator(e)?5:o?a===2?5:2:p?4:3}function writeScalar(e,n,r,i,a){e.dump=(function(){if(n.length===0)return e.quotingType===2?`""`:`''`;if(!e.noCompatMode&&(s.indexOf(n)!==-1||c.test(n)))return e.quotingType===2?`"`+n+`"`:`'`+n+`'`;let o=e.indent*Math.max(1,r),l=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),u=i||e.flowLevel>-1&&r>=e.flowLevel;function testAmbiguity(t){return testImplicitResolving(e,t)}switch(chooseScalarStyle(n,u,e.indent,l,testAmbiguity,e.quotingType,e.forceQuotes&&!i,a)){case 1:return n;case 2:return`'`+n.replace(/'/g,`''`)+`'`;case 3:return`|`+blockHeader(n,e.indent)+dropEndingNewline(indentString(n,o));case 4:return`>`+blockHeader(n,e.indent)+dropEndingNewline(indentString(foldString(n,l),o));case 5:return`"`+escapeString(n)+`"`;default:throw new t(`impossible error: invalid scalar style`)}})()}function blockHeader(e,t){let n=needIndentIndicator(e)?String(t):``,r=e[e.length-1]===`
|
|
49
|
-
`;return n+(r&&(e[e.length-2]===`
|
|
50
|
-
`||e===`
|
|
51
|
-
`)?`+`:r?``:`-`)+`
|
|
52
|
-
`}function dropEndingNewline(e){return e[e.length-1]===`
|
|
53
|
-
`?e.slice(0,-1):e}function foldString(e,t){let n=/(\n+)([^\n]*)/g,r=(function(){let r=e.indexOf(`
|
|
54
|
-
`);return r=r===-1?e.length:r,n.lastIndex=r,foldLine(e.slice(0,r),t)})(),i=e[0]===`
|
|
55
|
-
`||e[0]===` `,a,o;for(;o=n.exec(e);){let e=o[1],n=o[2];a=n[0]===` `,r+=e+(!i&&!a&&n!==``?`
|
|
56
|
-
`:``)+foldLine(n,t),i=a}return r}function foldLine(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=`
|
|
57
|
-
`+e.slice(i,a),i=a+1),o=s;return c+=`
|
|
58
|
-
`,e.length-i>t&&o>i?c+=e.slice(i,o)+`
|
|
59
|
-
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function escapeString(e){let t=``,n=0;for(let r=0;r<e.length;n>=65536?r+=2:r++){n=codePointAt(e,r);let i=o[n];!i&&isPrintable(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=i||encodeHex(n)}return t}function writeFlowSequence(e,t,n){let r=``,i=e.tag;for(let i=0,a=n.length;i<a;i+=1){let a=n[i];e.replacer&&(a=e.replacer.call(n,String(i),a)),(writeNode(e,t,a,!1,!1)||a===void 0&&writeNode(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump)}e.tag=i,e.dump=`[`+r+`]`}function writeBlockSequence(e,t,n,r){let i=``,a=e.tag;for(let a=0,o=n.length;a<o;a+=1){let o=n[a];e.replacer&&(o=e.replacer.call(n,String(a),o)),(writeNode(e,t+1,o,!0,!0,!1,!0)||o===void 0&&writeNode(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=generateNextLine(e,t)),e.dump&&e.dump.charCodeAt(0)===10?i+=`-`:i+=`- `,i+=e.dump)}e.tag=a,e.dump=i||`[]`}function writeFlowMapping(e,t,n){let r=``,i=e.tag,a=Object.keys(n);for(let i=0,o=a.length;i<o;i+=1){let o=``;r!==``&&(o+=`, `),e.condenseFlow&&(o+=`"`);let s=a[i],c=n[s];e.replacer&&(c=e.replacer.call(n,s,c)),writeNode(e,t,s,!1,!1)&&(e.dump.length>1024&&(o+=`? `),o+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),writeNode(e,t,c,!1,!1)&&(o+=e.dump,r+=o))}e.tag=i,e.dump=`{`+r+`}`}function writeBlockMapping(e,n,r,i){let a=``,o=e.tag,s=Object.keys(r);if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==`function`)s.sort(e.sortKeys);else if(e.sortKeys)throw new t(`sortKeys must be a boolean or a function`);for(let t=0,o=s.length;t<o;t+=1){let o=``;(!i||a!==``)&&(o+=generateNextLine(e,n));let c=s[t],l=r[c];if(e.replacer&&(l=e.replacer.call(r,c,l)),!writeNode(e,n+1,c,!0,!0,!0))continue;let u=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024;u&&(e.dump&&e.dump.charCodeAt(0)===10?o+=`?`:o+=`? `),o+=e.dump,u&&(o+=generateNextLine(e,n)),writeNode(e,n+1,l,!0,u)&&(e.dump&&e.dump.charCodeAt(0)===10?o+=`:`:o+=`: `,o+=e.dump,a+=o)}e.tag=o,e.dump=a||`{}`}function detectType(e,n,a){let o=a?e.explicitTypes:e.implicitTypes;for(let s=0,c=o.length;s<c;s+=1){let c=o[s];if((c.instanceOf||c.predicate)&&(!c.instanceOf||typeof n==`object`&&n instanceof c.instanceOf)&&(!c.predicate||c.predicate(n))){if(e.tag=a?c.multi&&c.representName?c.representName(n):c.tag:`?`,c.represent){let a=e.styleMap[c.tag]||c.defaultStyle,o;if(r.call(c.represent)===`[object Function]`)o=c.represent(n,a);else if(i.call(c.represent,a))o=c.represent[a](n,a);else throw new t(`!<`+c.tag+`> tag resolver accepts not "`+a+`" style`);e.dump=o}return!0}}return!1}function writeNode(e,n,i,a,o,s,c){e.tag=null,e.dump=i,detectType(e,i,!1)||detectType(e,i,!0);let l=r.call(e.dump),u=a;a&&=e.flowLevel<0||e.flowLevel>n;let d=l===`[object Object]`||l===`[object Array]`,p,m;if(d&&(p=e.duplicates.indexOf(i),m=p!==-1),(e.tag!==null&&e.tag!==`?`||m||e.indent!==2&&n>0)&&(o=!1),m&&e.usedDuplicates[p])e.dump=`*ref_`+p;else{if(d&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l===`[object Object]`)a&&Object.keys(e.dump).length!==0?(writeBlockMapping(e,n,e.dump,o),m&&(e.dump=`&ref_`+p+e.dump)):(writeFlowMapping(e,n,e.dump),m&&(e.dump=`&ref_`+p+` `+e.dump));else if(l===`[object Array]`)a&&e.dump.length!==0?(e.noArrayIndent&&!c&&n>0?writeBlockSequence(e,n-1,e.dump,o):writeBlockSequence(e,n,e.dump,o),m&&(e.dump=`&ref_`+p+e.dump)):(writeFlowSequence(e,n,e.dump),m&&(e.dump=`&ref_`+p+` `+e.dump));else if(l===`[object String]`)e.tag!==`?`&&writeScalar(e,e.dump,n,s,u);else if(l===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new t(`unacceptable kind of an object to dump `+l)}if(e.tag!==null&&e.tag!==`?`){let t=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`);t=e.tag[0]===`!`?`!`+t:t.slice(0,18)===`tag:yaml.org,2002:`?`!!`+t.slice(18):`!<`+t+`>`,e.dump=t+` `+e.dump}}return!0}function getDuplicateReferences(e,t){let n=[],r=[];inspectNode(e,n,r);let i=r.length;for(let e=0;e<i;e+=1)t.duplicates.push(n[r[e]]);t.usedDuplicates=Array(i)}function inspectNode(e,t,n){if(typeof e==`object`&&e){let r=t.indexOf(e);if(r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(let r=0,i=e.length;r<i;r+=1)inspectNode(e[r],t,n);else{let r=Object.keys(e);for(let i=0,a=r.length;i<a;i+=1)inspectNode(e[r[i]],t,n)}}}function dump2(e,t){t||={};let n=new State(t);n.noRefs||getDuplicateReferences(e,n);let r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),writeNode(n,0,r,!0,!0)?n.dump+`
|
|
60
|
-
`:``}return gi.dump=dump2,gi}var vi;function requireJsYaml(){if(vi)return Cr;vi=1;let e=requireLoader(),t=requireDumper();function renamed(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}return Cr.Type=requireType(),Cr.Schema=requireSchema(),Cr.FAILSAFE_SCHEMA=requireFailsafe(),Cr.JSON_SCHEMA=requireJson(),Cr.CORE_SCHEMA=requireCore(),Cr.DEFAULT_SCHEMA=require_default(),Cr.load=e.load,Cr.loadAll=e.loadAll,Cr.dump=t.dump,Cr.YAMLException=requireException(),Cr.types={binary:requireBinary(),float:requireFloat(),map:requireMap(),null:require_null$1(),pairs:requirePairs(),set:requireSet(),timestamp:requireTimestamp(),bool:requireBool(),int:requireInt(),merge:requireMerge(),omap:requireOmap(),seq:requireSeq(),str:requireStr()},Cr.safeLoad=renamed(`safeLoad`,`load`),Cr.safeLoadAll=renamed(`safeLoadAll`,`loadAll`),Cr.safeDump=renamed(`safeDump`,`dump`),Cr}const yi=getDefaultExportFromCjs(requireJsYaml()),{Type:bi,Schema:xi,FAILSAFE_SCHEMA:Si,JSON_SCHEMA:Ci,CORE_SCHEMA:wi,DEFAULT_SCHEMA:Ti,load:Ei,loadAll:Di,dump:Oi,YAMLException:ki,types:Ai,safeLoad:ji,safeLoadAll:Mi,safeDump:Ni}=yi;function createScanner(e,t=!1){let n=e.length,r=0,i=``,a=0,o=16,s=0,c=0,l=0,u=0,d=0;function scanHexDigits(t,n){let i=0,a=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)a=a*16+t-48;else if(t>=65&&t<=70)a=a*16+t-65+10;else if(t>=97&&t<=102)a=a*16+t-97+10;else break;r++,i++}return i<t&&(a=-1),a}function setPosition(e){r=e,i=``,a=0,o=16,d=0}function scanNumber(){let t=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&isDigit$1(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46){if(r++,r<e.length&&isDigit$1(e.charCodeAt(r)))for(r++;r<e.length&&isDigit$1(e.charCodeAt(r));)r++;else return d=3,e.substring(t,r)}let n=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101)){if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&isDigit$1(e.charCodeAt(r))){for(r++;r<e.length&&isDigit$1(e.charCodeAt(r));)r++;n=r}else d=3}return e.substring(t,n)}function scanString(){let t=``,i=r;for(;;){if(r>=n){t+=e.substring(i,r),d=2;break}let a=e.charCodeAt(r);if(a===34){t+=e.substring(i,r),r++;break}if(a===92){if(t+=e.substring(i,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
|
|
61
|
-
`;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=scanHexDigits(4,!0);e>=0?t+=String.fromCharCode(e):d=4;break;default:d=5}i=r;continue}if(a>=0&&a<=31){if(isLineBreak(a)){t+=e.substring(i,r),d=2;break}d=6}r++}return t}function scanNext(){if(i=``,d=0,a=r,c=s,u=l,r>=n)return a=n,o=17;let t=e.charCodeAt(r);if(isWhiteSpace(t)){do r++,i+=String.fromCharCode(t),t=e.charCodeAt(r);while(isWhiteSpace(t));return o=15}if(isLineBreak(t))return r++,i+=String.fromCharCode(t),t===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
62
|
-
`),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=scanString(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!isLineBreak(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,isLineBreak(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!isDigit$1(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=scanNumber(),o=11;default:for(;r<n&&isUnknownContentCharacter(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function isUnknownContentCharacter(e){if(isWhiteSpace(e)||isLineBreak(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function scanNextNonTrivia(){let e;do e=scanNext();while(e>=12&&e<=15);return e}return{setPosition,getPosition:()=>r,scan:t?scanNextNonTrivia:scanNext,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function isWhiteSpace(e){return e===32||e===9}function isLineBreak(e){return e===10||e===13}function isDigit$1(e){return e>=48&&e<=57}__name(isDigit$1,`isDigit`);var Pi;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(Pi||={}),Array(20).fill(0).map((e,t)=>` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
|
|
63
|
-
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
|
|
64
|
-
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
|
|
65
|
-
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
|
|
66
|
-
`+` `.repeat(t));var Fi;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Fi||={});function parse$5(e,t=[],n=Fi.DEFAULT){let r=null,i=[],a=[];function onValue(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return visit(e,{onObjectBegin:()=>{let e={};onValue(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];onValue(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:onValue,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}__name(parse$5,`parse`);function parseTree$1(e,t=[],n=Fi.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function ensurePropertyComplete(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function onValue(e){return r.children.push(e),e}visit(e,{onObjectBegin:e=>{r=onValue({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=onValue({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{ensurePropertyComplete(e+t),r.length=e+t-r.offset,r=r.parent,ensurePropertyComplete(e+t)},onArrayBegin:(e,t)=>{r=onValue({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,ensurePropertyComplete(e+t)},onLiteralValue:(e,t,n)=>{onValue({type:getNodeType(e),offset:t,length:n,parent:r,value:e}),ensurePropertyComplete(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&ensurePropertyComplete(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let i=r.children[0];return i&&delete i.parent,i}__name(parseTree$1,`parseTree`);function findNodeAtLocation$1(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}__name(findNodeAtLocation$1,`findNodeAtLocation`);function visit(e,t,n=Fi.DEFAULT){let r=createScanner(e,!1),i=[],a=0;function toNoArgVisit(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function toOneArgVisit(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function toOneArgVisitWithPath(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function toBeginVisit(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function toEndVisit(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let o=toBeginVisit(t.onObjectBegin),s=toOneArgVisitWithPath(t.onObjectProperty),c=toEndVisit(t.onObjectEnd),l=toBeginVisit(t.onArrayBegin),u=toEndVisit(t.onArrayEnd),d=toOneArgVisitWithPath(t.onLiteralValue),p=toOneArgVisit(t.onSeparator),m=toNoArgVisit(t.onComment),h=toOneArgVisit(t.onError),g=n&&n.disallowComments,_=n&&n.allowTrailingComma;function scanNext(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:handleError(14);break;case 5:handleError(15);break;case 3:handleError(13);break;case 1:g||handleError(11);break;case 2:handleError(12);break;case 6:handleError(16)}switch(e){case 12:case 13:g?handleError(10):m();break;case 16:handleError(1);break;case 15:case 14:break;default:return e}}}function handleError(e,t=[],n=[]){if(h(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){scanNext();break}if(n.indexOf(e)!==-1)break;e=scanNext()}}}function parseString(e){let t=r.getTokenValue();return e?d(t):(s(t),i.push(t)),scanNext(),!0}function parseLiteral(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(handleError(2),t=0),d(t);break;case 7:d(null);break;case 8:d(!0);break;case 9:d(!1);break;default:return!1}return scanNext(),!0}function parseProperty(){return r.getToken()===10?(parseString(!1),r.getToken()===6?(p(`:`),scanNext(),parseValue()||handleError(4,[],[2,5])):handleError(5,[],[2,5]),i.pop(),!0):(handleError(3,[],[2,5]),!1)}function parseObject(){o(),scanNext();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||handleError(4,[],[]),p(`,`),scanNext(),r.getToken()===2&&_)break}else e&&handleError(6,[],[]);parseProperty()||handleError(4,[],[2,5]),e=!0}return c(),r.getToken()===2?scanNext():handleError(7,[2],[]),!0}function parseArray(){l(),scanNext();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||handleError(4,[],[]),p(`,`),scanNext(),r.getToken()===4&&_)break}else t&&handleError(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,parseValue()||handleError(4,[],[4,5]),t=!0}return u(),e||i.pop(),r.getToken()===4?scanNext():handleError(8,[4],[]),!0}function parseValue(){switch(r.getToken()){case 3:return parseArray();case 1:return parseObject();case 10:return parseString(!0);default:return parseLiteral()}}return scanNext(),r.getToken()===17?n.allowEmptyContent?!0:(handleError(4,[],[]),!1):parseValue()?(r.getToken()!==17&&handleError(9,[],[]),!0):(handleError(4,[],[]),!1)}function getNodeType(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}var Ii;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(Ii||={});var Li;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(Li||={});const Ri=parse$5,zi=parseTree$1,Bi=findNodeAtLocation$1;var Vi;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(Vi||={});function printParseErrorCode(e){switch(e){case 1:return`InvalidSymbol`;case 2:return`InvalidNumberFormat`;case 3:return`PropertyNameExpected`;case 4:return`ValueExpected`;case 5:return`ColonExpected`;case 6:return`CommaExpected`;case 7:return`CloseBraceExpected`;case 8:return`CloseBracketExpected`;case 9:return`EndOfFileExpected`;case 10:return`InvalidCommentToken`;case 11:return`UnexpectedEndOfComment`;case 12:return`UnexpectedEndOfString`;case 13:return`UnexpectedEndOfNumber`;case 14:return`InvalidUnicode`;case 15:return`InvalidEscapeCharacter`;case 16:return`InvalidCharacter`}return`<unknown ParseErrorCode>`}const Hi={platform:process.platform};function isCaseInsensitiveFs(){return Hi.platform===`darwin`||Hi.platform===`win32`}function findFileUp(e,t){for(let n of ancestors(e)){let e=y(n,t);if(isFile(e))return e}}function findAnyFileUp(e,t){let n=isCaseInsensitiveFs();for(let r of ancestors(e)){let e=readEntries(r,n);if(e)for(let i of t){let t=lookup(e,i,n);if(t&&isFileEntry(r,t))return y(r,t.name)}}}function*ancestors(e){let t=C(e),{root:n}=b(t);for(;;){if(yield t,t===n)return;t=_(t)}}function readEntries(e,t){let n;try{n=s(e,{withFileTypes:!0})}catch{return}let r=new Map;for(let e of n)if(r.set(e.name,e),t){let t=e.name.toLowerCase();r.has(t)||r.set(t,e)}return r}function lookup(e,t,n){let r=e.get(t);return r||!n?r:e.get(t.toLowerCase())}function isFileEntry(e,t){return t.isFile()?!0:t.isSymbolicLink()?isFile(y(e,t.name)):!1}function isFile(e){return p(e,{throwIfNoEntry:!1})?.isFile()??!1}function findPackageJson(e){return findFileUp(e,`package.json`)}function getPackageJson(e){return JSON.parse(o(e,`utf-8`))}function readTextFile(e){return o(e,`utf-8`)}async function importModule(e){return import(D(e).href)}const Ui={findPackageJson,getPackageJson};function lookupConfig({cwd:e},t){let n=getConfigFilenames(t),r=findAnyFileUp(e,n);if(r)return{source:{type:`file`,path:r,format:getConfigFormat(r)},candidates:n};let i=Ui.findPackageJson(e);return i&&Ui.getPackageJson(i)[t]?{source:{type:`package.json`,path:i,property:t},candidates:n}:{source:{type:`none`},candidates:n}}async function resolveConfig({cwd:e,ui:t},n){let{source:r,candidates:i}=lookupConfig({cwd:e},n);if(r.type===`file`){t.debug(`load config from: ${r.path}`);let e=await readConfigFile(r.path);return t.debug(`config: ${JSON.stringify(e,void 0,2)}`),{config:e,source:r,candidates:i}}if(r.type===`package.json`){t.debug(`load config from package.json: ${r.path}`);let e=Ui.getPackageJson(r.path)[r.property];return t.debug(`config: ${JSON.stringify(e,void 0,2)}`),{config:e,source:r,candidates:i}}return t.warn(`no config found under '${e}':\n ${i.join(`
|
|
67
|
-
`)}`),{config:void 0,source:r,candidates:i}}function describeConfigSource(e){switch(e.type){case`file`:return e.path;case`package.json`:return`${e.path} (property "${e.property}")`;default:return`not found`}}function getConfigFilenames(e){let t=[e,`${e}.cjs`,`${e}.mjs`,`${e}.js`,`${e}.json`,`${e}.jsonc`,`${e}.yml`,`${e}.yaml`,`${e}rc.cjs`,`${e}rc.mjs`,`${e}rc.js`,`${e}rc.json`,`${e}rc.jsonc`,`${e}rc.yml`,`${e}rc.yaml`,`${e}rc`];return e.startsWith(`.`)?t:t.flatMap(e=>[e,`.${e}`])}function getConfigFormat(e){switch(v(e).toLowerCase()){case`.json`:case`.jsonc`:return`jsonc`;case`.yml`:case`.yaml`:return`yaml`;case`.js`:case`.cjs`:case`.mjs`:return`module`;default:return`unknown`}}async function readConfigFile(e){let t=getConfigFormat(e);if(t===`module`)return readModuleConfig(e);let n=readTextFile(e);if(t===`jsonc`)return parseJsoncOrThrow(n,e);if(t===`yaml`)return yi.load(n);try{return parseJsoncOrThrow(n,e)}catch{try{return yi.load(n)}catch{return readModuleConfig(e)}}}async function readModuleConfig(e){let t=await importModule(e);return t.activate?t:t.default}function parseJsoncOrThrow(e,t){let n=[],r=Ri(e,n,{allowTrailingComma:!0,disallowComments:!1});if(n.length>0){let[{error:e,offset:r}]=n;throw Error(`Unable to parse ${t} as JSON: ${printParseErrorCode(e)} at offset ${r}`)}return r}const Wi=new WeakMap;function parseArgv(e){let t=[],n=e.slice(2).reduce((e,n)=>(e.args.__?e.args.__.push(n):isOption(n)?(isInOptionState(e)&&(e=endOption(e)),e=startOption(e,n,t)):isInOptionState(e)?(e.values.push(n),t[t.length-1].following.push(n)):n===`--`?e.args.__=[]:e.args._.push(n),e),{args:{_:[]},key:``,values:[]}),r=(isInOptionState(n)?endOption(n):n).args;return Wi.set(r,t),r}function isInOptionState(e){return!!e.key}function isOption(e){return e.startsWith(`-`)&&/\w+/.test(e)}function startOption(e,t,n){return e=/^-\w+/.test(t)?startSingleCharacterOptions(e,t,n):startMultiCharacterOptions(e,t),n.push({key:e.key,inline:[...e.values],following:[]}),e}function startSingleCharacterOptions(e,t,n){let r=t.indexOf(`=`),[i,a]=r>0?[t.slice(1,r),[t.slice(r+1)]]:[t.slice(1),[]],o=i.split(``),s=o.pop();for(let e of o)n.push({key:e,inline:[`true`],following:[]});return e=addBooleanOptions(e,o),e.key=s,e.values=a,e}function addBooleanOptions(e,t){return t.length<=0?e:(e.key=t.pop(),e.values=[`true`],addBooleanOptions(endOption(e),t))}function startMultiCharacterOptions(e,t){let n=t.indexOf(`=`);return n>0?(e.key=t.slice(2,n),e.values=[t.slice(n+1)]):(e.key=t.slice(2),e.values=[]),e}function endOption(e){let{key:t,values:n}=e,r={...e.args};return r[t]||(r[t]=[]),n.length===0?r[t].push(`true`):r[t].push(...n),{args:r,key:``,values:[]}}function lookupCommand(e,t,n){let r=matchCommand(e,t);return processCommand(r[0],assignOptionValues(r[1],r[0],n))}function matchCommand(e,t){if(e.commands){let n=e.commands;for(let e=n.length-1;e>=0;e--){let r=n[e];if(!r.name)return[r,t];if(t._[0]===r.name||r.alias?.includes(t._[0]))return t._.shift(),r.commands&&matchCommand(r,t)||[r,t]}}return[e,t]}function assignOptionValues(e,t,n){let r=Wi.get(e);if(!r)return e;let i={},a=[];for(let e of r){let r=countFollowing(lookupOptions(t,e.key)[1]??(n&&lookupOptions(n,e.key)[1]),e),o=e.following.slice(0,r);a.push(...e.following.slice(r));let s=e.inline.length+o.length>0?[...e.inline,...o]:[`true`];i[e.key]=[...i[e.key]??[],...s]}let o={...e,_:[...e._,...a]};for(let t of Object.keys(i))e[t]&&(o[t]=i[t]);return o}function countFollowing(e,t){if(!e)return t.following.length;let n=unwrapOptional(e.type??Fn());return isZodArray(n)?t.following.length:t.inline.length>0?0:isZodBoolean(n)?+!!/^(true|false)$/i.test(t.following[0]??``):1}function processCommand(e,t){return fillDefaultOptions(checkConflicts(fillInputOptions(fillArguments({command:e,rawArgs:t,args:{_:[]},errors:[]}))))}function fillArguments(e){let t=e.command,n=[...e.rawArgs._];return e.args=(t.arguments||[]).reduce((t,r)=>{let i=r.type??q();if(n.length===0)return isZodOptional(i)||e.errors.push({type:`missing-argument`,name:r.name}),t;let a=isZodArray(unwrapOptional(i))?n.splice(0):[n.shift()],[o,s]=convertValue(i,r.name,a);return e.errors.push(...s),t.args[r.name]=o,t},{args:{_:[]}}).args,n.length>0&&e.errors.push({type:`extra-arguments`,name:t.name,values:n}),e}function fillInputOptions(e){return reduceByKey(e.rawArgs,(t,n)=>{if(n===`_`)return t;if(/^-/.test(n))return t.errors.push({type:`invalid-key`,key:n}),t;let[r,i]=lookupOptions(e.command,n);if(!r)return t.errors.push({type:`invalid-key`,key:n}),t;let[a,o]=convertValue(i.type||J(Fn()),n,e.rawArgs[n]);return o&&t.errors.push(...o),t.args[r]=a,t},e)}function checkConflicts(e){let t=e.command.options;if(!t)return e;let n=new Map;for(let t of Object.keys(e.rawArgs)){let[r]=lookupOptions(e.command,t);r&&!n.has(r)&&n.set(r,t)}let r=[...n.keys()];for(let i=0;i<r.length;i++)for(let a=i+1;a<r.length;a++){let[o,s]=[r[i],r[a]];if(!t[o].conflicts?.includes(s)&&!t[s].conflicts?.includes(o))continue;let[c,l]=t[o].conflicts?.includes(s)?[o,s]:[s,o];e.errors.push({type:`conflicting-options`,key:n.get(c),conflictsWith:n.get(l)})}return e}function fillDefaultOptions(e){let t=e.command.options||{};return reduceByKey(t,(e,n)=>{if(e.args[n]!==void 0)return e;let r=t[n];return typeof r==`string`||r.default===void 0||(e.args[n]=isZodArray(r.type)&&!Array.isArray(r.default)?[r.default]:r.default),e},e)}function lookupOptions(e,t){let n=e.options;if(!n)return[];let r=n[t];if(r)return[t,r];let i=findKey(n,e=>{let r=n[e];return r.alias?r.alias.some(e=>e===t||e.alias===t):!1});return i?[i,n[i]]:[]}function unwrapOptional(e){return isZodOptional(e)?e._def.innerType:e}function convertValue(e,t,n){let[r,i]=parse$3(e,t,n);return r.success?[r.data,i]:(i.length===0&&i.push({type:`invalid-value`,key:t,value:n[n.length-1],message:describeValue(e,r.error)}),[void 0,i])}function describeValue(e,t){let n=unwrapOptional(e);return isZodEnum(n)?`expected one of: ${n.options.join(`, `)}`:t.issues[0].message}function parse$3(e,t,n){let[r,i]=toParsable(e,t,n,[]);return[e.safeParse(r),i]}__name(parse$3,`parse`);function toParsable(e,t,n,r){if(isZodOptional(e))return toParsable(e._def.innerType,t,n,r);if(isZodBoolean(e))return n.length>1&&r.push({type:`expect-single`,key:t,keyType:e,value:n}),toBoolean(t,n[n.length-1],r);if(isZodNumber(e))return n.length>1&&r.push({type:`expect-single`,key:t,keyType:e,value:n}),toNumber(t,n[n.length-1],r);if(isZodString(e))return n.length>1&&r.push({type:`expect-single`,key:t,keyType:e,value:n}),[n[n.length-1],r];if(isZodArray(e)){let i=e.element;if(isZodBoolean(i))return n.reduce(([e,n],r)=>{let[i,a]=toBoolean(t,r,n);return e.push(i),[e,a]},[[],r]);if(isZodNumber(i))return n.reduce(([e,n],r)=>{let[i,a]=toNumber(t,r,n);return e.push(i),[e,a]},[[],r]);if(isZodString(i))return[n,r]}return n.length>1&&r.push({type:`expect-single`,key:t,keyType:e,value:n}),[n[n.length-1],r]}function toBoolean(e,t,n){return t.toLowerCase()===`true`?[!0,n]:t.toLowerCase()===`false`?[!1,n]:(n.push({type:`invalid-value`,key:e,value:t,message:`expected to be boolean`}),[void 0,n])}function toNumber(e,t,n){let r=+t;return typeof r==`number`&&!Number.isNaN(r)?[r,n]:(n.push({type:`invalid-value`,key:e,value:t,message:`expected to be number`}),[void 0,n])}function createRegistry(){let e=new Map,t=new Map;function get(n){return n.kind===`collection`?t.get(n.id)??[]:e.get(n.id)?.value}return{register(n,r,i){if(r.kind===`collection`){let e=t.get(r.id)??[];return e.push({source:n,value:i}),t.set(r.id,e),{accepted:!0}}let a=e.get(r.id);return a?{accepted:!1,source:a.source}:(e.set(r.id,{source:n,value:i}),{accepted:!0})},get,has(n){return n.kind===`collection`?t.has(n.id):e.has(n.id)},describe(n){if(n.kind===`collection`)return(t.get(n.id)??[]).map(({source:e})=>e);let r=e.get(n.id)?.source;return r?[r]:[]}}}function formatLookupError(e,t){switch(e.type){case`invalid-key`:return`unknown option ${formatOption(e.key)}`;case`missing-argument`:return`missing required argument <${e.name}>`;case`extra-arguments`:return`unexpected argument${e.values.length>1?`s`:``}: ${e.values.join(`, `)}`;case`invalid-value`:return`invalid value for ${formatKey(e.key,t)}: ${e.message}, received "${e.value}"`;case`conflicting-options`:return`option ${formatOption(e.key)} cannot be used with option ${formatOption(e.conflictsWith)}`;case`expect-single`:return`${formatKey(e.key,t)} expects a single value, received: ${toArray(e.value).join(`, `)}`}}function formatKey(e,t){return t.arguments?.some(t=>t.name===e)?`argument <${e}>`:`option ${formatOption(e)}`}function formatOption(e){return e.length===1?`-${e}`:`--${e}`}function toArray(e){return Array.isArray(e)?e:[e]}function state(e){let{name:t,description:n=``,version:r,config:i,keywords:a=[]}=e;i&&a.length===0&&a.push(t);let o=typeof i==`string`?i:i?t:void 0;return{name:t,description:n,version:r,configName:o,keywords:a,displayLevel:`info`,command:getBaseCommand(n,{config:!!o})}}function builder(e,t){let n=state(t),r=n.description,i=[],a=createRegistry(),o=n.configName?e.loadConfig(n.configName):void 0,s=n.configName||n.keywords.length>0;return s&&n.command.commands.push(adjustCommand(n.command,Sr)),o&&i.push((async()=>{let t=await o;if(n.config=t,t?.plugins){let r=await e.loadPlugins(t.plugins,a,{name:n.name,version:n.version||``});n.command.commands.push(...r.map(e=>adjustCommand(n.command,e)))}})()),{name:n.name,version:n.version||``,description:r,parse:s?parse:void 0,default(e){return n.command=adjustCommand(n.command,{...n.command,...e}),delete this.default,{...this,parse}},command(e){return n.command.commands.push(adjustCommand(n.command,e)),{...this,parse}}};async function parse(r){await Promise.all(i),e.ui.debug(`argv:`,r.join(` `));let o=parseArgv(r),s=getBaseCommand(n.description,{config:!!n.configName}),{args:c}=lookupCommand(s,o);if(c.silent&&(delete o.silent,n.displayLevel=`none`),c.verbose&&(delete o.verbose,n.displayLevel=`debug`),c[`debug-cli`]&&(delete o[`debug-cli`],n.displayLevel=`trace`),e.ui.displayLevel=n.displayLevel,e.ui.dump(),n.configName&&c[`show-config`])return showConfig(n.configName);let l=lookupCommand(n.command,o,s),{args:u,command:d}=l;if(c.version||u.version)return createCommandInstance(e,n,l.command,a).ui.showVersion();if(c.help||u.help)return createCommandInstance(e,n,l.command,a).ui.showHelp();let p=l.errors.filter(e=>!(e.type===`invalid-key`&&lookupOptions(s,e.key)[0]));if(p.length>0){let r=createCommandInstance(e,n,l.command,a).ui,i=findUsageErrorHandler(d)??t.onUsageError;if(i){let e=await i(p,{command:d,ui:r});return exit(typeof e==`number`?e:k.usage)}for(let e of p)r.error(formatLookupError(e,d));return r.showHelp(),exit(k.usage)}if(d.config){let t=typeof n.configName==`string`?n.configName:n.name,{config:r,errors:i}=parseConfig(d.config,await e.loadConfig(t));if(n.config=r,i)return e.ui.error(`config fails validation:`),forEachKey(i,t=>e.ui.error(` ${String(t)}: ${i[t]}`)),createCommandInstance(e,n,l.command,a).ui.showHelp(),exit(k.error);n.config=r}let m=createCommandInstance(e,n,d,a);if(!m.run)return m.ui.showHelp(),exit(k.usage);try{return await m.run(u)}catch(e){if(!isCliError(e))throw e;m.ui.error(e.message);for(let t of e.help)m.ui.error(t);return exit(e.exitCode)}}async function showConfig(t){let{config:r,source:i}=await e.resolveConfig(t),a=createCommandUI(e,n,n.command);a.info(`config: ${describeConfigSource(i)}`),i.type!==`none`&&a.info(JSON.stringify(r,void 0,2))}function exit(t){return e.exit(t),t}function parseConfig(e,t){let n=e.safeParse(t);return n.success?{config:t}:{errors:n.error.flatten().fieldErrors}}}function findUsageErrorHandler(e){for(let t=e;t;t=t.parent)if(t.onUsageError)return t.onUsageError}function createCommandInstance(e,t,n,r){return{...n,run:n.run,ui:createCommandUI(e,t,n),config:t.config,keywords:t.keywords,cwd:e.cwd,registry:r}}function createCommandUI(e,t,n){let r=e.createCommandUI(n.name||t.name);return r.displayLevel=t.displayLevel,{...r,showVersion:()=>r.showVersion(t.version),showHelp:()=>r.showHelp(t.name,n)}}function adjustCommand(e,t){return t.name&&(t.parent=e),t.commands&&=t.commands.map(e=>adjustCommand(t,e)),t}const Y={none:0,emergency:100,alert:200,critical:300,error:400,warn:500,notice:600,info:700,debug:800,trace:900,planck:1/0,all:1/0};function toLogLevelName(e){return e<=100?`emergency`:e<=200?`alert`:e<=300?`critical`:e<=400?`error`:e<=500?`warn`:e<=600?`notice`:e<=700?`info`:e<=800?`debug`:e<=900?`trace`:`planck`}function toLogLevel(e){return Y[e.toLocaleLowerCase()]}const Gi=[`emergency`,`alert`,`critical`,`error`,`warn`,`notice`,`info`,`debug`,`trace`,`planck`];var Ki=__toESM(__commonJSMin(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return parse(e);if(n===`number`&&isFinite(e))return t.long?fmtLong(e):fmtShort(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function parse(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function fmtShort(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function fmtLong(e){var t=Math.abs(e);return t>=a?plural(e,t,a,`day`):t>=i?plural(e,t,i,`hour`):t>=r?plural(e,t,r,`minute`):t>=n?plural(e,t,n,`second`):e+` ms`}function plural(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}))(),1);function createTimestampFormatter(e){switch(e){case`none`:return e=>void 0;case`iso`:return e=>e.toISOString();case`elapsed`:{let e;return t=>{let n=t.getTime(),r=(0,Ki.default)(e===void 0?0:n-e);return e=n,r}}}}function consoleFormatter({args:e}){return e}const qi=record();function toConsoleMethod(e){switch(!0){case e<=0:return`debug`;case e<=Y.error:return`error`;case e<=Y.warn:return`warn`;case e<=Y.info:return`info`;default:return`debug`}}function buildPolyfillConsole(){return console.log.bind?{debug:(typeof console.info==`function`?console.debug:console.log).bind(console),info:(typeof console.info==`function`?console.info:console.log).bind(console),warn:(typeof console.warn==`function`?console.warn:console.log).bind(console),error:(typeof console.error==`function`?console.error:console.log).bind(console)}:{debug:buildFn(typeof console.debug==`function`?`debug`:`log`),info:buildFn(typeof console.info==`function`?`info`:`log`),warn:buildFn(typeof console.warn==`function`?`warn`:`log`),error:buildFn(typeof console.error==`function`?`error`:`log`)}}function buildFn(e){return(...t)=>{console[e](...t)}}function createConsoleLogReporter(e){let{id:t,formatter:n,filter:r}=unpartial$1({id:`console`,formatter:consoleFormatter},e);return qi.console||=buildPolyfillConsole(),Object.freeze({id:t,isConsoleReporter:!0,get formatter(){return n},get filter(){return r},console:qi.console,write(e){if(r&&!r(e))return;let t=n(e),i=toConsoleMethod(e.level);this.console[i](...t)}})}function createLogStore(e){return{loggers:record(),nonConsoleLoggers:record(),reporters:e.reporters||[createConsoleLogReporter()],logLevel:e.logLevel,logLevelStore:logLevelStore(e)}}function logLevelStore(e){let t=e.customLevels||record(),n={customLevels:t,customLevelsReverse:reduceByKey(t,(e,n)=>(e[t[n]]=n,e),{})};return{getName(e){return n.customLevelsReverse[e]??toLogLevelName(e)},getLevel(e){return n.customLevels[e]??toLogLevel(e)},getAllLevels(){return $t(Y,(e,t)=>(t!==`none`&&t!==`all`&&e.push({name:t,level:Y[t]}),e),mapKey(n.customLevels,e=>({name:e,level:n.customLevels[e]})))}}}function createLogger(e,t,n){t=sanitizeId(t);let r=n?.writeTo??(()=>!0),[i,a]=typeof r==`string`?[e=>e===r,e.reporters]:r instanceof RegExp?[e=>r.test(e),e.reporters]:typeof r==`function`?[r,e.reporters]:[()=>!0,[r]];function write(e){writeToReporters(a,e,i)}let o={level:n?.level,write};return Object.defineProperties(o,{id:{value:t,writable:!1},count:{writable:!1,value:(n=>(...r)=>{shouldLog(e,Y.debug,o.level)&&write({id:t,level:Y.debug,args:[++n,...r],timestamp:new Date})})(0)},on:{writable:!1,value:(t,n)=>{let r=typeof t==`string`?e.logLevelStore.getLevel(t):t;if(shouldLog(e,r,o.level)){let t=e.logLevelStore.getName(r),i=o[t].bind(o),a=n(i,o.level??e.logLevel);a&&i(a)}}}}),e.logLevelStore.getAllLevels().forEach(function addMethod({name:n,level:r}){Object.defineProperty(o,n,{writable:!1,value:(...n)=>{shouldLog(e,r,o.level)&&write({id:t,level:r,args:n,timestamp:new Date})}})}),o}function sanitizeId(e){return e.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g,`-`)}function writeToReporters(e,t,n){e.filter(e=>n(e.id)).forEach(e=>e.write(t))}function shouldLog(e,t,n){return t<=(n===void 0?e.logLevel:n)}const Ji=record();function createStandardLog(e){let t=createStandardLogClosure(e);return e?.reporters?.some(e=>!e.id)&&t.standardLog.getLogger(`standard-log`).critical(`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`),Ji.gsl||=t,t.standardLog}function noop(){}function createStandardLogClosure(e){let t=createLogStore(required$1({logLevel:Y.info},e)),n=e?.reporters?.filter(e=>!e.isConsoleReporter).map(e=>e.id)??[],r=Gi.concat(Object.keys(e?.customLevels??{})).concat([`on`,`count`,`write`]);return{store:t,standardLog:{get logLevel(){return t.logLevel},toLogLevelName(e){return t.logLevelStore.getName(e)},toLogLevel(e){return t.logLevelStore.getLevel(e)},getLogger(e,n){return t.loggers[e]?t.loggers[e]:t.loggers[e]=createLogger(t,e,{ssf:this.getLogger,...n})},getNonConsoleLogger(e,i){return t.nonConsoleLoggers[e]?t.nonConsoleLoggers[e]:t.loggers[e]?(this.getLogger(`standard-log`).warn(`attempt to create a non-console logger with existing id ('${e}'), ignoring`),t.nonConsoleLoggers[e]=createDummyLogger(r)):t.nonConsoleLoggers[e]=n.length===0?createDummyLogger(r):createLogger(t,e,{ssf:this.getNonConsoleLogger,...i,writeTo(e){return n.indexOf(e)>=0}})}}}}function createDummyLogger(e){return e.reduce((e,t)=>(e[t]=noop,e),record())}function wrapAnsi(e,t){return`\u001B[${t.join(`;`)}m${e}\u001B[0m`}var Yi=__commonJSMin(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),Xi=__toESM(__commonJSMin(((e,t)=>{let n=O(`os`),r=O(`tty`),i=Yi(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1);function envForceColor(){if(`FORCE_COLOR`in a)return a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(a.FORCE_COLOR,10),3)}function translateLevel(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function supportsColor(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let s=envForceColor();s!==void 0&&(o=s);let c=r?o:s;if(c===0)return 0;if(r){if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2}if(e&&!t&&c===void 0)return 0;let l=c||0;if(a.TERM===`dumb`)return l;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`,`DRONE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:l;if(`TEAMCITY_VERSION`in a)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION);if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=Number.parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:l}function getSupportLevel(e,t={}){return translateLevel(supportsColor(e,{streamIsTTY:e&&e.isTTY,...t}))}t.exports={supportsColor:getSupportLevel,stdout:getSupportLevel({isTTY:r.isatty(1)}),stderr:getSupportLevel({isTTY:r.isatty(2)})}}))(),1);let Zi;function supportColor(){return Zi||={stderr:Xi.default.stderr?Xi.default.stderr.level:0,stdout:Xi.default.stdout?Xi.default.stdout.level:0}}function createAnsiFormatter(e={timestamp:`none`}){let t=createTimestampFormatter(e.timestamp);return function ansiFormatter(e){let n=toConsoleMethod(e.level);return[formatID(n,e.id),...formatArgs(t,n,e)]}}function formatArgs(e,t,n){let r=[...n.args],i=e(n.timestamp);i!==void 0&&r.push(i);let a=t===`error`?[31]:t===`warn`?[33]:void 0;return a?r.map(e=>wrapAnsi(e,a)):r}function formatID(e,t){let n=supportColor();return toIDFormatter(e===`error`?n.stderr:n.stdout)(t)}function toIDFormatter(e){switch(e){case 0:return e=>e;case 1:return basicIDFormatter;case 2:return ansiIDFormatter;case 3:return truecolorIDFormatter}}function basicIDFormatter(e){let t=getAnsiColor(e);return wrapAnsi(` ${e} `,t)}const Qi={counter:0,list:[[37,41],[30,42],[30,43],[37,44],[37,45],[30,46],[37,40],[37,41,1],[30,42,1],[30,43,1],[37,44,1],[37,45,1],[30,46,1],[37,40,1],[37,41,4],[30,42,4],[30,43,4],[37,44,4],[37,45,4],[30,46,4],[37,40,4],[37,41,1,4],[30,42,1,4],[30,43,1,4],[37,44,1,4],[37,45,1,4],[30,46,1,4],[37,40,1,4]]},$i=Object.create(null);function getAnsiColor(e){return $i[e]=$i[e]||Qi.list[Qi.counter++%Qi.list.length]}function ansiIDFormatter(e){return basicIDFormatter(e)}function truecolorIDFormatter(e){return basicIDFormatter(e)}zn();function createColorLogReporter(e){return createConsoleLogReporter(required({formatter:createAnsiFormatter()},e))}async function loadPlugins({cwd:e,ui:t,registry:n,host:r},i){return activatePlugins(e,t,n,r,i)}async function activatePlugins(e,t,n,r,i){let a=await Promise.all(i.map(async n=>(t.debug(`loading plugin`,n),{name:n,pluginModule:await loadModule(e,t,n)}))),o=[];for(let{name:e,pluginModule:i}of a){if(!isValidPlugin(i)){t.warn(`not a valid plugin`,e);continue}t.debug(`activating plugin`,e),(await activatePlugin(i,n,r,e,t)).forEach(e=>{t.debug(`adding command`,e.name),o.push(e)}),t.debug(`activated plugin`,e)}return o}async function loadModule(e,t,n){try{return await import(n)}catch(r){t.warn(`Unable to load plugin from ${n}. Please let the plugin author knows about it.`),t.warn(`cwd: ${e}`),t.warn(`error: `,r.message||r);return}}function isValidPlugin(e){return e&&typeof e.activate==`function`}async function activatePlugin(e,t,n,r,i){let a=[];return await e.activate({addCommand:e=>a.push(e),register:(e,n)=>{let a=t.register(r,e,n);a.accepted||i.warn(`plugin ${r} could not register ${e.id}; it is already registered by ${a.source}`)},get:t.get,has:t.has,host:n}),a}
|
|
68
|
-
/*!
|
|
69
|
-
* repeat-string <https://github.com/jonschlinkert/repeat-string>
|
|
70
|
-
*
|
|
71
|
-
* Copyright (c) 2014-2015, Jon Schlinkert.
|
|
72
|
-
* Licensed under the MIT License.
|
|
73
|
-
*/
|
|
74
|
-
var ea=__commonJSMin(((e,t)=>{var n=``,r;t.exports=repeat;function repeat(e,t){if(typeof e!=`string`)throw TypeError(`expected a string`);if(t===1)return e;if(t===2)return e+e;var i=e.length*t;if(r!==e||r===void 0)r=e,n=``;else if(n.length>=i)return n.substr(0,i);for(;i>n.length&&t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+=e,n=n.substr(0,i),n}})),ta=__commonJSMin(((e,t)=>{var n=ea();t.exports=function padLeft(e,t,r){var i=``,a=t-e.length;if(a<=5&&!r)i=`00000`;else if(a<=25&&!r)i=`000000000000000000000000000`;else return e+n(r||`0`,a);return e+i.slice(0,a)}})),na=__commonJSMin(((e,t)=>{var n=t.exports=function(e,t,n){typeof e==`object`&&(n=e,e=n.start,t=n.stop),typeof t==`object`&&(n=t,e||=n.start,t=void 0),t||(t=e,e=0),n||={};var r=n.mode||`soft`,i=r===`hard`?/\b/:/(\S+\s+)/;return function(n){return n.toString().split(i).reduce(function(n,i){if(r===`hard`)for(var a=0;a<i.length;a+=t-e)n.push(i.slice(a,a+t-e));else n.push(i);return n},[]).reduce(function(n,r){if(r===``)return n;var i=r.replace(/\t/g,` `),a=n.length-1;if(n[a].length+i.length>t)n[a]=n[a].replace(/\s+$/,``),i.split(/\n/).forEach(function(t){n.push(Array(e+1).join(` `)+t.replace(/^\s+/,``))});else if(i.match(/\n/)){var o=i.split(/\n/);n[a]+=o.shift(),o.forEach(function(t){n.push(Array(e+1).join(` `)+t.replace(/^\s+/,``))})}else n[a]+=i;return n},[Array(e+1).join(` `)]).join(`
|
|
75
|
-
`)}};n.soft=n,n.hard=function(e,t){return n(e,t,{mode:`hard`})}})),ra=__toESM(ta(),1);const ia=(0,__toESM(na(),1).default)(80);function generateHelpMessage(e,t){return`
|
|
76
|
-
${[generateUsageSection(e,t),generateDescriptionSection(t),generateCommandsSection(t),generateArgumentsSection(t),generateOptionsSection(t),generateAliasSection(t),generateConfigSection(t)].filter(e=>!!e).join(`
|
|
13
|
+
`}${encode({help:[...t]},n)}`)}function toRecord(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{result:e}}function withHelp(e,t){if(t.length===0)return e;let{help:n,...r}=e;return{...r,help:[...t]}}function helpLines(e){return e===void 0?[]:typeof e==`string`?[e]:[...e]}function line(e){return e.endsWith(`
|
|
14
|
+
`)?e:`${e}\n`}function formatLookupError(e,t){switch(e.type){case`invalid-key`:return`unknown option ${formatOption(e.key)}`;case`missing-argument`:return`missing required ${formatKey(e.name,t,`argument`)}`;case`extra-arguments`:return`unexpected argument${e.values.length>1?`s`:``}: ${e.values.join(`, `)}`;case`invalid-value`:{let n=e.index===void 0?``:`[${e.index}]`,r=e.value===void 0?``:`, received "${e.value}"`;return`invalid value for ${formatKey(e.key,t)}${n}: ${e.message}${r}`}case`conflicting-options`:return`option ${formatOption(e.key)} cannot be used with option ${formatOption(e.conflictsWith)}`;case`expect-single`:return`${formatKey(e.key,t)} expects a single value, received: ${toArray$1(e.value).join(`, `)}`}}function formatKey(e,t,n=`option`){return t.arguments?.some(t=>t.name===e)||n===`argument`&&!t.options?.[e]?`argument <${e}>`:`option ${formatOption(e)}`}function formatOption(e){return e.length===1?`-${e}`:`--${e}`}function toArray$1(e){return Array.isArray(e)?e:[e]}__name(toArray$1,`toArray`);function wrap(e,t){let n=[``];for(let r of e.split(/(\S+\s+)/)){if(r===``)continue;let e=r.replace(/\t/g,` `),i=n.length-1;if(n[i].length+e.length>t){n[i]=n[i].replace(/\s+$/,``);for(let t of e.split(`
|
|
15
|
+
`))n.push(t.replace(/^\s+/,``))}else if(e.includes(`
|
|
16
|
+
`)){let[t,...r]=e.split(`
|
|
17
|
+
`);n[i]+=t;for(let e of r)n.push(e.replace(/^\s+/,``))}else n[i]+=e}return n.join(`
|
|
18
|
+
`)}function generateHelpMessage(e,t){return`
|
|
19
|
+
${[generateUsageSection(e,t),generateDescriptionSection(t),generateCommandsSection(t),generateArgumentsSection(t),generateOptionsSection(t),generateAliasSection(t),generateConfigSection(t),generateExamplesSection(t)].filter(e=>!!e).join(`
|
|
77
20
|
|
|
78
21
|
`)}
|
|
79
|
-
`}function generateUsageSection(e,t){let n=getCommandNameChain(e,t),r=t.commands&&t.commands.length>0,i=`Usage: ${n.join(` `)}${r?` <command>`:``}`;
|
|
80
|
-
${
|
|
22
|
+
`}function generateUsageSection(e,t){let n=getCommandNameChain(e,t),r=t.commands&&t.commands.length>0,i=`Usage: ${n.join(` `)}${r?` <command>`:``}`;if(t.arguments&&(i+=t.arguments.some(e=>isRequired(e,!0))?` <arguments>`:` [arguments]`),t.options){let e=t.options;i+=Object.keys(e).some(t=>isRequired(e[t],!1))?` <options>`:` [options]`}return i}function isRequired({type:e,default:t},n){return e?!e.isOptional&&t===void 0:n}function generateDescriptionSection(e){return e.description?` ${e.description}`:``}function getCommandNameChain(e,t){let n=[t];for(;t.parent;)n.unshift(t.parent),t=t.parent;return[e,...n.map(e=>e.name).filter(e=>e)]}function generateCommandsSection(e){let t=getCommandsNamesAndAlias(e.commands);return t.length===0?``:`Commands:
|
|
23
|
+
${wrap(t.join(`, `),80)}
|
|
81
24
|
|
|
82
|
-
${(
|
|
83
|
-
`,n=[],r=0;e.arguments.forEach(e=>{let t=
|
|
25
|
+
${(e.name?`${e.name} <command> -h`:` <command> -h`).padEnd(25)}Get help for <command>`}function getCommandsNamesAndAlias(e){let t=[];return e&&e.forEach(e=>{e.alias?t.push(`${e.name} (${e.alias.join(`|`)})`):t.push(e.name)}),t}function generateArgumentsSection(e){if(!e.arguments)return``;let t=`Arguments:
|
|
26
|
+
`,n=[],r=0;e.arguments.forEach(e=>{let t=e.type?formatArgumentDescriptor(e.name,e.type):`<${e.name}>`;r=Math.max(r,t.length),n.push([t,e.description||``])});let i=Math.max(23,r+2);return t+=n.map(e=>` ${e[0].padEnd(i)}${e[1]}`.trimEnd()).join(`
|
|
84
27
|
`),t}function generateOptionsSection(e){if(!e.options)return``;let t=`Options:
|
|
85
|
-
`,n=[],r=0;for(let t in e.options){let i=e.options[t],a=formatKeyValue(t,i),o=formatDescription(i,conflictsOf(t,e.options));n.push([a,o]),r=Math.max(r,a.length)}let i=Math.max(23,r+2);return t+=n.map(e=>` ${
|
|
86
|
-
`),t}function formatKeyValue(e,t){
|
|
87
|
-
${
|
|
88
|
-
${toPrettyType(e.config)}`:``}function toPrettyType(e){return tersify(toTypeObject(e),{maxLength:1/0}).replace(/'/g,``)}function toTypeObject(e){if(isZodObject(e)){let t=e.shape;return reduceByKey(t,(e,n)=>{let r=t[n];return isZodOptional(r)?e[`${n}?`]=toTypeObject(r._def.innerType):e[n]=toTypeObject(r),e},{})}return isZodString(e)?`string`:isZodBoolean(e)?`boolean`:isZodNumber(e)?`number`:isZodArray(e)?isZodObject(e.element)?`Array<${toPrettyType(e.element)}>`:`${toPrettyType(e.element)}[]`:``}function createBuilderUI(e){let t=!0,n=[];return{...e,get displayLevel(){return e.displayLevel},set displayLevel(t){e.displayLevel=t},debug:(...r)=>t?n.push([`debug`,r]):e.debug(...r),info:(...r)=>t?n.push([`info`,r]):e.info(...r),warn:(...r)=>t?n.push([`warn`,r]):e.warn(...r),error:(...r)=>t?n.push([`error`,r]):e.error(...r),dump:()=>{t=!1,n.forEach(([t,n])=>{e[t](...n)})}}}function createUI(e){return e.level=Y.info,{get displayLevel(){return e.level<=Y.none?`none`:e.level<=Y.info?`info`:e.level<=Y.debug?`debug`:`trace`},set displayLevel(t){switch(t){case`none`:e.level=Y.none;break;case`debug`:e.level=Y.debug;break;case`trace`:e.level=Y.trace}},debug:(...t)=>e.debug(...t),info:(...t)=>e.info(...t),warn:(...t)=>e.warn(...t),error:(...t)=>e.error(...t),showHelp:(t,n)=>{let r=generateHelpMessage(t,n);e.info(r)},showVersion(t){e.info(t||`not versioned`)}}}function context(){let e=process.cwd(),t=createStandardLog({logLevel:Y.all,reporters:[createConsoleLogReporter()]}),n,r;return{async loadConfig(e){return(await this.resolveConfig(e)).config},async resolveConfig(t){return n||=resolveConfig({cwd:e,ui:this.ui},t)},async loadPlugins(t,n,i){return r||=loadPlugins({cwd:e,ui:this.ui,registry:n,host:i},t)},cwd:e,exit(e){process.exitCode=e},createCommandUI(e){return createUI(t.getLogger(e))},ui:createBuilderUI(createUI(t.getLogger(`clibuilder`,{writeTo:createColorLogReporter()})))}}function cli(e){return builder(context(),e)}const aa={comma:`,`,tab:` `,pipe:`|`},oa=aa.comma;function escapeString(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`).replace(/[\u0000-\u001F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function isBooleanOrNullLiteral(e){return e===`true`||e===`false`||e===`null`}function setOwnProperty(e,t,n){if(t===`__proto__`){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});return}e[t]=n}const sa=RegExp(`(?:^?|\\n) *#`);var RawString=class{constructor(e){if(sa.test(e))throw TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(e)}`);this.value=e}};function isRawString(e){return e instanceof RawString}const ca=/[\uD800-\uDFFF]/;function normalizeValue(e){if(e===null)return null;if(isRawString(e))return e;if(typeof e==`object`&&e&&`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();if(t!==e)return normalizeValue(t)}if(typeof e==`string`)return assertNoLoneSurrogate(e,`string value`),e;if(typeof e==`boolean`)return e;if(typeof e==`number`)return Object.is(e,-0)?0:Number.isFinite(e)?e:null;if(typeof e==`bigint`)return e>=-(2**53-1)&&e<=2**53-1?Number(e):e.toString();if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(normalizeValue);if(e instanceof Set)return Array.from(e).map(normalizeValue);if(e instanceof Map)return Object.fromEntries(Array.from(e,([e,t])=>[String(e),normalizeValue(t)]));if(isPlainObject(e)){let t={};for(let n in e)Object.hasOwn(e,n)&&(assertNoLoneSurrogate(n,`object key`),setOwnProperty(t,n,normalizeValue(e[n])));return t}return null}function assertNoLoneSurrogate(e,t){if(ca.test(e))for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<55296||r>57343)continue;let i=r<=56319,a=e.charCodeAt(n+1);if(i&&a>=56320&&a<=57343){n++;continue}throw TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${r.toString(16).toUpperCase()} at index ${n}`)}}function isJsonPrimitive(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function isEncodablePrimitive(e){return isJsonPrimitive(e)||isRawString(e)}function isJsonArray(e){return Array.isArray(e)}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!isRawString(e)}function isEmptyObject(e){return Object.keys(e).length===0}function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function isArrayOfPrimitives(e){return e.length===0||e.every(e=>isEncodablePrimitive(e))}function isArrayOfArrays(e){return e.length===0||e.every(e=>isJsonArray(e))}function isArrayOfObjects(e){return e.length===0||e.every(e=>isJsonObject(e))}const la=/^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;function assertValidDelimiter(e){if(!Object.values(aa).includes(e))throw TypeError(`Invalid delimiter ${JSON.stringify(e)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`)}function isValidUnquotedKey(e){return/^[A-Z_][\w.]*$/i.test(e)}function isSafeUnquoted(e,t=oa){return!(!e||/^[ \t]|[ \t]$/.test(e)||isBooleanOrNullLiteral(e)||isNumericLike(e)||e.includes(`:`)||e.includes(`"`)||e.includes(`\\`)||/[[\]{}]/.test(e)||/[\u0000-\u001F]/.test(e)||e.includes(t)||e.startsWith(`-`)||e.startsWith(`#`))}function isNumericLike(e){return la.test(e)}function encodePrimitive(e,t){return isRawString(e)?e.value:e===null?`null`:typeof e==`boolean`||typeof e==`number`?String(e):encodeStringLiteral(e,t)}function encodeStringLiteral(e,t=oa){return isSafeUnquoted(e,t)?e:`"${escapeString(e)}"`}function encodeKey(e){return isValidUnquotedKey(e)?e:`"${escapeString(e)}"`}function encodeAndJoinPrimitives(e,t=oa){return e.map(e=>encodePrimitive(e,t)).join(t)}function formatHeader(e,t){let n=t?.key,r=t?.fields,i=t?.delimiter??`,`,a=``;return n!=null&&(a+=encodeKey(n)),a+=`[${e}${t?.keyed?`:`:``}${i===oa?``:i}]`,r&&(a+=`{${formatFieldSegment(r,i)}}`),a+=`:`,a}function formatFieldSegment(e,t){return e.map(e=>encodeKey(e.name)+(e.children?`{${formatFieldSegment(e.children,t)}}`:``)).join(t)}function extractTabularFields(e){if(e.length===0)return;let t=Object.keys(e[0]);if(t.length===0)return;for(let n of e){if(Object.keys(n).length!==t.length)return;for(let e of t)if(!Object.hasOwn(n,e))return}let n=[];for(let r of t){let t=classifyColumn(r,e.map(e=>e[r]));if(!t)return;n.push(t)}return n}function extractKeyedTabularFields(e){let t=Object.values(e);if(!(t.length<2)&&t.every(e=>isJsonObject(e)&&!isEmptyObject(e)))return extractTabularFields(t)}function collectRowLeaves(e,t){let n=[];return collectLeafValues(e,t,n),n}function classifyColumn(e,t){if(t.every(e=>isEncodablePrimitive(e)))return{name:e};if(!t.every(e=>isJsonObject(e)&&!isEmptyObject(e)))return;let n=extractTabularFields(t);if(n)return{name:e,children:n}}function collectLeafValues(e,t,n){for(let r of t){let t=e[r.name];r.children?collectLeafValues(t,r.children,n):n.push(t)}}function*encodeJsonValue(e,t,n){if(isEncodablePrimitive(e)){let n=encodePrimitive(e,t.delimiter);n!==``&&(yield n);return}if(isJsonArray(e))yield*encodeArrayLines(void 0,e,n,t);else if(isJsonObject(e)){let r=extractKeyedTabularFields(e);if(r){yield*encodeKeyedObjectLines(void 0,e,r,n,t);return}yield*encodeObjectLines(e,n,t)}}function*encodeObjectLines(e,t,n){for(let[r,i]of Object.entries(e))yield*encodeKeyValuePairLines(r,i,t,n)}function*encodeKeyValuePairLines(e,t,n,r){let i=encodeKey(e);if(isEncodablePrimitive(t))yield indentedLine(n,`${i}: ${encodePrimitive(t,r.delimiter)}`,r.indentSize);else if(isJsonArray(t))yield*encodeArrayLines(e,t,n,r);else if(isJsonObject(t)){let a=extractKeyedTabularFields(t);if(a){yield*encodeKeyedObjectLines(e,t,a,n,r);return}yield indentedLine(n,`${i}:`,r.indentSize),isEmptyObject(t)||(yield*encodeObjectLines(t,n+1,r))}}function*encodeKeyedObjectLines(e,t,n,r,i){let a=Object.entries(t);yield indentedLine(r,formatHeader(a.length,{key:e,fields:n,delimiter:i.delimiter,keyed:!0}),i.indentSize),yield*encodeKeyedEntryRowsLines(a,n,r+1,i)}function*encodeKeyedEntryRowsLines(e,t,n,r){for(let[i,a]of e){let e=collectRowLeaves(a,t);yield indentedLine(n,`${encodeKey(i)}: ${encodeAndJoinPrimitives(e,r.delimiter)}`,r.indentSize)}}function*encodeArrayLines(e,t,n,r){if(t.length===0){yield indentedLine(n,e==null?`[]`:`${encodeKey(e)}: []`,r.indentSize);return}if(isArrayOfPrimitives(t)){yield indentedLine(n,encodeInlineArrayLine(t,r.delimiter,e),r.indentSize);return}if(isArrayOfArrays(t)&&t.every(e=>isArrayOfPrimitives(e))){yield*encodeArrayOfArraysAsListItemsLines(e,t,n,r);return}if(isArrayOfObjects(t)){let i=extractTabularFields(t);i?yield*encodeArrayOfObjectsAsTabularLines(e,t,i,n,r):yield*encodeMixedArrayAsListItemsLines(e,t,n,r);return}yield*encodeMixedArrayAsListItemsLines(e,t,n,r)}function*encodeArrayOfArraysAsListItemsLines(e,t,n,r){yield indentedLine(n,formatHeader(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)if(isArrayOfPrimitives(e)){let t=encodeInlineArrayLine(e,r.delimiter);yield indentedListItem(n+1,t,r.indentSize)}}function encodeInlineArrayLine(e,t,n){let r=formatHeader(e.length,{key:n,delimiter:t}),i=encodeAndJoinPrimitives(e,t);return e.length===0?r:`${r} ${i}`}function*encodeArrayOfObjectsAsTabularLines(e,t,n,r,i){yield indentedLine(r,formatHeader(t.length,{key:e,fields:n,delimiter:i.delimiter}),i.indentSize),yield*writeTabularRowsLines(t,n,r+1,i)}function*writeTabularRowsLines(e,t,n,r){for(let i of e)yield indentedLine(n,encodeAndJoinPrimitives(collectRowLeaves(i,t),r.delimiter),r.indentSize)}function*encodeMixedArrayAsListItemsLines(e,t,n,r){yield indentedLine(n,formatHeader(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)yield*encodeListItemValueLines(e,n+1,r)}function*encodeObjectAsListItemLines(e,t,n){if(isEmptyObject(e)){yield indentedLine(t,`-`,n.indentSize);return}let r=Object.entries(e),[i,a]=r[0],o=r.slice(1);if(isJsonArray(a)&&isArrayOfObjects(a)){let e=extractTabularFields(a);if(e){yield indentedListItem(t,formatHeader(a.length,{key:i,fields:e,delimiter:n.delimiter}),n.indentSize),yield*writeTabularRowsLines(a,e,t+2,n),o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n));return}}if(isJsonObject(a)){let e=extractKeyedTabularFields(a);if(e){let r=Object.entries(a);yield indentedListItem(t,formatHeader(r.length,{key:i,fields:e,delimiter:n.delimiter,keyed:!0}),n.indentSize),yield*encodeKeyedEntryRowsLines(r,e,t+2,n),o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n));return}}let s=encodeKey(i);if(isEncodablePrimitive(a))yield indentedListItem(t,`${s}: ${encodePrimitive(a,n.delimiter)}`,n.indentSize);else if(isJsonArray(a)){if(a.length===0)yield indentedListItem(t,`${s}: []`,n.indentSize);else if(isArrayOfPrimitives(a))yield indentedListItem(t,`${s}${encodeInlineArrayLine(a,n.delimiter)}`,n.indentSize);else{yield indentedListItem(t,`${s}${formatHeader(a.length,{delimiter:n.delimiter})}`,n.indentSize);for(let e of a)yield*encodeListItemValueLines(e,t+2,n)}}else isJsonObject(a)&&(yield indentedListItem(t,`${s}:`,n.indentSize),isEmptyObject(a)||(yield*encodeObjectLines(a,t+2,n)));o.length>0&&(yield*encodeObjectLines(Object.fromEntries(o),t+1,n))}function*encodeListItemValueLines(e,t,n){if(isEncodablePrimitive(e))yield indentedListItem(t,encodePrimitive(e,n.delimiter),n.indentSize);else if(isJsonArray(e)){if(isArrayOfPrimitives(e))yield indentedListItem(t,encodeInlineArrayLine(e,n.delimiter),n.indentSize);else{yield indentedListItem(t,formatHeader(e.length,{delimiter:n.delimiter}),n.indentSize);for(let r of e)yield*encodeListItemValueLines(r,t+1,n)}}else isJsonObject(e)&&(yield*encodeObjectAsListItemLines(e,t,n))}function indentedLine(e,t,n){return` `.repeat(n*e)+t}function indentedListItem(e,t,n){return indentedLine(e,`- `+t,n)}function applyReplacer(e,t){let n=t(``,e,[]);return n===void 0?transformChildren(e,t,[]):transformReplaced(e,n,t,[])}function transformReplaced(e,t,n,r){return isRawString(t)&&!isEncodablePrimitive(e)?transformChildren(e,n,r):transformChildren(normalizeValue(t),n,r)}function transformChildren(e,t,n){return isJsonObject(e)?transformObject(e,t,n):isJsonArray(e)?transformArray(e,t,n):e}function transformObject(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=[...n,i],o=t(i,a,e);o!==void 0&&setOwnProperty(r,i,transformReplaced(a,o,t,e))}return r}function transformArray(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=[...n,i],s=t(String(i),a,o);s!==void 0&&r.push(transformReplaced(a,s,t,o))}return r}function encode(e,t){return Array.from(encodeLines(e,t)).join(`
|
|
89
|
-
|
|
90
|
-
`)
|
|
91
|
-
`)}__name(renderText$1,`renderText`);function collapseHome$1(e,t){return e&&t.startsWith(e+w)?`~${t.slice(e.length)}`:t}__name(collapseHome$1,`collapseHome`);function displayBinPath(e,t){return t?collapseHome$1(e,t):`buddy-agent-harness`}var X=__commonJSMin((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),isAlias=e=>!!e&&typeof e==`object`&&e[s]===t,isDocument=e=>!!e&&typeof e==`object`&&e[s]===n,isMap=e=>!!e&&typeof e==`object`&&e[s]===r,isPair=e=>!!e&&typeof e==`object`&&e[s]===i,isScalar=e=>!!e&&typeof e==`object`&&e[s]===a,isSeq=e=>!!e&&typeof e==`object`&&e[s]===o;function isCollection(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function isNode(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}let hasAnchor=e=>(isScalar(e)||isCollection(e))&&!!e.anchor;e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=hasAnchor,e.isAlias=isAlias,e.isCollection=isCollection,e.isDocument=isDocument,e.isMap=isMap,e.isNode=isNode,e.isPair=isPair,e.isScalar=isScalar,e.isSeq=isSeq})),da=__commonJSMin((e=>{var t=X();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function visit(e,n){let r=initVisitor(n);t.isDocument(e)?visit_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):visit_(null,e,r,Object.freeze([]))}visit.BREAK=n,visit.SKIP=r,visit.REMOVE=i;function visit_(e,r,a,o){let s=callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visit_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=visit_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=visit_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=visit_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}async function visitAsync(e,n){let r=initVisitor(n);t.isDocument(e)?await visitAsync_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await visitAsync_(null,e,r,Object.freeze([]))}visitAsync.BREAK=n,visitAsync.SKIP=r,visitAsync.REMOVE=i;async function visitAsync_(e,r,a,o){let s=await callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visitAsync_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await visitAsync_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await visitAsync_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await visitAsync_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function initVisitor(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function callVisitor(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function replaceNode(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=visit,e.visitAsync=visitAsync})),fa=__commonJSMin((e=>{var t=X(),n=da();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},escapeTagName=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var i=class Directives{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Directives.defaultYaml,e),this.tags=Object.assign({},Directives.defaultTags,t)}clone(){let e=new Directives(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Directives(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},Directives.defaultTags)}return e}add(e,t){this.atNextDocument&&=(this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},Directives.defaultTags),!1);let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case`%TAG`:{if(n.length!==2&&(t(0,`%TAG directive should contain exactly two parts`),n.length<2))return!1;let[e,r]=n;return this.tags[e]=r,!0}case`%YAML`:{if(this.yaml.explicit=!0,n.length!==1)return t(0,`%YAML directive should contain exactly one part`),!1;let[e]=n;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let n=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,n),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+escapeTagName(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
92
|
-
`)}};i.defaultYaml={explicit:!1,version:`1.2`},i.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=i})),pa=__commonJSMin((e=>{var t=X(),n=da();function anchorIsValid(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function anchorNames(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function findNewAnchor(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function createNodeAnchors(e,n){let r=[],i=new Map,a=null;return{onAnchor:t=>{r.push(t),a??=anchorNames(e);let i=findNewAnchor(n,a);return a.add(i),i},setAnchors:()=>{for(let e of r){let n=i.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:i}}e.anchorIsValid=anchorIsValid,e.anchorNames=anchorNames,e.createNodeAnchors=createNodeAnchors,e.findNewAnchor=findNewAnchor})),ma=__commonJSMin((e=>{function applyReviver(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=applyReviver(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=applyReviver(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=applyReviver(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=applyReviver(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}e.applyReviver=applyReviver})),ha=__commonJSMin((e=>{var t=X();function toJS(e,n,r){if(Array.isArray(e))return e.map((e,t)=>toJS(e,String(t),r));if(e&&typeof e.toJSON==`function`){if(!r||!t.hasAnchor(e))return e.toJSON(n,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=e=>{i.res=e,delete r.onCreate};let a=e.toJSON(n,r);return r.onCreate&&r.onCreate(a),a}return typeof e==`bigint`&&!r?.keep?Number(e):e}e.toJS=toJS})),ga=__commonJSMin((e=>{var t=ma(),n=X(),r=ha(),NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}};e.NodeBase=NodeBase})),_a=__commonJSMin((e=>{var t=pa(),n=da(),r=X(),i=ga(),a=ha(),Alias=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let s=n.get(o);if(s||=(a.toJS(o,null,t),n.get(o)),s?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=getAliasCount(r,o,n)),s.count*s.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return s.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function getAliasCount(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=getAliasCount(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=getAliasCount(e,t.key,n),i=getAliasCount(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=Alias})),Z=__commonJSMin((e=>{var t=X(),n=ga(),r=ha();let isScalarValue=e=>!e||typeof e!=`function`&&typeof e!=`object`;var Scalar=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};Scalar.BLOCK_FOLDED=`BLOCK_FOLDED`,Scalar.BLOCK_LITERAL=`BLOCK_LITERAL`,Scalar.PLAIN=`PLAIN`,Scalar.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Scalar.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=Scalar,e.isScalarValue=isScalarValue})),va=__commonJSMin((e=>{var t=_a(),n=X(),r=Z();function findTagObject(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function createNode(e,i,a){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=a.schema[n.MAP].createNode?.(a.schema,null,a);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:s,onTagObj:c,schema:l,sourceObjects:u}=a,d;if(o&&e&&typeof e==`object`){if(d=u.get(e),d)return d.anchor??(d.anchor=s(e)),new t.Alias(d.anchor);d={anchor:null,node:null},u.set(e,d)}i?.startsWith(`!!`)&&(i=`tag:yaml.org,2002:`+i.slice(2));let p=findTagObject(e,i,l.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return d&&(d.node=t),t}p=e instanceof Map?l[n.MAP]:Symbol.iterator in Object(e)?l[n.SEQ]:l[n.MAP]}c&&(c(p),delete a.onTagObj);let m=p?.createNode?p.createNode(a.schema,e,a):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(a.schema,e,a):new r.Scalar(e);return i?m.tag=i:p.default||(m.tag=p.tag),d&&(d.node=m),m}e.createNode=createNode})),ya=__commonJSMin((e=>{var t=va(),n=X(),r=ga();function collectionFromPath(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let isEmptyPath=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(isEmptyPath(e))this.add(t);else{let[r,...i]=e,a=this.get(r,!0);if(n.isCollection(a))a.addIn(i,t);else if(a===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(i,t);else if(e===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};e.Collection=Collection,e.collectionFromPath=collectionFromPath,e.isEmptyPath=isEmptyPath})),ba=__commonJSMin((e=>{let stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function indentComment(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}let lineComment=(e,t,n)=>e.endsWith(`
|
|
28
|
+
`,n=[],r=0;for(let t in e.options){let i=e.options[t],a=formatKeyValue(t,i),o=formatDescription(i,conflictsOf(t,e.options));n.push([a,o]),r=Math.max(r,a.length)}let i=Math.max(23,r+2);return t+=n.map(e=>` ${e[0].padEnd(i)}${e[1]}`).join(`
|
|
29
|
+
`),t}function formatKeyValue(e,t){let n=[...t.alias?t.alias.map(e=>typeof e==`string`?e:e.hidden?void 0:e.alias).filter(e=>e):[],e].sort((e,t)=>e.length-t.length).map(e=>e.length===1?`-${e}`:`--${e}`).join(`|`);return t.type?formatOptionDescriptor(n,t.type,isRequired(t,!1)):`[${n}]`}function formatOptionDescriptor(e,t,n){let r=`${e}${takesValue$1(t)?` <${describeConstraint(t)}>`:``}${t.kind===`array`?`...`:``}`;return n?r:`[${r}]`}function formatArgumentDescriptor(e,t){let n=`${e}: ${describeConstraint(t)}${t.kind===`array`?`...`:``}`;return t.isOptional?`[${n}]`:`<${n}>`}function formatDescription(e,t){let n=typeof e.default==`string`?`'${e.default}'`:e.default,r=e.default?`${e.description} (default ${n})`:e.description;return t.length===0?r:`${r} (conflicts with ${t.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `)})`}function conflictsOf(e,t){return Object.keys(t).filter(n=>n!==e&&(t[e].conflicts?.includes(n)||t[n].conflicts?.includes(e)))}function generateAliasSection(e){return e.alias?`Alias:
|
|
30
|
+
${wrap(e.alias.join(`, `),80)}`:``}function generateConfigSection(e){let t=describeConfig(e);return t===void 0?``:`Config:
|
|
31
|
+
${t}`}function describeConfig(e){if(e.config)return describeStandardConfig(e.config)}function generateExamplesSection(e){return!e.examples||e.examples.length===0?``:`Examples:
|
|
32
|
+
${e.examples.map(e=>` ${e.description}\n ${e.command}`).join(`
|
|
33
|
+
`)}`}function describeStandardConfig(e){let t=e[`~standard`]?.jsonSchema;if(t)try{return describeJsonSchema(t.input({target:`draft-2020-12`}))}catch{return}}function describeJsonSchema(e){if(Array.isArray(e.enum))return e.enum.map(e=>JSON.stringify(e)).join(` | `);if(`const`in e)return JSON.stringify(e.const);let t=e.anyOf??e.oneOf;if(Array.isArray(t))return t.map(describeJsonSchema).join(` | `);switch(e.type){case`object`:{let t=e.properties??{},n=e.required??[],r=Object.keys(t).map(e=>`${e}${n.includes(e)?``:`?`}: ${describeJsonSchema(t[e])}`);return r.length===0?`{}`:`{ ${r.join(`, `)} }`}case`array`:{let t=e.items&&typeof e.items==`object`?e.items:{};return t.type===`object`?`Array<${describeJsonSchema(t)}>`:`${describeJsonSchema(t)}[]`}case`string`:case`boolean`:case`number`:case`null`:return e.type;case`integer`:return`number`;default:return`unknown`}}function generateHelpModel(e,t,n){let r={name:getCommandNameChain(e,t).join(` `),usage:generateUsageSection(e,t).slice(7)};t.description&&(r.description=t.description),t.alias&&t.alias.length>0&&(r.aliases=[...t.alias]),t.commands&&t.commands.length>0&&(r.commands=t.commands.map(e=>{let t={name:e.name};e.alias&&e.alias.length>0&&(t.aliases=[...e.alias]);let n=e.description?.split(`
|
|
34
|
+
`)[0];return n&&(t.description=n),t})),t.arguments&&t.arguments.length>0&&(r.arguments=t.arguments.map(e=>{let t={name:e.name,required:isRequired(e,!0),...describeType(e.type)};return e.description&&(t.description=e.description),t}));let i=!t.parent&&!t.name,a=optionModels(t.options,i?Object.keys(n):[]);a.length>0&&(r.options=a);let o=describeConfig(t);return o!==void 0&&(r.config=o),t.examples&&t.examples.length>0&&(r.examples=t.examples.map(({command:e,description:t})=>({command:e,description:t}))),r.globalOptions=optionModels(n,[]),r}function optionModels(e,t){return e?Object.keys(e).filter(e=>!t.includes(e)).map(t=>{let n=e[t],r={name:t},i=(n.alias??[]).map(e=>typeof e==`string`?e:e.hidden?void 0:e.alias).filter(e=>!!e);i.length>0&&(r.aliases=i),Object.assign(r,describeType(n.type)),r.required=isRequired(n,!1),n.default!==void 0&&(r.default=n.default),n.description&&(r.description=n.description);let a=conflictsOf(t,e);return a.length>0&&(r.conflicts=a),r}):[]}function describeType(e){return e?describeData(e):{}}function describeData(e){switch(e.kind){case`string`:return e.pattern?{type:`string`,pattern:String(e.pattern)}:{type:`string`};case`number`:case`int`:{let t={type:e.kind};return e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),t}case`literal`:return{type:`literal`,values:[e.value]};case`enum`:return{type:`enum`,values:[...e.values]};case`array`:return{...describeData(e.element),array:!0};default:return{type:e.kind}}}const Oe={"invalid-key":0,"conflicting-options":1,"invalid-value":2,"expect-single":3,"missing-argument":4,"extra-arguments":5};function topUsageError(e){return e.reduce((e,t)=>!e||Oe[t.type]<Oe[e.type]?t:e,void 0)}const ke={"invalid-key":`unknown-option`,"conflicting-options":`conflicting-options`,"invalid-value":`invalid-value`,"expect-single":`expect-single`,"missing-argument":`missing-argument`,"extra-arguments":`extra-arguments`};function usageErrorCode(e){return ke[e.type]}function describeUsageError(e,t,n){let r=generateUsageSection(n,t),i=formatLookupError(e,t),a=usageErrorCode(e);switch(e.type){case`invalid-key`:return{message:i,code:a,details:{option:optionName(e.key)},help:[r,optionsHelp(t,n)]};case`conflicting-options`:return{message:i,code:a,details:{option:optionName(e.key),conflictsWith:optionName(e.conflictsWith)},help:[r]};case`invalid-value`:{let n=keyName(e.key,t);return{message:i,code:a,details:{...n.details,...e.value===void 0?{}:{value:rawValue(e.value)}},help:[r,...valueHelp(e,n.label)]}}case`expect-single`:return{message:i,code:a,details:{...keyName(e.key,t).details,value:toArray(e.value).map(String)},help:[r]};case`missing-argument`:return!t.arguments?.some(t=>t.name===e.name)&&t.options?.[e.name]?{message:i,code:a,details:{option:optionName(e.name)},help:[r,optionsHelp(t,n)]}:{message:i,code:a,details:{argument:e.name},help:[r,argumentsHelp(t,n)]};case`extra-arguments`:return{message:i,code:a,details:{arguments:e.values},help:[r,argumentsHelp(t,n)]}}}function describeMissingCommand(e,t){let n=commandName(e,t),r=(e.commands??[]).map(e=>e.name);return{message:`missing command for \`${n}\``,code:`missing-command`,details:{command:n},help:[generateUsageSection(t,e),r.length>0?`valid commands for \`${n}\`: ${r.join(`, `)}`:`\`${n}\` has no commands (--help always allowed)`]}}function optionName(e){return e.length===1?`-${e}`:`--${e}`}function keyName(e,t){return t.arguments?.some(t=>t.name===e)?{label:`<${e}>`,details:{argument:e}}:{label:optionName(e),details:{option:optionName(e)}}}function commandName(e,t){let n=[];for(let t=e;t;t=t.parent)t.name&&n.unshift(t.name);return[t,...n].join(` `)}function isOptional(e){return!!e?.isOptional}function argumentsHelp(e,t){let n=e.name||t,r=(e.commands??[]).map(e=>e.name);if(!e.arguments?.length&&r.length>0)return`valid commands for \`${n}\`: ${r.join(`, `)}`;let i=(e.arguments??[]).map(e=>isOptional(e.type)?`[${e.name}]`:`<${e.name}>`);return i.length>0?`\`${n}\` takes: ${i.join(` `)}`:`\`${n}\` takes no arguments`}function optionsHelp(e,t){let n=e.name||t,r=Object.keys(e.options??{}).map(optionName);return r.length>0?`valid options for \`${n}\`: ${r.join(`, `)} (--help always allowed)`:`\`${n}\` takes no options (--help always allowed)`}function valueHelp(e,t){let n=e.index===void 0?``:`[${e.index}]`,r=e.value===void 0?``:` (received ${toArray(e.value).map(quote).join(`, `)})`;return e.allowed?.length?[`allowed for ${t}${n}: ${e.allowed.join(`, `)}${r}`]:e.constraint?[`expected for ${t}${n}: ${e.constraint}${r}`]:[]}function rawValue(e){return Array.isArray(e)?e.map(String):String(e)}function quote(e){return`"${String(e)}"`}function toArray(e){return Array.isArray(e)?e:[e]}function state(e){let{name:t,description:n=``,version:r}=e;return{name:t,description:n,version:r,displayLevel:`info`,command:getBaseCommand(n,{format:e.format})}}function resolveGlobalOptions(e,t,n){let r=lookupCommand(e,t);convertDescriptorsSync(r);let{args:i,errors:a}=r,o=a.filter(t=>`key`in t&&isDeclared(e,t.key)).map(withAllowedFormats(e)),s=!o.some(t=>`key`in t&&isGlobalFormatKey(e,t.key));return{help:i.help,version:i.version,verbose:i.verbose,silent:i.silent,"debug-cli":i[`debug-cli`],values:i,format:s&&i.format||n,errors:o}}function resolveUsageErrors(e,t,n,r){return e.flatMap(e=>!(`key`in e)||!isDeclared(n,e.key)||isOwn(t,e.key)?[e]:r.errors.filter(t=>`key`in t&&t.key===e.key)).map(withCode)}function withCode(e){return Object.defineProperty(e,"code",{value:usageErrorCode(e),enumerable:!1,configurable:!0})}function isDeclared(e,t){return lookupOptions(e,t).length>0}function isOwn(e,t){let[n,r]=lookupOptions(e,t);return!!n&&!isGlobalFormatEntry(r)}function isGlobalFormatKey(e,t){return isGlobalFormatEntry(lookupOptions(e,t)[1])}function withAllowedFormats(e){return t=>t.type===`invalid-value`&&isGlobalFormatKey(e,t.key)?{...t,allowed:Se}:t}function builder(e,t){let n=state(t),r=t.format??`toon`,i=t.output??`axi`;if(!Se.includes(r))throw TypeError(`cli({ format }) must be one of ${Se.join(`, `)}, received ${String(r)}`);let a=n.description,o=createRegistry(),s=new Map,c=[],l={},u={},d=[],f=n.command.options,p,m=!1;return{name:n.name,version:n.version||``,description:a,default(e){return n.command=adjust(n.command,{...n.command,...e}),delete this.default,{...this,parse}},command(e){return n.command.commands.push(adjust(n.command,e)),{...this,parse}},use(e){return c.push(e),{...this,parse}}};function extend(){return p??=(async()=>{let t={host:{name:n.name,version:n.version||``},cwd:e.cwd,ui:createExtensionUI(e,n),registry:o,shared:{get:e=>s.get(e.id),set(e,t){s.set(e.id,t)},has:e=>s.has(e.id)},addCommand(e){n.command.commands.push(adjust(n.command,e))},addGlobalOption(e,t,n){l[e]=t,u[e]=n},beforeRun(e){d.push(e)},async resolveConfig(){return m=!0,s.get(Te.id)??{config:void 0,source:{type:`none`},candidates:[]}}};for(let e of c)await e(t);listGlobalOptions(),warnUnloadedPlugins()})()}function listGlobalOptions(){if(Object.keys(l).length===0)return;let{format:e,...t}=f;for(let e of Object.keys(f))delete f[e];Object.assign(f,t,l,{format:e})}function warnUnloadedPlugins(){let t=s.get(Te.id)?.config?.plugins;!m&&Array.isArray(t)&&t.length!==0&&e.ui.warn(`the config lists plugins, but this cli loads none. Plugin loading moved out of clibuilder 12 into @clibuilder/plugins: add .use(plugins()) to the cli.`)}async function parse(a){if(isBareVersion(a)){e.writeStdout(`${n.version||`not versioned`}\n`);return}e.ui.debug(`argv:`,a.join(` `));let c=parseArgv(a);await extend();let f=getBaseCommand(n.description,{format:r,options:l}),p=resolveGlobalOptions(f,c,r);p.silent&&(delete c.silent,n.displayLevel=`none`),p.verbose&&(delete c.verbose,n.displayLevel=`debug`),p[`debug-cli`]&&(delete c[`debug-cli`],n.displayLevel=`trace`),e.ui.displayLevel=n.displayLevel,e.ui.dump();for(let t of Object.keys(u)){let r=p.values[t];if(r===void 0)continue;let a=createCommandUI(e,n,n.command);return answer(await u[t]({value:r,format:p.format,output:i,ui:a}),p.format)}let m=lookupCommand(n.command,c,f),{args:h,command:g}=m,_=peekFlags(m,[`help`,`version`]);if(p.version||_.version)return i===`axi`?writeVersion():createCommandInstance(e,n,m.command,o).ui.showVersion();if(p.help||_.help)return i===`axi`?writeHelp(m.command,f,p.format):createCommandInstance(e,n,m.command,o).ui.showHelp();await convertDescriptors(m);let v=resolveUsageErrors(m.errors,g,f,p);if(v.length>0){let r=createCommandInstance(e,n,m.command,o).ui,a=findUsageErrorHandler(g)??t.onUsageError;if(a){let e=await a(v,{command:g,ui:r,format:p.format,exitCode:D.usage});return exit(typeof e==`number`?e:D.usage)}if(i===`axi`)return writeReport(describeUsageError(topUsageError(v),g,n.name),p.format),exit(D.usage);for(let e of v)r.error(formatLookupError(e,g));return r.showHelp(),exit(D.usage)}if(g.config&&!s.has(Te.id)){let e=g.name?`command '${g.name}'`:`the default command`;throw Error(`${e} declares config, but the cli does not load config. Add .use(config()) from 'clibuilder/config' to the cli.`)}if(d.length>0){let t=createCommandInstance(e,n,m.command,o).ui,r={command:g,config:n.config,format:p.format,output:i,ui:t};try{for(let e of d)await e(r)}catch(e){if(!isCliError(e))throw e;return reportCliError(e,p.format,t),exit(e.exitCode)}n.config=r.config}let y=createCommandInstance(e,n,g,o,p.format,i);if(!y.run)return i===`axi`?writeReport(describeMissingCommand(g,n.name),p.format):y.ui.showHelp(),exit(D.usage);i===`axi`&&(y.ui.showHelp=()=>writeHelp(g,f,p.format),y.ui.showVersion=()=>writeVersion());try{return answer(await y.run(h),p.format)}catch(e){if(!isCliError(e))throw e;return reportCliError(e,p.format,y.ui),exit(e.exitCode)}}function reportCliError(t,n,r){if(!isReportedCliError(t)){if(i===`axi`){let i=errorOutput({message:t.message,code:t.code??`error`,details:t.details,help:t.help});e.writeStdout(`${encode(i,n)}\n`),r.debug(t);return}r.error(t.message);for(let e of t.help)r.error(e)}}function writeReport(t,n){e.writeStdout(`${encode(errorOutput(t),n)}\n`)}function answer(t,n){if(i===`axi`){let r=printAnswer(t,n);r!==void 0&&e.writeStdout(r)}return answerValue(t)}function writeHelp(t,r,i){e.writeStdout(i===`text`?`${generateHelpMessage(n.name,t)}\n`:`${encode(generateHelpModel(n.name,t,r.options),i)}\n`)}function writeVersion(){e.writeStdout(`${n.version||`not versioned`}\n`)}function exit(t){return e.exit(t),t}function adjust(e,t){return adjustCommand(e,t)}}function isBareVersion(e){let t=e.slice(2);return t.length===1&&(t[0]===`--version`||t[0]===`-v`)}function createExtensionUI(e,t){let n=e.ui;return{get displayLevel(){return n.displayLevel},set displayLevel(e){n.displayLevel=e},info:(...e)=>n.info(...e),warn:(...e)=>n.warn(...e),error:(...e)=>n.error(...e),debug:(...e)=>n.debug(...e),showHelp:()=>n.showHelp(t.name,t.command),showVersion:()=>n.showVersion(t.version)}}function findUsageErrorHandler(e){for(let t=e;t;t=t.parent)if(t.onUsageError)return t.onUsageError}function createCommandInstance(e,t,n,r,i=`toon`,a=`axi`){return{...n,run:n.run,ui:createCommandUI(e,t,n),format:i,output:a,config:t.config,cwd:e.cwd,registry:r}}function createCommandUI(e,t,n){let r=e.createCommandUI(n.name||t.name);return r.displayLevel=t.displayLevel,{...r,showVersion:()=>r.showVersion(t.version),showHelp:()=>r.showHelp(t.name,n)}}function adjustCommand(e,t){return t=yieldToGlobalFormat(t),t.name&&(t.parent=e),t.commands&&(t.commands=t.commands.map(e=>adjustCommand(t,e))),t}function createBuilderUI(e){let t=!0,n=[];return{...e,get displayLevel(){return e.displayLevel},set displayLevel(t){e.displayLevel=t},debug:(...r)=>t?n.push([`debug`,r]):e.debug(...r),info:(...r)=>t?n.push([`info`,r]):e.info(...r),warn:(...r)=>t?n.push([`warn`,r]):e.warn(...r),error:(...r)=>t?n.push([`error`,r]):e.error(...r),dump:()=>{t=!1;for(let[t,r]of n.splice(0))e[t](...r)}}}const Ae={console:{debug:`stdout`,info:`stdout`,warn:`stderr`,error:`stderr`,answer:`stdout`},axi:{debug:`stderr`,info:`stderr`,warn:`stderr`,error:`stderr`,answer:`stdout`}},je={none:0,info:1,debug:2,trace:3},Me={error:1,warn:1,info:1,answer:1,debug:2},Ne={error:`red`,warn:`yellow`};function createStreamUI(e,t){let n=`info`,r=Ae[t];function write(t,i){if(Me[t]>je[n])return;let a=e[r[t]],o=formatLine(i,a.colour),s=Ne[t];a.write(`${s&&a.colour?h(s,o,{validateStream:!1}):o}\n`)}return{get displayLevel(){return n},set displayLevel(e){n=e},debug:(...e)=>write(`debug`,e),info:(...e)=>write(`info`,e),warn:(...e)=>write(`warn`,e),error:(...e)=>write(`error`,e),showHelp(e,t){write(`answer`,[generateHelpMessage(e,t)])},showVersion(e){write(`answer`,[e||`not versioned`])}}}function formatLine(e,t){return e.map(e=>typeof e==`object`&&e?m(e,{colors:t}):e).join(` `)}function shouldColour(e,t=process.env){if(!e.isTTY)return!1;let n=t.FORCE_COLOR;return n===void 0?t.NO_COLOR?!1:typeof e.hasColors!=`function`||e.hasColors(t):n!==`0`&&n!==`false`}function createSinks(e,t=process.env){return e.stdout===process.stdout&&handleEpipe(process.stdout),{stdout:createSink(e.stdout,t),stderr:createSink(e.stderr,t)}}function createSink(e,t){return{colour:shouldColour(e,t),write(t){Fe.has(e)||e.write(t)}}}const Pe=new WeakSet,Fe=new WeakSet;function handleEpipe(e){Pe.has(e)||(Pe.add(e),e.on(`error`,t=>{if(t?.code!==`EPIPE`)throw t;Fe.add(e),process.exitCode=0}))}function context(e={}){let t=process.cwd(),n=createSinks(e.streams??{stdout:process.stdout,stderr:process.stderr}),r=e.output??`axi`;return{cwd:t,exit(e){process.exitCode=e},writeStdout(e){n.stdout.write(e)},createCommandUI(){return createStreamUI(n,r)},ui:createBuilderUI(createStreamUI(n,r))}}function cli(e){return builder(context({streams:e.streams,output:e.output}),e)}function fail$1(e,t){throw isCliError(e)?e:(process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),O.reported(D.error))}__name(fail$1,`fail`);function answerThenFail$1(e,t){let n=printAnswer(e,t);throw n!==void 0&&process.stdout.write(n),O.reported(D.error)}__name(answerThenFail$1,`answerThenFail`);function collapseHome$1(e,t){return e&&t.startsWith(e+w)?`~${t.slice(e.length)}`:t}__name(collapseHome$1,`collapseHome`);function displayBinPath(e,t){return t?collapseHome$1(e,t):`buddy-agent-harness`}var __commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ie=e(import.meta.url);function resolveHarnessEnvironment(e={}){return{env:e.env??process.env,homedir:e.homedir??g(),cwd:e.cwd??process.cwd(),platform:e.platform??process.platform}}function managedPolicyLocations(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;return Le[e](n,r)}const joinFor=e=>e===`win32`?T.join:x.join,dirnameFor=e=>e===`win32`?T.dirname:x.dirname;function opencodeFamily(e,t,n,r){let i={darwin:`/Library/Application Support/${n}`,linux:`/etc/${n}`,win32:T.join(t.ProgramData??`C:\\ProgramData`,n)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`ai.opencode.managed`,description:`MDM configuration profile; outranks the managed config folder`,research:r.preferences}),...when(i!==void 0,{kind:`directory`,location:i??``,description:`Managed config files; outrank user and project config`,research:r.directory})]}function geminiFamily(e,t,n){let r=e===`darwin`||e===`win32`?n.dirs[e]:n.dirs.linux,i=t[n.settingsVariable]||joinFor(e)(r,`settings.json`),a=t[n.defaultsVariable]||joinFor(e)(dirnameFor(e)(i),`system-defaults.json`);return[{kind:`file`,location:i,description:`System settings; outrank user and workspace settings. ${n.settingsVariable} overrides the path`,research:n.research},{kind:`file`,location:a,description:`System defaults; user and workspace settings override them. ${n.defaultsVariable} overrides the path`,research:n.research}]}const when=(e,...t)=>e?t:[],Le={"claude-code":e=>{let t={darwin:`/Library/Application Support/ClaudeCode`,linux:`/etc/claude-code`,win32:`C:\\Program Files\\ClaudeCode`}[e],n=joinFor(e);return[{kind:`server`,location:`claude.ai admin console or a self-hosted Claude apps gateway`,description:`Server-managed settings; the highest-ranked managed source`,research:`E-CC-M6`},...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.anthropic.claudecode`,description:`MDM configuration profile with the same top-level keys as managed-settings.json`,research:`E-CC-M6`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\ClaudeCode`,description:`MDM or Group Policy; the Settings value holds managed-settings JSON`,research:`E-CC-M6`}),...when(t!==void 0,{kind:`file`,location:n(t??``,`managed-settings.json`),description:`Managed settings, same shape as settings.json`,research:`E-CC-M1`},{kind:`directory`,location:n(t??``,`managed-settings.d`),description:`Drop-in managed settings files, merged with managed-settings.json`,research:`E-CC-M1`},{kind:`file`,location:n(t??``,`managed-mcp.json`),description:`Managed MCP servers`,research:`E-CC-M1`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKCU\\SOFTWARE\\Policies\\ClaudeCode`,description:`User-writable; used only when no other managed source delivers a policy key`,research:`E-CC-M6`})]},cursor:e=>{let t={darwin:`/Library/Application Support/Cursor/hooks.json`,linux:`/etc/cursor/hooks.json`,win32:`C:\\ProgramData\\Cursor\\hooks.json`}[e];return[...when(t!==void 0,{kind:`file`,location:t??``,description:`Enterprise hooks deployed by MDM; hooks only, not other enterprise settings`,research:`E-CUR-M1`}),{kind:`server`,location:`Cursor dashboard`,description:`Team hooks and other enterprise settings, synced from the dashboard`,research:`E-CUR-M1`}]},codex:(e,t)=>{let n={kind:`server`,location:`ChatGPT workspace admin settings`,description:`Cloud-managed requirements; outrank every local source`,research:`E-CODEX-M8`};return e===`win32`?[n,{kind:`file`,location:T.join(t.ProgramData??`C:\\ProgramData`,`OpenAI`,`Codex`,`requirements.toml`),description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M4`}]:[n,...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.openai.codex`,description:`MDM keys requirements_toml_base64 (enforced) and config_toml_base64 (managed defaults)`,research:`E-CODEX-M6`}),{kind:`file`,location:`/etc/codex/requirements.toml`,description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M3`},{kind:`file`,location:`/etc/codex/managed_config.toml`,description:`Managed defaults; a user can override them within a session`,research:`E-CODEX-M2`},{kind:`file`,location:`/etc/codex/config.toml`,description:`System-wide config`,research:`E-CODEX-M1`}]},"copilot-cli":(e,t)=>{let n={darwin:`/Library/Application Support/GitHubCopilot/managed-settings.json`,linux:`/etc/github-copilot/managed-settings.json`,win32:T.join(t.ProgramFiles??`C:\\Program Files`,`GitHubCopilot`,`managed-settings.json`)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.github.copilot`,description:`MDM-managed settings; the highest-ranked source`,research:`E-COPILOT-M2`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\GitHubCopilot`,description:`MDM-managed settings as REG_SZ values; the highest-ranked source`,research:`E-COPILOT-M2`}),{kind:`server`,location:`copilot/managed-settings.json in the enterprise's .github-private repository`,description:`Server-managed settings, fetched for the signed-in account`,research:`E-COPILOT-M3`},...when(n!==void 0,{kind:`file`,location:n??``,description:`File-based managed settings; on macOS and Linux it must be a root-owned regular file`,research:`E-COPILOT-M1`})]},opencode:(e,t)=>[...opencodeFamily(e,t,`opencode`,{directory:`E-OC-M1`,preferences:`E-OC-M1`}),{kind:`server`,location:`Remote config at the organization domain /.well-known/opencode`,description:`Organization defaults; the lowest-ranked config source, so user config overrides them`,research:`E-OC-M2`}],kilo:(e,t)=>opencodeFamily(e,t,`kilo`,{directory:`E-KILO-M1`,preferences:`E-KILO-M2`}),"gemini-cli":(e,t)=>geminiFamily(e,t,{settingsVariable:`GEMINI_CLI_SYSTEM_SETTINGS_PATH`,defaultsVariable:`GEMINI_CLI_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/GeminiCli`,linux:`/etc/gemini-cli`,win32:`C:\\ProgramData\\gemini-cli`},research:`E-GEM-M1`}),"qwen-code":(e,t)=>geminiFamily(e,t,{settingsVariable:`QWEN_CODE_SYSTEM_SETTINGS_PATH`,defaultsVariable:`QWEN_CODE_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/QwenCode`,linux:`/etc/qwen-code`,win32:`C:\\ProgramData\\qwen-code`},research:`E-QWEN-M1`}),"vscode-copilot":e=>[...when(e===`win32`,{kind:`windows-registry`,location:`Software\\Policies\\Microsoft\\VSCode`,description:`VS Code policies set by Group Policy (ADMX templates ship with VS Code)`,research:`E-VSC-M1`}),...when(e===`linux`,{kind:`file`,location:`/etc/vscode/policy.json`,description:`VS Code policies as JSON, read by VS Code 1.106 and later`,research:`E-VSC-M3`})],cline:()=>[{kind:`server`,location:`Cline Enterprise admin console`,description:`Provider, model, and tool policy pushed to clients; no local policy file is documented`,research:`E-CLINE-M1`}],crush:e=>when(e!==`win32`,{kind:`file`,location:`/etc/crush/crush.json`,description:`System config; the lowest-ranked source, so user and project config override it`,research:`E-CRUSH-M1`}),openhands:()=>[{kind:`server`,location:`OpenHands Cloud or Enterprise deployment`,description:`Organization controls held server-side; no local policy file is known`,research:`E-OH-D8`}],augment:(e,t)=>[{kind:`file`,location:e===`win32`?T.join(t.ProgramData||`C:\\ProgramData`,`augment`,`settings.json`):`/etc/augment/settings.json`,description:`System settings, read from the Auggie CLI bundle; its rank against user settings is not documented`,research:`E-AUG-M1`}]};async function readText(e){try{return await E(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}function stripJsonComments$1(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`"`){let r=n+1;for(;r<e.length&&e[r]!==`"`;)r+=e[r]===`\\`?2:1;t+=e.slice(n,r+1),n=r+1}else if(r===`/`&&e[n+1]===`/`)for(;n<e.length&&e[n]!==`
|
|
35
|
+
`;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2}else t+=r,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}__name(stripJsonComments$1,`stripJsonComments`);function isRecord$1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}__name(isRecord$1,`isRecord`);function pluginStorage(e,t={}){return Re[e](resolveHarnessEnvironment(t))}const xdgConfig=({env:e,homedir:t})=>e.XDG_CONFIG_HOME||b(t,`.config`);function vscodeAgentPlugins({env:e,homedir:t,platform:n}){if(n===`win32`){let n=T.join(e.APPDATA||T.join(t,`AppData`,`Roaming`),`Code`);return{configDir:n,path:T.join(n,`agentPlugins`)}}let r=n===`darwin`?b(t,`Library`,`Application Support`,`Code`):b(t,`.config`,`Code`);return{configDir:r,path:b(r,`agentPlugins`)}}const Re={"claude-code":({env:e,homedir:t})=>{let n=e.CLAUDE_CONFIG_DIR||b(t,`.claude`),r=b(n,`plugins`);return{harness:`claude-code`,configDir:n,locations:[{kind:`plugin-cache`,path:b(r,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CC-P1`},{kind:`marketplaces`,path:b(r,`marketplaces`),description:`Marketplace checkouts`,research:`E-CC-P1`},{kind:`install-record`,path:b(r,`installed_plugins.json`),description:`Installs keyed by plugin@marketplace, each with scope, installPath, and version`,research:`E-CC-P2`},{kind:`enabled-record`,path:b(n,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-CC-P3`}]}},cursor:({homedir:e})=>{let t=b(e,`.cursor`);return{harness:`cursor`,configDir:t,locations:[{kind:`local-plugins`,path:b(t,`plugins`,`local`),description:`Plugins under development, one folder each`,research:`E-CUR-P2`},{kind:`marketplaces`,path:b(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-CUR-P3`}]}},codex:({env:e,homedir:t})=>{let n=e.CODEX_HOME||b(t,`.codex`);return{harness:`codex`,configDir:n,locations:[{kind:`plugin-cache`,path:b(n,`plugins`,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CODEX-P3`},{kind:`enabled-record`,path:b(n,`config.toml`),description:`User config; [plugins."<plugin>@<marketplace>"] tables carry enabled = <bool>`,research:`E-CODEX-P2`}]}},"copilot-cli":({env:e,homedir:t})=>{let n=e.COPILOT_HOME||b(t,`.copilot`);return{harness:`copilot-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:b(n,`installed-plugins`),description:`Installed plugins as <marketplace>/<plugin>/, or _direct/<source-id>/ for direct installs`,research:`E-COPILOT-P9`},{kind:`install-record`,path:b(n,`config.json`),description:`Application state, including installedPlugins`,research:`E-COPILOT-P9`},{kind:`enabled-record`,path:b(n,`settings.json`),description:`User settings (JSON with comments); enabledPlugins maps plugin specs to a boolean`,research:`E-COPILOT-P4`}]}},opencode:e=>{let t=b(xdgConfig(e),`opencode`);return{harness:`opencode`,configDir:t,locations:[{kind:`local-plugins`,path:b(t,`plugins`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-OC-P2`}]}},kilo:e=>{let t=b(xdgConfig(e),`kilo`);return{harness:`kilo`,configDir:t,locations:[{kind:`local-plugins`,path:b(t,`plugin`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-KILO-P2`}]}},"gemini-cli":({env:e,homedir:t})=>{let n=b(e.GEMINI_CLI_HOME||t,`.gemini`),r=b(n,`extensions`);return{harness:`gemini-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a gemini-extension.json manifest`,research:`E-GEM-P1`},{kind:`enabled-record`,path:b(r,`extension-enablement.json`),description:`Per-extension path-glob overrides that enable or disable it by folder, not a boolean`,research:`E-GEM-P3`}]}},"qwen-code":({env:e,homedir:t})=>{let n=e.QWEN_HOME||b(t,`.qwen`),r=b(n,`extensions`);return{harness:`qwen-code`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a qwen-extension.json manifest`,research:`E-QWEN-P1`},{kind:`enabled-record`,path:b(r,`extension-enablement.json`),description:`Extension enable/disable state, inherited from Gemini CLI's format`,research:`E-QWEN-P2`}]}},"vscode-copilot":e=>{let{configDir:t,path:n}=vscodeAgentPlugins(e);return{harness:`vscode-copilot`,configDir:t,locations:[{kind:`installed-plugins`,path:n,description:`Installed agent plugins as <host>/<org>/<repo>/`,research:`E-VSC-P3`}]}},cline:({homedir:e})=>{let t=b(e,`.cline`);return{harness:`cline`,configDir:t,locations:[{kind:`installed-plugins`,path:b(t,`plugins`,`_installed`),description:`Installed plugins, grouped by source: npm, git, remote, or local`,research:`E-CLINE-P3`}]}},crush:({env:e,homedir:t})=>({harness:`crush`,configDir:e.CRUSH_GLOBAL_CONFIG||b(e.XDG_CONFIG_HOME||b(t,`.config`),`crush`),locations:[]}),openhands:({env:e,homedir:t})=>{let n=e.OH_PERSISTENCE_DIR||e.OPENHANDS_PERSISTENCE_DIR||b(t,`.openhands`),r=b(n,`plugins`,`installed`);return{harness:`openhands`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed plugins, one folder each`,research:`E-OH-P3`},{kind:`enabled-record`,path:b(r,`.installed.json`),description:`Install metadata keyed by plugin name, each with enabled: <bool>`,research:`E-OH-P4`}]}},augment:({homedir:e})=>{let t=b(e,`.augment`);return{harness:`augment`,configDir:t,locations:[{kind:`marketplaces`,path:b(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-AUG-P2`},{kind:`enabled-record`,path:b(t,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-AUG-P4`}]}}};async function enabledPlugins(e,t={}){let n=He[e](resolveHarnessEnvironment(t),t.managedSettingsPath),r=new Map,i=[];for(let e of n.sources){let t;try{let n=await readText(e.path);if(n===void 0){i.push({scope:e.scope,path:e.path,found:!1});continue}t=e.parse(n)}catch(t){i.push({scope:e.scope,path:e.path,found:!0,error:String(t)});continue}i.push({scope:e.scope,path:e.path,found:!0});for(let[n,i]of Object.entries(t))r.has(n)||r.set(n,{id:n,enabled:i,scope:e.scope,source:e.path})}return{harness:e,supported:n.supported,plugins:[...r.values()],sources:i,unread:n.unread,research:n.research}}function jsonEnabledPlugins(e){let t=JSON.parse(e),n=isRecord$1(t)?t.enabledPlugins:void 0;return isRecord$1(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`boolean`)):{}}const ze=/^\[\s*plugins\s*\.\s*(?:"([^"]*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/,Be=/^enabled\s*=\s*(true|false)\s*(?:#.*)?$/;function tomlEnabledPlugins(e){let t={},n;for(let r of e.split(/\r?\n/)){let e=r.trim();if(e.startsWith(`[`)){let t=ze.exec(e);n=t?t[1]??t[2]??t[3]:void 0;continue}let i=n===void 0?null:Be.exec(e);n!==void 0&&i&&(t[n]=i[1]===`true`)}return t}const Ve={server:`server-managed settings`,"macos-managed-preferences":`MDM managed preferences`,"windows-registry":`Windows registry policy`,directory:`drop-in managed settings`,file:`managed file`};function unreadPolicy(e,t,n=[]){return e.filter(e=>e.location!==t&&!n.some(t=>e.location.endsWith(t))).map(e=>`${Ve[e.kind]} (${e.location})`)}function managedFile(e,t){return e.find(e=>e.kind===`file`&&e.location.endsWith(t))?.location}function jsoncEnabledPlugins(e){return jsonEnabledPlugins(stripJsonComments$1(e))}const unsupported$1=(...e)=>({supported:!1,sources:[],unread:[],research:e}),He={"claude-code":(e,t)=>{let{configDir:n}=pluginStorage(`claude-code`,e),r=managedPolicyLocations(`claude-code`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=b(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsonEnabledPlugins}],{scope:`local`,path:b(o,`settings.local.json`),parse:jsonEnabledPlugins},{scope:`project`,path:b(o,`settings.json`),parse:jsonEnabledPlugins},{scope:`user`,path:b(n,`settings.json`),parse:jsonEnabledPlugins}],unread:unreadPolicy(r,i,[`managed-mcp.json`]),research:[`E-CC-P3`,`E-CC-P7`,`E-CC-M1`,`E-CC-M6`]}},cursor:()=>unsupported$1(),opencode:()=>unsupported$1(`E-OC-P3`),kilo:()=>unsupported$1(`E-KILO-P3`),"gemini-cli":()=>unsupported$1(`E-GEM-P3`),"qwen-code":()=>unsupported$1(`E-QWEN-P2`),"vscode-copilot":()=>unsupported$1(`E-VSC-P4`),cline:()=>unsupported$1(`E-CLINE-P4`),crush:()=>unsupported$1(`E-CRUSH-P2`),openhands:()=>unsupported$1(`E-OH-P4`),augment:()=>unsupported$1(`E-AUG-P4`),codex:e=>{let t=pluginStorage(`codex`,e);return{supported:!0,sources:[{scope:`user`,path:b(t.configDir,`config.toml`),parse:tomlEnabledPlugins}],unread:unreadPolicy(managedPolicyLocations(`codex`,e),void 0),research:[`E-CODEX-P2`,`E-CODEX-M7`]}},"copilot-cli":(e,t)=>{let n=pluginStorage(`copilot-cli`,e),r=managedPolicyLocations(`copilot-cli`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=b(e.cwd,`.github`,`copilot`),s=b(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsoncEnabledPlugins}],{scope:`local`,path:b(o,`settings.local.json`),parse:jsoncEnabledPlugins},{scope:`project`,path:b(o,`settings.json`),parse:jsoncEnabledPlugins},{scope:`user`,path:b(n.configDir,`settings.json`),parse:jsoncEnabledPlugins}],unread:[...unreadPolicy(r,i),`Claude Code project settings (${b(s,`settings.json`)})`,`Claude Code local settings (${b(s,`settings.local.json`)})`],research:[`E-COPILOT-P4`,`E-COPILOT-M1`,`E-COPILOT-M2`,`E-COPILOT-M4`]}}};async function installedPlugins(e,t={}){let n=Xe[e](resolveHarnessEnvironment(t)),r={harness:e,supported:n.supported,unread:n.unread,research:n.research};if(n.source===void 0)return{...r,plugins:[],unresolved:[],sources:[]};let i=n.source;try{let e=await n.read(i);return e===void 0?{...r,plugins:[],unresolved:[],sources:[{path:i,found:!1}]}:{...r,plugins:e.plugins,unresolved:e.unresolved??[],sources:[{path:i,found:!0}]}}catch(e){return{...r,plugins:[],unresolved:[],sources:[{path:i,found:!0,error:String(e)}]}}}const Ue=[`managed`,`local`,`project`,`user`],optionalString=e=>typeof e==`string`&&e!==``?e:void 0;async function readClaudeInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(t),r=isRecord$1(n)?n.plugins:void 0;if(!isRecord$1(r))return{plugins:[]};let i=[];for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let n of t){let t=isRecord$1(n)?optionalString(n.installPath):void 0;if(!isRecord$1(n)||t===void 0)continue;let r=optionalString(n.version),a=typeof n.scope==`string`&&Ue.includes(n.scope)?n.scope:void 0,o=optionalString(n.projectPath);i.push({id:e,path:t,...r===void 0?{}:{version:r},...a===void 0?{}:{scope:a},...o===void 0?{}:{projectPath:o},research:[`E-CC-P2`]})}return{plugins:i}}async function readCopilotInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(stripJsonComments$1(t)),r=isRecord$1(n)?n.installedPlugins:void 0;if(!Array.isArray(r))return{plugins:[]};let i=[];for(let e of r){if(!isRecord$1(e))continue;let t=optionalString(e.name),n=optionalString(e.cache_path);if(t===void 0||n===void 0)continue;let r=optionalString(e.marketplace),a=optionalString(e.version);i.push({id:r===void 0?t:`${t}@${r}`,path:n,...a===void 0?{}:{version:a},research:r===void 0?[`E-COPILOT-P10`,`E-COPILOT-P11`]:[`E-COPILOT-P10`]})}return{plugins:i}}const We=`local`,Ge=/^[A-Za-z0-9_-]+$/,Ke=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/,qe=/^[A-Za-z0-9._+-]+$/;async function readCodexInstalls(e){let t=await directories$1(e);if(t===void 0)return;let n=[],r=[];for(let i of t.filter(e=>Ge.test(e)))for(let t of await directories$1(b(e,i))??[]){if(!Ke.test(t))continue;let a=`${t}@${i}`,o=(await directories$1(b(e,i,t))??[]).filter(e=>qe.test(e)&&e!==`.`&&e!==`..`);if(o.length===0)continue;let s=activeCodexVersion(o);if(s===void 0){r.push(a);continue}n.push({id:a,path:b(e,i,t,s),version:s,research:[`E-CODEX-P3`,`E-CODEX-P8`]})}return{plugins:n,unresolved:r}}function activeCodexVersion(e){if(e.includes(We))return We;let t=e.filter(e=>parseSemver(e)!==void 0).length;if(!(e.length>2&&t!==0&&t!==e.length))return[...e].sort(compareCodexVersions).at(-1)}async function directories$1(e){try{return(await ee(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e.code===`ENOENT`)return;throw e}}__name(directories$1,`directories`);const Je=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function parseSemver(e){let t=Je.exec(e);if(t)return{core:[t[1],t[2],t[3]],pre:t[4]===void 0?[]:t[4].split(`.`),build:t[5]===void 0?[]:t[5].split(`.`)}}function compareCodexVersions(e,t){let n=parseSemver(e),r=parseSemver(t);if(n===void 0||r===void 0)return compareStrings(e,t);for(let e=0;e<3;e++){let t=compareNumeric(n.core[e],r.core[e]);if(t!==0)return t}let i=n.pre.length===0||r.pre.length===0?r.pre.length-n.pre.length:compareIdentifiers(n.pre,r.pre);return i===0?compareIdentifiers(n.build,r.build):Math.sign(i)}const Ye=/^\d+$/;function compareIdentifiers(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=Ye.test(r),o=Ye.test(i),s=a&&o?compareNumeric(r,i):a===o?compareStrings(r,i):a?-1:1;if(s!==0)return s}return e.length-t.length}function compareNumeric(e,t){let n=e.replace(/^0+(?=\d)/,``),r=t.replace(/^0+(?=\d)/,``);return n.length-r.length||compareStrings(n,r)||e.length-t.length}const compareStrings=(e,t)=>e<t?-1:+(e>t),A={supported:!1,read:async()=>void 0,unread:[],research:[]},Xe={"claude-code":e=>({supported:!0,source:b(pluginStorage(`claude-code`,e).configDir,`plugins`,`installed_plugins.json`),read:readClaudeInstalls,unread:[],research:[`E-CC-P2`]}),codex:e=>({supported:!0,source:b(pluginStorage(`codex`,e).configDir,`plugins`,`cache`),read:readCodexInstalls,unread:[],research:[`E-CODEX-P3`,`E-CODEX-P8`]}),"copilot-cli":e=>{let{configDir:t}=pluginStorage(`copilot-cli`,e);return{supported:!0,source:b(t,`config.json`),read:readCopilotInstalls,unread:[`plugins from marketplaces added by local path (extraKnownMarketplaces in ${b(t,`settings.json`)})`],research:[`E-COPILOT-P10`,`E-COPILOT-P11`,`E-COPILOT-P12`,`E-COPILOT-P13`]}},cursor:()=>A,opencode:()=>A,kilo:()=>A,"gemini-cli":()=>A,"qwen-code":()=>A,"vscode-copilot":()=>A,cline:()=>A,crush:()=>A,openhands:()=>A,augment:()=>A},isOne=e=>e===`1`,isSet=e=>e!==``,Ze={name:`CLAUDECODE`,matches:isOne,description:`Claude Code sets CLAUDECODE=1 in subprocesses it spawns; IDE extensions also set it in integrated terminals`,research:`E-CC-D1`},Qe=[{harness:`claude-code`,all:[Ze,{name:`CLAUDE_CODE_CHILD_SESSION`,matches:isOne,description:`Claude Code sets CLAUDE_CODE_CHILD_SESSION=1 for tool, hook, and status line subprocesses`,research:`E-CC-D3`}]},{harness:`claude-code`,all:[Ze,{name:`CLAUDE_CODE_SESSION_ID`,matches:isSet,description:`Claude Code sets CLAUDE_CODE_SESSION_ID in tool, hook, and stdio MCP server subprocesses`,research:`E-CC-D6`}]},{harness:`cursor`,all:[{name:`CURSOR_AGENT`,matches:isOne,description:`Cursor sets CURSOR_AGENT=1 on terminal commands its agent runs`,research:`E-CUR-D1`}]},{harness:`cursor`,all:[{name:`CURSOR_VERSION`,matches:isSet,description:`Cursor sets CURSOR_VERSION for hook commands`,research:`E-CUR-D10`},{name:`CURSOR_PROJECT_DIR`,matches:isSet,description:`Cursor sets CURSOR_PROJECT_DIR for hook commands`,research:`E-CUR-D10`}]},{harness:`codex`,all:[{name:`CODEX_THREAD_ID`,matches:isSet,description:`Codex injects CODEX_THREAD_ID into shell tool commands, even under a restrictive shell env policy`,research:`E-CODEX-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_CLI`,matches:isOne,description:`Copilot CLI sets COPILOT_CLI=1 in its subprocesses`,research:`E-COPILOT-D1`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_AGENT_SESSION_ID`,matches:isSet,description:`Copilot CLI passes COPILOT_AGENT_SESSION_ID to shell commands and MCP servers`,research:`E-COPILOT-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_PLUGIN_ROOT`,matches:isSet,description:`Copilot CLI passes COPILOT_PLUGIN_ROOT to plugin hooks`,research:`E-COPILOT-D6`}]},{harness:`opencode`,all:[{name:`OPENCODE`,matches:isOne,description:`OpenCode sets OPENCODE=1 for shell tool commands and MCP servers; Kilo Code, its fork, sets it too`,research:`E-OC-D1`},{name:`OPENCODE_PID`,matches:isSet,description:`OpenCode sets OPENCODE_PID for shell tool commands and MCP servers; Kilo Code sets KILO_PID instead`,research:`E-OC-D2`}]},{harness:`kilo`,all:[{name:`KILO`,matches:isOne,description:`Kilo Code sets KILO=1 for shell tool commands and MCP servers`,research:`E-KILO-D2`},{name:`KILO_PID`,matches:isSet,description:`Kilo Code sets KILO_PID for shell tool commands and MCP servers`,research:`E-KILO-D1`}]},{harness:`gemini-cli`,all:[{name:`GEMINI_CLI`,matches:isOne,description:`Gemini CLI sets GEMINI_CLI=1 for shell tool commands and MCP stdio servers`,research:`E-GEM-D1`}]},{harness:`qwen-code`,all:[{name:`QWEN_CODE`,matches:isOne,description:`Qwen Code sets QWEN_CODE=1 for shell tool commands, not for MCP servers or hooks`,research:`E-QWEN-D1`}]},{harness:`vscode-copilot`,all:[{name:`COPILOT_AGENT`,matches:isOne,description:`VS Code 1.121+ sets COPILOT_AGENT=1 on terminals its Copilot agent runs commands in`,research:`E-VSC-D1`}]},{harness:`cline`,all:[{name:`CLINE_ACTIVE`,matches:e=>e===`true`,description:`Cline's VS Code extension sets CLINE_ACTIVE=true on the terminals it creates; the Cline CLI does not`,research:`E-CLINE-D1`}]},{harness:`crush`,all:[{name:`CRUSH`,matches:isOne,description:`Crush sets CRUSH=1 for bash tool and hook commands, not for MCP servers`,research:`E-CRUSH-D1`}]},{harness:`openhands`,all:[{name:`AI_AGENT`,matches:e=>e===`openhands`,description:`OpenHands (SDK 1.40.1 and later) sets AI_AGENT=openhands for terminal tool and hook commands when AI_AGENT is unset; other vendors use the name with other values`,research:`E-OH-D1`}]},{harness:`openhands`,all:[{name:`OPENHANDS_EVENT_TYPE`,matches:isSet,description:`OpenHands sets OPENHANDS_EVENT_TYPE for hook commands`,research:`E-OH-D4`},{name:`OPENHANDS_PROJECT_DIR`,matches:isSet,description:`OpenHands sets OPENHANDS_PROJECT_DIR for hook commands`,research:`E-OH-D4`}]},{harness:`augment`,all:[{name:`AUGMENT_HOOK_EVENT`,matches:isSet,description:`The Auggie CLI sets AUGMENT_HOOK_EVENT for hook commands; its shell commands carry no marker`,research:`E-AUG-D3`},{name:`AUGMENT_PROJECT_DIR`,matches:isSet,description:`The Auggie CLI sets AUGMENT_PROJECT_DIR for hook commands`,research:`E-AUG-D3`}]}];function detectHarness(e={}){let t=e.env??process.env,n=[],r=[];for(let e of Qe){let i=e.all.filter(e=>{let n=t[e.name];return n!==void 0&&e.matches(n)});for(let t of i)n.some(n=>n.harness===e.harness&&n.signal===t.name)||n.push({harness:e.harness,signal:t.name,description:t.description,research:t.research});i.length===e.all.length&&!r.includes(e.harness)&&r.push(e.harness)}return{harness:r.length===1?r[0]:`unknown`,evidence:n,candidates:r}}function declaredDependencies(e){if(!e||typeof e!=`object`)return[];let t=e,n=new Set;for(let e of[`dependencies`,`devDependencies`]){let r=t[e];if(r&&typeof r==`object`)for(let e of Object.keys(r))n.add(e)}return[...n].sort()}function ancestorCandidates(e,t){let n=t.split(`/`),r=[],i=e;for(;;){r.push(b(i,`node_modules`,...n));let e=y(i);if(e===i)break;i=e}return r}function packageDir(t,r){try{let n=e(r);return y(n.resolve(`${t}/package.json`))}catch{}for(let e of ancestorCandidates(y(r),t))if(n(b(e,`package.json`)))return e}const $e=[`plugin.json`,`.claude-plugin/plugin.json`,`.cursor-plugin/plugin.json`,`.codex-plugin/plugin.json`,`.github/plugin.json`,`.github/plugin/plugin.json`];function pluginManifestName(e){for(let t of $e){let n;try{n=JSON.parse(a(b(e,t),`utf8`))}catch{continue}if(isRecord$1(n)&&typeof n.name==`string`&&n.name)return n.name}}function skillsDirectories(e){switch(e){case`claude-code`:return{project:[`.claude/skills`],user:[`.claude/skills`],research:[`E-CC-L1`]};case`cursor`:return{project:[`.cursor/skills`,`.claude/skills`,`.codex/skills`,`.grok/skills`,`.agents/skills`],user:[`.cursor/skills`,`.claude/skills`,`.codex/skills`,`.grok/skills`,`.agents/skills`],research:[`E-CUR-L1`,`E-SR-CUR-10`]};case`codex`:return{project:[`.agents/skills`],user:[`.agents/skills`],research:[`E-CODEX-L1`]};case`copilot-cli`:return{project:[`.github/skills`,`.agents/skills`,`.claude/skills`],user:[`.copilot/skills`,`.agents/skills`],research:[`E-COPILOT-S5`,`E-SR-COPILOT-9`],relocatedBy:{variable:`COPILOT_HOME`,skills:`skills`}};case`vscode-copilot`:return{project:[`.github/skills`,`.claude/skills`,`.agents/skills`],user:[`.copilot/skills`,`.claude/skills`,`.agents/skills`],research:[`E-VSC-P1`]};case`opencode`:return{project:[`.opencode/skills`,`.claude/skills`,`.agents/skills`],user:[`.config/opencode/skills`,`.claude/skills`,`.agents/skills`],research:[`E-OC-S1`]};case`gemini-cli`:return{project:[`.agents/skills`,`.gemini/skills`],user:[`.agents/skills`,`.gemini/skills`],research:[`E-GEM-L1`]};case`cline`:return{project:[`.cline/skills`,`.clinerules/skills`,`.claude/skills`,`.agents/skills`],user:[`.cline/skills`,`.agents/skills`],research:[`E-CLINE-S1`,`E-CLINE-S3`]};case`augment`:return{project:[`.augment/skills`,`.claude/skills`,`.agents/skills`],user:[`.augment/skills`,`.claude/skills`,`.agents/skills`],research:[`E-AUG-S4`]};case`kilo`:return{project:[`.kilo/skills`,`.agents/skills`,`.claude/skills`],user:[`.kilo/skills`,`.agents/skills`,`.claude/skills`],research:[`E-KILO-L2`]};case`qwen-code`:case`crush`:case`openhands`:return}}const et=[`claude-code`,`cursor`,`codex`,`copilot-cli`,`opencode`,`gemini-cli`];function adminSkillFolders(e,t,n={}){let r=n.ProgramData||`C:\\ProgramData`;switch(e){case`claude-code`:return t===`darwin`?[`/Library/Application Support/ClaudeCode/.claude/skills`]:t===`win32`?[T.join(`C:\\Program Files\\ClaudeCode`,`.claude`,`skills`)]:[`/etc/claude-code/.claude/skills`];case`codex`:return t===`win32`?[]:[`/etc/codex/skills`];case`opencode`:{let e=t===`darwin`?`/Library/Application Support/opencode`:t===`win32`?T.join(r,`opencode`):`/etc/opencode`,n=t===`win32`?T:{join:b};return[n.join(e,`skill`),n.join(e,`skills`)]}default:return[]}}function harnessSkillFolders(e,{chain:t,home:n,platform:r,env:i={}}){if(!et.includes(e))return;let a=skillsDirectories(e);if(!a)return;let o=t.flatMap(e=>a.project.map(t=>b(e,t))),s=a.relocatedBy&&i[a.relocatedBy.variable],c=s&&C(s)!==b(n,`.copilot`)?[b(s,a.relocatedBy.skills)]:a.user.map(e=>b(n,e));return[...o,...c,...adminSkillFolders(e,r,i)]}function manifestSkills(e){for(let t of $e){let n;try{n=JSON.parse(a(b(e,t),`utf8`))}catch{continue}if(!isRecord$1(n))return;let r=n.skills;return typeof r==`string`?[r]:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}function pluginSkillFolders(e,t){if(e===`opencode`)return[];let n=e===`gemini-cli`?void 0:manifestSkills(t),r=b(t,`skills`);if(!n)return[r];let i=n.map(e=>b(t,e));return e===`claude-code`?[r,...i]:i}var j=__commonJSMin((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),isAlias=e=>!!e&&typeof e==`object`&&e[s]===t,isDocument=e=>!!e&&typeof e==`object`&&e[s]===n,isMap=e=>!!e&&typeof e==`object`&&e[s]===r,isPair=e=>!!e&&typeof e==`object`&&e[s]===i,isScalar=e=>!!e&&typeof e==`object`&&e[s]===a,isSeq=e=>!!e&&typeof e==`object`&&e[s]===o;function isCollection(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function isNode(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}let hasAnchor=e=>(isScalar(e)||isCollection(e))&&!!e.anchor;e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=hasAnchor,e.isAlias=isAlias,e.isCollection=isCollection,e.isDocument=isDocument,e.isMap=isMap,e.isNode=isNode,e.isPair=isPair,e.isScalar=isScalar,e.isSeq=isSeq})),tt=__commonJSMin((e=>{var t=j();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function visit(e,n){let r=initVisitor(n);t.isDocument(e)?visit_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):visit_(null,e,r,Object.freeze([]))}visit.BREAK=n,visit.SKIP=r,visit.REMOVE=i;function visit_(e,r,a,o){let s=callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visit_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=visit_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=visit_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=visit_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}async function visitAsync(e,n){let r=initVisitor(n);t.isDocument(e)?await visitAsync_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await visitAsync_(null,e,r,Object.freeze([]))}visitAsync.BREAK=n,visitAsync.SKIP=r,visitAsync.REMOVE=i;async function visitAsync_(e,r,a,o){let s=await callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visitAsync_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await visitAsync_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await visitAsync_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await visitAsync_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function initVisitor(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function callVisitor(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function replaceNode(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=visit,e.visitAsync=visitAsync})),nt=__commonJSMin((e=>{var t=j(),n=tt();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},escapeTagName=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var i=class Directives{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Directives.defaultYaml,e),this.tags=Object.assign({},Directives.defaultTags,t)}clone(){let e=new Directives(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Directives(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},Directives.defaultTags)}return e}add(e,t){this.atNextDocument&&=(this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},Directives.defaultTags),!1);let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case`%TAG`:{if(n.length!==2&&(t(0,`%TAG directive should contain exactly two parts`),n.length<2))return!1;let[e,r]=n;return this.tags[e]=r,!0}case`%YAML`:{if(this.yaml.explicit=!0,n.length!==1)return t(0,`%YAML directive should contain exactly one part`),!1;let[e]=n;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let n=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,n),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+escapeTagName(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
36
|
+
`)}};i.defaultYaml={explicit:!1,version:`1.2`},i.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=i})),rt=__commonJSMin((e=>{var t=j(),n=tt();function anchorIsValid(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function anchorNames(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function findNewAnchor(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function createNodeAnchors(e,n){let r=[],i=new Map,a=null;return{onAnchor:t=>{r.push(t),a??=anchorNames(e);let i=findNewAnchor(n,a);return a.add(i),i},setAnchors:()=>{for(let e of r){let n=i.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:i}}e.anchorIsValid=anchorIsValid,e.anchorNames=anchorNames,e.createNodeAnchors=createNodeAnchors,e.findNewAnchor=findNewAnchor})),it=__commonJSMin((e=>{function applyReviver(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=applyReviver(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=applyReviver(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=applyReviver(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=applyReviver(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}e.applyReviver=applyReviver})),M=__commonJSMin((e=>{var t=j();function toJS(e,n,r){if(Array.isArray(e))return e.map((e,t)=>toJS(e,String(t),r));if(e&&typeof e.toJSON==`function`){if(!r||!t.hasAnchor(e))return e.toJSON(n,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=e=>{i.res=e,delete r.onCreate};let a=e.toJSON(n,r);return r.onCreate&&r.onCreate(a),a}return typeof e==`bigint`&&!r?.keep?Number(e):e}e.toJS=toJS})),ot=__commonJSMin((e=>{var t=it(),n=j(),r=M(),NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}};e.NodeBase=NodeBase})),st=__commonJSMin((e=>{var t=rt(),n=tt(),r=j(),i=ot(),a=M(),Alias=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=getAliasCount(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function getAliasCount(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=getAliasCount(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=getAliasCount(e,t.key,n),i=getAliasCount(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=Alias})),N=__commonJSMin((e=>{var t=j(),n=ot(),r=M();let isScalarValue=e=>!e||typeof e!=`function`&&typeof e!=`object`;var Scalar=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};Scalar.BLOCK_FOLDED=`BLOCK_FOLDED`,Scalar.BLOCK_LITERAL=`BLOCK_LITERAL`,Scalar.PLAIN=`PLAIN`,Scalar.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Scalar.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=Scalar,e.isScalarValue=isScalarValue})),ct=__commonJSMin((e=>{var t=st(),n=j(),r=N();function findTagObject(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function createNode(e,i,a){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=a.schema[n.MAP].createNode?.(a.schema,null,a);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:s,onTagObj:c,schema:l,sourceObjects:u}=a,d;if(o&&e&&typeof e==`object`){if(d=u.get(e),d)return d.anchor??(d.anchor=s(e)),new t.Alias(d.anchor);d={anchor:null,node:null},u.set(e,d)}i?.startsWith(`!!`)&&(i=`tag:yaml.org,2002:`+i.slice(2));let f=findTagObject(e,i,l.tags);if(!f){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return d&&(d.node=t),t}f=e instanceof Map?l[n.MAP]:Symbol.iterator in Object(e)?l[n.SEQ]:l[n.MAP]}c&&(c(f),delete a.onTagObj);let p=f?.createNode?f.createNode(a.schema,e,a):typeof f?.nodeClass?.from==`function`?f.nodeClass.from(a.schema,e,a):new r.Scalar(e);return i?p.tag=i:f.default||(p.tag=f.tag),d&&(d.node=p),p}e.createNode=createNode})),lt=__commonJSMin((e=>{var t=ct(),n=j(),r=ot();function collectionFromPath(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let isEmptyPath=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(isEmptyPath(e))this.add(t);else{let[r,...i]=e,a=this.get(r,!0);if(n.isCollection(a))a.addIn(i,t);else if(a===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(i,t);else if(e===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};e.Collection=Collection,e.collectionFromPath=collectionFromPath,e.isEmptyPath=isEmptyPath})),ut=__commonJSMin((e=>{let stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function indentComment(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}let lineComment=(e,t,n)=>e.endsWith(`
|
|
93
37
|
`)?indentComment(n,t):n.includes(`
|
|
94
38
|
`)?`
|
|
95
|
-
`+indentComment(n,t):(e.endsWith(` `)?``:` `)+n;e.indentComment=indentComment,e.lineComment=lineComment,e.stringifyComment=stringifyComment})),
|
|
96
|
-
`)i===t&&(
|
|
97
|
-
`&&
|
|
98
|
-
`&&t!==` `&&(
|
|
99
|
-
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=foldFlowLines})),
|
|
39
|
+
`+indentComment(n,t):(e.endsWith(` `)?``:` `)+n;e.indentComment=indentComment,e.lineComment=lineComment,e.stringifyComment=stringifyComment})),dt=__commonJSMin((e=>{let t=`block`,n=`quoted`;function foldFlowLines(e,r,i=`flow`,{indentAtStart:a,lineWidth:o=80,minContentWidth:s=20,onFold:c,onOverflow:l}={}){if(!o||o<0)return e;o<s&&(s=0);let u=Math.max(1+s,1+o-r.length);if(e.length<=u)return e;let d=[],f={},p=o-r.length;typeof a==`number`&&(a>o-Math.max(2,s)?d.push(0):p=o-a);let m,h,g=!1,_=-1,v=-1,y=-1;i===t&&(_=consumeMoreIndentedLines(e,_,r.length),_!==-1&&(p=_+u));for(let a;a=e[_+=1];){if(i===n&&a===`\\`){switch(v=_,e[_+1]){case`x`:_+=3;break;case`u`:_+=5;break;case`U`:_+=9;break;default:_+=1}y=_}if(a===`
|
|
40
|
+
`)i===t&&(_=consumeMoreIndentedLines(e,_,r.length)),p=_+r.length+u,m=void 0;else{if(a===` `&&h&&h!==` `&&h!==`
|
|
41
|
+
`&&h!==` `){let t=e[_+1];t&&t!==` `&&t!==`
|
|
42
|
+
`&&t!==` `&&(m=_)}if(_>=p){if(m)d.push(m),p=m+u,m=void 0;else if(i===n){for(;h===` `||h===` `;)h=a,a=e[_+=1],g=!0;let t=_>y+1?_-2:v-1;if(f[t])return e;d.push(t),f[t]=!0,p=t+u,m=void 0}else g=!0}}h=a}if(g&&l&&l(),d.length===0)return e;c&&c();let b=e.slice(0,d[0]);for(let t=0;t<d.length;++t){let a=d[t],o=d[t+1]||e.length;a===0?b=`\n${r}${e.slice(0,o)}`:(i===n&&f[a]&&(b+=`${e[a]}\\`),b+=`\n${r}${e.slice(a+1,o)}`)}return b}function consumeMoreIndentedLines(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
43
|
+
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=foldFlowLines})),ft=__commonJSMin((e=>{var t=N(),n=dt();let getFoldOptions=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),containsDocumentMarker=e=>/^(%|---|\.\.\.)/m.test(e);function lineLengthOverLimit(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
100
44
|
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function doubleQuotedString(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,a=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(containsDocumentMarker(e)?` `:``),s=``,c=0;for(let e=0,t=r[e];t;t=r[++e])if(t===` `&&r[e+1]===`\\`&&r[e+2]===`n`&&(s+=r.slice(c,e)+`\\ `,e+=1,c=e,t=`\\`),t===`\\`)switch(r[e+1]){case`u`:{s+=r.slice(c,e);let t=r.substr(e+2,4);switch(t){case`0000`:s+=`\\0`;break;case`0007`:s+=`\\a`;break;case`000b`:s+=`\\v`;break;case`001b`:s+=`\\e`;break;case`0085`:s+=`\\N`;break;case`00a0`:s+=`\\_`;break;case`2028`:s+=`\\L`;break;case`2029`:s+=`\\P`;break;default:t.substr(0,2)===`00`?s+=`\\x`+t.substr(2):s+=r.substr(e,6)}e+=5,c=e+1}break;case`n`:if(i||r[e+2]===`"`||r.length<a)e+=1;else{for(s+=r.slice(c,e)+`
|
|
101
45
|
|
|
102
46
|
`;r[e+2]===`\\`&&r[e+3]===`n`&&r[e+4]!==`"`;)s+=`
|
|
@@ -104,58 +48,56 @@ ${toPrettyType(e.config)}`:``}function toPrettyType(e){return tersify(toTypeObje
|
|
|
104
48
|
`)||/[ \t]\n|\n[ \t]/.test(e))return doubleQuotedString(e,t);let r=t.indent||(containsDocumentMarker(e)?` `:``),i=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${r}`)+`'`;return t.implicitKey?i:n.foldFlowLines(i,r,n.FOLD_FLOW,getFoldOptions(t,!1))}function quotedString(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=doubleQuotedString;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?singleQuotedString:i&&!t?doubleQuotedString:n?singleQuotedString:doubleQuotedString}return r(e,t)}let r;try{r=RegExp(`(^|(?<!
|
|
105
49
|
))
|
|
106
50
|
+(?!
|
|
107
|
-
|$)`,`g`)}catch{r=/\n+(?!\n|$)/g}function blockString({comment:e,type:i,value:a},o,s,c){let{blockQuote:l,commentString:u,lineWidth:d}=o.options;if(!l||/\n[\t ]+$/.test(a))return quotedString(a,o);let
|
|
51
|
+
|$)`,`g`)}catch{r=/\n+(?!\n|$)/g}function blockString({comment:e,type:i,value:a},o,s,c){let{blockQuote:l,commentString:u,lineWidth:d}=o.options;if(!l||/\n[\t ]+$/.test(a))return quotedString(a,o);let f=o.indent||(o.forceBlockIndent||containsDocumentMarker(a)?` `:``),p=l===`literal`?!0:l===`folded`||i===t.Scalar.BLOCK_FOLDED?!1:i===t.Scalar.BLOCK_LITERAL||!lineLengthOverLimit(a,d,f.length);if(!a)return p?`|
|
|
108
52
|
`:`>
|
|
109
|
-
`;let h
|
|
110
|
-
`&&e!==` `&&e!==` `)break}let
|
|
111
|
-
`);
|
|
112
|
-
`&&(
|
|
113
|
-
`)
|
|
114
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${
|
|
115
|
-
`)||
|
|
116
|
-
`)?quotedString(s,r):blockString(e,r,i,a);if(!l&&!
|
|
117
|
-
`))return blockString(e,r,i,a);if(containsDocumentMarker(s)){if(u===``)return r.forceBlockIndent=!0,blockString(e,r,i,a);if(l&&u===d)return quotedString(s,r)}let
|
|
118
|
-
`:``,
|
|
119
|
-
`&&
|
|
53
|
+
`;let m,h;for(h=a.length;h>0;--h){let e=a[h-1];if(e!==`
|
|
54
|
+
`&&e!==` `&&e!==` `)break}let g=a.substring(h),_=g.indexOf(`
|
|
55
|
+
`);_===-1?m=`-`:a===g||_!==g.length-1?(m=`+`,c&&c()):m=``,g&&=(a=a.slice(0,-g.length),g[g.length-1]===`
|
|
56
|
+
`&&(g=g.slice(0,-1)),g.replace(r,`$&${f}`));let v=!1,y,b=-1;for(y=0;y<a.length;++y){let e=a[y];if(e===` `)v=!0;else if(e===`
|
|
57
|
+
`)b=y;else break}let x=a.substring(0,b<y?b+1:y);x&&=(a=a.substring(x.length),x.replace(/\n+/g,`$&${f}`));let S=(v?f?`2`:`1`:``)+m;if(e&&(S+=` `+u(e.replace(/ ?[\r\n]+/g,` `)),s&&s()),!p){let e=a.replace(/\n+/g,`
|
|
58
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${f}`),r=!1,s=getFoldOptions(o,!0);l!==`folded`&&i!==t.Scalar.BLOCK_FOLDED&&(s.onOverflow=()=>{r=!0});let c=n.foldFlowLines(`${x}${e}${g}`,f,n.FOLD_BLOCK,s);if(!r)return`>${S}\n${f}${c}`}return a=a.replace(/\n+/g,`$&${f}`),`|${S}\n${f}${x}${a}${g}`}function plainString(e,r,i,a){let{type:o,value:s}=e,{actualString:c,implicitKey:l,indent:u,indentStep:d,inFlow:f}=r;if(l&&s.includes(`
|
|
59
|
+
`)||f&&/[[\]{},]/.test(s))return quotedString(s,r);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return l||f||!s.includes(`
|
|
60
|
+
`)?quotedString(s,r):blockString(e,r,i,a);if(!l&&!f&&o!==t.Scalar.PLAIN&&s.includes(`
|
|
61
|
+
`))return blockString(e,r,i,a);if(containsDocumentMarker(s)){if(u===``)return r.forceBlockIndent=!0,blockString(e,r,i,a);if(l&&u===d)return quotedString(s,r)}let p=s.replace(/\n+/g,`$&\n${u}`);if(c){let test=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(p),{compat:e,tags:t}=r.doc.schema;if(t.some(test)||e?.some(test))return quotedString(s,r)}return l?p:n.foldFlowLines(p,u,n.FOLD_FLOW,getFoldOptions(r,!1))}function stringifyString(e,n,r,i){let{implicitKey:a,inFlow:o}=n,s=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:c}=e;c!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(c=t.Scalar.QUOTE_DOUBLE);let _stringify=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||o?quotedString(s.value,n):blockString(s,n,r,i);case t.Scalar.QUOTE_DOUBLE:return doubleQuotedString(s.value,n);case t.Scalar.QUOTE_SINGLE:return singleQuotedString(s.value,n);case t.Scalar.PLAIN:return plainString(s,n,r,i);default:return null}},l=_stringify(c);if(l===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(l=_stringify(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}e.stringifyString=stringifyString})),pt=__commonJSMin((e=>{var t=rt(),n=j(),r=ut(),i=ft();function createStringifyContext(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function getTagObject(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function stringifyProps(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function stringify(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let o,s=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>o=e});o??=getTagObject(t.doc.schema.tags,s);let c=stringifyProps(s,o,t);c.length>0&&(t.indentAtStart=(t.indentAtStart??0)+c.length+1);let l=typeof o.stringify==`function`?o.stringify(s,t,r,a):n.isScalar(s)?i.stringifyString(s,t,r,a):s.toString(t,r,a);return c?n.isScalar(s)||l[0]===`{`||l[0]===`[`?`${c} ${l}`:`${c}\n${t.indent}${l}`:l}e.createStringifyContext=createStringifyContext,e.stringify=stringify})),mt=__commonJSMin((e=>{var t=j(),n=N(),r=pt(),i=ut();function stringifyPair({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
|
|
62
|
+
`:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
|
|
63
|
+
`&&C&&(E=`
|
|
120
64
|
|
|
121
|
-
`):
|
|
122
|
-
`),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=
|
|
123
|
-
`)&&(
|
|
124
|
-
`}}return e?(
|
|
125
|
-
`+r.indentComment(
|
|
126
|
-
`),a<e.length-1?l+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(
|
|
127
|
-
`;return`${e}\n${s}${
|
|
128
|
-
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Ua=__commonJSMin((e=>{var t=X(),n=Oa(),r=Z(),i=Ma();function resolvePairs(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function createPairs(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let a={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:resolvePairs,createNode:createPairs};e.createPairs=createPairs,e.pairs=a,e.resolvePairs=resolvePairs})),Wa=__commonJSMin((e=>{var t=X(),n=ha(),r=Aa(),i=Ma(),a=Ua(),o=class YAMLOMap extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=YAMLOMap.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Ga=__commonJSMin((e=>{var t=Z();function boolStringify({value:e,source:t},i){return t&&(e?n:r).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}let n={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:boolStringify},r={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:boolStringify};e.falseTag=r,e.trueTag=n})),Ka=__commonJSMin((e=>{var t=Z(),n=La();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),qa=__commonJSMin((e=>{var t=La();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e);function intResolve(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function intStringify(e,n,r){let{value:i}=e;if(intIdentify(i)){let e=i.toString(n);return i<0?`-`+r+e.substr(1):r+e}return t.stringifyNumber(e)}let n={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>intResolve(e,2,2,n),stringify:e=>intStringify(e,2,`0b`)},r={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>intResolve(e,1,8,n),stringify:e=>intStringify(e,8,`0`)},i={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},a={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)};e.int=i,e.intBin=n,e.intHex=a,e.intOct=r})),Ja=__commonJSMin((e=>{var t=X(),n=Oa(),r=Aa(),i=class YAMLSet extends r.YAMLMap{constructor(e){super(e),this.tag=YAMLSet.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),Ya=__commonJSMin((e=>{var t=La();function parseSexagesimal(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,num=e=>t?BigInt(e):Number(e),i=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*num(60)+num(t),num(0));return n===`-`?num(-1)*i:i}function stringifySexagesimal(e){let{value:n}=e,num=e=>e;if(typeof n==`bigint`)num=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let r=``;n<0&&(r=`-`,n*=num(-1));let i=num(60),a=[n%i];return n<60?a.unshift(0):(n=(n-a[0])/i,a.unshift(n%i),n>=60&&(n=(n-a[0])/i,a.unshift(n))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let n={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>parseSexagesimal(e,n),stringify:stringifySexagesimal},r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>parseSexagesimal(e,!1),stringify:stringifySexagesimal},i={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(i.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,a,o,s,c]=t.map(Number),l=t[7]?Number((t[7]+`00`).substr(1,3)):0,u=Date.UTC(n,r-1,a,o||0,s||0,c||0,l),d=t[8];if(d&&d!==`Z`){let e=parseSexagesimal(d,!1);Math.abs(e)<30&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=r,e.intTime=n,e.timestamp=i})),Xa=__commonJSMin((e=>{var t=ja(),n=Fa(),r=Na(),i=Pa(),a=Ha(),o=Ga(),s=Ka(),c=qa(),l=Ea(),u=Wa(),d=Ua(),p=Ja(),m=Ya();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,p.set,m.intTime,m.floatTime,m.timestamp]})),Za=__commonJSMin((e=>{var t=ja(),n=Fa(),r=Na(),i=Pa(),a=Ia(),o=Ra(),s=za(),c=Ba(),l=Va(),u=Ha(),d=Ea(),p=Wa(),m=Ua(),h=Xa(),g=Ja(),_=Ya();let v=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,h.schema],[`yaml-1.1`,h.schema]]),y={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:_.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:_.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:p.omap,pairs:m.pairs,seq:r.seq,set:g.set,timestamp:_.timestamp},b={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":g.set,"tag:yaml.org,2002:timestamp":_.timestamp};function getTags(e,t,n){let r=v.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?y[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(y).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=b,e.getTags=getTags})),Qa=__commonJSMin((e=>{var t=X(),n=ja(),r=Na(),i=Pa(),a=Za();let sortMapEntriesByKey=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class Schema{constructor({compat:e,customTags:o,merge:s,resolveKnownTags:c,schema:l,sortMapEntries:u,toStringDefaults:d}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof l==`string`&&l||`core`,this.knownTags=c?a.coreKnownTags:{},this.tags=a.getTags(o,this.name,s),this.toStringOptions=d??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof u==`function`?u:u===!0?sortMapEntriesByKey:null}clone(){let e=Object.create(Schema.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}})),$a=__commonJSMin((e=>{var t=X(),n=Ca(),r=ba();function stringifyDocument(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
65
|
+
`):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
66
|
+
`),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else(T===``||T[0]===`
|
|
67
|
+
`)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=stringifyPair})),ht=__commonJSMin((e=>{var t=Ie(`process`);function debug(e,...t){e===`debug`&&console.log(...t)}function warn(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=debug,e.warn=warn})),gt=__commonJSMin((e=>{var t=j(),n=N();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:addMergeToJSMap}),stringify:()=>`<<`},isMergeKey=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function addMergeToJSMap(e,n,r){let i=resolveAliasValue(e,r);if(t.isSeq(i))for(let t of i.items)mergeValue(e,n,t);else if(Array.isArray(i))for(let t of i)mergeValue(e,n,t);else mergeValue(e,n,i)}function mergeValue(e,n,r){let i=resolveAliasValue(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function resolveAliasValue(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=addMergeToJSMap,e.isMergeKey=isMergeKey,e.merge=r})),_t=__commonJSMin((e=>{var t=ht(),n=gt(),r=pt(),i=j(),a=M();function addPairToJSMap(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=stringifyKey(r,n,e),s=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[i]=s}}return t}function stringifyKey(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=addPairToJSMap})),P=__commonJSMin((e=>{var t=ct(),n=mt(),r=_t(),i=j();function createPair(e,n,r){return new a(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var a=class Pair{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return i.isNode(t)&&(t=t.clone(e)),i.isNode(n)&&(n=n.clone(e)),new Pair(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=a,e.createPair=createPair})),vt=__commonJSMin((e=>{var t=j(),n=pt(),r=ut();function stringifyCollection(e,t,n){return(t.inFlow??e.flow?stringifyFlowCollection:stringifyBlockCollection)(e,t,n)}function stringifyBlockCollection({comment:e,items:i},a,{blockItemPrefix:o,flowChars:s,itemIndent:c,onChompKeep:l,onComment:u}){let{indent:d,options:{commentString:f}}=a,p=Object.assign({},a,{indent:c,type:null}),m=!1,h=[];for(let e=0;e<i.length;++e){let s=i[e],l=null;if(t.isNode(s))!m&&s.spaceBefore&&h.push(``),addCommentBefore(a,h,s.commentBefore,m),s.comment&&(l=s.comment);else if(t.isPair(s)){let e=t.isNode(s.key)?s.key:null;e&&(!m&&e.spaceBefore&&h.push(``),addCommentBefore(a,h,e.commentBefore,m))}m=!1;let u=n.stringify(s,p,()=>l=null,()=>m=!0);l&&(u+=r.lineComment(u,c,f(l))),m&&l&&(m=!1),h.push(o+u)}let g;if(h.length===0)g=s.start+s.end;else{g=h[0];for(let e=1;e<h.length;++e){let t=h[e];g+=t?`\n${d}${t}`:`
|
|
68
|
+
`}}return e?(g+=`
|
|
69
|
+
`+r.indentComment(f(e),d),u&&u()):m&&l&&l(),g}function stringifyFlowCollection({items:e},i,{flowChars:a,itemIndent:o}){let{indent:s,indentStep:c,flowCollectionPadding:l,options:{commentString:u}}=i;o+=c;let d=Object.assign({},i,{indent:o,inFlow:!0,type:null}),f=!1,p=0,m=[];for(let a=0;a<e.length;++a){let s=e[a],c=null;if(t.isNode(s))s.spaceBefore&&m.push(``),addCommentBefore(i,m,s.commentBefore,!1),s.comment&&(c=s.comment);else if(t.isPair(s)){let e=t.isNode(s.key)?s.key:null;e&&(e.spaceBefore&&m.push(``),addCommentBefore(i,m,e.commentBefore,!1),e.comment&&(f=!0));let n=t.isNode(s.value)?s.value:null;n?(n.comment&&(c=n.comment),n.commentBefore&&(f=!0)):s.value==null&&e?.comment&&(c=e.comment)}c&&(f=!0);let l=n.stringify(s,d,()=>c=null);f||=m.length>p||l.includes(`
|
|
70
|
+
`),a<e.length-1?l+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(f||=m.reduce((e,t)=>e+t.length+2,2)+(l.length+2)>i.options.lineWidth),f&&(l+=`,`)),c&&(l+=r.lineComment(l,o,u(c))),m.push(l),p=m.length}let{start:h,end:g}=a;if(m.length===0)return h+g;if(!f){let e=m.reduce((e,t)=>e+t.length+2,2);f=i.options.lineWidth>0&&e>i.options.lineWidth}if(f){let e=h;for(let t of m)e+=t?`\n${c}${s}${t}`:`
|
|
71
|
+
`;return`${e}\n${s}${g}`}return`${h}${l}${m.join(` `)}${l}${g}`}function addCommentBefore({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=stringifyCollection})),F=__commonJSMin((e=>{var t=vt(),n=_t(),r=lt(),i=j(),a=P(),o=N();function findPair(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}var YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),add=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)add(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))add(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=findPair(this.items,n.key),s=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(s){let e=this.items.findIndex(e=>s(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=findPair(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=findPair(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!findPair(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}};e.YAMLMap=YAMLMap,e.findPair=findPair})),I=__commonJSMin((e=>{var t=j(),n=F();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),L=__commonJSMin((e=>{var t=ct(),n=vt(),r=lt(),i=j(),a=N(),o=M(),YAMLSeq=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=asItemIndex(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=asItemIndex(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=asItemIndex(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=asItemIndex(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function asItemIndex(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=YAMLSeq})),R=__commonJSMin((e=>{var t=j(),n=L();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),yt=__commonJSMin((e=>{var t=ft();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),bt=__commonJSMin((e=>{var t=N();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),xt=__commonJSMin((e=>{var t=N();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),z=__commonJSMin((e=>{function stringifyNumber({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=stringifyNumber})),St=__commonJSMin((e=>{var t=N(),n=z();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Ct=__commonJSMin((e=>{var t=z();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e),intResolve=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function intStringify(e,n,r){let{value:i}=e;return intIdentify(i)&&i>=0?r+i.toString(n):t.stringifyNumber(e)}e.int={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>intIdentify(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)},e.intOct={identify:e=>intIdentify(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>intResolve(e,2,8,n),stringify:e=>intStringify(e,8,`0o`)}})),wt=__commonJSMin((e=>{var t=I(),n=bt(),r=R(),i=yt(),a=xt(),o=St(),s=Ct();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),Tt=__commonJSMin((e=>{var t=N(),n=I(),r=R();function intIdentify(e){return typeof e==`bigint`||Number.isInteger(e)}let stringifyJSON=({value:e})=>JSON.stringify(e),i=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:stringifyJSON},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:stringifyJSON},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:stringifyJSON},{identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>intIdentify(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:stringifyJSON}];e.schema=[n.map,r.seq].concat(i,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Et=__commonJSMin((e=>{var t=Ie(`buffer`),n=N(),r=ft();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
|
|
72
|
+
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Dt=__commonJSMin((e=>{var t=j(),n=P(),r=N(),i=L();function resolvePairs(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function createPairs(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let a={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:resolvePairs,createNode:createPairs};e.createPairs=createPairs,e.pairs=a,e.resolvePairs=resolvePairs})),Ot=__commonJSMin((e=>{var t=j(),n=M(),r=F(),i=L(),a=Dt(),o=class YAMLOMap extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=YAMLOMap.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),kt=__commonJSMin((e=>{var t=N();function boolStringify({value:e,source:t},i){return t&&(e?n:r).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}let n={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:boolStringify},r={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:boolStringify};e.falseTag=r,e.trueTag=n})),At=__commonJSMin((e=>{var t=N(),n=z();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),jt=__commonJSMin((e=>{var t=z();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e);function intResolve(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function intStringify(e,n,r){let{value:i}=e;if(intIdentify(i)){let e=i.toString(n);return i<0?`-`+r+e.substr(1):r+e}return t.stringifyNumber(e)}let n={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>intResolve(e,2,2,n),stringify:e=>intStringify(e,2,`0b`)},r={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>intResolve(e,1,8,n),stringify:e=>intStringify(e,8,`0`)},i={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},a={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)};e.int=i,e.intBin=n,e.intHex=a,e.intOct=r})),Mt=__commonJSMin((e=>{var t=j(),n=P(),r=F(),i=class YAMLSet extends r.YAMLMap{constructor(e){super(e),this.tag=YAMLSet.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),Nt=__commonJSMin((e=>{var t=z();function parseSexagesimal(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,num=e=>t?BigInt(e):Number(e),i=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*num(60)+num(t),num(0));return n===`-`?num(-1)*i:i}function stringifySexagesimal(e){let{value:n}=e,num=e=>e;if(typeof n==`bigint`)num=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let r=``;n<0&&(r=`-`,n*=num(-1));let i=num(60),a=[n%i];return n<60?a.unshift(0):(n=(n-a[0])/i,a.unshift(n%i),n>=60&&(n=(n-a[0])/i,a.unshift(n))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let n={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>parseSexagesimal(e,n),stringify:stringifySexagesimal},r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>parseSexagesimal(e,!1),stringify:stringifySexagesimal},i={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(i.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,a,o,s,c]=t.map(Number),l=t[7]?Number((t[7]+`00`).substr(1,3)):0,u=Date.UTC(n,r-1,a,o||0,s||0,c||0,l),d=t[8];if(d&&d!==`Z`){let e=parseSexagesimal(d,!1);Math.abs(e)<30&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=r,e.intTime=n,e.timestamp=i})),Pt=__commonJSMin((e=>{var t=I(),n=bt(),r=R(),i=yt(),a=Et(),o=kt(),s=At(),c=jt(),l=gt(),u=Ot(),d=Dt(),f=Mt(),p=Nt();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Ft=__commonJSMin((e=>{var t=I(),n=bt(),r=R(),i=yt(),a=xt(),o=St(),s=Ct(),c=wt(),l=Tt(),u=Et(),d=gt(),f=Ot(),p=Dt(),m=Pt(),h=Mt(),g=Nt();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function getTags(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=getTags})),It=__commonJSMin((e=>{var t=j(),n=I(),r=R(),i=yt(),a=Ft();let sortMapEntriesByKey=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class Schema{constructor({compat:e,customTags:o,merge:s,resolveKnownTags:c,schema:l,sortMapEntries:u,toStringDefaults:d}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof l==`string`&&l||`core`,this.knownTags=c?a.coreKnownTags:{},this.tags=a.getTags(o,this.name,s),this.toStringOptions=d??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof u==`function`?u:u===!0?sortMapEntriesByKey:null}clone(){let e=Object.create(Schema.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}})),Lt=__commonJSMin((e=>{var t=j(),n=pt(),r=ut();function stringifyDocument(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
129
73
|
`)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`)}else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
|
|
130
74
|
`)+`
|
|
131
|
-
`}e.stringifyDocument=stringifyDocument})),
|
|
132
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};e.YAMLError=YAMLError,e.YAMLParseError=YAMLParseError,e.YAMLWarning=YAMLWarning,e.prettifyError=prettifyError})),
|
|
133
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(containsNewline(t.key)||containsNewline(t.value))return!0}return!1;default:return!0}}e.containsNewline=containsNewline})),
|
|
134
|
-
`+
|
|
135
|
-
`+
|
|
136
|
-
`+
|
|
137
|
-
`+e:n.comment=e,
|
|
138
|
-
`+s.comment:i.comment=s.comment);let
|
|
139
|
-
`+e.comment:
|
|
140
|
-
`.repeat(Math.max(1,s.length-1)):``,t=i+a.length;return n.source&&(t+=n.source.length),{value:e,type:o,comment:a.comment,range:[i,t,t]}}let l=n.indent+a.indent,u=n.offset+a.length,d=0;for(let t=0;t<c;++t){let[n,i]=s[t];if(i===``||i===`\r`)a.indent===0&&n.length>l&&(l=n.length);else{n.length<l&&r(u+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),a.indent===0&&(l=n.length),d=t,l===0&&!e.atRoot&&r(u,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}u+=n.length+i.length+1}for(let e=s.length-1;e>=c;--e)s[e][0].length>l&&(c=e+1);let p=``,m
|
|
141
|
-
`;for(let e=d;e<c;++e){let[n,i]=s[e];u+=n.length+i.length+1;let c=i[i.length-1]===`\r`;if(c&&(i=i.slice(0,-1)),i&&n.length<l){let e=`Block scalar lines must not be less indented than their ${a.indent?`explicit indentation indicator`:`first line`}`;r(u-i.length-(c?2:1),`BAD_INDENT`,e),n=``}o===t.Scalar.BLOCK_LITERAL?(p
|
|
142
|
-
`):n.length>l||i[0]===` `?(
|
|
143
|
-
`:!
|
|
144
|
-
`&&(
|
|
75
|
+
`}e.stringifyDocument=stringifyDocument})),Rt=__commonJSMin((e=>{var t=st(),n=lt(),r=j(),i=P(),a=M(),o=It(),s=Lt(),c=rt(),l=it(),u=ct(),d=nt(),f=class Document{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(Document.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=r.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){assertCollection(this.contents)&&this.contents.add(e)}addIn(e,t){assertCollection(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let keyToStr=e=>typeof e==`number`||e instanceof String||e instanceof Number,e=t.filter(keyToStr).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return assertCollection(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):assertCollection(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):assertCollection(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):assertCollection(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function assertCollection(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),zt=__commonJSMin((e=>{var YAMLError=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},YAMLParseError=class extends YAMLError{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},YAMLWarning=class extends YAMLError{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};let prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
76
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};e.YAMLError=YAMLError,e.YAMLParseError=YAMLParseError,e.YAMLWarning=YAMLWarning,e.prettifyError=prettifyError})),Bt=__commonJSMin((e=>{function resolveProps(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=resolveProps})),Vt=__commonJSMin((e=>{function containsNewline(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
77
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(containsNewline(t.key)||containsNewline(t.value))return!0}return!1;default:return!0}}e.containsNewline=containsNewline})),Ht=__commonJSMin((e=>{var t=Vt();function flowIndentCheck(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=flowIndentCheck})),Ut=__commonJSMin((e=>{var t=j();function mapIncludes(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=mapIncludes})),Wt=__commonJSMin((e=>{var t=P(),n=F(),r=Bt(),i=Vt(),a=Ht(),o=Ut();let s=`All mapping items must start at the same column`;function resolveBlockMap({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
|
|
78
|
+
`+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
|
|
79
|
+
`+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=resolveBlockMap})),Gt=__commonJSMin((e=>{var t=L(),n=Bt(),r=Ht();function resolveBlockSeq({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=resolveBlockSeq})),B=__commonJSMin((e=>{function resolveEnd(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=resolveEnd})),Kt=__commonJSMin((e=>{var t=j(),n=P(),r=F(),i=L(),a=B(),o=Bt(),s=Vt(),c=Ut();let l=`Block collections are not allowed within flow collections`,isBlock=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function resolveFlowCollection({composeNode:e,composeEmptyNode:u},d,f,p,m){let h=f.start.source===`{`,g=h?`flow map`:`flow sequence`,_=new((m?.nodeClass)??(h?r.YAMLMap:i.YAMLSeq))(d.schema);_.flow=!0;let v=d.atRoot;v&&(d.atRoot=!1),d.atKey&&=!1;let y=f.offset+f.start.source.length;for(let i=0;i<f.items.length;++i){let a=f.items[i],{start:m,key:v,sep:b,value:x}=a,S=o.resolveProps(m,{flow:g,indicator:`explicit-key-ind`,next:v??b?.[0],offset:y,onError:p,parentIndent:f.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!b&&!x){i===0&&S.comma?p(S.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${g}`):i<f.items.length-1&&p(S.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${g}`),S.comment&&(_.comment?_.comment+=`
|
|
80
|
+
`+S.comment:_.comment=S.comment),y=S.end;continue}!h&&d.options.strict&&s.containsNewline(v)&&p(v,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)S.comma&&p(S.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${g}`);else if(S.comma||p(S.start,`MISSING_CHAR`,`Missing , between ${g} items`),S.comment){let e=``;loop:for(let t of m)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=_.items[_.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
|
|
81
|
+
`+e:n.comment=e,S.comment=S.comment.substring(e.length+1)}}if(!h&&!b&&!S.found){let t=x?e(d,x,S,p):u(d,S.end,b,null,S,p);_.items.push(t),y=t.range[2],isBlock(x)&&p(t.range,`BLOCK_IN_FLOW`,l)}else{d.atKey=!0;let t=S.end,i=v?e(d,v,S,p):u(d,t,m,null,S,p);isBlock(v)&&p(i.range,`BLOCK_IN_FLOW`,l),d.atKey=!1;let s=o.resolveProps(b??[],{flow:g,indicator:`map-value-ind`,next:x,offset:i.range[2],onError:p,parentIndent:f.indent,startOnNewline:!1});if(s.found){if(!h&&!S.found&&d.options.strict){if(b)for(let e of b){if(e===s.found)break;if(e.type===`newline`){p(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}S.start<s.found.offset-1024&&p(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else x&&(`source`in x&&x.source?.[0]===`:`?p(x,`MISSING_CHAR`,`Missing space after : in ${g}`):p(s.start,`MISSING_CHAR`,`Missing , or : between ${g} items`));let C=x?e(d,x,s,p):s.found?u(d,s.end,b,null,s,p):null;C?isBlock(x)&&p(C.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
|
|
82
|
+
`+s.comment:i.comment=s.comment);let w=new n.Pair(i,C);if(d.options.keepSourceTokens&&(w.srcToken=a),h){let e=_;c.mapIncludes(d,e.items,i)&&p(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(w)}else{let e=new r.YAMLMap(d.schema);e.flow=!0,e.items.push(w);let t=(C??i).range;e.range=[i.range[0],t[1],t[2]],_.items.push(e)}y=C?C.range[2]:s.end}}let b=h?`}`:`]`,[x,...S]=f.end,C=y;if(x?.source===b)C=x.offset+x.source.length;else{let e=g[0].toUpperCase()+g.substring(1),t=v?`${e} must end with a ${b}`:`${e} in block collection must be sufficiently indented and end with a ${b}`;p(y,v?`MISSING_CHAR`:`BAD_INDENT`,t),x&&x.source.length!==1&&S.unshift(x)}if(S.length>0){let e=a.resolveEnd(S,C,d.options.strict,p);e.comment&&(_.comment?_.comment+=`
|
|
83
|
+
`+e.comment:_.comment=e.comment),_.range=[f.offset,C,e.offset]}else _.range=[f.offset,C,C];return _}e.resolveFlowCollection=resolveFlowCollection})),qt=__commonJSMin((e=>{var t=j(),n=N(),r=F(),i=L(),a=Wt(),o=Gt(),s=Kt();function resolveCollection(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function composeCollection(e,a,o,s,c){let l=s.tag,u=l?a.directives.tagName(l.source,e=>c(l,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&l?e.offset>l.offset?e:l:e??l;n&&(!t||t.offset<n.offset)&&c(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let d=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!l||!u||u===`!`||u===r.YAMLMap.tagName&&d===`map`||u===i.YAMLSeq.tagName&&d===`seq`)return resolveCollection(e,a,o,c,u);let f=a.schema.tags.find(e=>e.tag===u&&e.collection===d);if(!f){let t=a.schema.knownTags[u];if(t?.collection===d)a.schema.tags.push(Object.assign({},t,{default:!1})),f=t;else return t?c(l,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${d} collection, but expects ${t.collection??`scalar`}`,!0):c(l,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${u}`,!0),resolveCollection(e,a,o,c,u)}let p=resolveCollection(e,a,o,c,u,f),m=f.resolve?.(p,e=>c(l,`TAG_RESOLVE_FAILED`,e),a.options)??p,h=t.isNode(m)?m:new n.Scalar(m);return h.range=p.range,h.tag=u,f?.format&&(h.format=f.format),h}e.composeCollection=composeCollection})),Jt=__commonJSMin((e=>{var t=N();function resolveBlockScalar(e,n,r){let i=n.offset,a=parseBlockScalarHeader(n,e.options.strict,r);if(!a)return{value:``,type:null,comment:``,range:[i,i,i]};let o=a.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,s=n.source?splitLines(n.source):[],c=s.length;for(let e=s.length-1;e>=0;--e){let t=s[e][1];if(t===``||t===`\r`)c=e;else break}if(c===0){let e=a.chomp===`+`&&s.length>0?`
|
|
84
|
+
`.repeat(Math.max(1,s.length-1)):``,t=i+a.length;return n.source&&(t+=n.source.length),{value:e,type:o,comment:a.comment,range:[i,t,t]}}let l=n.indent+a.indent,u=n.offset+a.length,d=0;for(let t=0;t<c;++t){let[n,i]=s[t];if(i===``||i===`\r`)a.indent===0&&n.length>l&&(l=n.length);else{n.length<l&&r(u+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),a.indent===0&&(l=n.length),d=t,l===0&&!e.atRoot&&r(u,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}u+=n.length+i.length+1}for(let e=s.length-1;e>=c;--e)s[e][0].length>l&&(c=e+1);let f=``,p=``,m=!1;for(let e=0;e<d;++e)f+=s[e][0].slice(l)+`
|
|
85
|
+
`;for(let e=d;e<c;++e){let[n,i]=s[e];u+=n.length+i.length+1;let c=i[i.length-1]===`\r`;if(c&&(i=i.slice(0,-1)),i&&n.length<l){let e=`Block scalar lines must not be less indented than their ${a.indent?`explicit indentation indicator`:`first line`}`;r(u-i.length-(c?2:1),`BAD_INDENT`,e),n=``}o===t.Scalar.BLOCK_LITERAL?(f+=p+n.slice(l)+i,p=`
|
|
86
|
+
`):n.length>l||i[0]===` `?(p===` `?p=`
|
|
87
|
+
`:!m&&p===`
|
|
88
|
+
`&&(p=`
|
|
145
89
|
|
|
146
|
-
`),p
|
|
147
|
-
`,
|
|
148
|
-
`?
|
|
149
|
-
`:
|
|
150
|
-
`:(p
|
|
151
|
-
`+s[e][0].slice(l);
|
|
152
|
-
`&&(
|
|
153
|
-
`);break;default:
|
|
154
|
-
`}let
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
`?i+=a:a=`
|
|
158
|
-
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function doubleQuotedValue(e,t){let n=``;for(let i=1;i<e.length-1;++i){let a=e[i];if(a!==`\r`||e[i+1]!==`
|
|
90
|
+
`),f+=p+n.slice(l)+i,p=`
|
|
91
|
+
`,m=!0):i===``?p===`
|
|
92
|
+
`?f+=`
|
|
93
|
+
`:p=`
|
|
94
|
+
`:(f+=p+i,p=` `,m=!1)}switch(a.chomp){case`-`:break;case`+`:for(let e=c;e<s.length;++e)f+=`
|
|
95
|
+
`+s[e][0].slice(l);f[f.length-1]!==`
|
|
96
|
+
`&&(f+=`
|
|
97
|
+
`);break;default:f+=`
|
|
98
|
+
`}let h=i+a.length+n.source.length;return{value:f,type:o,comment:a.comment,range:[i,h,h]}}function parseBlockScalarHeader({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function splitLines(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=resolveBlockScalar})),Yt=__commonJSMin((e=>{var t=N(),n=B();function resolveFlowScalar(e,r,i){let{offset:a,type:o,source:s,end:c}=e,l,u,_onError=(e,t,n)=>i(a+e,t,n);switch(o){case`scalar`:l=t.Scalar.PLAIN,u=plainValue(s,_onError);break;case`single-quoted-scalar`:l=t.Scalar.QUOTE_SINGLE,u=singleQuotedValue(s,_onError);break;case`double-quoted-scalar`:l=t.Scalar.QUOTE_DOUBLE,u=doubleQuotedValue(s,_onError);break;default:return i(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${o}`),{value:``,type:null,comment:``,range:[a,a+s.length,a+s.length]}}let d=a+s.length,f=n.resolveEnd(c,d,r,i);return{value:u,type:l,comment:f.comment,range:[a,d,f.offset]}}function plainValue(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),unfoldLines(e)}function singleQuotedValue(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),unfoldLines(e.slice(1,-1)).replace(/''/g,`'`)}function unfoldLines(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
|
|
99
|
+
`?a+=o:o=`
|
|
100
|
+
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function doubleQuotedValue(e,t){let n=``;for(let i=1;i<e.length-1;++i){let a=e[i];if(a!==`\r`||e[i+1]!==`
|
|
159
101
|
`){if(a===`
|
|
160
102
|
`){let{fold:t,offset:r}=foldNewline(e,i);n+=t,i=r}else if(a===`\\`){let a=e[++i],o=r[a];if(o)n+=o;else if(a===`
|
|
161
103
|
`)for(a=e[i+1];a===` `||a===` `;)a=e[++i+1];else if(a===`\r`&&e[i+1]===`
|
|
@@ -166,10 +108,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
166
108
|
`);)r===`
|
|
167
109
|
`&&(n+=`
|
|
168
110
|
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let r={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
169
|
-
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function parseCharCode(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=resolveFlowScalar})),
|
|
111
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function parseCharCode(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=resolveFlowScalar})),Xt=__commonJSMin((e=>{var t=j(),n=N(),r=Jt(),i=Yt();function composeScalar(e,a,o,s){let{value:c,type:l,comment:u,range:d}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,s):i.resolveFlowScalar(a,e.options.strict,s),f=o?e.directives.tagName(o.source,e=>s(o,`TAG_RESOLVE_FAILED`,e)):null,p;p=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:f?findScalarTagByName(e.schema,c,f,o,s):a.type===`scalar`?findScalarTagByTest(e,c,a,s):e.schema[t.SCALAR];let m;try{let r=p.resolve(c,e=>s(o??a,`TAG_RESOLVE_FAILED`,e),e.options);m=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);s(o??a,`TAG_RESOLVE_FAILED`,t),m=new n.Scalar(c)}return m.range=d,m.source=c,l&&(m.type=l),f&&(m.tag=f),p.format&&(m.format=p.format),u&&(m.comment=u),m}function findScalarTagByName(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function findScalarTagByTest({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=composeScalar})),Zt=__commonJSMin((e=>{function emptyScalarPosition(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=emptyScalarPosition})),Qt=__commonJSMin((e=>{var t=st(),n=j(),r=qt(),i=Xt(),a=B(),o=Zt();let s={composeNode,composeEmptyNode};function composeNode(e,t,a,o){let c=e.atKey,{spaceBefore:l,comment:u,anchor:d,tag:f}=a,p,m=!0;switch(t.type){case`alias`:p=composeAlias(e,t,o),(d||f)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:p=i.composeScalar(e,t,f,o),d&&(p.anchor=d.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{p=r.composeCollection(s,e,t,a,o),d&&(p.anchor=d.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),m=!1}return p??=composeEmptyNode(e,t.offset,void 0,null,a,o),d&&p.anchor===``&&o(d,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(p)||typeof p.value!=`string`||p.tag&&p.tag!==`tag:yaml.org,2002:str`)&&o(f??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),l&&(p.spaceBefore=!0),u&&(t.type===`scalar`&&t.source===``?p.comment=u:p.commentBefore=u),e.options.keepSourceTokens&&m&&(p.srcToken=t),p}function composeEmptyNode(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function composeAlias({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=composeEmptyNode,e.composeNode=composeNode})),$t=__commonJSMin((e=>{var t=Rt(),n=Qt(),r=B(),i=Bt();function composeDoc(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=composeDoc})),en=__commonJSMin((e=>{var t=Ie(`process`),n=nt(),r=Rt(),i=zt(),a=j(),o=$t(),s=B();function getErrorPos(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function parsePrelude(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
170
112
|
|
|
171
113
|
`:`
|
|
172
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=getErrorPos(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=parsePrelude(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:parsePrelude(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=getErrorPos(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}};e.Composer=Composer})),
|
|
114
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=getErrorPos(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=parsePrelude(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:parsePrelude(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=getErrorPos(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}};e.Composer=Composer})),tn=__commonJSMin((e=>{var t=Jt(),n=Yt(),r=zt(),i=ft();function resolveAsScalar(e,i=!0,a){if(e){let _onError=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,_onError);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,_onError)}}return null}function createScalarToken(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:`newline`,offset:-1,indent:r,source:`
|
|
173
115
|
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
174
116
|
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
175
117
|
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return addEndtoBlockProps(i,l)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
@@ -177,9 +119,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
177
119
|
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
178
120
|
`;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];addEndtoBlockProps(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
|
|
179
121
|
`});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function addEndtoBlockProps(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function setFlowScalarValue(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
|
|
180
|
-
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=createScalarToken,e.resolveAsScalar=resolveAsScalar,e.setScalarValue=setScalarValue})),
|
|
122
|
+
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=createScalarToken,e.resolveAsScalar=resolveAsScalar,e.setScalarValue=setScalarValue})),nn=__commonJSMin((e=>{let stringify=e=>`type`in e?stringifyToken(e):stringifyItem(e);function stringifyToken(e){switch(e.type){case`block-scalar`:{let t=``;for(let n of e.props)t+=stringifyToken(n);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=stringifyItem(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=stringifyItem(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=stringifyItem(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function stringifyItem({start:e,key:t,sep:n,value:r}){let i=``;for(let t of e)i+=t.source;if(t&&(i+=stringifyToken(t)),n)for(let e of n)i+=e.source;return r&&(i+=stringifyToken(r)),i}e.stringify=stringify})),rn=__commonJSMin((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function visit(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),_visit(Object.freeze([]),e,t)}visit.BREAK=t,visit.SKIP=n,visit.REMOVE=r,visit.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},visit.parentCollection=(e,t)=>{let n=visit.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function _visit(e,n,i){let a=i(n,e);if(typeof a==`symbol`)return a;for(let o of[`key`,`value`]){let s=n[o];if(s&&`items`in s){for(let n=0;n<s.items.length;++n){let a=_visit(Object.freeze(e.concat([[o,n]])),s.items[n],i);if(typeof a==`number`)n=a-1;else if(a===t)return t;else a===r&&(s.items.splice(n,1),--n)}typeof a==`function`&&o===`key`&&(a=a(n,e))}}return typeof a==`function`?a(n,e):a}e.visit=visit})),an=__commonJSMin((e=>{var t=tn(),n=nn(),r=rn();let isCollection=e=>!!e&&`items`in e,isScalar=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function prettyToken(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function tokenType(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
181
123
|
`:case`\r
|
|
182
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=isCollection,e.isScalar=isScalar,e.prettyToken=prettyToken,e.tokenType=tokenType})),
|
|
124
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=isCollection,e.isScalar=isScalar,e.prettyToken=prettyToken,e.tokenType=tokenType})),on=__commonJSMin((e=>{var t=an();function isEmpty(e){switch(e){case void 0:case` `:case`
|
|
183
125
|
`:case`\r`:case` `:return!0;default:return!1}}let n=new Set(`0123456789ABCDEFabcdef`),r=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),i=new Set(`,[]{}`),a=new Set(` ,[]{}
|
|
184
126
|
\r `),isNotAnchorChar=e=>!e||a.has(e);var Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
185
127
|
`||t===`\r`&&this.buffer[e+1]===`
|
|
@@ -198,29 +140,25 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
198
140
|
`,t=this.buffer[r+1]):n=r),t===`#`||e&&i.has(t))break;if(a===`
|
|
199
141
|
`){let e=this.continueScalar(r+1);if(e===-1)break;r=Math.max(r,e-2)}}else{if(e&&i.has(a))break;n=r}return!a&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(n+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(isNotAnchorChar),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(isEmpty(n)||t&&i.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!isEmpty(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(r.has(t))t=this.buffer[++e];else if(t===`%`&&n.has(this.buffer[e+1])&&n.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
200
142
|
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
201
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};e.Lexer=Lexer})),
|
|
143
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};e.Lexer=Lexer})),sn=__commonJSMin((e=>{var LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};e.LineCounter=LineCounter})),cn=__commonJSMin((e=>{var t=Ie(`process`),n=an(),r=on();function includesToken(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function findNonEmptyIndex(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function isFlowToken(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function getPrevProps(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function getFirstKeyStartProps(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function arrayPushArray(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function fixFlowSeqItems(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!includesToken(t.start,`explicit-key-ind`)&&!includesToken(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,isFlowToken(t.value)?t.value.end?arrayPushArray(t.value.end,t.sep):t.value.end=t.sep:arrayPushArray(t.start,t.sep),delete t.sep)}var Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&fixFlowSeqItems(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&findNonEmptyIndex(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:findNonEmptyIndex(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=getFirstKeyStartProps(getPrevProps(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
202
144
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
203
145
|
`,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)){arrayPushArray(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`,i=[];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&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),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?(i.push(this.sourceToken),e.items.push({start:i,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(includesToken(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=getFirstKeyStartProps(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(includesToken(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(isFlowToken(t.key)&&!includesToken(t.sep,`newline`)){let e=getFirstKeyStartProps(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 i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):includesToken(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:i,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&&!includesToken(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:i});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)){arrayPushArray(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||includesToken(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=getFirstKeyStartProps(getPrevProps(t));fixFlowSeqItems(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(`
|
|
204
146
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
205
|
-
`,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=getFirstKeyStartProps(getPrevProps(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=getFirstKeyStartProps(getPrevProps(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())}}};e.Parser=Parser})),Eo=__commonJSMin((e=>{var t=vo(),n=eo(),r=to(),i=Ta(),a=X(),o=wo(),s=To();function parseOptions(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function parseAllDocuments(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=Array.from(c.compose(o.parse(e)));if(a&&i)for(let t of l)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return l.length>0?l:Object.assign([],{empty:!0},c.streamInfo())}function parseDocument(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=null;for(let t of c.compose(o.parse(e),!0,e.length))if(!l)l=t;else if(l.options.logLevel!==`silent`){l.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(l.errors.forEach(r.prettifyError(e,i)),l.warnings.forEach(r.prettifyError(e,i))),l}function parse(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=parseDocument(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 stringify(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=parse,e.parseAllDocuments=parseAllDocuments,e.parseDocument=parseDocument,e.stringify=stringify})),Do=__commonJSMin((e=>{var t=vo(),n=eo(),r=Qa(),i=to(),a=_a(),o=X(),s=Oa(),c=Z(),l=Aa(),u=Ma();So();var d=Co(),p=wo(),m=To(),h=Eo(),g=da();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=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}))();const isOne=e=>e===`1`,isSet=e=>e!==``,Oo={name:`CLAUDECODE`,matches:isOne,description:`Claude Code sets CLAUDECODE=1 in subprocesses it spawns; IDE extensions also set it in integrated terminals`,research:`E-CC-D1`},ko=[{harness:`claude-code`,all:[Oo,{name:`CLAUDE_CODE_CHILD_SESSION`,matches:isOne,description:`Claude Code sets CLAUDE_CODE_CHILD_SESSION=1 for tool, hook, and status line subprocesses`,research:`E-CC-D3`}]},{harness:`claude-code`,all:[Oo,{name:`CLAUDE_CODE_SESSION_ID`,matches:isSet,description:`Claude Code sets CLAUDE_CODE_SESSION_ID in tool, hook, and stdio MCP server subprocesses`,research:`E-CC-D6`}]},{harness:`cursor`,all:[{name:`CURSOR_AGENT`,matches:isOne,description:`Cursor sets CURSOR_AGENT=1 on terminal commands its agent runs`,research:`E-CUR-D1`}]},{harness:`cursor`,all:[{name:`CURSOR_VERSION`,matches:isSet,description:`Cursor sets CURSOR_VERSION for hook commands`,research:`E-CUR-D10`},{name:`CURSOR_PROJECT_DIR`,matches:isSet,description:`Cursor sets CURSOR_PROJECT_DIR for hook commands`,research:`E-CUR-D10`}]},{harness:`codex`,all:[{name:`CODEX_THREAD_ID`,matches:isSet,description:`Codex injects CODEX_THREAD_ID into shell tool commands, even under a restrictive shell env policy`,research:`E-CODEX-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_CLI`,matches:isOne,description:`Copilot CLI sets COPILOT_CLI=1 in its subprocesses`,research:`E-COPILOT-D1`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_AGENT_SESSION_ID`,matches:isSet,description:`Copilot CLI passes COPILOT_AGENT_SESSION_ID to shell commands and MCP servers`,research:`E-COPILOT-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_PLUGIN_ROOT`,matches:isSet,description:`Copilot CLI passes COPILOT_PLUGIN_ROOT to plugin hooks`,research:`E-COPILOT-D6`}]},{harness:`opencode`,all:[{name:`OPENCODE`,matches:isOne,description:`OpenCode sets OPENCODE=1 for shell tool commands and MCP servers; Kilo Code, its fork, sets it too`,research:`E-OC-D1`},{name:`OPENCODE_PID`,matches:isSet,description:`OpenCode sets OPENCODE_PID for shell tool commands and MCP servers; Kilo Code sets KILO_PID instead`,research:`E-OC-D2`}]},{harness:`kilo`,all:[{name:`KILO`,matches:isOne,description:`Kilo Code sets KILO=1 for shell tool commands and MCP servers`,research:`E-KILO-D2`},{name:`KILO_PID`,matches:isSet,description:`Kilo Code sets KILO_PID for shell tool commands and MCP servers`,research:`E-KILO-D1`}]},{harness:`gemini-cli`,all:[{name:`GEMINI_CLI`,matches:isOne,description:`Gemini CLI sets GEMINI_CLI=1 for shell tool commands and MCP stdio servers`,research:`E-GEM-D1`}]},{harness:`qwen-code`,all:[{name:`QWEN_CODE`,matches:isOne,description:`Qwen Code sets QWEN_CODE=1 for shell tool commands, not for MCP servers or hooks`,research:`E-QWEN-D1`}]},{harness:`vscode-copilot`,all:[{name:`COPILOT_AGENT`,matches:isOne,description:`VS Code 1.121+ sets COPILOT_AGENT=1 on terminals its Copilot agent runs commands in`,research:`E-VSC-D1`}]},{harness:`cline`,all:[{name:`CLINE_ACTIVE`,matches:e=>e===`true`,description:`Cline's VS Code extension sets CLINE_ACTIVE=true on the terminals it creates; the Cline CLI does not`,research:`E-CLINE-D1`}]},{harness:`crush`,all:[{name:`CRUSH`,matches:isOne,description:`Crush sets CRUSH=1 for bash tool and hook commands, not for MCP servers`,research:`E-CRUSH-D1`}]},{harness:`openhands`,all:[{name:`AI_AGENT`,matches:e=>e===`openhands`,description:`OpenHands (SDK 1.40.1 and later) sets AI_AGENT=openhands for terminal tool and hook commands when AI_AGENT is unset; other vendors use the name with other values`,research:`E-OH-D1`}]},{harness:`openhands`,all:[{name:`OPENHANDS_EVENT_TYPE`,matches:isSet,description:`OpenHands sets OPENHANDS_EVENT_TYPE for hook commands`,research:`E-OH-D4`},{name:`OPENHANDS_PROJECT_DIR`,matches:isSet,description:`OpenHands sets OPENHANDS_PROJECT_DIR for hook commands`,research:`E-OH-D4`}]},{harness:`augment`,all:[{name:`AUGMENT_HOOK_EVENT`,matches:isSet,description:`The Auggie CLI sets AUGMENT_HOOK_EVENT for hook commands; its shell commands carry no marker`,research:`E-AUG-D3`},{name:`AUGMENT_PROJECT_DIR`,matches:isSet,description:`The Auggie CLI sets AUGMENT_PROJECT_DIR for hook commands`,research:`E-AUG-D3`}]}];function detectHarness(e={}){let t=e.env??process.env,n=[],r=[];for(let e of ko){let i=e.all.filter(e=>{let n=t[e.name];return n!==void 0&&e.matches(n)});for(let t of i)n.some(n=>n.harness===e.harness&&n.signal===t.name)||n.push({harness:e.harness,signal:t.name,description:t.description,research:t.research});i.length===e.all.length&&!r.includes(e.harness)&&r.push(e.harness)}return{harness:r.length===1?r[0]:`unknown`,evidence:n,candidates:r}}function managedPolicyLocations(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;return Ao[e](n,r)}const joinFor=e=>e===`win32`?T.join:x.join,dirnameFor=e=>e===`win32`?T.dirname:x.dirname;function opencodeFamily(e,t,n,r){let i={darwin:`/Library/Application Support/${n}`,linux:`/etc/${n}`,win32:T.join(t.ProgramData??`C:\\ProgramData`,n)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`ai.opencode.managed`,description:`MDM configuration profile; outranks the managed config folder`,research:r.preferences}),...when(i!==void 0,{kind:`directory`,location:i??``,description:`Managed config files; outrank user and project config`,research:r.directory})]}function geminiFamily(e,t,n){let r=e===`darwin`||e===`win32`?n.dirs[e]:n.dirs.linux,i=t[n.settingsVariable]||joinFor(e)(r,`settings.json`),a=t[n.defaultsVariable]||joinFor(e)(dirnameFor(e)(i),`system-defaults.json`);return[{kind:`file`,location:i,description:`System settings; outrank user and workspace settings. ${n.settingsVariable} overrides the path`,research:n.research},{kind:`file`,location:a,description:`System defaults; user and workspace settings override them. ${n.defaultsVariable} overrides the path`,research:n.research}]}const when=(e,...t)=>e?t:[],Ao={"claude-code":e=>{let t={darwin:`/Library/Application Support/ClaudeCode`,linux:`/etc/claude-code`,win32:`C:\\Program Files\\ClaudeCode`}[e],n=joinFor(e);return[{kind:`server`,location:`claude.ai admin console or a self-hosted Claude apps gateway`,description:`Server-managed settings; the highest-ranked managed source`,research:`E-CC-M6`},...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.anthropic.claudecode`,description:`MDM configuration profile with the same top-level keys as managed-settings.json`,research:`E-CC-M6`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\ClaudeCode`,description:`MDM or Group Policy; the Settings value holds managed-settings JSON`,research:`E-CC-M6`}),...when(t!==void 0,{kind:`file`,location:n(t??``,`managed-settings.json`),description:`Managed settings, same shape as settings.json`,research:`E-CC-M1`},{kind:`directory`,location:n(t??``,`managed-settings.d`),description:`Drop-in managed settings files, merged with managed-settings.json`,research:`E-CC-M1`},{kind:`file`,location:n(t??``,`managed-mcp.json`),description:`Managed MCP servers`,research:`E-CC-M1`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKCU\\SOFTWARE\\Policies\\ClaudeCode`,description:`User-writable; used only when no other managed source delivers a policy key`,research:`E-CC-M6`})]},cursor:e=>{let t={darwin:`/Library/Application Support/Cursor/hooks.json`,linux:`/etc/cursor/hooks.json`,win32:`C:\\ProgramData\\Cursor\\hooks.json`}[e];return[...when(t!==void 0,{kind:`file`,location:t??``,description:`Enterprise hooks deployed by MDM; hooks only, not other enterprise settings`,research:`E-CUR-M1`}),{kind:`server`,location:`Cursor dashboard`,description:`Team hooks and other enterprise settings, synced from the dashboard`,research:`E-CUR-M1`}]},codex:(e,t)=>{let n={kind:`server`,location:`ChatGPT workspace admin settings`,description:`Cloud-managed requirements; outrank every local source`,research:`E-CODEX-M8`};return e===`win32`?[n,{kind:`file`,location:T.join(t.ProgramData??`C:\\ProgramData`,`OpenAI`,`Codex`,`requirements.toml`),description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M4`}]:[n,...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.openai.codex`,description:`MDM keys requirements_toml_base64 (enforced) and config_toml_base64 (managed defaults)`,research:`E-CODEX-M6`}),{kind:`file`,location:`/etc/codex/requirements.toml`,description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M3`},{kind:`file`,location:`/etc/codex/managed_config.toml`,description:`Managed defaults; a user can override them within a session`,research:`E-CODEX-M2`},{kind:`file`,location:`/etc/codex/config.toml`,description:`System-wide config`,research:`E-CODEX-M1`}]},"copilot-cli":(e,t)=>{let n={darwin:`/Library/Application Support/GitHubCopilot/managed-settings.json`,linux:`/etc/github-copilot/managed-settings.json`,win32:T.join(t.ProgramFiles??`C:\\Program Files`,`GitHubCopilot`,`managed-settings.json`)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.github.copilot`,description:`MDM-managed settings; the highest-ranked source`,research:`E-COPILOT-M2`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\GitHubCopilot`,description:`MDM-managed settings as REG_SZ values; the highest-ranked source`,research:`E-COPILOT-M2`}),{kind:`server`,location:`copilot/managed-settings.json in the enterprise's .github-private repository`,description:`Server-managed settings, fetched for the signed-in account`,research:`E-COPILOT-M3`},...when(n!==void 0,{kind:`file`,location:n??``,description:`File-based managed settings; on macOS and Linux it must be a root-owned regular file`,research:`E-COPILOT-M1`})]},opencode:(e,t)=>[...opencodeFamily(e,t,`opencode`,{directory:`E-OC-M1`,preferences:`E-OC-M1`}),{kind:`server`,location:`Remote config at the organization domain /.well-known/opencode`,description:`Organization defaults; the lowest-ranked config source, so user config overrides them`,research:`E-OC-M2`}],kilo:(e,t)=>opencodeFamily(e,t,`kilo`,{directory:`E-KILO-M1`,preferences:`E-KILO-M2`}),"gemini-cli":(e,t)=>geminiFamily(e,t,{settingsVariable:`GEMINI_CLI_SYSTEM_SETTINGS_PATH`,defaultsVariable:`GEMINI_CLI_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/GeminiCli`,linux:`/etc/gemini-cli`,win32:`C:\\ProgramData\\gemini-cli`},research:`E-GEM-M1`}),"qwen-code":(e,t)=>geminiFamily(e,t,{settingsVariable:`QWEN_CODE_SYSTEM_SETTINGS_PATH`,defaultsVariable:`QWEN_CODE_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/QwenCode`,linux:`/etc/qwen-code`,win32:`C:\\ProgramData\\qwen-code`},research:`E-QWEN-M1`}),"vscode-copilot":e=>[...when(e===`win32`,{kind:`windows-registry`,location:`Software\\Policies\\Microsoft\\VSCode`,description:`VS Code policies set by Group Policy (ADMX templates ship with VS Code)`,research:`E-VSC-M1`}),...when(e===`linux`,{kind:`file`,location:`/etc/vscode/policy.json`,description:`VS Code policies as JSON, read by VS Code 1.106 and later`,research:`E-VSC-M3`})],cline:()=>[{kind:`server`,location:`Cline Enterprise admin console`,description:`Provider, model, and tool policy pushed to clients; no local policy file is documented`,research:`E-CLINE-M1`}],crush:e=>when(e!==`win32`,{kind:`file`,location:`/etc/crush/crush.json`,description:`System config; the lowest-ranked source, so user and project config override it`,research:`E-CRUSH-M1`}),openhands:()=>[{kind:`server`,location:`OpenHands Cloud or Enterprise deployment`,description:`Organization controls held server-side; no local policy file is known`,research:`E-OH-D8`}],augment:(e,t)=>[{kind:`file`,location:e===`win32`?T.join(t.ProgramData||`C:\\ProgramData`,`augment`,`settings.json`):`/etc/augment/settings.json`,description:`System settings, read from the Auggie CLI bundle; its rank against user settings is not documented`,research:`E-AUG-M1`}]};function resolveHarnessEnvironment(e={}){return{env:e.env??process.env,homedir:e.homedir??ee(),cwd:e.cwd??process.cwd(),platform:e.platform??process.platform}}async function readText(e){try{return await ne(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}function stripJsonComments$1(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`"`){let r=n+1;for(;r<e.length&&e[r]!==`"`;)r+=e[r]===`\\`?2:1;t+=e.slice(n,r+1),n=r+1}else if(r===`/`&&e[n+1]===`/`)for(;n<e.length&&e[n]!==`
|
|
206
|
-
`;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2}else t+=r,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}__name(stripJsonComments$1,`stripJsonComments`);function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pluginStorage(e,t={}){return jo[e](resolveHarnessEnvironment(t))}const xdgConfig=({env:e,homedir:t})=>e.XDG_CONFIG_HOME||y(t,`.config`);function vscodeAgentPlugins({env:e,homedir:t,platform:n}){if(n===`win32`){let n=T.join(e.APPDATA||T.join(t,`AppData`,`Roaming`),`Code`);return{configDir:n,path:T.join(n,`agentPlugins`)}}let r=n===`darwin`?y(t,`Library`,`Application Support`,`Code`):y(t,`.config`,`Code`);return{configDir:r,path:y(r,`agentPlugins`)}}const jo={"claude-code":({env:e,homedir:t})=>{let n=e.CLAUDE_CONFIG_DIR||y(t,`.claude`),r=y(n,`plugins`);return{harness:`claude-code`,configDir:n,locations:[{kind:`plugin-cache`,path:y(r,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CC-P1`},{kind:`marketplaces`,path:y(r,`marketplaces`),description:`Marketplace checkouts`,research:`E-CC-P1`},{kind:`install-record`,path:y(r,`installed_plugins.json`),description:`Installs keyed by plugin@marketplace, each with scope, installPath, and version`,research:`E-CC-P2`},{kind:`enabled-record`,path:y(n,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-CC-P3`}]}},cursor:({homedir:e})=>{let t=y(e,`.cursor`);return{harness:`cursor`,configDir:t,locations:[{kind:`local-plugins`,path:y(t,`plugins`,`local`),description:`Plugins under development, one folder each`,research:`E-CUR-P2`},{kind:`marketplaces`,path:y(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-CUR-P3`}]}},codex:({env:e,homedir:t})=>{let n=e.CODEX_HOME||y(t,`.codex`);return{harness:`codex`,configDir:n,locations:[{kind:`plugin-cache`,path:y(n,`plugins`,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CODEX-P3`},{kind:`enabled-record`,path:y(n,`config.toml`),description:`User config; [plugins."<plugin>@<marketplace>"] tables carry enabled = <bool>`,research:`E-CODEX-P2`}]}},"copilot-cli":({env:e,homedir:t})=>{let n=e.COPILOT_HOME||y(t,`.copilot`);return{harness:`copilot-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:y(n,`installed-plugins`),description:`Installed plugins as <marketplace>/<plugin>/, or _direct/<source-id>/ for direct installs`,research:`E-COPILOT-P9`},{kind:`install-record`,path:y(n,`config.json`),description:`Application state, including installedPlugins`,research:`E-COPILOT-P9`},{kind:`enabled-record`,path:y(n,`settings.json`),description:`User settings (JSON with comments); enabledPlugins maps plugin specs to a boolean`,research:`E-COPILOT-P4`}]}},opencode:e=>{let t=y(xdgConfig(e),`opencode`);return{harness:`opencode`,configDir:t,locations:[{kind:`local-plugins`,path:y(t,`plugins`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-OC-P2`}]}},kilo:e=>{let t=y(xdgConfig(e),`kilo`);return{harness:`kilo`,configDir:t,locations:[{kind:`local-plugins`,path:y(t,`plugin`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-KILO-P2`}]}},"gemini-cli":({env:e,homedir:t})=>{let n=y(e.GEMINI_CLI_HOME||t,`.gemini`),r=y(n,`extensions`);return{harness:`gemini-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a gemini-extension.json manifest`,research:`E-GEM-P1`},{kind:`enabled-record`,path:y(r,`extension-enablement.json`),description:`Per-extension path-glob overrides that enable or disable it by folder, not a boolean`,research:`E-GEM-P3`}]}},"qwen-code":({env:e,homedir:t})=>{let n=e.QWEN_HOME||y(t,`.qwen`),r=y(n,`extensions`);return{harness:`qwen-code`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a qwen-extension.json manifest`,research:`E-QWEN-P1`},{kind:`enabled-record`,path:y(r,`extension-enablement.json`),description:`Extension enable/disable state, inherited from Gemini CLI's format`,research:`E-QWEN-P2`}]}},"vscode-copilot":e=>{let{configDir:t,path:n}=vscodeAgentPlugins(e);return{harness:`vscode-copilot`,configDir:t,locations:[{kind:`installed-plugins`,path:n,description:`Installed agent plugins as <host>/<org>/<repo>/`,research:`E-VSC-P3`}]}},cline:({homedir:e})=>{let t=y(e,`.cline`);return{harness:`cline`,configDir:t,locations:[{kind:`installed-plugins`,path:y(t,`plugins`,`_installed`),description:`Installed plugins, grouped by source: npm, git, remote, or local`,research:`E-CLINE-P3`}]}},crush:({env:e,homedir:t})=>({harness:`crush`,configDir:e.CRUSH_GLOBAL_CONFIG||y(e.XDG_CONFIG_HOME||y(t,`.config`),`crush`),locations:[]}),openhands:({env:e,homedir:t})=>{let n=e.OH_PERSISTENCE_DIR||e.OPENHANDS_PERSISTENCE_DIR||y(t,`.openhands`),r=y(n,`plugins`,`installed`);return{harness:`openhands`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed plugins, one folder each`,research:`E-OH-P3`},{kind:`enabled-record`,path:y(r,`.installed.json`),description:`Install metadata keyed by plugin name, each with enabled: <bool>`,research:`E-OH-P4`}]}},augment:({homedir:e})=>{let t=y(e,`.augment`);return{harness:`augment`,configDir:t,locations:[{kind:`marketplaces`,path:y(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-AUG-P2`},{kind:`enabled-record`,path:y(t,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-AUG-P4`}]}}};async function enabledPlugins(e,t={}){let n=Fo[e](resolveHarnessEnvironment(t),t.managedSettingsPath),r=new Map,i=[];for(let e of n.sources){let t;try{let n=await readText(e.path);if(n===void 0){i.push({scope:e.scope,path:e.path,found:!1});continue}t=e.parse(n)}catch(t){i.push({scope:e.scope,path:e.path,found:!0,error:String(t)});continue}i.push({scope:e.scope,path:e.path,found:!0});for(let[n,i]of Object.entries(t))r.has(n)||r.set(n,{id:n,enabled:i,scope:e.scope,source:e.path})}return{harness:e,supported:n.supported,plugins:[...r.values()],sources:i,unread:n.unread,research:n.research}}function jsonEnabledPlugins(e){let t=JSON.parse(e),n=isRecord(t)?t.enabledPlugins:void 0;return isRecord(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`boolean`)):{}}const Mo=/^\[\s*plugins\s*\.\s*(?:"([^"]*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/,No=/^enabled\s*=\s*(true|false)\s*(?:#.*)?$/;function tomlEnabledPlugins(e){let t={},n;for(let r of e.split(/\r?\n/)){let e=r.trim();if(e.startsWith(`[`)){let t=Mo.exec(e);n=t?t[1]??t[2]??t[3]:void 0;continue}let i=n===void 0?null:No.exec(e);n!==void 0&&i&&(t[n]=i[1]===`true`)}return t}const Po={server:`server-managed settings`,"macos-managed-preferences":`MDM managed preferences`,"windows-registry":`Windows registry policy`,directory:`drop-in managed settings`,file:`managed file`};function unreadPolicy(e,t,n=[]){return e.filter(e=>e.location!==t&&!n.some(t=>e.location.endsWith(t))).map(e=>`${Po[e.kind]} (${e.location})`)}function managedFile(e,t){return e.find(e=>e.kind===`file`&&e.location.endsWith(t))?.location}function jsoncEnabledPlugins(e){return jsonEnabledPlugins(stripJsonComments$1(e))}const unsupported$1=(...e)=>({supported:!1,sources:[],unread:[],research:e}),Fo={"claude-code":(e,t)=>{let{configDir:n}=pluginStorage(`claude-code`,e),r=managedPolicyLocations(`claude-code`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=y(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsonEnabledPlugins}],{scope:`local`,path:y(o,`settings.local.json`),parse:jsonEnabledPlugins},{scope:`project`,path:y(o,`settings.json`),parse:jsonEnabledPlugins},{scope:`user`,path:y(n,`settings.json`),parse:jsonEnabledPlugins}],unread:unreadPolicy(r,i,[`managed-mcp.json`]),research:[`E-CC-P3`,`E-CC-P7`,`E-CC-M1`,`E-CC-M6`]}},cursor:()=>unsupported$1(),opencode:()=>unsupported$1(`E-OC-P3`),kilo:()=>unsupported$1(`E-KILO-P3`),"gemini-cli":()=>unsupported$1(`E-GEM-P3`),"qwen-code":()=>unsupported$1(`E-QWEN-P2`),"vscode-copilot":()=>unsupported$1(`E-VSC-P4`),cline:()=>unsupported$1(`E-CLINE-P4`),crush:()=>unsupported$1(`E-CRUSH-P2`),openhands:()=>unsupported$1(`E-OH-P4`),augment:()=>unsupported$1(`E-AUG-P4`),codex:e=>{let t=pluginStorage(`codex`,e);return{supported:!0,sources:[{scope:`user`,path:y(t.configDir,`config.toml`),parse:tomlEnabledPlugins}],unread:unreadPolicy(managedPolicyLocations(`codex`,e),void 0),research:[`E-CODEX-P2`,`E-CODEX-M7`]}},"copilot-cli":(e,t)=>{let n=pluginStorage(`copilot-cli`,e),r=managedPolicyLocations(`copilot-cli`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=y(e.cwd,`.github`,`copilot`),s=y(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsoncEnabledPlugins}],{scope:`local`,path:y(o,`settings.local.json`),parse:jsoncEnabledPlugins},{scope:`project`,path:y(o,`settings.json`),parse:jsoncEnabledPlugins},{scope:`user`,path:y(n.configDir,`settings.json`),parse:jsoncEnabledPlugins}],unread:[...unreadPolicy(r,i),`Claude Code project settings (${y(s,`settings.json`)})`,`Claude Code local settings (${y(s,`settings.local.json`)})`],research:[`E-COPILOT-P4`,`E-COPILOT-M1`,`E-COPILOT-M2`,`E-COPILOT-M4`]}}};async function installedPlugins(e,t={}){let n=Wo[e](resolveHarnessEnvironment(t)),r={harness:e,supported:n.supported,unread:n.unread,research:n.research};if(n.source===void 0)return{...r,plugins:[],unresolved:[],sources:[]};let i=n.source;try{let e=await n.read(i);return e===void 0?{...r,plugins:[],unresolved:[],sources:[{path:i,found:!1}]}:{...r,plugins:e.plugins,unresolved:e.unresolved??[],sources:[{path:i,found:!0}]}}catch(e){return{...r,plugins:[],unresolved:[],sources:[{path:i,found:!0,error:String(e)}]}}}const Io=[`managed`,`local`,`project`,`user`],optionalString=e=>typeof e==`string`&&e!==``?e:void 0;async function readClaudeInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(t),r=isRecord(n)?n.plugins:void 0;if(!isRecord(r))return{plugins:[]};let i=[];for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let n of t){let t=isRecord(n)?optionalString(n.installPath):void 0;if(!isRecord(n)||t===void 0)continue;let r=optionalString(n.version),a=typeof n.scope==`string`&&Io.includes(n.scope)?n.scope:void 0,o=optionalString(n.projectPath);i.push({id:e,path:t,...r===void 0?{}:{version:r},...a===void 0?{}:{scope:a},...o===void 0?{}:{projectPath:o},research:[`E-CC-P2`]})}return{plugins:i}}async function readCopilotInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(stripJsonComments$1(t)),r=isRecord(n)?n.installedPlugins:void 0;if(!Array.isArray(r))return{plugins:[]};let i=[];for(let e of r){if(!isRecord(e))continue;let t=optionalString(e.name),n=optionalString(e.cache_path);if(t===void 0||n===void 0)continue;let r=optionalString(e.marketplace),a=optionalString(e.version);i.push({id:r===void 0?t:`${t}@${r}`,path:n,...a===void 0?{}:{version:a},research:r===void 0?[`E-COPILOT-P10`,`E-COPILOT-P11`]:[`E-COPILOT-P10`]})}return{plugins:i}}const Lo=`local`,Ro=/^[A-Za-z0-9_-]+$/,zo=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/,Bo=/^[A-Za-z0-9._+-]+$/;async function readCodexInstalls(e){let t=await directories$1(e);if(t===void 0)return;let n=[],r=[];for(let i of t.filter(e=>Ro.test(e)))for(let t of await directories$1(y(e,i))??[]){if(!zo.test(t))continue;let a=`${t}@${i}`,o=(await directories$1(y(e,i,t))??[]).filter(e=>Bo.test(e)&&e!==`.`&&e!==`..`);if(o.length===0)continue;let s=activeCodexVersion(o);if(s===void 0){r.push(a);continue}n.push({id:a,path:y(e,i,t,s),version:s,research:[`E-CODEX-P3`,`E-CODEX-P8`]})}return{plugins:n,unresolved:r}}function activeCodexVersion(e){if(e.includes(Lo))return Lo;let t=e.filter(e=>parseSemver(e)!==void 0).length;if(!(e.length>2&&t!==0&&t!==e.length))return[...e].sort(compareCodexVersions).at(-1)}async function directories$1(e){try{return(await re(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e.code===`ENOENT`)return;throw e}}__name(directories$1,`directories`);const Vo=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function parseSemver(e){let t=Vo.exec(e);if(t)return{core:[t[1],t[2],t[3]],pre:t[4]===void 0?[]:t[4].split(`.`),build:t[5]===void 0?[]:t[5].split(`.`)}}function compareCodexVersions(e,t){let n=parseSemver(e),r=parseSemver(t);if(n===void 0||r===void 0)return compareStrings(e,t);for(let e=0;e<3;e++){let t=compareNumeric(n.core[e],r.core[e]);if(t!==0)return t}let i=n.pre.length===0||r.pre.length===0?r.pre.length-n.pre.length:compareIdentifiers(n.pre,r.pre);return i===0?compareIdentifiers(n.build,r.build):Math.sign(i)}const Ho=/^\d+$/;function compareIdentifiers(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=Ho.test(r),o=Ho.test(i),s=a&&o?compareNumeric(r,i):a===o?compareStrings(r,i):a?-1:1;if(s!==0)return s}return e.length-t.length}function compareNumeric(e,t){let n=e.replace(/^0+(?=\d)/,``),r=t.replace(/^0+(?=\d)/,``);return n.length-r.length||compareStrings(n,r)||e.length-t.length}const compareStrings=(e,t)=>e<t?-1:+(e>t),Uo={supported:!1,read:async()=>void 0,unread:[],research:[]},Wo={"claude-code":e=>({supported:!0,source:y(pluginStorage(`claude-code`,e).configDir,`plugins`,`installed_plugins.json`),read:readClaudeInstalls,unread:[],research:[`E-CC-P2`]}),codex:e=>({supported:!0,source:y(pluginStorage(`codex`,e).configDir,`plugins`,`cache`),read:readCodexInstalls,unread:[],research:[`E-CODEX-P3`,`E-CODEX-P8`]}),"copilot-cli":e=>{let{configDir:t}=pluginStorage(`copilot-cli`,e);return{supported:!0,source:y(t,`config.json`),read:readCopilotInstalls,unread:[`plugins from marketplaces added by local path (extraKnownMarketplaces in ${y(t,`settings.json`)})`],research:[`E-COPILOT-P10`,`E-COPILOT-P11`,`E-COPILOT-P12`,`E-COPILOT-P13`]}},cursor:()=>Uo,opencode:()=>Uo,kilo:()=>Uo,"gemini-cli":()=>Uo,"qwen-code":()=>Uo,"vscode-copilot":()=>Uo,cline:()=>Uo,crush:()=>Uo,openhands:()=>Uo,augment:()=>Uo};function declaredDependencies(e){if(!e||typeof e!=`object`)return[];let t=e,n=new Set;for(let e of[`dependencies`,`devDependencies`]){let r=t[e];if(r&&typeof r==`object`)for(let e of Object.keys(r))n.add(e)}return[...n].sort()}function ancestorCandidates(e,t){let n=t.split(`/`),r=[],i=e;for(;;){r.push(y(i,`node_modules`,...n));let e=_(i);if(e===i)break;i=e}return r}function packageDir(t,n){try{let r=e(n);return _(r.resolve(`${t}/package.json`))}catch{}for(let e of ancestorCandidates(_(n),t))if(r(y(e,`package.json`)))return e}function detectedHarnesses(e){return detectHarness({env:e}).candidates}const Go={"macos-managed-preferences":`a macOS managed-preferences domain delivered by MDM`,"windows-registry":`a Windows registry key delivered by MDM or Group Policy`,server:`server-side settings`};function skippedLayer(e,t,n,r=[]){return{tier:e,dir:t,plugins:r,status:n,skipped:n}}function managedFolders(e,t,n){let r=t===`win32`?T:x,i=managedPolicyLocations(e,{platform:t,env:n}),a=[...new Set(i.flatMap(({kind:e,location:t})=>e===`file`?[r.dirname(t)]:e===`directory`?[t]:[]))];return{read:a.filter(e=>!a.some(t=>e.startsWith(t+r.sep))).map(e=>r.join(e,`references`)),unread:i.flatMap(({kind:t,location:n})=>{let r=Go[t];return r?[{location:n,reason:`not read — ${e} keeps this policy in ${r}, which cannot be read locally`}]:[]})}}function harnessManagedLayers(e,t,n){return e.length?e.flatMap(e=>{let{read:r,unread:i}=managedFolders(e,t,n);return[...r.map(e=>({tier:`managed`,dir:e,plugins:[],status:``})),...i.map(({location:e,reason:t})=>skippedLayer(`managed`,e,t))]}):[skippedLayer(`managed`,`(no harness detected)`,`not read — no harness detected, so no harness managed folder`)]}function activeInstall(e,t){for(let n of t){let t=e.find(({projectPath:e})=>e===n);if(t)return t}return e.find(({projectPath:e})=>e===void 0)}async function enabledPluginLayers(e,t,n){let r=[];for(let i of e){let[e,a]=await Promise.all([enabledPlugins(i,n),installedPlugins(i,n)]);if(!e.supported){r.push(skippedLayer(`plugin`,`(${i} enabled plugins)`,`not read — ${i} keeps no readable record of enabled plugins`));continue}e.unread.length&&r.push(skippedLayer(`plugin`,`(${i} plugin policy)`,`not read — ${e.unread.join(`; `)} may also enable or disable ${i} plugins`));for(let{id:n,enabled:o}of e.plugins){if(!o)continue;let e=n.split(`@`)[0],s=activeInstall(a.plugins.filter(e=>e.id===n),t);if(s){r.push({tier:`plugin`,dir:y(s.path,`references`),plugins:[e],status:``});continue}r.push(skippedLayer(`plugin`,`(${n})`,`not read — enabled in ${i}, but no install folder for this project is recorded`,[e]))}}return r}const Ko=`legacy — move these documents to references/ beside it`;function managedGovernancesDir$1(e,t){return e===`darwin`?`/Library/Application Support/BuddyAgentHarness/governances`:e===`win32`?y(t||`C:\\ProgramData`,`BuddyAgentHarness`,`governances`):`/etc/buddy-agent-harness/governances`}__name(managedGovernancesDir$1,`managedGovernancesDir`);function deprecatedManagedGovernancesDir$1(e,t){return e===`darwin`?`/Library/Application Support/UniPlugin/governances`:e===`win32`?y(t||`C:\\ProgramData`,`UniPlugin`,`governances`):`/etc/universal-plugin/governances`}__name(deprecatedManagedGovernancesDir$1,`deprecatedManagedGovernancesDir`);function managedReferencesDir(e,t){return y(_(managedGovernancesDir$1(e,t)),`references`)}function projectReferencesDir(e){return y(e,`.agents`,`references`)}function projectReferenceLayers(e){return[{tier:`project`,dir:projectReferencesDir(e),plugins:[],status:``},{tier:`project`,dir:y(e,`.agents`,`governances`),plugins:[],status:Ko}]}function readJson$2(e){try{return JSON.parse(o(e,`utf8`))}catch{return}}__name(readJson$2,`readJson`);function isRepositoryRoot(e){if(r(y(e,`.git`))||r(y(e,`pnpm-workspace.yaml`)))return!0;let t=readJson$2(y(e,`package.json`));return isRecord(t)&&t.workspaces!==void 0}function projectChain(e){let t=C(e),n=[],r=t;for(;;){if(n.push(r),isRepositoryRoot(r))return n;let e=_(r);if(e===r)return[t];r=e}}function isDirectory$2(e){try{return p(e).isDirectory()}catch{return!1}}__name(isDirectory$2,`isDirectory`);function nearestManifest(e){let t=e;for(;;){let e=y(t,`package.json`);if(r(e))return e;let n=_(t);if(n===t)return;t=n}}function canonical(e){try{return l(e)}catch{return e}}function dependencyLayers(e,t){let n=nearestManifest(e);if(!n)return[];let r=[];for(let e of declaredDependencies(readJson$2(n))){let i=packageDir(e,n);if(!i||t.has(canonical(i)))continue;let a=y(i,`references`);if(!isDirectory$2(a))continue;let o=readJson$2(y(i,`plugin.json`)),s=isRecord(o)&&typeof o.name==`string`?o.name:void 0,c=s&&s!==e?[e,s]:[e];r.push({tier:`plugin`,dir:a,plugins:c,status:``})}return r}function ownLayers({name:e,root:t}){return[{tier:`plugin`,dir:y(t,`references`),plugins:[e],status:``},{tier:`plugin`,dir:y(t,`governances`),plugins:[e],status:Ko}]}async function referenceLayers$1({root:e,home:t,platform:n,programData:r,plugin:i,env:a=process.env}){let layer=(e,t,n=``)=>({tier:e,dir:t,plugins:[],status:n}),o=detectedHarnesses(a),s=projectChain(e),c=i&&canonical(i.root),l=await enabledPluginLayers(o,s,{env:a,homedir:t,cwd:C(e),platform:n}),u=[layer(`managed`,managedReferencesDir(n,r)),...harnessManagedLayers(o,n,a),layer(`managed`,managedGovernancesDir$1(n,r),Ko),layer(`managed`,deprecatedManagedGovernancesDir$1(n,r),`deprecated — move these documents to the managed references/ layer`),...s.flatMap(projectReferenceLayers),layer(`user`,y(t,`.agents`,`references`)),layer(`user`,y(t,`.agents`,`governances`),Ko),...i?ownLayers(i):[],...l.filter(({dir:e,skipped:t})=>t||isDirectory$2(e)&&canonical(_(e))!==c),...dependencyLayers(e,new Set(c?[c]:[]))],d=new Set;return u.filter(({dir:e})=>!d.has(e)&&d.add(e))}__name(referenceLayers$1,`referenceLayers`);const qo=[`first-wins`,`combine`,`merge-sections`],Jo=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function parseDocument(e,t){let n=Jo.exec(e);if(!n)return{metadata:{},body:e};let r=e.slice(n[0].length);try{let e=(0,Do.parse)(n[1]);if(e==null)return{metadata:{},body:r};if(isRecord(e))return{metadata:e,body:r}}catch{}return t(`frontmatter is not a YAML mapping; it is ignored`),{metadata:{},body:r}}function readMergeMode(e,t){let n=e.merge;return n===void 0?`first-wins`:qo.includes(n)?n:(t(`unknown merge mode "${String(n)}"; read as first-wins`),`first-wins`)}const Yo=/^\s*<!--\s*merge:\s*([\w-]*)\s*-->\s*$/,Xo=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,Zo=/^ {0,3}(`{3,}|~{3,})/;function fenceTracker(){let e;return t=>{if(e)return RegExp(`^ {0,3}${e[0]==="`"?"`":`~`}{${e.length},}\\s*$`).test(t)&&(e=void 0),!0;let n=Zo.exec(t);return n?(e=n[1],!0):!1}}function stripMergeComments(e){let t=fenceTracker();return e.split(`
|
|
207
|
-
`)
|
|
208
|
-
`)}function
|
|
209
|
-
`).
|
|
210
|
-
`))
|
|
211
|
-
`));let visit
|
|
212
|
-
`)}`:e.heading);for(let t of e.children)visit(t)};for(let t of e.children)visit(t);return`${t.join(`
|
|
213
|
-
|
|
214
|
-
`)}\n`}const Qo=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i,$o=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i;function parseReferenceName(e){if(e.endsWith(`.md`))throw Error(`"${e}" names a file. Ask for the reference by name, without the .md extension.`);let t=e.lastIndexOf(`/`),n=t===-1?e:e.slice(t+1),r=t===-1?void 0:e.slice(0,t);if(!Qo.test(n)||r!==void 0&&!$o.test(r))throw Error(`"${e}" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/" — not a path.`);return{name:n,plugin:r,raw:e}}const es=[`README.md`,`index.md`,`SKILL.md`];function candidateFiles(e){return[`${e}.md`,...es.map(t=>`${e}/${t}`)]}function tryRead(e){try{return o(e,`utf8`)}catch{return}}function pluginLabel(e){return e.plugins[0]??``}function layerName(e){return e.tier===`plugin`?`plugin ${pluginLabel(e)}`:e.tier}function layersFor$1(e,t){let n=e.plugin;if(n===void 0)return[...t];let r=t.filter(e=>e.tier!==`plugin`||e.plugins.includes(n));return r.some(e=>e.tier===`plugin`)?r:[...r,{tier:`plugin`,dir:`(no dependency named ${n})`,plugins:[n],status:``}]}__name(layersFor$1,`layersFor`);function resolveReference(e,t,{display:n=e=>e,without:r}={}){let i=[],a=[],o=[];for(let s of layersFor$1(e,t)){let t={tier:s.tier,plugin:pluginLabel(s),path:s.dir,found:!1,candidate:``,merge:``,outcome:`missing`,description:``};if(a.push(t),s.skipped){t.outcome=s.skipped;continue}let[c,...l]=candidateFiles(e.name).flatMap(e=>{let t=y(s.dir,e),n=t===r?void 0:tryRead(t);return n===void 0?[]:[{candidate:e,raw:n}]});if(!c)continue;for(let e of l)i.push(`${n(y(s.dir,e.candidate))} is ignored: ${c.candidate} answers first in that folder`);let u=y(s.dir,c.candidate),warn=e=>i.push(`${n(u)}: ${e}`),{metadata:d,body:p}=parseDocument(c.raw,warn),m=readMergeMode(d,warn),h=typeof d.description==`string`?d.description:``;Object.assign(t,{path:u,found:!0,candidate:c.candidate,merge:m,outcome:``,description:h}),o.push({layer:s,entry:t,metadata:d,body:p,merge:m})}let s={name:e.raw,status:`missing`,layers:[],warnings:i,plugins:[],trace:a},c=o.findIndex(({merge:e})=>e===`first-wins`),l=c===-1?o:o.slice(0,c+1),u=c===-1?[]:o.slice(c+1),d=l.at(-1),p=[...new Set(o.filter(({layer:e})=>e.tier===`plugin`).map(({entry:e})=>e.plugin))];if(e.plugin===void 0&&p.length>1&&l.some(({layer:e})=>e.tier===`plugin`)){for(let{entry:e}of o)e.outcome=`ambiguous`;return s.status=`ambiguous`,s.plugins=p.map(t=>`${t}/${e.name}`),s}for(let e of u)e.entry.outcome=`shadowed by ${d.layer.tier} (first-wins)`;if(!d)return s;for(let{entry:e}of l)e.outcome=`used`;let m=l[0];return{...s,status:`found`,tier:m.layer.tier,plugin:m.entry.plugin,path:m.entry.path,merge:m.merge,metadata:Object.assign({},...[...l].reverse().map(({metadata:e})=>e)),content:withNewline(stripMergeComments(fold(l,n,e=>i.push(e)))),layers:l.map(({layer:e,entry:t,merge:n})=>({tier:e.tier,plugin:t.plugin,path:t.path,merge:n}))}}function fold(e,t,n){let label=({layer:e,entry:n})=>`${layerName(e)} ${t(n.path)}`,[r,...i]=[...e].reverse(),a=[{labels:[label(r)],body:r.body}];for(let e of i){if(e.merge===`combine`){a=[{labels:[label(e)],body:e.body},...a];continue}let t=mergeSections(parseSections(a.map(({body:e})=>e.trim()).join(`
|
|
147
|
+
`,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=getFirstKeyStartProps(getPrevProps(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=getFirstKeyStartProps(getPrevProps(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())}}};e.Parser=Parser})),ln=__commonJSMin((e=>{var t=en(),n=Rt(),r=zt(),i=ht(),a=j(),o=sn(),s=cn();function parseOptions(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function parseAllDocuments(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=Array.from(c.compose(o.parse(e)));if(a&&i)for(let t of l)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return l.length>0?l:Object.assign([],{empty:!0},c.streamInfo())}function parseDocument(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=null;for(let t of c.compose(o.parse(e),!0,e.length))if(!l)l=t;else if(l.options.logLevel!==`silent`){l.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(l.errors.forEach(r.prettifyError(e,i)),l.warnings.forEach(r.prettifyError(e,i))),l}function parse(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=parseDocument(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 stringify(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=parse,e.parseAllDocuments=parseAllDocuments,e.parseDocument=parseDocument,e.stringify=stringify})),un=__commonJSMin((e=>{var t=en(),n=Rt(),r=It(),i=zt(),a=st(),o=j(),s=P(),c=N(),l=F(),u=L();an();var d=on(),f=sn(),p=cn(),m=ln(),h=tt();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})),dn=un();const fn=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function skillName(e){let t;try{t=a(b(e,`SKILL.md`),`utf8`)}catch{return}let n=fn.exec(t);if(n)try{let e=(0,dn.parse)(n[1]);if(isRecord$1(e)&&typeof e.name==`string`&&e.name.trim())return e.name.trim()}catch{}return v(e)}function isDirectory$1$1(e){try{return d(e).isDirectory()}catch{return!1}}__name(isDirectory$1$1,`isDirectory$1`);function skillsIn(e){let t=[],n=new Set,add=(e,r)=>{let i=e;try{i=c(e)}catch{}n.has(i)||(n.add(i),t.push({name:r,folder:i}))};for(let t of e){let e=skillName(t);if(e!==void 0){add(t,e);continue}let n;try{n=o(t)}catch{continue}for(let e of n.sort()){let n=b(t,e);if(!isDirectory$1$1(n))continue;let r=skillName(n);r!==void 0&&add(n,r)}}return t}function detectedHarnesses(e){return detectHarness({env:e}).candidates}const pn={"macos-managed-preferences":`a macOS managed-preferences domain delivered by MDM`,"windows-registry":`a Windows registry key delivered by MDM or Group Policy`,server:`server-side settings`};function skippedLayer(e,t,n,r){return r===void 0?{tier:e,dir:t,skipped:n}:{tier:e,dir:t,plugin:r,skipped:n}}function managedFolders(e,t,n){let r=t===`win32`?T:x,i=managedPolicyLocations(e,{platform:t,env:n}),a=[...new Set(i.flatMap(({kind:e,location:t})=>e===`file`?[r.dirname(t)]:e===`directory`?[t]:[]))];return{read:a.filter(e=>!a.some(t=>e.startsWith(t+r.sep))).map(e=>r.join(e,`references`)),unread:i.flatMap(({kind:t,location:n})=>{let r=pn[t];return r?[{location:n,reason:`${e} keeps this policy in ${r}, which cannot be read locally`}]:[]})}}function harnessManagedLayers(e,t,n){return e.length?e.flatMap(e=>{let{read:r,unread:i}=managedFolders(e,t,n);return[...r.map(e=>({tier:`managed`,dir:e})),...i.map(({location:e,reason:t})=>skippedLayer(`managed`,e,t))]}):[skippedLayer(`managed`,`(no harness detected)`,`no harness detected, so no managed folder`)]}function activeInstall(e,t){for(let n of t){let t=e.find(({projectPath:e})=>e===n);if(t)return t}return e.find(({projectPath:e})=>e===void 0)}async function enabledPluginLayers(e,t,n){let r=[];for(let i of e){let[e,a]=await Promise.all([enabledPlugins(i,n),installedPlugins(i,n)]);if(!e.supported){r.push(skippedLayer(`plugin`,`(${i} enabled plugins)`,`${i} keeps no readable record of enabled plugins`));continue}e.unread.length&&r.push(skippedLayer(`plugin`,`(${i} plugin policy)`,`${e.unread.join(`; `)} may also enable or disable ${i} plugins`));for(let{id:n,enabled:o}of e.plugins){if(!o)continue;let e=n.split(`@`)[0],s=activeInstall(a.plugins.filter(e=>e.id===n),t);if(s){let t=pluginManifestName(s.path)??e;r.push({tier:`plugin`,dir:b(s.path,`references`),plugin:t});continue}r.push(skippedLayer(`plugin`,`(${n})`,`enabled in ${i}, but no install folder for this project is recorded`,e))}}return r}function projectReferencesDir(e){return b(e,`.agents`,`references`)}function userReferencesDir(e){return b(e,`.agents`,`references`)}function readJson$2(e){try{return JSON.parse(a(e,`utf8`))}catch{return}}__name(readJson$2,`readJson`);function isRepositoryRoot(e){if(n(b(e,`.git`))||n(b(e,`pnpm-workspace.yaml`)))return!0;let t=readJson$2(b(e,`package.json`));return isRecord$1(t)&&t.workspaces!==void 0}function projectChain(e){let t=C(e),n=[],r=t;for(;;){if(n.push(r),isRepositoryRoot(r))return n;let e=y(r);if(e===r)return[t];r=e}}function repositoryRoot(e){let t=projectChain(e).at(-1);return isRepositoryRoot(t)?t:void 0}function isDirectory$2(e){try{return d(e).isDirectory()}catch{return!1}}__name(isDirectory$2,`isDirectory`);function nearestManifest(e){let t=e;for(;;){let e=b(t,`package.json`);if(n(e))return e;let r=y(t);if(r===t)return;t=r}}function canonical(e){try{return c(e)}catch{return e}}function dependencyLayers(e,t){let n=nearestManifest(e);if(!n)return[];let r=[];for(let e of declaredDependencies(readJson$2(n))){let i=packageDir(e,n);if(!i||t.has(canonical(i)))continue;let a=b(i,`references`);if(!isDirectory$2(a))continue;let o=pluginManifestName(i);r.push(o?{tier:`plugin`,dir:a,plugin:o}:{tier:`plugin`,dir:a,skipped:`not a plugin`})}return r}function dependencyPluginRoots(e){let t=nearestManifest(e);return t?declaredDependencies(readJson$2(t)).flatMap(e=>{let n=packageDir(e,t);return n&&pluginManifestName(n)?[n]:[]}):[]}function holdsDefault(e){try{return o(b(e,`references`)).some(e=>e.endsWith(`.default.md`))}catch{return!1}}function skillDefaults(e,t,n){if(!e.length)return{skills:[],unverified:`no harness detected, so no skill folder is read and no skill's default is listed`};let r=[],i=[];for(let a of e){let e=harnessSkillFolders(a,t);if(!e){i.push(a);continue}r.push(...e,...n.flatMap(e=>pluginSkillFolders(a,e)))}let a=n.filter(e=>skillName(e)!==void 0),o=r.length?skillsIn([...r,...a]).filter(({folder:e})=>holdsDefault(e)):[];return i.length?{skills:o,unverified:`the skill folders ${i.join(`, `)} ${i.length===1?`reads are`:`read are`} not verified, so ${i.length===1?`its`:`their`} skills' defaults are not listed`}:{skills:o}}function defaultLayer(e){let t=b(e,`references`);return isDirectory$2(e)?{tier:`default`,dir:t,skill:skillName(e)??v(e)}:{tier:`default`,dir:t,skill:v(e),skipped:`no skill folder`,warning:{code:`default-folder-missing`,message:`the skill folder ${e} does not exist; the name resolves without its default`}}}async function referenceLayers$1({root:e,home:t,platform:n,plugin:r,defaultSkill:i,env:a=process.env}){let o=detectedHarnesses(a),s=projectChain(e),c=r&&canonical(r.root),l=await enabledPluginLayers(o,s,{env:a,homedir:t,cwd:C(e),platform:n}),u=[...r?[r.root]:[],...l.flatMap(({dir:e,skipped:t})=>t?[]:[y(e)]),...dependencyPluginRoots(e)],d=skillDefaults(o,{chain:s,home:t,platform:n,env:a},u),f=[...harnessManagedLayers(o,n,a),...s.map(e=>({tier:`project`,dir:projectReferencesDir(e)})),{tier:`user`,dir:userReferencesDir(t)},...r?[{tier:`plugin`,dir:b(r.root,`references`),plugin:r.name}]:[],...l.filter(({dir:e,skipped:t})=>t||isDirectory$2(e)&&canonical(y(e))!==c),...dependencyLayers(e,new Set(c?[c]:[])),...i===void 0?[]:[defaultLayer(C(i))]],p=new Set;return{layers:f.filter(({dir:e})=>!p.has(e)&&p.add(e)),harnesses:o,skills:d}}__name(referenceLayers$1,`referenceLayers`);const mn=[`replace`,`patch`,`combine`,`remove`];function isMergeOperation(e){return mn.includes(e)}const hn=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function parseDocument(e,t){let n=hn.exec(e);if(!n)return{metadata:{},body:e};let r=e.slice(n[0].length);try{let e=(0,dn.parse)(n[1]);if(e==null)return{metadata:{},body:r};if(isRecord$1(e))return{metadata:e,body:r}}catch{}return t(`frontmatter-invalid`,`frontmatter is not a YAML mapping; it is ignored`),{metadata:{},body:r}}function readMergeOperation(e,t){let n=e.merge;if(n!==void 0)return isMergeOperation(n)?n:(t(`merge-unknown`,`unknown merge "${String(n)}"; read as patch`),`patch`)}function hasBody(e){return stripMergeMarkers(e).trim().length>0}const gn=/^\s*<!--\s*merge:\s*([\w-]*)\s*-->\s*$/,_n=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,vn=/^ {0,3}(`{3,}|~{3,})/;function fenceTracker(){let e;return t=>{if(e)return RegExp(`^ {0,3}${e[0]==="`"?"`":`~`}{${e.length},}\\s*$`).test(t)&&(e=void 0),!0;let n=vn.exec(t);return n?(e=n[1],!0):!1}}function stripMergeMarkers(e){let t=fenceTracker();return e.split(`
|
|
148
|
+
`).filter(e=>t(e)||!gn.test(e)).join(`
|
|
149
|
+
`)}function sectionKey$1(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function topLevel(e){let t=fenceTracker(),n;for(let r of e.split(`
|
|
150
|
+
`)){if(t(r))continue;let e=_n.exec(r);e&&(n=Math.min(n??6,e[1].length))}return n}function parseSections(e,t){let n=topLevel(e),r={top:n,preamble:[],children:[]},i=[],a=fenceTracker(),o;for(let s of e.split(`
|
|
151
|
+
`)){let e=a(s),c=e?null:_n.exec(s);if(c){let e=c[1].length,t={depth:e-(n??e),level:e,title:(c[2]??``).trim(),heading:s.trimEnd(),marker:void 0,text:[],children:[]};for(;(i.at(-1)?.level??0)>=e;)i.pop();(i.at(-1)?.children??r.children).push(t),i.push(t),o=t;continue}if(o&&!e){if(!s.trim())continue;let e=gn.exec(s);if(e){let n=e[1];isMergeOperation(n)?o.marker=n:(t(`marker-unknown`,`unknown merge "${n}" on "${o.title}"; read as patch`),o.marker=`patch`),o=void 0;continue}}o=void 0,(i.at(-1)?.text??r.preamble).push(s)}return r}function trimBlank(e){let t=0,n=e.length;for(;t<n&&!e[t].trim();)t++;for(;n>t&&!e[n-1].trim();)n--;return e.slice(t,n)}function emptyComposed(){return{top:void 0,preamble:[],preambleSources:[],children:[],removed:[],joined:!1}}function pathOf(e,t){return e?`${e} > ${t}`:t}function warnRepeats(e,t,{warn:n}){let r=new Set;for(let i of e){let e=sectionKey$1(i.title);r.has(e)&&n(`heading-repeated`,`heading path "${pathOf(t,i.title)}" appears more than once; the first is matched`),r.add(e),warnRepeats(i.children,pathOf(t,i.title),{warn:n})}}function warnUnmatched(e,t,{warn:n}){n(`marker-unmatched`,`"<!-- merge: ${e.marker} -->" on "${pathOf(t,e.title)}" matches no section below`)}function place(e,t,n,r){let i=pathOf(n,e.title),a=e.children.flatMap(e=>(e.marker&&warnUnmatched(e,i,r),e.marker===`remove`?[]:[place(e,e.marker??t,i,r)])),o=trimBlank(e.text);return{depth:e.depth,title:e.title,heading:e.heading,level:e.level,text:o,sources:o.length?[{contribution:r.label,operation:t}]:[],children:a}}function join$1(e,t){return e.length&&t.length?[...e,``,...t]:[...e,...t]}function applyChildren(e,t,n,r,i){let a=[...e],o=[],s=new Set;for(let c of t){let t=c.marker??n,l=sectionKey$1(c.title),u=s.has(l)?-1:e.findIndex(e=>sectionKey$1(e.title)===l);if(s.add(l),u===-1){c.marker&&warnUnmatched(c,r,i),t!==`remove`&&o.push(place(c,t,r,i));continue}let d=e[u],f=pathOf(r,d.title);if(t===`remove`){a[u]=void 0,i.composed.removed.push({path:f,by:i.label});continue}if(t===`replace`){a[u]={...place(c,`replace`,r,i),depth:d.depth};continue}let p=trimBlank(c.text),m=p.length?[{contribution:i.label,operation:t}]:[];if(t===`combine`){p.length&&d.text.length&&(i.composed.joined=!0),a[u]={...d,text:join$1(d.text,p),sources:[...d.sources,...m],children:applyChildren(d.children,c.children,`combine`,f,i)};continue}a[u]={...d,text:p.length?p:d.text,sources:p.length?m:d.sources,children:applyChildren(d.children,c.children,`replace`,f,i)}}return[...a.filter(e=>e!==void 0),...o]}function applyContribution(e,t,n,r,i){let a=parseSections(t,i),o=n===`replace`?emptyComposed():e,s={...o,removed:[...o.removed]},c={label:r,warn:i,composed:s};warnRepeats(a.children,``,c);let l=trimBlank(a.preamble);return n===`combine`?(l.length&&o.preamble.length&&(s.joined=!0),s.preamble=join$1(o.preamble,l),l.length&&(s.preambleSources=[...o.preambleSources,{contribution:r,operation:n}])):l.length&&(s.preamble=l,s.preambleSources=[{contribution:r,operation:n}]),s.top=o.top??a.top,s.children=applyChildren(o.children,a.children,n,``,c),s}function renderComposed(e){let t=[];e.joined&&t.push(`> Where combined text conflicts, the later text wins.`),e.preamble.length&&t.push(e.preamble.join(`
|
|
152
|
+
`));let n=e.top??1,visit=e=>{let r=Math.min(6,n+e.depth),i=r===e.level?e.heading:`${`#`.repeat(r)} ${e.title}`.trimEnd();t.push(e.text.length?`${i}\n\n${e.text.join(`
|
|
153
|
+
`)}`:i);for(let t of e.children)visit(t)};for(let t of e.children)visit(t);return t.length?`${t.join(`
|
|
215
154
|
|
|
216
|
-
`),n),parseSections(e.body,n),label(e),n);a=[{labels:[label(e),...a.flatMap(({labels:e})=>e)],body:renderSections(t)}]}return a.length===1?a[0].body:[`> Combined from ${a.length} layers, highest precedence first. Where they conflict, the first layer wins.`,...a.map(({labels:e,body:t})=>`<!-- layer: ${e.join(`, `)} -->\n\n${t.trim()}`)].join(`
|
|
217
|
-
|
|
218
|
-
`)}function
|
|
219
|
-
`)?e:`${e}\n`}function layerNames(e){let t;try{t=s(e,{withFileTypes:!0})}catch{return[]}let n=new Set;for(let r of t){let t=r.isFile()&&r.name.endsWith(`.md`)?r.name.slice(0,-3):r.name;Qo.test(t)&&(r.isFile()?r.name.endsWith(`.md`):es.some(n=>tryRead(y(e,t,n))!==void 0))&&n.add(t)}return[...n]}function referenceNames(e){return[...new Set(e.flatMap(({dir:e,skipped:t})=>t?[]:layerNames(e)))].sort((e,t)=>e.localeCompare(t))}function listReferences(e,t={}){let n=[],r=new Set;for(let i of referenceNames(e)){let a=resolveReference(parseReferenceName(i),e,t);for(let e of a.warnings)r.add(e);for(let e of a.trace)e.found&&n.push({name:i,tier:e.tier,plugin:e.plugin,path:e.path,status:e.outcome===`ambiguous`?`ambiguous — ask for one of ${a.plugins.join(`, `)}`:e.outcome,description:e.description})}return{rows:n,warnings:[...r]}}const ts=[`name`,`prefix`,`close name`,`description`,`heading`,`body`];function distance(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=n[a-1]+(e[r-1]===t[a-1]?0:1);i.push(Math.min(n[a]+1,i[a-1]+1,o))}n=i}return n[t.length]}function headings(e){let t=!1,n=[];for(let r of e.split(`
|
|
155
|
+
`)}\n`:``}function composedSections(e){let t=[];e.preambleSources.length&&t.push({path:`(before the first heading)`,sources:e.preambleSources});let visit=(e,n)=>{let r=pathOf(n,e.title);t.push({path:r,sources:e.sources});for(let t of e.children)visit(t,r)};for(let t of e.children)visit(t,``);return t}function headingPaths(e){let t=[],visit=(e,n)=>{let r=pathOf(n,e.title);t.push(r);for(let t of e.children)visit(t,r)};for(let t of parseSections(e,()=>{}).children)visit(t,``);return t}const yn=`.interface`,bn=/^([a-z0-9]+(?:[-.][a-z0-9]+)*)@(\d+)$/i;function interfaceIdOf(e){return e.endsWith(`.interface`)&&e.length>10?e.slice(0,-10):void 0}function isVersion(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function readSection(e){if(typeof e==`string`&&e.trim())return e.trim();if(isRecord$1(e)){let t=Object.keys(e),[n]=t;if(t.length===1&&n?.trim())return n.trim()}return{problem:`section ${JSON.stringify(e)} is not a heading name`}}function sectionKey(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function readInterface(e,t){let n=t.interface;if(!isRecord$1(n))return{problems:[n===void 0?"has no `interface:` block in its frontmatter":"`interface:` is not a mapping"]};let r=[],i=n.cardinality;i!==`one`&&i!==`many`&&r.push(`cardinality is ${JSON.stringify(i)}; it is one or many`);let a=n.version;isVersion(a)||r.push(`version is ${JSON.stringify(a)}; it is a positive integer`);let o=n.versions,s=isVersion(a)?[a]:[];o!==void 0&&(Array.isArray(o)&&o.length&&o.every(isVersion)?s=o:r.push(`versions is not a list of positive integers`));let c=n.sections,l=[];if(!Array.isArray(c)||!c.length)r.push(`sections is not a list of headings`);else{let e=new Set;for(let t of c){let n=readSection(t);if(typeof n!=`string`){r.push(n.problem);continue}let i=sectionKey(n);e.has(i)&&r.push(`section "${n}" is listed more than once`),e.add(i),l.push(n)}}return r.length?{problems:r}:{value:{id:e,cardinality:i,version:a,versions:s,sections:l},problems:r}}function readImplements(e){let t=e.implements;if(t===void 0)return{problems:[]};let n=Array.isArray(t)?t:[t];if(n.length!==1)return{problems:[n.length?`implements lists ${n.length} interfaces; an implementation implements one`:`implements is an empty list`]};let[r]=n,i=typeof r==`string`?bn.exec(r.trim()):null;return i?{entry:{id:i[1],version:Number(i[2])},problems:[]}:{problems:[`implements ${JSON.stringify(r)} is not <id>@<version>`]}}function fitsName(e,t){return e.cardinality===`one`?t===e.id:t.startsWith(`${e.id}.`)&&t.length>e.id.length+1&&!t.endsWith(`.interface`)}function documentSections(e){let t=[],visit=e=>{if(e.depth===0){let n=e.text.find(e=>e.trim());t.push({title:e.title,unsupported:n?.trim().startsWith(`**Unsupported.**`)??!1})}for(let t of e.children)visit(t)};for(let t of parseSections(e,()=>{}).children)visit(t);return t}function checkImplementation(e,{name:t,version:n,content:r,accept:i=e.versions}){let a=[],fail=(t,n)=>a.push({check:t,interface:e.id,message:n});i.includes(n)||fail(`version`,`unknown version ${n}`),fitsName(e,t)||fail(`name`,`name ${t} is not ${e.cardinality===`one`?e.id:`${e.id}.<key>`}`);let o=documentSections(r),s=e.sections.map(sectionKey),c=e.sections.filter(e=>{let t=o.find(t=>sectionKey(t.title)===sectionKey(e));return!t||t.unsupported}),l=-1,u=``,d=new Set;for(let e of o){let t=sectionKey(e.title),n=s.indexOf(t);n!==-1&&(d.has(t)?fail(`order`,`section ${e.title} appears more than once`):n<l&&fail(`order`,`section ${e.title} comes after ${u}`),d.add(t),n>l&&(l=n,u=e.title))}return{failures:a,unsupported:c}}const xn=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i,Sn=`.default`;function parseReferenceName(e){let invalid=t=>({raw:e,name:e,invalid:t});if(e.endsWith(`.md`))return invalid(`"${e}" names a file. Ask for the reference by name, without the .md extension.`);let t=e.split(`/`);if(t.length>2||e.includes(`\\`))return invalid(`"${e}" is a path. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/".`);let[n,r]=t,i=r??n,a=r===void 0?void 0:n;return i.endsWith(`.default`)?invalid(`"${e}" names a skill's default file. Ask for "${i.slice(0,-8)}"; the default joins when its skill loads it.`):!xn.test(i)||a!==void 0&&!xn.test(a)?invalid(`"${e}" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/", where <plugin> is a plugin's manifest name.`):a===void 0?{raw:e,name:i}:{raw:e,name:i,plugin:a}}function layersOf(e){return Array.isArray(e)?{layers:[...e],harnesses:[]}:e}function tryRead$1(e){try{return a(e,`utf8`)}catch{return}}__name(tryRead$1,`tryRead`);function candidateFiles(e,t){return e.tier==="default"?[`${t}${Sn}.md`]:[`${t}.md`,`${t}/README.md`]}function contributionLabel(e,t,n){return e.tier===`plugin`?`plugin ${e.plugin}`:e.tier==="default"?`default of ${e.skill}`:`${e.tier} ${n(t)}`}function readExtends(e,t){if(e===void 0)return;let malformed=e=>{t(`extends-invalid`,`\`extends\` ${e}; it is read as not written`)},n=typeof e==`string`?[e]:Array.isArray(e)?e:void 0;if(!n)return malformed(`is not a list of plugins`);let r=[];for(let e of n){let n=readStep(e,t);if(typeof n==`string`)return malformed(n);r.push(n)}return r}function readStep(e,t){if(typeof e==`string`)return xn.test(e)?{target:e}:`names "${e}", which is not a plugin name or default`;if(!isRecord$1(e)||Object.keys(e).length!==1)return`holds ${JSON.stringify(e)}, which is not a step`;let[n,r]=Object.entries(e)[0];if(!xn.test(n))return`names "${n}", which is not a plugin name or default`;if(r==null)return{target:n};let i={target:n};if(typeof r==`string`)return i.merge=readStepMerge(r,n,t),i;if(!isRecord$1(r)||Object.keys(r).some(e=>e!==`merge`&&e!==`extends`))return`gives "${n}" keys other than merge and extends`;if(r.merge!==void 0&&(i.merge=readStepMerge(r.merge,n,t)),r.extends!==void 0){let e=readExtends(r.extends,t);if(!e)return`gives "${n}" a malformed extends`;i.extends=e}return i}function readStepMerge(e,t,n){return isMergeOperation(e)?e:(n(`merge-unknown`,`unknown merge "${String(e)}" on the step ${t}; read as patch`),`patch`)}function expand(e,t,n,r,i){let a={entries:[],missing:[],allMissing:!1,replaced:[]},o=new Set,s=new Set,normalize=(e,t,n)=>{let r=[];for(let o of e){if(o.target===n){i(`extends-self`,`${t} lists itself in its extends; that entry is ignored`);continue}r.at(-1)?.target!==o.target&&(r.some(({target:e})=>e===o.target)&&!a.ambiguous&&(a.ambiguous={cause:`repeat`,message:`${t}'s extends lists ${o.target} at two places`}),r.push(o))}return r},c=normalize(e,t),l=new Set(c.map(({target:e})=>e)),visit=(e,c,u)=>{if(a.ambiguous||o.has(e.target))return;if(s.has(e.target)){n===`plugins`&&(a.ambiguous={cause:`cycle`,message:`the plugins' own extends form a cycle: ${[...u,e.target].join(` → `)}`});return}if(!c&&l.has(e.target))return;let d=r(e.target);if(`reason`in d){a.missing.push({target:e.target,reason:d.reason}),e.target!=="default"&&i(`extends-step-missing`,`the step ${e.target} in ${u.at(-1)??t}'s extends ${d.reason}; it is skipped`);return}s.add(e.target);let f=d.steps??[];if(e.extends){let t=new Set(e.extends.map(({target:e})=>e));for(let{target:n}of f)t.has(n)||a.replaced.push({target:n,step:e.target})}for(let t of normalize(e.extends??f,`plugin ${e.target}`,e.target))visit(t,!1,[...u,e.target]);s.delete(e.target);let p=e.merge??d.merge??`patch`,m=e.merge?`step`:d.merge?`contribution`:`default`;a.entries.push({target:e.target,contribution:d,operation:p,from:m}),o.add(e.target)};for(let e of c)visit(e,!0,[]);return a.allMissing=c.length>0&&c.every(({target:e})=>!o.has(e))&&c.some(({target:e})=>e!=="default"),a}const noWarn=()=>{};function plan(e,t,n,r,i,a){let o;for(let n of t){if(!n.steps)continue;if(e.plugin!==void 0){n.entry.extendsOutcome=`not used (qualified name)`;continue}if(o){expand(n.steps,n.label,`written`,r,noWarn).entries.map(({target:e})=>e).join(` `)!==o.targets&&(n.entry.extendsOutcome=`not used (${o.builder.label}'s extends builds the stack)`,a(`extends-not-used`,`${n.label} builds a different stack from ${o.builder.label}, whose extends is used`));continue}let t=expand(n.steps,n.label,`written`,r,a);if(t.ambiguous)return{status:`ambiguous`,...t.ambiguous};if(t.allMissing){n.entry.extendsOutcome=`not used (every step is missing)`,a(`extends-all-missing`,`every step in ${n.label}'s extends is missing; it is read as not written`);continue}o={entries:t.entries,builtBy:n.label,replaced:t.replaced,replacedBy:n.label,builder:n,targets:t.entries.map(({target:e})=>e).join(` `)}}if(o)return o;if(e.plugin!==void 0){let t=r(e.plugin);if(`reason`in t)return{status:`missing`,message:`the plugin ${e.plugin} ${t.reason}`};let n=expand([{target:e.plugin}],`plugin ${e.plugin}`,`plugins`,r,a);return n.ambiguous?{status:`ambiguous`,...n.ambiguous}:{entries:n.entries,builtBy:`qualified name`,replaced:[],replacedBy:``}}return planFromPlugins(n,r,i,e.name,a)}function planFromPlugins(e,t,n,r,i){let defaultEntry=()=>n?[{target:`default`,contribution:n,operation:n.merge??`patch`,from:n.merge?`contribution`:`default`}]:[],a=[...e.keys()];if(!a.length)return{entries:defaultEntry(),builtBy:`none`,replaced:[],replacedBy:``};let o=new Map;for(let e of a){let n=expand([{target:e}],`plugin ${e}`,`plugins`,t,noWarn);if(n.ambiguous)return{status:`ambiguous`,...n.ambiguous};o.set(e,new Set(n.entries.map(({target:e})=>e).filter(t=>t!==e)))}let s=a.filter(e=>!a.some(t=>t!==e&&o.get(t)?.has(e))),unordered=()=>({status:`ambiguous`,cause:`unordered`,message:`the plugins ${a.join(`, `)} hold it, and no extends orders them`});if(s.length!==1)return unordered();let c=s[0],l=expand([{target:c}],`plugin ${c}`,`plugins`,t,i);if(l.ambiguous)return{status:`ambiguous`,...l.ambiguous};let u=new Set(l.entries.map(({target:e})=>e));if(a.some(e=>!u.has(e)))return unordered();let d=l.entries;if(n&&!u.has(`default`)){d.unshift(...defaultEntry());let e=a.join(`, `);i(`default-not-selected`,`${a.length>1?`the plugins`:`the plugin`} ${e} ${a.length>1?`answer`:`answers`} over the default of ${n.layer.skill}, and no extends names either; run "reference select ${r} <option>..." to choose (options: ${[...a,`default`].join(`, `)})`)}return{entries:d,builtBy:c&&(e.get(c)?.steps?.length??0)>0?`plugin ${c}'s extends`:`none`,replaced:[],replacedBy:``}}function namesDefault(e){return(e??[]).some(e=>e.target==="default"||namesDefault(e.extends))}function emptyTrace(e){return{stack:[],builtBy:`none`,contributions:[],sections:[],layers:[],harnesses:[...e]}}function withNewline(e){return e.endsWith(`
|
|
156
|
+
`)?e:`${e}\n`}function trimLeadingBlank(e){return e.replace(/^(?:[ \t]*\r?\n)+/,``)}function resolveReference(e,t,{display:n=e=>e,without:r,below:i}={}){let a=typeof e==`string`?parseReferenceName(e):e,{layers:o,harnesses:s}=layersOf(t),c=emptyTrace(s),l=[],u={name:a.raw,status:`missing`,warnings:l,trace:c};if(a.invalid)return{...u,status:`invalid`,code:`reference-invalid`,message:a.invalid};let d=new Set,warnAt=e=>(t,n)=>{let r=e?`${e}: ${n}`:n;d.has(`${t} ${r}`)||(d.add(`${t} ${r}`),l.push({code:t,message:r}))},f=warnAt(``),p=i===void 0?-1:o.findIndex(e=>e.dir===i),m=p===-1?o:o.slice(p+1),h=[];for(let e of m){e.warning&&f(e.warning.code,e.warning.message);let t={tier:e.tier,path:e.dir,outcome:`missing`};if(e.plugin!==void 0&&(t.plugin=e.plugin),e.skill!==void 0&&(t.skill=e.skill),c.layers.push(t),e.skipped){t.outcome=`not read (${e.skipped})`;continue}let i=readContribution(e,a.name,t,{display:n,without:r,warnAt});i?h.push(i):e.tier==="default"&&(t.outcome=`not read (no default)`)}let g=new Map;for(let e of h.filter(({layer:e})=>e.tier===`plugin`)){let t=e.layer.plugin,r=g.get(t);r?e.entry.outcome=`not read (plugin ${t} answers from ${n(r.path)})`:g.set(t,e)}let _=h.find(({layer:e})=>e.tier==="default"),v=h.filter(({layer:e})=>e.tier!==`plugin`&&e.tier!=="default"),y=new Set(m.flatMap(({plugin:e,skipped:t})=>e&&!t?[e]:[])),lookup=e=>e==="default"?_??{reason:`has no default`}:g.get(e)??{reason:y.has(e)?`holds no ${a.name}`:`is not installed`},options=()=>[...[...g.keys()].map(e=>`${e}/${a.name}`),..._?[`default`]:[]];if(interfaceIdOf(a.name)!==void 0)return resolveInterface(a,h,g,_,u,f,options);let b=plan(a,v,g,lookup,_,f);if(`status`in b){if(b.status===`ambiguous`){for(let{entry:e}of h)e.outcome===``&&(e.outcome=`ambiguous`);return{...u,status:`ambiguous`,code:`reference-ambiguous`,message:b.message,cause:b.cause,options:options()}}for(let{entry:e}of h)e.outcome===``&&(e.outcome=`not used (qualified name)`);return{...u,status:`missing`,code:`reference-missing`,message:b.message}}!m.some(({tier:e})=>e==="default")&&h.some(({steps:e})=>namesDefault(e))&&c.layers.push({tier:`default`,path:`(no skill folder given)`,outcome:`not read (no default)`}),c.stack=b.entries.map(({target:e})=>e),c.builtBy=b.builtBy;let x=new Set(c.stack);for(let[e,t]of[...g.entries(),..._?[[`default`,_]]:[]]){if(x.has(e))continue;let n=b.replaced.find(t=>t.target===e);t.entry.outcome=a.plugin===void 0?n?`not used (${n.step}'s extends replaced by ${b.replacedBy})`:`not used (not in extends)`:`not used (qualified name)`}let S=[...b.entries,...[...v].reverse().map(e=>({contribution:e,operation:e.merge??`patch`,from:e.merge?`contribution`:`default`}))],C=emptyComposed(),w=[],T,E=[];for(let{contribution:e,operation:t,from:n}of S){let{entry:r}=e;r.operation=t,r.operationFrom=n;let i=warnAt(e.label);if(t===`remove`){e.hasBody&&i(`remove-body-ignored`,`a merge: remove contribution has a body; it is ignored`);for(let t of w)t.entry.outcome=`shadowed by ${e.label} (remove)`;for(let t of composedSections(C))t.path!==`(before the first heading)`&&C.removed.push({path:t.path,by:e.label});let t=C.removed;w=[],C={...emptyComposed(),removed:t},T=e,r.outcome=`used`,E.push(e);continue}if(!e.hasBody){r.outcome=r.extendsOutcome??`used`,r.extendsOutcome||E.push(e);continue}if(t===`replace`){for(let t of w)t.entry.outcome=`shadowed by ${e.label} (replace)`;w=[]}C=applyContribution(C,e.body,t,e.label,i),w.push(e),T=void 0,r.outcome=`used`,E.push(e)}if(c.sections=C.removed.map(({path:e,by:t})=>({path:e,contributions:[],removedBy:t})),!w.length){if(T)return{...u,status:`missing`,code:`reference-missing`,message:`"${a.name}" is turned off by ${T.label} (remove)`,removedBy:T.label};let e=a.plugin===void 0?`no tier holds a document for "${a.name}"`:`the plugin ${a.plugin} holds no document for "${a.name}"`;return{...u,status:`missing`,code:`reference-missing`,message:e}}let ee=E.filter(({entry:e})=>e.outcome===`used`);c.contributions=w.map(({layer:e,entry:t})=>{let n={tier:e.tier,path:t.path,operation:t.operation};return t.plugin!==void 0&&(n.plugin=t.plugin),t.skill!==void 0&&(n.skill=t.skill),n}),c.sections=[...composedSections(C).map(({path:e,sources:t})=>({path:e,contributions:t})),...c.sections];let te=w.length===1&&!C.removed.length?w[0].body:void 0,ne=te!==void 0&&stripMergeMarkers(te)===te?withNewline(trimLeadingBlank(te)):renderComposed(C);return{...u,status:`found`,content:ne,metadata:composedMetadata(ee)}}function composedMetadata(e){let t=Object.assign({},...e.map(({metadata:e})=>e));return delete t.merge,delete t.extends,t}function readContribution(e,t,n,{display:r,without:i,warnAt:a}){if(e.tier!=="default"){let n=b(e.dir,`${t}${Sn}.md`);n!==i&&tryRead$1(n)!==void 0&&a(r(n))(`default-in-tier`,`it is ignored: a default goes in a skill's references/ folder`)}let[o,...s]=candidateFiles(e,t).flatMap(t=>{let n=b(e.dir,t),r=n===i?void 0:tryRead$1(n);return r===void 0?[]:[{file:t,path:n,raw:r}]});if(!o)return;for(let e of s)a(r(e.path))(`file-ignored`,`it is ignored: ${o.file} answers first in that folder`);let c=contributionLabel(e,o.path,r),l=a(c),{metadata:u,body:d}=parseDocument(o.raw,l),f=readMergeOperation(u,l),p=readExtends(u.extends,l);Object.assign(n,{path:o.path,file:o.file,frontmatter:u,outcome:``}),typeof u.description==`string`&&(n.description=u.description);let m=hasBody(d);return m||(n.empty=!0),p&&!m&&f!==`remove`&&(n.selection=!0),{layer:e,entry:n,label:c,path:o.path,metadata:u,body:d,hasBody:m,merge:f,steps:p}}function resolveInterface(e,t,n,r,i,a,o){for(let e of t)(e.merge!==void 0||e.steps!==void 0)&&a(`interface-not-composed`,`${e.label}: merge and extends on an interface document are ignored; an interface is never composed`);if(e.plugin===void 0&&n.size>1){for(let{entry:e}of t)e.outcome===``&&(e.outcome=`ambiguous`);return{...i,status:`ambiguous`,code:`reference-ambiguous`,message:`the plugins ${[...n.keys()].join(`, `)} each hold the interface document`,cause:`unordered`,options:o()}}let s=e.plugin===void 0?[...n.values()]:n.has(e.plugin)?[n.get(e.plugin)]:[];if(e.plugin!==void 0){for(let[t,r]of n)t!==e.plugin&&(r.entry.outcome=`not used (qualified name)`);if(!s.length)return{...i,status:`missing`,code:`reference-missing`,message:`the plugin ${e.plugin} holds no "${e.name}"`}}let c=t.filter(({layer:e})=>e.tier!==`plugin`&&e.tier!=="default"),[l,...u]=[...e.plugin===void 0&&r?[r]:[],...s,...[...c].reverse()];if(!l)return{...i,status:`missing`,code:`reference-missing`,message:`no tier holds a document for "${e.name}"`};for(let e of u)e.entry.outcome=`not used (an interface document is never composed)`,a(`interface-not-composed`,`${e.label} is ignored: an interface document is never composed; define a new interface id instead`);r&&r!==l&&(r.entry.outcome=`not used (qualified name)`),l.entry.outcome=`used`,l.entry.operation=`replace`,l.entry.operationFrom=`default`;let{trace:d}=i;return l.layer.tier===`plugin`&&(d.stack=[l.layer.plugin]),l.layer.tier==="default"&&(d.stack=[`default`]),d.contributions=[{tier:l.layer.tier,...l.entry.plugin?{plugin:l.entry.plugin}:{},...l.entry.skill?{skill:l.entry.skill}:{},path:l.path,operation:`replace`}],{...i,status:`found`,content:withNewline(trimLeadingBlank(stripMergeMarkers(l.body))),metadata:composedMetadata([l])}}function layerNames(e){if(e.skipped)return[];let t;try{t=o(e.dir,{withFileTypes:!0})}catch{return[]}let n=new Set,r=e.tier==="default";for(let i of t){let t;r?i.name.endsWith(`.default.md`)&&(t=i.name.slice(0,-`${Sn}.md`.length)):i.name.endsWith(`.md`)&&!i.isDirectory()?t=i.name.slice(0,-3):!i.isFile()&&tryRead$1(b(e.dir,i.name,`README.md`))!==void 0&&(t=i.name),!(t===void 0||parseReferenceName(t).invalid)&&n.add(t)}return[...n]}function referenceNames(e){return[...new Set(layersOf(e).layers.flatMap(layerNames))].sort((e,t)=>e.localeCompare(t))}function skillHoldings(e){return(Array.isArray(e)?[]:e.skills?.skills??[]).flatMap(e=>layerNames(defaultLayer(e.folder)).map(t=>({name:t,skill:e}))).sort((e,t)=>e.name.localeCompare(t.name)||e.skill.name.localeCompare(t.skill.name))}function defaultsUnverified(e){return Array.isArray(e)?void 0:e.skills?.unverified}function withDefault(e,t){let{layers:n,harnesses:r,skills:i}=Array.isArray(e)?{layers:e,harnesses:[],skills:void 0}:e;return{layers:[...n.filter(({tier:e})=>e!=="default"),defaultLayer(t)],harnesses:r,skills:i}}function patternMatcher(e){let t=e.split(`*`).map(e=>e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`));return RegExp(`^${t.join(`.*`)}$`,`s`)}function firstLine$1(e){return typeof e==`string`&&e.split(`
|
|
157
|
+
`)[0]?.trim()||``}function collect(e,t,n){for(let r of n){let n=`${r.code} ${r.message}`;t.has(n)||e.push(r),t.add(n)}}function layerRow(e,t){let n={name:e,tier:t.tier,path:t.path,description:firstLine$1(t.description),outcome:t.outcome};return t.plugin!==void 0&&(n.plugin=t.plugin),t.skill!==void 0&&(n.skill=t.skill),t.selection&&(n.selection=!0),n}function listReferences(e,t={}){let{pattern:n,...r}=t,i=n===void 0?void 0:patternMatcher(n),a={references:[],layers:[],warnings:[]},o=defaultsUnverified(e);o&&(a.defaults=o);let s=new Set,c=skillHoldings(e),l=[...new Set([...referenceNames(e),...c.map(({name:e})=>e)])].sort((e,t)=>e.localeCompare(t));for(let t of l){if(i&&!i.test(t))continue;let n=c.filter(e=>e.name===t),o=resolveReference(t,e,r);!o.trace.layers.some(({file:e,tier:t})=>e&&t!=="default")&&n[0]&&(o=resolveReference(t,withDefault(e,n[0].skill.folder),r)),collect(a.warnings,s,o.warnings);let l={name:t,description:o.status===`found`?firstLine$1(o.metadata?.description):``,status:o.status};if(o.options){let e=n.map(({skill:e})=>`default of ${e.name}`);l.options=[...new Set([...o.options.filter(e=>e!=="default"),...e])]}a.references.push(l);for(let e of o.trace.layers)e.file!==void 0&&e.tier!=="default"&&a.layers.push(layerRow(t,e));for(let{skill:i}of n)a.layers.push(defaultRow(t,i.name,i.folder,e,r))}return a}function defaultRow(e,t,n,r,i){return{...layerRow(e,resolveReference(e,withDefault(r,n),i).trace.layers.find(({tier:e,file:t})=>e==="default"&&t)),reachedBy:`the default step, when ${t} loads ${e}`}}const Cn=[`name`,`prefix`,`close name`,`description`,`heading`,`body`];function distance(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=n[a-1]+(e[r-1]===t[a-1]?0:1);i.push(Math.min(n[a]+1,i[a-1]+1,o))}n=i}return n[t.length]}function headings(e){let t=!1,n=[];for(let r of e.split(`
|
|
220
158
|
`))/^ {0,3}(`{3,}|~{3,})/.test(r)?t=!t:!t&&/^ {0,3}#{1,6}\s/.test(r)&&n.push(r);return n.join(`
|
|
221
|
-
`)}function tagText(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function matchKind(e,t,n){let r=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(r===n||e.toLowerCase()===n)return`name`;if(r.startsWith(n))return`prefix`;if(r.includes(n)||distance(r,n)<=Math.max(1,Math.floor(n.length/4)))return`close name`;let i=n.split(/\s+/),holds=e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e))},a=t.metadata;if(holds(`${typeof a.description==`string`?a.description:``} ${tagText(a.tags)}`))return`description`;let o=t.content
|
|
222
|
-
`)[0]?.trim()||``}
|
|
223
|
-
`)){let t=/^\s*\[marketplaces\.(?:"([^"]+)"|([^\]]+))\]\s*$/.exec(e);if(t){a={name:t[1]??t[2],path:``},r.push(a);continue}if(/^\s*\[/.test(e)){a=void 0;continue}let n=a?/^\s*source\s*=\s*"([^"]*)"\s*$/.exec(e):void 0;n?.[1]&&a&&(a.path=n[1])}return{installed:n,marketplaces:r}}const ss=[os,{name:`codex`,scoped:!1,installedOnMachine:(e,t=process.env)=>r(codexHome(e,t)),state:(e,t=process.env)=>readCodexState(codexHome(e,t)),register:e=>`codex plugin marketplace add ./${e}`,install:e=>`codex plugin add ${e}`,update:e=>`codex plugin add ${e}`,uninstall:e=>`codex plugin remove ${e}`,refreshMarketplace:()=>``}];function ours(e,t,n,r){let i=`@${t}`;return e.filter(e=>e.id.endsWith(i)&&(!r||e.projectPath===n))}function reconcile({catalog:e,catalogDir:t,root:n,installed:r,marketplaces:i,scoped:a=!0}){let o=i.find(t=>t.name===e.name),s=[],c=t.split(/[\\/]/).filter(Boolean),l=o?c.every(e=>o.path.includes(e)):!1,u=o&&!l?o.path:void 0;o||s.push({kind:`register`,subject:e.name,detail:`marketplace is not registered with this harness`});let d=ours(r,e.name,n,a),p=new Map(d.map(e=>[e.id,e]));for(let t of e.plugins){let n=`${t.name}@${e.name}`,r=p.get(n);if(!r){s.push({kind:`install`,subject:n,detail:`not installed; catalog pins ${t.source.version}`});continue}r.version!==t.source.version&&s.push({kind:`update`,subject:n,detail:`installed ${r.version}, catalog pins ${t.source.version}`})}let m=new Set(e.plugins.map(t=>`${t.name}@${e.name}`));for(let e of d)m.has(e.id)||s.push({kind:`uninstall`,subject:e.id,detail:`installed but no longer in the catalog; it will report a load failure until removed`});return{actions:s,...u?{collision:u}:{},unregistered:!o}}function commandFor(e,t,n){switch(t.kind){case`register`:return e.register(is);case`install`:return e.install(t.subject);case`update`:{let r=e.refreshMarketplace(n),i=e.update(t.subject);return r?`${r} && ${i}`:i}case`uninstall`:return e.uninstall(t.subject)}}function notesFor(e){let t=[];e.pnp&&t.push(`Yarn Plug’n’Play is active: dependencies live inside zip archives, so no harness can install from them. Set nodeLinker: node-modules, or unplug the plugin dependencies.`),e.genericName&&t.push(`Marketplace name "${e.catalog.name}" is generic. Registering a second marketplace under a name already in use replaces the first silently, and the install that follows reports "already installed" — the repository then runs the other one's versions.`);for(let{package:n}of e.unresolved)t.push(`Declared dependency "${n}" is not installed; install dependencies before generating.`);return t}const cs=command({name:`dep-plugins`,description:`Derive the marketplace catalog for plugins shipped by this repository’s dependencies, so a harness can install them. Writes the catalog; installing is the harness’s own job.`,options:{root:{description:`Repository directory. Defaults to the current directory.`,type:J(q())},check:{description:`Report whether the catalog is current without writing it. For CI and postinstall.`,type:J(Fn())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:J(q()),default:`toon`}},run(e){try{let t=parseFormat$1(e.format),n=e.root??process.cwd(),r=deriveCatalog(n),i=e.check?catalogStatus(n,r.catalog)===`unchanged`?`current`:`would-change`:writeCatalog(n,r.catalog),a=ee(),o=notesFor(r),s=ss.filter(e=>e.installedOnMachine(a)),c=[],l=[];for(let e of s){let t=e.state(a),i=reconcile({catalog:r.catalog,catalogDir:is,root:C(n),installed:t.installed,marketplaces:t.marketplaces,scoped:e.scoped});i.collision&&o.push(`${e.name}: marketplace "${r.catalog.name}" is already registered against ${i.collision}. Registering over it replaces the other repository's silently, and the install that follows reports "already installed" — rename this repository's marketplace instead.`),c.push({runtime:e.name,status:i.actions.length?`${i.actions.length} to apply`:`in sync`});for(let t of i.actions)l.push({runtime:e.name,do:commandFor(e,t,r.catalog.name),subject:t.subject,why:t.detail})}return r.plugins.length&&o.push(`Copilot CLI rejects an npm marketplace source, so it cannot install from this catalog. It needs a path-sourced catalog, which cannot reach node_modules from a subdirectory.`),writeResult$1({catalog:as,marketplace:r.catalog.name,outcome:i,plugins:r.plugins.length?r.plugins.map(({plugin:e,package:t,version:n})=>({name:e,package:t,version:n})):`0 dependencies ship a plugin — nothing to install`,harness:c.length?c:`no supported harness detected on this machine`,actions:l.length?l:`0 actions — every detected harness matches the catalog`,...o.length?{notes:o}:{}},t),i===`would-change`?k.error:k.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Catalog generation failed.`}\n`),k.error}}});function filesUnder(e){try{return s(e,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(t=>S(e,y(t.parentPath,t.name)).split(w).join(x.sep)).sort()}catch{return[]}}function skillsProjection(e,t,n=skillsDirectories(e)?.[t]){let r=n??[],[i]=r;if(i===void 0)throw Error(`@cyberuni/agent-harness records no ${t} skills directories for ${e}.`);return r.includes(`.agents/skills`)?{}:{skillsDirectory:i}}const ls=`.agents/AGENTS.md`,us=[{name:`claude-code`,project:{detect:`.claude`,...skillsProjection(`claude-code`,`project`),shadowedBy:[`CLAUDE.md`,`.claude/CLAUDE.md`,`CLAUDE.local.md`],mcpConfig:{path:`.mcp.json`,key:`mcpServers`,format:`json`,dialect:`claude-code`},nonstandard:[{path:`.claude/commands`,shape:`directory`,kind:`command`},{path:`.claude/rules`,shape:`directory`,kind:`rule`},{path:`.claude/agents`,shape:`directory`,kind:`subagent`}]},user:{detect:`.claude`,...skillsProjection(`claude-code`,`user`),relocatedBy:`CLAUDE_CONFIG_DIR`,emptyRelocatesToStart:!0,instructionBridge:{kind:`import`,path:`.claude/CLAUDE.md`,line:`@~/${ls}`}}},{name:`cursor`,project:{detect:`.cursor`,...skillsProjection(`cursor`,`project`),mcpConfig:{path:`.cursor/mcp.json`,key:`mcpServers`,format:`json`,dialect:`cursor`},nonstandard:[{path:`.cursorrules`,shape:`file`,kind:`instructions`},{path:`.cursor/rules`,shape:`directory`,kind:`rule`},{path:`.cursor/commands`,shape:`directory`,kind:`command`},{path:`.cursor/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.cursor`,...skillsProjection(`cursor`,`user`)}},{name:`codex`,project:{detect:`.codex`,...skillsProjection(`codex`,`project`),mcpConfig:{path:`.codex/config.toml`,key:`mcp_servers`,format:`toml`,dialect:`codex`,shared:!0},nonstandard:[{path:`.codex/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.codex`,...skillsProjection(`codex`,`user`),instructionBridge:{kind:`symlink`,path:`.codex/AGENTS.md`},shadowedBy:[`.codex/AGENTS.override.md`],relocatedBy:`CODEX_HOME`}},{name:`copilot-cli`,project:{detect:`.github/skills`,...skillsProjection(`copilot-cli`,`project`),nonstandard:[{path:`.github/copilot-instructions.md`,shape:`file`,kind:`instructions`},{path:`.github/instructions`,shape:`directory`,kind:`instructions`},{path:`.github/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.copilot`,...skillsProjection(`copilot-cli`,`user`),relocatedBy:`COPILOT_HOME`,instructionBridge:{kind:`symlink`,path:`.copilot/copilot-instructions.md`}}},{name:`gemini-cli`,project:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`project`),instructionBridge:{kind:`settings-entry`,path:`.gemini/settings.json`,key:`context.fileName`},mcpConfig:{path:`.gemini/settings.json`,key:`mcpServers`,format:`json`,dialect:`gemini-cli`,shared:!0},nonstandard:[{path:`GEMINI.md`,shape:`file`,kind:`instructions`},{path:`.gemini/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`user`),instructionBridge:{kind:`symlink`,path:`.gemini/GEMINI.md`}}},{name:`devin-desktop`,project:{detect:`.devin`}},{name:`windsurf`,project:{detect:`.windsurf`,skillsDirectory:`.windsurf/skills`,nonstandard:[{path:`.windsurfrules`,shape:`file`,kind:`instructions`},{path:`.windsurf/rules`,shape:`directory`,kind:`rule`}]},deprecated:`devin-desktop`}],ds=new Set(us.map(e=>e.name));function isHarnessName(e){return ds.has(e)}function parseHarnesses(e){let t=(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>!isHarnessName(e));if(n.length)throw Error(`Unsupported harness: ${n.join(`, `)}. Supported: ${us.map(e=>e.name).join(`, `)}.`);return t.filter(isHarnessName)}const fs=[`claude-code`,`cursor`];function directoryExists(e){try{return i(e).isDirectory()}catch{return!1}}function selectHarnesses(e,t){let n=new Set([...fs,...t]);return us.filter(t=>n.has(t.name)||directoryExists(y(e,t.project.detect)))}function locatorText({file:e,server:t,field:n,position:r}){return r?`${e}#L${r.line}:${r.column}`:t===void 0?e:`${e}#servers.${t}${n===void 0?``:`.${n}`}`}function repairsOf(e){return Object.entries(e).map(([e,t])=>({problem:e,...t}))}const ps=`buddy-agent-harness`,ms=`/buddy-agent-harness:repair`,Q=`/buddy-agent-harness:init-buddy-agent-harness`,hs=`.agents/buddy-agent-harness/mcp.toml`,gs={"no-canonical":{detail:`the canonical skill directory does not exist, so no bridge can resolve`,repair:(e,t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create .agents/skills and the bridges into it`}),skillRepair:()=>`run \`${Q}\`, which creates \`.agents/skills\` and the bridges`},missing:{detail:`no bridge at this path — the harness sees zero project skills`,repair:({file:e},t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create the bridge at ${e}`}),skillRepair:()=>`run \`${Q}\``},degraded:{detail:`expected a directory but found a regular file — checkout without core.symlinks`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} as a real directory`}),skillRepair:({file:e})=>`run \`${Q} --copy --force ${e}\``},stale:{detail:`symlink does not resolve to .agents/skills`,repair:({file:e},t)=>({command:`${t} init --force ${e}`,instruction:`run \`${t} init --force ${e}\` to repoint ${e} at .agents/skills`}),skillRepair:({file:e})=>`run \`${Q} --force ${e}\``},"diverged-bridge":{detail:`only the bridge changed since the two last agreed — an agent wrote through the copy`,repair:({file:e},t)=>({command:``,instruction:`replace .agents/skills with ${e} to keep the newer edit, then run \`${t} init --force ${e}\``}),skillRepair:({file:e})=>`replace .agents/skills with ${e} to keep the newer edit, then run \`${Q} --force ${e}\``},"diverged-canonical":{detail:`only .agents/skills changed since the two last agreed — the copy is stale`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} from the newer .agents/skills`}),skillRepair:({file:e})=>`run \`${Q} --copy --force ${e}\``},"diverged-both":{detail:`both sides changed since they last agreed — rebuilding would discard one of them`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — rebuilding would discard one of them; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"diverged-unknown":{detail:`contents differ and no commit where they agreed was found — which side moved is unknown`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — which side moved is unknown; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"unpinned-copy":{detail:`tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed`,repair:({file:e})=>({command:`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree`,instruction:`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\` to restore the skip-worktree bit`}),skillRepair:({file:e})=>`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\``}};repairsOf(gs);const _s={"no-instructions":{detail:`no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most`,repair:()=>({command:``,instruction:`hand this to \`${Q}\`, which consolidates what the repository has into AGENTS.md, or derives it`}),skillRepair:()=>`run \`${Q}\`, which consolidates or derives AGENTS.md`},"instructions-missing":{detail:`no instruction bridge at this path — the harness reads none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${Q}\`, which writes the bridge into it`}),skillRepair:()=>`run \`${Q}\``},"instructions-unbridged":{detail:`the file is present but names AGENTS.md nowhere — the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${Q}\`, which adds the bridge without discarding what the file already says`}),skillRepair:()=>`run \`${Q}\`, which adds the bridge without discarding what the file already says`},"instructions-shadowing":{detail:`this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${Q}\`, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`}),skillRepair:()=>`run \`${Q}\`, which consolidates the file into AGENTS.md or imports AGENTS.md from it`},"instructions-superseded":{detail:`a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it`,repair:({file:e})=>({command:``,instruction:`remove ${e}, or keep it for sessions that cannot read AGENTS.md directly — \`${Q}\` offers the choice`}),skillRepair:()=>`run \`${Q}\`, which offers to remove it`},"instructions-unreadable":{detail:`the settings file does not parse, so the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`fix the JSON in ${e} by hand, then hand it to \`${Q}\``}),skillRepair:()=>`fix the JSON by hand, then run \`${Q}\``}};repairsOf(_s);const vs=`~/${ls}`;function globalBridgeStep(e,t=`~/${e.path}`){return e.kind===`import`?`add the line \`${e.line}\` to ${t}`:`run \`ln -s ${vs} ${t}\``}function userSpellings(e,t){let n=`${e.detect}/`;return e.relocatedBy!==void 0&&t.startsWith(n)?[`~/${t}`,`$${e.relocatedBy}/${t.slice(n.length)}`]:[`~/${t}`]}function userBridgeAt(e){for(let{user:t}of us){let n=t?.instructionBridge;if(t&&n&&userSpellings(t,n.path).includes(e))return n}}function stepAt(e,t){let n=userBridgeAt(e);return n===void 0?`add the bridge the harness page names for ${e}`:`${t&&n.kind!==`import`?`move what ${e} says into ${vs} and remove it, then `:``}${globalBridgeStep(n,e)}`}const ys=`hand the user this step, since nothing here writes outside the repository:`,bs={"global-instructions-missing":{detail:`no user-scope instruction file at this path — the harness loads none of ${vs}`,repair:({file:e})=>({command:``,instruction:`${ys} ${stepAt(e,!1)}`}),skillRepair:()=>`hand the user the step the harness page names for that file; write nothing yourself`},"global-instructions-unbridged":{detail:`the file holds its own content and does not load ${vs} — text placed there reaches no session of this harness`,repair:({file:e})=>({command:``,instruction:`${ys} ${stepAt(e,!0)}`}),skillRepair:()=>`hand the user the step the harness page names for that file, keeping what the file says; write nothing yourself`},"global-instructions-overridden":{detail:`the harness reads this file in place of its own user-scope file, so whatever that file loads goes unread, and this one does not load ${vs}`,repair:({file:e})=>({command:``,instruction:`${ys} move what ${e} says into ${vs} and remove it`}),skillRepair:()=>`hand the user the move of what that file says into the global file, and its removal; write nothing yourself`},"global-instructions-emptied":{detail:`the variable is set but empty, which this harness reads as the directory it starts in rather than as unset — its user-scope file is whichever one sits there, not the one in its own folder`,repair:({file:e})=>({command:``,instruction:`${ys} unset ${e.slice(1)} where your shell sets it, or set it to the folder you meant`}),skillRepair:()=>`hand the user the step of unsetting that variable; write nothing yourself`}};repairsOf(bs);const xs={"deprecated-harness":{detail:`a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all`,repair:({file:e})=>({command:``,instruction:`remove ${e} and enable the harness that replaced it — \`${ms}\` offers the correction`}),skillRepair:()=>`run \`${ms}\``},"ignored-bridge":{detail:`a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently`,repair:({file:e})=>({command:``,instruction:`narrow or remove the .gitignore rule matching ${e} — \`${ms}\` offers the correction`}),skillRepair:()=>`run \`${ms}\``},"unread-local-override":{detail:`no harness reads this filename, so everything in it is invisible to every agent`,repair:({file:e})=>({command:``,instruction:`move ${e} to CLAUDE.local.md, or consolidate it into AGENTS.md — \`${ms}\` offers the correction`}),skillRepair:()=>`run \`${ms}\``},"unloadable-skill":{detail:`frontmatter that does not parse, or no description — either one makes a harness skip the skill outright`,repair:({file:e})=>({command:``,instruction:`quote the description in ${e}, or add one — \`${ms}\` offers the correction`}),skillRepair:()=>`run \`${ms}\``}};repairsOf(xs);const Ss={"mcp-golden-unreadable":{detail:`the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it`,repair:e=>({command:``,instruction:`fix the TOML at ${locatorText(e)}`}),skillRepair:e=>`fix the TOML at ${locatorText(e)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`},"mcp-target-unreadable":{detail:`this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared`,repair:e=>({command:``,instruction:`fix the syntax of ${locatorText(e)}`}),skillRepair:e=>`fix the syntax of ${locatorText(e)} by hand`},"mcp-unprojected":{detail:`the golden set declares this server and the harness config does not carry it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${e}, or drop it from the golden set — \`${ms}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${ms}\`, which projects it from its golden entry with \`mcp project\` — or drop it from the golden set`},"mcp-undeclared":{detail:`the harness config carries this server and the golden set does not declare it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${hs}, or drop it from ${e} — \`${ms}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${ms}\`, which imports it field by field with \`mcp reconcile\`, refusing any literal credential — or drop it from ${e.file}`},"mcp-diverged-target":{detail:`only the harness config changed since the two last agreed — the edit was made through the copy`,repair:e=>({command:``,instruction:`reconcile the value at ${locatorText(e)} back into ${hs} — \`${ms}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${ms}\`, which imports the field into ${hs} with \`mcp reconcile\` once approved`},"mcp-diverged-golden":{detail:`only the golden set changed since the two last agreed — the harness copy is stale`,repair:e=>({command:``,instruction:`update ${locatorText(e)} from the golden entry — \`${ms}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${ms}\`, which updates it from the golden entry with \`mcp project\``},"mcp-diverged-both":{detail:`both sides changed since they last agreed — merging either way would discard the other`,repair:e=>({command:``,instruction:`reconcile ${locatorText(e)} against ${hs} by hand`}),skillRepair:e=>`reconcile ${locatorText(e)} against ${hs} by hand — never merge a three-way conflict automatically`},"mcp-diverged-unknown":{detail:`the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server`,repair:e=>({command:``,instruction:`compare ${locatorText(e)} against ${hs} by hand`}),skillRepair:e=>`compare ${locatorText(e)} against ${hs} by hand`},"mcp-literal-secret":{detail:`a credential-bearing field holds a literal rather than a reference to an environment variable`,repair:e=>({command:``,instruction:`move the value at ${locatorText(e)} into an environment variable and reference it`}),skillRepair:e=>`move the value at ${locatorText(e)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`},"mcp-committed-secret":{detail:`a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it`,repair:e=>({command:``,instruction:`rotate the credential behind ${locatorText(e)}, then reference it from an environment variable`}),skillRepair:e=>`rotate the credential behind ${locatorText(e)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`}};repairsOf(Ss);const Cs={"nonstandard-instructions":{detail:`instruction content only one harness reads — AGENTS.md carries the same prose to all of them`,repair:({file:e})=>({command:``,instruction:`consolidate ${e} into AGENTS.md — \`${Q}\` offers the consolidation, and keeps the content reachable where this harness needs it`}),skillRepair:({file:e})=>`hand ${e} to \`${Q}\`, which consolidates it into AGENTS.md`},"nonstandard-rule":{detail:`a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental`,repair:({file:e})=>({command:``,instruction:`convert ${e} into a skill under .agents/skills where its guidance is not tied to the paths it names — \`${Q}\` offers the conversion; keep it where the path scoping is the point`}),skillRepair:({file:e})=>`hand ${e} to \`${Q}\` to convert into a skill, unless the path scoping is load-bearing`},"nonstandard-command":{detail:`a harness command file — a skill is the portable form, and this harness reads skills too`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills/<name>/SKILL.md — \`${Q}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${Q}\`, which moves it to .agents/skills`},"nonstandard-skill":{detail:`a skill under a harness directory rather than the canonical one, where only that harness finds it`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills and project it back where the harness needs one — \`${Q}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${Q}\`, which moves it to .agents/skills`},"nonstandard-subagent":{detail:`a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet`,repair:({file:e})=>({command:``,instruction:`leave ${e} where it is and record that it reaches one harness only — no portable form exists to convert it to`}),skillRepair:({file:e})=>`leave ${e} in place — no portable form exists yet, so this is work for a person rather than a skill`}};repairsOf(Cs);const ws={...gs,..._s,...bs,...xs,...Ss,...Cs};repairsOf(ws);function repairFor(e){return{problem:e,...ws[e]}}const Ts=`.agents/skills`,Es=`AGENTS.local.md`;function frontmatterFault(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return`unparseable`;let n=/^description:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();if(!n)return`no-description`;if(!/^(['"]).*\1$/.test(n)&&/:\s/.test(n))return`unparseable`}function diagnoseConfiguration({root:e,git:t,cli:n}){let i=[],add=(e,t)=>{let{detail:r,repair:a}=repairFor(t);i.push({path:e,problem:t,detail:r,repair:a({file:e},n)})},a=selectHarnesses(e,[]);for(let t of a){let n=t.project.skillsDirectory;t.deprecated&&n&&r(y(e,n))&&add(n,`deprecated-harness`)}for(let n of a){let i=n.project.skillsDirectory;i&&r(y(e,i))&&t.isIgnored(i)&&add(i,`ignored-bridge`)}r(y(e,Es))&&add(Es,`unread-local-override`);for(let t of filesUnder(y(e,Ts)).filter(e=>e.endsWith(`SKILL.md`)))frontmatterFault(o(y(e,Ts,t),`utf8`))&&add(`${Ts}/${t}`,`unloadable-skill`);return i}const Ds=[`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`enabled`,`timeout`,`source`],Os=new Set([`env`,`headers`]);function sameValue(e,t,n){if(Os.has(e)&&isRecord$1(t)&&isRecord$1(n)){let e=Object.keys(t);return e.length===Object.keys(n).length&&e.every(e=>t[e]===n[e])}return JSON.stringify(t)===JSON.stringify(n)}function divergingFields(e,t,n=new Set(Ds)){return Ds.filter(r=>{if(!n.has(r))return!1;let i=e[r];if(i===void 0)return!1;if(Os.has(r)&&isRecord$1(i)&&isRecord$1(t[r])){let e=t[r];return Object.keys(i).some(t=>i[t]!==e[t])}return!sameValue(r,i,t[r])})}function sameField(e,t,n){return sameValue(e,t?.[e],n?.[e])}function stringMap(e){if(!isRecord$1(e))return;let t=Object.entries(e).filter(([,e])=>typeof e==`string`);return t.length?Object.fromEntries(t):void 0}const ks=new Set([`stdio`,`http`,`sse`]);function transportOf(e){let t=e.type??e.transport;if(typeof t==`string`&&ks.has(t))return t;if(typeof e.url==`string`)return`http`;if(typeof e.command==`string`)return`stdio`}function serverFrom(e){let t=Array.isArray(e.args)&&e.args.every(e=>typeof e==`string`),n=transportOf(e),r=stringMap(e.env),i=stringMap(e.headers);return{...n?{transport:n}:{},...typeof e.command==`string`?{command:e.command}:{},...t?{args:e.args}:{},...r?{env:r}:{},...typeof e.url==`string`?{url:e.url}:{},...i?{headers:i}:{},...typeof e.description==`string`?{description:e.description}:{},...typeof e.enabled==`boolean`?{enabled:e.enabled}:{},...typeof e.timeout==`number`?{timeout:e.timeout}:{},...typeof e.source==`string`?{source:e.source}:{}}}const As=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/,js=/\$\{[^}]*\}|\$[A-Za-z_]/;var Refusal=class extends Error{field;reason;constructor(e,t){super(t),this.field=e,this.reason=t}};function refuse(e,t){throw new Refusal(e,t)}function rendering(e){try{return{kind:`entry`,entry:e()}}catch(e){if(!(e instanceof Refusal))throw e;return{kind:`refused`,field:e.field,reason:e.reason}}}function assertRunnable(e){(e.transport===`stdio`?!e.command:!e.url)&&refuse(e.transport===`stdio`?`command`:`url`,`the golden set leaves it unset and the target requires it`)}function defined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function mapValues(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}function noReferenceIn(e,t,n){for(let r of t){let t=e[r];(Array.isArray(t)?t:[t]).some(e=>typeof e==`string`&&js.test(e))&&refuse(r,`${n} documents no reference expansion here`)}}const Ms={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`timeout`]),read:serverFrom,write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport,command:e.command,args:e.args,env:e.env,url:e.url,headers:e.headers,description:e.description,timeout:e.timeout})))};function toCursor(e,t){return e.replace(/\$\{([^}]*)\}|\$[A-Za-z_]/g,(e,n)=>((n===void 0||!As.test(e))&&refuse(t,`Cursor expands only a plain variable reference, with no default`),`\${env:${n}}`))}function fromCursor(e){return e.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>`\${${t}}`)}function fromCursorEntry(e){let strings=e=>typeof e==`string`?fromCursor(e):e,map=e=>isRecord$1(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,strings(t)])):e;return{...e,command:strings(e.command),args:Array.isArray(e.args)?e.args.map(strings):e.args,env:map(e.env),url:strings(e.url),headers:map(e.headers)}}const Ns={fields:new Set([`command`,`args`,`env`,`url`,`headers`]),read:e=>serverFrom(fromCursorEntry(e)),write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport===`stdio`?`stdio`:void 0,command:e.command&&toCursor(e.command,`command`),args:e.args?.map(e=>toCursor(e,`args`)),env:mapValues(e.env,e=>toCursor(e,`env`)),url:e.url&&toCursor(e.url,`url`),headers:mapValues(e.headers,e=>toCursor(e,`headers`))})))},Ps=/^Bearer \$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function codexEnv(e){let t={},n=[];for(let[r,i]of Object.entries(e??{}))As.exec(i)?.[1]===r?n.push(r):js.test(i)?refuse(`env`,`Codex passes a variable through only under its own name`):t[r]=i;return defined({env:Object.keys(t).length?t:void 0,env_vars:n.length?n:void 0})}function codexHeaders(e){let t={},n={},r;for(let[i,a]of Object.entries(e??{})){let e=As.exec(a)?.[1],o=Ps.exec(a)?.[1];o&&i===`Authorization`?r=o:e?n[i]=e:js.test(a)?refuse(`headers`,`Codex fills a header only from a whole variable reference, or Bearer and one`):t[i]=a}return defined({http_headers:Object.keys(t).length?t:void 0,env_http_headers:Object.keys(n).length?n:void 0,bearer_token_env_var:r})}function stringRecord(e){return isRecord$1(e)?Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`)):{}}function fromCodex(e){let t=Array.isArray(e.env_vars)?e.env_vars.filter(e=>typeof e==`string`):[],n={...stringRecord(e.env),...Object.fromEntries(t.map(e=>[e,`\${${e}}`]))},r=e.bearer_token_env_var,i={...stringRecord(e.http_headers),...Object.fromEntries(Object.entries(stringRecord(e.env_http_headers)).map(([e,t])=>[e,`\${${t}}`])),...typeof r==`string`?{Authorization:`Bearer \${${r}}`}:{}},a=e.tool_timeout_sec;return{command:e.command,args:e.args,env:n,url:e.url,headers:i,enabled:e.enabled,timeout:typeof a==`number`?Math.round(a*1e3):void 0}}const Fs={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`enabled`,`timeout`]),defaults:{timeout:6e4},read:e=>serverFrom(fromCodex(e)),write:e=>rendering(()=>(e.transport===`sse`&&refuse(`transport`,`Codex supports no SSE transport`),assertRunnable(e),noReferenceIn(e,[`command`,`args`,`url`],`Codex`),defined({command:e.command,args:e.args,...codexEnv(e.env),url:e.url,...codexHeaders(e.headers),enabled:e.enabled,tool_timeout_sec:e.timeout===void 0?void 0:e.timeout/1e3})))};function fromGemini(e){let{httpUrl:t,url:n,...r}=e;return typeof t==`string`?{...r,type:`http`,url:t}:typeof n==`string`?{...r,type:`sse`,url:n}:r}const Is={"claude-code":Ms,cursor:Ns,codex:Fs,"gemini-cli":{fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`timeout`]),defaults:{timeout:6e5},read:e=>serverFrom(fromGemini(e)),write:e=>rendering(()=>(assertRunnable(e),defined({command:e.command,args:e.args,env:e.env,url:e.transport===`sse`?e.url:void 0,httpUrl:e.transport===`http`?e.url:void 0,headers:e.headers,timeout:e.timeout})))}};function stripJsonComments(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(r){t+=a,i?i=!1:a===`\\`?i=!0:a===`"`&&(r=!1),n+=1;continue}if(a===`"`){r=!0,t+=a,n+=1;continue}if(a===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
|
|
159
|
+
`)}function tagText(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function matchKind(e,t,n){let r=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(r===n||e.toLowerCase()===n)return`name`;if(r.startsWith(n))return`prefix`;if(r.includes(n)||distance(r,n)<=Math.max(1,Math.floor(n.length/4)))return`close name`;let i=n.split(/\s+/),holds=e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e))},a=t.metadata??{};if(holds(`${typeof a.description==`string`?a.description:``} ${tagText(a.tags)}`))return`description`;let o=t.content??``;if(holds(headings(o)))return`heading`;if(holds(o))return`body`}function searchReferences(e,t,n={}){let r=e.trim().toLowerCase(),i=[],consider=(e,t)=>{if(e.status!==`found`)return;let n=matchKind(e.name,e,r);if(!n)return;let a=e.trace.contributions.at(-1),o={name:e.name,description:firstLine$1(e.metadata?.description),match:n,tier:a?.tier??`plugin`};a?.plugin!==void 0&&(o.plugin=a.plugin),a?.skill!==void 0&&(o.skill=a.skill),t!==void 0&&(o.loadedBy=t),i.push(o)},a=new Map;for(let e of referenceNames(t)){let r=resolveReference(e,t,n);if(a.set(e,r.content),r.status!==`ambiguous`)consider(r);else for(let e of r.options??[])e!=="default"&&consider(resolveReference(e,t,n))}for(let{name:e,skill:r}of skillHoldings(t)){let i=resolveReference(e,withDefault(t,r.folder),n);i.trace.layers.some(({tier:e,outcome:t})=>e==="default"&&t===`used`)&&i.content!==a.get(e)&&consider(i,r.name)}i.sort((e,t)=>Cn.indexOf(e.match)-Cn.indexOf(t.match)||e.name.localeCompare(t.name));let o=defaultsUnverified(t);return o?{matches:i,defaults:o}:{matches:i}}function interfaceLookup(e,t={}){let n=new Map;return r=>{let i=n.get(r);if(i)return i;let a=lookUp(r,e,t);return n.set(r,a),a}}function lookUp(e,t,n){let r=`${e}${yn}`,i=resolveReference(r,t,n),failure=t=>({failure:{check:`interface found`,interface:e,message:t}});if(i.status===`invalid`)return failure(`${e} is not an interface id`);if(i.status===`missing`)return failure(`no interface document ${r}`);if(i.status===`ambiguous`)return failure(`${r} is ambiguous between ${(i.options??[]).join(` and `)}`);let{value:a,problems:o}=readInterface(e,i.metadata??{});return a?{value:a}:failure(`${r} is malformed: ${o.join(`; `)}`)}function bareName$1(e){return e.slice(e.lastIndexOf(`/`)+1)}__name(bareName$1,`bareName`);function kindOf(e){let t=e.metadata??{};return interfaceIdOf(bareName$1(e.name))!==void 0||t.interface!==void 0?`interface`:t.implements===void 0?`none`:`implementation`}function checkResolved(e,t,n){if(e.status!==`found`)return{failures:[],unsupported:[]};let r=bareName$1(e.name),i=e.metadata??{},a=[],o=[];if(kindOf(e)===`interface`){let e=interfaceIdOf(r);if(e===void 0)a.push({check:`interface`,message:`${r} has an \`interface:\` block; an interface document is named <id>${yn}`});else for(let t of readInterface(e,i).problems)a.push({check:`interface`,interface:e,message:t})}else{let{entry:s,problems:c}=readImplements(i);for(let e of c)a.push({check:`interface found`,message:e});if(s){let i=t(s.id);if(i.value){let t=checkImplementation(i.value,{name:r,version:s.version,content:e.content??``,accept:n?.id===s.id?n.versions:void 0});a.push(...t.failures),o=t.unsupported}else a.push(i.failure)}}return e.warnings.length&&a.push({check:`compose`,message:`composing it raised ${e.warnings.length===1?`a warning`:`${e.warnings.length} warnings`}: ${e.warnings.map(({code:e,message:t})=>`${e}: ${t}`).join(`; `)}`}),{failures:a,unsupported:o}}function entryOf(e,t){if(e.status!==`found`)return{name:e.name,kind:`none`,status:e.status,failures:[{check:e.code,message:e.message??e.status}],unsupported:[]};let n=kindOf(e),{failures:r,unsupported:i}=n===`none`?{failures:[{check:`interface found`,message:`${e.name} declares no \`implements\` and is not an interface document`}],unsupported:[]}:checkResolved(e,t);return{name:e.name,kind:n,status:r.length?`failed`:`passed`,failures:r,unsupported:i}}function pluginCopies(e,t){let n=[...new Set(t.trace.layers.flatMap(({plugin:e,file:t})=>e!==void 0&&t?[e]:[]))];return n.length>1?n.map(t=>`${t}/${e}`):[]}function checkReferences(e,t={}){let{names:n,...r}=t,i=interfaceLookup(e,r),resolve=t=>resolveReference(parseReferenceName(t),e,r);if(n?.length)return n.map(e=>entryOf(resolve(e),i));let a=[],o=new Map;for(let t of referenceNames(e)){let e=resolve(t);o.set(t,e.content);let n=[...e.status===`found`?[e]:[],...pluginCopies(t,e).map(resolve)];for(let e of n)e.status===`found`&&kindOf(e)!==`none`&&a.push(entryOf(e,i))}for(let{name:t,skill:n}of skillHoldings(e)){let s=resolveReference(t,withDefault(e,n.folder),r),c=s.trace.layers.some(({tier:e,outcome:t})=>e==="default"&&t===`used`);s.status===`found`&&c&&kindOf(s)!==`none`&&s.content!==o.get(t)&&a.push({...entryOf(s,i),loadedBy:n.name})}return a}function firstLine(e){return typeof e==`string`&&e.split(`
|
|
160
|
+
`)[0]?.trim()||``}function belongsElsewhere(e,t,n){return t!==void 0&&t!==n&&(e===t||e.startsWith(`${t}.`))}function referenceImplementations(e,t,n={}){let{accept:r,...i}=n,a=parseReferenceName(`${e}${yn}`);if(a.invalid||a.plugin!==void 0)throw Error(`"${e}" is not an interface id.`);let o=interfaceLookup(t,i),s=o(e),c=s.value;if(!c)throw Error(s.failure?.message??`no interface ${e}`);let l=[...r?.length?r:c.versions],u={interface:e,cardinality:c.cardinality,accept:l,implementations:[],excluded:[],warnings:[]},d=new Set,consider=(t,n)=>{if(n.status!==`found`)return;let r=readImplements(n.metadata??{}).entry,i=t===e||t.startsWith(`${e}.`),a=r?.id===e;if(!a&&(!i||t.endsWith(`.interface`)||belongsElsewhere(t,r?.id,e)))return;for(let e of n.warnings){let t=`${e.code} ${e.message}`;d.has(t)||u.warnings.push(e),d.add(t)}if(!a){let r=fitsName(c,t)?``:` and is not named ${c.cardinality===`one`?e:`${e}.<key>`}`;u.excluded.push({name:n.name,reasons:[`declares no implements ${e}@<version>${r}`]});return}let{failures:s,unsupported:f}=checkResolved(n,o,{id:e,versions:l});if(s.length){u.excluded.push({name:n.name,reasons:s.map(({check:e,message:t})=>`${e}: ${t}`)});return}let p=n.trace.contributions.at(-1);u.implementations.push({pin:n.name,description:firstLine(n.metadata?.description),unsupported:f,name:t,tier:p?.tier??`plugin`,version:r.version})};for(let n of referenceNames(t)){if(n===`${e}.interface`)continue;let r=resolveReference(n,t,i);if(r.status!==`ambiguous`){consider(n,r);continue}for(let e of r.options??[])e!=="default"&&consider(n,resolveReference(e,t,i))}return u}const wn={project:`everyone working in this repository`,user:`only you, in every repository`};function whereReference(e,t,{root:n,display:r=e=>e}){let i=typeof e==`string`?parseReferenceName(e):e,a=resolveReference(i,t,{display:r}),o={name:i.raw,status:a.status,places:[],layers:a.trace.layers,warnings:a.warnings};if(a.options&&(o.options=a.options),i.invalid)return o;let s=Array.isArray(t)?t:t.layers,c=projectReferencesDir(n),l=s.find(({tier:e})=>e===`user`)?.dir,u=[{scope:`project`,dir:c},...l?[{scope:`user`,dir:l}]:[]];for(let{scope:e,dir:s}of u){let c=b(s,`${i.name}.md`),l=a.trace.layers.find(e=>e.path===c),u=resolveReference(i,t,{display:r,below:s});o.places.push({scope:e,path:e===`project`?S(n,c):r(c),reaches:wn[e],status:l?.file?l.outcome:`empty`,sections:u.status===`found`?headingPaths(u.content??``):[]})}return o}const Tn=new Set([`deps`,`dependencies`,`local`,`plugins`,`marketplace`,`plugin`,`default`]);function isGenericName(e){return Tn.has(e.toLowerCase())}function marketplaceName(e){return e.replace(/^@/,``).replace(/\//g,`-`).replace(/[^a-zA-Z0-9-_.]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`agent-plugins`}function buildCatalog({name:e,owner:t,plugins:n}){let r=[...n].sort((e,t)=>e.plugin.localeCompare(t.plugin)).map(({plugin:e,package:t,version:n,description:r})=>{let i={source:`npm`,package:t,version:n};return r?{name:e,source:i,description:r}:{name:e,source:i}});return{name:e,owner:{name:t},description:`Plugins provided by this repository’s dependencies. Generated — do not edit.`,plugins:r}}function serializeCatalog(e){return`${JSON.stringify(e,null,` `)}\n`}function readJson$1(e){try{return JSON.parse(a(e,`utf8`))}catch{return}}__name(readJson$1,`readJson`);function readDepPlugin(e,t){let n=packageDir(e,t);if(!n)return{ok:!1,package:e,reason:`unresolved`};let r=readJson$1(b(n,`plugin.json`));if(!r||typeof r!=`object`)return{ok:!1,package:e,reason:`no-manifest`};let i=r,a=typeof i.name==`string`?i.name:void 0;if(!a)return{ok:!1,package:e,reason:`unnamed`};let o=readJson$1(b(n,`package.json`)),s=typeof o?.version==`string`?o.version:void 0;if(!s)return{ok:!1,package:e,reason:`no-manifest`};let c=typeof i.description==`string`?i.description:void 0;return{ok:!0,plugin:c?{package:e,plugin:a,version:s,description:c}:{package:e,plugin:a,version:s}}}function isPnp(){return!!process.versions.pnp}const En=b(`.agents`,`buddy-agent-harness`),Dn=b(En,`.claude-plugin`,`marketplace.json`);function readManifest(e){return JSON.parse(a(e,`utf8`))}function deriveCatalog(e){let t=b(e,`package.json`),n=readManifest(t),r=[],i=[];for(let e of declaredDependencies(n)){let n=readDepPlugin(e,t);n.ok?r.push(n.plugin):n.reason===`unresolved`&&i.push({package:e,reason:n.reason})}let a=typeof n.name==`string`?n.name:`unknown`,o=marketplaceName(a);return{catalog:buildCatalog({name:o,owner:a,plugins:r}),plugins:r,unresolved:i,genericName:isGenericName(o),pnp:isPnp()}}function catalogStatus(e,t){let n;try{n=a(b(e,Dn),`utf8`)}catch{n=void 0}return n===serializeCatalog(t)?`unchanged`:n===void 0?`created`:`updated`}function writeCatalog(e,t){let n=catalogStatus(e,t);if(n===`unchanged`)return n;let r=b(e,Dn);return i(y(r),{recursive:!0}),p(r,serializeCatalog(t)),n}function readJson(e){try{return JSON.parse(a(e,`utf8`))}catch{return}}function directories(e){try{return o(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}function claudeConfigDir(e,t=process.env){return t.CLAUDE_CONFIG_DIR||b(e,`.claude`)}function readClaudeState(e){let t=readJson(b(e,`plugins`,`installed_plugins.json`)),n=[];for(let[e,r]of Object.entries(t?.plugins??{}))if(Array.isArray(r))for(let t of r){if(!t||typeof t!=`object`)continue;let r=t,i=typeof r.version==`string`?r.version:void 0,a=typeof r.scope==`string`?r.scope:void 0;if(!i||!a)continue;let o=typeof r.projectPath==`string`?r.projectPath:void 0;n.push(o?{id:e,version:i,scope:a,projectPath:o}:{id:e,version:i,scope:a})}let r=readJson(b(e,`plugins`,`known_marketplaces.json`)),i=[];for(let[e,t]of Object.entries(r??{}))i.push({name:e,path:typeof t?.source?.path==`string`?t.source.path:``});return{installed:n,marketplaces:i}}const On={name:`claude-code`,scoped:!0,installedOnMachine:(e,t=process.env)=>n(claudeConfigDir(e,t)),state:(e,t=process.env)=>readClaudeState(claudeConfigDir(e,t)),register:e=>`claude plugin marketplace add ./${e} --scope project`,install:e=>`claude plugin install ${e} --scope project`,update:e=>`claude plugin update ${e} --scope project`,uninstall:e=>`claude plugin uninstall ${e} --scope project`,refreshMarketplace:e=>`claude plugin marketplace update ${e}`};function codexHome(e,t=process.env){return t.CODEX_HOME||b(e,`.codex`)}function readCodexState(e){let t=b(e,`plugins`,`cache`),n=[];for(let e of directories(t))for(let r of directories(b(t,e)))for(let i of directories(b(t,e,r)))n.push({id:`${r}@${e}`,version:i,scope:`user`});let r=[],i=``;try{i=a(b(e,`config.toml`),`utf8`)}catch{i=``}let o;for(let e of i.split(`
|
|
161
|
+
`)){let t=/^\s*\[marketplaces\.(?:"([^"]+)"|([^\]]+))\]\s*$/.exec(e);if(t){o={name:t[1]??t[2],path:``},r.push(o);continue}if(/^\s*\[/.test(e)){o=void 0;continue}let n=o?/^\s*source\s*=\s*"([^"]*)"\s*$/.exec(e):void 0;n?.[1]&&o&&(o.path=n[1])}return{installed:n,marketplaces:r}}const kn=[On,{name:`codex`,scoped:!1,installedOnMachine:(e,t=process.env)=>n(codexHome(e,t)),state:(e,t=process.env)=>readCodexState(codexHome(e,t)),register:e=>`codex plugin marketplace add ./${e}`,install:e=>`codex plugin add ${e}`,update:e=>`codex plugin add ${e}`,uninstall:e=>`codex plugin remove ${e}`,refreshMarketplace:()=>``}];function ours(e,t,n,r){let i=`@${t}`;return e.filter(e=>e.id.endsWith(i)&&(!r||e.projectPath===n))}function reconcile({catalog:e,catalogDir:t,root:n,installed:r,marketplaces:i,scoped:a=!0}){let o=i.find(t=>t.name===e.name),s=[],c=t.split(/[\\/]/).filter(Boolean),l=o?c.every(e=>o.path.includes(e)):!1,u=o&&!l?o.path:void 0;o||s.push({kind:`register`,subject:e.name,detail:`marketplace is not registered with this harness`});let d=ours(r,e.name,n,a),f=new Map(d.map(e=>[e.id,e]));for(let t of e.plugins){let n=`${t.name}@${e.name}`,r=f.get(n);if(!r){s.push({kind:`install`,subject:n,detail:`not installed; catalog pins ${t.source.version}`});continue}r.version!==t.source.version&&s.push({kind:`update`,subject:n,detail:`installed ${r.version}, catalog pins ${t.source.version}`})}let p=new Set(e.plugins.map(t=>`${t.name}@${e.name}`));for(let e of d)p.has(e.id)||s.push({kind:`uninstall`,subject:e.id,detail:`installed but no longer in the catalog; it will report a load failure until removed`});return{actions:s,...u?{collision:u}:{},unregistered:!o}}function commandFor(e,t,n){switch(t.kind){case`register`:return e.register(En);case`install`:return e.install(t.subject);case`update`:{let r=e.refreshMarketplace(n),i=e.update(t.subject);return r?`${r} && ${i}`:i}case`uninstall`:return e.uninstall(t.subject)}}function notesFor(e){let t=[];e.pnp&&t.push(`Yarn Plug’n’Play is active: dependencies live inside zip archives, so no harness can install from them. Set nodeLinker: node-modules, or unplug the plugin dependencies.`),e.genericName&&t.push(`Marketplace name "${e.catalog.name}" is generic. Registering a second marketplace under a name already in use replaces the first silently, and the install that follows reports "already installed" — the repository then runs the other one's versions.`);for(let{package:n}of e.unresolved)t.push(`Declared dependency "${n}" is not installed; install dependencies before generating.`);return t}const An=command({name:`dep-plugins`,description:`Derive the marketplace catalog for plugins shipped by this repository’s dependencies, so a harness can install them. Writes the catalog; installing is the harness’s own job.`,options:{root:{description:`Repository directory. Defaults to the current directory.`,type:k.string().optional()},check:{description:`Report whether the catalog is current without writing it. For CI and postinstall.`,type:k.boolean().optional()}},run(e){try{let t=e.root??process.cwd(),n=deriveCatalog(t),r=e.check?catalogStatus(t,n.catalog)===`unchanged`?`current`:`would-change`:writeCatalog(t,n.catalog),i=g(),a=notesFor(n),o=kn.filter(e=>e.installedOnMachine(i)),s=[],c=[];for(let e of o){let r=e.state(i),o=reconcile({catalog:n.catalog,catalogDir:En,root:C(t),installed:r.installed,marketplaces:r.marketplaces,scoped:e.scoped});o.collision&&a.push(`${e.name}: marketplace "${n.catalog.name}" is already registered against ${o.collision}. Registering over it replaces the other repository's silently, and the install that follows reports "already installed" — rename this repository's marketplace instead.`),s.push({runtime:e.name,status:o.actions.length?`${o.actions.length} to apply`:`in sync`});for(let t of o.actions)c.push({runtime:e.name,do:commandFor(e,t,n.catalog.name),subject:t.subject,why:t.detail})}n.plugins.length&&a.push(`Copilot CLI rejects an npm marketplace source, so it cannot install from this catalog. It needs a path-sourced catalog, which cannot reach node_modules from a subdirectory.`);let l=result({catalog:Dn,marketplace:n.catalog.name,outcome:r,plugins:n.plugins.length?n.plugins.map(({plugin:e,package:t,version:n})=>({name:e,package:t,version:n})):`0 dependencies ship a plugin — nothing to install`,harness:s.length?s:`no supported harness detected on this machine`,actions:c.length?c:`0 actions — every detected harness matches the catalog`,...a.length?{notes:a}:{}});return r===`would-change`?answerThenFail$1(l,this.format):l}catch(e){return fail$1(e,`Catalog generation failed.`)}}});function filesUnder(e){try{return o(e,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(t=>S(e,b(t.parentPath,t.name)).split(w).join(x.sep)).sort()}catch{return[]}}function skillsProjection(e,t,n=skillsDirectories(e)?.[t]){let r=n??[],[i]=r;if(i===void 0)throw Error(`cyber-agentkit records no ${t} skills directories for ${e}.`);return r.includes(`.agents/skills`)?{}:{skillsDirectory:i}}const jn=`.agents/AGENTS.md`,V=[{name:`claude-code`,project:{detect:`.claude`,...skillsProjection(`claude-code`,`project`),shadowedBy:[`CLAUDE.md`,`.claude/CLAUDE.md`,`CLAUDE.local.md`],mcpConfig:{path:`.mcp.json`,key:`mcpServers`,format:`json`,dialect:`claude-code`},nonstandard:[{path:`.claude/commands`,shape:`directory`,kind:`command`},{path:`.claude/rules`,shape:`directory`,kind:`rule`},{path:`.claude/agents`,shape:`directory`,kind:`subagent`}]},user:{detect:`.claude`,...skillsProjection(`claude-code`,`user`),relocatedBy:`CLAUDE_CONFIG_DIR`,emptyRelocatesToStart:!0,instructionBridge:{kind:`import`,path:`.claude/CLAUDE.md`,line:`@~/${jn}`}}},{name:`cursor`,project:{detect:`.cursor`,...skillsProjection(`cursor`,`project`),mcpConfig:{path:`.cursor/mcp.json`,key:`mcpServers`,format:`json`,dialect:`cursor`},nonstandard:[{path:`.cursorrules`,shape:`file`,kind:`instructions`},{path:`.cursor/rules`,shape:`directory`,kind:`rule`},{path:`.cursor/commands`,shape:`directory`,kind:`command`},{path:`.cursor/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.cursor`,...skillsProjection(`cursor`,`user`)}},{name:`codex`,project:{detect:`.codex`,...skillsProjection(`codex`,`project`),mcpConfig:{path:`.codex/config.toml`,key:`mcp_servers`,format:`toml`,dialect:`codex`,shared:!0},nonstandard:[{path:`.codex/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.codex`,...skillsProjection(`codex`,`user`),instructionBridge:{kind:`symlink`,path:`.codex/AGENTS.md`},shadowedBy:[`.codex/AGENTS.override.md`],relocatedBy:`CODEX_HOME`}},{name:`copilot-cli`,project:{detect:`.github/skills`,...skillsProjection(`copilot-cli`,`project`),nonstandard:[{path:`.github/copilot-instructions.md`,shape:`file`,kind:`instructions`},{path:`.github/instructions`,shape:`directory`,kind:`instructions`},{path:`.github/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.copilot`,...skillsProjection(`copilot-cli`,`user`),relocatedBy:`COPILOT_HOME`,instructionBridge:{kind:`symlink`,path:`.copilot/copilot-instructions.md`}}},{name:`gemini-cli`,project:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`project`),instructionBridge:{kind:`settings-entry`,path:`.gemini/settings.json`,key:`context.fileName`},mcpConfig:{path:`.gemini/settings.json`,key:`mcpServers`,format:`json`,dialect:`gemini-cli`,shared:!0},nonstandard:[{path:`GEMINI.md`,shape:`file`,kind:`instructions`},{path:`.gemini/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`user`),instructionBridge:{kind:`symlink`,path:`.gemini/GEMINI.md`}}},{name:`devin-desktop`,project:{detect:`.devin`}},{name:`windsurf`,project:{detect:`.windsurf`,skillsDirectory:`.windsurf/skills`,nonstandard:[{path:`.windsurfrules`,shape:`file`,kind:`instructions`},{path:`.windsurf/rules`,shape:`directory`,kind:`rule`}]},deprecated:`devin-desktop`}],Mn=new Set(V.map(e=>e.name));function isHarnessName(e){return Mn.has(e)}function parseHarnesses(e){let t=(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>!isHarnessName(e));if(n.length)throw Error(`Unsupported harness: ${n.join(`, `)}. Supported: ${V.map(e=>e.name).join(`, `)}.`);return t.filter(isHarnessName)}const Nn=[`claude-code`,`cursor`];function directoryExists(e){try{return r(e).isDirectory()}catch{return!1}}function selectHarnesses(e,t){let n=new Set([...Nn,...t]);return V.filter(t=>n.has(t.name)||directoryExists(b(e,t.project.detect)))}function locatorText({file:e,server:t,field:n,position:r}){return r?`${e}#L${r.line}:${r.column}`:t===void 0?e:`${e}#servers.${t}${n===void 0?``:`.${n}`}`}function repairsOf(e){return Object.entries(e).map(([e,t])=>({problem:e,...t}))}const H=`buddy-agent-harness`,Pn=`/buddy-agent-harness:init-buddy-agent-harness`,pnpmSkillRef=e=>`\`${e}\` (pnpm install: \`pnpm-${H}-${e.slice(e.indexOf(`:`)+1)}\`)`,U=pnpmSkillRef(Pn),W=pnpmSkillRef(`/buddy-agent-harness:repair`),G=`.agents/buddy-agent-harness/mcp.toml`,Fn={"no-canonical":{detail:`the canonical skill directory does not exist, so no bridge can resolve`,repair:(e,t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create .agents/skills and the bridges into it`}),skillRepair:()=>`run ${U}, which creates \`.agents/skills\` and the bridges`},missing:{detail:`no bridge at this path — the harness sees zero project skills`,repair:({file:e},t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create the bridge at ${e}`}),skillRepair:()=>`run ${U}`},degraded:{detail:`expected a directory but found a regular file — checkout without core.symlinks`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} as a real directory`}),skillRepair:({file:e})=>`run \`${Pn} --copy --force ${e}\``},stale:{detail:`symlink does not resolve to .agents/skills`,repair:({file:e},t)=>({command:`${t} init --force ${e}`,instruction:`run \`${t} init --force ${e}\` to repoint ${e} at .agents/skills`}),skillRepair:({file:e})=>`run \`${Pn} --force ${e}\``},"diverged-bridge":{detail:`only the bridge changed since the two last agreed — an agent wrote through the copy`,repair:({file:e},t)=>({command:``,instruction:`replace .agents/skills with ${e} to keep the newer edit, then run \`${t} init --force ${e}\``}),skillRepair:({file:e})=>`replace .agents/skills with ${e} to keep the newer edit, then run \`${Pn} --force ${e}\``},"diverged-canonical":{detail:`only .agents/skills changed since the two last agreed — the copy is stale`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} from the newer .agents/skills`}),skillRepair:({file:e})=>`run \`${Pn} --copy --force ${e}\``},"diverged-both":{detail:`both sides changed since they last agreed — rebuilding would discard one of them`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — rebuilding would discard one of them; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"diverged-unknown":{detail:`contents differ and no commit where they agreed was found — which side moved is unknown`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — which side moved is unknown; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"unpinned-copy":{detail:`tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed`,repair:({file:e})=>({command:`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree`,instruction:`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\` to restore the skip-worktree bit`}),skillRepair:({file:e})=>`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\``}};repairsOf(Fn);const In={"no-instructions":{detail:`no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most`,repair:()=>({command:``,instruction:`hand this to ${U}, which consolidates what the repository has into AGENTS.md, or derives it`}),skillRepair:()=>`run ${U}, which consolidates or derives AGENTS.md`},"instructions-missing":{detail:`no instruction bridge at this path — the harness reads none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to ${U}, which writes the bridge into it`}),skillRepair:()=>`run ${U}`},"instructions-unbridged":{detail:`the file is present but names AGENTS.md nowhere — the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`hand ${e} to ${U}, which adds the bridge without discarding what the file already says`}),skillRepair:()=>`run ${U}, which adds the bridge without discarding what the file already says`},"instructions-shadowing":{detail:`this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to ${U}, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`}),skillRepair:()=>`run ${U}, which consolidates the file into AGENTS.md or imports AGENTS.md from it`},"instructions-superseded":{detail:`a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it`,repair:({file:e})=>({command:``,instruction:`remove ${e}, or keep it for sessions that cannot read AGENTS.md directly — ${U} offers the choice`}),skillRepair:()=>`run ${U}, which offers to remove it`},"instructions-unreadable":{detail:`the settings file does not parse, so the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`fix the JSON in ${e} by hand, then hand it to ${U}`}),skillRepair:()=>`fix the JSON by hand, then run ${U}`}};repairsOf(In);const K=`~/${jn}`;function globalBridgeStep(e,t=`~/${e.path}`){return e.kind===`import`?`add the line \`${e.line}\` to ${t}`:`run \`ln -s ${K} ${t}\``}function userSpellings(e,t){let n=`${e.detect}/`;return e.relocatedBy!==void 0&&t.startsWith(n)?[`~/${t}`,`$${e.relocatedBy}/${t.slice(n.length)}`]:[`~/${t}`]}function userBridgeAt(e){for(let{user:t}of V){let n=t?.instructionBridge;if(t&&n&&userSpellings(t,n.path).includes(e))return n}}function stepAt(e,t){let n=userBridgeAt(e);return n===void 0?`add the bridge the harness page names for ${e}`:`${t&&n.kind!==`import`?`move what ${e} says into ${K} and remove it, then `:``}${globalBridgeStep(n,e)}`}const Ln=`hand the user this step, since nothing here writes outside the repository:`,Rn={"global-instructions-missing":{detail:`no user-scope instruction file at this path — the harness loads none of ${K}`,repair:({file:e})=>({command:``,instruction:`${Ln} ${stepAt(e,!1)}`}),skillRepair:()=>`hand the user the step the harness page names for that file; write nothing yourself`},"global-instructions-unbridged":{detail:`the file holds its own content and does not load ${K} — text placed there reaches no session of this harness`,repair:({file:e})=>({command:``,instruction:`${Ln} ${stepAt(e,!0)}`}),skillRepair:()=>`hand the user the step the harness page names for that file, keeping what the file says; write nothing yourself`},"global-instructions-overridden":{detail:`the harness reads this file in place of its own user-scope file, so whatever that file loads goes unread, and this one does not load ${K}`,repair:({file:e})=>({command:``,instruction:`${Ln} move what ${e} says into ${K} and remove it`}),skillRepair:()=>`hand the user the move of what that file says into the global file, and its removal; write nothing yourself`},"global-instructions-emptied":{detail:`the variable is set but empty, which this harness reads as the directory it starts in rather than as unset — its user-scope file is whichever one sits there, not the one in its own folder`,repair:({file:e})=>({command:``,instruction:`${Ln} unset ${e.slice(1)} where your shell sets it, or set it to the folder you meant`}),skillRepair:()=>`hand the user the step of unsetting that variable; write nothing yourself`}};repairsOf(Rn);const zn={"deprecated-harness":{detail:`a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all`,repair:({file:e})=>({command:``,instruction:`remove ${e} and enable the harness that replaced it — ${W} offers the correction`}),skillRepair:()=>`run ${W}`},"ignored-bridge":{detail:`a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently`,repair:({file:e})=>({command:``,instruction:`narrow or remove the .gitignore rule matching ${e} — ${W} offers the correction`}),skillRepair:()=>`run ${W}`},"unread-local-override":{detail:`no harness reads this filename, so everything in it is invisible to every agent`,repair:({file:e})=>({command:``,instruction:`move ${e} to CLAUDE.local.md, or consolidate it into AGENTS.md — ${W} offers the correction`}),skillRepair:()=>`run ${W}`},"unloadable-skill":{detail:`frontmatter that does not parse, or no description — either one makes a harness skip the skill outright`,repair:({file:e})=>({command:``,instruction:`quote the description in ${e}, or add one — ${W} offers the correction`}),skillRepair:()=>`run ${W}`}};repairsOf(zn);const Bn={"mcp-golden-unreadable":{detail:`the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it`,repair:e=>({command:``,instruction:`fix the TOML at ${locatorText(e)}`}),skillRepair:e=>`fix the TOML at ${locatorText(e)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`},"mcp-target-unreadable":{detail:`this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared`,repair:e=>({command:``,instruction:`fix the syntax of ${locatorText(e)}`}),skillRepair:e=>`fix the syntax of ${locatorText(e)} by hand`},"mcp-unprojected":{detail:`the golden set declares this server and the harness config does not carry it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${e}, or drop it from the golden set — ${W} offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to ${W}, which projects it from its golden entry with \`mcp project\` — or drop it from the golden set`},"mcp-undeclared":{detail:`the harness config carries this server and the golden set does not declare it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${G}, or drop it from ${e} — ${W} offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to ${W}, which imports it field by field with \`mcp reconcile\`, refusing any literal credential — or drop it from ${e.file}`},"mcp-diverged-target":{detail:`only the harness config changed since the two last agreed — the edit was made through the copy`,repair:e=>({command:``,instruction:`reconcile the value at ${locatorText(e)} back into ${G} — ${W} offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to ${W}, which imports the field into ${G} with \`mcp reconcile\` once approved`},"mcp-diverged-golden":{detail:`only the golden set changed since the two last agreed — the harness copy is stale`,repair:e=>({command:``,instruction:`update ${locatorText(e)} from the golden entry — ${W} offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to ${W}, which updates it from the golden entry with \`mcp project\``},"mcp-diverged-both":{detail:`both sides changed since they last agreed — merging either way would discard the other`,repair:e=>({command:``,instruction:`reconcile ${locatorText(e)} against ${G} by hand`}),skillRepair:e=>`reconcile ${locatorText(e)} against ${G} by hand — never merge a three-way conflict automatically`},"mcp-diverged-unknown":{detail:`the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server`,repair:e=>({command:``,instruction:`compare ${locatorText(e)} against ${G} by hand`}),skillRepair:e=>`compare ${locatorText(e)} against ${G} by hand`},"mcp-literal-secret":{detail:`a credential-bearing field holds a literal rather than a reference to an environment variable`,repair:e=>({command:``,instruction:`move the value at ${locatorText(e)} into an environment variable and reference it`}),skillRepair:e=>`move the value at ${locatorText(e)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`},"mcp-committed-secret":{detail:`a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it`,repair:e=>({command:``,instruction:`rotate the credential behind ${locatorText(e)}, then reference it from an environment variable`}),skillRepair:e=>`rotate the credential behind ${locatorText(e)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`}};repairsOf(Bn);const Vn={"nonstandard-instructions":{detail:`instruction content only one harness reads — AGENTS.md carries the same prose to all of them`,repair:({file:e})=>({command:``,instruction:`consolidate ${e} into AGENTS.md — ${U} offers the consolidation, and keeps the content reachable where this harness needs it`}),skillRepair:({file:e})=>`hand ${e} to ${U}, which consolidates it into AGENTS.md`},"nonstandard-rule":{detail:`a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental`,repair:({file:e})=>({command:``,instruction:`convert ${e} into a skill under .agents/skills where its guidance is not tied to the paths it names — ${U} offers the conversion; keep it where the path scoping is the point`}),skillRepair:({file:e})=>`hand ${e} to ${U} to convert into a skill, unless the path scoping is load-bearing`},"nonstandard-command":{detail:`a harness command file — a skill is the portable form, and this harness reads skills too`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills/<name>/SKILL.md — ${U} offers the move`}),skillRepair:({file:e})=>`hand ${e} to ${U}, which moves it to .agents/skills`},"nonstandard-skill":{detail:`a skill under a harness directory rather than the canonical one, where only that harness finds it`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills and project it back where the harness needs one — ${U} offers the move`}),skillRepair:({file:e})=>`hand ${e} to ${U}, which moves it to .agents/skills`},"nonstandard-subagent":{detail:`a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet`,repair:({file:e})=>({command:``,instruction:`leave ${e} where it is and record that it reaches one harness only — no portable form exists to convert it to`}),skillRepair:({file:e})=>`leave ${e} in place — no portable form exists yet, so this is work for a person rather than a skill`}};repairsOf(Vn);const Hn={...Fn,...In,...Rn,...zn,...Bn,...Vn};repairsOf(Hn);function repairFor(e){return{problem:e,...Hn[e]}}const Un=`.agents/skills`,Wn=`AGENTS.local.md`;function frontmatterFault(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return`unparseable`;let n=/^description:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();if(!n)return`no-description`;if(!/^(['"]).*\1$/.test(n)&&/:\s/.test(n))return`unparseable`}function diagnoseConfiguration({root:e,git:t,cli:r}){let i=[],add=(e,t)=>{let{detail:n,repair:a}=repairFor(t);i.push({path:e,problem:t,detail:n,repair:a({file:e},r)})},o=selectHarnesses(e,[]);for(let t of o){let r=t.project.skillsDirectory;t.deprecated&&r&&n(b(e,r))&&add(r,`deprecated-harness`)}for(let r of o){let i=r.project.skillsDirectory;i&&n(b(e,i))&&t.isIgnored(i)&&add(i,`ignored-bridge`)}n(b(e,Wn))&&add(Wn,`unread-local-override`);for(let t of filesUnder(b(e,Un)).filter(e=>e.endsWith(`SKILL.md`)))frontmatterFault(a(b(e,Un,t),`utf8`))&&add(`${Un}/${t}`,`unloadable-skill`);return i}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Gn=[`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`enabled`,`timeout`,`source`],Kn=new Set([`env`,`headers`]);function sameValue(e,t,n){if(Kn.has(e)&&isRecord(t)&&isRecord(n)){let e=Object.keys(t);return e.length===Object.keys(n).length&&e.every(e=>t[e]===n[e])}return JSON.stringify(t)===JSON.stringify(n)}function divergingFields(e,t,n=new Set(Gn)){return Gn.filter(r=>{if(!n.has(r))return!1;let i=e[r];if(i===void 0)return!1;if(Kn.has(r)&&isRecord(i)&&isRecord(t[r])){let e=t[r];return Object.keys(i).some(t=>i[t]!==e[t])}return!sameValue(r,i,t[r])})}function sameField(e,t,n){return sameValue(e,t?.[e],n?.[e])}function stringMap(e){if(!isRecord(e))return;let t=Object.entries(e).filter(([,e])=>typeof e==`string`);return t.length?Object.fromEntries(t):void 0}const qn=new Set([`stdio`,`http`,`sse`]);function transportOf(e){let t=e.type??e.transport;if(typeof t==`string`&&qn.has(t))return t;if(typeof e.url==`string`)return`http`;if(typeof e.command==`string`)return`stdio`}function serverFrom(e){let t=Array.isArray(e.args)&&e.args.every(e=>typeof e==`string`),n=transportOf(e),r=stringMap(e.env),i=stringMap(e.headers);return{...n?{transport:n}:{},...typeof e.command==`string`?{command:e.command}:{},...t?{args:e.args}:{},...r?{env:r}:{},...typeof e.url==`string`?{url:e.url}:{},...i?{headers:i}:{},...typeof e.description==`string`?{description:e.description}:{},...typeof e.enabled==`boolean`?{enabled:e.enabled}:{},...typeof e.timeout==`number`?{timeout:e.timeout}:{},...typeof e.source==`string`?{source:e.source}:{}}}const Jn=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/,Yn=/\$\{[^}]*\}|\$[A-Za-z_]/;var Refusal=class extends Error{field;reason;constructor(e,t){super(t),this.field=e,this.reason=t}};function refuse(e,t){throw new Refusal(e,t)}function rendering(e){try{return{kind:`entry`,entry:e()}}catch(e){if(!(e instanceof Refusal))throw e;return{kind:`refused`,field:e.field,reason:e.reason}}}function assertRunnable(e){(e.transport===`stdio`?!e.command:!e.url)&&refuse(e.transport===`stdio`?`command`:`url`,`the golden set leaves it unset and the target requires it`)}function defined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function mapValues(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}function noReferenceIn(e,t,n){for(let r of t){let t=e[r];(Array.isArray(t)?t:[t]).some(e=>typeof e==`string`&&Yn.test(e))&&refuse(r,`${n} documents no reference expansion here`)}}const Xn={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`timeout`]),read:serverFrom,write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport,command:e.command,args:e.args,env:e.env,url:e.url,headers:e.headers,description:e.description,timeout:e.timeout})))};function toCursor(e,t){return e.replace(/\$\{([^}]*)\}|\$[A-Za-z_]/g,(e,n)=>((n===void 0||!Jn.test(e))&&refuse(t,`Cursor expands only a plain variable reference, with no default`),`\${env:${n}}`))}function fromCursor(e){return e.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>`\${${t}}`)}function fromCursorEntry(e){let strings=e=>typeof e==`string`?fromCursor(e):e,map=e=>isRecord(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,strings(t)])):e;return{...e,command:strings(e.command),args:Array.isArray(e.args)?e.args.map(strings):e.args,env:map(e.env),url:strings(e.url),headers:map(e.headers)}}const Zn={fields:new Set([`command`,`args`,`env`,`url`,`headers`]),read:e=>serverFrom(fromCursorEntry(e)),write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport===`stdio`?`stdio`:void 0,command:e.command&&toCursor(e.command,`command`),args:e.args?.map(e=>toCursor(e,`args`)),env:mapValues(e.env,e=>toCursor(e,`env`)),url:e.url&&toCursor(e.url,`url`),headers:mapValues(e.headers,e=>toCursor(e,`headers`))})))},Qn=/^Bearer \$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function codexEnv(e){let t={},n=[];for(let[r,i]of Object.entries(e??{}))Jn.exec(i)?.[1]===r?n.push(r):Yn.test(i)?refuse(`env`,`Codex passes a variable through only under its own name`):t[r]=i;return defined({env:Object.keys(t).length?t:void 0,env_vars:n.length?n:void 0})}function codexHeaders(e){let t={},n={},r;for(let[i,a]of Object.entries(e??{})){let e=Jn.exec(a)?.[1],o=Qn.exec(a)?.[1];o&&i===`Authorization`?r=o:e?n[i]=e:Yn.test(a)?refuse(`headers`,`Codex fills a header only from a whole variable reference, or Bearer and one`):t[i]=a}return defined({http_headers:Object.keys(t).length?t:void 0,env_http_headers:Object.keys(n).length?n:void 0,bearer_token_env_var:r})}function stringRecord(e){return isRecord(e)?Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`)):{}}function fromCodex(e){let t=Array.isArray(e.env_vars)?e.env_vars.filter(e=>typeof e==`string`):[],n={...stringRecord(e.env),...Object.fromEntries(t.map(e=>[e,`\${${e}}`]))},r=e.bearer_token_env_var,i={...stringRecord(e.http_headers),...Object.fromEntries(Object.entries(stringRecord(e.env_http_headers)).map(([e,t])=>[e,`\${${t}}`])),...typeof r==`string`?{Authorization:`Bearer \${${r}}`}:{}},a=e.tool_timeout_sec;return{command:e.command,args:e.args,env:n,url:e.url,headers:i,enabled:e.enabled,timeout:typeof a==`number`?Math.round(a*1e3):void 0}}const $n={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`enabled`,`timeout`]),defaults:{timeout:6e4},read:e=>serverFrom(fromCodex(e)),write:e=>rendering(()=>(e.transport===`sse`&&refuse(`transport`,`Codex supports no SSE transport`),assertRunnable(e),noReferenceIn(e,[`command`,`args`,`url`],`Codex`),defined({command:e.command,args:e.args,...codexEnv(e.env),url:e.url,...codexHeaders(e.headers),enabled:e.enabled,tool_timeout_sec:e.timeout===void 0?void 0:e.timeout/1e3})))};function fromGemini(e){let{httpUrl:t,url:n,...r}=e;return typeof t==`string`?{...r,type:`http`,url:t}:typeof n==`string`?{...r,type:`sse`,url:n}:r}const q={"claude-code":Xn,cursor:Zn,codex:$n,"gemini-cli":{fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`timeout`]),defaults:{timeout:6e5},read:e=>serverFrom(fromGemini(e)),write:e=>rendering(()=>(assertRunnable(e),defined({command:e.command,args:e.args,env:e.env,url:e.transport===`sse`?e.url:void 0,httpUrl:e.transport===`http`?e.url:void 0,headers:e.headers,timeout:e.timeout})))}};function stripJsonComments(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(r){t+=a,i?i=!1:a===`\\`?i=!0:a===`"`&&(r=!1),n+=1;continue}if(a===`"`){r=!0,t+=a,n+=1;continue}if(a===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
|
|
224
162
|
`;)n+=1;continue}if(a===`/`&&e[n+1]===`*`){for(n+=2;n<e.length&&(e[n]!==`*`||e[n+1]!==`/`);)n+=1;n+=2;continue}t+=a,n+=1}return t}function parseJsonWithComments(e){try{return JSON.parse(stripJsonComments(e))}catch{return}}
|
|
225
163
|
/*!
|
|
226
164
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -249,7 +187,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
249
187
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
250
188
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
251
189
|
*/
|
|
252
|
-
let
|
|
190
|
+
let er=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var tr=class TomlDate extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(er);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(e,t=`Z`){let n=new TomlDate(e);return n.#n=t,n}static wrapAsLocalDateTime(e){let t=new TomlDate(e);return t.#n=null,t}static wrapAsLocalDate(e){let t=new TomlDate(e);return t.#t=!1,t.#n=null,t}static wrapAsLocalTime(e){let t=new TomlDate(e);return t.#e=!1,t.#n=null,t}};
|
|
253
191
|
/*!
|
|
254
192
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
255
193
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -336,8 +274,8 @@ function indexOfNewline(e,t=0){let n=e.indexOf(`
|
|
|
336
274
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
337
275
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
338
276
|
*/
|
|
339
|
-
let
|
|
340
|
-
`;else if(n===102)o+=`\f`;else if(n===114)o+=`\r`;else if(n===101)o+=`\x1B`;else if(n===34)o+=`"`;else if(n===92)o+=`\\`;else throw new TomlError(`unrecognized escape sequence`,{toml:e.s,ptr:e.p});s=e.p+1,c=0}}else if(n!==32&&n!==9){if(c===2)throw new TomlError(`invalid escape: only line-ending whitespace may be escaped`,{toml:e.s,ptr:s});c=+(!i&&n===92),s=e.p}throw new TomlError(`unfinished string`,{toml:e.s,ptr:t})}function sliceAndTrimEndOf(e,t,n){let r=e.s.slice(t,n),i=r.indexOf(`#`);return i>0&&(skipComment({s:r,p:i,d:0}),r=r.slice(0,i)),r.trimEnd()}function parseValue(e,t,n){let r=e.p,i={toml:e.s,ptr:r};skipUntil(e,44,n);let a=sliceAndTrimEndOf(e,r,e.p);if(!a)throw new TomlError(`incomplete declaration: value expected`,i);if(a===`-inf`)return-1/0;if(a===`inf`||a===`+inf`)return 1/0;if(a===`nan`||a===`+nan`||a===`-nan`)return NaN;if(a===`-0`)return t?0n:0;let o=
|
|
277
|
+
let nr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,rr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ir=/^[+-]?0[0-9_]/;function parseString(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)throw new TomlError(`control characters are not allowed in strings`,{toml:e.s,ptr:e.p});else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r))return a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),c||(o+=e.s.slice(s,e.p)),e.p+=a?3:1,o;else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1){if(n===120||n===117||n===85){let t=0,r=n===120?2:n===117?4:8;for(let n=0;n<r;n++,e.p++){let n=e.s.charCodeAt(e.p+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new TomlError(`invalid non-hex character in unicode escape`,{toml:e.s,ptr:e.p+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new TomlError(`invalid unicode escape`,{toml:e.s,ptr:e.p});o+=String.fromCodePoint(t),s=e.p+1,c=0}else if(n===32||n===9)c=2;else{if(n===98)o+=`\b`;else if(n===116)o+=` `;else if(n===110)o+=`
|
|
278
|
+
`;else if(n===102)o+=`\f`;else if(n===114)o+=`\r`;else if(n===101)o+=`\x1B`;else if(n===34)o+=`"`;else if(n===92)o+=`\\`;else throw new TomlError(`unrecognized escape sequence`,{toml:e.s,ptr:e.p});s=e.p+1,c=0}}else if(n!==32&&n!==9){if(c===2)throw new TomlError(`invalid escape: only line-ending whitespace may be escaped`,{toml:e.s,ptr:s});c=+(!i&&n===92),s=e.p}throw new TomlError(`unfinished string`,{toml:e.s,ptr:t})}function sliceAndTrimEndOf(e,t,n){let r=e.s.slice(t,n),i=r.indexOf(`#`);return i>0&&(skipComment({s:r,p:i,d:0}),r=r.slice(0,i)),r.trimEnd()}function parseValue(e,t,n){let r=e.p,i={toml:e.s,ptr:r};skipUntil(e,44,n);let a=sliceAndTrimEndOf(e,r,e.p);if(!a)throw new TomlError(`incomplete declaration: value expected`,i);if(a===`-inf`)return-1/0;if(a===`inf`||a===`+inf`)return 1/0;if(a===`nan`||a===`+nan`||a===`-nan`)return NaN;if(a===`-0`)return t?0n:0;let o=nr.test(a);if(o||rr.test(a)){if(ir.test(a))throw new TomlError(`leading zeroes are not allowed`,i);a=a.replace(/_/g,``);let e=+a;if(isNaN(e))throw new TomlError(`invalid number`,i);if(o){if((o=!Number.isSafeInteger(e))&&!t)throw new TomlError(`integer value cannot be represented losslessly`,i);(o||t===!0)&&(e=BigInt(a))}return e}let s=new tr(a);if(!s.isValid())throw new TomlError(`invalid value`,i);return s}
|
|
341
279
|
/*!
|
|
342
280
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
343
281
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -393,7 +331,7 @@ function extractValue(e,t,n){let r=e.p,i=e.s.charCodeAt(r);if(i===91||i===123){i
|
|
|
393
331
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
394
332
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
395
333
|
*/
|
|
396
|
-
let
|
|
334
|
+
let ar=/^[a-zA-Z0-9-_]+[ \t]*$/;function parseKey(e,t=`=`){let n=e.p,r=n-1,i=[],a=e.s.indexOf(t,n);if(a<0)throw new TomlError(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});do{let o=e.s.charCodeAt(e.p=++r);if(o!==32&&o!==9){if(o===34||o===39){if(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2))throw new TomlError(`multiline strings are not allowed in keys`,{toml:e.s,ptr:e.p});let s=parseString(e);r=e.s.indexOf(`.`,e.p);let c=e.s.slice(e.p,r<0||r>a?a:r),l=indexOfNewline(c);if(l>-1)throw new TomlError(`newlines are not allowed in keys`,{toml:e.s,ptr:l});if(c.trimStart())throw new TomlError(`found extra tokens after the string part`,{toml:e.s,ptr:e.p});if(a<e.p&&(a=e.s.indexOf(t,e.p),a<0))throw new TomlError(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});i.push(s)}else{r=e.s.indexOf(`.`,e.p);let t=e.s.slice(e.p,r<0||r>a?a:r);if(!ar.test(t))throw new TomlError(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e.s,ptr:e.p});i.push(t.trimEnd())}}}while(r+1&&r<a);return e.p=a+1,skipVoid(e,!0,!0),i}function parseInlineTable(e,t){let n={},r=new Set,i;for(e.p++;e.p<e.s.length;){if(skipVoid(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let a,o=n,s=!1,c=e.p,l=parseKey(e);for(let t=0;t<l.length;t++){if(t&&(o=s?o[a]:o[a]={}),a=l[t],(s=Object.hasOwn(o,a))&&(typeof o[a]!=`object`||r.has(o[a])))throw new TomlError(`trying to redefine an already defined value`,{toml:e.s,ptr:c});!s&&a===`__proto__`&&Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0})}if(s)throw new TomlError(`trying to redefine an already defined value`,{toml:e.s,ptr:e.p});let u=extractValue(e,125,t);if(r.add(o[a]=u),skipVoid(e),(i=e.s.charCodeAt(e.p++))===125)return n;if(i!==44)throw new TomlError(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new TomlError(`unfinished table encountered`,{toml:e.s,ptr:e.p})}function parseArray(e,t){let n=[],r;for(e.p++;e.p<e.s.length;){if(skipVoid(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(extractValue(e,93,t)),skipVoid(e),(r=e.s.charCodeAt(e.p++))===93)return n;if(r!==44)throw new TomlError(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new TomlError(`unfinished array encountered`,{toml:e.s,ptr:e.p})}
|
|
397
335
|
/*!
|
|
398
336
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
399
337
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -421,7 +359,7 @@ let Hs=/^[a-zA-Z0-9-_]+[ \t]*$/;function parseKey(e,t=`=`){let n=e.p,r=n-1,i=[],
|
|
|
421
359
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
422
360
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
423
361
|
*/
|
|
424
|
-
function peekTable(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&(r!==1||c.t!==3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function parse
|
|
362
|
+
function peekTable(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&(r!==1||c.t!==3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function parse(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={s:e,p:0,d:t},i={},a={},o,s=i,c=a;for(skipVoid(r);r.p<e.length;){if(e.charCodeAt(r.p)===91){let t=e.charCodeAt(++r.p)===91;o=r.p+=+t;let n=parseKey(r,`]`);if(t){if(e.charCodeAt(r.p-1)!==93)throw new TomlError(`expected end of table declaration`,{toml:e,ptr:r.p-1});r.p++}let l=peekTable(n,i,a,t?2:1);if(!l)throw new TomlError(`trying to redefine an already defined table or value`,{toml:e,ptr:o});c=l[2],s=l[1]}else{o=r.p;let t=peekTable(parseKey(r),s,c,0);if(!t)throw new TomlError(`trying to redefine an already defined table or value`,{toml:e,ptr:o});t[1][t[0]]=extractValue(r,void 0,n)}if(skipVoid(r,!0),r.p<e.length&&(o=e.charCodeAt(r.p))!==10&&o!==13)throw new TomlError(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:r.p});skipVoid(r)}return i}
|
|
425
363
|
/*!
|
|
426
364
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
427
365
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -449,15 +387,14 @@ function peekTable(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(
|
|
|
449
387
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
450
388
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
451
389
|
*/
|
|
452
|
-
let
|
|
453
|
-
`}[[${t}]]\n`,i+=stringifyTable(0,e[a],t,n,r);return i}function stringifyTable(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=extendedTypeOf(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=
|
|
390
|
+
let or=/^[a-z0-9-_]+$/i;function extendedTypeOf(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e?.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal&&typeof e?.since==`function`&&(e instanceof Temporal.Instant||e instanceof Temporal.PlainDate||e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainTime||e instanceof Temporal.ZonedDateTime))return`temporal`}return t}function isArrayOfTables(e){for(let t=0;t<e.length;t++)if(extendedTypeOf(e[t])!==`object`)return!1;return e.length!=0}function formatString(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function stringifyTemporal(e){return e.toString({calendarName:`never`,timeZoneName:`never`})}function stringifyValue(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:return e.toString();case`string`:return formatString(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return stringifyInlineTable(e,n,r);case`array`:return stringifyArray(e,n,r);case`temporal`:return stringifyTemporal(e)}}function stringifyInlineTable(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=or.test(o)?o:formatString(o),i+=` = `,i+=stringifyValue(e[o],extendedTypeOf(e[o]),t-1,n)}return i+` }`}function stringifyArray(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=stringifyValue(e[i],extendedTypeOf(e[i]),t-1,n)}return r+` ]`}function stringifyArrayTable(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
391
|
+
`}[[${t}]]\n`,i+=stringifyTable(0,e[a],t,n,r);return i}function stringifyTable(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=extendedTypeOf(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=or.test(c)?c:formatString(c);if(e===`array`&&isArrayOfTables(t[c]))o+=(o&&`
|
|
454
392
|
`)+stringifyArrayTable(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
455
393
|
`)+stringifyTable(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=stringifyValue(t[c],e,r,i),a+=`
|
|
456
394
|
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function stringify(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(extendedTypeOf(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=stringifyTable(0,e,``,t,n);return r[r.length-1]===`
|
|
457
395
|
`?r:r+`
|
|
458
|
-
`}const
|
|
459
|
-
`)
|
|
460
|
-
`)}function collapseHome(e,t){return e&&t.startsWith(e+w)?`~${t.slice(e.length)}`:t}function readTemplate(e){if(e===void 0)return parseTemplate(`---
|
|
396
|
+
`}const J=`.agents/buddy-agent-harness/mcp.toml`;function mcpTargets(e){let t=new Set;return selectHarnesses(e,[]).map(e=>e.project.mcpConfig).filter(e=>e!==void 0).filter(e=>!t.has(e.path)&&t.add(e.path))}function serversUnder(e,t,n=serverFrom){let r=isRecord(e)?e[t]:void 0;return isRecord(r)?new Map(Object.entries(r).filter(([,e])=>isRecord(e)).map(([e,t])=>[e,n(t)])):new Map}function positionOf(e){if(!isRecord(e))return;let{line:t,column:n}=e;return typeof t==`number`&&typeof n==`number`?{line:t,column:n}:void 0}function parseGoldenSet(e){if(e===void 0)return{kind:`absent`};try{return{kind:`servers`,servers:serversUnder(parse(e),`servers`)}}catch(e){return{kind:`unreadable`,position:positionOf(e)}}}function parseTarget(e,t){if(t===void 0)return{kind:`absent`};if(e.format===`toml`)try{return{kind:`servers`,servers:serversUnder(parse(t),e.key,q[e.dialect].read)}}catch{return{kind:`unreadable`}}let n=parseJsonWithComments(t);return n===void 0?{kind:`unreadable`}:{kind:`servers`,servers:serversUnder(n,e.key,q[e.dialect].read)}}const Y=`.agents/buddy-agent-harness/mcp.projected.json`;function parseProjectionRecord(e){let t=e===void 0?void 0:parseJsonWithComments(e),n=isRecord(t)?t.targets:void 0;return isRecord(n)?new Map(Object.entries(n).filter(([,e])=>isRecord(e)).map(([e,t])=>[e,new Map(Object.entries(t).filter(([,e])=>isRecord(e)).map(([e,t])=>[e,t]))])):new Map}function formatProjectionRecord(e){let t=Object.fromEntries([...e].map(([e,t])=>[e,Object.fromEntries(t)]));return`${JSON.stringify({targets:t},null,2)}\n`}var McpBaseline=class{options;constructor(e){this.options=e}parsed=new Map;walked=new Map;directionOf(e,t,n,r,i){let a=this.baseFor(e,t,n);if(a===void 0)return`unknown`;let o=!sameField(n,r,a),s=!sameField(n,i,a);return o&&s?`both`:s?`target`:`golden`}baseFor(e,t,n){return this.options.record.get(e.path)?.get(t)||this.lastAgreed(e,t,n)}lastAgreed(e,t,n){for(let r of this.commitsTouching(e)){let i=this.parseAt(r,J,parseGoldenSet),a=this.parseAt(r,e.path,t=>parseTarget(e,t));if(i.kind!==`servers`||a.kind!==`servers`)continue;let o=i.servers.get(t),s=a.servers.get(t);if(o&&s&&sameField(n,o,s))return o}}commitsTouching(e){let t=this.walked.get(e.path);if(t)return t;let n=this.options.git.commitsTouching([J,e.path]);return this.walked.set(e.path,n),n}parseAt(e,t,n){let r=`${e}\u0000${t}`,i=this.parsed.get(r);if(i)return i;let a=n(this.options.git.contentAt(e,t));return this.parsed.set(r,a),a}};const sr=/token|secret|password|passwd|credential/i,cr=new Set([`key`,`apikey`,`auth`,`authorization`,`bearer`]);function segmentsOf(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}const lr=/\$\{[^}]+\}|\$[A-Za-z_][A-Za-z0-9_]*/;function holdsLiteral(e){return!lr.test(e)}function credentialKey(e){return sr.test(e)||segmentsOf(e).some(e=>cr.has(e))}function urlHoldsCredential(e){let t;try{t=new URL(e)}catch{return!1}if(t.password)return!0;for(let[e,n]of t.searchParams)if(credentialKey(e)&&holdsLiteral(n))return!0;return!1}function literalsIn$1(e,t){return Object.entries(t??{}).filter(([e,t])=>credentialKey(e)&&holdsLiteral(t)).map(([t])=>`${e}.${t}`)}__name(literalsIn$1,`literalsIn`);function credentialFields(e){return[...literalsIn$1(`env`,e.env),...literalsIn$1(`headers`,e.headers),...e.url&&urlHoldsCredential(e.url)?[`url`]:[]]}function nonSecretArgs(e){return(e??[]).filter(e=>{let t=e.indexOf(`=`);return t===-1||!(credentialKey(e.slice(0,t))&&holdsLiteral(e.slice(t+1)))})}function read$2(e,t){let r=b(e,t);return n(r)?a(r,`utf8`):void 0}__name(read$2,`read`);const ur={target:`mcp-diverged-target`,golden:`mcp-diverged-golden`,both:`mcp-diverged-both`,unknown:`mcp-diverged-unknown`};function diagnoseMcp({root:e,git:t,cli:n}){let r=[],add=(e,t)=>{let{detail:i,repair:a}=repairFor(t);r.push({path:locatorText(e),problem:t,detail:i,repair:a(e,n)})},reportSecrets=(e,n)=>{let r=t.trackingOf(e)!==`untracked`;for(let[t,i]of n)for(let n of credentialFields(i))add({file:e,server:t,field:n},r?`mcp-committed-secret`:`mcp-literal-secret`)},i=new Map,a=[];for(let t of mcpTargets(e)){let n=parseTarget(t,read$2(e,t.path));if(n.kind===`unreadable`){add({file:t.path},`mcp-target-unreadable`);continue}n.kind!==`absent`&&(reportSecrets(t.path,n.servers),i.set(t.path,n.servers),a.push(t))}let o=parseGoldenSet(read$2(e,J));if(o.kind===`unreadable`)return add({file:J,position:o.position},`mcp-golden-unreadable`),r;if(o.kind===`absent`)return r;reportSecrets(J,o.servers);let s=new McpBaseline({git:t,record:parseProjectionRecord(read$2(e,Y))});for(let e of a){let t=i.get(e.path);for(let[n,r]of o.servers){let i=t.get(n);if(!i){add({file:e.path,server:n},`mcp-unprojected`);continue}for(let t of divergingFields(r,i,q[e.dialect].fields))add({file:e.path,server:n,field:t},ur[s.directionOf(e,n,t,r,i)])}for(let n of t.keys())o.servers.has(n)||add({file:e.path,server:n},`mcp-undeclared`)}return r}const dr={instructions:`nonstandard-instructions`,rule:`nonstandard-rule`,command:`nonstandard-command`,skill:`nonstandard-skill`,subagent:`nonstandard-subagent`};function scopedByGlobs(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return!1;let n=/^globs:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();return n!==void 0&&n.length>0&&n!==`[]`}function skillFiles(e){return filesUnder(e).filter(e=>e.endsWith(`SKILL.md`))}function authoredHere(e){try{return!r(e).isSymbolicLink()}catch{return!1}}function artifactFiles(e,t){let n=b(e,t.path);return authoredHere(n)?t.shape===`file`?[t.path]:(t.kind===`skill`?skillFiles(n):filesUnder(n)).map(e=>x.join(t.path,e)):[]}function diagnoseNonstandard({root:e,cli:t}){let n=[];for(let r of V)for(let i of r.project.nonstandard??[])for(let r of artifactFiles(e,i)){let o=i.kind===`rule`&&r.endsWith(`.mdc`)&&!scopedByGlobs(a(b(e,r),`utf8`))?`instructions`:i.kind,s=dr[o],{detail:c,repair:l}=repairFor(s);n.push({path:r,problem:s,detail:c,repair:l({file:r},t)})}return n.sort((e,t)=>e.path.localeCompare(t.path))}function collapseHome(e,t){return e&&t.startsWith(e+w)?`~${t.slice(e.length)}`:t}var fr=un();function implementationTemplate(e){let t=e.sections.map(e=>`## ${e}\n\n**Unsupported.** Replace this line with the section, or say in one sentence why it is not supported.\n`);return parseTemplate(`---\ndescription: What this ${e.id} implementation covers, and when an agent should read it.\nimplements: ${e.id}@${e.version}\n---\n\n${t.join(`
|
|
397
|
+
`)}`,`the ${e.id} interface`)}function readTemplate(e){if(e===void 0)return parseTemplate(`---
|
|
461
398
|
description: What this reference covers, and when an agent should read it.
|
|
462
399
|
tags: [topic]
|
|
463
400
|
---
|
|
@@ -465,24 +402,29 @@ tags: [topic]
|
|
|
465
402
|
## Overview
|
|
466
403
|
|
|
467
404
|
Write the guidance here. Give each topic its own top-level \`##\` section.
|
|
468
|
-
`,`the default template`);let t;try{t=
|
|
469
|
-
`)+1,r=t[0][n-2]===`\r`?`\r
|
|
470
|
-
|
|
471
|
-
`,i=n+t[1].length;return`${e.slice(0,i)}${r}merge: merge-sections${e.slice(i)}`}function templateWarnings({metadata:e,body:t}){let n=titleHeadings(t).map(e=>`"${e.trim()}" is a heading with one hash; merge-sections matches by heading path, so an override would replace or duplicate the whole document. Use top-level ## sections.`);return(typeof e.description!=`string`||!e.description.trim())&&n.push("the reference has no `description` in its frontmatter; `list` and `search` show it blank."),n}const Qs={description:`Directory the project tier is read from, and each folder above it up to the repository root. Defaults to the current directory.`,type:J(q())};function layerSource(e){return(t,n)=>referenceLayers$1({root:t.root??process.cwd(),home:n,platform:process.platform,programData:process.env.ProgramData,env:process.env,plugin:e})}function fail(e,t){return process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),k.error}function traceOf(e,t){return e.trace.map(({description:e,...n})=>({...n,path:collapseHome(t,n.path)}))}function showEntry(e,t,n,r){let i={name:e.name,status:e.status,warnings:[]};return e.status===`found`&&Object.assign(i,{tier:e.tier,plugin:e.plugin,path:collapseHome(t,e.path),merge:e.merge,metadata:e.metadata,content:e.content,layers:e.layers.map(e=>({...e,path:collapseHome(t,e.path)}))}),e.status===`missing`&&(i.suggestions=n),e.status===`ambiguous`&&(i.plugins=e.plugins),i.warnings=e.warnings,r&&(i.trace=traceOf(e,t)),i}function missReason(e){if(e.status===`ambiguous`)return`"${e.name}" is held by more than one plugin; ask for one of ${e.plugins.join(`, `)}.`;let t=e.suggestions?.length?` Did you mean: ${e.suggestions.join(`, `)}?`:``;return`no reference named "${e.name}" in any tier.${t}`}function writeShowText(e){if(e.length===1){let[t]=e;t.content!==void 0&&writeDocument(t.content);return}writeDocument(e.map(e=>e.content===void 0?`<reference name="${e.name}" status="${e.status}" />`:`<reference name="${e.name}" tier="${e.tier}">\n${e.content}</reference>`).join(`
|
|
405
|
+
`,`the default template`);let t;try{t=a(e,`utf8`)}catch(t){throw Error(`cannot read the template ${e}: ${t.message}`)}return parseTemplate(t,`the template ${e}`)}function parseTemplate(e,t){let n=!0,{metadata:r,body:i}=parseDocument(e,()=>{n=!1});if(!n)throw Error(`${t} has frontmatter that is not a YAML mapping.`);return{content:e,metadata:r,body:i}}function titleOf({body:e}){let t=parseSections(e,()=>{}),[n]=t.children;return t.children.length===1&&n?.children.length?n.heading.trim():void 0}function hasDescription({metadata:e}){return typeof e.description==`string`&&e.description.trim().length>0}function editFrontmatter(e,t){let n=hn.exec(e),r=n?e.slice(n[0].length):e,i=(0,fr.parseDocument)(n?n[1]:``);for(let[e,n]of Object.entries(t))if(n===void 0)i.delete(e);else{let t=i.createNode(n,{flow:Array.isArray(n)});i.set(e,t)}if(!i.contents?.items?.length)return r.replace(/^(?:[ \t]*\r?\n)+/,``);let a=!n&&r.trim()?`
|
|
406
|
+
`:``;return`---\n${i.toString({lineWidth:0,flowCollectionPadding:!1})}---\n${a}${r}`}var ReferenceWriteError=class extends Error{code;usage;constructor(e,t,n=!1){super(t),this.code=e,this.usage=n}};function bareName(e){let t=parseReferenceName(e);if(t.invalid)throw new ReferenceWriteError(`reference-invalid`,t.invalid);if(t.plugin!==void 0)throw new ReferenceWriteError(`reference-qualified`,`a contribution is written under the bare name, which every tier resolves; ask for "${t.name}".`);return t}function insideRepository(e,t){let n=canonical(repositoryRoot(t)??C(t)),r=canonical(e);return r!==n&&!r.startsWith(n+w)?!1:!r.slice(n.length).split(w).includes(`node_modules`)}function writeTarget$1(e,{root:t,home:n,scope:r,plugin:i,default:a}){if([r,i,a].filter(e=>e!==void 0).length>1)throw new ReferenceWriteError(`options-conflict`,`pass one of --scope, --plugin, and --default.`,!0);if(i!==void 0){let n=C(i);if(!pluginManifestName(n))throw new ReferenceWriteError(`folder-invalid`,`${n} holds no plugin manifest, so it is not a plugin folder.`);if(!insideRepository(n,t))throw new ReferenceWriteError(`folder-invalid`,`${n} is outside the repository, such as an installed copy; write to the plugin's source instead.`);let r=b(n,`references`);return{scope:`plugin`,dir:r,path:b(r,`${e.name}.md`)}}if(a!==void 0){let n=C(a);if(skillName(n)===void 0)throw new ReferenceWriteError(`folder-invalid`,`${n} holds no SKILL.md, so it is not a skill folder.`);if(!insideRepository(n,t))throw new ReferenceWriteError(`folder-invalid`,`${n} is outside the repository, such as an installed copy; write to the skill's source instead.`);let r=b(n,`references`);return{scope:`default`,dir:r,path:b(r,`${e.name}.default.md`)}}if(r!==void 0&&r!==`project`&&r!==`user`)throw new ReferenceWriteError(`options-invalid`,`--scope is project or user.`,!0);let o=r===`user`?userReferencesDir(n):projectReferencesDir(C(t));return{scope:r===`user`?`user`:`project`,dir:o,path:b(o,`${e.name}.md`)}}__name(writeTarget$1,`writeTarget`);function tryRead(e){try{return a(e,`utf8`)}catch{return}}function describeAnswer(e,t=e=>e){if(e.status===`found`){let n=e.trace.contributions.at(-1),r=n?n.tier===`plugin`?`plugin ${n.plugin}`:n.tier==="default"?`the default of ${n.skill}`:`the ${n.tier} file ${t(n.path)}`:`nothing`,i=e.trace.stack.length?`, on the stack ${e.trace.stack.join(` → `)}`:``;return`"${e.name}" is answered by ${r}${i}.`}return e.status===`ambiguous`?`"${e.name}" is ambiguous: ${e.message}; the options are ${(e.options??[]).join(`, `)}.`:`"${e.name}" is ${e.status}: ${e.message}.`}function interfaceFor(e,t,n,r){let i=parseReferenceName(e);if(i.invalid||i.plugin!==void 0)throw new ReferenceWriteError(`interface-invalid`,`"${e}" is not an interface id.`);let a=interfaceLookup(n,r)(e);if(!a.value)throw new ReferenceWriteError(`interface-invalid`,a.failure?.message??`no interface ${e}`);if(!fitsName(a.value,t))throw new ReferenceWriteError(`interface-invalid`,`an implementation of ${e} is named ${a.value.cardinality===`one`?e:`${e}.<key>`}, not "${t}".`);return a.value}function hiddenBy(e,t,n){let r=e.trace.layers,i=r.findIndex(e=>e.path===t||e.path===n);if(i===-1)return;let a=r[i],tiered=e=>e===`managed`||e===`project`||e===`user`,o=a&&!tiered(a.tier)?e.trace.stack.indexOf(a.tier==="default"?`default`:a.plugin??``):-1,s=r.filter((t,n)=>{if(!t.file||t.outcome!==`used`)return!1;if(a&&tiered(a.tier))return n<i&&tiered(t.tier);if(tiered(t.tier))return!0;let r=e.trace.stack.indexOf(t.tier==="default"?`default`:t.plugin??``);return o!==-1&&r>o}).find(e=>e.operation===`remove`||e.operation===`replace`&&!e.empty);return s?`${s.tier}${s.plugin?` ${s.plugin}`:``} ${s.path} (${s.operation})`:void 0}function selectionKeys(e,t,n){let r=parseDocument(e,()=>{}).metadata,i={};for(let[e,n]of Object.entries(t.metadata))e!==`merge`&&!(e in r)&&(i[e]=n);return i.merge=n,i}function withBody(e,t){let n=t.replace(/^(?:[ \t]*\r?\n)+/,``);return n?`${e.replace(/\s*$/,``)}\n\n${n}`:e}function createContribution(e,t,n={}){let r=bareName(t.name),a=writeTarget$1(r,t);if(t.merge!==void 0&&!isMergeOperation(t.merge))throw new ReferenceWriteError(`options-invalid`,`--merge is replace, patch, combine, or remove; got "${t.merge}".`,!0);let o=t.merge;if(t.template!==void 0&&t.implements!==void 0)throw new ReferenceWriteError(`options-conflict`,`pass --template or --implements, not both.`);if(o===`remove`&&t.template!==void 0)throw new ReferenceWriteError(`options-conflict`,`--merge remove writes no body, so it takes no --template.`);if(o!==void 0&&a.scope==="default")throw new ReferenceWriteError(`options-conflict`,`a default is written with no merge; drop --merge.`);let s=tryRead(a.path);if(s!==void 0&&hasBody(parseDocument(s,()=>{}).body))throw new ReferenceWriteError(`file-exists`,`${(n.display??(e=>e))(a.path)} already holds "${r.name}"; change it with the reference skill's Update mode.`);let c=t.implements===void 0?o===`remove`?{content:``,metadata:{},body:``}:readTemplate(t.template===void 0?void 0:C(t.template)):implementationTemplate(interfaceFor(t.implements,r.name,e,n)),l=titleOf(c);if(l)throw new ReferenceWriteError(`template-title`,`the template's top level is the single heading "${l}" holding the others; patch matches by heading path, so make its sections top-level.`);let u=resolveReference(r,e,n),d=hiddenBy(u,a.dir,a.path);if(d)throw new ReferenceWriteError(`hidden`,`${d} applies above it, so nothing would read the new file; change that contribution instead.`);let f=a.scope==="default"?void 0:t.implements===void 0?o??(isMergeOperation(c.metadata.merge)?c.metadata.merge:void 0)??(a.scope===`plugin`?void 0:`patch`):`replace`,m=s===void 0?editFrontmatter(c.content,{merge:f}):withBody(editFrontmatter(s,selectionKeys(s,c,f)),c.body),h=hasDescription(parseDocument(m,()=>{}))?[]:["it has no `description` in its frontmatter, so `list` and `search` show it blank"],g={name:r.name,scope:a.scope,path:a.path,content:m,dryRun:!!t.dryRun,hints:h};return g.dryRun?g:(i(a.dir,{recursive:!0}),p(a.path,m,s===void 0?{flag:`wx`}:{}),u.trace.layers.some(e=>e.path===a.dir||e.path===a.path)&&(g.after=resolveReference(r,e,n)),g)}function selectContribution(e,t,n={}){let r=bareName(t.name),a=writeTarget$1(r,{root:t.root,home:t.home,scope:t.scope}),o=a.scope,s=tryRead(a.path);if(t.clear){if(t.options.length)throw new ReferenceWriteError(`options-conflict`,`--clear takes no option.`,!0);if(!(s!==void 0&&readExtends(parseDocument(s,()=>{}).metadata.extends,()=>{})))throw new ReferenceWriteError(`no-selection`,`the ${o} tier holds no selection of "${r.name}". ${describeAnswer(resolveReference(r,e,n),n.display)}`);let i=editFrontmatter(s,{extends:void 0}),c=!i.trim();return c?l(a.path):p(a.path,i),{name:r.name,scope:o,path:a.path,extends:[],deleted:c,after:resolveReference(r,e,n)}}if(!t.options.length)throw new ReferenceWriteError(`options-missing`,`name at least one option: a plugin or default.`,!0);let c=resolveReference(r,e,n),u=new Set(c.trace.layers.flatMap(({plugin:e,file:t})=>e!==void 0&&t?[e]:[])),d=t.options.map(e=>e.endsWith(`/${r.name}`)?e.slice(0,-r.name.length-1):e),f=d.filter(e=>e!=="default"&&!u.has(e));if(f.length)throw new ReferenceWriteError(`option-invalid`,`${f.join(`, `)} ${f.length===1?`is`:`are`} neither default nor a plugin holding "${r.name}"${u.size?`; the plugins holding it are ${[...u].join(`, `)}`:``}.`);let m=editFrontmatter(s??``,{extends:d});return i(a.dir,{recursive:!0}),p(a.path,m),{name:r.name,scope:o,path:a.path,extends:d,deleted:!1,after:resolveReference(r,e,n)}}function deleteContribution(e,t,r={}){let i=bareName(t.name),a=writeTarget$1(i,t),o=r.display??(e=>e),s=resolveReference(i,e,r),c=(a.scope===`project`||a.scope===`user`?[a.path,b(a.dir,i.name,`README.md`)]:[a.path]).find(e=>e!==r.without&&n(e));if(!c)throw new ReferenceWriteError(`no-file`,`${o(a.path)} does not exist, so there is no ${a.scope} contribution of "${i.name}" to delete. ${describeAnswer(s,r.display)} An installed plugin's, a managed, or an installed skill's contribution is never deleted.`);let d=readExtends(parseDocument(tryRead(c)??``,()=>{}).metadata.extends,()=>{}),f=!!t.dryRun;if(!f&&(l(c),y(c)!==a.dir))try{u(y(c))}catch{}let p={name:i.name,scope:a.scope,path:c,dryRun:f,after:resolveReference(i,e,{...r,without:f?c:void 0})};return d&&(p.selection=d.map(({target:e})=>e)),p}const X={description:"Directory the project tier is read from, and each folder above it up to the repository root; a project write goes to its `.agents/references/`. Defaults to the current directory.",type:k.string().optional()},Z={description:`Add the trace: every layer checked, with its outcome, and how the result was built.`,type:k.boolean().optional()},pr={description:"The calling skill's folder: its `references/<name>.default.md` joins as the `default` tier.",type:k.string().optional()};function layerSource(e){return(t,n)=>referenceLayers$1({root:t.root??process.cwd(),home:n,platform:process.platform,env:process.env,plugin:e,defaultSkill:t.default})}function compact(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``&&!(Array.isArray(e)&&!e.length)))}function fail(e,t){throw isCliError(e)?e:e instanceof ReferenceWriteError?(process.stderr.write(`error: ${e.code}: ${e.message}\n`),O.reported(e.usage?D.usage:D.error)):(process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),O.reported(D.error))}function usage(e){throw process.stderr.write(`error: usage: ${e}\n`),O.reported(D.usage)}function answerThenFail(e,t){let n=printAnswer(e,t);throw n!==void 0&&process.stdout.write(n),O.reported(D.error)}function writeWarnings(e){for(let{code:t,message:n}of e)process.stderr.write(`warning: ${t}: ${n}\n`)}function displayTrace(e,t){let show=e=>collapseHome(t,e);return{...e,contributions:e.contributions.map(e=>({...e,path:show(e.path)})),layers:e.layers.map(e=>({...e,path:show(e.path)}))}}function traceText(e,t){let n=displayTrace(e.trace,t),r=[`${e.name}: ${e.status}; stack: ${n.stack.join(` → `)||`none`}; built by ${n.builtBy}; harnesses: ${n.harnesses.join(`, `)||`none detected`}`];if(e.message&&r.push(` ${e.message}`),n.sections.length){r.push(`sections:`);for(let e of n.sections){let t=e.removedBy?`removed by ${e.removedBy}`:e.contributions.map(({contribution:e,operation:t})=>`${e} (${t})`).join(`, `)||`no text`;r.push(` ${e.path}: ${t}`)}}r.push(`layers:`);for(let e of n.layers){let t=e.plugin?` ${e.plugin}`:e.skill?` ${e.skill}`:``,n=e.operation?`; ${e.operation} from ${e.operationFrom}`:``,i=e.extendsOutcome?`; extends ${e.extendsOutcome}`:``,a=e.selection?`; selection`:``,o=e.frontmatter&&Object.keys(e.frontmatter).length?` ${JSON.stringify(e.frontmatter)}`:``;r.push(` ${e.tier}${t} ${e.path}: ${e.outcome}${n}${i}${a}${o}`)}return`${r.join(`
|
|
407
|
+
`)}\n`}function errorText(e){let t=e.options?.length?`; options: ${e.options.join(`, `)}`:``;return`${e.name}: ${e.message}${t}`}function showEntry(e,t,{metadata:n,trace:r}){return e.status===`found`&&!e.warnings.length&&!n&&!r?e.content:compact({name:e.name,status:e.status,content:e.content,code:e.code,options:e.options,metadata:n?e.metadata:void 0,warnings:e.warnings,trace:r?displayTrace(e.trace,t):void 0})}const mr={toon:e=>encode(e,`toon`),json:e=>encode(e,`json`)};function showText(e){if(e.length===1){let[t]=e;return t.content===void 0?void 0:document(t.content)}return document(e.map(e=>e.content===void 0?`<reference name="${e.name}" status="${e.status}" />`:`<reference name="${e.name}">\n${e.content}</reference>`).join(`
|
|
472
408
|
|
|
473
|
-
`))}function writeShowStderr(e,t){for(let n of e){if(t===`text`){for(let e of n.warnings)process.stderr.write(`warning: ${e}\n`);n.trace&&process.stderr.write(`${renderText({[`trace ${n.name}`]:n.trace})}\n`)}n.status!==`found`&&process.stderr.write(`error: ${missReason(n)}\n`)}}function showCommand(e){return command({name:`show`,description:`Print one or more references, each resolved through the tiers and combined as its layers ask.`,arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:In(q())}],options:{root:Qs,trace:{description:`Report every path checked, the file that matched, the merge mode, and why a layer was dropped.`,type:J(Fn())},format:{description:`Output format: text (default) writes the documents themselves; toon and json return an array with metadata.`,type:J(q()),default:`text`}},async run(t){try{let n=parseFormat(t.format),r=t.names.map(parseReferenceName);if(!r.length)throw Error(`Name at least one reference.`);let i=ee(),a=await e(t,i),display=e=>collapseHome(i,e),o=r.map(e=>{let n=resolveReference(e,a,{display}),r=n.status===`missing`?searchReferences(e.name,a,{display}).slice(0,3).map(e=>e.name):[];return showEntry(n,i,r,!!t.trace)});return n===`text`?writeShowText(o):writeResult(o,n),writeShowStderr(o,n),o.every(e=>e.status===`found`)?k.success:k.error}catch(e){return fail(e,`Reference lookup failed.`)}}})}const $s={description:`Output format: toon (default), json, or text for a human-readable report.`,type:J(q()),default:`toon`};function listCommand(e){return command({name:`list`,description:`List every layer, and every reference at every layer that holds it, marked used or shadowed.`,options:{root:Qs,format:$s},async run(t){try{let n=parseFormat(t.format),r=ee(),i=await e(t,r),{rows:a,warnings:o}=listReferences(i,{display:e=>collapseHome(r,e)}),s={layers:i.map(({tier:e,plugins:t,dir:n,status:i})=>({tier:e,plugin:t[0]??``,path:collapseHome(r,n),status:i})),references:a.length?a.map(e=>({...e,path:collapseHome(r,e.path)})):`0 references — no layer holds one`};return o.length&&(s.warnings=o),writeResult(s,n),k.success}catch(e){return fail(e,`Reference listing failed.`)}}})}function searchCommand(e){return command({name:`search`,description:`Find references by name, description, tags, headings, or body, best match first.`,arguments:[{name:`query`,description:`What the reference is about.`,type:q()}],options:{root:Qs,format:$s},async run(t){try{let n=parseFormat(t.format),r=t.query.trim();if(!r)throw Error(`Search needs a query.`);let i=ee(),a=searchReferences(r,await e(t,i),{display:e=>collapseHome(i,e)});return writeResult({query:r,references:a.length?a:`0 references match "${r}"`},n),k.success}catch(e){return fail(e,`Reference search failed.`)}}})}function whereCommand(e){return command({name:`where`,description:`List the project and user files an override of a reference can be written to, highest precedence first, with the copy each overrides and who it applies to.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:q()}],options:{root:Qs,caller:{description:`Folder of the skill that loads the reference, so its own copy is reported as the reference skill's Load mode reads it.`,type:J(q())},format:$s},async run(t){try{let n=parseFormat(t.format),r=parseReferenceName(t.name),i=ee(),a=whereReference(r,await e(t,i),{root:C(t.root??process.cwd()),caller:t.caller===void 0?void 0:C(t.caller),display:e=>collapseHome(i,e)});return writeResult(a,n),a.plugins?(process.stderr.write(`error: ${missReason({name:r.raw,status:`ambiguous`,plugins:a.plugins,warnings:[]})}\n`),k.error):k.success}catch(e){return fail(e,`Reference placement lookup failed.`)}}})}function parseScope(e){if(e!==`project`&&e!==`user`)throw Error(`--scope must be project or user.`);return e}function createCommand(e){return command({name:`create`,description:`Start a new reference in the project or user tier from a template, marked merge-sections when it overrides a copy below. Never overwrites.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:q()}],options:{root:Qs,template:{description:"File whose text is written as it is, frontmatter included. Defaults to a built-in template of top-level `##` sections with no `#` title.",type:J(q())},scope:{description:"Tier to write: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:J(q()),default:`project`},"dry-run":{description:`Print the target path and the exact content, and write nothing.`,type:J(Fn())},format:{description:`Output format: text (default) writes the path, then the content or the trace; toon and json return an object.`,type:J(q()),default:`text`}},async run(t){try{let n=parseFormat(t.format),r=parseReferenceName(t.name);if(r.plugin!==void 0)throw Error(`an override is written under the bare name, which every tier resolves; ask for "${r.name}".`);let i=parseScope(t.scope),o=readTemplate(t.template===void 0?void 0:C(t.template)),s=ee(),c=scopeDir(i,t.root,s),l=y(c,`${r.name}.md`),display=e=>collapseHome(s,e),u=await e(t,s),{trace:d}=resolveReference(r,u,{display}),p=u.findIndex(e=>e.dir===c);if(d[p]?.found)throw Error(`${display(d[p].path)} already holds "${r.name}"; change it with the reference skill's Update mode.`);let m=d.slice(0,p).find(e=>e.found&&e.merge===`first-wins`);if(m)throw Error(`the ${m.tier} copy ${display(m.path)} is first-wins, so nothing would read a new ${i} file; change that copy instead.`);let g=d.slice(p+1).some(e=>e.found)&&o.metadata.merge===void 0?withMergeSections(o.content):o.content,_=templateWarnings(o),v={name:r.name,scope:i,path:display(l),dryRun:!!t[`dry-run`],content:g,warnings:_};if(v.dryRun||(a(c,{recursive:!0}),h(l,g,{flag:`wx`}),v.trace=traceOf(resolveReference(r,u,{display}),s)),n!==`text`)writeResult(v,n);else{for(let e of _)process.stderr.write(`warning: ${e}\n`);v.trace?process.stdout.write(`${v.path}\n\n${renderText({trace:v.trace})}\n`):writeDocument(`${v.path}\n\n${g}`)}return k.success}catch(e){return fail(e,`Reference creation failed.`)}}})}function scopeDir(e,t,n){return e===`project`?projectReferencesDir(C(t??process.cwd())):y(n,`.agents`,`references`)}function nextOf(e,t){let n={status:e.status};return e.status===`found`&&Object.assign(n,{tier:e.tier,plugin:e.plugin,path:collapseHome(t,e.path)}),e.status===`ambiguous`&&(n.plugins=e.plugins),n}function describeNext(e,t){return t.status===`found`?`"${e}" is then answered by the ${t.tier} copy ${t.path}.`:t.status===`ambiguous`?`"${e}" is then held by more than one plugin: ${t.plugins.join(`, `)}.`:`no copy of "${e}" is left in any tier.`}function deleteCommand(e){return command({name:`delete`,description:`Delete the project or user copy of a reference, and report which copy answers the name afterwards. Never deletes a plugin-shipped or managed copy.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:q()}],options:{root:Qs,scope:{description:"Tier to delete from: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:J(q()),default:`project`},"dry-run":{description:`Print the file that would be deleted and what would answer the name then, and delete nothing.`,type:J(Fn())},format:{description:`Output format: text (default) writes the path, what answers next, and the trace; toon and json return an object.`,type:J(q()),default:`text`}},async run(t){try{let n=parseFormat(t.format),r=parseReferenceName(t.name);if(r.plugin!==void 0)throw Error(`a project or user copy is held under the bare name; ask for "${r.name}". A plugin's copy is never deleted.`);let i=parseScope(t.scope),a=ee(),o=scopeDir(i,t.root,a),display=e=>collapseHome(a,e),s=await e(t,a),c=resolveReference(r,s,{display}),l=c.trace[s.findIndex(e=>e.dir===o)];if(!l?.found){let e=c.status===`found`?` ${describeNext(r.name,nextOf(c,a))}`:``;throw Error(`${display(y(o,`${r.name}.md`))} does not exist, so there is no ${i} copy of "${r.name}" to delete.${e} Delete never removes a plugin-shipped or managed copy.`)}let p=l.path,m=!!t[`dry-run`];if(!m&&(u(p),_(p)!==o))try{d(_(p))}catch{}let h=resolveReference(r,s,{display,without:m?p:void 0}),g={name:r.name,scope:i,path:display(p),dryRun:m,next:nextOf(h,a),trace:traceOf(h,a)};return n===`text`?process.stdout.write(`${g.path}\n\n${m?`would delete`:`deleted`}. ${describeNext(g.name,g.next)}\n\n${renderText({trace:g.trace})}\n`):writeResult(g,n),k.success}catch(e){return fail(e,`Reference deletion failed.`)}}})}function createReferenceCommands({plugin:e}={}){let t=layerSource(e);return{show:showCommand(t),list:listCommand(t),search:searchCommand(t),where:whereCommand(t),create:createCommand(t),delete:deleteCommand(t)}}function createReferenceCommand(e={}){let{show:t,list:n,search:r,where:i,create:a,delete:o}=createReferenceCommands(e);return command({name:`reference`,description:`Read on-demand reference documents by name, layered across the managed, project, user, and plugin tiers, and start or delete one in the project or user tier.`,commands:[t,n,r,i,a,o]})}function managedGovernancesDir(e,t){return managedGovernancesDir$1(e,t)}function deprecatedManagedGovernancesDir(e,t){return deprecatedManagedGovernancesDir$1(e,t)}function projectGovernancesDir(e){return y(e,`.agents`,`governances`)}function userGovernancesDir(e){return y(e,`.agents`,`governances`)}function packageGovernancesDir(e=E(import.meta.url)){let t=_(e);for(;;){if(r(y(t,`package.json`)))return y(t,`governances`);let e=_(t);if(e===t)return y(t,`governances`);t=e}}function governanceLayers({root:e,home:t,platform:n,programData:r}){return[{scope:`project`,dir:projectGovernancesDir(e)},{scope:`user`,dir:userGovernancesDir(t)},{scope:`managed`,dir:managedGovernancesDir(n,r)},{scope:`managed-deprecated`,dir:deprecatedManagedGovernancesDir(n,r)},{scope:`package`,dir:packageGovernancesDir()}]}function overrideLayers(e){return e.filter(e=>e.scope!==`package`)}const ec=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i;function parseGovernanceName(e){if(e.endsWith(`.md`))throw Error(`"${e}" names a file. Ask for the governance by name, without the .md extension.`);if(!ec.test(e))throw Error(`"${e}" is not a governance name. A name is letters, digits, hyphens, and dots — not a path.`);return e}function tryReadDocument(e){try{return o(e,`utf8`)}catch{return}}function documentNames(e){try{return s(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>e.name.slice(0,-3))}catch{return[]}}function resolveGovernance(e,t){for(let{scope:n,dir:r}of t){let t=y(r,`${e}.md`),i=tryReadDocument(t);if(i!==void 0)return{name:e,scope:n,path:t,content:i}}}function listGovernances(e){let t=new Map;for(let{scope:n,dir:r}of e)for(let e of documentNames(r))t.has(e)||t.set(e,{name:e,scope:n,path:y(r,`${e}.md`)});return[...t.values()].sort((e,t)=>e.name.localeCompare(t.name))}const tc=`buddy-agent-harness`;function referenceLayers({packageRoot:e=_(packageGovernancesDir()),...t}){return referenceLayers$1({...t,plugin:{name:tc,root:e}})}const nc=createReferenceCommand({plugin:{name:tc,root:_(packageGovernancesDir())}});function skillNames(e){return s(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort()}function pathOccupied(e){try{return i(e),!0}catch{return!1}}function linksTo(e,t){try{return i(e).isSymbolicLink()?l(e)===l(t):!1}catch{return!1}}function countSkills(e){return a(e,{recursive:!0}),skillNames(e).length}function linkTarget(e,t){return te()===`win32`?C(t):S(_(e),t)}function parseForce(e){return e===`true`||e!==`false`&&e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function namesTarget(e,t,n){return C(e,n)===C(t)}function projectSkills({root:e,canonicalSkills:t,harnesses:r,copy:i,force:o}){let s=r.filter(e=>e.project.skillsDirectory).map(t=>({harness:t,target:y(e,t.project.skillsDirectory)})),c=Array.isArray(o)?o:[],l=c.filter(t=>!s.some(({target:n})=>namesTarget(e,n,t)));if(l.length)throw Error(`No skill target matches:\n${l.map(e=>`- ${e}`).join(`
|
|
409
|
+
`))}function showCommand(e){return command({name:`show`,description:`Print one or more references, each composed from its contributions as their extends and merge declare.`,arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` builds that plugin’s own stack.",type:k.array(k.string())}],options:{root:X,default:pr,metadata:{description:`Make every entry a record with its status and composed frontmatter.`,type:k.boolean().optional()},trace:Z},async run(t){let n=this.format;t.names.length||usage(`name at least one reference.`);try{let r=g(),i=await e(t,r),display=e=>collapseHome(r,e),a=interfaceLookup(i,{display}),o=t.names.map(e=>{let t=resolveReference(parseReferenceName(e),i,{display});for(let e of checkResolved(t,a).failures)e.check!==`compose`&&t.warnings.push({code:`interface-check`,message:`it fails its interface check (${e.check}): ${e.message}`});return t}),s=o.every(e=>e.status===`found`);if(n===`text`){for(let e of o)writeWarnings(e.warnings),e.status!==`found`&&process.stderr.write(`error: ${e.code}: ${errorText(e)}\n`),t.trace&&process.stderr.write(traceText(e,r));let e=showText(o);if(e===void 0)throw O.reported(D.error);return s?e:answerThenFail(e,n)}let c={metadata:!!t.metadata,trace:!!t.trace},l=result(o.map(e=>showEntry(e,r,c)),{render:mr});return s?l:answerThenFail(l,n)}catch(e){return fail(e,`Reference lookup failed.`)}}})}function listCommand(e){return command({name:`list`,description:`List every reference name, one row each, with its description, and its status when not found. A pattern keeps only the names it matches exactly.`,arguments:[{name:`pattern`,description:"Exact name pattern, where `*` stands for any run of characters, such as `project-tracker.capabilities.*`.",type:k.string().optional()}],options:{root:X,trace:{...Z,description:`Add one row per name per layer holding it, with its outcome.`}},async run(t){try{let n=g(),display=e=>collapseHome(n,e),r=listReferences(await e(t,n),{display,pattern:t.pattern}),i=compact({references:r.references.length?r.references.map(e=>compact({name:e.name,description:e.description,status:e.status===`found`?void 0:e.status,options:e.options})):t.pattern?`0 references match "${t.pattern}"`:`0 references — no layer holds one`,defaults:r.defaults});return t.trace&&(i.layers=r.layers.map(e=>compact({...e,path:display(e.path)}))),r.warnings.length&&(i.warnings=r.warnings),result(i)}catch(e){return fail(e,`Reference listing failed.`)}}})}function searchCommand(e){return command({name:`search`,description:`Find references by name, description, tags, headings, or body, best match first.`,arguments:[{name:`query`,description:`What the reference is about.`,type:k.string()}],options:{root:X,trace:{...Z,description:`Add the tier and plugin or skill of each match.`}},async run(t){let n=t.query.trim();n||usage(`search needs a query.`);try{let r=g(),{matches:i,defaults:a}=searchReferences(n,await e(t,r),{display:e=>collapseHome(r,e)});return result(compact({references:i.length?i.map(({name:e,description:n,match:r,tier:i,plugin:a,skill:o,loadedBy:s})=>compact(t.trace?{name:e,description:n,match:r,loadedBy:s,tier:i,plugin:a,skill:o}:{name:e,description:n,match:r,loadedBy:s})):`0 references match "${n}"`,defaults:a}))}catch(e){return fail(e,`Reference search failed.`)}}})}function whereCommand(e){return command({name:`where`,description:`Give the project and user files a customization or a selection of a reference is written to, who each reaches, and the heading paths of the document below each.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:k.string()}],options:{root:X,default:pr,trace:{...Z,description:`Add every layer checked, with its outcome.`}},async run(t){let n=this.format;try{let r=g(),display=e=>collapseHome(r,e),i=whereReference(t.name,await e(t,r),{root:C(t.root??process.cwd()),display}),a=compact({name:i.name,status:i.status,places:i.places.map(e=>compact(e)),options:i.options,layers:t.trace?i.layers.map(e=>({...e,path:display(e.path)})):void 0,warnings:i.warnings});n===`text`&&writeWarnings(i.warnings);let o=result(a);return i.status===`invalid`?(process.stderr.write(`error: reference-invalid: ${parseReferenceName(t.name).invalid}\n`),answerThenFail(o,n)):o}catch(e){return fail(e,`Reference placement lookup failed.`)}}})}function parseAccept(e){if(e===void 0)return;let t=e.split(`,`).map(e=>e.trim());return(!t.length||t.some(e=>!/^[1-9]\d*$/.test(e)))&&usage(`--accept is a comma-separated list of versions, such as 1,2; got "${e}".`),t.map(Number)}function implementationsCommand(e){return command({name:`implementations`,description:`List the implementations of an interface a consumer can load, each with its pin, description, and unsupported sections.`,arguments:[{name:`id`,description:"Interface id, the name of its `<id>.interface` document without the suffix.",type:k.string()}],options:{root:X,accept:{description:"Versions the consumer knows, comma-separated, such as 1,2. Defaults to the interface's `versions`.",type:k.string().optional()},trace:{...Z,description:`Add each one's name, tier, and version, the interface's cardinality and accepted versions, and the ones left out with why.`}},async run(t){let n=parseAccept(t.accept);try{let r=g(),i=referenceImplementations(t.id,await e(t,r),{accept:n,display:e=>collapseHome(r,e)}),a=i.implementations.map(({pin:e,description:n,unsupported:r,name:i,tier:a,version:o})=>compact(t.trace?{pin:e,description:n,unsupported:r,name:i,tier:a,version:o}:{pin:e,description:n,unsupported:r})),o={implementations:a.length?a:`0 implementations of ${t.id}`};return t.trace&&Object.assign(o,compact({interface:i.interface,cardinality:i.cardinality,accept:i.accept,excluded:i.excluded,warnings:i.warnings})),result(o)}catch(e){return fail(e,`Implementation lookup failed.`)}}})}function checkCommand(e){return command({name:`check`,description:"Check interface documents and their implementations, each composed as `show` composes it. With no names, checks every one found. Exits 1 on any failure.",arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` builds that plugin’s own stack.",type:k.array(k.string()).optional()}],options:{root:X,trace:{...Z,description:`Add every entry checked, with its kind and unsupported sections.`}},async run(t){let n=this.format;try{let r=g(),i=checkReferences(await e(t,r),{names:t.names??[],display:e=>collapseHome(r,e)}),a=i.filter(e=>e.status!==`passed`),strip=e=>e.map(({check:e,message:t})=>({check:e,message:t})),o=result(compact({failed:a.map(({name:e,loadedBy:t,failures:n})=>compact({name:e,loadedBy:t,failures:strip(n)})),passed:i.length-a.length,references:t.trace?i.map(({name:e,loadedBy:t,kind:n,status:r,failures:i,unsupported:a})=>compact({name:e,loadedBy:t,kind:n,status:r,failures:strip(i),unsupported:a})):void 0}));return a.length?(n===`text`&&process.stderr.write(`error: interface-check: ${a.length} of ${i.length} references fail their check.\n`),answerThenFail(o,n)):o}catch(e){return fail(e,`Reference check failed.`)}}})}const hr={description:"Tier to write: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:k.string().optional()},gr={description:"A plugin's source folder in this repository: acts on its `references/<name>.md`.",type:k.string().optional()},_r={description:"A skill's source folder in this repository: acts on its `references/<name>.default.md`.",type:k.string().optional()};function createCommand(e){return command({name:`create`,description:`Start a contribution in the project or user tier, or in a plugin's or a skill's source folder, from a template or an interface. Never overwrites a file with a body.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:k.string()}],options:{root:X,scope:hr,plugin:gr,default:_r,merge:{description:`How it applies over what is below: replace, patch (default), combine, or remove. remove writes no body.`,type:k.string().optional()},template:{description:"File whose text is written as it is, frontmatter included. Defaults to a built-in template of top-level `##` sections.",type:k.string().optional()},implements:{description:"Interface id to implement: the interface's sections become `##` headings, each stubbed `**Unsupported.**`, with `merge: replace`. Not with --template.",type:k.string().optional()},"dry-run":{description:`Print the target path and the exact content, and write nothing.`,type:k.boolean().optional()},trace:{...Z,description:`After the write, add the trace, in which the new file applies.`}},async run(t){let n=this.format;try{let r=g(),i=C(t.root??process.cwd()),display=e=>collapseHome(r,e),a=createContribution(await e({root:i,default:t.default},r),{root:i,home:r,name:t.name,scope:t.scope,plugin:t.plugin,default:t.default,merge:t.merge,template:t.template,implements:t.implements,dryRun:t[`dry-run`]},{display}),o=compact({path:display(a.path),hint:a.dryRun?`Nothing was written. Run again without --dry-run to write it.`:`Run \`show ${a.name}\` for the composed document.`,content:a.dryRun?a.content:void 0,hints:a.hints,trace:t.trace&&a.after?displayTrace(a.after.trace,r):void 0});if(n!==`text`)return result(o);for(let e of a.hints)process.stderr.write(`hint: ${e}\n`);return t.trace&&a.after&&process.stderr.write(traceText(a.after,r)),document(a.dryRun?`${o.path}\n\n${a.content}`:`${o.path}\n\n${o.hint}\n`)}catch(e){return fail(e,`Reference creation failed.`)}}})}function selectCommand(e){return command({name:`select`,description:"Choose what a name builds on: write an `extends` listing the options, bottom first, in the project or user file. Its body and other keys are kept.",arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:k.string()},{name:`options`,description:"Bottom first: each a plugin holding the name (or `<plugin>/<name>`), or `default`.",type:k.array(k.string()).optional()}],options:{root:X,scope:hr,clear:{description:`Remove the selection; a file left with nothing in it is deleted.`,type:k.boolean().optional()}},async run(t){let n=this.format;try{let r=g(),i=C(t.root??process.cwd()),display=e=>collapseHome(r,e),a=selectContribution(await e({root:i},r),{root:i,home:r,name:t.name,options:t.options??[],scope:t.scope,clear:t.clear},{display}),o=compact({path:display(a.path),extends:a.extends,deleted:a.deleted||void 0,status:a.after.status,stack:a.after.trace.stack,answer:describeAnswer(a.after,display)});if(n!==`text`)return result(o);writeWarnings(a.after.warnings);let s=t.clear?a.deleted?`selection cleared; the file was left empty and deleted`:`selection cleared`:`extends: [${a.extends.join(`, `)}]`;return document(`${o.path}\n\n${s}. ${o.answer}\n`)}catch(e){return fail(e,`Reference selection failed.`)}}})}function deleteReport(e,t){let n=e.selection?`the selection extends: [${e.selection.join(`, `)}] went with it; run \`reference select ${e.name} <option>...\` to restore it`:void 0;return compact({path:collapseHome(t,e.path),dryRun:e.dryRun||void 0,status:e.after.status,stack:e.after.trace.stack,answer:describeAnswer(e.after,e=>collapseHome(t,e)),selection:n,options:e.after.options})}function deleteCommand(e){return command({name:`delete`,description:`Delete a project or user contribution, or one in a plugin's or a skill's source folder, and report what answers the name afterwards. Never deletes an installed or managed one.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:k.string()}],options:{root:X,scope:{...hr,description:`Tier to delete from: project (default) or user.`},plugin:gr,default:_r,"dry-run":{description:`Print the file that would be deleted and what would answer the name then, and delete nothing.`,type:k.boolean().optional()}},async run(t){let n=this.format;try{let r=g(),i=C(t.root??process.cwd()),a=deleteContribution(await e({root:i,default:t.default},r),{root:i,home:r,name:t.name,scope:t.scope,plugin:t.plugin,default:t.default,dryRun:t[`dry-run`]},{display:e=>collapseHome(r,e)}),o=deleteReport(a,r);if(n!==`text`)return result(o);let s=o.selection?` Also, ${o.selection}.`:``;return document(`${o.path}\n\n${a.dryRun?`would delete`:`deleted`}. ${o.answer}${s}\n`)}catch(e){return fail(e,`Reference deletion failed.`)}}})}function createReferenceCommands({plugin:e}={}){let t=layerSource(e);return{show:showCommand(t),list:listCommand(t),search:searchCommand(t),where:whereCommand(t),create:createCommand(t),select:selectCommand(t),delete:deleteCommand(t),check:checkCommand(t),implementations:implementationsCommand(t)}}function createReferenceCommand(e={}){let{show:t,list:n,search:r,where:i,create:a,select:o,delete:s,check:c,implementations:l}=createReferenceCommands(e);return command({name:`reference`,description:`Read reference documents by name, composed from the managed, project, user, plugin, and default tiers, and write, select, or delete a contribution.`,commands:[t,n,r,i,a,o,s,l,c]})}function machineWideDir(e,t,n){return e===`darwin`?b(`/Library/Application Support`,n.macos,`governances`):e===`win32`?b(t||`C:\\ProgramData`,n.windows,`governances`):b(`/etc`,n.posix,`governances`)}function managedGovernancesDir(e,t){return machineWideDir(e,t,{posix:`buddy-agent-harness`,macos:`BuddyAgentHarness`,windows:`BuddyAgentHarness`})}function deprecatedManagedGovernancesDir(e,t){return machineWideDir(e,t,{posix:`universal-plugin`,macos:`UniPlugin`,windows:`UniPlugin`})}function projectGovernancesDir(e){return b(e,`.agents`,`governances`)}function userGovernancesDir(e){return b(e,`.agents`,`governances`)}function packageGovernancesDir(e=te(import.meta.url)){let t=y(e);for(;;){if(n(b(t,`package.json`)))return b(t,`governances`);let e=y(t);if(e===t)return b(t,`governances`);t=e}}function governanceLayers({root:e,home:t,platform:n,programData:r}){return[{scope:`project`,dir:projectGovernancesDir(e)},{scope:`user`,dir:userGovernancesDir(t)},{scope:`managed`,dir:managedGovernancesDir(n,r)},{scope:`managed-deprecated`,dir:deprecatedManagedGovernancesDir(n,r)},{scope:`package`,dir:packageGovernancesDir()}]}function overrideLayers(e){return e.filter(e=>e.scope!==`package`)}const vr=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i;function parseGovernanceName(e){if(e.endsWith(`.md`))throw Error(`"${e}" names a file. Ask for the governance by name, without the .md extension.`);if(!vr.test(e))throw Error(`"${e}" is not a governance name. A name is letters, digits, hyphens, and dots — not a path.`);return e}function tryReadDocument(e){try{return a(e,`utf8`)}catch{return}}function documentNames(e){try{return o(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>e.name.slice(0,-3))}catch{return[]}}function resolveGovernance(e,t){for(let{scope:n,dir:r}of t){let t=b(r,`${e}.md`),i=tryReadDocument(t);if(i!==void 0)return{name:e,scope:n,path:t,content:i}}}function listGovernances(e){let t=new Map;for(let{scope:n,dir:r}of e)for(let e of documentNames(r))t.has(e)||t.set(e,{name:e,scope:n,path:b(r,`${e}.md`)});return[...t.values()].sort((e,t)=>e.name.localeCompare(t.name))}const yr=`buddy-agent-harness`;function referenceLayers({packageRoot:e=y(packageGovernancesDir()),...t}){return referenceLayers$1({...t,plugin:{name:yr,root:e}})}const br=createReferenceCommand({plugin:{name:yr,root:y(packageGovernancesDir())}});function skillNames(e){return o(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort()}function pathOccupied(e){try{return r(e),!0}catch{return!1}}function linksTo(e,t){try{return r(e).isSymbolicLink()?c(e)===c(t):!1}catch{return!1}}function countSkills(e){return i(e,{recursive:!0}),skillNames(e).length}function linkTarget(e,t){return _()===`win32`?C(t):S(y(e),t)}function parseForce(e){return e===`true`||e!==`false`&&e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function namesTarget(e,t,n){return C(e,n)===C(t)}function projectSkills({root:e,canonicalSkills:n,harnesses:r,copy:a,force:o}){let s=r.filter(e=>e.project.skillsDirectory).map(t=>({harness:t,target:b(e,t.project.skillsDirectory)})),c=Array.isArray(o)?o:[],u=c.filter(t=>!s.some(({target:n})=>namesTarget(e,n,t)));if(u.length)throw Error(`No skill target matches:\n${u.map(e=>`- ${e}`).join(`
|
|
474
410
|
`)}\nTargets for the enabled harnesses:\n${s.map(({target:t})=>`- ${S(e,t)}`).join(`
|
|
475
|
-
`)}`);let forces=t=>o===!0||c.some(n=>namesTarget(e,t,n)),d=s.filter(({target:e})=>pathOccupied(e)&&!linksTo(e,
|
|
476
|
-
`)}`);let p=new Set(d.map(({harness:e})=>e.name));for(let{harness:e,target:r}of s)if(!p.has(e.name)&&(
|
|
477
|
-
`).some(e=>r.includes(e.trim()))}function base(e,t,n){let r=e.relocatedBy,i=r===void 0?void 0:t[r];return r===void 0||i===void 0?{}:i===``?e.emptyRelocatesToStart?{moved:{root:n,display:`.`},emptied:r}:{}:{moved:{root:C(i),display:`$${r}`}}}function locate(e,t,{moved:n},r){if(!n||r!==t.detect&&!r.startsWith(`${t.detect}/`))return{absolute:
|
|
478
|
-
`).some(e=>e.trim()===`@AGENTS.md`)?{kind:`import`,status:`superseded`,problem:`instructions-superseded`}:{kind:`file`,status:`shadowing`,problem:`instructions-shadowing`}}function diagnoseInstructions(e,t,n){let r=t.map(e=>({name:e.name,bridge:e.project.instructionBridge})).filter(e=>e.bridge?.kind===`settings-entry`),i=[],a=[],o=agentsFileDirectories(e),s=t.some(t=>(t.project.shadowedBy??[]).some(t=>exists(
|
|
479
|
-
`).filter(Boolean)}var GitBridgeState=class{root;repoRootPrefix;constructor(e){this.root=e,this.repoRootPrefix=git(e,[`rev-parse`,`--show-prefix`])?.trim()}trackingOf(e){if(this.repoRootPrefix===void 0)return`untracked`;let t=lines(git(this.root,[`ls-files`,`-v`,`--`,e]));return t.length?t.every(e=>e.startsWith(`S`))?`skip-worktree`:`tracked`:`untracked`}isIgnored(e){return this.repoRootPrefix!==void 0&&git(this.root,[`check-ignore`,`-q`,`--`,e])!==void 0}commitsTouching(e){return this.repoRootPrefix===void 0?[]:lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,...e]))}contentAt(e,t){if(this.repoRootPrefix!==void 0)return git(this.root,[`show`,`${e}:${this.repoRootPrefix}${t}`])}directionOf(e,t){if(this.repoRootPrefix===void 0)return`unknown`;let n=this.lastAgreedTree(e,t);if(n===void 0)return`unknown`;let r=!this.matchesTree(e,n),i=!this.matchesTree(t,n);return r&&i?`both`:r?`bridge`:`canonical`}lastAgreedTree(e,t){for(let n of lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,e,t]))){let r=git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${e}`])?.trim();if(r&&r===git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${t}`])?.trim())return r}}matchesTree(e,t){let n=new Map(lines(git(this.root,[`ls-tree`,`-r`,t])).map(e=>{let[t,n]=e.split(` `);return[n,t.split(` `)[2]]})),r=filesUnder(
|
|
480
|
-
`)));return i.length===r.length&&r.every((e,t)=>n.get(e)===i[t])}};const
|
|
481
|
-
`,cc={description:`Repository or package directory. Defaults to the current directory.`,type:J(q())},lc={description:`Resolve only the project, user, and machine-wide layers. Never returns a governance this package ships, and exits non-zero when no layer has one.`,type:J(Fn())},uc=command({name:`governance`,description:"Deprecated: use `reference`. Read the governance documents the project, user, and machine-wide override layers hold. Read-only.",commands:[command({name:`list`,description:`List every governance the override layers hold, each at the layer that would win.`,options:{root:cc,"overrides-only":lc,format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:J(q()),default:`toon`}},run(e){process.stderr.write(sc);try{let t=parseFormat$1(e.format),n=ee(),r=layersFor(e),i=listGovernances(r);return writeResult$1({layers:r.map(({scope:e,dir:t})=>({scope:e,path:collapseHome$1(n,t),status:e===`managed-deprecated`?`deprecated — move these documents to the managed layer above`:``})),governances:i.length?i.map(({name:e,scope:t,path:r})=>({name:e,scope:t,path:collapseHome$1(n,r)})):`0 governances — no layer holds one`},t),k.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Governance listing failed.`}\n`),k.error}}}),command({name:`show`,description:`Print one governance document, resolved through the layers in order.`,arguments:[{name:`name`,description:"The governance name, without the `.md` extension.",type:q()}],options:{root:cc,"overrides-only":lc,format:{description:`Output format: text (default) writes the document itself; toon and json wrap it with the layer it came from.`,type:J(q()),default:`text`}},run(e){process.stderr.write(sc);try{let t=parseFormat$1(e.format),n=parseGovernanceName(e.name),r=resolveGovernance(n,layersFor(e));return r?(t===`text`?writeDocument$1(r.content):writeResult$1({name:r.name,scope:r.scope,path:collapseHome$1(ee(),r.path),content:r.content},t),k.success):(process.stderr.write(e[`overrides-only`]?`error: no override for governance "${n}" in the project, user, or machine-wide layer.\n`:`error: no governance named "${n}" in any layer.\n`),k.error)}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Governance lookup failed.`}\n`),k.error}}})]});function initializeHarnesses({root:e,harnesses:t=[],copy:n=!1,force:r=!1}){let i=y(e,`.agents`,`skills`),o=countSkills(i);a(projectReferencesDir(e),{recursive:!0});let s=referenceNames(projectReferenceLayers(e)).length,c=selectHarnesses(e,t),{linked:l,skipped:u}=projectSkills({root:e,canonicalSkills:i,harnesses:c,copy:n,force:r});return{root:e,harnesses:c.map(e=>e.name),native:c.filter(e=>!e.project.skillsDirectory).map(e=>e.name),linked:l,skipped:u,deprecated:c.filter(e=>e.deprecated).map(e=>({name:e.name,replacedBy:e.deprecated})),skills:o,references:s,copied:n}}const dc=command({name:`init`,description:`Set up canonical agent skills for the harnesses already enabled in a repository.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:J(q())},harness:{description:`Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:J(q())},copy:{description:`Copy skills instead of linking them.`,type:J(Fn())},force:{description:`Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.`,type:J(q())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:J(q()),default:`toon`}},run(e){try{let t=parseFormat$1(e.format),n=parseHarnesses(e.harness);return writeResult$1(initializeHarnesses({root:e.root??process.cwd(),...n.length?{harnesses:n}:{},...e.copy===void 0?{}:{copy:e.copy},...e.force===void 0?{}:{force:parseForce(e.force)}}),t),k.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Harness initialization failed.`}\n`),k.error}}}),fc={ArrayExpression:[`elements`],ArrayPattern:[`elements`],ArrowFunctionExpression:[`params`,`body`],AssignmentExpression:[`left`,`right`],AssignmentPattern:[`left`,`right`],AwaitExpression:[`argument`],BinaryExpression:[`left`,`right`],BlockStatement:[`body`],BreakStatement:[`label`],CallExpression:[`callee`,`arguments`],CatchClause:[`param`,`body`],ChainExpression:[`expression`],ClassBody:[`body`],ClassDeclaration:[`id`,`superClass`,`body`],ClassExpression:[`id`,`superClass`,`body`],ConditionalExpression:[`test`,`consequent`,`alternate`],ContinueStatement:[`label`],DebuggerStatement:[],DoWhileStatement:[`body`,`test`],EmptyStatement:[],ExperimentalRestProperty:[`argument`],ExperimentalSpreadProperty:[`argument`],ExportAllDeclaration:[`exported`,`source`,`attributes`],ExportDefaultDeclaration:[`declaration`],ExportNamedDeclaration:[`declaration`,`specifiers`,`source`,`attributes`],ExportSpecifier:[`local`,`exported`],ExpressionStatement:[`expression`],ForInStatement:[`left`,`right`,`body`],ForOfStatement:[`left`,`right`,`body`],ForStatement:[`init`,`test`,`update`,`body`],FunctionDeclaration:[`id`,`params`,`body`],FunctionExpression:[`id`,`params`,`body`],Identifier:[],IfStatement:[`test`,`consequent`,`alternate`],ImportAttribute:[`key`,`value`],ImportDeclaration:[`specifiers`,`source`,`attributes`],ImportDefaultSpecifier:[`local`],ImportExpression:[`source`,`options`],ImportNamespaceSpecifier:[`local`],ImportSpecifier:[`imported`,`local`],JSXAttribute:[`name`,`value`],JSXClosingElement:[`name`],JSXClosingFragment:[],JSXElement:[`openingElement`,`children`,`closingElement`],JSXEmptyExpression:[],JSXExpressionContainer:[`expression`],JSXFragment:[`openingFragment`,`children`,`closingFragment`],JSXIdentifier:[],JSXMemberExpression:[`object`,`property`],JSXNamespacedName:[`namespace`,`name`],JSXOpeningElement:[`name`,`attributes`],JSXOpeningFragment:[],JSXSpreadAttribute:[`argument`],JSXSpreadChild:[`expression`],JSXText:[],LabeledStatement:[`label`,`body`],Literal:[],LogicalExpression:[`left`,`right`],MemberExpression:[`object`,`property`],MetaProperty:[`meta`,`property`],MethodDefinition:[`key`,`value`],NewExpression:[`callee`,`arguments`],ObjectExpression:[`properties`],ObjectPattern:[`properties`],PrivateIdentifier:[],Program:[`body`],Property:[`key`,`value`],PropertyDefinition:[`key`,`value`],RestElement:[`argument`],ReturnStatement:[`argument`],SequenceExpression:[`expressions`],SpreadElement:[`argument`],StaticBlock:[`body`],Super:[],SwitchCase:[`test`,`consequent`],SwitchStatement:[`discriminant`,`cases`],TaggedTemplateExpression:[`tag`,`quasi`],TemplateElement:[],TemplateLiteral:[`quasis`,`expressions`],ThisExpression:[],ThrowStatement:[`argument`],TryStatement:[`block`,`handler`,`finalizer`],UnaryExpression:[`argument`],UpdateExpression:[`argument`],VariableDeclaration:[`declarations`],VariableDeclarator:[`id`,`init`],WhileStatement:[`test`,`body`],WithStatement:[`object`,`body`],YieldExpression:[`argument`]},pc=Object.keys(fc);for(let e of pc)Object.freeze(fc[e]);Object.freeze(fc);function unionWith(e){let t=Object.assign({},fc);for(let n of Object.keys(e))if(Object.hasOwn(t,n)){let r=new Set(e[n]);for(let e of t[n])r.add(e);t[n]=Object.freeze(Array.from(r))}else t[n]=Object.freeze(Array.from(e[n]));return Object.freeze(t)}function last(e){return e[e.length-1]??null}function toKeyName(e){return e.type===`TOMLBare`?e.name:e.value}var TOMLVerImpl=class{constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}};const mc=new TOMLVerImpl(1,0),hc=new TOMLVerImpl(1,1),gc=hc,_c={"1.0":mc,"1.0.0":mc,"1.1":hc,"1.1.0":hc,latest:hc,next:hc};function getTOMLVer(e){return e&&_c[e]||gc}const vc={"unterminated-string":`Unterminated string constant`,"unterminated-table-key":`Unterminated table-key`,"unterminated-array":`Unterminated array`,"unterminated-inline-table":`Unterminated inline table`,"missing-key":`Empty bare keys are not allowed`,"missing-newline":`Must be a newline`,"missing-equals-sign":`Expected equal (=) token`,"missing-value":`Unspecified values are invalid`,"missing-comma":`Expected comma (,) token`,"dupe-keys":`Defining a key multiple times is invalid`,"unexpected-char":`Unexpected character`,"unexpected-token":`Unexpected token`,"invalid-control-character":`Control characters (codes < 0x1f and 0x7f) are not allowed`,"invalid-comment-character":`Invalid code point {{cp}} within comments`,"invalid-key-value-newline":`The key, equals sign, and value must be on the same line`,"invalid-inline-table-newline":`No newlines are allowed between the curly braces unless they are valid within a value`,"invalid-underscore":`Underscores are allowed between digits`,"invalid-space":`Unexpected spaces`,"invalid-three-quotes":`Three or more quotes are not permitted`,"invalid-date":`Unexpected invalid date`,"invalid-time":`Unexpected invalid time`,"invalid-leading-zero":`Leading zeros are not allowed`,"invalid-trailing-comma-in-inline-table":`Trailing comma is not permitted in an inline table`,"invalid-char-in-escape-sequence":`Invalid character in escape sequence`,"invalid-consecutive-dots-in-key":`Consecutive dots are not permitted in keys`,"invalid-code-point":`Invalid code point {{cp}}`,"invalid-trailing-dot-in-key":`Keys cannot end with a dot`,"invalid-leading-dot-in-key":`Keys cannot start with a dot`};function getMessage(e,t){return t?vc[e].replace(/\{\{(.*?)\}\}/gu,(e,n)=>n in t?t[n]:`{{${n}}}`):vc[e]}var ParseError=class extends SyntaxError{constructor(e,t,n,r,i){super(getMessage(e,i)),this.index=t,this.lineNumber=n,this.column=r}};const $={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function isControl(e){return e>=$.NULL&&e<=$.US}function isWhitespace(e){return e===$.TABULATION||e===$.SPACE}function isEOL(e){return e===$.LINE_FEED||e===$.CARRIAGE_RETURN}function isUpperLetter(e){return e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_Z}function isLowerLetter(e){return e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_Z}function isLetter(e){return isLowerLetter(e)||isUpperLetter(e)}function isDigit(e){return e>=$.DIGIT_0&&e<=$.DIGIT_9}function isHexDig(e){return isDigit(e)||e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_F||e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_F}function isOctalDig(e){return e>=$.DIGIT_0&&e<=$.DIGIT_7}function isUnicodeScalarValue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function sortedLastIndex(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1,a=e[i];if(a===t)return i+1;a<t?n=i+1:r=i}return n}var Locations=class{constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let n=this.offsets[t];if(n===e)return;if(n<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=sortedLastIndex(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},CodePointIterator=class{constructor(e){this.locs=new Locations,this.lastCodePoint=$.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===$.EOF?$.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e&&(this.next(),!0)}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??$.EOF;if(t===$.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===$.LINE_FEED)this.locs.addOffset(this.end);else if(t===$.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===$.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),$.LINE_FEED;return t}};const yc=typeof BigInt<`u`,bc={16:`0x`,10:``,8:`0o`,2:`0b`},xc={[$.QUOTATION_MARK]:$.QUOTATION_MARK,[$.BACKSLASH]:$.BACKSLASH,[$.LATIN_SMALL_B]:$.BACKSPACE,[$.LATIN_SMALL_F]:$.FORM_FEED,[$.LATIN_SMALL_N]:$.LINE_FEED,[$.LATIN_SMALL_R]:$.CARRIAGE_RETURN,[$.LATIN_SMALL_T]:$.TABULATION},Sc={...xc,[$.LATIN_SMALL_E]:$.ESCAPE};var Tokenizer=class{constructor(e,t){this.backCode=!1,this.lastCodePoint=$.NULL,this.state=`DATA`,this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new CodePointIterator(e),this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?Sc:xc}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let n=this.codePointIterator.start,r=this.codePointIterator.getLocFromIndex(n);throw new ParseError(e,n,r.line,r.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==$.EOF&&!this.token;){t=this.nextCode();let e=this[this.state](t);if(!e)throw Error(`Unknown error: pre state=${this.state}`);this.state=e}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===$.EOF?$.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===$.EOF?!1:this.backCode?this.lastCodePoint===e&&(this.backCode=!1,!0):this.codePointIterator.eat(e)}moveAt(e){this.backCode&&=!1,this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken(`Punctuator`,`end`)}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,n,r){let{tokenStart:i}=this,a=this.codePointIterator[t],o=[i,a],s={start:this.codePointIterator.getLocFromIndex(i),end:this.codePointIterator.getLocFromIndex(a)};if(e===`Block`)this.token={type:e,value:this.text.slice(i+1,a),range:o,loc:s};else{let t,c=this.text.slice(i,a);if(e===`BasicString`||e===`LiteralString`||e===`MultiLineBasicString`||e===`MultiLineLiteralString`)t={type:e,value:c,string:n,range:o,loc:s};else if(e===`Integer`){let i=n;t={type:e,value:c,number:parseInt(i,r),bigint:yc?BigInt(bc[r]+i):null,range:o,loc:s}}else t=e===`Float`?{type:e,value:c,number:n,range:o,loc:s}:e===`Boolean`?{type:e,value:c,boolean:n,range:o,loc:s}:e===`LocalDate`||e===`LocalTime`||e===`LocalDateTime`||e===`OffsetDateTime`?{type:e,value:c,date:n,range:o,loc:s}:{type:e,value:c,range:o,loc:s};this.token=t}}DATA(e){for(;isWhitespace(e)||isEOL(e);)e=this.nextCode();if(e===$.HASH)return this.startToken(),`COMMENT`;if(e===$.QUOTATION_MARK)return this.startToken(),`BASIC_STRING`;if(e===$.SINGLE_QUOTE)return this.startToken(),`LITERAL_STRING`;if(e===$.DOT||e===$.EQUALS_SIGN||e===$.LEFT_BRACKET||e===$.RIGHT_BRACKET||e===$.LEFT_BRACE||e===$.RIGHT_BRACE||e===$.COMMA)return this.punctuatorToken(),`DATA`;if(this.valuesEnabled){if(e===$.DASH||e===$.PLUS_SIGN)return this.startToken(),`SIGN`;if(e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I)return this.startToken(),this.back(`NAN_OR_INF`);if(isDigit(e))return this.startToken(),this.back(`NUMBER`);if(e===$.LATIN_SMALL_T||e===$.LATIN_SMALL_F)return this.startToken(),this.back(`BOOLEAN`)}else if(isUnquotedKeyChar(e,this.tomlVersion))return this.startToken(),`BARE`;return e===$.EOF?`DATA`:this.reportParseError(`unexpected-char`)}COMMENT(e){let t=this.tomlVersion.gte(1,1)?e=>{isNonEOL(e)||this.reportParseError(`invalid-comment-character`,{cp:JSON.stringify(String.fromCodePoint(e)).slice(1,-1)})}:e=>{isControlOtherThanTab(e)&&this.reportParseErrorControlChar()};for(;!isEOL(e)&&e!==$.EOF;)t(e),e=this.nextCode();return this.endToken(`Block`,`start`),`DATA`}BARE(e){for(;isUnquotedKeyChar(e,this.tomlVersion);)e=this.nextCode();return this.endToken(`Bare`,`start`),this.back(`DATA`)}BASIC_STRING(e){if(e===$.QUOTATION_MARK)return e=this.nextCode(),e===$.QUOTATION_MARK?`MULTI_LINE_BASIC_STRING`:(this.endToken(`BasicString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.QUOTATION_MARK&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return e===$.QUOTATION_MARK?(this.endToken(`BasicString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.QUOTATION_MARK){let e=this.codePointIterator.start;if(this.eatCode($.QUOTATION_MARK)&&this.eatCode($.QUOTATION_MARK))return this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineBasicString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}if(e===$.LINE_FEED){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}if(isWhitespace(e)){let t=!0,n=this.codePointIterator.start,r;for(;(r=this.nextCode())!==$.EOF&&r!==$.LINE_FEED;)if(!isWhitespace(r)){this.moveAt(n),t=!1;break}if(t){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}LITERAL_STRING(e){if(e===$.SINGLE_QUOTE)return e=this.nextCode(),e===$.SINGLE_QUOTE?`MULTI_LINE_LITERAL_STRING`:(this.endToken(`LiteralString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.SINGLE_QUOTE&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e===$.SINGLE_QUOTE?(this.endToken(`LiteralString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.SINGLE_QUOTE){let e=this.codePointIterator.start;if(this.eatCode($.SINGLE_QUOTE)&&this.eatCode($.SINGLE_QUOTE))return this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineLiteralString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}SIGN(e){return e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I?this.back(`NAN_OR_INF`):isDigit(e)?this.back(`NUMBER`):this.reportParseError(`unexpected-char`)}NAN_OR_INF(e){if(e===$.LATIN_SMALL_N){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_N))return this.endToken(`Float`,`end`,NaN),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_I){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_N)&&this.eatCode($.LATIN_SMALL_F))return this.endToken(`Float`,`end`,this.text[this.tokenStart]===`-`?-1/0:1/0),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}NUMBER(e){let t=this.text[this.tokenStart],n=t===`+`?$.PLUS_SIGN:t===`-`?$.DASH:$.NULL;if(e===$.DIGIT_0){if(n===$.NULL){let e=this.codePointIterator.start,t=this.nextCode();if(isDigit(t)){let n=this.nextCode();if(n===$.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint($.DIGIT_0,t)),minute:0,second:0},`TIME_MINUTE`;if(isDigit(n)){let e=this.nextCode();if(isDigit(e)&&this.eatCode($.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint($.DIGIT_0,t,n,e)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`}return this.moveAt(e),this.reportParseError(`invalid-leading-zero`)}this.moveAt(e)}return e=this.nextCode(),e===$.LATIN_SMALL_X||e===$.LATIN_SMALL_O||e===$.LATIN_SMALL_B?n===$.NULL?e===$.LATIN_SMALL_X?`HEX`:e===$.LATIN_SMALL_O?`OCTAL`:`BINARY`:this.reportParseError(`unexpected-char`):e===$.LATIN_SMALL_E||e===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:[$.DIGIT_0]},`EXPONENT_RIGHT`):e===$.DOT?(this.data={minus:n===$.DASH,absInt:[$.DIGIT_0]},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,`0`,10),this.back(`DATA`))}let{out:r,nextCp:i,hasUnderscore:a}=this.parseDigits(e,isDigit);return i===$.DASH&&n===$.NULL&&!a&&r.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...r)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`):i===$.COLON&&n===$.NULL&&!a&&r.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...r)),minute:0,second:0},`TIME_MINUTE`):i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:r},`EXPONENT_RIGHT`):i===$.DOT?(this.data={minus:n===$.DASH,absInt:r},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,n===$.DASH?String.fromCodePoint($.DASH,...r):String.fromCodePoint(...r),10),this.back(`DATA`))}HEX(e){let{out:t}=this.parseDigits(e,isHexDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),16),this.back(`DATA`)}OCTAL(e){let{out:t}=this.parseDigits(e,isOctalDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),8),this.back(`DATA`)}BINARY(e){let{out:t}=this.parseDigits(e,e=>e===$.DIGIT_0||e===$.DIGIT_1);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),2),this.back(`DATA`)}FRACTIONAL_RIGHT(e){let{minus:t,absInt:n}=this.data,{out:r,nextCp:i}=this.parseDigits(e,isDigit),a=[...n,$.DOT,...r];if(i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E)return this.data={minus:t,left:a},`EXPONENT_RIGHT`;let o=Number(t?String.fromCodePoint($.DASH,...a):String.fromCodePoint(...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}EXPONENT_RIGHT(e){let{left:t,minus:n}=this.data,r=!1;(e===$.DASH||e===$.PLUS_SIGN)&&(r=e===$.DASH,e=this.nextCode());let{out:i}=this.parseDigits(e,isDigit),a=i;r&&a.unshift($.DASH);let o=Number(n?String.fromCodePoint($.DASH,...t,$.LATIN_SMALL_E,...a):String.fromCodePoint(...t,$.LATIN_SMALL_E,...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}BOOLEAN(e){if(e===$.LATIN_SMALL_T){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_R)&&this.eatCode($.LATIN_SMALL_U)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!0),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_F){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_L)&&this.eatCode($.LATIN_SMALL_S)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!1),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}DATE_MONTH(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.DASH))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.month=Number(this.text.slice(t,n)),`DATE_DAY`}DATE_DAY(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;if(r.day=Number(this.text.slice(t,n)),!isValidDate(r.year,r.month,r.day))return this.reportParseError(`invalid-date`);if(e=this.nextCode(),e===$.LATIN_CAPITAL_T||e===$.LATIN_SMALL_T)return`TIME_HOUR`;if(e===$.SPACE){let e=this.codePointIterator.start;if(isDigit(this.nextCode())&&isDigit(this.nextCode()))return this.moveAt(e),`TIME_HOUR`;this.moveAt(e)}let i=getDateFromDateTimeData(r,``);return this.endToken(`LocalDate`,`start`,i),this.back(`DATA`)}TIME_HOUR(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.hour=Number(this.text.slice(t,n)),`TIME_MINUTE`}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.minute=Number(this.text.slice(t,n)),e=this.nextCode(),e===$.COLON?`TIME_SECOND`:this.tomlVersion.lt(1,1)?this.reportParseError(`unexpected-char`):isValidTime(r.hour,r.minute,r.second)?this.processTimeEnd(e,r):this.reportParseError(`invalid-time`)}TIME_SECOND(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.second=Number(this.text.slice(t,n)),isValidTime(r.hour,r.minute,r.second)?(e=this.nextCode(),e===$.DOT?`TIME_SEC_FRAC`:this.processTimeEnd(e,r)):this.reportParseError(`invalid-time`)}TIME_SEC_FRAC(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;for(;isDigit(e);)e=this.nextCode();let n=this.codePointIterator.start,r=this.data;return r.frac=this.text.slice(t,n),this.processTimeEnd(e,r)}processTimeEnd(e,t){if(t.hasDate){if(e===$.DASH||e===$.PLUS_SIGN)return t.offsetSign=e,`TIME_OFFSET`;if(e===$.LATIN_CAPITAL_Z||e===$.LATIN_SMALL_Z){let e=getDateFromDateTimeData(t,`Z`);return this.endToken(`OffsetDateTime`,`end`,e),`DATA`}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalDateTime`,`start`,n),this.back(`DATA`)}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalTime`,`start`,n),this.back(`DATA`)}TIME_OFFSET(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;if(e=this.nextCode(),!isDigit(e)||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start;e=this.nextCode();let r=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let i=this.codePointIterator.end,a=Number(this.text.slice(t,n)),o=Number(this.text.slice(r,i));if(!isValidTime(a,o,0))return this.reportParseError(`invalid-time`);let s=this.data,c=getDateFromDateTimeData(s,`${String.fromCodePoint(s.offsetSign)}${padStart(a,2)}:${padStart(o,2)}`);return this.endToken(`OffsetDateTime`,`end`,c),`DATA`}parseDigits(e,t){if(e===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`);if(!t(e))return this.reportParseError(`unexpected-char`);let n=[],r=$.NULL,i=!1;for(;t(e)||e===$.UNDERSCORE;){if(e===$.UNDERSCORE){if(i=!0,r===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`)}else n.push(e);r=e,e=this.nextCode()}return r===$.UNDERSCORE?this.reportParseError(`invalid-underscore`):{out:n,nextCp:e,hasUnderscore:i}}parseUnicode(e){let t=this.codePointIterator.start,n=this.codePointIterator.end,r=0,i;for(;(i=this.nextCode())!==$.EOF;){if(!isHexDig(i))return this.moveAt(t),this.reportParseError(`invalid-char-in-escape-sequence`);if(r++,r>=e)break}let a=this.codePointIterator.end,o=this.text.slice(n,a),s=parseInt(o,16);return isUnicodeScalarValue(s)?s:this.reportParseError(`invalid-code-point`,{cp:o})}reportParseErrorControlChar(){return this.reportParseError(`invalid-control-character`)}};function isUnquotedKeyChar(e,t){return isLetter(e)||isDigit(e)||e===$.UNDERSCORE||e===$.DASH?!0:(t.lt(1,1),!1)}function isControlOtherThanTab(e){return isControl(e)&&e!==$.TABULATION||e===$.DELETE}function isNonEOL(e){return e===$.TABULATION||$.SPACE<=e&&e<=$.TILDE||isNonAscii(e)}function isNonAscii(e){return $.PAD<=e&&e<=$.CP_D7FF||$.CP_E000<=e&&e<=$.CP_10FFFF}function isValidDate(e,t,n){return e>=0&&t<=12&&t>=1&&n>=1&&n<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1))}function isValidTime(e,t,n){return!(e>=24||e<0||t>59||t<0||n>60||n<0)}function getDateFromDateTimeData(e,t){let n=padStart(e.year,4),r=e.month?padStart(e.month,2):`01`,i=e.day?padStart(e.day,2):`01`,a=padStart(e.hour,2),o=padStart(e.minute,2),s=padStart(e.second,2),c=`${n}-${r}-${i}`,l=e.frac?`.${e.frac}`:``,u=new Date(`${c}T${a}:${o}:${s}${l}${t}`);return!isNaN(u.getTime())||e.second!==60?u:new Date(`${c}T${a}:${o}:59${l}${t}`)}function padStart(e,t){return String(e).padStart(t,`0`)}const Cc=Symbol(`VALUE_KIND_VALUE`),wc=Symbol(`VALUE_KIND_INTERMEDIATE`);var KeysResolver=class{constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,n=e.key.keys.length-1;for(let r=0;r<n;r++){let n=e.key.keys[r],i=toKeyName(n);e.resolvedKey.push(i);let a=t.get(i);if(!a)a={node:n,keys:new Map},t.set(i,a);else if(a.table===`array`){let t=a.peekIndex;e.resolvedKey.push(t),a=a.keys.get(t)}t=a.keys}let r=e.key.keys[n],i=toKeyName(r);e.resolvedKey.push(i);let a=t.get(i);if(!a){if(e.kind===`array`){e.resolvedKey.push(0);let n={node:r,keys:new Map};t.set(i,{table:e.kind,node:r,keys:new Map([[0,n]]),peekIndex:0}),this.tables.push({node:e,keys:n.keys})}else{let n={table:e.kind,node:r,keys:new Map};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(!a.table){if(e.kind===`array`)this.ctx.reportParseError(`dupe-keys`,r);else{let n={table:e.kind,node:r,keys:a.keys};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(a.table===`array`){if(e.kind===`array`){let t={node:r,keys:new Map},n=a.peekIndex+1;e.resolvedKey.push(n),a.keys.set(n,t),a.peekIndex=n,this.tables.push({node:e,keys:t.keys})}else this.ctx.reportParseError(`dupe-keys`,r)}else this.ctx.reportParseError(`dupe-keys`,r)}verifyDuplicateKeys(e){for(let t of e.body)t.type===`TOMLKeyValue`&&verifyDuplicateKeysForKeyValue(this.ctx,this.rootKeys,t);for(let{node:e,keys:t}of this.tables)for(let n of e.body)verifyDuplicateKeysForKeyValue(this.ctx,t,n)}};function verifyDuplicateKeysForKeyValue(e,t,n){let r=t,i=last(n.key.keys);for(let t of n.key.keys){let n=toKeyName(t),a=r.get(n);a?((a.value===Cc||i===t||a.table)&&e.reportParseError(`dupe-keys`,getAfterNode(t,a.node)),a.value=wc):(a=i===t?{value:Cc,node:t,keys:new Map}:{value:wc,node:t,keys:new Map},r.set(n,a)),r=a.keys}n.value.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,r,n.value):n.value.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,r,n.value)}function verifyDuplicateKeysForInlineTable(e,t,n){for(let r of n.body)verifyDuplicateKeysForKeyValue(e,t,r)}function verifyDuplicateKeysForArray(e,t,n){let r=t;for(let i=0;i<n.elements.length;i++){let a=n.elements[i],o=r.get(i);o?e.reportParseError(`dupe-keys`,getAfterNode(a,o.node)):(o={value:Cc,node:a,keys:new Map},t.set(i,o),a.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,o.keys,a):a.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,o.keys,a))}}function getAfterNode(e,t){return e.range[0]<=t.range[0]?t:e}var Context=class{constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Tokenizer(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new KeysResolver(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken){if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError(`missing-newline`,this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let n=this.tokenizer.nextToken();for(;n&&n.type===`Block`;)this.comments.push(n),n=this.tokenizer.nextToken();return n&&this.tokens.push(n),this.tokenizer.valuesEnabled=t,n}backToken(){if(this.back)throw Error(`Illegal state`);this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let n,r,i;if(t)n=t.range[0],r=t.loc.start.line,i=t.loc.start.column;else{n=this.tokenizer.start;let e=this.tokenizer.getLocFromIndex(n);r=e.line,i=e.column}throw new ParseError(e,n,r,i)}};const Tc={VALUE:`missing-value`},Ec={BasicString:`basic`,MultiLineBasicString:`basic`,LiteralString:`literal`,MultiLineLiteralString:`literal`},Dc={BasicString:`basic`,LiteralString:`literal`},Oc={OffsetDateTime:`offset-date-time`,LocalDateTime:`local-date-time`,LocalDate:`local-date`,LocalTime:`local-time`};var TOMLParser=class{constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion)}parse(){let e={type:`Program`,body:[],sourceType:`module`,tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:`TOMLTopLevelTable`,body:[],parent:e,range:cloneRange(e.range),loc:cloneLoc(e.loc)};e.body=[t];let n=new Context({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),r=n.nextToken();if(r){for(t.range[0]=r.range[0],t.loc.start=clonePos(r.loc.start);r;){let e=n.stateStack.pop()||`TABLE`;n.stateStack.push(...this[e](r,n)),r=n.nextToken()}let e=n.stateStack.pop()||`TABLE`;if(e in Tc)return n.reportParseError(Tc[e],null);n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),applyEndLoc(t,last(t.body))}n.verifyDuplicateKeys(),e.tokens=n.tokens,e.comments=n.comments;let i=n.tokenizer.end,a=n.tokenizer.getLocFromIndex(i);return e.range[1]=i,e.loc.end={line:a.line,column:a.column},e}TABLE(e,t){return isBare(e)||isString(e)?this.processKeyValue(e,t.table,t):isLeftBracket(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError(`unexpected-token`,e)}VALUE(e,t){return isString(e)||isMultiLineString(e)?this.processStringValue(e,t):isNumber(e)?this.processNumberValue(e,t):isBoolean(e)?this.processBooleanValue(e,t):isDateTime(e)?this.processDateTimeValue(e,t):isLeftBracket(e)?this.processArray(e,t):isLeftBrace(e)?this.processInlineTable(e,t):t.reportParseError(`unexpected-token`,e)}processTable(e,t,n){let r={type:`TOMLTable`,kind:`standard`,key:null,resolvedKey:[],body:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),t.body.push(r),n.table=r;let i=n.nextToken({needSameLine:`invalid-key-value-newline`});if(isLeftBracket(i)){if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i);r.kind=`array`,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}if(isRightBracket(i))return n.reportParseError(`missing-key`,i);if(!i)return n.reportParseError(`unterminated-table-key`,null);if(i=this.processKeyNode(i,r,n).nextToken,!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(r.kind===`array`){let e=i;if(i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i)}return applyEndLoc(r,i),n.applyResolveKeyForTable(r),n.needNewLine=!0,[]}processKeyValue(e,t,n){let r={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(r);let{nextToken:i}=this.processKeyNode(e,r,n);return isEq(i)?(n.addValueContainer({parent:r,set:e=>(r.value=e,applyEndLoc(r,e),n.needNewLine=!0,[])}),n.needSameLine=`invalid-key-value-newline`,[`VALUE`]):n.reportParseError(`missing-equals-sign`,i)}processKeyNode(e,t,n){isDot(e)&&n.reportParseError(`invalid-leading-dot-in-key`,e);let r={type:`TOMLKey`,keys:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.key=r;let i=e,a=null;do{if(isBare(i))this.processBareKey(i,r);else if(isString(i))this.processStringKey(i,r);else break;if(a=null,i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isDot(i))break;a=i,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}while(i);return a&&n.reportParseError(isDot(i)?`invalid-consecutive-dots-in-key`:`invalid-trailing-dot-in-key`,a),applyEndLoc(r,last(r.keys)),{keyNode:r,nextToken:i}}processBareKey(e,t){let n={type:`TOMLBare`,name:e.value,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringKey(e,t){let n={type:`TOMLQuoted`,kind:`string`,value:e.string,style:Dc[e.type],multiline:!1,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`string`,value:e.string,style:Ec[e.type],multiline:isMultiLineString(e),parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processNumberValue(e,t){let n=t.consumeValueContainer(),r=this.text,[i,a]=e.range,o=null,getNumberText=()=>o??=r.slice(i,a).replace(/_/g,``),s;return s=e.type===`Integer`?{type:`TOMLValue`,kind:`integer`,value:e.number,bigint:e.bigint,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)}:{type:`TOMLValue`,kind:`float`,value:e.number,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},n.set(s)}processBooleanValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`boolean`,value:e.boolean,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processDateTimeValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:Oc[e.type],value:e.date,datetime:e.value,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processArray(e,t){let n=t.consumeValueContainer(),r={type:`TOMLArray`,elements:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=t.nextToken({valuesEnabled:!0});return isRightBracket(i)?(applyEndLoc(r,i),n.set(r)):(t.backToken(),this.processArrayValue(r,n,t))}processArrayValue(e,t,n){return n.addValueContainer({parent:e,set:r=>{e.elements.push(r);let i=n.nextToken({valuesEnabled:!0}),a=isComma(i);return a&&(i=n.nextToken({valuesEnabled:!0})),isRightBracket(i)?(applyEndLoc(e,i),t.set(e)):a?(n.backToken(),this.processArrayValue(e,t,n)):n.reportParseError(i?`missing-comma`:`unterminated-array`,i)}}),[`VALUE`]}processInlineTable(e,t){let n=t.consumeValueContainer(),r={type:`TOMLInlineTable`,body:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`,a=t.nextToken({needSameLine:i});if(a){if(isBare(a)||isString(a))return this.processInlineTableKeyValue(a,r,n,t);if(isRightBrace(a))return applyEndLoc(r,a),n.set(r)}return t.reportParseError(`unexpected-token`,a)}processInlineTableKeyValue(e,t,n,r){let i={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(i);let{nextToken:a}=this.processKeyNode(e,i,r);if(!isEq(a))return r.reportParseError(`missing-equals-sign`,a);let o=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`;return r.addValueContainer({parent:i,set:e=>{i.value=e,applyEndLoc(i,e);let a=r.nextToken({needSameLine:o});if(isComma(a)){if(a=r.nextToken({needSameLine:o}),a&&(isBare(a)||isString(a)))return this.processInlineTableKeyValue(a,t,n,r);if(isRightBrace(a)){if(this.tomlVersion.lt(1,1))return r.reportParseError(`invalid-trailing-comma-in-inline-table`,a)}else return r.reportParseError(a?`unexpected-token`:`unterminated-inline-table`,a)}return isRightBrace(a)?(applyEndLoc(t,a),n.set(t)):r.reportParseError(a?`missing-comma`:`unterminated-inline-table`,a)}}),r.needSameLine=`invalid-key-value-newline`,[`VALUE`]}};function isDot(e){return isPunctuator(e)&&e.value===`.`}function isEq(e){return isPunctuator(e)&&e.value===`=`}function isLeftBracket(e){return isPunctuator(e)&&e.value===`[`}function isRightBracket(e){return isPunctuator(e)&&e.value===`]`}function isLeftBrace(e){return isPunctuator(e)&&e.value===`{`}function isRightBrace(e){return isPunctuator(e)&&e.value===`}`}function isComma(e){return isPunctuator(e)&&e.value===`,`}function isPunctuator(e){return!!(e&&e.type===`Punctuator`)}function isBare(e){return e.type===`Bare`}function isString(e){return e.type===`BasicString`||e.type===`LiteralString`}function isMultiLineString(e){return e.type===`MultiLineBasicString`||e.type===`MultiLineLiteralString`}function isNumber(e){return e.type===`Integer`||e.type===`Float`}function isBoolean(e){return e.type===`Boolean`}function isDateTime(e){return e.type===`OffsetDateTime`||e.type===`LocalDateTime`||e.type===`LocalDate`||e.type===`LocalTime`}function applyEndLoc(e,t){t&&(e.range[1]=t.range[1],e.loc.end=clonePos(t.loc.end))}function cloneRange(e){return[e[0],e[1]]}function cloneLoc(e){return{start:clonePos(e.start),end:clonePos(e.end)}}function clonePos(e){return{line:e.line,column:e.column}}const kc=unionWith({Program:[`body`],TOMLTopLevelTable:[`body`],TOMLTable:[`key`,`body`],TOMLKeyValue:[`key`,`value`],TOMLKey:[`keys`],TOMLArray:[`elements`],TOMLInlineTable:[`body`],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]});function parseForESLint(e,t){return{ast:new TOMLParser(e,t).parse(),visitorKeys:kc,services:{isTOML:!0}}}function parseTOML(e,t){return parseForESLint(e,t).ast}function nested(e,t){return e.reduceRight((e,t)=>({[t]:e}),t)}function renderTomlTable(e,t){return stringify(nested(e,t))}function appendTomlTable(e,t,n){return`${e}${e===``||e.endsWith(`
|
|
411
|
+
`)}`);let forces=t=>o===!0||c.some(n=>namesTarget(e,t,n)),d=s.filter(({target:e})=>pathOccupied(e)&&!linksTo(e,n)).filter(({target:e})=>!forces(e));if(d.length&&c.length===0)throw Error(`Refusing to replace existing skill targets:\n${d.map(({target:t})=>`- ${S(e,t)}`).join(`
|
|
412
|
+
`)}`);let p=new Set(d.map(({harness:e})=>e.name));for(let{harness:e,target:r}of s)if(!p.has(e.name)&&(i(y(r),{recursive:!0}),!linksTo(r,n))){if(pathOccupied(r)&&l(r,{recursive:!0,force:!0}),a){t(n,r,{recursive:!0});continue}try{f(linkTarget(r,n),r,_()===`win32`?`junction`:void 0)}catch(e){if(pathOccupied(r))throw e;t(n,r,{recursive:!0})}}return{linked:s.filter(({harness:e})=>!p.has(e.name)).map(({harness:e})=>e.name),skipped:s.filter(({harness:e})=>p.has(e.name)).map(({harness:e})=>e.name)}}function isDirectory$1(e){try{return r(e).isDirectory()}catch{return!1}}__name(isDirectory$1,`isDirectory`);function exists$1(e){try{return r(e),!0}catch{return!1}}__name(exists$1,`exists`);function importsGlobal(e,t,n){let r=t.kind===`import`?[t.line,`@${b(n,jn)}`]:[];return e.split(`
|
|
413
|
+
`).some(e=>r.includes(e.trim()))}function base(e,t,n){let r=e.relocatedBy,i=r===void 0?void 0:t[r];return r===void 0||i===void 0?{}:i===``?e.emptyRelocatesToStart?{moved:{root:n,display:`.`},emptied:r}:{}:{moved:{root:C(i),display:`$${r}`}}}function locate(e,t,{moved:n},r){if(!n||r!==t.detect&&!r.startsWith(`${t.detect}/`))return{absolute:b(e,r),display:`~/${r}`};let i=r.slice(t.detect.length);return{absolute:b(n.root,i),display:`${n.display}${i}`}}function readsAsShadow(e){try{return d(e).isFile()&&a(e,`utf8`).trim()!==``}catch{return!1}}function inspect$2(e,t,n){let i;try{i=r(t)}catch{return{kind:`none`,status:`missing`,problem:`global-instructions-missing`}}if(i.isSymbolicLink())return C(y(t),s(t))===b(e,`.agents/AGENTS.md`)?{kind:`symlink`,status:`ok`}:{kind:`symlink`,status:`unbridged`,problem:`global-instructions-unbridged`};let o;try{o=a(t,`utf8`)}catch{return{kind:`file`,status:`unbridged`,problem:`global-instructions-unbridged`}}return importsGlobal(o,n,e)?{kind:`import`,status:`ok`}:{kind:`file`,status:`unbridged`,problem:`global-instructions-unbridged`}}__name(inspect$2,`inspect`);function finding(e,t,n){let{detail:r,repair:i}=repairFor(t);return{path:e,problem:t,detail:r,repair:i({file:e},n)}}function diagnoseGlobalInstructions(e,t,n,r={},i=process.cwd()){let a=exists$1(b(e,jn)),o=[],s=[];for(let c of V){let l=c.user,u=l?.instructionBridge;if(!l||!u)continue;let d=base(l,r,i);if(!t.includes(c.name)&&!isDirectory$1(locate(e,l,d,l.detect).absolute))continue;let f=locate(e,l,d,u.path),p=inspect$2(e,f.absolute,u),m=(l.shadowedBy??[]).map(t=>locate(e,l,d,t)).find(({absolute:e})=>readsAsShadow(e));if(m!==void 0){let t=inspect$2(e,m.absolute,u);if(t.status===`ok`){o.push({harness:c.name,path:m.display,kind:t.kind,status:`ok`});continue}o.push({harness:c.name,path:f.display,kind:p.kind,status:`overridden`}),a&&s.push(finding(m.display,`global-instructions-overridden`,n))}else o.push({harness:c.name,path:f.display,kind:p.kind,status:p.status});a&&d.emptied?s.push(finding(`$${d.emptied}`,`global-instructions-emptied`,n)):a&&p.problem&&s.push(finding(f.display,p.problem,n))}return{globalInstructions:o,findings:s}}const xr=new Set([`node_modules`]);function agentsFileDirectories(e){let t=[],walk=r=>{n(b(e,r,`AGENTS.md`))&&t.push(r);let i;try{i=o(b(e,r),{withFileTypes:!0})}catch{return}for(let e of i)!e.isDirectory()||e.name.startsWith(`.`)||xr.has(e.name)||walk(r?x.join(r,e.name):e.name)};return walk(``),t.sort()}const Sr=`AGENTS.md`;function valueAt(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}function exists(e){try{return r(e),!0}catch{return!1}}function inspectSettingsEntry(e,t){let n;try{n=a(e,`utf8`)}catch{return{kind:`none`,status:`missing`,problem:`instructions-missing`}}let r=parseJsonWithComments(n);if(r===void 0)return{kind:`file`,status:`unreadable`,problem:`instructions-unreadable`};let i=valueAt(r,t);return Array.isArray(i)&&i.includes(`AGENTS.md`)?{kind:`settings-entry`,status:`ok`}:{kind:`file`,status:`unbridged`,problem:`instructions-unbridged`}}function inspectShadow(e){let t;try{t=r(e)}catch{return}if(t.isSymbolicLink())return s(e)===`AGENTS.md`?{kind:`symlink`,status:`superseded`,problem:`instructions-superseded`}:{kind:`symlink`,status:`shadowing`,problem:`instructions-shadowing`};let n;try{n=a(e,`utf8`)}catch{return{kind:`file`,status:`unreadable`,problem:`instructions-unreadable`}}return n.split(`
|
|
414
|
+
`).some(e=>e.trim()===`@AGENTS.md`)?{kind:`import`,status:`superseded`,problem:`instructions-superseded`}:{kind:`file`,status:`shadowing`,problem:`instructions-shadowing`}}function diagnoseInstructions(e,t,n){let r=t.map(e=>({name:e.name,bridge:e.project.instructionBridge})).filter(e=>e.bridge?.kind===`settings-entry`),i=[],a=[],o=agentsFileDirectories(e),s=t.some(t=>(t.project.shadowedBy??[]).some(t=>exists(b(e,t))));if((r.length||s)&&!o.includes(``)){let{detail:e,repair:t}=repairFor(`no-instructions`);a.push({path:Sr,problem:`no-instructions`,detail:e,repair:t({file:Sr},n)})}for(let{name:t,bridge:o}of r){let r=inspectSettingsEntry(b(e,o.path),o.key);if(i.push({harness:t,path:o.path,kind:r.kind,status:r.status}),r.problem){let{detail:e,repair:t}=repairFor(r.problem);a.push({path:o.path,problem:r.problem,detail:e,repair:t({file:o.path},n)})}}for(let r of t)for(let t of r.project.shadowedBy??[])for(let s of o){let o=s?x.join(s,t):t,c=inspectShadow(b(e,o));if(!c)continue;i.push({harness:r.name,path:o,kind:c.kind,status:c.status});let{detail:l,repair:u}=repairFor(c.problem);a.push({path:o,problem:c.problem,detail:l,repair:u({file:o},n)})}return{instructions:i,findings:a}}function git(e,t,n){try{return ne(`git`,t,{cwd:e,encoding:`utf8`,...n===void 0?{}:{input:n},stdio:[`pipe`,`pipe`,`pipe`]})}catch{return}}function lines(e){return(e??``).split(`
|
|
415
|
+
`).filter(Boolean)}var GitBridgeState=class{root;repoRootPrefix;constructor(e){this.root=e,this.repoRootPrefix=git(e,[`rev-parse`,`--show-prefix`])?.trim()}trackingOf(e){if(this.repoRootPrefix===void 0)return`untracked`;let t=lines(git(this.root,[`ls-files`,`-v`,`--`,e]));return t.length?t.every(e=>e.startsWith(`S`))?`skip-worktree`:`tracked`:`untracked`}isIgnored(e){return this.repoRootPrefix!==void 0&&git(this.root,[`check-ignore`,`-q`,`--`,e])!==void 0}commitsTouching(e){return this.repoRootPrefix===void 0?[]:lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,...e]))}contentAt(e,t){if(this.repoRootPrefix!==void 0)return git(this.root,[`show`,`${e}:${this.repoRootPrefix}${t}`])}directionOf(e,t){if(this.repoRootPrefix===void 0)return`unknown`;let n=this.lastAgreedTree(e,t);if(n===void 0)return`unknown`;let r=!this.matchesTree(e,n),i=!this.matchesTree(t,n);return r&&i?`both`:r?`bridge`:`canonical`}lastAgreedTree(e,t){for(let n of lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,e,t]))){let r=git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${e}`])?.trim();if(r&&r===git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${t}`])?.trim())return r}}matchesTree(e,t){let n=new Map(lines(git(this.root,[`ls-tree`,`-r`,t])).map(e=>{let[t,n]=e.split(` `);return[n,t.split(` `)[2]]})),r=filesUnder(b(this.root,e));if(r.length!==n.size||r.some(e=>!n.has(e)))return!1;let i=lines(git(this.root,[`hash-object`,`--stdin-paths`],r.map(t=>b(e,t)).join(`
|
|
416
|
+
`)));return i.length===r.length&&r.every((e,t)=>n.get(e)===i[t])}};const Cr=`.agents/skills`;function pathState(e){try{let t=r(e);return t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`}catch{return`missing`}}function isDirectory(e){try{return d(e).isDirectory()}catch{return!1}}function sameContent(e,t){let n=filesUnder(e),r=filesUnder(t);return n.length===r.length&&n.every((n,i)=>r[i]===n&&a(b(e,n)).equals(a(b(t,n))))}function inspect$1(e,t,n,r){switch(pathState(e)){case`missing`:return{kind:`none`,status:`missing`,problem:`missing`};case`file`:return{kind:`file`,status:`degraded`,problem:`degraded`};case`symlink`:return linksTo(e,n)?{kind:`symlink`,status:`ok`}:{kind:`symlink`,status:`stale`,problem:`stale`};default:if(!sameContent(e,n)){let e=r.directionOf(t,Cr);return{kind:`copy`,status:`diverged`,problem:`diverged-${e}`,direction:e}}return r.trackingOf(t)===`tracked`?{kind:`copy`,status:`ok`,problem:`unpinned-copy`}:{kind:`copy`,status:`ok`}}}__name(inspect$1,`inspect`);function diagnoseBridges({root:e,harnesses:t=[],cli:n,home:r,env:i}){let a=b(e,`.agents`,`skills`),o=new GitBridgeState(e),s=selectHarnesses(e,t),c=s.map(e=>({name:e.name,skillsDirectory:e.project.skillsDirectory})).filter(e=>!!e.skillsDirectory),l=[],u=[],d=[];if(!isDirectory(a)){let{detail:e,repair:t}=repairFor(`no-canonical`);d.push({path:Cr,problem:`no-canonical`,detail:e,repair:t({file:Cr},n)})}for(let t of c){let r=t.skillsDirectory,i=inspect$1(b(e,r),r,a,o);if(l.push({harness:t.name,path:r,kind:i.kind,status:i.status}),i.direction&&u.push({path:r,direction:i.direction}),i.problem){let{detail:e,repair:t}=repairFor(i.problem);d.push({path:r,problem:i.problem,detail:e,repair:t({file:r},n)})}}let f=diagnoseInstructions(e,s,n);d.push(...f.findings);let p=r===void 0?{globalInstructions:[],findings:[]}:diagnoseGlobalInstructions(r,t,n,i,e);return d.push(...p.findings),{bridges:l,instructions:f.instructions,globalInstructions:p.globalInstructions,divergence:u,findings:d}}function buildDoctorReport(e,t,n=[],r=[]){let i=[...t.findings,...n],a=r.length?r:`0 references — no layer outside the plugin tier holds one`;if(!i.length){let n=t.bridges.length+t.instructions.length,r=n===1?`the 1 bridge resolves`:`all ${n} bridges resolve`;return{bin:e,bridges:t.bridges,instructions:t.instructions,globalInstructions:t.globalInstructions,references:a,findings:`0 problems found — ${r} and the configuration around them is current`}}return{bin:e,bridges:t.bridges,instructions:t.instructions,globalInstructions:t.globalInstructions,references:a,...t.divergence.length?{divergence:t.divergence}:{},findings:i.map(({path:e,problem:t,detail:n})=>({path:e,problem:t,detail:n})),help:[...new Map(i.map(e=>[`${e.repair.command}\u0000${e.repair.instruction}`,e.repair])).values()]}}const wr=command({name:`doctor`,description:`Report whether this repository's harness bridges still resolve — skills into .agents/skills, instructions into AGENTS.md — and whether each harness's user-scope file loads ~/.agents/AGENTS.md. Read-only.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:k.string().optional()},harness:{description:`Comma-separated harnesses to check in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:k.string().optional()}},async run(e){try{let t=parseHarnesses(e.harness),n=e.root??process.cwd(),r=g(),i=diagnoseBridges({root:n,...t.length?{harnesses:t}:{},cli:H,home:r,env:process.env}),a=new GitBridgeState(n),o=[...diagnoseConfiguration({root:n,git:a,cli:H}),...diagnoseMcp({root:n,git:a,cli:H}),...diagnoseNonstandard({root:n,cli:H})],{layers:s}=listReferences(await referenceLayers({root:n,home:r,platform:process.platform,env:process.env})),c=s.filter(({tier:e})=>e!==`plugin`).map(({name:e,tier:t,path:n,outcome:i})=>({name:e,tier:t,path:collapseHome$1(r,n),status:i}));return result(buildDoctorReport(displayBinPath(r,process.argv[1]),i,o,c))}catch(e){return fail$1(e,`Harness diagnosis failed.`)}}});function layersFor(e){let t=governanceLayers({root:e.root??process.cwd(),home:g(),platform:process.platform,programData:process.env.ProgramData});return e[`overrides-only`]?overrideLayers(t):t}const Tr=`warning: "governance" is deprecated and will be removed in the next major version; use "reference show|list" instead.
|
|
417
|
+
`,Er={description:`Repository or package directory. Defaults to the current directory.`,type:k.string().optional()},Dr={description:`Resolve only the project, user, and machine-wide layers. Never returns a governance this package ships, and exits non-zero when no layer has one.`,type:k.boolean().optional()},Or=command({name:`governance`,description:"Deprecated: use `reference`. Read the governance documents the project, user, and machine-wide override layers hold. Read-only.",commands:[command({name:`list`,description:`List every governance the override layers hold, each at the layer that would win.`,options:{root:Er,"overrides-only":Dr},run(e){process.stderr.write(Tr);try{let t=g(),n=layersFor(e),r=listGovernances(n);return result({layers:n.map(({scope:e,dir:n})=>({scope:e,path:collapseHome$1(t,n),status:e===`managed-deprecated`?`deprecated — move these documents to the managed layer above`:``})),governances:r.length?r.map(({name:e,scope:n,path:r})=>({name:e,scope:n,path:collapseHome$1(t,r)})):`0 governances — no layer holds one`})}catch(e){return fail$1(e,`Governance listing failed.`)}}}),command({name:`show`,description:`Print one governance document, resolved through the layers in order.`,arguments:[{name:`name`,description:"The governance name, without the `.md` extension.",type:k.string()}],options:{root:Er,"overrides-only":Dr},run(e){let t=this.format;process.stderr.write(Tr);try{let n=parseGovernanceName(e.name),r=resolveGovernance(n,layersFor(e));if(!r)throw process.stderr.write(e[`overrides-only`]?`error: no override for governance "${n}" in the project, user, or machine-wide layer.\n`:`error: no governance named "${n}" in any layer.\n`),O.reported(D.error);let i={name:r.name,scope:r.scope,path:collapseHome$1(g(),r.path),content:r.content};return t===`text`?document(i.content):result(i)}catch(e){return fail$1(e,`Governance lookup failed.`)}}})]});function initializeHarnesses({root:e,harnesses:t=[],copy:n=!1,force:r=!1}){let a=b(e,`.agents`,`skills`),o=countSkills(a);i(projectReferencesDir(e),{recursive:!0});let s=referenceNames([{tier:`project`,dir:projectReferencesDir(e)}]).length,c=selectHarnesses(e,t),{linked:l,skipped:u}=projectSkills({root:e,canonicalSkills:a,harnesses:c,copy:n,force:r});return{root:e,harnesses:c.map(e=>e.name),native:c.filter(e=>!e.project.skillsDirectory).map(e=>e.name),linked:l,skipped:u,deprecated:c.filter(e=>e.deprecated).map(e=>({name:e.name,replacedBy:e.deprecated})),skills:o,references:s,copied:n}}const kr=command({name:`init`,description:`Set up canonical agent skills for the harnesses already enabled in a repository.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:k.string().optional()},harness:{description:`Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:k.string().optional()},copy:{description:`Copy skills instead of linking them.`,type:k.boolean().optional()},force:{description:`Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.`,type:k.string().optional()}},run(e){try{let t=parseHarnesses(e.harness);return result(initializeHarnesses({root:e.root??process.cwd(),...t.length?{harnesses:t}:{},...e.copy===void 0?{}:{copy:e.copy},...e.force===void 0?{}:{force:parseForce(e.force)}}))}catch(e){return fail$1(e,`Harness initialization failed.`)}}}),Ar={ArrayExpression:[`elements`],ArrayPattern:[`elements`],ArrowFunctionExpression:[`params`,`body`],AssignmentExpression:[`left`,`right`],AssignmentPattern:[`left`,`right`],AwaitExpression:[`argument`],BinaryExpression:[`left`,`right`],BlockStatement:[`body`],BreakStatement:[`label`],CallExpression:[`callee`,`arguments`],CatchClause:[`param`,`body`],ChainExpression:[`expression`],ClassBody:[`body`],ClassDeclaration:[`id`,`superClass`,`body`],ClassExpression:[`id`,`superClass`,`body`],ConditionalExpression:[`test`,`consequent`,`alternate`],ContinueStatement:[`label`],DebuggerStatement:[],DoWhileStatement:[`body`,`test`],EmptyStatement:[],ExperimentalRestProperty:[`argument`],ExperimentalSpreadProperty:[`argument`],ExportAllDeclaration:[`exported`,`source`,`attributes`],ExportDefaultDeclaration:[`declaration`],ExportNamedDeclaration:[`declaration`,`specifiers`,`source`,`attributes`],ExportSpecifier:[`local`,`exported`],ExpressionStatement:[`expression`],ForInStatement:[`left`,`right`,`body`],ForOfStatement:[`left`,`right`,`body`],ForStatement:[`init`,`test`,`update`,`body`],FunctionDeclaration:[`id`,`params`,`body`],FunctionExpression:[`id`,`params`,`body`],Identifier:[],IfStatement:[`test`,`consequent`,`alternate`],ImportAttribute:[`key`,`value`],ImportDeclaration:[`specifiers`,`source`,`attributes`],ImportDefaultSpecifier:[`local`],ImportExpression:[`source`,`options`],ImportNamespaceSpecifier:[`local`],ImportSpecifier:[`imported`,`local`],JSXAttribute:[`name`,`value`],JSXClosingElement:[`name`],JSXClosingFragment:[],JSXElement:[`openingElement`,`children`,`closingElement`],JSXEmptyExpression:[],JSXExpressionContainer:[`expression`],JSXFragment:[`openingFragment`,`children`,`closingFragment`],JSXIdentifier:[],JSXMemberExpression:[`object`,`property`],JSXNamespacedName:[`namespace`,`name`],JSXOpeningElement:[`name`,`attributes`],JSXOpeningFragment:[],JSXSpreadAttribute:[`argument`],JSXSpreadChild:[`expression`],JSXText:[],LabeledStatement:[`label`,`body`],Literal:[],LogicalExpression:[`left`,`right`],MemberExpression:[`object`,`property`],MetaProperty:[`meta`,`property`],MethodDefinition:[`key`,`value`],NewExpression:[`callee`,`arguments`],ObjectExpression:[`properties`],ObjectPattern:[`properties`],PrivateIdentifier:[],Program:[`body`],Property:[`key`,`value`],PropertyDefinition:[`key`,`value`],RestElement:[`argument`],ReturnStatement:[`argument`],SequenceExpression:[`expressions`],SpreadElement:[`argument`],StaticBlock:[`body`],Super:[],SwitchCase:[`test`,`consequent`],SwitchStatement:[`discriminant`,`cases`],TaggedTemplateExpression:[`tag`,`quasi`],TemplateElement:[],TemplateLiteral:[`quasis`,`expressions`],ThisExpression:[],ThrowStatement:[`argument`],TryStatement:[`block`,`handler`,`finalizer`],UnaryExpression:[`argument`],UpdateExpression:[`argument`],VariableDeclaration:[`declarations`],VariableDeclarator:[`id`,`init`],WhileStatement:[`test`,`body`],WithStatement:[`object`,`body`],YieldExpression:[`argument`]},jr=Object.keys(Ar);for(let e of jr)Object.freeze(Ar[e]);Object.freeze(Ar);function unionWith(e){let t=Object.assign({},Ar);for(let n of Object.keys(e))if(Object.hasOwn(t,n)){let r=new Set(e[n]);for(let e of t[n])r.add(e);t[n]=Object.freeze(Array.from(r))}else t[n]=Object.freeze(Array.from(e[n]));return Object.freeze(t)}function last(e){return e[e.length-1]??null}function toKeyName(e){return e.type===`TOMLBare`?e.name:e.value}var TOMLVerImpl=class{constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}};const Mr=new TOMLVerImpl(1,0),Q=new TOMLVerImpl(1,1),Nr=Q,Pr={"1.0":Mr,"1.0.0":Mr,"1.1":Q,"1.1.0":Q,latest:Q,next:Q};function getTOMLVer(e){return e&&Pr[e]||Nr}const Fr={"unterminated-string":`Unterminated string constant`,"unterminated-table-key":`Unterminated table-key`,"unterminated-array":`Unterminated array`,"unterminated-inline-table":`Unterminated inline table`,"missing-key":`Empty bare keys are not allowed`,"missing-newline":`Must be a newline`,"missing-equals-sign":`Expected equal (=) token`,"missing-value":`Unspecified values are invalid`,"missing-comma":`Expected comma (,) token`,"dupe-keys":`Defining a key multiple times is invalid`,"unexpected-char":`Unexpected character`,"unexpected-token":`Unexpected token`,"invalid-control-character":`Control characters (codes < 0x1f and 0x7f) are not allowed`,"invalid-comment-character":`Invalid code point {{cp}} within comments`,"invalid-key-value-newline":`The key, equals sign, and value must be on the same line`,"invalid-inline-table-newline":`No newlines are allowed between the curly braces unless they are valid within a value`,"invalid-underscore":`Underscores are allowed between digits`,"invalid-space":`Unexpected spaces`,"invalid-three-quotes":`Three or more quotes are not permitted`,"invalid-date":`Unexpected invalid date`,"invalid-time":`Unexpected invalid time`,"invalid-leading-zero":`Leading zeros are not allowed`,"invalid-trailing-comma-in-inline-table":`Trailing comma is not permitted in an inline table`,"invalid-char-in-escape-sequence":`Invalid character in escape sequence`,"invalid-consecutive-dots-in-key":`Consecutive dots are not permitted in keys`,"invalid-code-point":`Invalid code point {{cp}}`,"invalid-trailing-dot-in-key":`Keys cannot end with a dot`,"invalid-leading-dot-in-key":`Keys cannot start with a dot`};function getMessage(e,t){return t?Fr[e].replace(/\{\{(.*?)\}\}/gu,(e,n)=>n in t?t[n]:`{{${n}}}`):Fr[e]}var ParseError=class extends SyntaxError{constructor(e,t,n,r,i){super(getMessage(e,i)),this.index=t,this.lineNumber=n,this.column=r}};const $={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function isControl(e){return e>=$.NULL&&e<=$.US}function isWhitespace(e){return e===$.TABULATION||e===$.SPACE}function isEOL(e){return e===$.LINE_FEED||e===$.CARRIAGE_RETURN}function isUpperLetter(e){return e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_Z}function isLowerLetter(e){return e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_Z}function isLetter(e){return isLowerLetter(e)||isUpperLetter(e)}function isDigit$1(e){return e>=$.DIGIT_0&&e<=$.DIGIT_9}__name(isDigit$1,`isDigit`);function isHexDig(e){return isDigit$1(e)||e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_F||e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_F}function isOctalDig(e){return e>=$.DIGIT_0&&e<=$.DIGIT_7}function isUnicodeScalarValue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function sortedLastIndex(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1,a=e[i];if(a===t)return i+1;a<t?n=i+1:r=i}return n}var Locations=class{constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let n=this.offsets[t];if(n===e)return;if(n<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=sortedLastIndex(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},CodePointIterator=class{constructor(e){this.locs=new Locations,this.lastCodePoint=$.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===$.EOF?$.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e&&(this.next(),!0)}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??$.EOF;if(t===$.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===$.LINE_FEED)this.locs.addOffset(this.end);else if(t===$.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===$.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),$.LINE_FEED;return t}};const Ir=typeof BigInt<`u`,Lr={16:`0x`,10:``,8:`0o`,2:`0b`},Rr={[$.QUOTATION_MARK]:$.QUOTATION_MARK,[$.BACKSLASH]:$.BACKSLASH,[$.LATIN_SMALL_B]:$.BACKSPACE,[$.LATIN_SMALL_F]:$.FORM_FEED,[$.LATIN_SMALL_N]:$.LINE_FEED,[$.LATIN_SMALL_R]:$.CARRIAGE_RETURN,[$.LATIN_SMALL_T]:$.TABULATION},zr={...Rr,[$.LATIN_SMALL_E]:$.ESCAPE};var Tokenizer=class{constructor(e,t){this.backCode=!1,this.lastCodePoint=$.NULL,this.state=`DATA`,this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new CodePointIterator(e),this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?zr:Rr}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let n=this.codePointIterator.start,r=this.codePointIterator.getLocFromIndex(n);throw new ParseError(e,n,r.line,r.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==$.EOF&&!this.token;){t=this.nextCode();let e=this[this.state](t);if(!e)throw Error(`Unknown error: pre state=${this.state}`);this.state=e}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===$.EOF?$.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===$.EOF?!1:this.backCode?this.lastCodePoint===e&&(this.backCode=!1,!0):this.codePointIterator.eat(e)}moveAt(e){this.backCode&&=!1,this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken(`Punctuator`,`end`)}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,n,r){let{tokenStart:i}=this,a=this.codePointIterator[t],o=[i,a],s={start:this.codePointIterator.getLocFromIndex(i),end:this.codePointIterator.getLocFromIndex(a)};if(e===`Block`)this.token={type:e,value:this.text.slice(i+1,a),range:o,loc:s};else{let t,c=this.text.slice(i,a);if(e===`BasicString`||e===`LiteralString`||e===`MultiLineBasicString`||e===`MultiLineLiteralString`)t={type:e,value:c,string:n,range:o,loc:s};else if(e===`Integer`){let i=n;t={type:e,value:c,number:parseInt(i,r),bigint:Ir?BigInt(Lr[r]+i):null,range:o,loc:s}}else t=e===`Float`?{type:e,value:c,number:n,range:o,loc:s}:e===`Boolean`?{type:e,value:c,boolean:n,range:o,loc:s}:e===`LocalDate`||e===`LocalTime`||e===`LocalDateTime`||e===`OffsetDateTime`?{type:e,value:c,date:n,range:o,loc:s}:{type:e,value:c,range:o,loc:s};this.token=t}}DATA(e){for(;isWhitespace(e)||isEOL(e);)e=this.nextCode();if(e===$.HASH)return this.startToken(),`COMMENT`;if(e===$.QUOTATION_MARK)return this.startToken(),`BASIC_STRING`;if(e===$.SINGLE_QUOTE)return this.startToken(),`LITERAL_STRING`;if(e===$.DOT||e===$.EQUALS_SIGN||e===$.LEFT_BRACKET||e===$.RIGHT_BRACKET||e===$.LEFT_BRACE||e===$.RIGHT_BRACE||e===$.COMMA)return this.punctuatorToken(),`DATA`;if(this.valuesEnabled){if(e===$.DASH||e===$.PLUS_SIGN)return this.startToken(),`SIGN`;if(e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I)return this.startToken(),this.back(`NAN_OR_INF`);if(isDigit$1(e))return this.startToken(),this.back(`NUMBER`);if(e===$.LATIN_SMALL_T||e===$.LATIN_SMALL_F)return this.startToken(),this.back(`BOOLEAN`)}else if(isUnquotedKeyChar(e,this.tomlVersion))return this.startToken(),`BARE`;return e===$.EOF?`DATA`:this.reportParseError(`unexpected-char`)}COMMENT(e){let t=this.tomlVersion.gte(1,1)?e=>{isNonEOL(e)||this.reportParseError(`invalid-comment-character`,{cp:JSON.stringify(String.fromCodePoint(e)).slice(1,-1)})}:e=>{isControlOtherThanTab(e)&&this.reportParseErrorControlChar()};for(;!isEOL(e)&&e!==$.EOF;)t(e),e=this.nextCode();return this.endToken(`Block`,`start`),`DATA`}BARE(e){for(;isUnquotedKeyChar(e,this.tomlVersion);)e=this.nextCode();return this.endToken(`Bare`,`start`),this.back(`DATA`)}BASIC_STRING(e){if(e===$.QUOTATION_MARK)return e=this.nextCode(),e===$.QUOTATION_MARK?`MULTI_LINE_BASIC_STRING`:(this.endToken(`BasicString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.QUOTATION_MARK&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return e===$.QUOTATION_MARK?(this.endToken(`BasicString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.QUOTATION_MARK){let e=this.codePointIterator.start;if(this.eatCode($.QUOTATION_MARK)&&this.eatCode($.QUOTATION_MARK))return this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineBasicString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}if(e===$.LINE_FEED){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}if(isWhitespace(e)){let t=!0,n=this.codePointIterator.start,r;for(;(r=this.nextCode())!==$.EOF&&r!==$.LINE_FEED;)if(!isWhitespace(r)){this.moveAt(n),t=!1;break}if(t){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}LITERAL_STRING(e){if(e===$.SINGLE_QUOTE)return e=this.nextCode(),e===$.SINGLE_QUOTE?`MULTI_LINE_LITERAL_STRING`:(this.endToken(`LiteralString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.SINGLE_QUOTE&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e===$.SINGLE_QUOTE?(this.endToken(`LiteralString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.SINGLE_QUOTE){let e=this.codePointIterator.start;if(this.eatCode($.SINGLE_QUOTE)&&this.eatCode($.SINGLE_QUOTE))return this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineLiteralString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}SIGN(e){return e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I?this.back(`NAN_OR_INF`):isDigit$1(e)?this.back(`NUMBER`):this.reportParseError(`unexpected-char`)}NAN_OR_INF(e){if(e===$.LATIN_SMALL_N){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_N))return this.endToken(`Float`,`end`,NaN),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_I){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_N)&&this.eatCode($.LATIN_SMALL_F))return this.endToken(`Float`,`end`,this.text[this.tokenStart]===`-`?-1/0:1/0),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}NUMBER(e){let t=this.text[this.tokenStart],n=t===`+`?$.PLUS_SIGN:t===`-`?$.DASH:$.NULL;if(e===$.DIGIT_0){if(n===$.NULL){let e=this.codePointIterator.start,t=this.nextCode();if(isDigit$1(t)){let n=this.nextCode();if(n===$.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint($.DIGIT_0,t)),minute:0,second:0},`TIME_MINUTE`;if(isDigit$1(n)){let e=this.nextCode();if(isDigit$1(e)&&this.eatCode($.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint($.DIGIT_0,t,n,e)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`}return this.moveAt(e),this.reportParseError(`invalid-leading-zero`)}this.moveAt(e)}return e=this.nextCode(),e===$.LATIN_SMALL_X||e===$.LATIN_SMALL_O||e===$.LATIN_SMALL_B?n===$.NULL?e===$.LATIN_SMALL_X?`HEX`:e===$.LATIN_SMALL_O?`OCTAL`:`BINARY`:this.reportParseError(`unexpected-char`):e===$.LATIN_SMALL_E||e===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:[$.DIGIT_0]},`EXPONENT_RIGHT`):e===$.DOT?(this.data={minus:n===$.DASH,absInt:[$.DIGIT_0]},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,`0`,10),this.back(`DATA`))}let{out:r,nextCp:i,hasUnderscore:a}=this.parseDigits(e,isDigit$1);return i===$.DASH&&n===$.NULL&&!a&&r.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...r)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`):i===$.COLON&&n===$.NULL&&!a&&r.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...r)),minute:0,second:0},`TIME_MINUTE`):i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:r},`EXPONENT_RIGHT`):i===$.DOT?(this.data={minus:n===$.DASH,absInt:r},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,n===$.DASH?String.fromCodePoint($.DASH,...r):String.fromCodePoint(...r),10),this.back(`DATA`))}HEX(e){let{out:t}=this.parseDigits(e,isHexDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),16),this.back(`DATA`)}OCTAL(e){let{out:t}=this.parseDigits(e,isOctalDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),8),this.back(`DATA`)}BINARY(e){let{out:t}=this.parseDigits(e,e=>e===$.DIGIT_0||e===$.DIGIT_1);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),2),this.back(`DATA`)}FRACTIONAL_RIGHT(e){let{minus:t,absInt:n}=this.data,{out:r,nextCp:i}=this.parseDigits(e,isDigit$1),a=[...n,$.DOT,...r];if(i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E)return this.data={minus:t,left:a},`EXPONENT_RIGHT`;let o=Number(t?String.fromCodePoint($.DASH,...a):String.fromCodePoint(...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}EXPONENT_RIGHT(e){let{left:t,minus:n}=this.data,r=!1;(e===$.DASH||e===$.PLUS_SIGN)&&(r=e===$.DASH,e=this.nextCode());let{out:i}=this.parseDigits(e,isDigit$1),a=i;r&&a.unshift($.DASH);let o=Number(n?String.fromCodePoint($.DASH,...t,$.LATIN_SMALL_E,...a):String.fromCodePoint(...t,$.LATIN_SMALL_E,...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}BOOLEAN(e){if(e===$.LATIN_SMALL_T){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_R)&&this.eatCode($.LATIN_SMALL_U)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!0),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_F){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_L)&&this.eatCode($.LATIN_SMALL_S)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!1),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}DATE_MONTH(e){let t=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e))||(e=this.nextCode(),e!==$.DASH))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.month=Number(this.text.slice(t,n)),`DATE_DAY`}DATE_DAY(e){let t=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;if(r.day=Number(this.text.slice(t,n)),!isValidDate(r.year,r.month,r.day))return this.reportParseError(`invalid-date`);if(e=this.nextCode(),e===$.LATIN_CAPITAL_T||e===$.LATIN_SMALL_T)return`TIME_HOUR`;if(e===$.SPACE){let e=this.codePointIterator.start;if(isDigit$1(this.nextCode())&&isDigit$1(this.nextCode()))return this.moveAt(e),`TIME_HOUR`;this.moveAt(e)}let i=getDateFromDateTimeData(r,``);return this.endToken(`LocalDate`,`start`,i),this.back(`DATA`)}TIME_HOUR(e){let t=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e))||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.hour=Number(this.text.slice(t,n)),`TIME_MINUTE`}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.minute=Number(this.text.slice(t,n)),e=this.nextCode(),e===$.COLON?`TIME_SECOND`:this.tomlVersion.lt(1,1)?this.reportParseError(`unexpected-char`):isValidTime(r.hour,r.minute,r.second)?this.processTimeEnd(e,r):this.reportParseError(`invalid-time`)}TIME_SECOND(e){let t=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.second=Number(this.text.slice(t,n)),isValidTime(r.hour,r.minute,r.second)?(e=this.nextCode(),e===$.DOT?`TIME_SEC_FRAC`:this.processTimeEnd(e,r)):this.reportParseError(`invalid-time`)}TIME_SEC_FRAC(e){if(!isDigit$1(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;for(;isDigit$1(e);)e=this.nextCode();let n=this.codePointIterator.start,r=this.data;return r.frac=this.text.slice(t,n),this.processTimeEnd(e,r)}processTimeEnd(e,t){if(t.hasDate){if(e===$.DASH||e===$.PLUS_SIGN)return t.offsetSign=e,`TIME_OFFSET`;if(e===$.LATIN_CAPITAL_Z||e===$.LATIN_SMALL_Z){let e=getDateFromDateTimeData(t,`Z`);return this.endToken(`OffsetDateTime`,`end`,e),`DATA`}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalDateTime`,`start`,n),this.back(`DATA`)}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalTime`,`start`,n),this.back(`DATA`)}TIME_OFFSET(e){if(!isDigit$1(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;if(e=this.nextCode(),!isDigit$1(e)||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start;e=this.nextCode();let r=this.codePointIterator.start;if(!isDigit$1(e)||(e=this.nextCode(),!isDigit$1(e)))return this.reportParseError(`unexpected-char`);let i=this.codePointIterator.end,a=Number(this.text.slice(t,n)),o=Number(this.text.slice(r,i));if(!isValidTime(a,o,0))return this.reportParseError(`invalid-time`);let s=this.data,c=getDateFromDateTimeData(s,`${String.fromCodePoint(s.offsetSign)}${padStart(a,2)}:${padStart(o,2)}`);return this.endToken(`OffsetDateTime`,`end`,c),`DATA`}parseDigits(e,t){if(e===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`);if(!t(e))return this.reportParseError(`unexpected-char`);let n=[],r=$.NULL,i=!1;for(;t(e)||e===$.UNDERSCORE;){if(e===$.UNDERSCORE){if(i=!0,r===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`)}else n.push(e);r=e,e=this.nextCode()}return r===$.UNDERSCORE?this.reportParseError(`invalid-underscore`):{out:n,nextCp:e,hasUnderscore:i}}parseUnicode(e){let t=this.codePointIterator.start,n=this.codePointIterator.end,r=0,i;for(;(i=this.nextCode())!==$.EOF;){if(!isHexDig(i))return this.moveAt(t),this.reportParseError(`invalid-char-in-escape-sequence`);if(r++,r>=e)break}let a=this.codePointIterator.end,o=this.text.slice(n,a),s=parseInt(o,16);return isUnicodeScalarValue(s)?s:this.reportParseError(`invalid-code-point`,{cp:o})}reportParseErrorControlChar(){return this.reportParseError(`invalid-control-character`)}};function isUnquotedKeyChar(e,t){return isLetter(e)||isDigit$1(e)||e===$.UNDERSCORE||e===$.DASH?!0:(t.lt(1,1),!1)}function isControlOtherThanTab(e){return isControl(e)&&e!==$.TABULATION||e===$.DELETE}function isNonEOL(e){return e===$.TABULATION||$.SPACE<=e&&e<=$.TILDE||isNonAscii(e)}function isNonAscii(e){return $.PAD<=e&&e<=$.CP_D7FF||$.CP_E000<=e&&e<=$.CP_10FFFF}function isValidDate(e,t,n){return e>=0&&t<=12&&t>=1&&n>=1&&n<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1))}function isValidTime(e,t,n){return!(e>=24||e<0||t>59||t<0||n>60||n<0)}function getDateFromDateTimeData(e,t){let n=padStart(e.year,4),r=e.month?padStart(e.month,2):`01`,i=e.day?padStart(e.day,2):`01`,a=padStart(e.hour,2),o=padStart(e.minute,2),s=padStart(e.second,2),c=`${n}-${r}-${i}`,l=e.frac?`.${e.frac}`:``,u=new Date(`${c}T${a}:${o}:${s}${l}${t}`);return!isNaN(u.getTime())||e.second!==60?u:new Date(`${c}T${a}:${o}:59${l}${t}`)}function padStart(e,t){return String(e).padStart(t,`0`)}const Br=Symbol(`VALUE_KIND_VALUE`),Vr=Symbol(`VALUE_KIND_INTERMEDIATE`);var KeysResolver=class{constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,n=e.key.keys.length-1;for(let r=0;r<n;r++){let n=e.key.keys[r],i=toKeyName(n);e.resolvedKey.push(i);let a=t.get(i);if(!a)a={node:n,keys:new Map},t.set(i,a);else if(a.table===`array`){let t=a.peekIndex;e.resolvedKey.push(t),a=a.keys.get(t)}t=a.keys}let r=e.key.keys[n],i=toKeyName(r);e.resolvedKey.push(i);let a=t.get(i);if(!a){if(e.kind===`array`){e.resolvedKey.push(0);let n={node:r,keys:new Map};t.set(i,{table:e.kind,node:r,keys:new Map([[0,n]]),peekIndex:0}),this.tables.push({node:e,keys:n.keys})}else{let n={table:e.kind,node:r,keys:new Map};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(!a.table){if(e.kind===`array`)this.ctx.reportParseError(`dupe-keys`,r);else{let n={table:e.kind,node:r,keys:a.keys};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(a.table===`array`){if(e.kind===`array`){let t={node:r,keys:new Map},n=a.peekIndex+1;e.resolvedKey.push(n),a.keys.set(n,t),a.peekIndex=n,this.tables.push({node:e,keys:t.keys})}else this.ctx.reportParseError(`dupe-keys`,r)}else this.ctx.reportParseError(`dupe-keys`,r)}verifyDuplicateKeys(e){for(let t of e.body)t.type===`TOMLKeyValue`&&verifyDuplicateKeysForKeyValue(this.ctx,this.rootKeys,t);for(let{node:e,keys:t}of this.tables)for(let n of e.body)verifyDuplicateKeysForKeyValue(this.ctx,t,n)}};function verifyDuplicateKeysForKeyValue(e,t,n){let r=t,i=last(n.key.keys);for(let t of n.key.keys){let n=toKeyName(t),a=r.get(n);a?((a.value===Br||i===t||a.table)&&e.reportParseError(`dupe-keys`,getAfterNode(t,a.node)),a.value=Vr):(a=i===t?{value:Br,node:t,keys:new Map}:{value:Vr,node:t,keys:new Map},r.set(n,a)),r=a.keys}n.value.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,r,n.value):n.value.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,r,n.value)}function verifyDuplicateKeysForInlineTable(e,t,n){for(let r of n.body)verifyDuplicateKeysForKeyValue(e,t,r)}function verifyDuplicateKeysForArray(e,t,n){let r=t;for(let i=0;i<n.elements.length;i++){let a=n.elements[i],o=r.get(i);o?e.reportParseError(`dupe-keys`,getAfterNode(a,o.node)):(o={value:Br,node:a,keys:new Map},t.set(i,o),a.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,o.keys,a):a.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,o.keys,a))}}function getAfterNode(e,t){return e.range[0]<=t.range[0]?t:e}var Context=class{constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Tokenizer(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new KeysResolver(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken){if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError(`missing-newline`,this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let n=this.tokenizer.nextToken();for(;n&&n.type===`Block`;)this.comments.push(n),n=this.tokenizer.nextToken();return n&&this.tokens.push(n),this.tokenizer.valuesEnabled=t,n}backToken(){if(this.back)throw Error(`Illegal state`);this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let n,r,i;if(t)n=t.range[0],r=t.loc.start.line,i=t.loc.start.column;else{n=this.tokenizer.start;let e=this.tokenizer.getLocFromIndex(n);r=e.line,i=e.column}throw new ParseError(e,n,r,i)}};const Hr={VALUE:`missing-value`},Ur={BasicString:`basic`,MultiLineBasicString:`basic`,LiteralString:`literal`,MultiLineLiteralString:`literal`},Wr={BasicString:`basic`,LiteralString:`literal`},Gr={OffsetDateTime:`offset-date-time`,LocalDateTime:`local-date-time`,LocalDate:`local-date`,LocalTime:`local-time`};var TOMLParser=class{constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion)}parse(){let e={type:`Program`,body:[],sourceType:`module`,tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:`TOMLTopLevelTable`,body:[],parent:e,range:cloneRange(e.range),loc:cloneLoc(e.loc)};e.body=[t];let n=new Context({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),r=n.nextToken();if(r){for(t.range[0]=r.range[0],t.loc.start=clonePos(r.loc.start);r;){let e=n.stateStack.pop()||`TABLE`;n.stateStack.push(...this[e](r,n)),r=n.nextToken()}let e=n.stateStack.pop()||`TABLE`;if(e in Hr)return n.reportParseError(Hr[e],null);n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),applyEndLoc(t,last(t.body))}n.verifyDuplicateKeys(),e.tokens=n.tokens,e.comments=n.comments;let i=n.tokenizer.end,a=n.tokenizer.getLocFromIndex(i);return e.range[1]=i,e.loc.end={line:a.line,column:a.column},e}TABLE(e,t){return isBare(e)||isString(e)?this.processKeyValue(e,t.table,t):isLeftBracket(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError(`unexpected-token`,e)}VALUE(e,t){return isString(e)||isMultiLineString(e)?this.processStringValue(e,t):isNumber(e)?this.processNumberValue(e,t):isBoolean(e)?this.processBooleanValue(e,t):isDateTime(e)?this.processDateTimeValue(e,t):isLeftBracket(e)?this.processArray(e,t):isLeftBrace(e)?this.processInlineTable(e,t):t.reportParseError(`unexpected-token`,e)}processTable(e,t,n){let r={type:`TOMLTable`,kind:`standard`,key:null,resolvedKey:[],body:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),t.body.push(r),n.table=r;let i=n.nextToken({needSameLine:`invalid-key-value-newline`});if(isLeftBracket(i)){if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i);r.kind=`array`,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}if(isRightBracket(i))return n.reportParseError(`missing-key`,i);if(!i)return n.reportParseError(`unterminated-table-key`,null);if(i=this.processKeyNode(i,r,n).nextToken,!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(r.kind===`array`){let e=i;if(i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i)}return applyEndLoc(r,i),n.applyResolveKeyForTable(r),n.needNewLine=!0,[]}processKeyValue(e,t,n){let r={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(r);let{nextToken:i}=this.processKeyNode(e,r,n);return isEq(i)?(n.addValueContainer({parent:r,set:e=>(r.value=e,applyEndLoc(r,e),n.needNewLine=!0,[])}),n.needSameLine=`invalid-key-value-newline`,[`VALUE`]):n.reportParseError(`missing-equals-sign`,i)}processKeyNode(e,t,n){isDot(e)&&n.reportParseError(`invalid-leading-dot-in-key`,e);let r={type:`TOMLKey`,keys:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.key=r;let i=e,a=null;do{if(isBare(i))this.processBareKey(i,r);else if(isString(i))this.processStringKey(i,r);else break;if(a=null,i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isDot(i))break;a=i,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}while(i);return a&&n.reportParseError(isDot(i)?`invalid-consecutive-dots-in-key`:`invalid-trailing-dot-in-key`,a),applyEndLoc(r,last(r.keys)),{keyNode:r,nextToken:i}}processBareKey(e,t){let n={type:`TOMLBare`,name:e.value,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringKey(e,t){let n={type:`TOMLQuoted`,kind:`string`,value:e.string,style:Wr[e.type],multiline:!1,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`string`,value:e.string,style:Ur[e.type],multiline:isMultiLineString(e),parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processNumberValue(e,t){let n=t.consumeValueContainer(),r=this.text,[i,a]=e.range,o=null,getNumberText=()=>o??=r.slice(i,a).replace(/_/g,``),s;return s=e.type===`Integer`?{type:`TOMLValue`,kind:`integer`,value:e.number,bigint:e.bigint,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)}:{type:`TOMLValue`,kind:`float`,value:e.number,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},n.set(s)}processBooleanValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`boolean`,value:e.boolean,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processDateTimeValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:Gr[e.type],value:e.date,datetime:e.value,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processArray(e,t){let n=t.consumeValueContainer(),r={type:`TOMLArray`,elements:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=t.nextToken({valuesEnabled:!0});return isRightBracket(i)?(applyEndLoc(r,i),n.set(r)):(t.backToken(),this.processArrayValue(r,n,t))}processArrayValue(e,t,n){return n.addValueContainer({parent:e,set:r=>{e.elements.push(r);let i=n.nextToken({valuesEnabled:!0}),a=isComma(i);return a&&(i=n.nextToken({valuesEnabled:!0})),isRightBracket(i)?(applyEndLoc(e,i),t.set(e)):a?(n.backToken(),this.processArrayValue(e,t,n)):n.reportParseError(i?`missing-comma`:`unterminated-array`,i)}}),[`VALUE`]}processInlineTable(e,t){let n=t.consumeValueContainer(),r={type:`TOMLInlineTable`,body:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`,a=t.nextToken({needSameLine:i});if(a){if(isBare(a)||isString(a))return this.processInlineTableKeyValue(a,r,n,t);if(isRightBrace(a))return applyEndLoc(r,a),n.set(r)}return t.reportParseError(`unexpected-token`,a)}processInlineTableKeyValue(e,t,n,r){let i={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(i);let{nextToken:a}=this.processKeyNode(e,i,r);if(!isEq(a))return r.reportParseError(`missing-equals-sign`,a);let o=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`;return r.addValueContainer({parent:i,set:e=>{i.value=e,applyEndLoc(i,e);let a=r.nextToken({needSameLine:o});if(isComma(a)){if(a=r.nextToken({needSameLine:o}),a&&(isBare(a)||isString(a)))return this.processInlineTableKeyValue(a,t,n,r);if(isRightBrace(a)){if(this.tomlVersion.lt(1,1))return r.reportParseError(`invalid-trailing-comma-in-inline-table`,a)}else return r.reportParseError(a?`unexpected-token`:`unterminated-inline-table`,a)}return isRightBrace(a)?(applyEndLoc(t,a),n.set(t)):r.reportParseError(a?`missing-comma`:`unterminated-inline-table`,a)}}),r.needSameLine=`invalid-key-value-newline`,[`VALUE`]}};function isDot(e){return isPunctuator(e)&&e.value===`.`}function isEq(e){return isPunctuator(e)&&e.value===`=`}function isLeftBracket(e){return isPunctuator(e)&&e.value===`[`}function isRightBracket(e){return isPunctuator(e)&&e.value===`]`}function isLeftBrace(e){return isPunctuator(e)&&e.value===`{`}function isRightBrace(e){return isPunctuator(e)&&e.value===`}`}function isComma(e){return isPunctuator(e)&&e.value===`,`}function isPunctuator(e){return!!(e&&e.type===`Punctuator`)}function isBare(e){return e.type===`Bare`}function isString(e){return e.type===`BasicString`||e.type===`LiteralString`}function isMultiLineString(e){return e.type===`MultiLineBasicString`||e.type===`MultiLineLiteralString`}function isNumber(e){return e.type===`Integer`||e.type===`Float`}function isBoolean(e){return e.type===`Boolean`}function isDateTime(e){return e.type===`OffsetDateTime`||e.type===`LocalDateTime`||e.type===`LocalDate`||e.type===`LocalTime`}function applyEndLoc(e,t){t&&(e.range[1]=t.range[1],e.loc.end=clonePos(t.loc.end))}function cloneRange(e){return[e[0],e[1]]}function cloneLoc(e){return{start:clonePos(e.start),end:clonePos(e.end)}}function clonePos(e){return{line:e.line,column:e.column}}const Kr=unionWith({Program:[`body`],TOMLTopLevelTable:[`body`],TOMLTable:[`key`,`body`],TOMLKeyValue:[`key`,`value`],TOMLKey:[`keys`],TOMLArray:[`elements`],TOMLInlineTable:[`body`],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]});function parseForESLint(e,t){return{ast:new TOMLParser(e,t).parse(),visitorKeys:Kr,services:{isTOML:!0}}}function parseTOML(e,t){return parseForESLint(e,t).ast}function nested(e,t){return e.reduceRight((e,t)=>({[t]:e}),t)}function renderTomlTable(e,t){return stringify(nested(e,t))}function appendTomlTable(e,t,n){return`${e}${e===``||e.endsWith(`
|
|
482
418
|
`)?``:`
|
|
483
|
-
`}\n${renderTomlTable(t,n)}`}function keyNames(e){return e.keys.map(e=>e.type===`TOMLBare`?e.name:e.value)}function startsWith(e,t){return t.length<=e.length&&t.every((t,n)=>e[n]===t)}function overlaps(e,t){return startsWith(e,t)||startsWith(t,e)}function replaceTomlTable(e,t,n){let r;try{r=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let i=[];for(let e of r.body[0].body){if(e.type===`TOMLKeyValue`){if(overlaps(keyNames(e.key),t))return{kind:`refused`,reason:`shape`};continue}if(startsWith(e.resolvedKey,t)){if(e.kind===`array`)return{kind:`refused`,reason:`shape`};i.push(e);continue}let n=e.resolvedKey;if(e.body.some(e=>overlaps([...n,...keyNames(e.key)],t)))return{kind:`refused`,reason:`shape`}}if(!i.length)return{kind:`refused`,reason:`absent`};if(!i.some(e=>e.resolvedKey.length===t.length))return{kind:`refused`,reason:`shape`};let a=i.map(t=>{let n=e.slice(t.range[1]).search(/\r?\n/);return[t.range[0],n<0?e.length:t.range[1]+n]}),inside=e=>a.some(([t,n])=>t<=e&&e<n);if(r.comments.some(e=>inside(e.range[0])))return{kind:`refused`,reason:`comment`};let[o,...s]=a,c=e;for(let[e,t]of s.reverse()){let n=c.slice(0,e),r=c.slice(t).replace(/^\r?\n/,``);c=/\n\r?\n$/.test(n)?`${n}${r.replace(/^\r?\n/,``)}`:`${n}${r}`}let l=renderTomlTable(t,n).trimEnd();return{kind:`edited`,text:`${c.slice(0,o[0])}${l}${c.slice(o[1])}`}}const
|
|
419
|
+
`}\n${renderTomlTable(t,n)}`}function keyNames(e){return e.keys.map(e=>e.type===`TOMLBare`?e.name:e.value)}function startsWith(e,t){return t.length<=e.length&&t.every((t,n)=>e[n]===t)}function overlaps(e,t){return startsWith(e,t)||startsWith(t,e)}function replaceTomlTable(e,t,n){let r;try{r=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let i=[];for(let e of r.body[0].body){if(e.type===`TOMLKeyValue`){if(overlaps(keyNames(e.key),t))return{kind:`refused`,reason:`shape`};continue}if(startsWith(e.resolvedKey,t)){if(e.kind===`array`)return{kind:`refused`,reason:`shape`};i.push(e);continue}let n=e.resolvedKey;if(e.body.some(e=>overlaps([...n,...keyNames(e.key)],t)))return{kind:`refused`,reason:`shape`}}if(!i.length)return{kind:`refused`,reason:`absent`};if(!i.some(e=>e.resolvedKey.length===t.length))return{kind:`refused`,reason:`shape`};let a=i.map(t=>{let n=e.slice(t.range[1]).search(/\r?\n/);return[t.range[0],n<0?e.length:t.range[1]+n]}),inside=e=>a.some(([t,n])=>t<=e&&e<n);if(r.comments.some(e=>inside(e.range[0])))return{kind:`refused`,reason:`comment`};let[o,...s]=a,c=e;for(let[e,t]of s.reverse()){let n=c.slice(0,e),r=c.slice(t).replace(/^\r?\n/,``);c=/\n\r?\n$/.test(n)?`${n}${r.replace(/^\r?\n/,``)}`:`${n}${r}`}let l=renderTomlTable(t,n).trimEnd();return{kind:`edited`,text:`${c.slice(0,o[0])}${l}${c.slice(o[1])}`}}const qr=/^[A-Za-z0-9_-]+$/;function tomlKey(e){return qr.test(e)?e:JSON.stringify(e)}function renderTomlInline(e){return typeof e==`object`&&e&&!Array.isArray(e)?`{ ${Object.entries(e).map(([e,t])=>`${tomlKey(e)} = ${renderTomlInline(t)}`).join(`, `)} }`:stringify({v:e}).slice(4).trimEnd()}function appendInlineTomlTable(e,t,n){let r=e===``||e.endsWith(`
|
|
484
420
|
`)?``:`
|
|
485
421
|
`,i=Object.entries(n).map(([e,t])=>`${tomlKey(e)} = ${renderTomlInline(t)}\n`);return`${e}${r}\n[${t.map(tomlKey).join(`.`)}]\n${i.join(``)}`}function lineEndAt(e,t){let n=e.indexOf(`
|
|
486
422
|
`,t);return n===-1?e.length:n}function setTomlKey(e,t,n,r){let i;try{i=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let a=i.body[0].body.filter(e=>e.type===`TOMLTable`),o=a.find(e=>e.kind===`standard`&&e.resolvedKey.length===t.length&&startsWith(e.resolvedKey,t));if(!o)return{kind:`refused`,reason:`absent`};let s=o.body;if(a.some(e=>startsWith(e.resolvedKey,[...t,n]))||s.some(e=>keyNames(e.key)[0]===n&&e.key.keys.length>1))return{kind:`refused`,reason:`shape`};let c=s.find(e=>e.key.keys.length===1&&keyNames(e.key)[0]===n);if(c&&r!==void 0)return{kind:`edited`,text:`${e.slice(0,c.value.range[0])}${renderTomlInline(r)}${e.slice(c.value.range[1])}`};if(c){let t=e.lastIndexOf(`
|
|
487
|
-
`,c.range[0]-1)+1,n=lineEndAt(e,c.range[1]);return{kind:`edited`,text:`${e.slice(0,t)}${e.slice(Math.min(n+1,e.length))}`}}if(r===void 0)return{kind:`edited`,text:e};let l=lineEndAt(e,s.at(-1)?.range[1]??o.range[0]);return{kind:`edited`,text:`${e.slice(0,l)}\n${tomlKey(n)} = ${renderTomlInline(r)}${e.slice(l)}`}}function read$1(e,t){let
|
|
488
|
-
|
|
423
|
+
`,c.range[0]-1)+1,n=lineEndAt(e,c.range[1]);return{kind:`edited`,text:`${e.slice(0,t)}${e.slice(Math.min(n+1,e.length))}`}}if(r===void 0)return{kind:`edited`,text:e};let l=lineEndAt(e,s.at(-1)?.range[1]??o.range[0]);return{kind:`edited`,text:`${e.slice(0,l)}\n${tomlKey(n)} = ${renderTomlInline(r)}${e.slice(l)}`}}function read$1(e,t){let r=b(e,t);return n(r)?a(r,`utf8`):void 0}__name(read$1,`read`);const Jr={both:`both sides changed since the last projection — a three-way conflict for a person to settle, never imported`,unknown:`no baseline says which side changed — compare the two by hand; never imported`};function inferredTransport(e){return e.url===void 0?`stdio`:`http`}function mapValue(e,t){let n=Object.entries(e).flatMap(([e])=>{let n=isRecord(t)?t[e]:void 0;return typeof n==`string`?[[e,n]]:[]});return n.length?Object.fromEntries(n):void 0}function reconcileMcp({root:e,git:t,accept:n}){let r=read$1(e,J),i=parseGoldenSet(r);if(i.kind!==`servers`)return i;let a=parseProjectionRecord(read$1(e,Y)),o=new McpBaseline({git:t,record:a}),s=[],c=[];for(let t of mcpTargets(e)){let n=parseTarget(t,read$1(e,t.path));if(n.kind===`unreadable`){s.push({path:t.path,action:`refuse`,detail:`the target does not parse`});continue}if(n.kind===`absent`)continue;let r=q[t.dialect];for(let[e,a]of n.servers){let n=i.servers.get(e),at=n=>locatorText({file:t.path,server:e,field:n}),offer=(i,o)=>{let l=literalsIn(i,o);for(let e of l)s.push({path:at(e),action:`refuse`,detail:`${e} holds a literal credential, which never enters the golden set — set it in the environment and reference it as \${VAR}`});let u=withoutLiterals(i,o,l,n);if(l.length&&(u===void 0||sameField(i,{[i]:u},n)))return;let d=r.defaults?.[i];if(d!==void 0&&sameField(i,{[i]:u},{[i]:d})){s.push({path:at(i),action:`skip`,detail:`${t.dialect} fills this in by default, so it may not be the user's — set it in the golden set by hand if it is`});return}let f={path:at(i),action:`import`,detail:n?`only the harness changed it — approve to take it into the golden set`:`the golden set does not declare this server — approve each field to add it`,value:u===void 0?`(unset)`:`${i} = ${renderTomlInline(u)}`};s.push(f),c.push({row:f,config:t,server:e,field:i,value:u,carried:a,adds:!n})};if(!n){for(let e of Gn)r.fields.has(e)&&a[e]!==void 0&&(e!==`transport`||a.transport!==inferredTransport(a))&&offer(e,a[e]);continue}for(let i of divergingFields(n,a,r.fields)){let r=o.directionOf(t,e,i,n,a);r!==`golden`&&(r===`target`?offer(i,i===`env`||i===`headers`?mapValue(n[i],a[i]):a[i]):s.push({path:at(i),action:`skip`,detail:Jr[r]}))}}}if(!n.length)return{kind:`planned`,rows:s,written:!1};let l=approve(c,s,n);if(l.kind===`rejected`)return l;let u=r,d=[];for(let[e,t]of groupByServer(l.offers)){if(t[0]?.adds){let n=Object.fromEntries(Gn.flatMap(e=>{let n=t.find(t=>t.field===e);return n?[[e,n.value]]:[]}));u=land(u,appendInlineTomlTable(u,[`servers`,e],n),e,n,t,d);continue}for(let n of t){let t={...parseGoldenSet(u).servers.get(e),[n.field]:n.value};n.value===void 0&&delete t[n.field];let r=setTomlKey(u,[`servers`,e],n.field,n.value);u=land(u,r.kind===`edited`?r.text:void 0,e,t,[n],d)}}return u!==r&&(p(b(e,J),u),writeRecord$1(e,a,o,d,parseGoldenSet(u))),{kind:`planned`,rows:s,written:!0}}function literalsIn(e,t){return t===void 0?[]:e===`args`?nonSecretArgs(t).length===t.length?[]:[`args`]:e!==`env`&&e!==`headers`&&e!==`url`?[]:credentialFields({[e]:t})}function withoutLiterals(e,t,n,r){if(!n.length)return t;if(e!==`env`&&e!==`headers`)return;let i={...t};for(let t of n){let n=t.slice(e.length+1),a=r?.[e]?.[n];a===void 0?delete i[n]:i[n]=a}return Object.keys(i).length?i:void 0}function approve(e,t,n){let r=[],i=[];for(let a of new Set(n)){let n=e.find(e=>e.row.path===a);if(n)i.push(n);else{let e=t.find(e=>e.path===a);r.push(e?`${a} is ${e.action}, not importable: ${e.detail}`:`${a} names no importable field`)}}for(let[e,t]of groupByServer(i)){for(let n of new Set(t.map(e=>e.field))){let i=t.filter(e=>e.field===n);i.some(e=>!sameField(n,{[n]:e.value},{[n]:i[0]?.value}))&&r.push(`servers.${e}.${n} is approved from more than one target with different values — approve one`)}t[0]?.adds&&!t.some(e=>e.field===`command`||e.field===`url`)&&r.push(`servers.${e} would be added with nothing to run — approve its command or url too`)}return r.length?{kind:`rejected`,reasons:r}:{kind:`approved`,offers:i}}function groupByServer(e){let t=new Map;for(let n of e)t.set(n.server,[...t.get(n.server)??[],n]);return t}function land(e,t,n,r,i,a){let o=parseGoldenSet(e),s=t===void 0?void 0:parseGoldenSet(t),c=s?.kind===`servers`&&Gn.every(e=>e===`transport`&&r.transport===void 0||sameField(e,s.servers.get(n),r))&&[...o.servers].every(([e,t])=>e===n||JSON.stringify(s.servers.get(e))===JSON.stringify(t));for(let e of i)e.row.action=c?`imported`:`edit`,e.row.detail=c?`written into the golden set`:`the golden set writes this server in a shape that cannot be edited byte-safely — apply the value by hand`;return c?(a.push(...i),t):e}function writeRecord$1(e,t,n,r,a){for(let e of r){let r=t.get(e.config.path)??new Map,i=r.get(e.server),o=i?{...i,[e.field]:e.value}:baseEntry(e,n,a.servers.get(e.server));o&&(e.value===void 0&&delete o[e.field],r.set(e.server,o),t.set(e.config.path,r))}let o=b(e,Y);i(y(o),{recursive:!0}),p(o,formatProjectionRecord(t))}__name(writeRecord$1,`writeRecord`);function baseEntry(e,t,n){if(e.adds)return{...n};let r={};for(let i of q[e.config.dialect].fields){if(n[i]===void 0)continue;if(sameField(i,n,e.carried)){r[i]=n[i];continue}let a=t.baseFor(e.config,e.server,i);if(!a)return;r[i]=a[i]}return r}const Yr=command({name:`reconcile`,description:`Import a harness-side MCP change into the golden set, one approved field at a time. A dry run unless --accept names a field.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:k.string().optional()},accept:{description:`Approve one field by the path a dry run lists for it; repeat for each field. There is no approve-all.`,type:k.array(k.string()).optional()}},run(e){try{let t=e.root??process.cwd(),n=e.accept??[],r=reconcileMcp({root:t,git:new GitBridgeState(t),accept:n});if(r.kind===`unreadable`){let e=r.position?` at line ${r.position.line}, column ${r.position.column}`:``;throw process.stderr.write(`error: ${J} does not parse${e}.\n`),O.reported(D.error)}if(r.kind===`rejected`)throw process.stderr.write(`error: nothing written.\n${r.reasons.map(e=>`- ${e}\n`).join(``)}`),O.reported(D.error);return r.kind===`absent`?result({golden:`0 servers — no golden set at ${J}`,mode:`nothing to reconcile into`,fields:`0 fields`,record:`not written`}):result({golden:J,mode:r.written?`written — only the fields named by --accept`:`dry run — nothing written; re-run with --accept <path> for each approved field`,fields:r.rows.length?r.rows:`0 fields — no harness holds a change the golden set lacks`,record:r.written?Y:`not written — dry run`})}catch(e){return fail$1(e,`MCP reconcile failed.`)}}});function createScanner(e,t=!1){let n=e.length,r=0,i=``,a=0,o=16,s=0,c=0,l=0,u=0,d=0;function scanHexDigits(t,n){let i=0,a=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)a=a*16+t-48;else if(t>=65&&t<=70)a=a*16+t-65+10;else if(t>=97&&t<=102)a=a*16+t-97+10;else break;r++,i++}return i<t&&(a=-1),a}function setPosition(e){r=e,i=``,a=0,o=16,d=0}function scanNumber(){let t=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&isDigit(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46){if(r++,r<e.length&&isDigit(e.charCodeAt(r)))for(r++;r<e.length&&isDigit(e.charCodeAt(r));)r++;else return d=3,e.substring(t,r)}let n=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101)){if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&isDigit(e.charCodeAt(r))){for(r++;r<e.length&&isDigit(e.charCodeAt(r));)r++;n=r}else d=3}return e.substring(t,n)}function scanString(){let t=``,i=r;for(;;){if(r>=n){t+=e.substring(i,r),d=2;break}let a=e.charCodeAt(r);if(a===34){t+=e.substring(i,r),r++;break}if(a===92){if(t+=e.substring(i,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
|
|
424
|
+
`;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=scanHexDigits(4,!0);e>=0?t+=String.fromCharCode(e):d=4;break;default:d=5}i=r;continue}if(a>=0&&a<=31){if(isLineBreak(a)){t+=e.substring(i,r),d=2;break}d=6}r++}return t}function scanNext(){if(i=``,d=0,a=r,c=s,u=l,r>=n)return a=n,o=17;let t=e.charCodeAt(r);if(isWhiteSpace(t)){do r++,i+=String.fromCharCode(t),t=e.charCodeAt(r);while(isWhiteSpace(t));return o=15}if(isLineBreak(t))return r++,i+=String.fromCharCode(t),t===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
425
|
+
`),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=scanString(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!isLineBreak(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,isLineBreak(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!isDigit(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=scanNumber(),o=11;default:for(;r<n&&isUnknownContentCharacter(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function isUnknownContentCharacter(e){if(isWhiteSpace(e)||isLineBreak(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function scanNextNonTrivia(){let e;do e=scanNext();while(e>=12&&e<=15);return e}return{setPosition,getPosition:()=>r,scan:t?scanNextNonTrivia:scanNext,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function isWhiteSpace(e){return e===32||e===9}function isLineBreak(e){return e===10||e===13}function isDigit(e){return e>=48&&e<=57}var Xr;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(Xr||={}),Array(20).fill(0).map((e,t)=>` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
|
|
426
|
+
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
|
|
427
|
+
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
|
|
428
|
+
`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
|
|
429
|
+
`+` `.repeat(t));var Zr;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Zr||={});function parseTree$1(e,t=[],n=Zr.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function ensurePropertyComplete(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function onValue(e){return r.children.push(e),e}visit(e,{onObjectBegin:e=>{r=onValue({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=onValue({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{ensurePropertyComplete(e+t),r.length=e+t-r.offset,r=r.parent,ensurePropertyComplete(e+t)},onArrayBegin:(e,t)=>{r=onValue({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,ensurePropertyComplete(e+t)},onLiteralValue:(e,t,n)=>{onValue({type:getNodeType(e),offset:t,length:n,parent:r,value:e}),ensurePropertyComplete(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&ensurePropertyComplete(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let i=r.children[0];return i&&delete i.parent,i}__name(parseTree$1,`parseTree`);function findNodeAtLocation$1(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}__name(findNodeAtLocation$1,`findNodeAtLocation`);function visit(e,t,n=Zr.DEFAULT){let r=createScanner(e,!1),i=[],a=0;function toNoArgVisit(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function toOneArgVisit(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function toOneArgVisitWithPath(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function toBeginVisit(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function toEndVisit(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let o=toBeginVisit(t.onObjectBegin),s=toOneArgVisitWithPath(t.onObjectProperty),c=toEndVisit(t.onObjectEnd),l=toBeginVisit(t.onArrayBegin),u=toEndVisit(t.onArrayEnd),d=toOneArgVisitWithPath(t.onLiteralValue),f=toOneArgVisit(t.onSeparator),p=toNoArgVisit(t.onComment),m=toOneArgVisit(t.onError),h=n&&n.disallowComments,g=n&&n.allowTrailingComma;function scanNext(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:handleError(14);break;case 5:handleError(15);break;case 3:handleError(13);break;case 1:h||handleError(11);break;case 2:handleError(12);break;case 6:handleError(16)}switch(e){case 12:case 13:h?handleError(10):p();break;case 16:handleError(1);break;case 15:case 14:break;default:return e}}}function handleError(e,t=[],n=[]){if(m(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){scanNext();break}if(n.indexOf(e)!==-1)break;e=scanNext()}}}function parseString(e){let t=r.getTokenValue();return e?d(t):(s(t),i.push(t)),scanNext(),!0}function parseLiteral(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(handleError(2),t=0),d(t);break;case 7:d(null);break;case 8:d(!0);break;case 9:d(!1);break;default:return!1}return scanNext(),!0}function parseProperty(){return r.getToken()===10?(parseString(!1),r.getToken()===6?(f(`:`),scanNext(),parseValue()||handleError(4,[],[2,5])):handleError(5,[],[2,5]),i.pop(),!0):(handleError(3,[],[2,5]),!1)}function parseObject(){o(),scanNext();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||handleError(4,[],[]),f(`,`),scanNext(),r.getToken()===2&&g)break}else e&&handleError(6,[],[]);parseProperty()||handleError(4,[],[2,5]),e=!0}return c(),r.getToken()===2?scanNext():handleError(7,[2],[]),!0}function parseArray(){l(),scanNext();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||handleError(4,[],[]),f(`,`),scanNext(),r.getToken()===4&&g)break}else t&&handleError(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,parseValue()||handleError(4,[],[4,5]),t=!0}return u(),e||i.pop(),r.getToken()===4?scanNext():handleError(8,[4],[]),!0}function parseValue(){switch(r.getToken()){case 3:return parseArray();case 1:return parseObject();case 10:return parseString(!0);default:return parseLiteral()}}return scanNext(),r.getToken()===17?n.allowEmptyContent?!0:(handleError(4,[],[]),!1):parseValue()?(r.getToken()!==17&&handleError(9,[],[]),!0):(handleError(4,[],[]),!1)}function getNodeType(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}var Qr;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(Qr||={});var $r;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})($r||={});const ei=parseTree$1,ti=findNodeAtLocation$1;var ni;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(ni||={});function indentUnit(e){let t=/\n([ \t]+)\S/.exec(e);return t?t[1]:` `}function jsonAt(e,t,n){return JSON.stringify(e,null,t).replaceAll(`
|
|
430
|
+
`,`\n${t.repeat(n)}`)}function objectAt(e,t){let n=e&&(t.length?ti(e,t):e);return n?.type===`object`?n:void 0}function insertJsonProperty(e,t,n,r){let i=objectAt(ei(e),t);if(!i||ti(i,[n]))return;let a=t.length+1,o=indentUnit(e),s=`${o.repeat(a)}${JSON.stringify(n)}: ${jsonAt(r,o,a)}`,c=i.children?.at(-1);if(c){let t=c.offset+c.length;return`${e.slice(0,t)},\n${s}${e.slice(t)}`}let l=i.offset+1,u=i.offset+i.length-1;return`${e.slice(0,l)}\n${s}\n${o.repeat(a-1)}${e.slice(u)}`}function replaceJsonValue(e,t,n){let r=ei(e),i=r&&ti(r,t);if(!i)return{kind:`refused`,reason:`absent`};let a=i.offset+i.length,o=e.slice(i.offset,a);return stripJsonComments(o)===o?{kind:`edited`,text:`${e.slice(0,i.offset)}${jsonAt(n,indentUnit(e),t.length)}${e.slice(a)}`}:{kind:`refused`,reason:`comment`}}function createFile(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):`${JSON.stringify({[e.key]:{[t]:n}},null,2)}\n`}function appendServer(e,t,n,r){return e.format===`toml`?appendTomlTable(t,[e.key,n],r):insertJsonProperty(t,[e.key],n,r)??insertJsonProperty(t,[],e.key,{[n]:r})}function replaceServer(e,t,n,r){let i=e.format===`toml`?replaceTomlTable(t,[e.key,n],r):replaceJsonValue(t,[e.key,n],r);return i.kind===`edited`?i.text:void 0}function renderEntry(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):JSON.stringify({[t]:n},null,2)}function read(e,t){let r=b(e,t);return n(r)?a(r,`utf8`):void 0}const ri={target:`the target changed since the last projection — reconcile it into the golden set first`,both:`both sides changed since the last projection — a three-way conflict for a person to settle`,unknown:`no baseline says which side changed — compare the two by hand`};function heldBack(e){return[`both`,`unknown`,`target`].find(t=>e.includes(t))}function projectMcp({root:e,git:t,write:n}){let r=parseGoldenSet(read(e,J));if(r.kind!==`servers`)return r;let i=parseProjectionRecord(read(e,Y)),a=new McpBaseline({git:t,record:i}),o=[],s=[],c=[];for(let t of mcpTargets(e)){let n=read(e,t.path),i=parseTarget(t,n);if(i.kind===`unreadable`){o.push({target:t.path,server:``,action:`refuse`,detail:`the target does not parse`});continue}let l={config:t,source:n,created:n===void 0,servers:i.kind===`servers`?i.servers:new Map,agreed:new Map};c.push(l);let u=q[t.dialect];for(let[e,n]of r.servers){let row=(n,r)=>o.push({target:t.path,server:e,action:n,detail:r}),r=credentialFields(n)[0];if(r){row(`refuse`,`the golden set holds a literal credential at ${r} — reference it as \${VAR} first`);continue}let i=u.write(n);if(i.kind===`refused`){row(`refuse`,`${i.field}: ${i.reason}`);continue}let c=l.servers.get(e);if(!c){let r=l.source===void 0?createFile(t,e,i.entry):appendServer(t,l.source,e,i.entry);apply(l,e,n,i.entry,r,l.created?`creates the file`:`appends the server`,row,s);continue}let d=divergingFields(n,c,u.fields);if(!d.length){l.agreed.set(e,n);continue}let f=heldBack(d.map(r=>a.directionOf(t,e,r,n,c)));if(f){row(`skip`,ri[f]);continue}let p=replaceServer(t,l.source,e,i.entry);apply(l,e,n,i.entry,p,`replaces ${d.join(`, `)}`,row,s)}}if(n){for(let t of c)t.source!==void 0&&t.source!==read(e,t.config.path)&&writeTarget(e,t);writeRecord(e,i,c)}return{kind:`planned`,rows:o,entries:s,written:n}}function apply(e,t,n,r,i,a,o,s){let c=!e.servers.has(t),l=i!==void 0&&readsBack(e,t,n,i),u=l?c?`add`:`update`:`edit`;if(s.push({target:e.config.path,server:t,action:u,entry:renderEntry(e.config,t,r)}),!l){o(`edit`,c?`the file has no safe place to add it — apply the entry by hand`:`an in-place change here is applied by hand`);return}e.source=i,e.servers=parseTarget(e.config,i).servers,e.agreed.set(t,n),o(u,a)}function readsBack(e,t,n,r){let i=parseTarget(e.config,r);if(i.kind!==`servers`)return!1;let a=i.servers.get(t),o=q[e.config.dialect].fields;return!a||divergingFields(n,a,o).length?!1:[...e.servers].every(([e,n])=>{if(e===t)return!0;let r=i.servers.get(e);return r!==void 0&&JSON.stringify(r)===JSON.stringify(n)})}function writeTarget(e,t){let n=b(e,t.config.path);i(y(n),{recursive:!0}),p(n,t.source)}function writeRecord(e,t,n){for(let e of n){let n=t.get(e.config.path)??new Map;for(let[t,r]of e.agreed)n.set(t,r);n.size&&t.set(e.config.path,n)}let r=b(e,Y);i(y(r),{recursive:!0}),p(r,formatProjectionRecord(t))}const ii={name:`buddy-agent-harness`,description:`Initialize agent harness skill compatibility in consumer repositories.`,commands:[kr,wr,command({name:`mcp`,description:`Work with the golden MCP server set at .agents/buddy-agent-harness/mcp.toml.`,commands:[command({name:`project`,description:`Project the golden MCP server set into each enabled harness. A dry run unless --write; never overwrites a change made on the harness side.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:k.string().optional()},write:{description:`Apply the plan and record what was projected. Without it nothing on disk changes.`,type:k.boolean().optional()}},run(e){try{let t=e.root??process.cwd(),n=e.write===!0,r=projectMcp({root:t,git:new GitBridgeState(t),write:n});if(r.kind===`unreadable`){let e=r.position?` at line ${r.position.line}, column ${r.position.column}`:``;throw process.stderr.write(`error: ${J} does not parse${e}.\n`),O.reported(D.error)}return r.kind===`absent`?result({golden:`0 servers — no golden set at ${J}`,mode:`nothing to project`,actions:`0 changes`,record:`not written`}):result({golden:J,mode:n?`written`:`dry run — nothing written; re-run with --write to apply`,actions:r.rows.length?r.rows:`0 changes — every enabled harness already carries the golden set`,...r.entries.length?{entries:r.entries}:{},record:n?Y:`not written — dry run`})}catch(e){return fail$1(e,`MCP projection failed.`)}}}),Yr]}),An,br,Or]};function app(e){let[t,...n]=ii.commands;return n.reduce((e,t)=>e.command(t),cli({name:ii.name,version:`0.22.0`,description:ii.description,format:e}).command(t))}const ai={reference:[`show`,`create`,`delete`],governance:[`show`]};function defaultFormat(e){let t=e.slice(2);if(t.some(e=>e===`--format`||e.startsWith(`--format=`)))return`toon`;let[n,r]=t;return n!==void 0&&r!==void 0&&ai[n]?.includes(r)?`text`:`toon`}async function run(e){try{let t=await app(defaultFormat(e)).parse(e);return typeof t==`number`?t:D.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Invalid command.`}\n`),D.usage}}process.exitCode=await run([...process.argv.slice(0,2),`init`,...process.argv.slice(2)]);export{};
|