zod-args-parser 2.0.0-beta.2 → 2.0.0-beta.3

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/README.md CHANGED
@@ -27,6 +27,7 @@ A strictly typed command-line arguments parser powered by schema validation.
27
27
  - [Creating a Custom Help Message Style](#creating-a-custom-help-message-style)
28
28
  - [Help Message as HTML](#help-message-as-html)
29
29
  - [Handling and Inspecting Errors](#handling-and-inspecting-errors)
30
+ - [Loading from a CDN](#loading-from-a-cdn)
30
31
  - [API Reference](#api-reference)
31
32
  - [Type Utilities](docs/api-reference.md#type-utilities)
32
33
  - [Coerce Helpers](docs/api-reference.md#coerce-helpers)
@@ -73,11 +74,7 @@ import { defineCLI, coerce } from "zod-args-parser";
73
74
  const cli = defineCLI({
74
75
  cliName: "hello",
75
76
  options: {
76
- /**
77
- * 💡 **Tip:** Adding a **JSDoc** comment here will be displayed in IDE hovers alongside the TypeScript type.
78
- *
79
- * `--name` or `-n`
80
- */
77
+ /** `--name` or `-n` */
81
78
  name: {
82
79
  aliases: ["n"],
83
80
  schema: z.string().default("world"),
@@ -92,7 +89,6 @@ cli.onExecute(({ options }) => {
92
89
  const result = cli.run(process.argv.slice(2));
93
90
  if (result.error) {
94
91
  console.error(result.error.message);
95
- process.exit(1);
96
92
  }
97
93
  ```
98
94
 
@@ -641,9 +637,34 @@ if (results.error) {
641
637
  }
642
638
  ```
643
639
 
640
+ ### Loading from a CDN
641
+
642
+ **Global IIFE**
643
+
644
+ ```html
645
+ <!-- using jsdelivr -->
646
+ <script src="https://cdn.jsdelivr.net/npm/zod-args-parser"></script>
647
+
648
+ <!-- using unpkg -->
649
+ <script src="https://unpkg.com/zod-args-parser"></script>
650
+
651
+ <script>
652
+ // Access the library as a global
653
+ const { defineCLI, coerce } = ZodArgsParser;
654
+ </script>
655
+ ```
656
+
657
+ **ESM Module**
658
+
659
+ ```html
660
+ <script type="module">
661
+ import { defineCLI, coerce } from "https://cdn.jsdelivr.net/npm/zod-args-parser/+esm";
662
+ </script>
663
+ ```
664
+
644
665
  ## API Reference
645
666
 
646
- See the [API Reference](docs/api-reference.md) for more information.
667
+ See the [API Reference](./docs/api-reference.md) for more information.
647
668
 
648
669
  ## License
649
670
 
package/lib/iife/index.js CHANGED
@@ -1,2 +1,42 @@
1
- "use strict";(()=>{!function({onlyFirst:e=!1}={}){const t=String.raw`(?:\u0007|\u001B\u005C|\u009C)`,n=String.raw`(?:\u001B\][\s\S]*?${t})`,i=String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]`;new RegExp(`${n}|${i}`,e?void 0:"g")}();function e(e){const t=e;for(const[e]of Object.entries(t))t[e]=e;return Object.freeze(t)}var t=e({Internal:void 0,Parse:void 0,Validation:void 0,Definition:void 0}),n=e({MissingSchema:void 0,EmptyDefinitionGroup:void 0,MissingDefinitionName:void 0,InvalidDefinitionOptionName:void 0,InvalidDefinitionArgumentName:void 0,InvalidOptionalArgumentDefinition:void 0,DuplicateDefinitionName:void 0,EmptyStringAliasName:void 0,SelfRequire:void 0,UnknownRequireName:void 0,SelfConflict:void 0,UnknownConflictName:void 0,DefinitionRequiresConflictOverlap:void 0,MissingOnExecute:void 0,SubcommandHelpNotFound:void 0});var i=e({MissingPreparedTypes:void 0,CannotFindCliDefinition:void 0});var r=e({UnknownSubcommand:void 0,CommandWithoutOptions:void 0,UnknownOption:void 0,DuplicateOptionProvided:void 0,InvalidNegationForNonBooleanOption:void 0,PositionalArgumentNotAllowed:void 0,MissingRequiredOption:void 0,MissingRequiredArgument:void 0,OptionMissingValue:void 0,FlagAssignedValue:void 0});var o=e({NoOptionsToValidate:void 0,NoArgumentsToValidate:void 0,UnknownOptionValidation:void 0,UnknownArgumentValidation:void 0,SchemaValidationFailed:void 0,MutuallyExclusiveConflict:void 0,RequiredDependencyMissing:void 0,AsyncSchemaNotSupported:void 0,CoercionFailed:void 0});var s=class e extends Error{code;cause;context;constructor(t){super(t.message??e.errorMessage(t)),this.cause=t.cause,this.code=t.code,this.context=t.context}static errorMessage(e){const s="unknown error";if(e.cause===t.Internal)return function({code:e,context:t}){return e===i.MissingPreparedTypes?`internal error: missing prepared type for option "${t.name}" in ${t.commandKind} "${t.commandName}"`:e===i.CannotFindCliDefinition?`internal error: cannot find cli definition "${t.cliName}"`:e}(e)??s;if(e.cause===t.Parse)return function({code:e,context:t}){return e===r.UnknownSubcommand?`parsing error: unknown subcommand "${t.commandName}".`:e===r.CommandWithoutOptions?`parsing error: the ${t.commandKind} "${t.commandName}" does not allow options, but received "${t.optionName}".`:e===r.UnknownOption?`parsing error: unknown option "${t.optionName}" for the ${t.commandKind} "${t.commandName}".`:e===r.DuplicateOptionProvided?`parsing error: duplicate option "${t.optionName}" provided for the ${t.commandKind} "${t.commandName}".`:e===r.InvalidNegationForNonBooleanOption?`parsing error: option "${t.optionName}" cannot be negated because it is not a boolean option for the ${t.commandKind} "${t.commandName}".`:e===r.PositionalArgumentNotAllowed?`parsing error: positional argument "${t.argumentName}" is not allowed for the ${t.commandKind} "${t.commandName}".`:e===r.MissingRequiredOption?`parsing error: missing required option "${t.optionName}" for the ${t.commandKind} "${t.commandName}".`:e===r.MissingRequiredArgument?`parsing error: missing required argument "${t.argumentName}" for the ${t.commandKind} "${t.commandName}".`:e===r.OptionMissingValue?`parsing error: the option "${t.optionName}" for the ${t.commandKind} "${t.commandName}" expects a value but received none.`:e===r.FlagAssignedValue?`parsing error: flag option "${t.flag}" in ${t.commandKind} "${t.commandName}" cannot be assigned a value using "=" (provided: "${t.value}").`:e}(e)??s;if(e.cause===t.Definition)return function({code:e,context:t}){if(e===n.MissingDefinitionName){const e="command"===t.commandKind?"cliName":"name";return`invalid ${t.commandKind} definition: "${e}" property is required.`}if(e===n.EmptyDefinitionGroup)return`invalid ${t.commandKind} definition "${t.commandName}": "${t.kind}" property is optional but cannot be empty.`;if(e===n.MissingSchema)return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" is missing the "schema" property.`;if(e===n.InvalidDefinitionOptionName)return t.negatedAliasName?`invalid ${t.commandKind} definition "${t.commandName}": the option "${t.optionName}" has the alias "${t.negatedAliasName}" which cannot be named as a negated option.`:`invalid ${t.commandKind} definition "${t.commandName}": the option "${t.optionName}" cannot be named as a negated option.`;if(e===n.InvalidDefinitionArgumentName)return`invalid ${t.commandKind} definition "${t.commandName}": the argument "${t.name}" cannot be a number..`;if(e===n.DuplicateDefinitionName){const e=t.foundInName?`conflict with the ${t.foundInKind} "${t.foundInName}" alias name`:`conflict with other ${t.foundInKind} name`;return t.duplicatedAlias?`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" has the alias "${t.duplicatedAlias}" which ${e}.`:`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" name ${e}.`}if(e===n.EmptyStringAliasName)return t.optionName?`invalid ${t.commandKind} definition "${t.commandName}": the option "${t.optionName}" has an empty string alias name.`:`invalid ${t.commandKind} definition "${t.commandName}": empty string alias name is not allowed.`;if(e===n.SelfRequire)return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" cannot require itself.`;if(e===n.UnknownRequireName)return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" requires a non-existent name "${t.requiredName}".`;if(e===n.SelfConflict)return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" cannot conflict with itself.`;if(e===n.UnknownConflictName)return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" conflicts with a non-existent name "${t.requiredName}".`;if(e===n.DefinitionRequiresConflictOverlap){const e=t.intersectedNames.length>1?"s":"";return`invalid ${t.commandKind} definition "${t.commandName}": the ${t.kind} "${t.name}" has overlapping 'requires' and 'conflictsWith' name${e}: `+t.intersectedNames.join(", ")}return e===n.InvalidOptionalArgumentDefinition?t.allowPositionals?`invalid ${t.commandKind} definition "${t.commandName}": the argument "${t.name}" cannot be optional when "allowPositionals" is enabled.`:`invalid ${t.commandKind} definition "${t.commandName}": the argument "${t.name}" cannot be optional unless it is the last argument.`:e===n.MissingOnExecute?`trying to execute ${t.commandKind} "${t.commandName}" which does not have an "onExecute" handler.`:e===n.SubcommandHelpNotFound?`cannot generate help message for subcommand "${t.subcommandName}" because it does not exist in CLI "${t.cliName}".`:e}(e)??s;if(e.cause===t.Validation)return function({code:e,context:t}){if(e===o.NoOptionsToValidate)return`validation error: trying to validate options for ${t.commandKind} "${t.commandName}" which does not define any.`;if(e===o.NoArgumentsToValidate)return`validation error: trying to validate typed arguments for ${t.commandKind} "${t.commandName}" which does not define any.`;if(e===o.UnknownOptionValidation)return`validation error: trying to validate a non-existent option "${t.optionName}" for ${t.commandKind} "${t.commandName}".`;if(e===o.UnknownArgumentValidation)return`validation error: trying to validate a non-existent typed argument "${t.argumentName}" for ${t.commandKind} "${t.commandName}".`;if(e===o.SchemaValidationFailed)return`validation error: the ${t.kind} "${t.name}" for ${t.commandKind} "${t.commandName}" failed to validate "${"string"==typeof t.inputValue?t.inputValue:JSON.stringify(t.inputValue)}": `+t.issues.map(e=>{const t=e.path?.map(e=>"object"==typeof e&&"key"in e?e.key:e),n=t&&t.length>0?` at "${t.join(".")}"`:"";return`${e.message}${n}`}).join(" : ");if(e===o.MutuallyExclusiveConflict){const e=[];if(t.conflictedOptions.length>0){const n=t.conflictedOptions.map(e=>`"${e}"`).join(", "),i=t.conflictedOptions.length>1?"s":"";e.push(`option${i} ${n}`)}if(t.conflictedArguments.length>0){const n=t.conflictedArguments.map(e=>`"${e}"`).join(", "),i=t.conflictedArguments.length>1?"s":"";e.push(`argument${i} ${n}`)}return`validation error: the ${t.kind} "${t.name}" cannot be used with the ${e.join(" and ")} because they are mutually exclusive.`}if(e===o.RequiredDependencyMissing){const e=[];if(t.missingOptions.length>0){const n=t.missingOptions.map(e=>`"${e}"`).join(", "),i=t.missingOptions.length>1?"s":"";e.push(`option${i} ${n}`)}if(t.missingArguments.length>0){const n=t.missingArguments.map(e=>`"${e}"`).join(", "),i=t.missingArguments.length>1?"s":"";e.push(`argument${i} ${n}`)}return`validation error: the ${t.kind} "${t.name}" cannot be used without the required "${e.join(" and ")}".`}return e===o.AsyncSchemaNotSupported?`validation error: cannot validate async schema: received ${"string"==typeof t.value?t.value:JSON.stringify(t.value)}`:e===o.CoercionFailed?`validation error: failed to coerce the value "${"string"==typeof t.providedValue?t.providedValue:JSON.stringify(t.providedValue)}" of type "${typeof t.providedValue}" to type "${t.coerceToType}".`:e}(e)??s;return e}};var l=(e=0)=>t=>`[${t+e}m`,a=(e=0)=>t=>`[${38+e};5;${t}m`,c=(e=0)=>(t,n,i)=>`[${38+e};2;${t};${n};${i}m`,h={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(h.modifier),Object.keys(h.color),Object.keys(h.bgColor);var p=function(){const e=new Map;for(const[t,n]of Object.entries(h)){for(const[t,i]of Object.entries(n))h[t]={open:`[${i[0]}m`,close:`[${i[1]}m`},n[t]=h[t],e.set(i[0],i[1]);Object.defineProperty(h,t,{value:n,enumerable:!1})}return Object.defineProperty(h,"codes",{value:e,enumerable:!1}),h.color.close="",h.bgColor.close="",h.color.ansi=l(),h.color.ansi256=a(),h.color.ansi16m=c(),h.bgColor.ansi=l(10),h.bgColor.ansi256=a(10),h.bgColor.ansi16m=c(10),Object.defineProperties(h,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;3===n.length&&(n=[...n].map(e=>e+e).join(""));const i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,255&i]},enumerable:!1},hexToAnsi256:{value:e=>h.rgbToAnsi256(...h.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,n,i;if(e>=232)t=(10*(e-232)+8)/255,n=t,i=t;else{const r=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(r/6)/5,i=r%6/5}const r=2*Math.max(t,n,i);if(0===r)return 30;let o=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(t));return 2===r&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>h.ansi256ToAnsi(h.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>h.ansi256ToAnsi(h.hexToAnsi256(e)),enumerable:!1}}),h}(),u=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),d=0!==u&&{level:u,hasBasic:!0,has256:u>=2,has16m:u>=3},g={stdout:d,stderr:d};function m(e,t,n){let i=e.indexOf(t);if(-1===i)return e;const r=t.length;let o=0,s="";do{s+=e.slice(o,i)+t+n,o=i+r,i=e.indexOf(t,o)}while(-1!==i);return s+=e.slice(o),s}var{stdout:f,stderr:k}=g,x=Symbol("GENERATOR"),b=Symbol("STYLER"),w=Symbol("IS_EMPTY"),$=["ansi","ansi","ansi256","ansi16m"],y=Object.create(null),v=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const n=f?f.level:0;e.level=void 0===t.level?n:t.level})(t,e),Object.setPrototypeOf(t,A.prototype),t};function A(e){return v(e)}Object.setPrototypeOf(A.prototype,Function.prototype);for(const[e,t]of Object.entries(p))y[e]={get(){const n=C(this,R(t.open,t.close,this[b]),this[w]);return Object.defineProperty(this,e,{value:n}),n}};y.visible={get(){const e=C(this,this[b],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var S=(e,t,n,...i)=>"rgb"===e?"ansi16m"===t?p[n].ansi16m(...i):"ansi256"===t?p[n].ansi256(p.rgbToAnsi256(...i)):p[n].ansi(p.rgbToAnsi(...i)):"hex"===e?S("rgb",t,n,...p.hexToRgb(...i)):p[n][e](...i);for(const e of["rgb","hex","ansi256"]){y[e]={get(){const{level:t}=this;return function(...n){const i=R(S(e,$[t],"color",...n),p.color.close,this[b]);return C(this,i,this[w])}}};y["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const i=R(S(e,$[t],"bgColor",...n),p.bgColor.close,this[b]);return C(this,i,this[w])}}}}var T=Object.defineProperties(()=>{},{...y,level:{enumerable:!0,get(){return this[x].level},set(e){this[x].level=e}}}),R=(e,t,n)=>{let i,r;return void 0===n?(i=e,r=t):(i=n.openAll+e,r=t+n.closeAll),{open:e,close:t,openAll:i,closeAll:r,parent:n}},C=(e,t,n)=>{const i=(...e)=>N(i,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(i,T),i[x]=e,i[b]=t,i[w]=n,i},N=(e,t)=>{if(e.level<=0||!t)return e[w]?"":t;let n=e[b];if(void 0===n)return t;const{openAll:i,closeAll:r}=n;if(t.includes(""))for(;void 0!==n;)t=m(t,n.close,n.open),n=n.parent;const o=t.indexOf("\n");return-1!==o&&(t=function(e,t,n,i){let r=0,o="";do{const s="\r"===e[i-1];o+=e.slice(r,s?i-1:i)+t+(s?"\r\n":"\n")+n,r=i+1,i=e.indexOf("\n",r)}while(-1!==i);return o+=e.slice(r),o}(t,r,i,o)),i+t+r};Object.defineProperties(A.prototype,y);var B=A(),z=(A({level:k?k.level:0}),B);function E(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var O={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function P(e){O=e}var D={exec:()=>null};function I(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(F.caret,"$1"),n=n.replace(e,r),i},getRegex:()=>new RegExp(n,t)};return i}var j=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),F={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},_=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,q=/(?:[*+-]|\d{1,9}[.)])/,M=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,L=I(M).replace(/bull/g,q).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),K=I(M).replace(/bull/g,q).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),V=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Z=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,G=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Z).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),U=I(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,q).getRegex(),H="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Q=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,W=I("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Q).replace("tag",H).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),X=I(V).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),Y={blockquote:I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",X).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:G,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:_,html:W,lheading:L,list:U,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:X,table:D,text:/^[^\n]+/},J=I("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),ee={...Y,lheading:K,table:J,paragraph:I(V).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",J).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex()},te={...Y,html:I("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Q).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:D,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(V).replace("hr",_).replace("heading"," *#{1,6} *[^\n]").replace("lheading",L).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ne=/^( {2,}|\\)\n(?!\s*$)/,ie=/[\p{P}\p{S}]/u,re=/[\s\p{P}\p{S}]/u,oe=/[^\s\p{P}\p{S}]/u,se=I(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,re).getRegex(),le=/(?!~)[\p{P}\p{S}]/u,ae=I(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",j?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,he=I(ce,"u").replace(/punct/g,ie).getRegex(),pe=I(ce,"u").replace(/punct/g,le).getRegex(),ue="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",de=I(ue,"gu").replace(/notPunctSpace/g,oe).replace(/punctSpace/g,re).replace(/punct/g,ie).getRegex(),ge=I(ue,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,le).getRegex(),me=I("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,oe).replace(/punctSpace/g,re).replace(/punct/g,ie).getRegex(),fe=I(/\\(punct)/,"gu").replace(/punct/g,ie).getRegex(),ke=I(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xe=I(Q).replace("(?:--\x3e|$)","--\x3e").getRegex(),be=I("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xe).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),we=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,$e=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",we).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ye=I(/^!?\[(label)\]\[(ref)\]/).replace("label",we).replace("ref",Z).getRegex(),ve=I(/^!?\[(ref)\](?:\[\])?/).replace("ref",Z).getRegex(),Ae=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Se={_backpedal:D,anyPunctuation:fe,autolink:ke,blockSkip:ae,br:ne,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:D,emStrongLDelim:he,emStrongRDelimAst:de,emStrongRDelimUnd:me,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:$e,nolink:ve,punctuation:se,reflink:ye,reflinkSearch:I("reflink|nolink(?!\\()","g").replace("reflink",ye).replace("nolink",ve).getRegex(),tag:be,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:D},Te={...Se,link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",we).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",we).getRegex()},Re={...Se,emStrongRDelimAst:ge,emStrongLDelim:pe,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ae).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ae).getRegex()},Ce={...Re,br:I(ne).replace("{2,}","*").getRegex(),text:I(Re.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ne={normal:Y,gfm:ee,pedantic:te},Be={normal:Se,gfm:Re,breaks:Ce,pedantic:Te},ze={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ee=e=>ze[e];function Oe(e,t){if(t){if(F.escapeTest.test(e))return e.replace(F.escapeReplace,Ee)}else if(F.escapeTestNoEncode.test(e))return e.replace(F.escapeReplaceNoEncode,Ee);return e}function Pe(e){try{e=encodeURI(e).replace(F.percentDecode,"%")}catch{return null}return e}function De(e,t){let n=e.replace(F.findPipe,(e,t,n)=>{let i=!1,r=t;for(;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"}).split(F.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(F.slashPipe,"|");return n}function Ie(e,t,n){let i=e.length;if(0===i)return"";let r=0;for(;r<i;){let o=e.charAt(i-r-1);if(o!==t||n){if(o===t||!n)break;r++}else r++}return e.slice(0,i-r)}function je(e,t,n,i,r){let o=t.href,s=t.title||null,l=e[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let a={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:o,title:s,text:l,tokens:i.inlineTokens(l)};return i.state.inLink=!1,a}var Fe=class{options;rules;lexer;constructor(e){this.options=e||O}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ie(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let r=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=r.length?e.slice(r.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Ie(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ie(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Ie(t[0],"\n").split("\n"),n="",i="",r=[];for(;e.length>0;){let t,o=!1,s=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))s.push(e[t]),o=!0;else{if(o)break;s.push(e[t])}e=e.slice(t);let l=s.join("\n"),a=l.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${l}`:l,i=i?`${i}\n${a}`:a;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(a,r,!0),this.lexer.state.top=c,0===e.length)break;let h=r.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,o=t.raw+"\n"+e.join("\n"),s=this.blockquote(o);r[r.length-1]=s,n=n.substring(0,n.length-t.raw.length)+s.raw,i=i.substring(0,i.length-t.text.length)+s.text;break}if("list"===h?.type){let t=h,o=t.raw+"\n"+e.join("\n"),s=this.list(o);r[r.length-1]=s,n=n.substring(0,n.length-h.raw.length)+s.raw,i=i.substring(0,i.length-t.raw.length)+s.raw,e=o.substring(r.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:r,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let o=this.rules.other.listItemRegex(n),s=!1;for(;e;){let n=!1,i="",l="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let a=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],h=!a.trim(),p=0;if(this.options.pedantic?(p=2,l=a.trimStart()):h?p=t[1].length+1:(p=t[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,l=a.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),r=this.rules.other.fencesBeginRegex(p),o=this.rules.other.headingBeginRegex(p),s=this.rules.other.htmlBeginRegex(p);for(;e;){let u,d=e.split("\n",1)[0];if(c=d,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),r.test(c)||o.test(c)||s.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=p||!c.trim())l+="\n"+u.slice(p);else{if(h||a.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||r.test(a)||o.test(a)||n.test(a))break;l+="\n"+c}!h&&!c.trim()&&(h=!0),i+=d+"\n",e=e.substring(d.length+1),a=u.slice(p)}}r.loose||(s?r.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(s=!0));let u=null;this.options.gfm&&(u=this.rules.other.listIsTask.exec(l),u&&(l=l.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:i,task:!!u,loose:!1,text:l,tokens:[]}),r.raw+=i}let l=r.items.at(-1);if(!l)return;l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd(),r.raw=r.raw.trimEnd();for(let e of r.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,r.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!r.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));r.loose=n}}if(r.loose)for(let e of r.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=De(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?o.align.push("right"):this.rules.other.tableAlignCenter.test(e)?o.align.push("center"):this.rules.other.tableAlignLeft.test(e)?o.align.push("left"):o.align.push(null);for(let e=0;e<n.length;e++)o.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:o.align[e]});for(let e of r)o.rows.push(De(e,o.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Ie(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),je(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return je(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,r,o=[...i[0]].length-1,s=o,l=0,a="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+o);null!=(i=a.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(r=[...n].length,i[3]||i[4]){s+=r;continue}if((i[5]||i[6])&&o%3&&!((o+r)%3)){l+=r;continue}if(s-=r,s>0)continue;r=Math.min(r,r+s+l);let t=[...i[0]][0].length,a=e.slice(0,o+i.index+t+r);if(Math.min(o,r)%2){let e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}let c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},_e=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||O,this.options.tokenizer=this.options.tokenizer||new Fe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:F,block:Ne.normal,inline:Be.normal};this.options.pedantic?(t.block=Ne.pedantic,t.inline=Be.pedantic):this.options.gfm&&(t.block=Ne.gfm,this.options.breaks?t.inline=Be.breaks:t.inline=Be.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ne,inline:Be}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(F.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(F.tabCharGlobal," ").replace(F.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let r=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(r))){let o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+=(o.raw.endsWith("\n")?"":"\n")+i.raw,o.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(i),n=r.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(i));)n=r[2]?r[2].length:0,i=i.slice(0,r.index+n)+"["+"a".repeat(r[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let o=!1,s="";for(;e;){let n;if(o||(s=""),o=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,s)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let r=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(r)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(s=n.raw.slice(-1)),o=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},qe=class{options;parser;constructor(e){this.options=e||O}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(F.notSpaceStart)?.[0],r=e.replace(F.endingNewline,"")+"\n";return i?'<pre><code class="language-'+Oe(i)+'">'+(n?r:Oe(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:Oe(r,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+r+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i="";for(let t=0;t<e.rows.length;t++){let r=e.rows[t];n="";for(let e=0;e<r.length;e++)n+=this.tablecell(r[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Oe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),r=Pe(e);if(null===r)return i;let o='<a href="'+(e=r)+'"';return t&&(o+=' title="'+Oe(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=Pe(e);if(null===r)return Oe(n);let o=`<img src="${e=r}" alt="${n}"`;return t&&(o+=` title="${Oe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Oe(e.text)}},Me=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Le=class e{options;renderer;textRenderer;constructor(e){this.options=e||O,this.options.renderer=this.options.renderer||new qe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Me}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let r=i;switch(r.type){case"space":t+=this.renderer.space(r);break;case"hr":t+=this.renderer.hr(r);break;case"heading":t+=this.renderer.heading(r);break;case"code":t+=this.renderer.code(r);break;case"table":t+=this.renderer.table(r);break;case"blockquote":t+=this.renderer.blockquote(r);break;case"list":t+=this.renderer.list(r);break;case"checkbox":t+=this.renderer.checkbox(r);break;case"html":t+=this.renderer.html(r);break;case"def":t+=this.renderer.def(r);break;case"paragraph":t+=this.renderer.paragraph(r);break;case"text":t+=this.renderer.text(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let r=e[i];if(this.options.extensions?.renderers?.[r.type]){let e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}let o=r;switch(o.type){case"escape":case"text":n+=t.text(o);break;case"html":n+=t.html(o);break;case"link":n+=t.link(o);break;case"image":n+=t.image(o);break;case"checkbox":n+=t.checkbox(o);break;case"strong":n+=t.strong(o);break;case"em":n+=t.em(o);break;case"codespan":n+=t.codespan(o);break;case"br":n+=t.br(o);break;case"del":n+=t.del(o);break;default:{let e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Ke=class{options;block;constructor(e){this.options=e||O}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?_e.lex:_e.lexInline}provideParser(){return this.block?Le.parse:Le.parseInline}},Ve=class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Le;Renderer=qe;TextRenderer=Me;Lexer=_e;Tokenizer=Fe;Hooks=Ke;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let r=e[i].flat(1/0);n=n.concat(this.walkTokens(r,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new qe(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,r=e.renderer[i],o=t[i];t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Fe(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,r=e.tokenizer[i],o=t[i];t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ke;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,r=e.hooks[i],o=t[i];Ke.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&Ke.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await r.call(t,e);return o.call(t,n)})();let i=r.call(t,e);return o.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await r.apply(t,e);return!1===n&&(n=await o.apply(t,e)),n})();let n=r.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return _e.lex(e,t??this.defaults)}parser(e,t){return Le.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(!0===this.defaults.async&&!1===i.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,i=await(r.hooks?await r.hooks.provideLexer():e?_e.lex:_e.lexInline)(n,r),o=r.hooks?await r.hooks.processAllTokens(i):i;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let s=await(r.hooks?await r.hooks.provideParser():e?Le.parse:Le.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(s):s})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer():e?_e.lex:_e.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let i=(r.hooks?r.hooks.provideParser():e?Le.parse:Le.parseInline)(n,r);return r.hooks&&(i=r.hooks.postprocess(i)),i}catch(e){return o(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Oe(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Ze=new Ve;function Ge(e,t){return Ze.parse(e,t)}Ge.options=Ge.setOptions=function(e){return Ze.setOptions(e),Ge.defaults=Ze.defaults,P(Ge.defaults),Ge},Ge.getDefaults=E,Ge.defaults=O,Ge.use=function(...e){return Ze.use(...e),Ge.defaults=Ze.defaults,P(Ge.defaults),Ge},Ge.walkTokens=function(e,t){return Ze.walkTokens(e,t)},Ge.parseInline=Ze.parseInline,Ge.Parser=Le,Ge.parser=Le.parse,Ge.Renderer=qe,Ge.TextRenderer=Me,Ge.Lexer=_e,Ge.lexer=_e.lex,Ge.Tokenizer=Fe,Ge.Hooks=Ke,Ge.parse=Ge;Ge.options,Ge.setOptions,Ge.use,Ge.walkTokens,Ge.parseInline,Le.parse,_e.lex,z.bold,z.italic,z.bold.italic,z.strikethrough,z.underline,z.whiteBright,z.dim;var Ue=class e{static noColor=(...e)=>e.join(" ");title=e.noColor;description=e.noColor;default=e.noColor;optional=e.noColor;exampleTitle=e.noColor;example=e.noColor;command=e.noColor;option=e.noColor;argument=e.noColor;placeholder=e.noColor;punctuation=e.noColor;constructor(e,t){t&&Object.assign(this,t),Object.assign(this,e)}};Object.freeze({default:new Ue({title:z.bold.blue,description:z.white,default:z.dim.italic,optional:z.dim.italic,exampleTitle:z.yellow,example:z.dim,command:z.yellow,option:z.cyan,argument:z.green,placeholder:z.hex("#FF9800"),punctuation:z.white.dim}),dracula:new Ue({title:z.bold.hex("#BD93F9"),description:z.hex("#F8F8F2"),default:z.italic.hex("#6272A4"),optional:z.italic.hex("#6272A4"),exampleTitle:z.hex("#FFB86C"),example:z.hex("#6272A4"),command:z.hex("#50FA7B"),option:z.hex("#8BE9FD"),argument:z.hex("#FF79C6"),placeholder:z.hex("#F1FA8C"),punctuation:z.hex("#6272A4")}),solarizedDark:new Ue({title:z.bold.hex("#268BD2"),description:z.hex("#93A1A1"),default:z.italic.hex("#586E75"),optional:z.italic.hex("#586E75"),exampleTitle:z.hex("#B58900"),example:z.hex("#586E75"),command:z.hex("#2AA198"),option:z.hex("#268BD2"),argument:z.hex("#859900"),placeholder:z.hex("#CB4B16"),punctuation:z.hex("#657B83")}),nord:new Ue({title:z.bold.hex("#81A1C1"),description:z.hex("#D8DEE9"),default:z.italic.hex("#4C566A"),optional:z.italic.hex("#4C566A"),exampleTitle:z.hex("#EBCB8B"),example:z.hex("#4C566A"),command:z.hex("#A3BE8C"),option:z.hex("#88C0D0"),argument:z.hex("#BF616A"),placeholder:z.hex("#D08770"),punctuation:z.hex("#4C566A")}),html:new Ue({title:(...e)=>`<span style="color: #89dceb; font-weight: bold;">${He(e.join(" "))}</span>`,description:(...e)=>`<span style="color: #cdd6e8;">${He(e.join(" "))}</span>`,default:(...e)=>`<span style="color: #6c7086; font-style: italic;">${He(e.join(" "))}</span>`,optional:(...e)=>`<span style="color: #6c7086; font-style: italic;">${He(e.join(" "))}</span>`,exampleTitle:(...e)=>`<span style="color: #f9e2af;">${He(e.join(" "))}</span>`,example:(...e)=>`<span style="color: #6c7086;">${He(e.join(" "))}</span>`,command:(...e)=>`<span style="color: #f9e2af;">${He(e.join(" "))}</span>`,option:(...e)=>`<span style="color: #17b85d;">${He(e.join(" "))}</span>`,argument:(...e)=>`<span style="color: #00ff00;">${He(e.join(" "))}</span>`,placeholder:(...e)=>`<span style="color: #db9518;">${He(e.join(" "))}</span>`,punctuation:(...e)=>`<span style="color: #6c7086;">${He(e.join(" "))}</span>`}),gruvboxDark:new Ue({title:z.bold.hex("#FABD2F"),description:z.hex("#EBDBB2"),default:z.italic.hex("#928374"),optional:z.italic.hex("#928374"),exampleTitle:z.hex("#FE8019"),example:z.hex("#928374"),command:z.hex("#B8BB26"),option:z.hex("#83A598"),argument:z.hex("#D3869B"),placeholder:z.hex("#FB4934"),punctuation:z.hex("#928374")}),monokai:new Ue({title:z.bold.hex("#AE81FF"),description:z.hex("#F8F8F2"),default:z.italic.hex("#75715E"),optional:z.italic.hex("#75715E"),exampleTitle:z.hex("#FD971F"),example:z.hex("#75715E"),command:z.hex("#A6E22E"),option:z.hex("#66D9EF"),argument:z.hex("#F92672"),placeholder:z.hex("#E6DB74"),punctuation:z.hex("#75715E")}),oneDark:new Ue({title:z.bold.hex("#61AFEF"),description:z.hex("#ABB2BF"),default:z.italic.hex("#5C6370"),optional:z.italic.hex("#5C6370"),exampleTitle:z.hex("#E5C07B"),example:z.hex("#5C6370"),command:z.hex("#98C379"),option:z.hex("#56B6C2"),argument:z.hex("#E06C75"),placeholder:z.hex("#C678DD"),punctuation:z.hex("#5C6370")}),catppuccin:new Ue({title:z.bold.hex("#89B4FA"),description:z.hex("#CDD6F4"),default:z.italic.hex("#6C7086"),optional:z.italic.hex("#6C7086"),exampleTitle:z.hex("#F9E2AF"),example:z.hex("#6C7086"),command:z.hex("#A6E3A1"),option:z.hex("#94E2D5"),argument:z.hex("#F38BA8"),placeholder:z.hex("#FAB387"),punctuation:z.hex("#585B70")}),noColors:new Ue({})});function He(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qe(e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1;throw new s({cause:t.Validation,code:o.CoercionFailed,context:{coerceToType:"boolean",providedValue:e}})}var We=e=>Qe(e);We.type="boolean"})();
1
+ "use strict";var ZodArgsParser=(()=>{var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o={};function a(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function r(e){return"\n".repeat(e)}function s(e){return e<=0?"":" ".repeat(e)}function l(e,n){return e.replace(/\n/g,"\n"+s(n))}function c(e){return e instanceof Set?"new Set(["+Array.from(e).map(e=>c(e)).join(", ")+"])":JSON.stringify(e)}function u(e,n){const t=e.split("\n");return t[0]+=(t[0]?" ":"")+n,t.join("\n")}function d(e){let n=e.placeholder;return n||(e.options.length>0&&(n+=(n?" ":"")+"[options]"),e.arguments.length>0&&(n+=(n?" ":"")+"<arguments>"),e.allowPositionals&&(n+=(n?" ":"")+"<positionals>"),n||(n=" "),n)}((n,t)=>{for(var i in t)e(n,i,{get:t[i],enumerable:!0})})(o,{CliError:()=>w,DefinitionErrorCode:()=>g,ErrorCause:()=>f,HelpMessageStyle:()=>Tn,InternalErrorCode:()=>x,ParseErrorCode:()=>k,ValidationErrorCode:()=>b,coerce:()=>pt,defineArguments:()=>Ln,defineCLI:()=>it,defineOptions:()=>ot,defineSubcommand:()=>at,generateBashAutocompleteScript:()=>Bn,generateCliHelpMessage:()=>Dn,generateMarkdown:()=>Kn,generatePowerShellAutocompleteScript:()=>Mn,generateSubcommandHelpMessage:()=>Pn,generateZshAutocompleteScript:()=>En,getArgumentsMetadata:()=>A,getCliMetadata:()=>B,getOptionsMetadata:()=>_,getSubcommandsMetadata:()=>j,helpMessageStyles:()=>On,printCliHelp:()=>_n,printSubcommandHelp:()=>jn});var m=function({onlyFirst:e=!1}={}){const n=String.raw`(?:\u0007|\u001B\u005C|\u009C)`,t=String.raw`(?:\u001B\][\s\S]*?${n})`,i=String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]`;return new RegExp(`${t}|${i}`,e?void 0:"g")}();function p(e,n,t=""){for(const[i,o]of Object.entries(e)){const a=t?`${t}.${i}`:i,r=n(i,o,a);void 0!==r&&(e[i]=r);const s=e[i];s&&"object"==typeof s&&!Array.isArray(s)&&p(s,n,a)}}function h(e){const n=e;for(const[e]of Object.entries(n))n[e]=e;return Object.freeze(n)}var f=h({Internal:void 0,Parse:void 0,Validation:void 0,Definition:void 0}),g=h({MissingSchema:void 0,EmptyDefinitionGroup:void 0,MissingDefinitionName:void 0,InvalidDefinitionOptionName:void 0,InvalidDefinitionArgumentName:void 0,InvalidOptionalArgumentDefinition:void 0,DuplicateDefinitionName:void 0,EmptyStringAliasName:void 0,SelfRequire:void 0,UnknownRequireName:void 0,SelfConflict:void 0,UnknownConflictName:void 0,DefinitionRequiresConflictOverlap:void 0,MissingOnExecute:void 0,SubcommandHelpNotFound:void 0});var x=h({MissingPreparedTypes:void 0,CannotFindCliDefinition:void 0});var k=h({UnknownSubcommand:void 0,CommandWithoutOptions:void 0,UnknownOption:void 0,DuplicateOptionProvided:void 0,InvalidNegationForNonBooleanOption:void 0,PositionalArgumentNotAllowed:void 0,MissingRequiredOption:void 0,MissingRequiredArgument:void 0,OptionMissingValue:void 0,FlagAssignedValue:void 0});var b=h({NoOptionsToValidate:void 0,NoArgumentsToValidate:void 0,UnknownOptionValidation:void 0,UnknownArgumentValidation:void 0,SchemaValidationFailed:void 0,MutuallyExclusiveConflict:void 0,RequiredDependencyMissing:void 0,AsyncSchemaNotSupported:void 0,CoercionFailed:void 0});var w=class e extends Error{code;cause;context;constructor(n){super(n.message??e.errorMessage(n)),this.cause=n.cause,this.code=n.code,this.context=n.context}static errorMessage(e){const n="unknown error";if(e.cause===f.Internal)return function({code:e,context:n}){return e===x.MissingPreparedTypes?`internal error: missing prepared type for option "${n.name}" in ${n.commandKind} "${n.commandName}"`:e===x.CannotFindCliDefinition?`internal error: cannot find cli definition "${n.cliName}"`:e}(e)??n;if(e.cause===f.Parse)return function({code:e,context:n}){return e===k.UnknownSubcommand?`parsing error: unknown subcommand "${n.commandName}".`:e===k.CommandWithoutOptions?`parsing error: the ${n.commandKind} "${n.commandName}" does not allow options, but received "${n.optionName}".`:e===k.UnknownOption?`parsing error: unknown option "${n.optionName}" for the ${n.commandKind} "${n.commandName}".`:e===k.DuplicateOptionProvided?`parsing error: duplicate option "${n.optionName}" provided for the ${n.commandKind} "${n.commandName}".`:e===k.InvalidNegationForNonBooleanOption?`parsing error: option "${n.optionName}" cannot be negated because it is not a boolean option for the ${n.commandKind} "${n.commandName}".`:e===k.PositionalArgumentNotAllowed?`parsing error: positional argument "${n.argumentName}" is not allowed for the ${n.commandKind} "${n.commandName}".`:e===k.MissingRequiredOption?`parsing error: missing required option "${n.optionName}" for the ${n.commandKind} "${n.commandName}".`:e===k.MissingRequiredArgument?`parsing error: missing required argument "${n.argumentName}" for the ${n.commandKind} "${n.commandName}".`:e===k.OptionMissingValue?`parsing error: the option "${n.optionName}" for the ${n.commandKind} "${n.commandName}" expects a value but received none.`:e===k.FlagAssignedValue?`parsing error: flag option "${n.flag}" in ${n.commandKind} "${n.commandName}" cannot be assigned a value using "=" (provided: "${n.value}").`:e}(e)??n;if(e.cause===f.Definition)return function({code:e,context:n}){if(e===g.MissingDefinitionName){const e="command"===n.commandKind?"cliName":"name";return`invalid ${n.commandKind} definition: "${e}" property is required.`}if(e===g.EmptyDefinitionGroup)return`invalid ${n.commandKind} definition "${n.commandName}": "${n.kind}" property is optional but cannot be empty.`;if(e===g.MissingSchema)return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" is missing the "schema" property.`;if(e===g.InvalidDefinitionOptionName)return n.negatedAliasName?`invalid ${n.commandKind} definition "${n.commandName}": the option "${n.optionName}" has the alias "${n.negatedAliasName}" which cannot be named as a negated option.`:`invalid ${n.commandKind} definition "${n.commandName}": the option "${n.optionName}" cannot be named as a negated option.`;if(e===g.InvalidDefinitionArgumentName)return`invalid ${n.commandKind} definition "${n.commandName}": the argument "${n.name}" cannot be a number..`;if(e===g.DuplicateDefinitionName){const e=n.foundInName?`conflict with the ${n.foundInKind} "${n.foundInName}" alias name`:`conflict with other ${n.foundInKind} name`;return n.duplicatedAlias?`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" has the alias "${n.duplicatedAlias}" which ${e}.`:`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" name ${e}.`}if(e===g.EmptyStringAliasName)return n.optionName?`invalid ${n.commandKind} definition "${n.commandName}": the option "${n.optionName}" has an empty string alias name.`:`invalid ${n.commandKind} definition "${n.commandName}": empty string alias name is not allowed.`;if(e===g.SelfRequire)return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" cannot require itself.`;if(e===g.UnknownRequireName)return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" requires a non-existent name "${n.requiredName}".`;if(e===g.SelfConflict)return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" cannot conflict with itself.`;if(e===g.UnknownConflictName)return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" conflicts with a non-existent name "${n.requiredName}".`;if(e===g.DefinitionRequiresConflictOverlap){const e=n.intersectedNames.length>1?"s":"";return`invalid ${n.commandKind} definition "${n.commandName}": the ${n.kind} "${n.name}" has overlapping 'requires' and 'conflictsWith' name${e}: `+n.intersectedNames.join(", ")}return e===g.InvalidOptionalArgumentDefinition?n.allowPositionals?`invalid ${n.commandKind} definition "${n.commandName}": the argument "${n.name}" cannot be optional when "allowPositionals" is enabled.`:`invalid ${n.commandKind} definition "${n.commandName}": the argument "${n.name}" cannot be optional unless it is the last argument.`:e===g.MissingOnExecute?`trying to execute ${n.commandKind} "${n.commandName}" which does not have an "onExecute" handler.`:e===g.SubcommandHelpNotFound?`cannot generate help message for subcommand "${n.subcommandName}" because it does not exist in CLI "${n.cliName}".`:e}(e)??n;if(e.cause===f.Validation)return function({code:e,context:n}){if(e===b.NoOptionsToValidate)return`validation error: trying to validate options for ${n.commandKind} "${n.commandName}" which does not define any.`;if(e===b.NoArgumentsToValidate)return`validation error: trying to validate typed arguments for ${n.commandKind} "${n.commandName}" which does not define any.`;if(e===b.UnknownOptionValidation)return`validation error: trying to validate a non-existent option "${n.optionName}" for ${n.commandKind} "${n.commandName}".`;if(e===b.UnknownArgumentValidation)return`validation error: trying to validate a non-existent typed argument "${n.argumentName}" for ${n.commandKind} "${n.commandName}".`;if(e===b.SchemaValidationFailed)return`validation error: the ${n.kind} "${n.name}" for ${n.commandKind} "${n.commandName}" failed to validate "${"string"==typeof n.inputValue?n.inputValue:JSON.stringify(n.inputValue)}": `+n.issues.map(e=>{const n=e.path?.map(e=>"object"==typeof e&&"key"in e?e.key:e),t=n&&n.length>0?` at "${n.join(".")}"`:"";return`${e.message}${t}`}).join(" : ");if(e===b.MutuallyExclusiveConflict){const e=[];if(n.conflictedOptions.length>0){const t=n.conflictedOptions.map(e=>`"${e}"`).join(", "),i=n.conflictedOptions.length>1?"s":"";e.push(`option${i} ${t}`)}if(n.conflictedArguments.length>0){const t=n.conflictedArguments.map(e=>`"${e}"`).join(", "),i=n.conflictedArguments.length>1?"s":"";e.push(`argument${i} ${t}`)}return`validation error: the ${n.kind} "${n.name}" cannot be used with the ${e.join(" and ")} because they are mutually exclusive.`}if(e===b.RequiredDependencyMissing){const e=[];if(n.missingOptions.length>0){const t=n.missingOptions.map(e=>`"${e}"`).join(", "),i=n.missingOptions.length>1?"s":"";e.push(`option${i} ${t}`)}if(n.missingArguments.length>0){const t=n.missingArguments.map(e=>`"${e}"`).join(", "),i=n.missingArguments.length>1?"s":"";e.push(`argument${i} ${t}`)}return`validation error: the ${n.kind} "${n.name}" cannot be used without the required "${e.join(" and ")}".`}return e===b.AsyncSchemaNotSupported?`validation error: cannot validate async schema: received ${"string"==typeof n.value?n.value:JSON.stringify(n.value)}`:e===b.CoercionFailed?`validation error: failed to coerce the value "${"string"==typeof n.providedValue?n.providedValue:JSON.stringify(n.providedValue)}" of type "${typeof n.providedValue}" to type "${n.coerceToType}".`:e}(e)??n;return e}};function $(e,n){const t=e["~standard"].validate(n);if(t instanceof Promise)throw new w({cause:f.Validation,code:b.AsyncSchemaNotSupported,context:{schema:e,value:n}});return t}function y(e){const n=$(e);return n.issues?{defaultValue:void 0,optional:!1}:{defaultValue:n.value,optional:!0}}function N(e,n){const{optional:t,defaultValue:i}=y(e);return{schema:e,optional:t,defaultValue:i,coerceTo:n.type,validate:t=>$(e,t&&n(t))}}function v(e){if(e)for(const n of Object.values(e))n.coerce||(n.coerce=e=>e),n._preparedType||(n._preparedType=N(n.schema,n.coerce))}function A(e){const n=[];for(const[t,i]of Object.entries(e)){const e=i.meta??{},{optional:o,defaultValue:a}=i._preparedType??y(i.schema);n.push({name:e.name??t,description:e.description??"",descriptionMarkdown:e.descriptionMarkdown??"",defaultValue:a,defaultValueAsString:e.default??c(a)??"",optional:e.optional??o,example:e.example??"",schema:i.schema,hidden:e.hidden??!1})}return n}function S(e,n){return void 0===e?n:n.subcommands?n.subcommands.find(n=>n.name===e||e&&n.aliases&&n.aliases.includes(e)):void 0}function T(e,n){const t=function(e){e=(e=e.startsWith("--")?e.slice(2):e.slice(1)).toLowerCase();const n=new Set,t=e.replace(/-(.)/g,e=>e[1].toUpperCase());n.add(t),n.add(t.replace(/^(.)/,e=>e.toUpperCase()));const i=e.replace(/-(.)/g,e=>"_"+e[1]);return n.add(i),n.add(i.toUpperCase()),n}(e),i=e.startsWith("--no-");return Object.entries(n).find(([e,n])=>!!t.has(e)||(!(!i||!t.has(R(e)))||!!n.aliases&&(!!n.aliases.some(e=>t.has(e))||!(!i||!n.aliases.map(e=>R(e)).some(e=>t.has(e))))))}function O(e){return/^-[A-Za-z]$/.test(e)}function C(e){return"string"==typeof e&&(O(e)||function(e){return/^--.{2,}/.test(e)}(e))}function R(e){return"no"+e.replace(/^[a-z]/,e=>e.toUpperCase())}function D(e){return 1===e.length?`-${e.toLowerCase()}`:/^[a-z_]+$/.test(e)||/^[A-Z_]+$/.test(e)?`--${(e=e.replace(/_/g,"-")).toLowerCase()}`:`--${(e=e.replace(/[A-Z]/g,(e,n)=>n>0?"-"+e:e)).toLowerCase()}`}function P(e){const n=e.split(".");return[n[0],n.slice(1).filter(Boolean)]}function _(e){const n=[];if(!e)return n;for(const[t,i]of Object.entries(e)){const e=i.aliases??[],o=i.meta??{},{optional:a,defaultValue:r}=i._preparedType??y(i.schema);n.push({name:t,nameAsArg:D(t),aliases:e,aliasesAsArgs:e.map(e=>D(e)),placeholder:o.placeholder??"",description:o.description??"",descriptionMarkdown:o.descriptionMarkdown??"",optional:o.optional??a,example:o.example??"",defaultValue:r,defaultValueAsString:o.default??c(r)??"",schema:i.schema,hidden:o.hidden??!1})}return n}function j(e){const n=[];if(!e||0===e.length)return n;for(const t of e){const e=t.options?_(t.options):[],i=t.arguments?A(t.arguments):[],o=t.meta??{};n.push({name:t.name,aliases:t.aliases??[],description:o.description??"",descriptionMarkdown:o.descriptionMarkdown??"",placeholder:o.placeholder??"",usage:o.usage??"",example:o.example??"",allowPositionals:t.allowPositionals??!1,options:e,arguments:i,hidden:o.hidden??!1})}return n}function B(e){const n=e.subcommands??[],t=e.meta??{};return{name:e.cliName,description:t.description??"",descriptionMarkdown:t.descriptionMarkdown??"",usage:t.usage??"",example:t.example??"",allowPositionals:e.allowPositionals??!1,options:e.options?_(e.options):[],arguments:e.arguments?A(e.arguments):[],subcommands:n?j(n):[]}}var M=(e=0)=>n=>`[${n+e}m`,E=(e=0)=>n=>`[${38+e};5;${n}m`,K=(e=0)=>(n,t,i)=>`[${38+e};2;${n};${t};${i}m`,I={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(I.modifier),Object.keys(I.color),Object.keys(I.bgColor);var V=function(){const e=new Map;for(const[n,t]of Object.entries(I)){for(const[n,i]of Object.entries(t))I[n]={open:`[${i[0]}m`,close:`[${i[1]}m`},t[n]=I[n],e.set(i[0],i[1]);Object.defineProperty(I,n,{value:t,enumerable:!1})}return Object.defineProperty(I,"codes",{value:e,enumerable:!1}),I.color.close="",I.bgColor.close="",I.color.ansi=M(),I.color.ansi256=E(),I.color.ansi16m=K(),I.bgColor.ansi=M(10),I.bgColor.ansi256=E(10),I.bgColor.ansi16m=K(10),Object.defineProperties(I,{rgbToAnsi256:{value:(e,n,t)=>e===n&&n===t?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(t/255*5),enumerable:!1},hexToRgb:{value(e){const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!n)return[0,0,0];let[t]=n;3===t.length&&(t=[...t].map(e=>e+e).join(""));const i=Number.parseInt(t,16);return[i>>16&255,i>>8&255,255&i]},enumerable:!1},hexToAnsi256:{value:e=>I.rgbToAnsi256(...I.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let n,t,i;if(e>=232)n=(10*(e-232)+8)/255,t=n,i=n;else{const o=(e-=16)%36;n=Math.floor(e/36)/5,t=Math.floor(o/6)/5,i=o%6/5}const o=2*Math.max(n,t,i);if(0===o)return 30;let a=30+(Math.round(i)<<2|Math.round(t)<<1|Math.round(n));return 2===o&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,n,t)=>I.ansi256ToAnsi(I.rgbToAnsi256(e,n,t)),enumerable:!1},hexToAnsi:{value:e=>I.ansi256ToAnsi(I.hexToAnsi256(e)),enumerable:!1}}),I}(),z=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),q=0!==z&&{level:z,hasBasic:!0,has256:z>=2,has16m:z>=3},L={stdout:q,stderr:q};function F(e,n,t){let i=e.indexOf(n);if(-1===i)return e;const o=n.length;let a=0,r="";do{r+=e.slice(a,i)+n+t,a=i+o,i=e.indexOf(n,a)}while(-1!==i);return r+=e.slice(a),r}var{stdout:W,stderr:U}=L,Z=Symbol("GENERATOR"),G=Symbol("STYLER"),H=Symbol("IS_EMPTY"),Q=["ansi","ansi","ansi256","ansi16m"],J=Object.create(null),X=e=>{const n=(...e)=>e.join(" ");return((e,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const t=W?W.level:0;e.level=void 0===n.level?t:n.level})(n,e),Object.setPrototypeOf(n,Y.prototype),n};function Y(e){return X(e)}Object.setPrototypeOf(Y.prototype,Function.prototype);for(const[e,n]of Object.entries(V))J[e]={get(){const t=ie(this,te(n.open,n.close,this[G]),this[H]);return Object.defineProperty(this,e,{value:t}),t}};J.visible={get(){const e=ie(this,this[G],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var ee=(e,n,t,...i)=>"rgb"===e?"ansi16m"===n?V[t].ansi16m(...i):"ansi256"===n?V[t].ansi256(V.rgbToAnsi256(...i)):V[t].ansi(V.rgbToAnsi(...i)):"hex"===e?ee("rgb",n,t,...V.hexToRgb(...i)):V[t][e](...i);for(const e of["rgb","hex","ansi256"]){J[e]={get(){const{level:n}=this;return function(...t){const i=te(ee(e,Q[n],"color",...t),V.color.close,this[G]);return ie(this,i,this[H])}}};J["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:n}=this;return function(...t){const i=te(ee(e,Q[n],"bgColor",...t),V.bgColor.close,this[G]);return ie(this,i,this[H])}}}}var ne=Object.defineProperties(()=>{},{...J,level:{enumerable:!0,get(){return this[Z].level},set(e){this[Z].level=e}}}),te=(e,n,t)=>{let i,o;return void 0===t?(i=e,o=n):(i=t.openAll+e,o=n+t.closeAll),{open:e,close:n,openAll:i,closeAll:o,parent:t}},ie=(e,n,t)=>{const i=(...e)=>oe(i,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(i,ne),i[Z]=e,i[G]=n,i[H]=t,i},oe=(e,n)=>{if(e.level<=0||!n)return e[H]?"":n;let t=e[G];if(void 0===t)return n;const{openAll:i,closeAll:o}=t;if(n.includes(""))for(;void 0!==t;)n=F(n,t.close,t.open),t=t.parent;const a=n.indexOf("\n");return-1!==a&&(n=function(e,n,t,i){let o=0,a="";do{const r="\r"===e[i-1];a+=e.slice(o,r?i-1:i)+n+(r?"\r\n":"\n")+t,o=i+1,i=e.indexOf("\n",o)}while(-1!==i);return a+=e.slice(o),a}(n,o,i,a)),i+n+o};Object.defineProperties(Y.prototype,J);var ae=Y(),re=(Y({level:U?U.level:0}),ae);function se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var le={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function ce(e){le=e}var ue={exec:()=>null};function de(e,n=""){let t="string"==typeof e?e:e.source,i={replace:(e,n)=>{let o="string"==typeof n?n:n.source;return o=o.replace(pe.caret,"$1"),t=t.replace(e,o),i},getRegex:()=>new RegExp(t,n)};return i}var me=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),pe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},he=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,fe=/(?:[*+-]|\d{1,9}[.)])/,ge=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xe=de(ge).replace(/bull/g,fe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ke=de(ge).replace(/bull/g,fe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),be=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,we=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$e=de(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",we).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ye=de(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fe).getRegex(),Ne="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ae=de("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",ve).replace("tag",Ne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se=de(be).replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Te={blockquote:de(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Se).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:$e,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:he,html:Ae,lheading:xe,list:ye,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Se,table:ue,text:/^[^\n]+/},Oe=de("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Ce={...Te,lheading:ke,table:Oe,paragraph:de(be).replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Oe).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex()},Re={...Te,html:de("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ve).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:de(be).replace("hr",he).replace("heading"," *#{1,6} *[^\n]").replace("lheading",xe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},De=/^( {2,}|\\)\n(?!\s*$)/,Pe=/[\p{P}\p{S}]/u,_e=/[\s\p{P}\p{S}]/u,je=/[^\s\p{P}\p{S}]/u,Be=de(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_e).getRegex(),Me=/(?!~)[\p{P}\p{S}]/u,Ee=de(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",me?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ke=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ie=de(Ke,"u").replace(/punct/g,Pe).getRegex(),Ve=de(Ke,"u").replace(/punct/g,Me).getRegex(),ze="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",qe=de(ze,"gu").replace(/notPunctSpace/g,je).replace(/punctSpace/g,_e).replace(/punct/g,Pe).getRegex(),Le=de(ze,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Me).getRegex(),Fe=de("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,je).replace(/punctSpace/g,_e).replace(/punct/g,Pe).getRegex(),We=de(/\\(punct)/,"gu").replace(/punct/g,Pe).getRegex(),Ue=de(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ze=de(ve).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ge=de("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ze).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),He=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Qe=de(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",He).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Je=de(/^!?\[(label)\]\[(ref)\]/).replace("label",He).replace("ref",we).getRegex(),Xe=de(/^!?\[(ref)\](?:\[\])?/).replace("ref",we).getRegex(),Ye=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,en={_backpedal:ue,anyPunctuation:We,autolink:Ue,blockSkip:Ee,br:De,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ue,emStrongLDelim:Ie,emStrongRDelimAst:qe,emStrongRDelimUnd:Fe,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Qe,nolink:Xe,punctuation:Be,reflink:Je,reflinkSearch:de("reflink|nolink(?!\\()","g").replace("reflink",Je).replace("nolink",Xe).getRegex(),tag:Ge,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ue},nn={...en,link:de(/^!?\[(label)\]\((.*?)\)/).replace("label",He).getRegex(),reflink:de(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",He).getRegex()},tn={...en,emStrongRDelimAst:Le,emStrongLDelim:Ve,url:de(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ye).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:de(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ye).getRegex()},on={...tn,br:de(De).replace("{2,}","*").getRegex(),text:de(tn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},an={normal:Te,gfm:Ce,pedantic:Re},rn={normal:en,gfm:tn,breaks:on,pedantic:nn},sn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ln=e=>sn[e];function cn(e,n){if(n){if(pe.escapeTest.test(e))return e.replace(pe.escapeReplace,ln)}else if(pe.escapeTestNoEncode.test(e))return e.replace(pe.escapeReplaceNoEncode,ln);return e}function un(e){try{e=encodeURI(e).replace(pe.percentDecode,"%")}catch{return null}return e}function dn(e,n){let t=e.replace(pe.findPipe,(e,n,t)=>{let i=!1,o=n;for(;--o>=0&&"\\"===t[o];)i=!i;return i?"|":" |"}).split(pe.splitPipe),i=0;if(t[0].trim()||t.shift(),t.length>0&&!t.at(-1)?.trim()&&t.pop(),n)if(t.length>n)t.splice(n);else for(;t.length<n;)t.push("");for(;i<t.length;i++)t[i]=t[i].trim().replace(pe.slashPipe,"|");return t}function mn(e,n,t){let i=e.length;if(0===i)return"";let o=0;for(;o<i;){let a=e.charAt(i-o-1);if(a!==n||t){if(a===n||!t)break;o++}else o++}return e.slice(0,i-o)}function pn(e,n,t,i,o){let a=n.href,r=n.title||null,s=e[1].replace(o.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:t,href:a,title:r,text:s,tokens:i.inlineTokens(s)};return i.state.inLink=!1,l}var hn=class{options;rules;lexer;constructor(e){this.options=e||le}space(e){let n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){let n=this.rules.block.code.exec(e);if(n){let e=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:mn(e,"\n")}}}fences(e){let n=this.rules.block.fences.exec(e);if(n){let e=n[0],t=function(e,n,t){let i=e.match(t.other.indentCodeCompensation);if(null===i)return n;let o=i[1];return n.split("\n").map(e=>{let n=e.match(t.other.beginningSpace);if(null===n)return e;let[i]=n;return i.length>=o.length?e.slice(o.length):e}).join("\n")}(e,n[3]||"",this.rules);return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:t}}}heading(e){let n=this.rules.block.heading.exec(e);if(n){let e=n[2].trim();if(this.rules.other.endingHash.test(e)){let n=mn(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:mn(n[0],"\n")}}blockquote(e){let n=this.rules.block.blockquote.exec(e);if(n){let e=mn(n[0],"\n").split("\n"),t="",i="",o=[];for(;e.length>0;){let n,a=!1,r=[];for(n=0;n<e.length;n++)if(this.rules.other.blockquoteStart.test(e[n]))r.push(e[n]),a=!0;else{if(a)break;r.push(e[n])}e=e.slice(n);let s=r.join("\n"),l=s.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");t=t?`${t}\n${s}`:s,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,o,!0),this.lexer.state.top=c,0===e.length)break;let u=o.at(-1);if("code"===u?.type)break;if("blockquote"===u?.type){let n=u,a=n.raw+"\n"+e.join("\n"),r=this.blockquote(a);o[o.length-1]=r,t=t.substring(0,t.length-n.raw.length)+r.raw,i=i.substring(0,i.length-n.text.length)+r.text;break}if("list"===u?.type){let n=u,a=n.raw+"\n"+e.join("\n"),r=this.list(a);o[o.length-1]=r,t=t.substring(0,t.length-u.raw.length)+r.raw,i=i.substring(0,i.length-n.raw.length)+r.raw,e=a.substring(o.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:t,tokens:o,text:i}}}list(e){let n=this.rules.block.list.exec(e);if(n){let t=n[1].trim(),i=t.length>1,o={type:"list",raw:"",ordered:i,start:i?+t.slice(0,-1):"",loose:!1,items:[]};t=i?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=i?t:"[*+-]");let a=this.rules.other.listItemRegex(t),r=!1;for(;e;){let t=!1,i="",s="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;i=n[0],e=e.substring(i.length);let l=n[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],u=!l.trim(),d=0;if(this.options.pedantic?(d=2,s=l.trimStart()):u?d=n[1].length+1:(d=n[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=l.slice(d),d+=n[1].length),u&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),t=!0),!t){let n=this.rules.other.nextBulletRegex(d),t=this.rules.other.hrRegex(d),o=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),r=this.rules.other.htmlBeginRegex(d);for(;e;){let m,p=e.split("\n",1)[0];if(c=p,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),m=c):m=c.replace(this.rules.other.tabCharGlobal," "),o.test(c)||a.test(c)||r.test(c)||n.test(c)||t.test(c))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!c.trim())s+="\n"+m.slice(d);else{if(u||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||o.test(l)||a.test(l)||t.test(l))break;s+="\n"+c}!u&&!c.trim()&&(u=!0),i+=p+"\n",e=e.substring(p.length+1),l=m.slice(d)}}o.loose||(r?o.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(r=!0));let m=null;this.options.gfm&&(m=this.rules.other.listIsTask.exec(s),m&&(s=s.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:i,task:!!m,loose:!1,text:s,tokens:[]}),o.raw+=i}let s=o.items.at(-1);if(!s)return;s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd(),o.raw=o.raw.trimEnd();for(let e of o.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,o.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!o.loose){let n=e.tokens.filter(e=>"space"===e.type),t=n.length>0&&n.some(e=>this.rules.other.anyLine.test(e.raw));o.loose=t}}if(o.loose)for(let e of o.items){e.loose=!0;for(let n of e.tokens)"text"===n.type&&(n.type="paragraph")}return o}}html(e){let n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:"pre"===n[1]||"script"===n[1]||"style"===n[1],text:n[0]}}def(e){let n=this.rules.block.def.exec(e);if(n){let e=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),t=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:t,title:i}}}table(e){let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let t=dn(n[1]),i=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(t.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of o)a.rows.push(dn(e,a.header.length).map((e,n)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[n]})));return a}}lheading(e){let n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:"="===n[2].charAt(0)?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){let n=this.rules.block.paragraph.exec(e);if(n){let e="\n"===n[1].charAt(n[1].length-1)?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){let n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(e){let n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){let n=this.rules.inline.link.exec(e);if(n){let e=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=mn(e.slice(0,-1),"\\");if((e.length-n.length)%2==0)return}else{let e=function(e,n){if(-1===e.indexOf(n[1]))return-1;let t=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===n[0])t++;else if(e[i]===n[1]&&(t--,t<0))return i;return t>0?-2:-1}(n[2],"()");if(-2===e)return;if(e>-1){let t=(0===n[0].indexOf("!")?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=""}}let t=n[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(t);e&&(t=e[1],i=e[3])}else i=n[3]?n[3].slice(1,-1):"";return t=t.trim(),this.rules.other.startAngleBracket.test(t)&&(t=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?t.slice(1):t.slice(1,-1)),pn(n,{href:t&&t.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(e,n){let t;if((t=this.rules.inline.reflink.exec(e))||(t=this.rules.inline.nolink.exec(e))){let e=n[(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=t[0].charAt(0);return{type:"text",raw:e,text:e}}return pn(t,e,t[0],this.lexer,this.rules)}}emStrong(e,n,t=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!t||this.rules.inline.punctuation.exec(t))){let t,o,a=[...i[0]].length-1,r=a,s=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,n=n.slice(-1*e.length+a);null!=(i=l.exec(n));){if(t=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!t)continue;if(o=[...t].length,i[3]||i[4]){r+=o;continue}if((i[5]||i[6])&&a%3&&!((a+o)%3)){s+=o;continue}if(r-=o,r>0)continue;o=Math.min(o,o+r+s);let n=[...i[0]][0].length,l=e.slice(0,a+i.index+n+o);if(Math.min(a,o)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let n=this.rules.inline.code.exec(e);if(n){let e=n[2].replace(this.rules.other.newLineCharGlobal," "),t=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return t&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:n[0],text:e}}}br(e){let n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){let n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){let n=this.rules.inline.autolink.exec(e);if(n){let e,t;return"@"===n[2]?(e=n[1],t="mailto:"+e):(e=n[1],t=e),{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let n;if(n=this.rules.inline.url.exec(e)){let e,t;if("@"===n[2])e=n[0],t="mailto:"+e;else{let i;do{i=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??""}while(i!==n[0]);e=n[0],t="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let n=this.rules.inline.text.exec(e);if(n){let e=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:e}}}},fn=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||le,this.options.tokenizer=this.options.tokenizer||new hn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:pe,block:an.normal,inline:rn.normal};this.options.pedantic?(n.block=an.pedantic,n.inline=rn.pedantic):this.options.gfm&&(n.block=an.gfm,this.options.breaks?n.inline=rn.breaks:n.inline=rn.gfm),this.tokenizer.rules=n}static get rules(){return{block:an,inline:rn}}static lex(n,t){return new e(t).lex(n)}static lexInline(n,t){return new e(t).inlineTokens(n)}lex(e){e=e.replace(pe.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],t=!1){for(this.options.pedantic&&(e=e.replace(pe.tabCharGlobal," ").replace(pe.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(t=>!!(i=t.call({lexer:this},e,n))&&(e=e.substring(i.raw.length),n.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let t=n.at(-1);1===i.raw.length&&void 0!==t?t.raw+="\n":n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+i.raw,t.text+="\n"+i.text,this.inlineQueue.at(-1).src=t.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+i.raw,t.text+="\n"+i.raw,this.inlineQueue.at(-1).src=t.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let o=e;if(this.options.extensions?.startBlock){let n,t=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{n=e.call({lexer:this},i),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o))){let a=n.at(-1);t&&"paragraph"===a?.type?(a.raw+=(a.raw.endsWith("\n")?"":"\n")+i.raw,a.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i),t=o.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let t=n.at(-1);"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+i.raw,t.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=t.text):n.push(i);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let t,i=e,o=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(o=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(o=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,o.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(o=this.tokenizer.rules.inline.blockSkip.exec(i));)t=o[2]?o[2].length:0,i=i.slice(0,o.index+t)+"["+"a".repeat(o[0].length-t-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let a=!1,r="";for(;e;){let t;if(a||(r=""),a=!1,this.options.extensions?.inline?.some(i=>!!(t=i.call({lexer:this},e,n))&&(e=e.substring(t.raw.length),n.push(t),!0)))continue;if(t=this.tokenizer.escape(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.tag(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.link(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(t.raw.length);let i=n.at(-1);"text"===t.type&&"text"===i?.type?(i.raw+=t.raw,i.text+=t.text):n.push(t);continue}if(t=this.tokenizer.emStrong(e,i,r)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.codespan(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.br(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.del(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.autolink(e)){e=e.substring(t.raw.length),n.push(t);continue}if(!this.state.inLink&&(t=this.tokenizer.url(e))){e=e.substring(t.raw.length),n.push(t);continue}let o=e;if(this.options.extensions?.startInline){let n,t=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{n=e.call({lexer:this},i),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(t=this.tokenizer.inlineText(o)){e=e.substring(t.raw.length),"_"!==t.raw.slice(-1)&&(r=t.raw.slice(-1)),a=!0;let i=n.at(-1);"text"===i?.type?(i.raw+=t.raw,i.text+=t.text):n.push(t);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return n}},gn=class{options;parser;constructor(e){this.options=e||le}space(e){return""}code({text:e,lang:n,escaped:t}){let i=(n||"").match(pe.notSpaceStart)?.[0],o=e.replace(pe.endingNewline,"")+"\n";return i?'<pre><code class="language-'+cn(i)+'">'+(t?o:cn(o,!0))+"</code></pre>\n":"<pre><code>"+(t?o:cn(o,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>\n`}hr(e){return"<hr>\n"}list(e){let n=e.ordered,t=e.start,i="";for(let n=0;n<e.items.length;n++){let t=e.items[n];i+=this.listitem(t)}let o=n?"ol":"ul";return"<"+o+(n&&1!==t?' start="'+t+'"':"")+">\n"+i+"</"+o+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let n="",t="";for(let n=0;n<e.header.length;n++)t+=this.tablecell(e.header[n]);n+=this.tablerow({text:t});let i="";for(let n=0;n<e.rows.length;n++){let o=e.rows[n];t="";for(let e=0;e<o.length;e++)t+=this.tablecell(o[e]);i+=this.tablerow({text:t})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+n+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let n=this.parser.parseInline(e.tokens),t=e.header?"th":"td";return(e.align?`<${t} align="${e.align}">`:`<${t}>`)+n+`</${t}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${cn(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:t}){let i=this.parser.parseInline(t),o=un(e);if(null===o)return i;let a='<a href="'+(e=o)+'"';return n&&(a+=' title="'+cn(n)+'"'),a+=">"+i+"</a>",a}image({href:e,title:n,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let o=un(e);if(null===o)return cn(t);let a=`<img src="${e=o}" alt="${t}"`;return n&&(a+=` title="${cn(n)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:cn(e.text)}},xn=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},kn=class e{options;renderer;textRenderer;constructor(e){this.options=e||le,this.options.renderer=this.options.renderer||new gn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xn}static parse(n,t){return new e(t).parse(n)}static parseInline(n,t){return new e(t).parseInline(n)}parse(e){let n="";for(let t=0;t<e.length;t++){let i=e[t];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let o=i;switch(o.type){case"space":n+=this.renderer.space(o);break;case"hr":n+=this.renderer.hr(o);break;case"heading":n+=this.renderer.heading(o);break;case"code":n+=this.renderer.code(o);break;case"table":n+=this.renderer.table(o);break;case"blockquote":n+=this.renderer.blockquote(o);break;case"list":n+=this.renderer.list(o);break;case"checkbox":n+=this.renderer.checkbox(o);break;case"html":n+=this.renderer.html(o);break;case"def":n+=this.renderer.def(o);break;case"paragraph":n+=this.renderer.paragraph(o);break;case"text":n+=this.renderer.text(o);break;default:{let e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,n=this.renderer){let t="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let e=this.options.extensions.renderers[o.type].call({parser:this},o);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){t+=e||"";continue}}let a=o;switch(a.type){case"escape":case"text":t+=n.text(a);break;case"html":t+=n.html(a);break;case"link":t+=n.link(a);break;case"image":t+=n.image(a);break;case"checkbox":t+=n.checkbox(a);break;case"strong":t+=n.strong(a);break;case"em":t+=n.em(a);break;case"codespan":t+=n.codespan(a);break;case"br":t+=n.br(a);break;case"del":t+=n.del(a);break;default:{let e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}},bn=class{options;block;constructor(e){this.options=e||le}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?fn.lex:fn.lexInline}provideParser(){return this.block?kn.parse:kn.parseInline}},wn=class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=kn;Renderer=gn;TextRenderer=xn;Lexer=fn;Tokenizer=hn;Hooks=bn;constructor(...e){this.use(...e)}walkTokens(e,n){let t=[];for(let i of e)switch(t=t.concat(n.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)t=t.concat(this.walkTokens(i.tokens,n));for(let i of e.rows)for(let e of i)t=t.concat(this.walkTokens(e.tokens,n));break}case"list":{let e=i;t=t.concat(this.walkTokens(e.items,n));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let o=e[i].flat(1/0);t=t.concat(this.walkTokens(o,n))}):e.tokens&&(t=t.concat(this.walkTokens(e.tokens,n)))}}return t}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let t={...e};if(t.async=this.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let t=n.renderers[e.name];n.renderers[e.name]=t?function(...n){let i=e.renderer.apply(this,n);return!1===i&&(i=t.apply(this,n)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let t=n[e.level];t?t.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),t.extensions=n),e.renderer){let n=this.defaults.renderer||new gn(this.defaults);for(let t in e.renderer){if(!(t in n))throw new Error(`renderer '${t}' does not exist`);if(["options","parser"].includes(t))continue;let i=t,o=e.renderer[i],a=n[i];n[i]=(...e)=>{let t=o.apply(n,e);return!1===t&&(t=a.apply(n,e)),t||""}}t.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new hn(this.defaults);for(let t in e.tokenizer){if(!(t in n))throw new Error(`tokenizer '${t}' does not exist`);if(["options","rules","lexer"].includes(t))continue;let i=t,o=e.tokenizer[i],a=n[i];n[i]=(...e)=>{let t=o.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new bn;for(let t in e.hooks){if(!(t in n))throw new Error(`hook '${t}' does not exist`);if(["options","block"].includes(t))continue;let i=t,o=e.hooks[i],a=n[i];bn.passThroughHooks.has(t)?n[i]=e=>{if(this.defaults.async&&bn.passThroughHooksRespectAsync.has(t))return(async()=>{let t=await o.call(n,e);return a.call(n,t)})();let i=o.call(n,e);return a.call(n,i)}:n[i]=(...e)=>{if(this.defaults.async)return(async()=>{let t=await o.apply(n,e);return!1===t&&(t=await a.apply(n,e)),t})();let t=o.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,i=e.walkTokens;t.walkTokens=function(e){let t=[];return t.push(i.call(this,e)),n&&(t=t.concat(n.call(this,e))),t}}this.defaults={...this.defaults,...t}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return fn.lex(e,n??this.defaults)}parser(e,n){return kn.parse(e,n??this.defaults)}parseMarkdown(e){return(n,t)=>{let i={...t},o={...this.defaults,...i},a=this.onError(!!o.silent,!!o.async);if(!0===this.defaults.async&&!1===i.async)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||null===n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let t=o.hooks?await o.hooks.preprocess(n):n,i=await(o.hooks?await o.hooks.provideLexer():e?fn.lex:fn.lexInline)(t,o),a=o.hooks?await o.hooks.processAllTokens(i):i;o.walkTokens&&await Promise.all(this.walkTokens(a,o.walkTokens));let r=await(o.hooks?await o.hooks.provideParser():e?kn.parse:kn.parseInline)(a,o);return o.hooks?await o.hooks.postprocess(r):r})().catch(a);try{o.hooks&&(n=o.hooks.preprocess(n));let t=(o.hooks?o.hooks.provideLexer():e?fn.lex:fn.lexInline)(n,o);o.hooks&&(t=o.hooks.processAllTokens(t)),o.walkTokens&&this.walkTokens(t,o.walkTokens);let i=(o.hooks?o.hooks.provideParser():e?kn.parse:kn.parseInline)(t,o);return o.hooks&&(i=o.hooks.postprocess(i)),i}catch(e){return a(e)}}}onError(e,n){return t=>{if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+cn(t.message+"",!0)+"</pre>";return n?Promise.resolve(e):e}if(n)return Promise.reject(t);throw t}}},$n=new wn;function yn(e,n){return $n.parse(e,n)}yn.options=yn.setOptions=function(e){return $n.setOptions(e),yn.defaults=$n.defaults,ce(yn.defaults),yn},yn.getDefaults=se,yn.defaults=le,yn.use=function(...e){return $n.use(...e),yn.defaults=$n.defaults,ce(yn.defaults),yn},yn.walkTokens=function(e,n){return $n.walkTokens(e,n)},yn.parseInline=$n.parseInline,yn.Parser=kn,yn.parser=kn.parse,yn.Renderer=gn,yn.TextRenderer=xn,yn.Lexer=fn,yn.lexer=fn.lex,yn.Tokenizer=hn,yn.Hooks=bn,yn.parse=yn;yn.options,yn.setOptions,yn.use,yn.walkTokens,yn.parseInline,kn.parse,fn.lex;var Nn={bold:re.bold,italic:re.italic,boldItalic:re.bold.italic,code:(...e)=>re.bgHex("#282828").whiteBright(` ${e.join(" ")} `),strikethrough:re.strikethrough,link:re.underline,listBullet:re.whiteBright,hr:re.dim,blockquote:(...e)=>re.dim.bold("┃ ")+re.dim(e.join("").replace(/\s\s\n/g," \n"+re.bold("┃ ")))};var vn=["•","◦","▪"],An={list(e){let n=0,t=e;for(;t.parent;)n++,t=t.parent;const i=e.ordered&&e.start?e.start:void 0;return"\n"+e.items.map(t=>this.listitem(Object.assign(t,{depth:n,parent:e,start:i}))).join("\n")},listitem(e){let n="";const t=e;for(const i of e.tokens)"list"===i.type&&(n+=this.parser.parse([Object.assign(i,{parent:t.parent})])),"tokens"in i&&Array.isArray(i.tokens)&&(n+=this.parser.parseInline(i.tokens));let i=" ".repeat(2*t.depth);if(t.task)return i+=t.checked?"☑ ":"☐ ",Nn.listBullet(i)+n;if(void 0!==t.start){const e=t.parent.items.indexOf(t);return i+=t.start+e+". ",Nn.listBullet(i)+n}return i+=vn[t.depth%vn.length]+" ",Nn.listBullet(i)+n},link:e=>Nn.link(e.text+" <"+e.href+">"),checkbox:({checked:e})=>e.toString(),code:e=>function(e){const n=e.split("\n"),t=Math.max(...n.map(e=>e.length)),i="┌"+"─".repeat(t+2)+"┐",o="└"+"─".repeat(t+2)+"┘",a=n.map(e=>re.dim("│ ")+re.dim(e).padEnd(t)+re.dim(" │")).join("\n");return[re.dim(i),a,re.dim(o)].join("\n")}(e.text),codespan:({text:e})=>Nn.code(e),def:({raw:e})=>e,del:({text:e})=>Nn.strikethrough(e),paragraph({tokens:e}){return this.parser.parseInline(e)},blockquote:({text:e})=>Nn.blockquote(e),strong({tokens:e}){return Nn.bold(this.parser.parseInline(e))},em({tokens:e}){return Nn.italic(this.parser.parseInline(e))},heading:({text:e})=>Nn.bold(e)+"\n",text:e=>e.raw,space:e=>e.raw.replace(/\n+/g,"\n"),hr:()=>Nn.hr("─".repeat(80)),br:()=>"\n"};function Sn(e,n="terminal",t=(...e)=>e.join(" ")){if(!e)return"";if("terminal"===n){const n=new wn;return n.use({renderer:An}),t(n.parse(e))}return`<span class="_markdown">${yn.parse(e).trim()}</span>`}var Tn=class e{static noColor=(...e)=>e.join(" ");title=e.noColor;description=e.noColor;default=e.noColor;optional=e.noColor;exampleTitle=e.noColor;example=e.noColor;command=e.noColor;option=e.noColor;argument=e.noColor;placeholder=e.noColor;punctuation=e.noColor;constructor(e,n){n&&Object.assign(this,n),Object.assign(this,e)}},On=Object.freeze({default:new Tn({title:re.bold.blue,description:re.white,default:re.dim.italic,optional:re.dim.italic,exampleTitle:re.yellow,example:re.dim,command:re.yellow,option:re.cyan,argument:re.green,placeholder:re.hex("#FF9800"),punctuation:re.white.dim}),dracula:new Tn({title:re.bold.hex("#BD93F9"),description:re.hex("#F8F8F2"),default:re.italic.hex("#6272A4"),optional:re.italic.hex("#6272A4"),exampleTitle:re.hex("#FFB86C"),example:re.hex("#6272A4"),command:re.hex("#50FA7B"),option:re.hex("#8BE9FD"),argument:re.hex("#FF79C6"),placeholder:re.hex("#F1FA8C"),punctuation:re.hex("#6272A4")}),solarizedDark:new Tn({title:re.bold.hex("#268BD2"),description:re.hex("#93A1A1"),default:re.italic.hex("#586E75"),optional:re.italic.hex("#586E75"),exampleTitle:re.hex("#B58900"),example:re.hex("#586E75"),command:re.hex("#2AA198"),option:re.hex("#268BD2"),argument:re.hex("#859900"),placeholder:re.hex("#CB4B16"),punctuation:re.hex("#657B83")}),nord:new Tn({title:re.bold.hex("#81A1C1"),description:re.hex("#D8DEE9"),default:re.italic.hex("#4C566A"),optional:re.italic.hex("#4C566A"),exampleTitle:re.hex("#EBCB8B"),example:re.hex("#4C566A"),command:re.hex("#A3BE8C"),option:re.hex("#88C0D0"),argument:re.hex("#BF616A"),placeholder:re.hex("#D08770"),punctuation:re.hex("#4C566A")}),html:new Tn({title:(...e)=>`<span style="color: #89dceb; font-weight: bold;">${Cn(e.join(" "))}</span>`,description:(...e)=>`<span style="color: #cdd6e8;">${Cn(e.join(" "))}</span>`,default:(...e)=>`<span style="color: #6c7086; font-style: italic;">${Cn(e.join(" "))}</span>`,optional:(...e)=>`<span style="color: #6c7086; font-style: italic;">${Cn(e.join(" "))}</span>`,exampleTitle:(...e)=>`<span style="color: #f9e2af;">${Cn(e.join(" "))}</span>`,example:(...e)=>`<span style="color: #6c7086;">${Cn(e.join(" "))}</span>`,command:(...e)=>`<span style="color: #f9e2af;">${Cn(e.join(" "))}</span>`,option:(...e)=>`<span style="color: #17b85d;">${Cn(e.join(" "))}</span>`,argument:(...e)=>`<span style="color: #00ff00;">${Cn(e.join(" "))}</span>`,placeholder:(...e)=>`<span style="color: #db9518;">${Cn(e.join(" "))}</span>`,punctuation:(...e)=>`<span style="color: #6c7086;">${Cn(e.join(" "))}</span>`}),gruvboxDark:new Tn({title:re.bold.hex("#FABD2F"),description:re.hex("#EBDBB2"),default:re.italic.hex("#928374"),optional:re.italic.hex("#928374"),exampleTitle:re.hex("#FE8019"),example:re.hex("#928374"),command:re.hex("#B8BB26"),option:re.hex("#83A598"),argument:re.hex("#D3869B"),placeholder:re.hex("#FB4934"),punctuation:re.hex("#928374")}),monokai:new Tn({title:re.bold.hex("#AE81FF"),description:re.hex("#F8F8F2"),default:re.italic.hex("#75715E"),optional:re.italic.hex("#75715E"),exampleTitle:re.hex("#FD971F"),example:re.hex("#75715E"),command:re.hex("#A6E22E"),option:re.hex("#66D9EF"),argument:re.hex("#F92672"),placeholder:re.hex("#E6DB74"),punctuation:re.hex("#75715E")}),oneDark:new Tn({title:re.bold.hex("#61AFEF"),description:re.hex("#ABB2BF"),default:re.italic.hex("#5C6370"),optional:re.italic.hex("#5C6370"),exampleTitle:re.hex("#E5C07B"),example:re.hex("#5C6370"),command:re.hex("#98C379"),option:re.hex("#56B6C2"),argument:re.hex("#E06C75"),placeholder:re.hex("#C678DD"),punctuation:re.hex("#5C6370")}),catppuccin:new Tn({title:re.bold.hex("#89B4FA"),description:re.hex("#CDD6F4"),default:re.italic.hex("#6C7086"),optional:re.italic.hex("#6C7086"),exampleTitle:re.hex("#F9E2AF"),example:re.hex("#6C7086"),command:re.hex("#A6E3A1"),option:re.hex("#94E2D5"),argument:re.hex("#F38BA8"),placeholder:re.hex("#FAB387"),punctuation:re.hex("#585B70")}),noColors:new Tn({})});function Cn(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Rn(e){const n={...e};return n.style??=On.default,n.markdownRenderer??="terminal",n.kebabCaseArgumentName??=!0,n.indentBeforeName??=2,n.indentAfterName??=4,n.indentBeforePlaceholder??=1,n.newLineIndent??=0,n.emptyLines??=0,n.emptyLinesBeforeTitle??=1,n.emptyLinesAfterTitle??=0,n.exampleKeyword??="Example",n.optionalKeyword??="(optional)",n.defaultKeyword??="(default: {{ value }})",n.usageTitle??="USAGE",n.descriptionTitle??="DESCRIPTION",n.commandsTitle??="COMMANDS",n.optionsTitle??="OPTIONS",n.argumentsTitle??="ARGUMENTS",n.exampleTitle??="EXAMPLE",n}function Dn(e,n={}){const t=Rn(n),i={...On.default,...t.style},o=B(e),c=e=>s(1)+i.title(e);let m="",p=o.usage;if(p||(p=i.punctuation("$"),p+=o.name?i.description("",o.name):"",p+=o.subcommands.length>0?i.command("","[command]"):"",p+=o.options.length>0?i.option("","[options]"):"",p+=o.arguments.length>0?i.argument("","<arguments>"):"",p+=o.allowPositionals?i.argument("","<positionals>"):""),m+=c(t.usageTitle)+r(1+t.emptyLinesAfterTitle),m+=s(t.indentBeforeName)+p+r(1),o.description||o.descriptionMarkdown){m+=r(t.emptyLinesBeforeTitle)+c(t.descriptionTitle)+r(1+t.emptyLinesAfterTitle);let e=o.description?i.description(o.description):Sn(o.descriptionMarkdown,t.markdownRenderer,i.description);e=l(e,t.indentBeforeName),m+=s(t.indentBeforeName)+e+r(1)}let h=0;const f=o.options;let g=0;for(const e of f){const n=[...e.aliasesAsArgs,e.nameAsArg].join(", ").length+e.placeholder.length;g=Math.max(n,g)}h=Math.max(g,h);const x=o.subcommands;let k=0;for(const e of x){const n=[...e.aliases,e.name].join(", "),t=d(e),i=n.length+t.length;k=Math.max(i,k)}h=Math.max(k,h);const b=o.arguments;let w=0;for(const e of b)w=Math.max(e.name.length,w);h=Math.max(w,h);const $=Object.assign({...t},{style:i,longest:h});if(m+=function(e,n){if(0===e.length)return"";const{style:t,indentBeforeName:i,indentAfterName:o,indentBeforePlaceholder:a,newLineIndent:c,emptyLines:d,longest:m,exampleKeyword:p,optionalKeyword:h,defaultKeyword:f,optionsTitle:g,emptyLinesBeforeTitle:x,emptyLinesAfterTitle:k,markdownRenderer:b}=n;let w=r(x)+s(1)+t.title(g)+r(1+k);const $=m+i+o+a+c;for(const n of e){if(n.hidden)continue;const e=[...n.aliasesAsArgs,n.nameAsArg],c=e.map(e=>t.option(e)).join(t.punctuation(", "));let g=n.description?t.description(n.description):Sn(n.descriptionMarkdown,b,t.description);g=l(g,$);let x="";n.defaultValueAsString&&(x=t.default(f.replace("{{ value }}",n.defaultValueAsString))),n.optional&&!x&&(x=t.optional(h));const k=m-(e.join(", ").length+n.placeholder.length);if(w+=s(i)+c+s(a)+t.placeholder(n.placeholder)+s(o)+s(k)+u(g,x)+r(1+d),n.example){const e=l(n.example,$+p.length+1);w+=s($)+t.exampleTitle(p)+s(1)+t.example(e)+r(1)}}return w}(f,$),m+=function(e,n){if(0===e.length)return"";const{style:t,indentBeforeName:i,indentAfterName:o,indentBeforePlaceholder:a,newLineIndent:c,longest:u,commandsTitle:m,emptyLines:p,emptyLinesBeforeTitle:h,emptyLinesAfterTitle:f,markdownRenderer:g}=n;let x=r(h)+s(1)+t.title(m)+r(1+f);const k=u+i+o+a+c;for(const n of e){if(n.hidden)continue;const e=n.aliases.concat([n.name]),c=d(n);let m=n.description?t.description(n.description):Sn(n.descriptionMarkdown,g,t.description);m=l(m,k);const h=u-(e.join(", ").length+c.length),f=e.map(e=>t.command(e)).join(t.punctuation(", "));x+=s(i)+f+s(a)+t.placeholder(c)+s(o)+s(h)+m+r(1+p)}return x}(x,$),m+=function(e,n){if(0===e.length)return"";const{style:t,indentBeforeName:i,indentAfterName:o,indentBeforePlaceholder:c,newLineIndent:d,longest:m,argumentsTitle:p,defaultKeyword:h,optionalKeyword:f,exampleKeyword:g,emptyLines:x,emptyLinesBeforeTitle:k,emptyLinesAfterTitle:b,markdownRenderer:w,kebabCaseArgumentName:$}=n;let y=r(k)+s(1)+t.title(p)+r(1+b);const N=m+i+o+c+d;for(const n of e){if(n.hidden)continue;let e=n.description?t.description(n.description):Sn(n.descriptionMarkdown,w,t.description);e=l(e,N);let d="";n.defaultValueAsString&&(d=t.default(h.replace("{{ value }}",n.defaultValueAsString))),n.optional&&!d&&(d=t.optional(f));const p=m-n.name.length;if(y+=s(i)+t.argument($?a(n.name):n.name)+s(c+o)+s(p)+u(e,d)+r(1+x),n.example){const e=l(n.example,N+g.length+1);y+=s(N)+t.exampleTitle(g)+s(1)+t.example(e)+r(1)}}return y}(b,$),o.example){m+=r(t.emptyLinesBeforeTitle)+c(t.exampleTitle)+r(1+t.emptyLinesAfterTitle);const e=l(o.example,t.indentBeforeName);m+=s(t.indentBeforeName)+i.example(e)}return m}function Pn(e,n={},t=""){Rn(n);const i={...On.default,...n.style},o=e.meta??{};let a=o.usage;a||(a=i.punctuation("$"),a+=t?` ${t}`:"",a+=i.command("",e.name),a+=e.options?i.option(" [options]"):"",a+=e.arguments||e.allowPositionals?i.argument(" <arguments>"):"");return Dn({...e,cliName:e.name,meta:{usage:a,...o}},n)}function _n(e,n={}){console.log(Dn(e,n))}function jn(e,n={},t=""){console.log(Pn(e,n,t))}function Bn(e){const n=e.subcommands??[],t={};for(const e of n)t[e.name]={options:e.options?Object.keys(e.options).map(e=>D(e)):[],aliases:e.aliases??[]};let i="";for(const[e,{options:n,aliases:o}]of Object.entries(t)){i+=` ${[e,...o].join("|")})\n`,i+=` opts="${n.join(" ")}"\n`,i+=" ;;\n"}const o=e.options?Object.keys(e.options).map(e=>D(e)):[];return o.length>0&&(i+=" *)\n",i+=` opts="${o.join(" ")}"\n`,i+=" ;;\n"),`# Auto-generated by zod-args-parser\n\n_${e.cliName}_autocomplete() {\n local cur prev commands opts subcommand used_opts filtered_opts\n\n cur="\${COMP_WORDS[COMP_CWORD]}"\n prev="\${COMP_WORDS[COMP_CWORD-1]}"\n subcommand="\${COMP_WORDS[1]}"\n\n commands="${Object.keys(t).join(" ")}"\n\n case "$subcommand" in\n${i} esac\n\n used_opts=""\n if [[ " \${commands[@]} " =~ " $subcommand " ]]; then\n for word in "\${COMP_WORDS[@]:2}"; do\n if [[ "$word" =~ ^- ]]; then\n used_opts+=" $word"\n fi\n done\n fi\n\n if [[ -n "$opts" ]]; then\n filtered_opts=""\n for opt in $opts; do\n if [[ ! " $used_opts " =~ " $opt " ]]; then\n filtered_opts+="$opt "\n fi\n done\n COMPREPLY=( $(compgen -W "$filtered_opts" -- "$cur") )\n return\n fi\n\n if [[ "\${COMP_CWORD}" -eq 1 ]]; then\n COMPREPLY=( $(compgen -W "$commands" -- "$cur") )\n fi\n}\n\ncomplete -F _${e.cliName}_autocomplete ${e.cliName}\n`}function Mn(e){const n=e.subcommands??[],t=e.meta??{},i={};for(const e of n){const n=[];if(e.options)for(const t of Object.keys(e.options))n.push(D(t));const t=e.aliases??[];i[e.name]={options:n,aliases:t}}const o=Object.keys(i).map(e=>`'${e}'`).join(", "),a=[];if(e.options)for(const n of Object.keys(e.options))a.push(D(n));const r=a.map(e=>`'${e}'`).join(", ");let s="switch ($subcommand) {\n";for(const e in i){const n=i[e],t=n.options.map(e=>`'${e}'`).join(", ");s+=` '${e}' { @(${t}) }\n`;for(const e of n.aliases)s+=` '${e}' { @(${t}) }\n`}s+=` default { @(${r}) }\n }`;let l="";(t.description||t.example)&&(l="<#\n",(t.description||t.descriptionMarkdown)&&(l+=`.DESCRIPTION\n${t.description??t.descriptionMarkdown}\n\n`),t.example&&(l+=`.EXAMPLE\n${t.example}\n`),l+="#>");const c=e.cliName;return`# Auto-generated by zod-args-parser\n\n${l}\nfunction ${c} {\n param(\n [Parameter(Position = 0, Mandatory = $false)]\n [string]$subcommand,\n [Parameter(Position = 1, ValueFromRemainingArguments = $true)]\n [string[]]$arguments\n )\n $scriptPath = (Get-Command '${c}.ps1').Source\n if ($scriptPath) {\n $argumentList = @($subcommand) + ($arguments | Where-Object { $_ -notin '--', '--%' }) | Where-Object { $_ -ne '' }\n & $scriptPath @argumentList\n return\n }\n Write-Error "Could not find '${c}.ps1' script"\n}\n\nRegister-ArgumentCompleter -CommandName '${c}' -ParameterName 'subcommand' -ScriptBlock {\n param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)\n $subcommands = @(${o}${o&&r?", ":""}${r})\n $subcommands | Where-Object { $_ -like "$wordToComplete*" }\n}\n\nRegister-ArgumentCompleter -CommandName '${c}' -ParameterName 'arguments' -ScriptBlock {\n param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)\n $subcommand = $commandAst.CommandElements[1].Value\n $arguments = ${s}\n $arguments | Where-Object { $_ -like "$wordToComplete*" }\n}`}function En(e){const n=e.subcommands??[],t=e=>{return String.raw`${e.name})
2
+ _arguments \
3
+ ${n=e,n.options?Object.entries(n.options).map(([e,n])=>{const t=n.meta?.description??"";return`'${D(e)}[${t}]'`}).join(" \\\n "):""} \
4
+ '*: :_files' \
5
+ && ret=0
6
+ ;;`;var n},i=n.map(e=>t(e)).filter(Boolean).join("\n "),o=n.map(e=>`"${e.name}:${e.meta?.description??""}"`).join("\n "),a=e.options?Object.entries(e.options).map(([e,n])=>{const t=n.meta?.description??"";return`'${D(e)}[${t}]'`}).join(" \\\n "):"",r=e.cliName;return String.raw`# Auto-generated by zod-args-parser
7
+
8
+ _${r}_autocomplete() {
9
+ local ret=1
10
+
11
+ _arguments -C \
12
+ '1: :_${r}_commands' \
13
+ '*:: :->subcmds' \
14
+ && ret=0
15
+
16
+ case $state in
17
+ subcmds)
18
+ case "$words[1]" in
19
+ ${i}
20
+ *)
21
+ _arguments \
22
+ ${a?a+" \\\n ":""}'*: :_files' \
23
+ && ret=0
24
+ ;;
25
+ esac
26
+ ;;
27
+ esac
28
+
29
+ return $ret
30
+ }
31
+
32
+ _${r}_commands() {
33
+ local -a commands=(
34
+ ${o}
35
+ )
36
+
37
+ _describe -t subcommands 'subcommand' commands
38
+ }
39
+
40
+ compdef _${r}_autocomplete ${r}
41
+ `}function Kn(e){const n=B(e);let t="\x3c!-- Auto-generated by zod-args-parser --\x3e\n\n";return t+=`# ${n.name}\n\n`,n.description&&!n.descriptionMarkdown&&(t+=`${qn(n.description)}\n`),n.descriptionMarkdown&&(t+=`${qn(n.descriptionMarkdown)}\n`),n.example&&(t+=In(n.example)),n.options.length>0&&(t+="\n## Options:\n\n",t+=Vn(n.options,3)),n.arguments.length>0&&(t+="\n## Arguments:\n\n",t+=zn(n.arguments,3)),n.subcommands.length>0&&(t+="\n## Subcommands:\n\n",t+=function(e){let n="";for(let t=0;t<e.length;t++){const i=e[t];if(i.hidden)continue;n+=`### ${[i.name].concat(i.aliases).join(", ")+(i.placeholder&&` ${i.placeholder}`)}\n\n`,i.description&&!i.descriptionMarkdown&&(n+=`${qn(i.description)}\n`),i.descriptionMarkdown&&(n+=`${qn(i.descriptionMarkdown)}\n`),i.example&&(n+=In(i.example)),i.options.length>0&&(n+="\n#### Options:\n\n",n+=Vn(i.options,4)),i.arguments.length>0&&(n+="\n#### Arguments:\n\n",n+=zn(i.arguments,4)),t<e.length-1&&(n+="\n---\n\n")}return n}(n.subcommands)),t=t.replace(m,""),t=function(e){const n={"&":"&amp;","<":"&lt;",">":"&gt;"};return e.replace(/(```[\s\S]*?```|`[^`]*`)|(<!--[\s\S]*?-->)|(<[^>]+>)/g,(e,t,i,o)=>t||i||(o?o.replace(/[&<>]/g,e=>n[e]):e))}(t),t}function In(e){let n="\n**Example:**\n";return n+="\n",n+="```bash\n",n+=e,n+="\n```\n",n}function Vn(e=[],n){let t="";for(let i=0;i<e.length;i++){const o=e[i];if(o.hidden)continue;const a=[o.nameAsArg].concat(o.aliasesAsArgs).join(", "),r=o.placeholder&&` ${o.placeholder}`;if(t+=`${"#".repeat(n)} \`${a+r}\``,o.optional&&(t+=" _optional_"),t+="\n\n",o.description&&!o.descriptionMarkdown&&(t+=`${qn(o.description)}\n`),o.descriptionMarkdown&&(t+=`${qn(o.descriptionMarkdown)}\n`),void 0!==o.defaultValue){const e=t.endsWith("\n\n")?"":"\n";t+=`${e}**default:** \`${o.defaultValueAsString}\`\n`}o.example&&(t+=In(o.example)),i<e.length-1&&(t+="\n")}return t}function zn(e=[],n){let t="";for(let i=0;i<e.length;i++){const o=e[i];if(!o.hidden){if(t+=`${"#".repeat(n)} \`${o.name}\``,o.optional&&(t+=" _optional_"),t+="\n\n",o.description&&!o.descriptionMarkdown&&(t+=`${qn(o.description)}\n`),o.descriptionMarkdown&&(t+=`${qn(o.descriptionMarkdown)}\n`),void 0!==o.defaultValue){const e=t.endsWith("\n\n")?"":"\n";t+=`${e}**default:** \`${o.defaultValueAsString}\`\n`}o.example&&(t+=In(o.example)),i<e.length-1&&(t+="\n")}}return t}function qn(e){return e.replace(/(\n+)/g," $1")}function Ln(e){return v(e),e}function Fn(e,n){const t={subcommand:"cliName"in n?void 0:n.name};return Wn(n,t,e.options,"options"),Wn(n,t,e.arguments,"arguments"),n.allowPositionals&&(t.positionals??=e.positionals),t}function Wn(e,n,t,i){if(!e[i])return;const o=e[i],a=i.slice(0,-1),r="cliName"in e?"command":"subcommand",s="cliName"in e?e.cliName:e.name,l=Object.entries(o);for(const[e,o]of l){if(!o._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:r,commandName:s,kind:a,name:e}});const{schema:l,optional:c,defaultValue:u}=o._preparedType;if(t&&e in t){const o=t[e];n[i]??={},n[i][e]=void 0===o?{schema:l,optional:c,defaultValue:u,source:"default"}:{schema:l,optional:c,defaultValue:u,passedValue:o,source:"programmatic"};continue}if(!c){if("option"===a)throw new w({cause:f.Parse,code:k.MissingRequiredOption,context:{commandKind:r,commandName:s,optionName:e}});if("argument"===a)throw new w({cause:f.Parse,code:k.MissingRequiredArgument,context:{commandKind:r,commandName:s,argumentName:e}})}n[i]??={},n[i][e]={schema:l,optional:c,defaultValue:u,source:"default"}}}function Un(e){if(!e.options)return;const n="cliName"in e,t=n?e.cliName:e.name,i=n?"command":"subcommand",o=Object.entries(e.options);if(0===o.length)throw new w({cause:f.Definition,code:g.EmptyDefinitionGroup,context:{commandKind:i,commandName:t,kind:"option"}});for(const[n,a]of o){if(!a.schema)throw new w({cause:f.Definition,code:g.MissingSchema,context:{commandKind:i,commandName:t,kind:"option",name:n}});if(!a._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:i,commandName:t,kind:"option",name:n}});if(Gn(n))throw new w({cause:f.Definition,code:g.InvalidDefinitionOptionName,context:{commandKind:i,commandName:t,optionName:n}});if(e.arguments&&n in e.arguments)throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:i,commandName:t,kind:"option",name:n,foundInKind:"argument"}});if(a.aliases)for(const r of a.aliases){if(""===r)throw new w({cause:f.Definition,code:g.EmptyStringAliasName,context:{commandKind:i,commandName:t,optionName:n}});if(Gn(r))throw new w({cause:f.Definition,code:g.InvalidDefinitionOptionName,context:{commandKind:i,commandName:t,optionName:n,negatedAliasName:r}});if(e.options[r])throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:i,commandName:t,kind:"option",name:n,duplicatedAlias:r,foundInKind:"option"}});if(e.arguments&&r in e.arguments)throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:i,commandName:t,kind:"option",name:n,duplicatedAlias:r,foundInKind:"argument"}});const a=o.find(([e,t])=>e!==n&&t.aliases?.includes(r));if(a)throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:i,commandName:t,kind:"option",name:r,foundInKind:"option",foundInName:a[0]}})}if(a.requires){if(a.requires.includes(n))throw new w({cause:f.Definition,code:g.SelfRequire,context:{commandKind:i,commandName:t,kind:"option",name:n}});for(const o of a.requires){if(!(o in e.options||o in(e.arguments??[])))throw new w({cause:f.Definition,code:g.UnknownRequireName,context:{commandKind:i,commandName:t,kind:"option",name:n,requiredName:o}})}}if(a.conflictWith){if(a.conflictWith.includes(n))throw new w({cause:f.Definition,code:g.SelfConflict,context:{commandKind:i,commandName:t,kind:"option",name:n}});for(const o of a.conflictWith){if(!(o in e.options||o in(e.arguments??[])))throw new w({cause:f.Definition,code:g.UnknownConflictName,context:{commandKind:i,commandName:t,kind:"option",name:n,requiredName:o}})}}if(a.requires&&a.conflictWith){const e=new Set(a.requires),o=new Set(a.conflictWith),r=e.intersection(o),s=Array.from(r).map(e=>`"${e}"`);if(s.length>0)throw new w({cause:f.Definition,code:g.DefinitionRequiresConflictOverlap,context:{commandKind:i,commandName:t,kind:"option",name:n,intersectedNames:s}})}}}function Zn(e){if(!e.arguments)return;const n="cliName"in e,t=n?e.cliName:e.name,i=n?"command":"subcommand",o=Object.entries(e.arguments);if(0===o.length)throw new w({cause:f.Definition,code:g.EmptyDefinitionGroup,context:{commandKind:i,commandName:t,kind:"argument"}});for(const[n,[a,r]]of o.entries()){if(/^\d+$/.test(a))throw new w({cause:f.Definition,code:g.InvalidDefinitionArgumentName,context:{commandKind:i,commandName:t,name:a}});if(!r._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:i,commandName:t,kind:"argument",name:a}});if(!r.schema)throw new w({cause:f.Definition,code:g.MissingSchema,context:{commandKind:i,commandName:t,kind:"argument",name:a}});if(r._preparedType.optional){if(e.allowPositionals)throw new w({cause:f.Definition,code:g.InvalidOptionalArgumentDefinition,context:{commandKind:i,commandName:t,name:a,allowPositionals:!0}});if(n!==o.length-1)throw new w({cause:f.Definition,code:g.InvalidOptionalArgumentDefinition,context:{commandKind:i,commandName:t,name:a,allowPositionals:!1}});if(r.requires){if(r.requires.includes(a))throw new w({cause:f.Definition,code:g.SelfRequire,context:{commandKind:i,commandName:t,kind:"argument",name:a}});for(const n of r.requires){if(!(n in(e.options??{})||n in e.arguments))throw new w({cause:f.Definition,code:g.UnknownRequireName,context:{commandKind:i,commandName:t,kind:"argument",name:a,requiredName:n}})}}if(r.conflictWith){if(r.conflictWith.includes(a))throw new w({cause:f.Definition,code:g.SelfConflict,context:{commandKind:i,commandName:t,kind:"argument",name:a}});for(const n of r.conflictWith){if(!(n in(e.options??{})||n in e.arguments))throw new w({cause:f.Definition,code:g.UnknownConflictName,context:{commandKind:i,commandName:t,kind:"argument",name:a,requiredName:n}})}}if(r.requires&&r.conflictWith){const e=new Set(r.requires),n=new Set(r.conflictWith),o=e.intersection(n),s=Array.from(o).map(e=>`"${e}"`);if(s.length>0)throw new w({cause:f.Definition,code:g.DefinitionRequiresConflictOverlap,context:{commandKind:i,commandName:t,kind:"argument",name:a,intersectedNames:s}})}}}}function Gn(e){return D(e).startsWith("--no-")}function Hn(e,n){return!!n.arguments&&(e in n.arguments&&"default"!==n.arguments[e].source)}function Qn(e,n){return!!n.options&&(e in n.options&&"default"!==n.options[e].source)}function Jn(e,n){return Qn(e,n)||Hn(e,n)}function Xn({name:e,optionOrArgument:n,context:t,kind:i}){const o=n.conflictWith;if(!o||0===o.length)return;if(!Jn(e,t))return;const a=[],r=[];if(t.options)for(const[n,i]of Object.entries(t.options))n!==e&&o.includes(n)&&"default"!==i.source&&a.push(n);if(t.arguments)for(const[n,i]of Object.entries(t.arguments))n!==e&&o.includes(n)&&"default"!==i.source&&r.push(n);if(0!==a.length||0!==r.length)throw new w({cause:f.Validation,code:b.MutuallyExclusiveConflict,context:{kind:i,name:e,conflictedOptions:a,conflictedArguments:r}})}function Yn({name:e,optionOrArgument:n,context:t,kind:i}){if(!n.exclusive)return;if(!Jn(e,t))return;const o=n.requires??[],a=[],r=[];if(t.options)for(const[n,i]of Object.entries(t.options))n!==e&&(o.includes(n)||"default"!==i.source&&a.push(n));if(t.arguments)for(const[n,i]of Object.entries(t.arguments))n!==e&&(o.includes(n)||"default"!==i.source&&r.push(n));if(0!==a.length||0!==r.length)throw new w({cause:f.Validation,code:b.MutuallyExclusiveConflict,context:{kind:i,name:e,conflictedOptions:a,conflictedArguments:r}})}function et({name:e,commandDefinition:n,optionOrArgument:t,context:i,kind:o}){const a=t.requires;if(!a||0===a.length)return;if(!Jn(e,i))return;const r=n.options??{},s=[],l=[];for(const e of a){const n=e in r;(n?Qn(e,i):Hn(e,i))||(n?s.push(e):l.push(e))}if(0!==s.length||0!==l.length)throw new w({cause:f.Validation,code:b.RequiredDependencyMissing,context:{kind:o,name:e,missingArguments:l,missingOptions:s}})}function nt(e,n){const t={subcommand:e.subcommand,positionals:e.positionals,context:e};return function({commandDefinition:e,context:n,output:t}){if(!n.options)return;t.options??={};const i="cliName"in e?"command":"subcommand",o="cliName"in e?e.cliName:e.name,a=e.options;if(!a)throw new w({cause:f.Validation,code:b.NoOptionsToValidate,context:{commandKind:i,commandName:o}});for(const[t,i]of Object.entries(a))et({name:t,commandDefinition:e,optionOrArgument:i,context:n,kind:"option"}),Yn({name:t,optionOrArgument:i,context:n,kind:"option"}),Xn({name:t,optionOrArgument:i,context:n,kind:"option"});const r=Object.entries(n.options);for(const[e,{passedValue:n,stringValue:s,source:l,schema:c}]of r){const r=a[e];if(!r)throw new w({cause:f.Validation,code:b.UnknownOptionValidation,context:{commandKind:i,commandName:o,optionName:e}});if(!r._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:i,commandName:o,kind:"option",name:e}});const u="programmatic"===l,d=u?$(c,n):r._preparedType.validate(s);if(d.issues)throw new w({cause:f.Validation,code:b.SchemaValidationFailed,context:{commandKind:i,commandName:o,kind:"option",name:e,inputValue:u?n:s,issues:d.issues}});t.options[e]=d.value}}({commandDefinition:n,context:e,output:t}),function({commandDefinition:e,context:n,output:t}){if(!n.arguments)return;t.arguments??={};const i="cliName"in e?"command":"subcommand",o="cliName"in e?e.cliName:e.name,a=e.arguments;if(!a)throw new w({cause:f.Validation,code:b.NoArgumentsToValidate,context:{commandKind:i,commandName:o}});for(const[t,i]of Object.entries(a))et({name:t,commandDefinition:e,optionOrArgument:i,context:n,kind:"option"}),Yn({name:t,optionOrArgument:i,context:n,kind:"option"}),Xn({name:t,optionOrArgument:i,context:n,kind:"option"});const r=Object.entries(n.arguments);for(const[e,{passedValue:n,stringValue:s,source:l,schema:c}]of r){const r="programmatic"===l,u=a[e];if(!u)throw new w({cause:f.Validation,code:b.UnknownArgumentValidation,context:{commandKind:i,commandName:o,argumentName:e}});if(!u._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:i,commandName:o,kind:"argument",name:e}});const d=r?$(c,n):u._preparedType.validate(s);if(d.issues)throw new w({cause:f.Validation,code:b.SchemaValidationFailed,context:{commandKind:i,commandName:o,kind:"option",name:e,inputValue:r?n:s,issues:d.issues}});t.arguments[e]=d.value}}({commandDefinition:n,context:e,output:t}),t}function tt(e,n){const t="string"==typeof e?function(e){const n=[];let t,i;for(let o=0;o<e.length;o++){const a=e[o],r=e[o-1],s=e[o+1],l=o===e.length-1;if('"'!==a&&"'"!==a||"\\"===r)if("\\"!==a||"\n"!==s){if(void 0!==i&&void 0===t){if(" "===a){n.push(i),i=void 0;continue}if(l){i+=a,n.push(i),i=void 0;continue}}" "===a&&void 0===t||("\\"!==a||"'"!==s&&'"'!==s)&&(i??="",i+=a)}else o++;else{if(t===a){t=void 0;continue}if(void 0===t){t=a;continue}if(void 0!==t&&a!==t){i??="",i+=a;continue}}}return void 0!==i&&n.push(i),n}(e):e;try{!function(e){if(!e.cliName)throw new w({cause:f.Definition,code:g.MissingDefinitionName,context:{commandKind:"command"}});Un(e),Zn(e);const n=e.subcommands;if(!n)return;if(0===n.length)throw new w({cause:f.Definition,code:g.EmptyDefinitionGroup,context:{commandKind:"command",commandName:e.cliName,kind:"subcommands"}});const t=new Set(n.map(e=>e.name)),i=new Set;for(const o of n){if(!o.name)throw new w({cause:f.Definition,code:g.MissingDefinitionName,context:{commandKind:"subcommand"}});if(i.has(o.name))throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:"command",commandName:e.cliName,kind:"subcommand",name:o.name,foundInKind:"subcommand"}});if(i.add(o.name),o.aliases)for(const i of o.aliases){if(""===i)throw new w({cause:f.Definition,code:g.EmptyStringAliasName,context:{commandKind:"subcommand",commandName:o.name}});if(t.has(i))throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:"command",commandName:e.cliName,kind:"subcommand",name:o.name,foundInKind:"subcommand",duplicatedAlias:i}});const a=n.filter(e=>e.name!==o.name&&e.aliases?.includes(i));if(a.length>0)throw new w({cause:f.Definition,code:g.DuplicateDefinitionName,context:{commandKind:"command",commandName:e.cliName,kind:"subcommand",name:o.name,foundInKind:"subcommand",duplicatedAlias:i,foundInName:a[0].name}})}Un(o),Zn(o)}}(n)}catch(e){return{error:e}}let i;try{i=function(e,n){const t=n.cliName,i=n.subcommands??[],o=new Set(i.flatMap(e=>[e.name,...e.aliases||[]]));e=function(e){const n=/^-[a-z0-9]{2,}$/i,t=[];for(const i of e){if(!n.test(i)){t.push(i);continue}const e=i.slice(1).split("").map(e=>"-"+e);t.push(...e)}return t}(e);const a={subcommand:void 0},r=()=>S(a.subcommand,n);for(let n=0;n<e.length;n++){const i=e[n];if(0===n&&(a.subcommand=o.has(i)?i:void 0,a.subcommand))continue;const s=i.split("=").filter(Boolean),l=i.includes("="),[c,u]=P(s[0]),d=u.length>0,m=s[1],p=c.startsWith("--no-");if(C(c)){const i=r(),o=void 0===a.subcommand?"command":"subcommand",s=a.subcommand??t;if(O(c)&&l)throw new w({cause:f.Parse,code:k.FlagAssignedValue,context:{commandKind:o,commandName:s,flag:c,value:m}});if(!i){if(void 0===a.subcommand)throw new w({cause:f.Internal,code:x.CannotFindCliDefinition,context:{cliName:t}});throw new w({cause:f.Parse,code:k.UnknownSubcommand,context:{commandName:s}})}if(!i.options)throw new w({cause:f.Parse,code:k.CommandWithoutOptions,context:{commandKind:o,commandName:s,optionName:c}});const h=T(c,i.options);if(!h)throw new w({cause:f.Parse,code:k.UnknownOption,context:{commandKind:o,commandName:s,optionName:c}});const[g,b]=h;if(!d&&a.options&&g in a.options)throw new w({cause:f.Parse,code:k.DuplicateOptionProvided,context:{commandKind:o,commandName:s,optionName:g}});if(!b._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:o,commandName:s,kind:"option",name:g}});const{schema:$,optional:y,defaultValue:N,coerceTo:v}=b._preparedType,A=e[n+1];let S=l?m:A;const R="boolean"===v;if(p&&!R)throw new w({cause:f.Parse,code:k.InvalidNegationForNonBooleanOption,context:{commandKind:o,commandName:s,optionName:g}});if(R&&(l||(S="true"),p&&["true","false"].includes(S.toLowerCase())&&(S="true"===S?"false":"true")),void 0===S||!l&&C(S))throw new w({cause:f.Parse,code:k.OptionMissingValue,context:{commandKind:o,commandName:s,optionName:g}});if(a.options??={},d){const e=JSON.parse(a.options[g]?.stringValue||"{}");let n=e;for(let e=0;e<u.length;e++){const t=u[e];void 0===n[t]&&(n[t]={}),e!==u.length-1?n=n[t]:n[t]=S}S=JSON.stringify(e)}a.options[g]={schema:$,optional:y,defaultValue:N,flag:c,stringValue:S,source:"terminal"},l||R||n++;continue}const h=r();if(h?.arguments){a.arguments??={};const e=Object.keys(a.arguments).length,n=Object.entries(h.arguments);if(e<n.length){const[o,r]=n[e];if(!r._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,kind:"argument",name:o}});const{schema:s,optional:l,defaultValue:c}=r._preparedType;a.arguments[o]={schema:s,optional:l,defaultValue:c,stringValue:i,source:"terminal"};continue}}if(!h?.allowPositionals)throw new w({cause:f.Parse,code:k.PositionalArgumentNotAllowed,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,argumentName:i}});a.positionals??=[],a.positionals.push(i)}const s=r();if(!s){if(void 0===a.subcommand)throw new w({cause:f.Internal,code:x.CannotFindCliDefinition,context:{cliName:t}});throw new w({cause:f.Parse,code:k.UnknownSubcommand,context:{commandName:a.subcommand??t}})}if(s.options){a.options??={};for(const[e,n]of Object.entries(s.options)){if(e in a.options)continue;if(!n._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,kind:"option",name:e}});const{schema:i,optional:o,defaultValue:r}=n._preparedType;if(!o)throw new w({cause:f.Parse,code:k.MissingRequiredOption,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,optionName:e}});void 0!==r&&(a.options[e]={schema:i,optional:o,defaultValue:r,source:"default"})}}if(s.arguments){a.arguments??={};const e=Object.keys(a.arguments).length,n=Object.entries(s.arguments),i=n.length;if(e<i)for(let o=e;o<i;o++){const[e,i]=n[o];if(!i._preparedType)throw new w({cause:f.Internal,code:x.MissingPreparedTypes,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,kind:"argument",name:e}});const{schema:r,optional:s,defaultValue:l}=i._preparedType;if(!s)throw new w({cause:f.Parse,code:k.MissingRequiredArgument,context:{commandKind:a.subcommand?"subcommand":"command",commandName:a.subcommand??t,argumentName:e}});void 0!==l&&(a.arguments[e]={schema:r,optional:s,defaultValue:l,source:"default"})}}return s.allowPositionals&&(a.positionals??=[]),a}(t,n)}catch(e){return{error:e}}const o=S(i.subcommand,n);if(!o){return{error:new Error(`Subcommand "${i.subcommand}" does not exist`)}}let a;try{a=nt(i,o)}catch(e){return{error:e}}return{error:void 0,validateResult:a,subcommandObject:o}}function it(e){const n=e;if(v(n.options),v(n.arguments),n.subcommands)for(const e of Object.values(n.subcommands))v(e.options),v(e.arguments);const t={generateCliHelpMessage:e=>Dn(n,e),generateSubcommandHelpMessage(e,t){const i=n.subcommands?.find(n=>n.name===e);if(!i)throw new w({cause:f.Definition,code:g.SubcommandHelpNotFound,context:{cliName:n.cliName,subcommandName:e}});return Pn(i,t,n.cliName)}};if(Object.assign(n,t),n.subcommands)for(const e of n.subcommands)Object.assign(e,t);return Object.assign(n,{onExecute:e=>(n._onExecute??=[],n._onExecute.push(e),()=>{const t=n._onExecute?.indexOf(e);!t||t<0||n._onExecute?.splice(t,1)}),execute:e=>{e??={};const t=n._onExecute;if(!t)throw new w({cause:f.Definition,code:g.MissingOnExecute,context:{commandKind:"command",commandName:n.cliName}});const i=nt(Fn(e,n),n);for(const e of t)e(i)},executeAsync:async e=>{e??={};const t=n._onExecute;if(!t)throw new w({cause:f.Definition,code:g.MissingOnExecute,context:{commandKind:"command",commandName:n.cliName}});const i=nt(Fn(e,n),n);await Promise.all(t.map(async e=>await e(i)))},run:e=>function(e,n){const t=tt(e,n);if(t.error)return{error:t.error};const{validateResult:i,subcommandObject:o}=t;if(o._onExecute)for(const e of o._onExecute)e(i);return{error:void 0,value:i}}(e,n),runAsync:e=>async function(e,n){const t=tt(e,n);if(t.error)return{error:t.error};const{validateResult:i,subcommandObject:o}=t;return o._onExecute&&await Promise.all(o._onExecute.map(async e=>await e(i))),{error:void 0,value:i}}(e,n)})}function ot(e){return v(e),e}function at(e){const n=e;v(n.options),v(n.arguments);return Object.assign(n,{onExecute:e=>(n._onExecute??=[],n._onExecute.push(e),()=>{const t=n._onExecute?.indexOf(e);!t||t<0||n._onExecute?.splice(t,1)}),execute:e=>{e??={};const t=n._onExecute;if(!t)throw new w({cause:f.Definition,code:g.MissingOnExecute,context:{commandKind:"subcommand",commandName:n.name}});const i=nt(Fn(e,n),n);for(const e of t)e(i)},executeAsync:async e=>{e??={};const t=n._onExecute;if(!t)throw new w({cause:f.Definition,code:g.MissingOnExecute,context:{commandKind:"subcommand",commandName:n.name}});const i=nt(Fn(e,n),n);await Promise.all(t.map(async e=>await e(i)))}})}function rt(e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1;throw new w({cause:f.Validation,code:b.CoercionFailed,context:{coerceToType:"boolean",providedValue:e}})}function st(e){const n=e.trim();if(!/^[-+]?[0-9]+(?:\.[0-9]+)?$/.test(n))throw new w({cause:f.Validation,code:b.CoercionFailed,context:{coerceToType:"number",providedValue:e}});const t=Number(n);if(!Number.isFinite(t))throw new w({cause:f.Validation,code:b.CoercionFailed,context:{coerceToType:"number",providedValue:e}});return t}function lt(e,n=","){return e.split(n).map(e=>e.trim()).filter(Boolean)}function ct(e,n=","){return lt(e,n).map(e=>st(e))}function ut(e,n=","){return lt(e,n).map(e=>rt(e))}var dt=e=>rt(e);dt.type="boolean";var mt,pt={string:e=>e,boolean:dt,number:e=>st(e),bigint:e=>function(e){const n=e.trim();if(!/^[+-]?[0-9]+$/.test(n))throw new w({cause:f.Validation,code:b.CoercionFailed,context:{coerceToType:"bigint",providedValue:e}});try{return BigInt(n)}catch{throw new w({cause:f.Validation,code:b.CoercionFailed,context:{coerceToType:"bigint",providedValue:e}})}}(e),object:(e={})=>n=>{const t=JSON.parse(n);return e.coerceBoolean||e.coerceNumber||e.coerceBigint||e.coerceDate?(p(t,(n,t,i)=>{if("string"!=typeof t)return t;const o=e=>!!e&&("boolean"==typeof e?e:e.includes(i));if(o(e.coerceBoolean))try{return rt(t)}catch{return t}if(o(e.coerceNumber))try{return st(t)}catch{return t}if(o(e.coerceBigint))try{return BigInt(t)}catch{return t}if(o(e.coerceDate))try{return new Date(t)}catch{return t}return t}),t):t},stringArray:e=>n=>lt(n,e),numberArray:e=>n=>ct(n,e),booleanArray:e=>n=>ut(n,e),stringSet:e=>n=>function(e,n=","){return new Set(lt(e,n))}(n,e),numberSet:e=>n=>function(e,n=","){return new Set(ct(e,n))}(n,e),booleanSet:e=>n=>function(e,n=","){return new Set(ut(e,n))}(n,e),json:e=>JSON.parse(e)};return mt=o,((o,a,r,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let l of t(a))i.call(o,l)||l===r||e(o,l,{get:()=>a[l],enumerable:!(s=n(a,l))||s.enumerable});return o})(e({},"__esModule",{value:!0}),mt)})();
2
42
  //# sourceMappingURL=index.js.map