yanki 2.0.1 → 2.0.2
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/dist/bin/cli.js +2 -2
- package/dist/lib/index.js +1 -1
- package/dist/standalone/index.js +1 -1
- package/package.json +1 -1
- package/dist/.DS_Store +0 -0
package/dist/bin/cli.js
CHANGED
|
@@ -99,7 +99,7 @@ complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name
|
|
|
99
99
|
`)}`:``;t.fail(i(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(r).length,Object.keys(r).join(`, `)+n))}},a.unknownArguments=function(n,r,o,s,c=!0){let l=e.getInternalMethods().getCommandInstance().getCommands(),u=[],d=e.getInternalMethods().getContext();if(Object.keys(n).forEach(t=>{!yi.includes(t)&&!Object.prototype.hasOwnProperty.call(o,t)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),t)&&!a.isValidAndSomeAliasIsNotNew(t,r)&&u.push(t)}),c&&(d.commands.length>0||l.length>0||s)&&n._.slice(d.commands.length).forEach(e=>{l.includes(``+e)||u.push(``+e)}),c){let t=e.getDemandedCommands()._?.max||0,r=d.commands.length+t;r<n._.length&&n._.slice(r).forEach(e=>{e=String(e),!d.commands.includes(e)&&!u.includes(e)&&u.push(e)})}u.length&&t.fail(i(`Unknown argument: %s`,`Unknown arguments: %s`,u.length,u.map(e=>e.trim()?e:`"${e}"`).join(`, `)))},a.unknownCommands=function(n){let r=e.getInternalMethods().getCommandInstance().getCommands(),a=[],o=e.getInternalMethods().getContext();return(o.commands.length>0||r.length>0)&&n._.slice(o.commands.length).forEach(e=>{r.includes(``+e)||a.push(``+e)}),a.length>0?(t.fail(i(`Unknown command: %s`,`Unknown commands: %s`,a.length,a.join(`, `))),!0):!1},a.isValidAndSomeAliasIsNotNew=function(t,n){if(!Object.prototype.hasOwnProperty.call(n,t))return!1;let r=e.parsed.newAliases;return[t,...n[t]].some(e=>!Object.prototype.hasOwnProperty.call(r,e)||!r[t])},a.limitedChoices=function(n){let i=e.getOptions(),a={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach(e=>{yi.indexOf(e)===-1&&Object.prototype.hasOwnProperty.call(i.choices,e)&&[].concat(n[e]).forEach(t=>{i.choices[e].indexOf(t)===-1&&t!==void 0&&(a[e]=(a[e]||[]).concat(t))})});let o=Object.keys(a);if(!o.length)return;let s=r(`Invalid values:`);o.forEach(e=>{s+=`\n ${r(`Argument: %s, Given: %s, Choices: %s`,e,t.stringifiedValues(a[e]),t.stringifiedValues(i.choices[e]))}`}),t.fail(s)};let o={};a.implies=function(t,r){F(`<string|object> [array|number|string]`,[t,r],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.implies(e,t[e])}):(e.global(t),o[t]||(o[t]=[]),Array.isArray(r)?r.forEach(e=>a.implies(t,e)):(Rr(r,void 0,n),o[t].push(r)))},a.getImplied=function(){return o};function s(e,t){let n=Number(t);return t=isNaN(n)?t:n,typeof t==`number`?t=e._.length>=t:t.match(/^--no-.+/)?(t=t.match(/^--no-(.+)/)[1],t=!Object.prototype.hasOwnProperty.call(e,t)):t=Object.prototype.hasOwnProperty.call(e,t),t}a.implications=function(e){let n=[];if(Object.keys(o).forEach(t=>{let r=t;(o[t]||[]).forEach(t=>{let i=r,a=t;i=s(e,i),t=s(e,t),i&&!t&&n.push(` ${r} -> ${a}`)})}),n.length){let e=`${r(`Implications failed:`)}\n`;n.forEach(t=>{e+=t}),t.fail(e)}};let c={};a.conflicts=function(t,n){F(`<string|object> [array|string]`,[t,n],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.conflicts(e,t[e])}):(e.global(t),c[t]||(c[t]=[]),Array.isArray(n)?n.forEach(e=>a.conflicts(t,e)):c[t].push(n))},a.getConflicting=()=>c,a.conflicting=function(i){Object.keys(i).forEach(e=>{c[e]&&c[e].forEach(n=>{n&&i[e]!==void 0&&i[n]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,n))})}),e.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(c).forEach(e=>{c[e].forEach(a=>{a&&i[n.Parser.camelCase(e)]!==void 0&&i[n.Parser.camelCase(a)]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,a))})})},a.recommendCommands=function(e,n){n=n.sort((e,t)=>t.length-e.length);let i=null,a=1/0;for(let t=0,r;(r=n[t])!==void 0;t++){let t=vi(e,r);t<=3&&t<a&&(a=t,i=r)}i&&t.fail(r(`Did you mean %s?`,i))},a.reset=function(e){return o=oi(o,t=>!e[t]),c=oi(c,t=>!e[t]),a};let l=[];return a.freeze=function(){l.push({implied:o,conflicting:c})},a.unfreeze=function(){let e=l.pop();Rr(e,void 0,n),{implied:o,conflicting:c}=e},a}let xi=[],Si;function Ci(e,t,n,r){Si=r;let i={};if(Object.prototype.hasOwnProperty.call(e,`extends`)){if(typeof e.extends!=`string`)return i;let r=/\.json|\..*rc$/.test(e.extends),a=null;if(r)a=Ti(t,e.extends);else try{a=N.resolve(e.extends)}catch{return e}wi(a),xi.push(a),i=r?JSON.parse(Si.readFileSync(a,`utf8`)):N(e.extends),delete e.extends,i=Ci(i,Si.path.dirname(a),n,Si)}return xi=[],n?Ei(i,e):Object.assign({},i,e)}function wi(e){if(xi.indexOf(e)>-1)throw new Or(`Circular extended configurations: '${e}'.`)}function Ti(e,t){return Si.path.resolve(e,t)}function Ei(e,t){let n={};function r(e){return e&&typeof e==`object`&&!Array.isArray(e)}Object.assign(n,e);for(let i of Object.keys(t))r(t[i])&&r(n[i])?n[i]=Ei(e[i],t[i]):n[i]=t[i];return n}var I=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},L=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,R,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,z,$i,ea,ta,B,na,ra,ia;function aa(e){return(t=[],n=e.process.cwd(),r)=>{let i=new Ha(t,n,r,e);return Object.defineProperty(i,`argv`,{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}const oa=Symbol(`copyDoubleDash`),sa=Symbol(`copyDoubleDash`),ca=Symbol(`deleteFromParserHintObject`),la=Symbol(`emitWarning`),ua=Symbol(`freeze`),da=Symbol(`getDollarZero`),fa=Symbol(`getParserConfiguration`),pa=Symbol(`getUsageConfiguration`),ma=Symbol(`guessLocale`),ha=Symbol(`guessVersion`),ga=Symbol(`parsePositionalNumbers`),_a=Symbol(`pkgUp`),va=Symbol(`populateParserHintArray`),ya=Symbol(`populateParserHintSingleValueDictionary`),ba=Symbol(`populateParserHintArrayDictionary`),xa=Symbol(`populateParserHintDictionary`),Sa=Symbol(`sanitizeKey`),Ca=Symbol(`setKey`),wa=Symbol(`unfreeze`),Ta=Symbol(`validateAsync`),Ea=Symbol(`getCommandInstance`),Da=Symbol(`getContext`),Oa=Symbol(`getHasOutput`),ka=Symbol(`getLoggerInstance`),Aa=Symbol(`getParseContext`),ja=Symbol(`getUsageInstance`),Ma=Symbol(`getValidationInstance`),Na=Symbol(`hasParseCallback`),Pa=Symbol(`isGlobalContext`),Fa=Symbol(`postProcess`),Ia=Symbol(`rebase`),La=Symbol(`reset`),Ra=Symbol(`runYargsParserAndExecuteCommands`),za=Symbol(`runValidation`),Ba=Symbol(`setHasOutput`),Va=Symbol(`kTrackManuallySetKeys`);var Ha=class{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,Di.set(this,void 0),Oi.set(this,void 0),ki.set(this,{commands:[],fullCommands:[]}),Ai.set(this,null),ji.set(this,null),Mi.set(this,`show-hidden`),Ni.set(this,null),Pi.set(this,!0),Fi.set(this,{}),Ii.set(this,!0),Li.set(this,[]),Ri.set(this,void 0),zi.set(this,{}),Bi.set(this,!1),Vi.set(this,null),Hi.set(this,!0),Ui.set(this,void 0),Wi.set(this,``),R.set(this,void 0),Gi.set(this,void 0),Ki.set(this,{}),qi.set(this,null),Ji.set(this,null),Yi.set(this,{}),Xi.set(this,{}),Zi.set(this,void 0),Qi.set(this,!1),z.set(this,void 0),$i.set(this,!1),ea.set(this,!1),ta.set(this,!1),B.set(this,void 0),na.set(this,{}),ra.set(this,null),ia.set(this,void 0),I(this,z,r,`f`),I(this,Zi,e,`f`),I(this,Oi,t,`f`),I(this,Gi,n,`f`),I(this,Ri,new Kr(this),`f`),this.$0=this[da](),this[La](),I(this,Di,L(this,Di,`f`),`f`),I(this,B,L(this,B,`f`),`f`),I(this,ia,L(this,ia,`f`),`f`),I(this,R,L(this,R,`f`),`f`),L(this,R,`f`).showHiddenOpt=L(this,Mi,`f`),I(this,Ui,this[sa](),`f`)}addHelpOpt(e,t){return F(`[string|boolean] [string]`,[e,t],arguments.length),L(this,Vi,`f`)&&(this[ca](L(this,Vi,`f`)),I(this,Vi,null,`f`)),e===!1&&t===void 0?this:(I(this,Vi,typeof e==`string`?e:`help`,`f`),this.boolean(L(this,Vi,`f`)),this.describe(L(this,Vi,`f`),t||L(this,B,`f`).deferY18nLookup(`Show help`)),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(F(`[string|boolean] [string]`,[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==`string`?e:L(this,Mi,`f`);return this.boolean(n),this.describe(n,t||L(this,B,`f`).deferY18nLookup(`Show hidden options`)),L(this,R,`f`).showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return F(`<object|string|array> [string|array]`,[e,t],arguments.length),this[ba](this.alias.bind(this),`alias`,e,t),this}array(e){return F(`<array|string>`,[e],arguments.length),this[va](`array`,e),this[Va](e),this}boolean(e){return F(`<array|string>`,[e],arguments.length),this[va](`boolean`,e),this[Va](e),this}check(e,t){return F(`<function> [boolean]`,[e,t],arguments.length),this.middleware((t,n)=>Yr(()=>e(t,n.getOptions()),n=>(n?(typeof n==`string`||n instanceof Error)&&L(this,B,`f`).fail(n.toString(),n):L(this,B,`f`).fail(L(this,z,`f`).y18n.__(`Argument check failed: %s`,e.toString())),t),e=>(L(this,B,`f`).fail(e.message?e.message:e.toString(),e),t)),!1,t),this}choices(e,t){return F(`<object|string|array> [string|array]`,[e,t],arguments.length),this[ba](this.choices.bind(this),`choices`,e,t),this}coerce(e,t){if(F(`<object|string|array> [function]`,[e,t],arguments.length),Array.isArray(e)){if(!t)throw new Or(`coerce callback must be provided`);for(let n of e)this.coerce(n,t);return this}else if(typeof e==`object`){for(let t of Object.keys(e))this.coerce(t,e[t]);return this}if(!t)throw new Or(`coerce callback must be provided`);return L(this,R,`f`).key[e]=!0,L(this,Ri,`f`).addCoerceMiddleware((n,r)=>{let i;return Object.prototype.hasOwnProperty.call(n,e)?Yr(()=>(i=r.getAliases(),t(n[e])),t=>{n[e]=t;let a=r.getInternalMethods().getParserConfiguration()[`strip-aliased`];if(i[e]&&a!==!0)for(let r of i[e])n[r]=t;return n},e=>{throw new Or(e.message)}):n},e),this}conflicts(e,t){return F(`<string|object> [string|array]`,[e,t],arguments.length),L(this,ia,`f`).conflicts(e,t),this}config(e=`config`,t,n){return F(`[object|string] [string|function] [function]`,[e,t,n],arguments.length),typeof e==`object`&&!Array.isArray(e)?(e=Ci(e,L(this,Oi,`f`),this[fa]()[`deep-merge-config`]||!1,L(this,z,`f`)),L(this,R,`f`).configObjects=(L(this,R,`f`).configObjects||[]).concat(e),this):(typeof t==`function`&&(n=t,t=void 0),this.describe(e,t||L(this,B,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(e)?e:[e]).forEach(e=>{L(this,R,`f`).config[e]=n||!0}),this)}completion(e,t,n){return F(`[string] [string|boolean|function] [function]`,[e,t,n],arguments.length),typeof t==`function`&&(n=t,t=void 0),I(this,ji,e||L(this,ji,`f`)||`completion`,`f`),!t&&t!==!1&&(t=`generate completion script`),this.command(L(this,ji,`f`),t),n&&L(this,Ai,`f`).registerFunction(n),this}command(e,t,n,r,i,a){return F(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[e,t,n,r,i,a],arguments.length),L(this,Di,`f`).addHandler(e,t,n,r,i,a),this}commands(e,t,n,r,i,a){return this.command(e,t,n,r,i,a)}commandDir(e,t){F(`<string> [object]`,[e,t],arguments.length);let n=L(this,Gi,`f`)||L(this,z,`f`).require;return L(this,Di,`f`).addDirectory(e,n,L(this,z,`f`).getCallerFile(),t),this}count(e){return F(`<array|string>`,[e],arguments.length),this[va](`count`,e),this[Va](e),this}default(e,t,n){return F(`<object|string|array> [*] [string]`,[e,t,n],arguments.length),n&&(zr(e,L(this,z,`f`)),L(this,R,`f`).defaultDescription[e]=n),typeof t==`function`&&(zr(e,L(this,z,`f`)),L(this,R,`f`).defaultDescription[e]||(L(this,R,`f`).defaultDescription[e]=L(this,B,`f`).functionDescription(t)),t=t.call()),this[ya](this.default.bind(this),`default`,e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){return F(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[e,t,n,r],arguments.length),typeof t!=`number`&&(n=t,t=1/0),this.global(`_`,!1),L(this,R,`f`).demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(e=>{Rr(n,!0,L(this,z,`f`)),this.demandOption(e,n)}),t=1/0):typeof t!=`number`&&(n=t,t=1/0),typeof e==`number`?(Rr(n,!0,L(this,z,`f`)),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(e=>{Rr(n,!0,L(this,z,`f`)),this.demandOption(e,n)}):typeof n==`string`?this.demandOption(e,n):(n===!0||n===void 0)&&this.demandOption(e),this}demandOption(e,t){return F(`<object|string|array> [string]`,[e,t],arguments.length),this[ya](this.demandOption.bind(this),`demandedOptions`,e,t),this}deprecateOption(e,t){return F(`<string> [string|boolean]`,[e,t],arguments.length),L(this,R,`f`).deprecatedOptions[e]=t,this}describe(e,t){return F(`<object|string|array> [string]`,[e,t],arguments.length),this[Ca](e,!0),L(this,B,`f`).describe(e,t),this}detectLocale(e){return F(`<boolean>`,[e],arguments.length),I(this,Pi,e,`f`),this}env(e){return F(`[string|boolean]`,[e],arguments.length),e===!1?delete L(this,R,`f`).envPrefix:L(this,R,`f`).envPrefix=e||``,this}epilogue(e){return F(`<string>`,[e],arguments.length),L(this,B,`f`).epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return F(`<string|array> [string]`,[e,t],arguments.length),Array.isArray(e)?e.forEach(e=>this.example(...e)):L(this,B,`f`).example(e,t),this}exit(e,t){I(this,Bi,!0,`f`),I(this,Ni,t,`f`),L(this,Ii,`f`)&&L(this,z,`f`).process.exit(e)}exitProcess(e=!0){return F(`[boolean]`,[e],arguments.length),I(this,Ii,e,`f`),this}fail(e){if(F(`<function|boolean>`,[e],arguments.length),typeof e==`boolean`&&e!==!1)throw new Or(`Invalid first argument. Expected function or boolean 'false'`);return L(this,B,`f`).failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return F(`<array> [function]`,[e,t],arguments.length),t?L(this,Ai,`f`).getCompletion(e,t):new Promise((t,n)=>{L(this,Ai,`f`).getCompletion(e,(e,r)=>{e?n(e):t(r)})})}getDemandedOptions(){return F([],0),L(this,R,`f`).demandedOptions}getDemandedCommands(){return F([],0),L(this,R,`f`).demandedCommands}getDeprecatedOptions(){return F([],0),L(this,R,`f`).deprecatedOptions}getDetectLocale(){return L(this,Pi,`f`)}getExitProcess(){return L(this,Ii,`f`)}getGroups(){return Object.assign({},L(this,zi,`f`),L(this,Xi,`f`))}getHelp(){if(I(this,Bi,!0,`f`),!L(this,B,`f`).hasCachedHelpMessage()){if(!this.parsed){let e=this[Ra](L(this,Zi,`f`),void 0,void 0,0,!0);if(Vr(e))return e.then(()=>L(this,B,`f`).help())}let e=L(this,Di,`f`).runDefaultBuilderOn(this);if(Vr(e))return e.then(()=>L(this,B,`f`).help())}return Promise.resolve(L(this,B,`f`).help())}getOptions(){return L(this,R,`f`)}getStrict(){return L(this,$i,`f`)}getStrictCommands(){return L(this,ea,`f`)}getStrictOptions(){return L(this,ta,`f`)}global(e,t){return F(`<string|array> [boolean]`,[e,t],arguments.length),e=[].concat(e),t===!1?e.forEach(e=>{L(this,R,`f`).local.includes(e)||L(this,R,`f`).local.push(e)}):L(this,R,`f`).local=L(this,R,`f`).local.filter(t=>e.indexOf(t)===-1),this}group(e,t){F(`<string|array> <string>`,[e,t],arguments.length);let n=L(this,Xi,`f`)[t]||L(this,zi,`f`)[t];L(this,Xi,`f`)[t]&&delete L(this,Xi,`f`)[t];let r={};return L(this,zi,`f`)[t]=(n||[]).concat(e).filter(e=>r[e]?!1:r[e]=!0),this}hide(e){return F(`<string>`,[e],arguments.length),L(this,R,`f`).hiddenOptions.push(e),this}implies(e,t){return F(`<string|object> [number|string|array]`,[e,t],arguments.length),L(this,ia,`f`).implies(e,t),this}locale(e){return F(`[string]`,[e],arguments.length),e===void 0?(this[ma](),L(this,z,`f`).y18n.getLocale()):(I(this,Pi,!1,`f`),L(this,z,`f`).y18n.setLocale(e),this)}middleware(e,t,n){return L(this,Ri,`f`).addMiddleware(e,!!t,n)}nargs(e,t){return F(`<string|object|array> [number]`,[e,t],arguments.length),this[ya](this.nargs.bind(this),`narg`,e,t),this}normalize(e){return F(`<array|string>`,[e],arguments.length),this[va](`normalize`,e),this}number(e){return F(`<array|string>`,[e],arguments.length),this[va](`number`,e),this[Va](e),this}option(e,t){if(F(`<string|object> [object]`,[e,t],arguments.length),typeof e==`object`)Object.keys(e).forEach(t=>{this.options(t,e[t])});else{typeof t!=`object`&&(t={}),this[Va](e),L(this,ra,`f`)&&(e===`version`||t?.alias===`version`)&&this[la]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
|
|
100
100
|
`),void 0,`versionWarning`),L(this,R,`f`).key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let r=t.demand||t.required||t.require;r&&this.demand(e,r),t.demandOption&&this.demandOption(e,typeof t.demandOption==`string`?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),`default`in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type===`boolean`)&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type===`array`)&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type===`number`)&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type===`string`)&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type===`count`)&&this.count(e),typeof t.global==`boolean`&&this.global(e,t.global),t.defaultDescription&&(L(this,R,`f`).defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let i=t.describe||t.description||t.desc,a=L(this,B,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof i==`string`)&&this.describe(e,i),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){F(`[string|array] [function|boolean|object] [function]`,[e,t,n],arguments.length),this[ua](),e===void 0&&(e=L(this,Zi,`f`)),typeof t==`object`&&(I(this,Ji,t,`f`),t=n),typeof t==`function`&&(I(this,qi,t,`f`),t=!1),t||I(this,Zi,e,`f`),L(this,qi,`f`)&&I(this,Ii,!1,`f`);let r=this[Ra](e,!!t),i=this.parsed;return L(this,Ai,`f`).setParsed(this.parsed),Vr(r)?r.then(e=>(L(this,qi,`f`)&&L(this,qi,`f`).call(this,L(this,Ni,`f`),e,L(this,Wi,`f`)),e)).catch(e=>{throw L(this,qi,`f`)&&L(this,qi,`f`)(e,this.parsed.argv,L(this,Wi,`f`)),e}).finally(()=>{this[wa](),this.parsed=i}):(L(this,qi,`f`)&&L(this,qi,`f`).call(this,L(this,Ni,`f`),r,L(this,Wi,`f`)),this[wa](),this.parsed=i,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return Vr(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(Vr(r))throw new Or(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return r}parserConfiguration(e){return F(`<object>`,[e],arguments.length),I(this,Ki,e,`f`),this}pkgConf(e,t){F(`<string> [string]`,[e,t],arguments.length);let n=null,r=this[_a](t||L(this,Oi,`f`));return r[e]&&typeof r[e]==`object`&&(n=Ci(r[e],t||L(this,Oi,`f`),this[fa]()[`deep-merge-config`]||!1,L(this,z,`f`)),L(this,R,`f`).configObjects=(L(this,R,`f`).configObjects||[]).concat(n)),this}positional(e,t){F(`<string> <object>`,[e,t],arguments.length);let n=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];t=oi(t,(e,t)=>e===`type`&&![`string`,`number`,`boolean`].includes(t)?!1:n.includes(e));let r=L(this,ki,`f`).fullCommands[L(this,ki,`f`).fullCommands.length-1],i=r?L(this,Di,`f`).cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Br(i).forEach(n=>{let r=i[n];Array.isArray(r)?r.indexOf(e)!==-1&&(t[n]=!0):r[e]&&!(n in t)&&(t[n]=r[e])}),this.group(e,L(this,B,`f`).getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return F(`[boolean]`,[e],arguments.length),I(this,Qi,e,`f`),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return F(`<array|string|object> [number]`,[e],arguments.length),typeof e==`string`&&L(this,R,`f`).narg[e]||this[ya](this.requiresArg.bind(this),`narg`,e,NaN),this}showCompletionScript(e,t){return F(`[string] [string]`,[e,t],arguments.length),e||=this.$0,L(this,Ui,`f`).log(L(this,Ai,`f`).generateCompletionScript(e,t||L(this,ji,`f`)||`completion`)),this}showHelp(e){if(F(`[string|function]`,[e],arguments.length),I(this,Bi,!0,`f`),!L(this,B,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[Ra](L(this,Zi,`f`),void 0,void 0,0,!0);if(Vr(t))return t.then(()=>{L(this,B,`f`).showHelp(e)}),this}let t=L(this,Di,`f`).runDefaultBuilderOn(this);if(Vr(t))return t.then(()=>{L(this,B,`f`).showHelp(e)}),this}return L(this,B,`f`).showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return F(`[boolean|string] [string]`,[e,t],arguments.length),L(this,B,`f`).showHelpOnFail(e,t),this}showVersion(e){return F(`[string|function]`,[e],arguments.length),L(this,B,`f`).showVersion(e),this}skipValidation(e){return F(`<array|string>`,[e],arguments.length),this[va](`skipValidation`,e),this}strict(e){return F(`[boolean]`,[e],arguments.length),I(this,$i,e!==!1,`f`),this}strictCommands(e){return F(`[boolean]`,[e],arguments.length),I(this,ea,e!==!1,`f`),this}strictOptions(e){return F(`[boolean]`,[e],arguments.length),I(this,ta,e!==!1,`f`),this}string(e){return F(`<array|string>`,[e],arguments.length),this[va](`string`,e),this[Va](e),this}terminalWidth(){return F([],0),L(this,z,`f`).process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return F(`<object>`,[e],arguments.length),I(this,Pi,!1,`f`),L(this,z,`f`).y18n.updateLocale(e),this}usage(e,t,n,r){if(F(`<string|null|undefined> [string|boolean] [function|object] [function]`,[e,t,n,r],arguments.length),t!==void 0){if(Rr(e,null,L(this,z,`f`)),(e||``).match(/^\$0( |$)/))return this.command(e,t,n,r);throw new Or(`.usage() description must start with $0 if being used as alias for .command()`)}else return L(this,B,`f`).usage(e),this}usageConfiguration(e){return F(`<object>`,[e],arguments.length),I(this,na,e,`f`),this}version(e,t,n){let r=`version`;if(F(`[boolean|string] [string] [string]`,[e,t,n],arguments.length),L(this,ra,`f`)&&(this[ca](L(this,ra,`f`)),L(this,B,`f`).version(void 0),I(this,ra,null,`f`)),arguments.length===0)n=this[ha](),e=r;else if(arguments.length===1){if(e===!1)return this;n=e,e=r}else arguments.length===2&&(n=t,t=void 0);return I(this,ra,typeof e==`string`?e:r,`f`),t||=L(this,B,`f`).deferY18nLookup(`Show version number`),L(this,B,`f`).version(n||void 0),this.boolean(L(this,ra,`f`)),this.describe(L(this,ra,`f`),t),this}wrap(e){return F(`<number|null|undefined>`,[e],arguments.length),L(this,B,`f`).wrap(e),this}[(Di=new WeakMap,Oi=new WeakMap,ki=new WeakMap,Ai=new WeakMap,ji=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,Pi=new WeakMap,Fi=new WeakMap,Ii=new WeakMap,Li=new WeakMap,Ri=new WeakMap,zi=new WeakMap,Bi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,Ui=new WeakMap,Wi=new WeakMap,R=new WeakMap,Gi=new WeakMap,Ki=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Yi=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,z=new WeakMap,$i=new WeakMap,ea=new WeakMap,ta=new WeakMap,B=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,oa)](e){if(!e._||!e[`--`])return e;e._.push.apply(e._,e[`--`]);try{delete e[`--`]}catch{}return e}[sa](){return{log:(...e)=>{this[Na]()||console.log(...e),I(this,Bi,!0,`f`),L(this,Wi,`f`).length&&I(this,Wi,L(this,Wi,`f`)+`
|
|
101
101
|
`,`f`),I(this,Wi,L(this,Wi,`f`)+e.join(` `),`f`)},error:(...e)=>{this[Na]()||console.error(...e),I(this,Bi,!0,`f`),L(this,Wi,`f`).length&&I(this,Wi,L(this,Wi,`f`)+`
|
|
102
|
-
`,`f`),I(this,Wi,L(this,Wi,`f`)+e.join(` `),`f`)}}}[ca](e){Br(L(this,R,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=L(this,R,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete L(this,B,`f`).getDescriptions()[e]}[la](e,t,n){L(this,Fi,`f`)[n]||(L(this,z,`f`).process.emitWarning(e,t),L(this,Fi,`f`)[n]=!0)}[ua](){L(this,Li,`f`).push({options:L(this,R,`f`),configObjects:L(this,R,`f`).configObjects.slice(0),exitProcess:L(this,Ii,`f`),groups:L(this,zi,`f`),strict:L(this,$i,`f`),strictCommands:L(this,ea,`f`),strictOptions:L(this,ta,`f`),completionCommand:L(this,ji,`f`),output:L(this,Wi,`f`),exitError:L(this,Ni,`f`),hasOutput:L(this,Bi,`f`),parsed:this.parsed,parseFn:L(this,qi,`f`),parseContext:L(this,Ji,`f`)}),L(this,B,`f`).freeze(),L(this,ia,`f`).freeze(),L(this,Di,`f`).freeze(),L(this,Ri,`f`).freeze()}[da](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(L(this,z,`f`).process.argv()[0])?L(this,z,`f`).process.argv().slice(1,2):L(this,z,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Ia](L(this,Oi,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),L(this,z,`f`).getEnv(`_`)&&L(this,z,`f`).getProcessArgvBin()===L(this,z,`f`).getEnv(`_`)&&(e=L(this,z,`f`).getEnv(`_`).replace(`${L(this,z,`f`).path.dirname(L(this,z,`f`).process.execPath())}/`,``)),e}[fa](){return L(this,Ki,`f`)}[pa](){return L(this,na,`f`)}[ma](){if(!L(this,Pi,`f`))return;let e=L(this,z,`f`).getEnv(`LC_ALL`)||L(this,z,`f`).getEnv(`LC_MESSAGES`)||L(this,z,`f`).getEnv(`LANG`)||L(this,z,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[ha](){return this[_a]().version||`unknown`}[ga](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)L(this,z,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[_a](e){let t=e||`*`;if(L(this,Yi,`f`)[t])return L(this,Yi,`f`)[t];let n={};try{let t=e||L(this,z,`f`).mainFilename;!e&&L(this,z,`f`).path.extname(t)&&(t=L(this,z,`f`).path.dirname(t));let r=L(this,z,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Rr(r,void 0,L(this,z,`f`)),n=JSON.parse(L(this,z,`f`).readFileSync(r,`utf8`))}catch{}return L(this,Yi,`f`)[t]=n||{},L(this,Yi,`f`)[t]}[va](e,t){t=[].concat(t),t.forEach(t=>{t=this[Sa](t),L(this,R,`f`)[e].push(t)})}[ya](e,t,n,r){this[xa](e,t,n,r,(e,t,n)=>{L(this,R,`f`)[e][t]=n})}[ba](e,t,n,r){this[xa](e,t,n,r,(e,t,n)=>{L(this,R,`f`)[e][t]=(L(this,R,`f`)[e][t]||[]).concat(n)})}[xa](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of Br(n))e(t,n[t]);else i(t,this[Sa](n),r)}[Sa](e){return e===`__proto__`?`___proto___`:e}[Ca](e,t){return this[ya](this[Ca].bind(this),`key`,e,t),this}[wa](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=L(this,Li,`f`).pop();Rr(f,void 0,L(this,z,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){I(e,R,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){I(t,Ii,e,`f`)}}.value,groups:{set value(e){I(n,zi,e,`f`)}}.value,output:{set value(e){I(r,Wi,e,`f`)}}.value,exitError:{set value(e){I(i,Ni,e,`f`)}}.value,hasOutput:{set value(e){I(a,Bi,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){I(o,$i,e,`f`)}}.value,strictCommands:{set value(e){I(s,ea,e,`f`)}}.value,strictOptions:{set value(e){I(c,ta,e,`f`)}}.value,completionCommand:{set value(e){I(l,ji,e,`f`)}}.value,parseFn:{set value(e){I(u,qi,e,`f`)}}.value,parseContext:{set value(e){I(d,Ji,e,`f`)}}.value}=f,L(this,R,`f`).configObjects=p,L(this,B,`f`).unfreeze(),L(this,ia,`f`).unfreeze(),L(this,Di,`f`).unfreeze(),L(this,Ri,`f`).unfreeze()}[Ta](e,t){return Yr(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Ea].bind(this),getContext:this[Da].bind(this),getHasOutput:this[Oa].bind(this),getLoggerInstance:this[ka].bind(this),getParseContext:this[Aa].bind(this),getParserConfiguration:this[fa].bind(this),getUsageConfiguration:this[pa].bind(this),getUsageInstance:this[ja].bind(this),getValidationInstance:this[Ma].bind(this),hasParseCallback:this[Na].bind(this),isGlobalContext:this[Pa].bind(this),postProcess:this[Fa].bind(this),reset:this[La].bind(this),runValidation:this[za].bind(this),runYargsParserAndExecuteCommands:this[Ra].bind(this),setHasOutput:this[Ba].bind(this)}}[Ea](){return L(this,Di,`f`)}[Da](){return L(this,ki,`f`)}[Oa](){return L(this,Bi,`f`)}[ka](){return L(this,Ui,`f`)}[Aa](){return L(this,Ji,`f`)||{}}[ja](){return L(this,B,`f`)}[Ma](){return L(this,ia,`f`)}[Na](){return!!L(this,qi,`f`)}[Pa](){return L(this,Hi,`f`)}[Fa](e,t,n,r){return n||Vr(e)?e:(t||(e=this[oa](e)),(this[fa]()[`parse-positional-numbers`]||this[fa]()[`parse-positional-numbers`]===void 0)&&(e=this[ga](e)),r&&(e=Jr(e,this,L(this,Ri,`f`).getMiddleware(),!1)),e)}[La](e={}){I(this,R,L(this,R,`f`)||{},`f`);let t={};t.local=L(this,R,`f`).local||[],t.configObjects=L(this,R,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(L(this,Xi,`f`),Object.keys(L(this,zi,`f`)).reduce((e,t)=>{let r=L(this,zi,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),I(this,zi,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(L(this,R,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=oi(L(this,R,`f`)[e],e=>!n[e])}),t.envPrefix=L(this,R,`f`).envPrefix,I(this,R,t,`f`),I(this,B,L(this,B,`f`)?L(this,B,`f`).reset(n):li(this,L(this,z,`f`)),`f`),I(this,ia,L(this,ia,`f`)?L(this,ia,`f`).reset(n):bi(this,L(this,B,`f`),L(this,z,`f`)),`f`),I(this,Di,L(this,Di,`f`)?L(this,Di,`f`).reset():ei(L(this,B,`f`),L(this,ia,`f`),L(this,Ri,`f`),L(this,z,`f`)),`f`),L(this,Ai,`f`)||I(this,Ai,hi(this,L(this,B,`f`),L(this,Di,`f`),L(this,z,`f`)),`f`),L(this,Ri,`f`).reset(),I(this,ji,null,`f`),I(this,Wi,``,`f`),I(this,Ni,null,`f`),I(this,Bi,!1,`f`),this.parsed=!1,this}[Ia](e,t){return L(this,z,`f`).path.relative(e,t)}[Ra](e,t,n,r=0,i=!1){let a=!!n||i;e||=L(this,Zi,`f`),L(this,R,`f`).__=L(this,z,`f`).y18n.__,L(this,R,`f`).configuration=this[fa]();let o=!!L(this,R,`f`).configuration[`populate--`],s=Object.assign({},L(this,R,`f`).configuration,{"populate--":!0}),c=L(this,z,`f`).Parser.detailed(e,Object.assign({},L(this,R,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,L(this,Ji,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===L(this,Vi,`f`)&&l[e]?f=!0:e===L(this,ra,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&L(this,B,`f`).clearCachedHelpMessage();try{if(this[ma](),t)return this[Fa](l,o,!!n,!1);L(this,Vi,`f`)&&[L(this,Vi,`f`)].concat(d[L(this,Vi,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),I(this,Hi,!1,`f`);let s=L(this,Di,`f`).getCommands(),m=L(this,Ai,`f`).completionKey in l,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++)if(a=String(l._[t]),s.includes(a)&&a!==L(this,ji,`f`)){let e=L(this,Di,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Fa](e,o,!!n,!1)}else if(!e&&a!==L(this,ji,`f`)){e=a;break}!L(this,Di,`f`).hasDefaultCommand()&&L(this,Qi,`f`)&&e&&!h&&L(this,ia,`f`).recommendCommands(e,s)}L(this,ji,`f`)&&l._.includes(L(this,ji,`f`))&&!m&&(L(this,Ii,`f`)&&si(!0),this.showCompletionScript(),this.exit(0))}if(L(this,Di,`f`).hasDefaultCommand()&&!h){let e=L(this,Di,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Fa](e,o,!!n,!1)}if(m){L(this,Ii,`f`)&&si(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${L(this,Ai,`f`).completionKey}`)+1);return L(this,Ai,`f`).getCompletion(t,(e,t)=>{if(e)throw new Or(e.message);(t||[]).forEach(e=>{L(this,Ui,`f`).log(e)}),this.exit(0)}),this[Fa](l,!o,!!n,!1)}if(L(this,Bi,`f`)||(f?(L(this,Ii,`f`)&&si(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(L(this,Ii,`f`)&&si(!0),a=!0,L(this,B,`f`).showVersion(`log`),this.exit(0))),!a&&L(this,R,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>L(this,R,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new Or(c.error.message);if(!m){let e=this[za](d,{},c.error);n||(u=Jr(l,this,L(this,Ri,`f`).getMiddleware(),!0)),u=this[Ta](e,u??l),Vr(u)&&!n&&(u=u.then(()=>Jr(l,this,L(this,Ri,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof Or)L(this,B,`f`).fail(e.message,e);else throw e}return this[Fa](u??l,o,!!n,!0)}[za](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new Or(n.message);L(this,ia,`f`).nonOptionCount(a),L(this,ia,`f`).requiredArguments(a,i);let o=!1;L(this,ea,`f`)&&(o=L(this,ia,`f`).unknownCommands(a)),L(this,$i,`f`)&&!o?L(this,ia,`f`).unknownArguments(a,e,t,!!r):L(this,ta,`f`)&&L(this,ia,`f`).unknownArguments(a,e,{},!1,!1),L(this,ia,`f`).limitedChoices(a),L(this,ia,`f`).implications(a),L(this,ia,`f`).conflicting(a)}}[Ba](){I(this,Bi,!0,`f`)}[Va](e){if(typeof e==`string`)L(this,R,`f`).key[e]=!0;else for(let t of e)L(this,R,`f`).key[t]=!0}};function Ua(e){return!!e&&typeof e.getInternalMethods==`function`}const Wa=aa(Lr);var Ga=`2.0.1`;const Ka={defaultMerge:Symbol(`deepmerge-ts: default merge`),skip:Symbol(`deepmerge-ts: skip`)};Ka.defaultMerge;function qa(e,t){return t}function Ja(e,t){return e.filter(e=>e!==void 0)}var Ya;(function(e){e[e.NOT=0]=`NOT`,e[e.RECORD=1]=`RECORD`,e[e.ARRAY=2]=`ARRAY`,e[e.SET=3]=`SET`,e[e.MAP=4]=`MAP`,e[e.OTHER=5]=`OTHER`})(Ya||={});function Xa(e){return typeof e!=`object`||!e?0:Array.isArray(e)?2:to(e)?1:e instanceof Set?3:e instanceof Map?4:5}function Za(e){let t=new Set;for(let n of e)for(let e of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(e);return t}function Qa(e,t){return typeof e==`object`&&Object.prototype.propertyIsEnumerable.call(e,t)}function $a(e){let t=0,n=e[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(n===void 0)return{done:!0,value:void 0};let r=n.next();if(r.done===!0){t+=1,n=e[t]?.[Symbol.iterator]();continue}return{done:!1,value:r.value}}while(!0)}}}}}const eo=[`[object Object]`,`[object Module]`];function to(e){if(!eo.includes(Object.prototype.toString.call(e)))return!1;let{constructor:t}=e;if(t===void 0)return!0;let n=t.prototype;return!(typeof n!=`object`||!n||!eo.includes(Object.prototype.toString.call(n))||!n.hasOwnProperty(`isPrototypeOf`))}function no(e,t,n){let r={};for(let i of Za(e)){let a=[];for(let t of e)Qa(t,i)&&a.push(t[i]);if(a.length===0)continue;let o=fo(a,t,t.metaDataUpdater(n,{key:i,parents:e}));o!==Ka.skip&&(i===`__proto__`?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function ro(e){return e.flat()}function io(e){return new Set($a(e))}function ao(e){return new Map($a(e))}function oo(e){return e.at(-1)}const so={mergeRecords:no,mergeArrays:ro,mergeSets:io,mergeMaps:ao,mergeOthers:oo};function co(...e){return lo({})(...e)}function lo(e,t){let n=uo(e,r);function r(...e){return fo(e,n,t)}return r}function uo(e,t){return{defaultMergeFunctions:so,mergeFunctions:{...so,...Object.fromEntries(Object.entries(e).filter(([e,t])=>Object.hasOwn(so,e)).map(([e,t])=>t===!1?[e,so.mergeOthers]:[e,t]))},metaDataUpdater:e.metaDataUpdater??qa,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Ja,actions:Ka}}function fo(e,t,n){let r=t.filterValues?.(e,n)??e;if(r.length===0)return;if(r.length===1)return _o(r,t,n);let i=Xa(r[0]);if(i!==0&&i!==5){for(let e=1;e<r.length;e++)if(Xa(r[e])!==i)return _o(r,t,n)}switch(i){case 1:return po(r,t,n);case 2:return mo(r,t,n);case 3:return ho(r,t,n);case 4:return go(r,t,n);default:return _o(r,t,n)}}function po(e,t,n){let r=t.mergeFunctions.mergeRecords(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function mo(e,t,n){let r=t.mergeFunctions.mergeArrays(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function ho(e,t,n){let r=t.mergeFunctions.mergeSets(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function go(e,t,n){let r=t.mergeFunctions.mergeMaps(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function _o(e,t,n){let r=t.mergeFunctions.mergeOthers(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}const vo=new Map(Object.entries({abscissa:`abscissae`,addendum:`addenda`,adulthood:`adulthood`,advice:`advice`,afreet:`afreets`,afrit:`afrits`,agendum:`agenda`,aid:`aid`,aircraft:`aircraft`,albino:`albinos`,alcohol:`alcohol`,alga:`algae`,alto:`altos`,alumna:`alumnae`,alumnus:`alumni`,alveolus:`alveoli`,amoeba:`amoebas`,ammo:`ammo`,analysis:`analyses`,analytics:`analytics`,anathema:`anathemas`,anime:`anime`,antenna:`antennas`,antithesis:`antitheses`,aphelion:`aphelia`,apparatus:`apparatuses`,appendix:`appendixes`,aquarium:`aquariums`,archipelago:`archipelagos`,armadillo:`armadillos`,asyndeton:`asyndetons`,athletics:`athletics`,audio:`audio`,aurora:`auroras`,automaton:`automatons`,axis:`axes`,bacillus:`bacilli`,bacterium:`bacteria`,baculum:`bacula`,barracks:`barracks`,basis:`bases`,basso:`bassos`,beau:`beaus`,beef:`beefs`,blood:`blood`,bema:`bemas`,biceps:`biceps`,bison:`bison`,bream:`bream`,breeches:`breeches`,britches:`britches`,brother:`brothers`,buffalo:`buffalo`,bureau:`bureaus`,businessman:`businessmen`,butter:`butter`,cactus:`cactuses`,calf:`calves`,cash:`cash`,candelabrum:`candelabra`,canto:`cantos`,cantus:`cantus`,carcinoma:`carcinomas`,carp:`carp`,census:`censuses`,chapeau:`chapeaus`,charisma:`charismas`,chairman:`chairmen`,chassis:`chassis`,cherub:`cherubs`,chess:`chess`,child:`children`,château:`châteaus`,clippers:`clippers`,clitoris:`clitorises`,clothes:`clothes`,clothing:`clothing`,cloaca:`cloacae`,cod:`cod`,codex:`codices`,commerce:`commerce`,coitus:`coitus`,commando:`commandos`,compendium:`compendiums`,concerto:`concertos`,consortium:`consortia`,contralto:`contraltos`,contretemps:`contretemps`,cooperation:`cooperation`,corps:`corps`,corpus:`corpora`,cortex:`cortices`,cranium:`crania`,crescendo:`crescendos`,crisis:`crises`,criterion:`criteria`,curriculum:`curricula`,cyclops:`cyclopses`,cystoma:`cystomata`,data:`data`,datum:`data`,debris:`debris`,deer:`deer`,desideratum:`desiderata`,diabetes:`diabetes`,diagnosis:`diagnoses`,dictum:`dicta`,die:`dice`,digestion:`digestion`,dingo:`dingoes`,diploma:`diplomas`,ditto:`dittos`,djinni:`djinn`,dogma:`dogmata`,drama:`dramas`,dwarf:`dwarfs`,dynamo:`dynamos`,economics:`economics`,echo:`echoes`,edema:`edemas`,efreet:`efreets`,eland:`eland`,elf:`elves`,elk:`elk`,ellipsis:`ellipses`,embargo:`embargoes`,embryo:`embryos`,emphasis:`emphases`,emporium:`emporia`,encomium:`encomia`,enigma:`enigmas`,equipment:`equipment`,ephemeris:`ephemerides`,erratum:`errata`,excretion:`excretion`,expertise:`expertise`,extremum:`extrema`,"faux pas":`faux pas`,fez:`fezzes`,fiasco:`fiascos`,fibula:`fibulae`,firmware:`firmware`,fish:`fish`,flounder:`flounder`,focus:`focuses`,foot:`feet`,fun:`fun`,foramen:`foramina`,formula:`formulas`,forum:`forums`,fungus:`fungi`,gallows:`gallows`,garbage:`garbage`,ganglion:`ganglia`,generalissimo:`generalissimos`,genie:`genies`,gentleman:`gentlemen`,genus:`genera`,ghetto:`ghettos`,glomerulus:`glomeruli`,goose:`geese`,goy:`goyim`,graffiti:`graffiti`,graffito:`graffiti`,grouse:`grouse`,guano:`guano`,gumma:`gummata`,gymnasium:`gymnasiums`,half:`halves`,hamulus:`hamuli`,hardware:`hardware`,health:`health`,headquarters:`headquarters`,hero:`heroes`,herpes:`herpes`,highjinks:`highjinks`,hijinks:`hijinks`,hiatus:`hiatuses`,hippopotamus:`hippopotamuses`,homework:`homework`,honorarium:`honoraria`,hoof:`hooves`,housework:`housework`,hovercraft:`hovercraft`,humerus:`humeri`,hyperbaton:`hyperbata`,hyperbola:`hyperbolae`,hypothesis:`hypotheses`,ilium:`ilia`,impetus:`impetuses`,incubus:`incubi`,index:`indexes`,information:`information`,inferno:`infernos`,innings:`innings`,interregnum:`interregna`,interstitium:`interstitia`,jackanapes:`jackanapes`,jeans:`jeans`,jumbo:`jumbos`,kakapo:`kakapo`,knife:`knives`,kudos:`kudos`,labour:`labour`,lacuna:`lacunas`,larva:`larvae`,leaf:`leaves`,lemma:`lemmas`,libretto:`librettos`,life:`lives`,lingo:`lingos`,literature:`literature`,loaf:`loaves`,loculus:`loculi`,locus:`loci`,looey:`looies`,louse:`lice`,lumbago:`lumbagos`,lumen:`lumina`,lustrum:`lustra`,lymphoma:`lymphomata`,machinery:`machinery`,mackerel:`mackerel`,magma:`magmas`,mail:`mail`,magneto:`magnetos`,man:`men`,manga:`manga`,manifesto:`manifestos`,matrix:`matrices`,maximum:`maxima`,means:`means`,measles:`measles`,medico:`medicos`,medium:`media`,melisma:`melismas`,memorandum:`memoranda`,meniscus:`menisci`,mews:`mews`,miasma:`miasmas`,millennium:`millennia`,minimum:`minima`,minutia:`minutiae`,momentum:`momenta`,mongoose:`mongooses`,moose:`moose`,mud:`mud`,mouse:`mice`,mumps:`mumps`,music:`music`,murex:`murices`,mythos:`mythoi`,nebula:`nebulas`,nemesis:`nemeses`,neurosis:`neuroses`,news:`news`,nexus:`nexuses`,nimbus:`nimbuses`,noumenon:`noumena`,nova:`novas`,nucleolus:`nucleoli`,nucleus:`nuclei`,oasis:`oases`,occiput:`occipita`,octavo:`octavos`,octopus:`octopuses`,oedema:`oedemas`,offspring:`offspring`,omphalos:`omphaloi`,optimum:`optima`,opus:`opuses`,organon:`organons`,ovum:`ova`,ox:`oxen`,parabola:`parabolas`,paralysis:`paralyses`,parenthesis:`parentheses`,passerby:`passersby`,penny:`pennies`,personnel:`personnel`,perihelion:`perihelia`,person:`people`,phalanx:`phalanges`,phenomenon:`phenomena`,photo:`photos`,physics:`physics`,phylum:`phyla`,pike:`pike`,pincers:`pincers`,plankton:`plankton`,plateau:`plateaus`,platypus:`platypuses`,plexus:`plexuses`,pliers:`pliers`,police:`police`,policeman:`policemen`,politics:`politics`,pollution:`pollution`,polyhedron:`polyhedra`,pontifex:`pontifices`,potato:`potatoes`,premises:`premises`,pro:`pros`,proceedings:`proceedings`,prognosis:`prognoses`,prolegomenon:`prolegomena`,prospectus:`prospectuses`,quantum:`quanta`,quarto:`quartos`,quiz:`quizzes`,rabies:`rabies`,rain:`rain`,radius:`radii`,referendum:`referendums`,reindeer:`reindeer`,research:`research`,rhino:`rhinos`,rice:`rice`,roof:`roofs`,rostrum:`rostrums`,salmon:`salmon`,sarcoma:`sarcomas`,sarcophagus:`sarcophagi`,savings:`savings`,scarf:`scarves`,schema:`schemas`,scissors:`scissors`,scrotum:`scrota`,"sea bass":`sea bass`,sewage:`sewage`,self:`selves`,seminoma:`seminomas`,shambles:`shambles`,seraph:`seraphs`,series:`series`,shears:`shears`,sheep:`sheep`,shelf:`shelves`,shrimp:`shrimp`,silex:`silices`,simplex:`simplexes`,simulacrum:`simulacra`,software:`software`,sinus:`sinuses`,soliloquy:`soliloquies`,solo:`solos`,soma:`somas`,soprano:`sopranos`,spacecraft:`spacecraft`,spokesman:`spokesmen`,species:`species`,spectrum:`spectra`,speculum:`specula`,sphinx:`sphinxes`,squid:`squid`,stadium:`stadiums`,staff:`staffs`,stairs:`stairs`,stamen:`stamens`,status:`statuses`,stigma:`stigmas`,stimulus:`stimuli`,stoma:`stomas`,stratum:`strata`,stylus:`styluses`,succubus:`succubi`,swine:`swine`,syconium:`syconia`,syllabus:`syllabuses`,symposium:`symposiums`,synopsis:`synopses`,synthesis:`syntheses`,tennis:`tennis`,tableau:`tableaus`,tempo:`tempos`,thanks:`thanks`,testis:`testes`,that:`those`,thesis:`theses`,thief:`thieves`,this:`these`,thrombus:`thrombi`,tibia:`tibias`,tomato:`tomatoes`,tooth:`teeth`,torpedo:`torpedoes`,tornado:`tornadoes`,torus:`tori`,traffic:`traffic`,transportation:`transportation`,trapezium:`trapezia`,trauma:`traumas`,triceps:`triceps`,trilby:`trilbies`,trout:`trout`,tuna:`tuna`,ultimatum:`ultimatums`,umbilicus:`umbilici`,upstairs:`upstairs`,uterus:`uteruses`,vacuum:`vacuums`,velum:`vela`,vertebra:`vertebrae`,vertex:`vertices`,veto:`vetoes`,viscus:`viscera`,wealth:`wealth`,welfare:`welfare`,vita:`vitae`,volcano:`volcanoes`,vortex:`vortices`,watercraft:`watercraft`,wharf:`wharves`,whiting:`whiting`,wife:`wives`,wildebeest:`wildebeest`,wildlife:`wildlife`,wolf:`wolves`,woman:`women`}));function yo(e,t,n){if(typeof t==`number`&&(n=t),vo.has(e.toLowerCase())){t=vo.get(e.toLowerCase());let n=e.charAt(0);n===n.toUpperCase()&&(t=n+t.slice(1)),e===e.toUpperCase()&&(t=t.toUpperCase())}else typeof t!=`string`&&(t=(e.replace(/(?:s|x|z|ch|sh)$/i,`$&e`).replace(/([^aeiou])y$/i,`$1ie`)+`s`).replace(/i?e?s$/i,t=>e.slice(-1)===e.slice(-1).toLowerCase()?t.toLowerCase():t.toUpperCase()));return Math.abs(n)===1?e:t}const bo=e=>Number.isFinite(e)?e:0;function xo(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(bo(e*1e3)%1e3),nanoseconds:Math.trunc(bo(e*1e6)%1e3)}}function So(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function Co(e){switch(typeof e){case`number`:if(Number.isFinite(e))return xo(e);break;case`bigint`:return So(e)}throw TypeError(`Expected a finite number or bigint`)}const wo=e=>e===0||e===0n,To=(e,t)=>t===1||t===1n?e:`${e}s`,Eo=24n*60n*60n*1000n;function Do(e,t){let n=typeof e==`bigint`;if(!n&&!Number.isFinite(e))throw TypeError(`Expected a finite number or bigint`);t={...t};let r=e<0?`-`:``;e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[],a=(e,t)=>{let n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)},o=(e,n,r,a)=>{if(!((i.length===0||!t.colonNotation)&&wo(e)&&!(t.colonNotation&&r===`m`))){if(a??=String(e),t.colonNotation){let e=a.includes(`.`)?a.split(`.`)[0].length:a.length,t=i.length>0?2:1;a=`0`.repeat(Math.max(0,t-e))+a}else a+=t.verbose?` `+To(n,e):r;i.push(a)}},s=Co(e),c=BigInt(s.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(s.hours),`hour`,`h`):(t.hideYear?o(c,`day`,`d`):(o(c/365n,`year`,`y`),o(c%365n,`day`,`d`)),o(Number(s.hours),`hour`,`h`)),o(Number(s.minutes),`minute`,`m`),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,`second`,`s`),t.formatSubMilliseconds)o(n,`millisecond`,`ms`),o(r,`microsecond`,`µs`),o(i,`nanosecond`,`ns`);else{let e=n+r/1e3+i/1e6,a=typeof t.millisecondsDecimalDigits==`number`?t.millisecondsDecimalDigits:0,s=a?e.toFixed(a):e>=1?Math.round(e):Math.ceil(e);o(Number.parseFloat(s),`millisecond`,`ms`,s)}}else{let r=a((n?Number(e%Eo):e)/1e3%60,typeof t.secondsDecimalDigits==`number`?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,``);o(Number.parseFloat(i),`second`,`s`,i)}if(i.length===0)return r+`0`+(t.verbose?` milliseconds`:`ms`);let l=t.colonNotation?`:`:` `;return typeof t.unitCount==`number`&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const Oo=typeof window>`u`?typeof process>`u`?`other`:`node`:`browser`,ko=Oo===`browser`?/windows/i.test(navigator.userAgent)?`windows`:/mac/i.test(navigator.userAgent)?`mac`:`other`:Oo===`node`?process.platform===`win32`?`windows`:process.platform===`darwin`?`mac`:`other`:`other`;let Ao=0,jo=0;async function Mo(){if(ko===`mac`&&Oo===`node`){let{openApp:e}=await import(`./open-8AenGr4K.js`);if(jo>=100){console.warn(`Too many Anki App launch attempts this session, ignoring`);return}(Ao===0||Date.now()-Ao>5e3)&&(console.warn(`Attempting to launch Anki app`),Ao=Date.now(),jo++,await e(`/Applications/Anki.app`,{background:!0,newInstance:!1,wait:!1}))}else console.warn(`Automatic Anki App launch is only supported on macOS in Node.js environment`)}const No={autoLaunch:!1,fetchAdapter:fetch.bind(globalThis),host:`http://127.0.0.1`,key:void 0,port:8765,version:6};var Po=class{card={answerCards:this.build(`answerCards`),areDue:this.build(`areDue`),areSuspended:this.build(`areSuspended`),cardsInfo:this.build(`cardsInfo`),cardsModTime:this.build(`cardsModTime`),cardsToNotes:this.build(`cardsToNotes`),findCards:this.build(`findCards`),forgetCards:this.build(`forgetCards`),getEaseFactors:this.build(`getEaseFactors`),getIntervals:this.build(`getIntervals`),relearnCards:this.build(`relearnCards`),setDueDate:this.build(`setDueDate`),setEaseFactors:this.build(`setEaseFactors`),setSpecificValueOfCard:this.build(`setSpecificValueOfCard`),suspend:this.build(`suspend`),suspended:this.build(`suspended`),unsuspend:this.build(`unsuspend`)};deck={changeDeck:this.build(`changeDeck`),cloneDeckConfigId:this.build(`cloneDeckConfigId`),createDeck:this.build(`createDeck`),deckNames:this.build(`deckNames`),deckNamesAndIds:this.build(`deckNamesAndIds`),deleteDecks:this.build(`deleteDecks`),getDeckConfig:this.build(`getDeckConfig`),getDecks:this.build(`getDecks`),getDeckStats:this.build(`getDeckStats`),removeDeckConfigId:this.build(`removeDeckConfigId`),saveDeckConfig:this.build(`saveDeckConfig`),setDeckConfigId:this.build(`setDeckConfigId`)};graphical={guiAddCards:this.build(`guiAddCards`),guiAnswerCard:this.build(`guiAnswerCard`),guiBrowse:this.build(`guiBrowse`),guiCheckDatabase:this.build(`guiCheckDatabase`),guiCurrentCard:this.build(`guiCurrentCard`),guiDeckBrowser:this.build(`guiDeckBrowser`),guiDeckOverview:this.build(`guiDeckOverview`),guiDeckReview:this.build(`guiDeckReview`),guiEditNote:this.build(`guiEditNote`),guiExitAnki:this.build(`guiExitAnki`),guiImportFile:this.build(`guiImportFile`),guiPlayAudio:this.build(`guiPlayAudio`),guiSelectCard:this.build(`guiSelectCard`),guiSelectedNotes:this.build(`guiSelectedNotes`),guiSelectNote:this.build(`guiSelectNote`),guiShowAnswer:this.build(`guiShowAnswer`),guiShowQuestion:this.build(`guiShowQuestion`),guiStartCardTimer:this.build(`guiStartCardTimer`),guiUndo:this.build(`guiUndo`)};media={deleteMediaFile:this.build(`deleteMediaFile`),getMediaDirPath:this.build(`getMediaDirPath`),getMediaFilesNames:this.build(`getMediaFilesNames`),retrieveMediaFile:this.build(`retrieveMediaFile`),storeMediaFile:this.build(`storeMediaFile`)};miscellaneous={apiReflect:this.build(`apiReflect`),exportPackage:this.build(`exportPackage`),getActiveProfile:this.build(`getActiveProfile`),getProfiles:this.build(`getProfiles`),importPackage:this.build(`importPackage`),loadProfile:this.build(`loadProfile`),multi:this.build(`multi`),reloadCollection:this.build(`reloadCollection`),requestPermission:this.build(`requestPermission`),sync:this.build(`sync`),version:this.build(`version`)};model={createModel:this.build(`createModel`),findAndReplaceInModels:this.build(`findAndReplaceInModels`),findModelsById:this.build(`findModelsById`),findModelsByName:this.build(`findModelsByName`),modelFieldAdd:this.build(`modelFieldAdd`),modelFieldDescriptions:this.build(`modelFieldDescriptions`),modelFieldFonts:this.build(`modelFieldFonts`),modelFieldNames:this.build(`modelFieldNames`),modelFieldRemove:this.build(`modelFieldRemove`),modelFieldRename:this.build(`modelFieldRename`),modelFieldReposition:this.build(`modelFieldReposition`),modelFieldSetDescription:this.build(`modelFieldSetDescription`),modelFieldSetFont:this.build(`modelFieldSetFont`),modelFieldSetFontSize:this.build(`modelFieldSetFontSize`),modelFieldsOnTemplates:this.build(`modelFieldsOnTemplates`),modelNames:this.build(`modelNames`),modelNamesAndIds:this.build(`modelNamesAndIds`),modelStyling:this.build(`modelStyling`),modelTemplateAdd:this.build(`modelTemplateAdd`),modelTemplateRemove:this.build(`modelTemplateRemove`),modelTemplateRename:this.build(`modelTemplateRename`),modelTemplateReposition:this.build(`modelTemplateReposition`),modelTemplates:this.build(`modelTemplates`),updateModelStyling:this.build(`updateModelStyling`),updateModelTemplates:this.build(`updateModelTemplates`)};note={addNote:this.build(`addNote`),addNotes:this.build(`addNotes`),addTags:this.build(`addTags`),canAddNotes:this.build(`canAddNotes`),canAddNotesWithErrorDetail:this.build(`canAddNotesWithErrorDetail`),clearUnusedTags:this.build(`clearUnusedTags`),deleteNotes:this.build(`deleteNotes`),findNotes:this.build(`findNotes`),getNoteTags:this.build(`getNoteTags`),getTags:this.build(`getTags`),notesInfo:this.build(`notesInfo`),notesModTime:this.build(`notesInfo`),removeEmptyNotes:this.build(`removeEmptyNotes`),removeTags:this.build(`removeTags`),replaceTags:this.build(`replaceTags`),replaceTagsInAllNotes:this.build(`replaceTagsInAllNotes`),updateNote:this.build(`updateNote`),updateNoteFields:this.build(`updateNoteFields`),updateNoteModel:this.build(`updateNoteModel`),updateNoteTags:this.build(`updateNoteTags`)};statistic={cardReviews:this.build(`cardReviews`),getCollectionStatsHTML:this.build(`getCollectionStatsHTML`),getLatestReviewID:this.build(`getLatestReviewID`),getNumCardsReviewedByDay:this.build(`getNumCardsReviewedByDay`),getNumCardsReviewedToday:this.build(`getNumCardsReviewedToday`),getReviewsOfCards:this.build(`getReviewsOfCards`),insertReviews:this.build(`insertReviews`)};autoLaunch;fetchAdapter;host;key;port;version;constructor(e){if(this.host=e?.host??No.host,this.port=e?.port??No.port,this.version=e?.version??No.version,this.key=e?.key??No.key,this.autoLaunch=e?.autoLaunch??No.autoLaunch,No.fetchAdapter===void 0)throw Error(`A fetch implementation is required`);if(this.fetchAdapter=e?.fetchAdapter??No.fetchAdapter,(ko!==`mac`||Oo!==`node`)&&this.autoLaunch!==!1&&(console.warn(`The autoLaunch option is only supported in a Node environment on macOS`),this.autoLaunch=!1),this.version!==6)throw Error(`YankiConnect currently only supports Anki-Connect API version 6`);this.autoLaunch===`immediately`&&Mo()}async invoke(e,t){let n,r;try{if(n=await this.fetchAdapter(`${this.host}:${this.port}`,{body:JSON.stringify({action:e,...this.key===void 0?{}:{key:this.key},params:t,version:this.version}),headers:{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`},method:`POST`,mode:`cors`}),n===void 0)throw Error(`Anki-Connect response is undefined`);if(n.status!==200)throw Error(`Anki-Connect response status is ${n.status}`);if(r=await n.json(),this.autoLaunch!==!1&&r.error===`collection is not available`)throw Error(r.error)}catch(n){if(this.autoLaunch!==!1)return console.warn(`Can't connect to Anki app, retrying with auto-launch...`),await Mo(),await new Promise(e=>{setTimeout(e,500)}),t===void 0?this.invoke(e):this.invoke(e,t);throw n}if(!(`error`in r))throw Error(`response is missing required error field`);if(!(`result`in r))throw Error(`response is missing required result field`);return r}build(e){return async t=>{let n=await this.invoke(e,t);if(n.error!==null)throw Error(n.error);return n.result}}},Fo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Io(e){return Lo(e)}function Lo(e){return Array.isArray(e)?Ro(e):e instanceof RegExp?e:typeof e==`object`?zo(e):e}function Ro(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Lo(e[n]);return t}function zo(e){let t={};for(let n in e)t[n]=Lo(e[n]);return t}function Bo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Vo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Vo(e.substring(0,e.length-1)):e.substr(~t+1)}var Ho=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Uo=class{static hasCaptures(e){return e===null?!1:(Ho.lastIndex=0,Ho.test(e))}static replaceCaptures(e,t,n){return e.replace(Ho,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Wo(e,t){return e<t?-1:e>t?1:0}function Go(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Wo(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function Ko(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function qo(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var Jo=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Yo=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(es(e),t)}static createFromParsedTheme(e,t){return rs(e,t)}_cachedMatchRoot=new Jo(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>Zo(e.parent,t.parentScopes));return n?new $o(n.fontStyle,n.foreground,n.background):null}},Xo=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function Zo(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!Qo(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Qo(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var $o=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function es(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&Ko(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&Ko(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new ts(l,u,e,o,s,c)}}return n}var ts=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},ns=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(ns||{});function rs(e,t){e.sort((e,t)=>{let n=Wo(e.scope,t.scope);return n!==0||(n=Go(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new is(t),o=new $o(n,a.getId(r),a.getId(i)),s=new ss(new os(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Yo(a,o,s)}var is=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},as=Object.freeze([]),os=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||as,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},ss=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),os.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Go(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new os(e,t,n,r,i))}},cs=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=e.containsBalancedBrackets(t)?1:0,d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=us(r)),i!==null&&(u=i?1:0),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function ls(e){return e}function us(e){return e}function ds(e,t){let n=[],r=ps(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(fs(i)){let e=[];do e.push(i),i=r.next();while(fs(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function fs(e){return!!e&&!!e.match(/[\w\.:]+/)}function ps(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function ms(e){typeof e.dispose==`function`&&e.dispose()}var hs=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},gs=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},_s=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},vs=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new hs(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new _s;for(let n of e)ys(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof hs){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ys(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof hs?xs({baseGrammar:a,selfGrammar:i},r):bs(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new hs(e))}function bs(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Ss([r],t,n)}}function xs(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ss(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ss(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ss(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Bo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ss(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Os(i);switch(a.kind){case 0:xs({...t,selfGrammar:t.baseGrammar},n);break;case 1:xs(t,n);break;case 2:bs(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?bs(a.ruleName,i,n):xs(i,n)}else a.kind===4?n.add(new gs(a.scopeName,a.ruleName)):n.add(new hs(a.scopeName));break}}}var Cs=class{kind=0},ws=class{kind=1},Ts=class{constructor(e){this.ruleName=e}kind=2},Es=class{constructor(e){this.scopeName=e}kind=3},Ds=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Os(e){if(e===`$base`)return new Cs;if(e===`$self`)return new ws;let t=e.indexOf(`#`);return t===-1?new Es(e):t===0?new Ts(e.substring(1)):new Ds(e.substring(0,t),e.substring(t+1))}var ks=/\\(\d+)/,As=/\\(\d+)/g,js=-1,Ms=-2;function Ns(e){return e}function Ps(e){return e}var Fs=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Uo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Uo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Vo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Uo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Uo.replaceCaptures(this._contentName,e,t)}},Is=class extends Fs{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Ls=class extends Fs{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Hs(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Us,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Rs=class extends Fs{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Us,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zs=class extends Fs{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Hs(i,this.id),this.beginCaptures=a,this._end=new Hs(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Us;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Bs=class extends Fs{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Hs(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Hs(o,Ms),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Us;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Us,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Vs=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Is(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Ls(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Bo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Rs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Bs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new zs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Os(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Rs||e instanceof zs||e instanceof Bs)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Hs=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=ks.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return As.lastIndex=0,this.source.replace(As,(e,t)=>qo(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Us=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){return this._cached||=new Ws(e,this._items.map(e=>e.source),this._items.map(e=>e.ruleId)),this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Ws(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Ws=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
102
|
+
`,`f`),I(this,Wi,L(this,Wi,`f`)+e.join(` `),`f`)}}}[ca](e){Br(L(this,R,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=L(this,R,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete L(this,B,`f`).getDescriptions()[e]}[la](e,t,n){L(this,Fi,`f`)[n]||(L(this,z,`f`).process.emitWarning(e,t),L(this,Fi,`f`)[n]=!0)}[ua](){L(this,Li,`f`).push({options:L(this,R,`f`),configObjects:L(this,R,`f`).configObjects.slice(0),exitProcess:L(this,Ii,`f`),groups:L(this,zi,`f`),strict:L(this,$i,`f`),strictCommands:L(this,ea,`f`),strictOptions:L(this,ta,`f`),completionCommand:L(this,ji,`f`),output:L(this,Wi,`f`),exitError:L(this,Ni,`f`),hasOutput:L(this,Bi,`f`),parsed:this.parsed,parseFn:L(this,qi,`f`),parseContext:L(this,Ji,`f`)}),L(this,B,`f`).freeze(),L(this,ia,`f`).freeze(),L(this,Di,`f`).freeze(),L(this,Ri,`f`).freeze()}[da](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(L(this,z,`f`).process.argv()[0])?L(this,z,`f`).process.argv().slice(1,2):L(this,z,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Ia](L(this,Oi,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),L(this,z,`f`).getEnv(`_`)&&L(this,z,`f`).getProcessArgvBin()===L(this,z,`f`).getEnv(`_`)&&(e=L(this,z,`f`).getEnv(`_`).replace(`${L(this,z,`f`).path.dirname(L(this,z,`f`).process.execPath())}/`,``)),e}[fa](){return L(this,Ki,`f`)}[pa](){return L(this,na,`f`)}[ma](){if(!L(this,Pi,`f`))return;let e=L(this,z,`f`).getEnv(`LC_ALL`)||L(this,z,`f`).getEnv(`LC_MESSAGES`)||L(this,z,`f`).getEnv(`LANG`)||L(this,z,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[ha](){return this[_a]().version||`unknown`}[ga](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)L(this,z,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[_a](e){let t=e||`*`;if(L(this,Yi,`f`)[t])return L(this,Yi,`f`)[t];let n={};try{let t=e||L(this,z,`f`).mainFilename;!e&&L(this,z,`f`).path.extname(t)&&(t=L(this,z,`f`).path.dirname(t));let r=L(this,z,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Rr(r,void 0,L(this,z,`f`)),n=JSON.parse(L(this,z,`f`).readFileSync(r,`utf8`))}catch{}return L(this,Yi,`f`)[t]=n||{},L(this,Yi,`f`)[t]}[va](e,t){t=[].concat(t),t.forEach(t=>{t=this[Sa](t),L(this,R,`f`)[e].push(t)})}[ya](e,t,n,r){this[xa](e,t,n,r,(e,t,n)=>{L(this,R,`f`)[e][t]=n})}[ba](e,t,n,r){this[xa](e,t,n,r,(e,t,n)=>{L(this,R,`f`)[e][t]=(L(this,R,`f`)[e][t]||[]).concat(n)})}[xa](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of Br(n))e(t,n[t]);else i(t,this[Sa](n),r)}[Sa](e){return e===`__proto__`?`___proto___`:e}[Ca](e,t){return this[ya](this[Ca].bind(this),`key`,e,t),this}[wa](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=L(this,Li,`f`).pop();Rr(f,void 0,L(this,z,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){I(e,R,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){I(t,Ii,e,`f`)}}.value,groups:{set value(e){I(n,zi,e,`f`)}}.value,output:{set value(e){I(r,Wi,e,`f`)}}.value,exitError:{set value(e){I(i,Ni,e,`f`)}}.value,hasOutput:{set value(e){I(a,Bi,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){I(o,$i,e,`f`)}}.value,strictCommands:{set value(e){I(s,ea,e,`f`)}}.value,strictOptions:{set value(e){I(c,ta,e,`f`)}}.value,completionCommand:{set value(e){I(l,ji,e,`f`)}}.value,parseFn:{set value(e){I(u,qi,e,`f`)}}.value,parseContext:{set value(e){I(d,Ji,e,`f`)}}.value}=f,L(this,R,`f`).configObjects=p,L(this,B,`f`).unfreeze(),L(this,ia,`f`).unfreeze(),L(this,Di,`f`).unfreeze(),L(this,Ri,`f`).unfreeze()}[Ta](e,t){return Yr(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Ea].bind(this),getContext:this[Da].bind(this),getHasOutput:this[Oa].bind(this),getLoggerInstance:this[ka].bind(this),getParseContext:this[Aa].bind(this),getParserConfiguration:this[fa].bind(this),getUsageConfiguration:this[pa].bind(this),getUsageInstance:this[ja].bind(this),getValidationInstance:this[Ma].bind(this),hasParseCallback:this[Na].bind(this),isGlobalContext:this[Pa].bind(this),postProcess:this[Fa].bind(this),reset:this[La].bind(this),runValidation:this[za].bind(this),runYargsParserAndExecuteCommands:this[Ra].bind(this),setHasOutput:this[Ba].bind(this)}}[Ea](){return L(this,Di,`f`)}[Da](){return L(this,ki,`f`)}[Oa](){return L(this,Bi,`f`)}[ka](){return L(this,Ui,`f`)}[Aa](){return L(this,Ji,`f`)||{}}[ja](){return L(this,B,`f`)}[Ma](){return L(this,ia,`f`)}[Na](){return!!L(this,qi,`f`)}[Pa](){return L(this,Hi,`f`)}[Fa](e,t,n,r){return n||Vr(e)?e:(t||(e=this[oa](e)),(this[fa]()[`parse-positional-numbers`]||this[fa]()[`parse-positional-numbers`]===void 0)&&(e=this[ga](e)),r&&(e=Jr(e,this,L(this,Ri,`f`).getMiddleware(),!1)),e)}[La](e={}){I(this,R,L(this,R,`f`)||{},`f`);let t={};t.local=L(this,R,`f`).local||[],t.configObjects=L(this,R,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(L(this,Xi,`f`),Object.keys(L(this,zi,`f`)).reduce((e,t)=>{let r=L(this,zi,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),I(this,zi,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(L(this,R,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=oi(L(this,R,`f`)[e],e=>!n[e])}),t.envPrefix=L(this,R,`f`).envPrefix,I(this,R,t,`f`),I(this,B,L(this,B,`f`)?L(this,B,`f`).reset(n):li(this,L(this,z,`f`)),`f`),I(this,ia,L(this,ia,`f`)?L(this,ia,`f`).reset(n):bi(this,L(this,B,`f`),L(this,z,`f`)),`f`),I(this,Di,L(this,Di,`f`)?L(this,Di,`f`).reset():ei(L(this,B,`f`),L(this,ia,`f`),L(this,Ri,`f`),L(this,z,`f`)),`f`),L(this,Ai,`f`)||I(this,Ai,hi(this,L(this,B,`f`),L(this,Di,`f`),L(this,z,`f`)),`f`),L(this,Ri,`f`).reset(),I(this,ji,null,`f`),I(this,Wi,``,`f`),I(this,Ni,null,`f`),I(this,Bi,!1,`f`),this.parsed=!1,this}[Ia](e,t){return L(this,z,`f`).path.relative(e,t)}[Ra](e,t,n,r=0,i=!1){let a=!!n||i;e||=L(this,Zi,`f`),L(this,R,`f`).__=L(this,z,`f`).y18n.__,L(this,R,`f`).configuration=this[fa]();let o=!!L(this,R,`f`).configuration[`populate--`],s=Object.assign({},L(this,R,`f`).configuration,{"populate--":!0}),c=L(this,z,`f`).Parser.detailed(e,Object.assign({},L(this,R,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,L(this,Ji,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===L(this,Vi,`f`)&&l[e]?f=!0:e===L(this,ra,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&L(this,B,`f`).clearCachedHelpMessage();try{if(this[ma](),t)return this[Fa](l,o,!!n,!1);L(this,Vi,`f`)&&[L(this,Vi,`f`)].concat(d[L(this,Vi,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),I(this,Hi,!1,`f`);let s=L(this,Di,`f`).getCommands(),m=L(this,Ai,`f`).completionKey in l,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++)if(a=String(l._[t]),s.includes(a)&&a!==L(this,ji,`f`)){let e=L(this,Di,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Fa](e,o,!!n,!1)}else if(!e&&a!==L(this,ji,`f`)){e=a;break}!L(this,Di,`f`).hasDefaultCommand()&&L(this,Qi,`f`)&&e&&!h&&L(this,ia,`f`).recommendCommands(e,s)}L(this,ji,`f`)&&l._.includes(L(this,ji,`f`))&&!m&&(L(this,Ii,`f`)&&si(!0),this.showCompletionScript(),this.exit(0))}if(L(this,Di,`f`).hasDefaultCommand()&&!h){let e=L(this,Di,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Fa](e,o,!!n,!1)}if(m){L(this,Ii,`f`)&&si(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${L(this,Ai,`f`).completionKey}`)+1);return L(this,Ai,`f`).getCompletion(t,(e,t)=>{if(e)throw new Or(e.message);(t||[]).forEach(e=>{L(this,Ui,`f`).log(e)}),this.exit(0)}),this[Fa](l,!o,!!n,!1)}if(L(this,Bi,`f`)||(f?(L(this,Ii,`f`)&&si(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(L(this,Ii,`f`)&&si(!0),a=!0,L(this,B,`f`).showVersion(`log`),this.exit(0))),!a&&L(this,R,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>L(this,R,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new Or(c.error.message);if(!m){let e=this[za](d,{},c.error);n||(u=Jr(l,this,L(this,Ri,`f`).getMiddleware(),!0)),u=this[Ta](e,u??l),Vr(u)&&!n&&(u=u.then(()=>Jr(l,this,L(this,Ri,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof Or)L(this,B,`f`).fail(e.message,e);else throw e}return this[Fa](u??l,o,!!n,!0)}[za](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new Or(n.message);L(this,ia,`f`).nonOptionCount(a),L(this,ia,`f`).requiredArguments(a,i);let o=!1;L(this,ea,`f`)&&(o=L(this,ia,`f`).unknownCommands(a)),L(this,$i,`f`)&&!o?L(this,ia,`f`).unknownArguments(a,e,t,!!r):L(this,ta,`f`)&&L(this,ia,`f`).unknownArguments(a,e,{},!1,!1),L(this,ia,`f`).limitedChoices(a),L(this,ia,`f`).implications(a),L(this,ia,`f`).conflicting(a)}}[Ba](){I(this,Bi,!0,`f`)}[Va](e){if(typeof e==`string`)L(this,R,`f`).key[e]=!0;else for(let t of e)L(this,R,`f`).key[t]=!0}};function Ua(e){return!!e&&typeof e.getInternalMethods==`function`}const Wa=aa(Lr);var Ga=`2.0.2`;const Ka={defaultMerge:Symbol(`deepmerge-ts: default merge`),skip:Symbol(`deepmerge-ts: skip`)};Ka.defaultMerge;function qa(e,t){return t}function Ja(e,t){return e.filter(e=>e!==void 0)}var Ya;(function(e){e[e.NOT=0]=`NOT`,e[e.RECORD=1]=`RECORD`,e[e.ARRAY=2]=`ARRAY`,e[e.SET=3]=`SET`,e[e.MAP=4]=`MAP`,e[e.OTHER=5]=`OTHER`})(Ya||={});function Xa(e){return typeof e!=`object`||!e?0:Array.isArray(e)?2:to(e)?1:e instanceof Set?3:e instanceof Map?4:5}function Za(e){let t=new Set;for(let n of e)for(let e of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(e);return t}function Qa(e,t){return typeof e==`object`&&Object.prototype.propertyIsEnumerable.call(e,t)}function $a(e){let t=0,n=e[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(n===void 0)return{done:!0,value:void 0};let r=n.next();if(r.done===!0){t+=1,n=e[t]?.[Symbol.iterator]();continue}return{done:!1,value:r.value}}while(!0)}}}}}const eo=[`[object Object]`,`[object Module]`];function to(e){if(!eo.includes(Object.prototype.toString.call(e)))return!1;let{constructor:t}=e;if(t===void 0)return!0;let n=t.prototype;return!(typeof n!=`object`||!n||!eo.includes(Object.prototype.toString.call(n))||!n.hasOwnProperty(`isPrototypeOf`))}function no(e,t,n){let r={};for(let i of Za(e)){let a=[];for(let t of e)Qa(t,i)&&a.push(t[i]);if(a.length===0)continue;let o=fo(a,t,t.metaDataUpdater(n,{key:i,parents:e}));o!==Ka.skip&&(i===`__proto__`?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function ro(e){return e.flat()}function io(e){return new Set($a(e))}function ao(e){return new Map($a(e))}function oo(e){return e.at(-1)}const so={mergeRecords:no,mergeArrays:ro,mergeSets:io,mergeMaps:ao,mergeOthers:oo};function co(...e){return lo({})(...e)}function lo(e,t){let n=uo(e,r);function r(...e){return fo(e,n,t)}return r}function uo(e,t){return{defaultMergeFunctions:so,mergeFunctions:{...so,...Object.fromEntries(Object.entries(e).filter(([e,t])=>Object.hasOwn(so,e)).map(([e,t])=>t===!1?[e,so.mergeOthers]:[e,t]))},metaDataUpdater:e.metaDataUpdater??qa,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Ja,actions:Ka}}function fo(e,t,n){let r=t.filterValues?.(e,n)??e;if(r.length===0)return;if(r.length===1)return _o(r,t,n);let i=Xa(r[0]);if(i!==0&&i!==5){for(let e=1;e<r.length;e++)if(Xa(r[e])!==i)return _o(r,t,n)}switch(i){case 1:return po(r,t,n);case 2:return mo(r,t,n);case 3:return ho(r,t,n);case 4:return go(r,t,n);default:return _o(r,t,n)}}function po(e,t,n){let r=t.mergeFunctions.mergeRecords(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function mo(e,t,n){let r=t.mergeFunctions.mergeArrays(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function ho(e,t,n){let r=t.mergeFunctions.mergeSets(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function go(e,t,n){let r=t.mergeFunctions.mergeMaps(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function _o(e,t,n){let r=t.mergeFunctions.mergeOthers(e,t,n);return r===Ka.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}const vo=new Map(Object.entries({abscissa:`abscissae`,addendum:`addenda`,adulthood:`adulthood`,advice:`advice`,afreet:`afreets`,afrit:`afrits`,agendum:`agenda`,aid:`aid`,aircraft:`aircraft`,albino:`albinos`,alcohol:`alcohol`,alga:`algae`,alto:`altos`,alumna:`alumnae`,alumnus:`alumni`,alveolus:`alveoli`,amoeba:`amoebas`,ammo:`ammo`,analysis:`analyses`,analytics:`analytics`,anathema:`anathemas`,anime:`anime`,antenna:`antennas`,antithesis:`antitheses`,aphelion:`aphelia`,apparatus:`apparatuses`,appendix:`appendixes`,aquarium:`aquariums`,archipelago:`archipelagos`,armadillo:`armadillos`,asyndeton:`asyndetons`,athletics:`athletics`,audio:`audio`,aurora:`auroras`,automaton:`automatons`,axis:`axes`,bacillus:`bacilli`,bacterium:`bacteria`,baculum:`bacula`,barracks:`barracks`,basis:`bases`,basso:`bassos`,beau:`beaus`,beef:`beefs`,blood:`blood`,bema:`bemas`,biceps:`biceps`,bison:`bison`,bream:`bream`,breeches:`breeches`,britches:`britches`,brother:`brothers`,buffalo:`buffalo`,bureau:`bureaus`,businessman:`businessmen`,butter:`butter`,cactus:`cactuses`,calf:`calves`,cash:`cash`,candelabrum:`candelabra`,canto:`cantos`,cantus:`cantus`,carcinoma:`carcinomas`,carp:`carp`,census:`censuses`,chapeau:`chapeaus`,charisma:`charismas`,chairman:`chairmen`,chassis:`chassis`,cherub:`cherubs`,chess:`chess`,child:`children`,château:`châteaus`,clippers:`clippers`,clitoris:`clitorises`,clothes:`clothes`,clothing:`clothing`,cloaca:`cloacae`,cod:`cod`,codex:`codices`,commerce:`commerce`,coitus:`coitus`,commando:`commandos`,compendium:`compendiums`,concerto:`concertos`,consortium:`consortia`,contralto:`contraltos`,contretemps:`contretemps`,cooperation:`cooperation`,corps:`corps`,corpus:`corpora`,cortex:`cortices`,cranium:`crania`,crescendo:`crescendos`,crisis:`crises`,criterion:`criteria`,curriculum:`curricula`,cyclops:`cyclopses`,cystoma:`cystomata`,data:`data`,datum:`data`,debris:`debris`,deer:`deer`,desideratum:`desiderata`,diabetes:`diabetes`,diagnosis:`diagnoses`,dictum:`dicta`,die:`dice`,digestion:`digestion`,dingo:`dingoes`,diploma:`diplomas`,ditto:`dittos`,djinni:`djinn`,dogma:`dogmata`,drama:`dramas`,dwarf:`dwarfs`,dynamo:`dynamos`,economics:`economics`,echo:`echoes`,edema:`edemas`,efreet:`efreets`,eland:`eland`,elf:`elves`,elk:`elk`,ellipsis:`ellipses`,embargo:`embargoes`,embryo:`embryos`,emphasis:`emphases`,emporium:`emporia`,encomium:`encomia`,enigma:`enigmas`,equipment:`equipment`,ephemeris:`ephemerides`,erratum:`errata`,excretion:`excretion`,expertise:`expertise`,extremum:`extrema`,"faux pas":`faux pas`,fez:`fezzes`,fiasco:`fiascos`,fibula:`fibulae`,firmware:`firmware`,fish:`fish`,flounder:`flounder`,focus:`focuses`,foot:`feet`,fun:`fun`,foramen:`foramina`,formula:`formulas`,forum:`forums`,fungus:`fungi`,gallows:`gallows`,garbage:`garbage`,ganglion:`ganglia`,generalissimo:`generalissimos`,genie:`genies`,gentleman:`gentlemen`,genus:`genera`,ghetto:`ghettos`,glomerulus:`glomeruli`,goose:`geese`,goy:`goyim`,graffiti:`graffiti`,graffito:`graffiti`,grouse:`grouse`,guano:`guano`,gumma:`gummata`,gymnasium:`gymnasiums`,half:`halves`,hamulus:`hamuli`,hardware:`hardware`,health:`health`,headquarters:`headquarters`,hero:`heroes`,herpes:`herpes`,highjinks:`highjinks`,hijinks:`hijinks`,hiatus:`hiatuses`,hippopotamus:`hippopotamuses`,homework:`homework`,honorarium:`honoraria`,hoof:`hooves`,housework:`housework`,hovercraft:`hovercraft`,humerus:`humeri`,hyperbaton:`hyperbata`,hyperbola:`hyperbolae`,hypothesis:`hypotheses`,ilium:`ilia`,impetus:`impetuses`,incubus:`incubi`,index:`indexes`,information:`information`,inferno:`infernos`,innings:`innings`,interregnum:`interregna`,interstitium:`interstitia`,jackanapes:`jackanapes`,jeans:`jeans`,jumbo:`jumbos`,kakapo:`kakapo`,knife:`knives`,kudos:`kudos`,labour:`labour`,lacuna:`lacunas`,larva:`larvae`,leaf:`leaves`,lemma:`lemmas`,libretto:`librettos`,life:`lives`,lingo:`lingos`,literature:`literature`,loaf:`loaves`,loculus:`loculi`,locus:`loci`,looey:`looies`,louse:`lice`,lumbago:`lumbagos`,lumen:`lumina`,lustrum:`lustra`,lymphoma:`lymphomata`,machinery:`machinery`,mackerel:`mackerel`,magma:`magmas`,mail:`mail`,magneto:`magnetos`,man:`men`,manga:`manga`,manifesto:`manifestos`,matrix:`matrices`,maximum:`maxima`,means:`means`,measles:`measles`,medico:`medicos`,medium:`media`,melisma:`melismas`,memorandum:`memoranda`,meniscus:`menisci`,mews:`mews`,miasma:`miasmas`,millennium:`millennia`,minimum:`minima`,minutia:`minutiae`,momentum:`momenta`,mongoose:`mongooses`,moose:`moose`,mud:`mud`,mouse:`mice`,mumps:`mumps`,music:`music`,murex:`murices`,mythos:`mythoi`,nebula:`nebulas`,nemesis:`nemeses`,neurosis:`neuroses`,news:`news`,nexus:`nexuses`,nimbus:`nimbuses`,noumenon:`noumena`,nova:`novas`,nucleolus:`nucleoli`,nucleus:`nuclei`,oasis:`oases`,occiput:`occipita`,octavo:`octavos`,octopus:`octopuses`,oedema:`oedemas`,offspring:`offspring`,omphalos:`omphaloi`,optimum:`optima`,opus:`opuses`,organon:`organons`,ovum:`ova`,ox:`oxen`,parabola:`parabolas`,paralysis:`paralyses`,parenthesis:`parentheses`,passerby:`passersby`,penny:`pennies`,personnel:`personnel`,perihelion:`perihelia`,person:`people`,phalanx:`phalanges`,phenomenon:`phenomena`,photo:`photos`,physics:`physics`,phylum:`phyla`,pike:`pike`,pincers:`pincers`,plankton:`plankton`,plateau:`plateaus`,platypus:`platypuses`,plexus:`plexuses`,pliers:`pliers`,police:`police`,policeman:`policemen`,politics:`politics`,pollution:`pollution`,polyhedron:`polyhedra`,pontifex:`pontifices`,potato:`potatoes`,premises:`premises`,pro:`pros`,proceedings:`proceedings`,prognosis:`prognoses`,prolegomenon:`prolegomena`,prospectus:`prospectuses`,quantum:`quanta`,quarto:`quartos`,quiz:`quizzes`,rabies:`rabies`,rain:`rain`,radius:`radii`,referendum:`referendums`,reindeer:`reindeer`,research:`research`,rhino:`rhinos`,rice:`rice`,roof:`roofs`,rostrum:`rostrums`,salmon:`salmon`,sarcoma:`sarcomas`,sarcophagus:`sarcophagi`,savings:`savings`,scarf:`scarves`,schema:`schemas`,scissors:`scissors`,scrotum:`scrota`,"sea bass":`sea bass`,sewage:`sewage`,self:`selves`,seminoma:`seminomas`,shambles:`shambles`,seraph:`seraphs`,series:`series`,shears:`shears`,sheep:`sheep`,shelf:`shelves`,shrimp:`shrimp`,silex:`silices`,simplex:`simplexes`,simulacrum:`simulacra`,software:`software`,sinus:`sinuses`,soliloquy:`soliloquies`,solo:`solos`,soma:`somas`,soprano:`sopranos`,spacecraft:`spacecraft`,spokesman:`spokesmen`,species:`species`,spectrum:`spectra`,speculum:`specula`,sphinx:`sphinxes`,squid:`squid`,stadium:`stadiums`,staff:`staffs`,stairs:`stairs`,stamen:`stamens`,status:`statuses`,stigma:`stigmas`,stimulus:`stimuli`,stoma:`stomas`,stratum:`strata`,stylus:`styluses`,succubus:`succubi`,swine:`swine`,syconium:`syconia`,syllabus:`syllabuses`,symposium:`symposiums`,synopsis:`synopses`,synthesis:`syntheses`,tennis:`tennis`,tableau:`tableaus`,tempo:`tempos`,thanks:`thanks`,testis:`testes`,that:`those`,thesis:`theses`,thief:`thieves`,this:`these`,thrombus:`thrombi`,tibia:`tibias`,tomato:`tomatoes`,tooth:`teeth`,torpedo:`torpedoes`,tornado:`tornadoes`,torus:`tori`,traffic:`traffic`,transportation:`transportation`,trapezium:`trapezia`,trauma:`traumas`,triceps:`triceps`,trilby:`trilbies`,trout:`trout`,tuna:`tuna`,ultimatum:`ultimatums`,umbilicus:`umbilici`,upstairs:`upstairs`,uterus:`uteruses`,vacuum:`vacuums`,velum:`vela`,vertebra:`vertebrae`,vertex:`vertices`,veto:`vetoes`,viscus:`viscera`,wealth:`wealth`,welfare:`welfare`,vita:`vitae`,volcano:`volcanoes`,vortex:`vortices`,watercraft:`watercraft`,wharf:`wharves`,whiting:`whiting`,wife:`wives`,wildebeest:`wildebeest`,wildlife:`wildlife`,wolf:`wolves`,woman:`women`}));function yo(e,t,n){if(typeof t==`number`&&(n=t),vo.has(e.toLowerCase())){t=vo.get(e.toLowerCase());let n=e.charAt(0);n===n.toUpperCase()&&(t=n+t.slice(1)),e===e.toUpperCase()&&(t=t.toUpperCase())}else typeof t!=`string`&&(t=(e.replace(/(?:s|x|z|ch|sh)$/i,`$&e`).replace(/([^aeiou])y$/i,`$1ie`)+`s`).replace(/i?e?s$/i,t=>e.slice(-1)===e.slice(-1).toLowerCase()?t.toLowerCase():t.toUpperCase()));return Math.abs(n)===1?e:t}const bo=e=>Number.isFinite(e)?e:0;function xo(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(bo(e*1e3)%1e3),nanoseconds:Math.trunc(bo(e*1e6)%1e3)}}function So(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function Co(e){switch(typeof e){case`number`:if(Number.isFinite(e))return xo(e);break;case`bigint`:return So(e)}throw TypeError(`Expected a finite number or bigint`)}const wo=e=>e===0||e===0n,To=(e,t)=>t===1||t===1n?e:`${e}s`,Eo=24n*60n*60n*1000n;function Do(e,t){let n=typeof e==`bigint`;if(!n&&!Number.isFinite(e))throw TypeError(`Expected a finite number or bigint`);t={...t};let r=e<0?`-`:``;e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[],a=(e,t)=>{let n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)},o=(e,n,r,a)=>{if(!((i.length===0||!t.colonNotation)&&wo(e)&&!(t.colonNotation&&r===`m`))){if(a??=String(e),t.colonNotation){let e=a.includes(`.`)?a.split(`.`)[0].length:a.length,t=i.length>0?2:1;a=`0`.repeat(Math.max(0,t-e))+a}else a+=t.verbose?` `+To(n,e):r;i.push(a)}},s=Co(e),c=BigInt(s.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(s.hours),`hour`,`h`):(t.hideYear?o(c,`day`,`d`):(o(c/365n,`year`,`y`),o(c%365n,`day`,`d`)),o(Number(s.hours),`hour`,`h`)),o(Number(s.minutes),`minute`,`m`),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,`second`,`s`),t.formatSubMilliseconds)o(n,`millisecond`,`ms`),o(r,`microsecond`,`µs`),o(i,`nanosecond`,`ns`);else{let e=n+r/1e3+i/1e6,a=typeof t.millisecondsDecimalDigits==`number`?t.millisecondsDecimalDigits:0,s=a?e.toFixed(a):e>=1?Math.round(e):Math.ceil(e);o(Number.parseFloat(s),`millisecond`,`ms`,s)}}else{let r=a((n?Number(e%Eo):e)/1e3%60,typeof t.secondsDecimalDigits==`number`?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,``);o(Number.parseFloat(i),`second`,`s`,i)}if(i.length===0)return r+`0`+(t.verbose?` milliseconds`:`ms`);let l=t.colonNotation?`:`:` `;return typeof t.unitCount==`number`&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const Oo=typeof window>`u`?typeof process>`u`?`other`:`node`:`browser`,ko=Oo===`browser`?/windows/i.test(navigator.userAgent)?`windows`:/mac/i.test(navigator.userAgent)?`mac`:`other`:Oo===`node`?process.platform===`win32`?`windows`:process.platform===`darwin`?`mac`:`other`:`other`;let Ao=0,jo=0;async function Mo(){if(ko===`mac`&&Oo===`node`){let{openApp:e}=await import(`./open-8AenGr4K.js`);if(jo>=100){console.warn(`Too many Anki App launch attempts this session, ignoring`);return}(Ao===0||Date.now()-Ao>5e3)&&(console.warn(`Attempting to launch Anki app`),Ao=Date.now(),jo++,await e(`/Applications/Anki.app`,{background:!0,newInstance:!1,wait:!1}))}else console.warn(`Automatic Anki App launch is only supported on macOS in Node.js environment`)}const No={autoLaunch:!1,fetchAdapter:fetch.bind(globalThis),host:`http://127.0.0.1`,key:void 0,port:8765,version:6};var Po=class{card={answerCards:this.build(`answerCards`),areDue:this.build(`areDue`),areSuspended:this.build(`areSuspended`),cardsInfo:this.build(`cardsInfo`),cardsModTime:this.build(`cardsModTime`),cardsToNotes:this.build(`cardsToNotes`),findCards:this.build(`findCards`),forgetCards:this.build(`forgetCards`),getEaseFactors:this.build(`getEaseFactors`),getIntervals:this.build(`getIntervals`),relearnCards:this.build(`relearnCards`),setDueDate:this.build(`setDueDate`),setEaseFactors:this.build(`setEaseFactors`),setSpecificValueOfCard:this.build(`setSpecificValueOfCard`),suspend:this.build(`suspend`),suspended:this.build(`suspended`),unsuspend:this.build(`unsuspend`)};deck={changeDeck:this.build(`changeDeck`),cloneDeckConfigId:this.build(`cloneDeckConfigId`),createDeck:this.build(`createDeck`),deckNames:this.build(`deckNames`),deckNamesAndIds:this.build(`deckNamesAndIds`),deleteDecks:this.build(`deleteDecks`),getDeckConfig:this.build(`getDeckConfig`),getDecks:this.build(`getDecks`),getDeckStats:this.build(`getDeckStats`),removeDeckConfigId:this.build(`removeDeckConfigId`),saveDeckConfig:this.build(`saveDeckConfig`),setDeckConfigId:this.build(`setDeckConfigId`)};graphical={guiAddCards:this.build(`guiAddCards`),guiAnswerCard:this.build(`guiAnswerCard`),guiBrowse:this.build(`guiBrowse`),guiCheckDatabase:this.build(`guiCheckDatabase`),guiCurrentCard:this.build(`guiCurrentCard`),guiDeckBrowser:this.build(`guiDeckBrowser`),guiDeckOverview:this.build(`guiDeckOverview`),guiDeckReview:this.build(`guiDeckReview`),guiEditNote:this.build(`guiEditNote`),guiExitAnki:this.build(`guiExitAnki`),guiImportFile:this.build(`guiImportFile`),guiPlayAudio:this.build(`guiPlayAudio`),guiSelectCard:this.build(`guiSelectCard`),guiSelectedNotes:this.build(`guiSelectedNotes`),guiSelectNote:this.build(`guiSelectNote`),guiShowAnswer:this.build(`guiShowAnswer`),guiShowQuestion:this.build(`guiShowQuestion`),guiStartCardTimer:this.build(`guiStartCardTimer`),guiUndo:this.build(`guiUndo`)};media={deleteMediaFile:this.build(`deleteMediaFile`),getMediaDirPath:this.build(`getMediaDirPath`),getMediaFilesNames:this.build(`getMediaFilesNames`),retrieveMediaFile:this.build(`retrieveMediaFile`),storeMediaFile:this.build(`storeMediaFile`)};miscellaneous={apiReflect:this.build(`apiReflect`),exportPackage:this.build(`exportPackage`),getActiveProfile:this.build(`getActiveProfile`),getProfiles:this.build(`getProfiles`),importPackage:this.build(`importPackage`),loadProfile:this.build(`loadProfile`),multi:this.build(`multi`),reloadCollection:this.build(`reloadCollection`),requestPermission:this.build(`requestPermission`),sync:this.build(`sync`),version:this.build(`version`)};model={createModel:this.build(`createModel`),findAndReplaceInModels:this.build(`findAndReplaceInModels`),findModelsById:this.build(`findModelsById`),findModelsByName:this.build(`findModelsByName`),modelFieldAdd:this.build(`modelFieldAdd`),modelFieldDescriptions:this.build(`modelFieldDescriptions`),modelFieldFonts:this.build(`modelFieldFonts`),modelFieldNames:this.build(`modelFieldNames`),modelFieldRemove:this.build(`modelFieldRemove`),modelFieldRename:this.build(`modelFieldRename`),modelFieldReposition:this.build(`modelFieldReposition`),modelFieldSetDescription:this.build(`modelFieldSetDescription`),modelFieldSetFont:this.build(`modelFieldSetFont`),modelFieldSetFontSize:this.build(`modelFieldSetFontSize`),modelFieldsOnTemplates:this.build(`modelFieldsOnTemplates`),modelNames:this.build(`modelNames`),modelNamesAndIds:this.build(`modelNamesAndIds`),modelStyling:this.build(`modelStyling`),modelTemplateAdd:this.build(`modelTemplateAdd`),modelTemplateRemove:this.build(`modelTemplateRemove`),modelTemplateRename:this.build(`modelTemplateRename`),modelTemplateReposition:this.build(`modelTemplateReposition`),modelTemplates:this.build(`modelTemplates`),updateModelStyling:this.build(`updateModelStyling`),updateModelTemplates:this.build(`updateModelTemplates`)};note={addNote:this.build(`addNote`),addNotes:this.build(`addNotes`),addTags:this.build(`addTags`),canAddNotes:this.build(`canAddNotes`),canAddNotesWithErrorDetail:this.build(`canAddNotesWithErrorDetail`),clearUnusedTags:this.build(`clearUnusedTags`),deleteNotes:this.build(`deleteNotes`),findNotes:this.build(`findNotes`),getNoteTags:this.build(`getNoteTags`),getTags:this.build(`getTags`),notesInfo:this.build(`notesInfo`),notesModTime:this.build(`notesInfo`),removeEmptyNotes:this.build(`removeEmptyNotes`),removeTags:this.build(`removeTags`),replaceTags:this.build(`replaceTags`),replaceTagsInAllNotes:this.build(`replaceTagsInAllNotes`),updateNote:this.build(`updateNote`),updateNoteFields:this.build(`updateNoteFields`),updateNoteModel:this.build(`updateNoteModel`),updateNoteTags:this.build(`updateNoteTags`)};statistic={cardReviews:this.build(`cardReviews`),getCollectionStatsHTML:this.build(`getCollectionStatsHTML`),getLatestReviewID:this.build(`getLatestReviewID`),getNumCardsReviewedByDay:this.build(`getNumCardsReviewedByDay`),getNumCardsReviewedToday:this.build(`getNumCardsReviewedToday`),getReviewsOfCards:this.build(`getReviewsOfCards`),insertReviews:this.build(`insertReviews`)};autoLaunch;fetchAdapter;host;key;port;version;constructor(e){if(this.host=e?.host??No.host,this.port=e?.port??No.port,this.version=e?.version??No.version,this.key=e?.key??No.key,this.autoLaunch=e?.autoLaunch??No.autoLaunch,No.fetchAdapter===void 0)throw Error(`A fetch implementation is required`);if(this.fetchAdapter=e?.fetchAdapter??No.fetchAdapter,(ko!==`mac`||Oo!==`node`)&&this.autoLaunch!==!1&&(console.warn(`The autoLaunch option is only supported in a Node environment on macOS`),this.autoLaunch=!1),this.version!==6)throw Error(`YankiConnect currently only supports Anki-Connect API version 6`);this.autoLaunch===`immediately`&&Mo()}async invoke(e,t){let n,r;try{if(n=await this.fetchAdapter(`${this.host}:${this.port}`,{body:JSON.stringify({action:e,...this.key===void 0?{}:{key:this.key},params:t,version:this.version}),headers:{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`},method:`POST`,mode:`cors`}),n===void 0)throw Error(`Anki-Connect response is undefined`);if(n.status!==200)throw Error(`Anki-Connect response status is ${n.status}`);if(r=await n.json(),this.autoLaunch!==!1&&r.error===`collection is not available`)throw Error(r.error)}catch(n){if(this.autoLaunch!==!1)return console.warn(`Can't connect to Anki app, retrying with auto-launch...`),await Mo(),await new Promise(e=>{setTimeout(e,500)}),t===void 0?this.invoke(e):this.invoke(e,t);throw n}if(!(`error`in r))throw Error(`response is missing required error field`);if(!(`result`in r))throw Error(`response is missing required result field`);return r}build(e){return async t=>{let n=await this.invoke(e,t);if(n.error!==null)throw Error(n.error);return n.result}}},Fo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Io(e){return Lo(e)}function Lo(e){return Array.isArray(e)?Ro(e):e instanceof RegExp?e:typeof e==`object`?zo(e):e}function Ro(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Lo(e[n]);return t}function zo(e){let t={};for(let n in e)t[n]=Lo(e[n]);return t}function Bo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Vo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Vo(e.substring(0,e.length-1)):e.substr(~t+1)}var Ho=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Uo=class{static hasCaptures(e){return e===null?!1:(Ho.lastIndex=0,Ho.test(e))}static replaceCaptures(e,t,n){return e.replace(Ho,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Wo(e,t){return e<t?-1:e>t?1:0}function Go(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Wo(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function Ko(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function qo(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var Jo=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Yo=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(es(e),t)}static createFromParsedTheme(e,t){return rs(e,t)}_cachedMatchRoot=new Jo(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>Zo(e.parent,t.parentScopes));return n?new $o(n.fontStyle,n.foreground,n.background):null}},Xo=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function Zo(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!Qo(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Qo(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var $o=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function es(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&Ko(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&Ko(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new ts(l,u,e,o,s,c)}}return n}var ts=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},ns=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(ns||{});function rs(e,t){e.sort((e,t)=>{let n=Wo(e.scope,t.scope);return n!==0||(n=Go(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new is(t),o=new $o(n,a.getId(r),a.getId(i)),s=new ss(new os(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Yo(a,o,s)}var is=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},as=Object.freeze([]),os=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||as,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},ss=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),os.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(Go(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new os(e,t,n,r,i))}},cs=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=e.containsBalancedBrackets(t)?1:0,d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=us(r)),i!==null&&(u=i?1:0),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function ls(e){return e}function us(e){return e}function ds(e,t){let n=[],r=ps(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(fs(i)){let e=[];do e.push(i),i=r.next();while(fs(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function fs(e){return!!e&&!!e.match(/[\w\.:]+/)}function ps(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function ms(e){typeof e.dispose==`function`&&e.dispose()}var hs=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},gs=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},_s=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},vs=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new hs(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new _s;for(let n of e)ys(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof hs){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ys(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof hs?xs({baseGrammar:a,selfGrammar:i},r):bs(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new hs(e))}function bs(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Ss([r],t,n)}}function xs(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ss(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ss(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ss(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Bo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ss(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Os(i);switch(a.kind){case 0:xs({...t,selfGrammar:t.baseGrammar},n);break;case 1:xs(t,n);break;case 2:bs(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?bs(a.ruleName,i,n):xs(i,n)}else a.kind===4?n.add(new gs(a.scopeName,a.ruleName)):n.add(new hs(a.scopeName));break}}}var Cs=class{kind=0},ws=class{kind=1},Ts=class{constructor(e){this.ruleName=e}kind=2},Es=class{constructor(e){this.scopeName=e}kind=3},Ds=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Os(e){if(e===`$base`)return new Cs;if(e===`$self`)return new ws;let t=e.indexOf(`#`);return t===-1?new Es(e):t===0?new Ts(e.substring(1)):new Ds(e.substring(0,t),e.substring(t+1))}var ks=/\\(\d+)/,As=/\\(\d+)/g,js=-1,Ms=-2;function Ns(e){return e}function Ps(e){return e}var Fs=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Uo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Uo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Vo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Uo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Uo.replaceCaptures(this._contentName,e,t)}},Is=class extends Fs{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Ls=class extends Fs{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Hs(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Us,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Rs=class extends Fs{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Us,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zs=class extends Fs{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Hs(i,this.id),this.beginCaptures=a,this._end=new Hs(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Us;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Bs=class extends Fs{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Hs(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Hs(o,Ms),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Us;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Us,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Vs=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Is(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Ls(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Bo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Rs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Bs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new zs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Os(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Rs||e instanceof zs||e instanceof Bs)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Hs=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=ks.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return As.lastIndex=0,this.source.replace(As,(e,t)=>qo(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Us=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){return this._cached||=new Ws(e,this._items.map(e=>e.source),this._items.map(e=>e.ruleId)),this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Ws(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Ws=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
103
103
|
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Gs=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Ks=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Gs(e,8),this._embeddedLanguagesMatcher=new qs(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Gs(0,0);_getBasicScopeAttributes=new Jo(e=>new Gs(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},qs=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>qo(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&process.env.VSCODE_TEXTMATE_DEBUG;var Js=!1,Ys=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Xs(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=Zs(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new Ys(i,!0);f()}return new Ys(i,!1);function f(){let o=Qs(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===js){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),ic(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof zs){let r=o;ic(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof Bs){let r=o;ic(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(ic(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function Zs(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof Bs&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=nc(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Ms){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),ic(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function Qs(e,t,n,r,i,a){let o=$s(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=ec(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function $s(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=tc(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function ec(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=tc(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function tc(e,t,n,r,i){return Js?{ruleScanner:e.compile(t,n),findOptions:rc(r,i)}:{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function nc(e,t,n,r,i){return Js?{ruleScanner:e.compileWhile(t,n),findOptions:rc(r,i)}:{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function rc(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function ic(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));Xs(e,p,n&&d.start===0,d.start,f,i,!1,0),ms(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new ac(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var ac=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function oc(e,t,n,r,i,a,o,s){return new uc(e,t,n,r,i,a,o,s)}function sc(e,t,n,r,i){let a=ds(t,cc),o=Vs.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function cc(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(lc(t[r],e))return n=r+1,!0;return!1})}function lc(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var uc=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new Ks(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=dc(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=ds(e,cc);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)sc(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&sc(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Ns(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Ps(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=dc(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Vs.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===pc.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=cs.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?fc.createRootAndLookUpScopeName(a,r,this):fc.createRoot(`unknown`,r),t=new pc(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
104
104
|
`;let a=this.createOnigString(e),o=a.content.length,s=new hc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Xs(this,a,i,0,t,s,!0,r);return ms(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function dc(e,t){return e=Io(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var fc=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=Xo.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new Xo(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new Xo(null,t),o=r.themeProvider.themeMatch(a);return new e(null,a,e.mergeAttributes(n,i,o))}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),cs.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a);return new e(t,a,e.mergeAttributes(t.tokenAttributes,i,o))}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},pc=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?fc.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Ps(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=fc.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Ns(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,fc.fromExtension(r,n.contentNameScopesList))}},mc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):ds(e,cc).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>ds(e,cc).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},hc=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=cs.set(n,0,ls(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=cs.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},gc=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,oc(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},_c=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new gc(Yo.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Yo.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new mc(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new vs(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},vc=pc.NULL;const yc=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`];var bc=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};bc.prototype.normal={},bc.prototype.property={},bc.prototype.space=void 0;function xc(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new bc(n,r,t)}function Sc(e){return e.toLowerCase()}var Cc=class{constructor(e,t){this.attribute=t,this.property=e}};Cc.prototype.attribute=``,Cc.prototype.booleanish=!1,Cc.prototype.boolean=!1,Cc.prototype.commaOrSpaceSeparated=!1,Cc.prototype.commaSeparated=!1,Cc.prototype.defined=!1,Cc.prototype.mustUseProperty=!1,Cc.prototype.number=!1,Cc.prototype.overloadedBoolean=!1,Cc.prototype.property=``,Cc.prototype.spaceSeparated=!1,Cc.prototype.space=void 0;var wc=ue({boolean:()=>V,booleanish:()=>Ec,commaOrSpaceSeparated:()=>Ac,commaSeparated:()=>kc,number:()=>H,overloadedBoolean:()=>Dc,spaceSeparated:()=>Oc});let Tc=0;const V=jc(),Ec=jc(),Dc=jc(),H=jc(),Oc=jc(),kc=jc(),Ac=jc();function jc(){return 2**++Tc}const Mc=Object.keys(wc);var Nc=class extends Cc{constructor(e,t,n,r){let i=-1;if(super(e,t),Pc(this,`space`,r),typeof n==`number`)for(;++i<Mc.length;){let e=Mc[i];Pc(this,Mc[i],(n&wc[e])===wc[e])}}};Nc.prototype.defined=!0;function Pc(e,t,n){n&&(e[t]=n)}function Fc(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Nc(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Sc(r)]=r,n[Sc(a.attribute)]=r}return new bc(t,n,e.space)}const Ic=Fc({properties:{ariaActiveDescendant:null,ariaAtomic:Ec,ariaAutoComplete:null,ariaBusy:Ec,ariaChecked:Ec,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:Oc,ariaCurrent:null,ariaDescribedBy:Oc,ariaDetails:null,ariaDisabled:Ec,ariaDropEffect:Oc,ariaErrorMessage:null,ariaExpanded:Ec,ariaFlowTo:Oc,ariaGrabbed:Ec,ariaHasPopup:null,ariaHidden:Ec,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Oc,ariaLevel:H,ariaLive:null,ariaModal:Ec,ariaMultiLine:Ec,ariaMultiSelectable:Ec,ariaOrientation:null,ariaOwns:Oc,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:Ec,ariaReadOnly:Ec,ariaRelevant:null,ariaRequired:Ec,ariaRoleDescription:Oc,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:Ec,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Lc(e,t){return t in e?e[t]:t}function Rc(e,t){return Lc(e,t.toLowerCase())}const zc=Fc({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:kc,acceptCharset:Oc,accessKey:Oc,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:Oc,autoFocus:V,autoPlay:V,blocking:Oc,capture:null,charSet:null,checked:V,cite:null,className:Oc,cols:H,colSpan:null,content:null,contentEditable:Ec,controls:V,controlsList:Oc,coords:H|kc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:Dc,draggable:Ec,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:Oc,height:H,hidden:Dc,high:H,href:null,hrefLang:null,htmlFor:Oc,httpEquiv:Oc,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:Oc,itemRef:Oc,itemScope:V,itemType:Oc,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:H,pattern:null,ping:Oc,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:Oc,required:V,reversed:V,rows:H,rowSpan:H,sandbox:Oc,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:Ec,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:Ec,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Oc,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:Ec,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:H,security:null,unselectable:null},space:`html`,transform:Rc}),Bc=Fc({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Ac,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:Oc,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:kc,g2:kc,glyphName:kc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:Ac,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:H,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Oc,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ac,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ac,rev:Ac,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ac,requiredFeatures:Ac,requiredFonts:Ac,requiredFormats:Ac,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:Ac,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ac,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ac,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Lc}),Vc=Fc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Hc=Fc({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Rc}),Uc=Fc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Wc=/[A-Z]/g,Gc=/-[a-z]/g,Kc=/^data[-\w.:]+$/i;function qc(e,t){let n=Sc(t),r=t,i=Cc;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Kc.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Gc,Yc);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Gc.test(e)){let n=e.replace(Wc,Jc);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Nc}return new i(r,t)}function Jc(e){return`-`+e.toLowerCase()}function Yc(e){return e.charAt(1).toUpperCase()}const Xc=xc([Ic,zc,Vc,Hc,Uc],`html`),Zc=xc([Ic,Bc,Vc,Hc,Uc],`svg`),Qc={}.hasOwnProperty;function $c(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&Qc.call(t,e)){let n=String(t[e]);i=Qc.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const el=/["&'<>`]/g,tl=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,nl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,rl=/[|\\{}()[\]^$+*?.]/g,il=new WeakMap;function al(e,t){if(e=e.replace(t.subset?ol(t.subset):el,r),t.subset||t.escapeOnly)return e;return e.replace(tl,n).replace(nl,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function ol(e){let t=il.get(e);return t||(t=sl(e),il.set(e,t)),t}function sl(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(rl,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}const cl=/[\dA-Fa-f]/;function ll(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!cl.test(String.fromCharCode(t))?r:r+`;`}const ul=/\d/;function dl(e,t,n){let r=`&#`+String(e);return n&&t&&!ul.test(String.fromCharCode(t))?r:r+`;`}const fl=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),pl={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},ml=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],hl={}.hasOwnProperty,gl={};let _l;for(_l in pl)hl.call(pl,_l)&&(gl[pl[_l]]=_l);const vl=/[^\dA-Za-z]/;function yl(e,t,n,r){let i=String.fromCharCode(e);if(hl.call(gl,i)){let e=gl[i],a=`&`+e;return n&&fl.includes(e)&&!ml.includes(e)&&(!r||t&&t!==61&&vl.test(String.fromCharCode(t)))?a:a+`;`}return``}function bl(e,t,n){let r=ll(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=yl(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=dl(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function xl(e,t){return al(e,Object.assign({format:bl},t))}const Sl=/^>|^->|<!--|-->|--!>|<!-$/g,Cl=[`>`],wl=[`<`,`>`];function Tl(e,t,n,r){return r.settings.bogusComments?`<?`+xl(e.value,Object.assign({},r.settings.characterReferences,{subset:Cl}))+`>`:`<!--`+e.value.replace(Sl,i)+`-->`;function i(e){return xl(e,Object.assign({},r.settings.characterReferences,{subset:wl}))}}function El(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function Dl(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Ol(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function kl(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function Al(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function jl(e){return e.join(` `).trim()}const Ml=/[ \t\n\f\r]/g;function Nl(e){return typeof e==`object`?e.type===`text`?Pl(e.value):!1:Pl(e)}function Pl(e){return e.replace(Ml,``)===``}const Fl=Rl(1),Il=Rl(-1),Ll=[];function Rl(e){return t;function t(t,n,r){let i=t?t.children:Ll,a=(n||0)+e,o=i[a];if(!r)for(;o&&Nl(o);)a+=e,o=i[a];return o}}const zl={}.hasOwnProperty;function Bl(e){return t;function t(t,n,r){return zl.call(e,t.tagName)&&e[t.tagName](t,n,r)}}const Vl=Bl({body:Wl,caption:Hl,colgroup:Hl,dd:Jl,dt:ql,head:Hl,html:Ul,li:Kl,optgroup:Xl,option:Zl,p:Gl,rp:Yl,rt:Yl,tbody:$l,td:nu,tfoot:eu,th:nu,thead:Ql,tr:tu});function Hl(e,t,n){let r=Fl(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Nl(r.value.charAt(0)))}function Ul(e,t,n){let r=Fl(n,t);return!r||r.type!==`comment`}function Wl(e,t,n){let r=Fl(n,t);return!r||r.type!==`comment`}function Gl(e,t,n){let r=Fl(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`))}function Kl(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&r.tagName===`li`}function ql(e,t,n){let r=Fl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function Jl(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Yl(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Xl(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Zl(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Ql(e,t,n){let r=Fl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function $l(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function eu(e,t,n){return!Fl(n,t)}function tu(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function nu(e,t,n){let r=Fl(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}const ru=Bl({body:ou,colgroup:su,head:au,html:iu,tbody:cu});function iu(e){let t=Fl(e,-1);return!t||t.type!==`comment`}function au(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function ou(e){let t=Fl(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Nl(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function su(e,t,n){let r=Il(n,t),i=Fl(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Vl(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function cu(e,t,n){let r=Il(n,t),i=Fl(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Vl(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}const lu={name:[[`
|
|
105
105
|
\f\r &/=>`.split(``),`
|
|
@@ -186,7 +186,7 @@ var SS=M(((e,t)=>{t.exports=typeof Object.defineProperty==`function`?Object.defi
|
|
|
186
186
|
|
|
187
187
|
<hr>
|
|
188
188
|
|
|
189
|
-
{{Extra}}{{/Extra}}`,Front:`{{Back}}`,YankiNamespace:`{{YankiNamespace}}`}],inOrderFields:[`Front`,`Back`,`Extra`,`YankiNamespace`],modelName:`Yanki - Basic (and reversed card with extra)`}],gw=hw.map(e=>e.modelName),_w=[`Yanki - Basic (and reversed card)`];async function vw(e,t,n=!1){if(n)return;let r=t.map(e=>e.noteId).filter(e=>e!==void 0);await e.note.deleteNotes({notes:r})}async function yw(e,t,n,r){if(t.noteId!==void 0)throw Error(`Note already has an ID`);if(n)return 0;let i=await e.note.addNote({note:{...t,options:{allowDuplicate:!0}}}).catch(async i=>{if(i instanceof Error){if(i.message===`model was not found: ${t.modelName}`){let i=hw.find(e=>e.modelName===t.modelName);if(i===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(i),yw(e,t,n,r)}if(i.message===`deck was not found: ${t.deckName}`){if(t.deckName===``)throw Error(`Deck name is empty`);return await e.deck.createDeck({deck:t.deckName}),yw(e,t,n,r)}throw i}else throw TypeError(`Unknown error`)});if(i===null)throw Error(`Note creation failed`);return await Ow(e,t,n,r),i}async function bw(e,t,n,r,i){if(t.noteId===void 0)throw Error(`Local note ID is undefined`);if(n.cards===void 0)throw Error(`Remote note cards are undefined`);let a=!1;if(t.deckName!==n.deckName){if(t.deckName===``)throw Error(`Local deck name is empty`);r||await e.deck.changeDeck({cards:n.cards,deck:t.deckName}),a=!0}return(!Cw(t.tags??[],n.tags??[])||!xw(t.fields,n.fields)||t.modelName!==n.modelName)&&(r||(await e.note.updateNoteModel({note:{...t,id:t.noteId,tags:t.tags??[]}}).catch(async a=>{if(a instanceof Error){if(a.message===`Model '${t.modelName}' not found`){let a=hw.find(e=>e.modelName===t.modelName);if(a===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(a),bw(e,t,n,r,i)}throw a}else throw TypeError(`Unknown error`)}),await Ow(e,t,r,i)),a=!0),a}function xw(e,t){for(let n of[`Front`,`Back`,`Extra`])if(n in e&&n in t){if(e[n].normalize(`NFC`)!==t[n].normalize(`NFC`))return!1}else if(n in e||n in t)return!1;return!0}function Sw(e,t,n=!0){return!(n&&e.noteId!==t.noteId||e.deckName!==t.deckName||e.modelName!==t.modelName||!xw(e.fields,t.fields)||!Cw(e.tags??[],t.tags??[]))}function Cw(e,t){let n=new Set(e.map(e=>e.normalize(`NFC`).toLowerCase())),r=new Set(t.map(e=>e.normalize(`NFC`).toLowerCase()));return new Set([...n,...r]).size===r.size}async function ww(e,t=Gx.namespace){return await Tw(e,await e.note.findNotes({query:`"YankiNamespace:${t}"`}))}async function Tw(e,t){let n=await e.note.notesInfo({notes:t}),r=[];if(n.every(e=>e.noteId===void 0))return Array.from({length:n.length}).fill(void 0);let i=n.flatMap(e=>e.cards??[]),a=await e.deck.getDecks({cards:i}),o=new Map;for(let[e,t]of Object.entries(a))for(let n of t)o.set(n,e);let s=new Map,c=new Map;for(let t of n){if(t.noteId===void 0){r.push(void 0);continue}if(![..._w,...gw].includes(t.modelName))throw Error(`Unknown model name ${t.modelName} for note ${t.noteId}`);let n=[...new Set(t.cards.map(e=>o.get(e)))];n.length;let i=n.at(0);if(i===void 0)throw Error(`No deck found for cards in note ${t.noteId}`);if(!s.has(i)){let t=!!(await e.deck.getDeckConfig({deck:i})).dyn;if(s.set(i,t),t){let t=await e.deck.deckNames();for(let n of t)if(!s.has(n)){let t=await e.deck.getDeckConfig({deck:n});s.set(n,!!t.dyn)}let n=[...s.entries()].filter(([e,t])=>!t&&e!==`Default`).map(([e])=>e).sort((e,t)=>t.split(`::`).length-e.split(`::`).length);n.push(`Default`);for(let e of n)c.set(e,void 0)}}if(s.get(i)){let n=c.keys(),r=!1;for(let a of n)if(c.get(a)===void 0&&c.set(a,await e.note.findNotes({query:`"deck:${a}"`})),c.get(a)?.includes(t.noteId)){i=a,r=!0;break}if(!r)throw Error(`No matching non-filtered deck found for note ${t.noteId}`)}r.push({cards:t.cards,deckName:i,fields:{Back:t.fields.Back.value??``,...t.fields.Extra!==void 0&&{Extra:t.fields.Extra.value??``},Front:t.fields.Front.value??``,YankiNamespace:t.fields.YankiNamespace.value??``},modelName:t.modelName,noteId:t.noteId,tags:t.tags})}return r}async function Ew(e,t,n,r){let i=[...new Set(t.map(e=>e.deckName))].filter(Boolean),a=[...new Set(n.map(e=>e.deckName))].filter(Boolean).filter(e=>!i.includes(e)),o=[];for(let e of a){let t=e.split(`::`);if(t.length!==1)for(;t.length>1;){t.pop();let e=t.join(`::`);if(i.some(t=>
|
|
189
|
+
{{Extra}}{{/Extra}}`,Front:`{{Back}}`,YankiNamespace:`{{YankiNamespace}}`}],inOrderFields:[`Front`,`Back`,`Extra`,`YankiNamespace`],modelName:`Yanki - Basic (and reversed card with extra)`}],gw=hw.map(e=>e.modelName),_w=[`Yanki - Basic (and reversed card)`];async function vw(e,t,n=!1){if(n)return;let r=t.map(e=>e.noteId).filter(e=>e!==void 0);await e.note.deleteNotes({notes:r})}async function yw(e,t,n,r){if(t.noteId!==void 0)throw Error(`Note already has an ID`);if(n)return 0;let i=await e.note.addNote({note:{...t,options:{allowDuplicate:!0}}}).catch(async i=>{if(i instanceof Error){if(i.message===`model was not found: ${t.modelName}`){let i=hw.find(e=>e.modelName===t.modelName);if(i===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(i),yw(e,t,n,r)}if(i.message===`deck was not found: ${t.deckName}`){if(t.deckName===``)throw Error(`Deck name is empty`);return await e.deck.createDeck({deck:t.deckName}),yw(e,t,n,r)}throw i}else throw TypeError(`Unknown error`)});if(i===null)throw Error(`Note creation failed`);return await Ow(e,t,n,r),i}async function bw(e,t,n,r,i){if(t.noteId===void 0)throw Error(`Local note ID is undefined`);if(n.cards===void 0)throw Error(`Remote note cards are undefined`);let a=!1;if(t.deckName!==n.deckName){if(t.deckName===``)throw Error(`Local deck name is empty`);r||await e.deck.changeDeck({cards:n.cards,deck:t.deckName}),a=!0}return(!Cw(t.tags??[],n.tags??[])||!xw(t.fields,n.fields)||t.modelName!==n.modelName)&&(r||(await e.note.updateNoteModel({note:{...t,id:t.noteId,tags:t.tags??[]}}).catch(async a=>{if(a instanceof Error){if(a.message===`Model '${t.modelName}' not found`){let a=hw.find(e=>e.modelName===t.modelName);if(a===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(a),bw(e,t,n,r,i)}throw a}else throw TypeError(`Unknown error`)}),await Ow(e,t,r,i)),a=!0),a}function xw(e,t){for(let n of[`Front`,`Back`,`Extra`])if(n in e&&n in t){if(e[n].normalize(`NFC`)!==t[n].normalize(`NFC`))return!1}else if(n in e||n in t)return!1;return!0}function Sw(e,t,n=!0){return!(n&&e.noteId!==t.noteId||e.deckName!==t.deckName||e.modelName!==t.modelName||!xw(e.fields,t.fields)||!Cw(e.tags??[],t.tags??[]))}function Cw(e,t){let n=new Set(e.map(e=>e.normalize(`NFC`).toLowerCase())),r=new Set(t.map(e=>e.normalize(`NFC`).toLowerCase()));return new Set([...n,...r]).size===r.size}async function ww(e,t=Gx.namespace){return await Tw(e,await e.note.findNotes({query:`"YankiNamespace:${t}"`}))}async function Tw(e,t){let n=await e.note.notesInfo({notes:t}),r=[];if(n.every(e=>e.noteId===void 0))return Array.from({length:n.length}).fill(void 0);let i=n.flatMap(e=>e.cards??[]),a=await e.deck.getDecks({cards:i}),o=new Map;for(let[e,t]of Object.entries(a))for(let n of t)o.set(n,e);let s=new Map,c=new Map;for(let t of n){if(t.noteId===void 0){r.push(void 0);continue}if(![..._w,...gw].includes(t.modelName))throw Error(`Unknown model name ${t.modelName} for note ${t.noteId}`);let n=[...new Set(t.cards.map(e=>o.get(e)))];n.length;let i=n.at(0);if(i===void 0)throw Error(`No deck found for cards in note ${t.noteId}`);if(!s.has(i)){let t=!!(await e.deck.getDeckConfig({deck:i})).dyn;if(s.set(i,t),t){let t=await e.deck.deckNames();for(let n of t)if(!s.has(n)){let t=await e.deck.getDeckConfig({deck:n});s.set(n,!!t.dyn)}let n=[...s.entries()].filter(([e,t])=>!t&&e!==`Default`).map(([e])=>e).sort((e,t)=>t.split(`::`).length-e.split(`::`).length);n.push(`Default`);for(let e of n)c.set(e,void 0)}}if(s.get(i)){let n=c.keys(),r=!1;for(let a of n)if(c.get(a)===void 0&&c.set(a,await e.note.findNotes({query:`"deck:${a}"`})),c.get(a)?.includes(t.noteId)){i=a,r=!0;break}if(!r)throw Error(`No matching non-filtered deck found for note ${t.noteId}`)}r.push({cards:t.cards,deckName:i,fields:{Back:t.fields.Back.value??``,...t.fields.Extra!==void 0&&{Extra:t.fields.Extra.value??``},Front:t.fields.Front.value??``,YankiNamespace:t.fields.YankiNamespace.value??``},modelName:t.modelName,noteId:t.noteId,tags:t.tags})}return r}async function Ew(e,t,n,r){let i=[...new Set(t.map(e=>e.deckName))].filter(Boolean),a=[...new Set(n.map(e=>e.deckName))].filter(Boolean).filter(e=>!i.includes(e)),o=[];for(let e of a){let t=e.split(`::`);if(t.length!==1)for(;t.length>1;){t.pop();let e=t.join(`::`);if(i.some(t=>t.startsWith(`${e}::`)))break;o.push(e)}}let s=[...new Set([...a,...o])].sort(),c=[];for(let i of s){let a=await e.deck.getDeckStats({decks:[i]}),o=Object.values(a);if(o.length>1){console.warn(`Multiple decks found for deck name: ${i}`);continue}let s=o.at(0);if(s===void 0){console.warn(`Deck not found for deck name: ${i}`);continue}let l=Math.max(s.total_in_deck,s.new_count+s.learn_count+s.review_count);if(r){let e=n.filter(e=>e.deckName===i).length,r=t.filter(e=>e.deckName===i).length;l===e&&r===0&&!c.includes(i)&&c.push(i)}else l===0&&!c.includes(i)&&c.push(i)}return r||await e.deck.deleteDecks({cardsToo:!0,decks:c}),c}async function Dw(e,t,n,r){let i;try{let{css:n}=await e.model.modelStyling({modelName:t});i=n}catch(i){if(i instanceof Error){if(i.message===`model was not found: ${t}`){let i=hw.find(e=>e.modelName===t);if(i===void 0)throw Error(`Model not found: ${t}`);return r?!1:(await e.model.createModel(i),Dw(e,i.modelName,n,r))}throw i}else throw TypeError(`Unknown error`)}return i!==void 0&&i===n?!1:(r||await e.model.updateModelStyling({model:{css:n,name:t}}),!0)}async function Ow(e,t,n,r){let i=rw(`${t.fields.Front}\n${t.fields.Back}\n${t.fields.Extra}`),a=[];for(let{filename:t,originalSrc:o}of i)if((await e.media.getMediaFilesNames({pattern:t})).length===0){if(!n)try{let n=await e.media.storeMediaFile(DC(o)?{deleteExisting:!0,filename:t,url:o}:{data:mw(await r.readFileBuffer(o)),deleteExisting:!0,filename:t});t!==n&&console.warn(`Anki media filename mismatch: Expected: "${t}" -> Received: "${n}"`)}catch(e){console.warn(`Anki could not store media file: "${t}"\n${String(e)}`)}a.push({filename:t,originalSrc:o})}return a}async function kw(e,t,n,r){if(r)return[];let i=bS(n),a=[];for(let e of t){let t=rw(`${e.fields.Front}\n${e.fields.Back}\n${e.fields.Extra}`);for(let{filename:e}of t)a.push(e)}let o=await e.media.getMediaFilesNames({pattern:`${i}-*`}),s=[];for(let t of o)a.includes(t)||(await e.media.deleteMediaFile({filename:t}),s.push(t));return s}async function Aw(e){try{let{permission:t}=await e.miscellaneous.requestPermission();if(t===`denied`)throw Error(`Permission denied, please add this source to the "webCorsOriginList" in the Anki-Connect add-on configuration options.`);return`granted`}catch(e){if(e instanceof Error&&(e.message===`fetch failed`||e.message===`net::ERR_CONNECTION_REFUSED`))return`ankiUnreachable`;throw e}}async function jw(e){try{await e.miscellaneous.sync()}catch{console.warn(`Could not sync to AnkiWeb.`)}}const Mw={...Gx};async function Nw(e){let t=performance.now(),{ankiConnectOptions:n,ankiWeb:r,dryRun:i,namespace:a}=co(Mw,e??{}),o=_S(a,!0),s=new Po(n);if(await Aw(s)===`ankiUnreachable`)throw Error(`Anki is unreachable. Is Anki running?`);let c=await ww(s,o);await vw(s,c,i);let l=await Ew(s,[],c,i),u=await kw(s,[],o,i);return c.length>0||l.length,!i&&r&&await jw(s),{ankiWeb:r,deletedDecks:l,deletedMedia:u,deletedNotes:c,dryRun:i,duration:performance.now()-t,namespace:o}}function Pw(e,t=!1){let n=e.deletedDecks.length,r=e.deletedNotes.length,i=e.deletedMedia.length;if(n===0&&r===0&&i===0)return`Nothing to delete`;let a=[`${e.dryRun?`Will`:`Successfully`} deleted ${r} ${yo(`note`,r)}, ${n} ${yo(`deck`,n)}, and ${i} media ${yo(`asset`,i)} from Anki${e.dryRun?``:` in ${Do(e.duration)}`}.`];if(t){if(r>0){a.push(``,e.dryRun?`Notes to delete:`:`Deleted notes:`);for(let t of e.deletedNotes){let e=Tx(nw(t.fields.Front),50);a.push(` Note ID ${t.noteId} ${e}`)}}if(n>0){a.push(``,e.dryRun?`Decks to delete:`:`Deleted decks:`);for(let t of e.deletedDecks)a.push(` ${t}`)}if(i>0){a.push(``,e.dryRun?`Media assets to delete:`:`Deleted media assets:`);for(let t of e.deletedMedia)a.push(` ${t}`)}}return a.join(`
|
|
190
190
|
`)}const Fw={...Gx};async function Iw(e){let t=performance.now(),{ankiConnectOptions:n,namespace:r}=co(Fw,e??{}),i=_S(r,!0),a=new Po(n);if(await Aw(a)===`ankiUnreachable`)throw Error(`Anki is unreachable. Is Anki running?`);let o=await ww(a,i);return{duration:performance.now()-t,namespace:i,notes:o}}function Lw(e){if(e.notes.length===0)return`No notes found.`;let t=[];for(let n of e.notes){let e=Tx(nw(n.fields.Front),50);t.push(`Note ID ${n.noteId} ${e}`)}return t.join(`
|
|
191
191
|
`)}const Rw={css:jx,...Gx};({...Gx});async function zw(e){let t=performance.now(),{ankiConnectOptions:n,ankiWeb:r,css:i,dryRun:a}=co(Rw,e??{}),o=new Po(n);if(await Aw(o)===`ankiUnreachable`)throw Error(`Anki is unreachable. Is Anki running?`);let s=[];for(let e of gw){let t=await Dw(o,e,i,a);s.push({action:t?`updated`:`unchanged`,name:e})}return s.some(e=>e.action!==`unchanged`),!a&&r&&await jw(o),{ankiWeb:r,dryRun:a,duration:performance.now()-t,models:s}}function Bw(e,t=!1){let n=[],r=e.models.filter(e=>e.action===`unchanged`),i=e.models.filter(e=>e.action===`updated`);if(n.push(`${e.dryRun?`Will`:`Successfully`} update ${i.length} ${yo(`model`,i.length)} and left ${r.length} ${yo(`model`,r.length)} unchanged${e.dryRun?``:` in ${Do(e.duration)}`}.`),t){if(i.length>0){n.push(``,e.dryRun?`Models to update:`:`Updated models:`);for(let e of i)n.push(` ${e.name}`)}if(r.length>0){n.push(``,e.dryRun?`Models unchanged:`:`Unchanged models:`);for(let e of r)n.push(` ${e.name}`)}}return n.join(`
|
|
192
192
|
`)}var Vw=M((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),Hw=M((e=>{var t=Vw();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),Uw=M((e=>{var t=Vw(),n=Hw();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
package/dist/lib/index.js
CHANGED
|
@@ -1318,7 +1318,7 @@ async function deleteOrphanedDecks(client, activeNotes, originalNotes, dryRun) {
|
|
|
1318
1318
|
while (parts.length > 1) {
|
|
1319
1319
|
parts.pop();
|
|
1320
1320
|
const parentDeckName = parts.join("::");
|
|
1321
|
-
if (activeNoteDeckNames.some((deckName) =>
|
|
1321
|
+
if (activeNoteDeckNames.some((deckName) => deckName.startsWith(`${parentDeckName}::`))) break;
|
|
1322
1322
|
orphanedParentDeckNames.push(parentDeckName);
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
package/dist/standalone/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var _g=s(((e,t)=>{t.exports=typeof Object.defineProperty==`function`?Object.defi
|
|
|
85
85
|
|
|
86
86
|
<hr>
|
|
87
87
|
|
|
88
|
-
{{Extra}}{{/Extra}}`,Front:`{{Back}}`,YankiNamespace:`{{YankiNamespace}}`}],inOrderFields:[`Front`,`Back`,`Extra`,`YankiNamespace`],modelName:`Yanki - Basic (and reversed card with extra)`}],fv=dv.map(e=>e.modelName),pv=[`Yanki - Basic (and reversed card)`];async function mv(e,t,n=!1){if(n)return;let r=t.map(e=>e.noteId).filter(e=>e!==void 0);await e.note.deleteNotes({notes:r})}async function hv(e,t,n,r){if(t.noteId!==void 0)throw Error(`Note already has an ID`);if(n)return 0;let i=await e.note.addNote({note:{...t,options:{allowDuplicate:!0}}}).catch(async i=>{if(i instanceof Error){if(i.message===`model was not found: ${t.modelName}`){let i=dv.find(e=>e.modelName===t.modelName);if(i===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(i),hv(e,t,n,r)}if(i.message===`deck was not found: ${t.deckName}`){if(t.deckName===``)throw Error(`Deck name is empty`);return await e.deck.createDeck({deck:t.deckName}),hv(e,t,n,r)}throw i}else throw TypeError(`Unknown error`)});if(i===null)throw Error(`Note creation failed`);return await Tv(e,t,n,r),i}async function gv(e,t,n,r,i){if(t.noteId===void 0)throw Error(`Local note ID is undefined`);if(n.cards===void 0)throw Error(`Remote note cards are undefined`);let a=!1;if(t.deckName!==n.deckName){if(t.deckName===``)throw Error(`Local deck name is empty`);r||await e.deck.changeDeck({cards:n.cards,deck:t.deckName}),a=!0}return(!yv(t.tags??[],n.tags??[])||!_v(t.fields,n.fields)||t.modelName!==n.modelName)&&(r||(await e.note.updateNoteModel({note:{...t,id:t.noteId,tags:t.tags??[]}}).catch(async a=>{if(a instanceof Error){if(a.message===`Model '${t.modelName}' not found`){let a=dv.find(e=>e.modelName===t.modelName);if(a===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(a),gv(e,t,n,r,i)}throw a}else throw TypeError(`Unknown error`)}),await Tv(e,t,r,i)),a=!0),a}function _v(e,t){for(let n of[`Front`,`Back`,`Extra`])if(n in e&&n in t){if(e[n].normalize(`NFC`)!==t[n].normalize(`NFC`))return!1}else if(n in e||n in t)return!1;return!0}function vv(e,t,n=!0){return!(n&&e.noteId!==t.noteId||e.deckName!==t.deckName||e.modelName!==t.modelName||!_v(e.fields,t.fields)||!yv(e.tags??[],t.tags??[]))}function yv(e,t){let n=new Set(e.map(e=>e.normalize(`NFC`).toLowerCase())),r=new Set(t.map(e=>e.normalize(`NFC`).toLowerCase()));return new Set([...n,...r]).size===r.size}async function bv(e,t=Vh.namespace){return await xv(e,await e.note.findNotes({query:`"YankiNamespace:${t}"`}))}async function xv(e,t){let n=await e.note.notesInfo({notes:t}),r=[];if(n.every(e=>e.noteId===void 0))return Array.from({length:n.length}).fill(void 0);let i=n.flatMap(e=>e.cards??[]),a=await e.deck.getDecks({cards:i}),o=new Map;for(let[e,t]of Object.entries(a))for(let n of t)o.set(n,e);let s=new Map,c=new Map;for(let t of n){if(t.noteId===void 0){r.push(void 0);continue}if(![...pv,...fv].includes(t.modelName))throw Error(`Unknown model name ${t.modelName} for note ${t.noteId}`);let n=[...new Set(t.cards.map(e=>o.get(e)))];n.length;let i=n.at(0);if(i===void 0)throw Error(`No deck found for cards in note ${t.noteId}`);if(!s.has(i)){let t=!!(await e.deck.getDeckConfig({deck:i})).dyn;if(s.set(i,t),t){let t=await e.deck.deckNames();for(let n of t)if(!s.has(n)){let t=await e.deck.getDeckConfig({deck:n});s.set(n,!!t.dyn)}let n=[...s.entries()].filter(([e,t])=>!t&&e!==`Default`).map(([e])=>e).sort((e,t)=>t.split(`::`).length-e.split(`::`).length);n.push(`Default`);for(let e of n)c.set(e,void 0)}}if(s.get(i)){let n=c.keys(),r=!1;for(let a of n)if(c.get(a)===void 0&&c.set(a,await e.note.findNotes({query:`"deck:${a}"`})),c.get(a)?.includes(t.noteId)){i=a,r=!0;break}if(!r)throw Error(`No matching non-filtered deck found for note ${t.noteId}`)}r.push({cards:t.cards,deckName:i,fields:{Back:t.fields.Back.value??``,...t.fields.Extra!==void 0&&{Extra:t.fields.Extra.value??``},Front:t.fields.Front.value??``,YankiNamespace:t.fields.YankiNamespace.value??``},modelName:t.modelName,noteId:t.noteId,tags:t.tags})}return r}async function Sv(e,t,n,r){let i=[...new Set(t.map(e=>e.deckName))].filter(Boolean),a=[...new Set(n.map(e=>e.deckName))].filter(Boolean).filter(e=>!i.includes(e)),o=[];for(let e of a){let t=e.split(`::`);if(t.length!==1)for(;t.length>1;){t.pop();let e=t.join(`::`);if(i.some(t=>
|
|
88
|
+
{{Extra}}{{/Extra}}`,Front:`{{Back}}`,YankiNamespace:`{{YankiNamespace}}`}],inOrderFields:[`Front`,`Back`,`Extra`,`YankiNamespace`],modelName:`Yanki - Basic (and reversed card with extra)`}],fv=dv.map(e=>e.modelName),pv=[`Yanki - Basic (and reversed card)`];async function mv(e,t,n=!1){if(n)return;let r=t.map(e=>e.noteId).filter(e=>e!==void 0);await e.note.deleteNotes({notes:r})}async function hv(e,t,n,r){if(t.noteId!==void 0)throw Error(`Note already has an ID`);if(n)return 0;let i=await e.note.addNote({note:{...t,options:{allowDuplicate:!0}}}).catch(async i=>{if(i instanceof Error){if(i.message===`model was not found: ${t.modelName}`){let i=dv.find(e=>e.modelName===t.modelName);if(i===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(i),hv(e,t,n,r)}if(i.message===`deck was not found: ${t.deckName}`){if(t.deckName===``)throw Error(`Deck name is empty`);return await e.deck.createDeck({deck:t.deckName}),hv(e,t,n,r)}throw i}else throw TypeError(`Unknown error`)});if(i===null)throw Error(`Note creation failed`);return await Tv(e,t,n,r),i}async function gv(e,t,n,r,i){if(t.noteId===void 0)throw Error(`Local note ID is undefined`);if(n.cards===void 0)throw Error(`Remote note cards are undefined`);let a=!1;if(t.deckName!==n.deckName){if(t.deckName===``)throw Error(`Local deck name is empty`);r||await e.deck.changeDeck({cards:n.cards,deck:t.deckName}),a=!0}return(!yv(t.tags??[],n.tags??[])||!_v(t.fields,n.fields)||t.modelName!==n.modelName)&&(r||(await e.note.updateNoteModel({note:{...t,id:t.noteId,tags:t.tags??[]}}).catch(async a=>{if(a instanceof Error){if(a.message===`Model '${t.modelName}' not found`){let a=dv.find(e=>e.modelName===t.modelName);if(a===void 0)throw Error(`Model not found: ${t.modelName}`);return await e.model.createModel(a),gv(e,t,n,r,i)}throw a}else throw TypeError(`Unknown error`)}),await Tv(e,t,r,i)),a=!0),a}function _v(e,t){for(let n of[`Front`,`Back`,`Extra`])if(n in e&&n in t){if(e[n].normalize(`NFC`)!==t[n].normalize(`NFC`))return!1}else if(n in e||n in t)return!1;return!0}function vv(e,t,n=!0){return!(n&&e.noteId!==t.noteId||e.deckName!==t.deckName||e.modelName!==t.modelName||!_v(e.fields,t.fields)||!yv(e.tags??[],t.tags??[]))}function yv(e,t){let n=new Set(e.map(e=>e.normalize(`NFC`).toLowerCase())),r=new Set(t.map(e=>e.normalize(`NFC`).toLowerCase()));return new Set([...n,...r]).size===r.size}async function bv(e,t=Vh.namespace){return await xv(e,await e.note.findNotes({query:`"YankiNamespace:${t}"`}))}async function xv(e,t){let n=await e.note.notesInfo({notes:t}),r=[];if(n.every(e=>e.noteId===void 0))return Array.from({length:n.length}).fill(void 0);let i=n.flatMap(e=>e.cards??[]),a=await e.deck.getDecks({cards:i}),o=new Map;for(let[e,t]of Object.entries(a))for(let n of t)o.set(n,e);let s=new Map,c=new Map;for(let t of n){if(t.noteId===void 0){r.push(void 0);continue}if(![...pv,...fv].includes(t.modelName))throw Error(`Unknown model name ${t.modelName} for note ${t.noteId}`);let n=[...new Set(t.cards.map(e=>o.get(e)))];n.length;let i=n.at(0);if(i===void 0)throw Error(`No deck found for cards in note ${t.noteId}`);if(!s.has(i)){let t=!!(await e.deck.getDeckConfig({deck:i})).dyn;if(s.set(i,t),t){let t=await e.deck.deckNames();for(let n of t)if(!s.has(n)){let t=await e.deck.getDeckConfig({deck:n});s.set(n,!!t.dyn)}let n=[...s.entries()].filter(([e,t])=>!t&&e!==`Default`).map(([e])=>e).sort((e,t)=>t.split(`::`).length-e.split(`::`).length);n.push(`Default`);for(let e of n)c.set(e,void 0)}}if(s.get(i)){let n=c.keys(),r=!1;for(let a of n)if(c.get(a)===void 0&&c.set(a,await e.note.findNotes({query:`"deck:${a}"`})),c.get(a)?.includes(t.noteId)){i=a,r=!0;break}if(!r)throw Error(`No matching non-filtered deck found for note ${t.noteId}`)}r.push({cards:t.cards,deckName:i,fields:{Back:t.fields.Back.value??``,...t.fields.Extra!==void 0&&{Extra:t.fields.Extra.value??``},Front:t.fields.Front.value??``,YankiNamespace:t.fields.YankiNamespace.value??``},modelName:t.modelName,noteId:t.noteId,tags:t.tags})}return r}async function Sv(e,t,n,r){let i=[...new Set(t.map(e=>e.deckName))].filter(Boolean),a=[...new Set(n.map(e=>e.deckName))].filter(Boolean).filter(e=>!i.includes(e)),o=[];for(let e of a){let t=e.split(`::`);if(t.length!==1)for(;t.length>1;){t.pop();let e=t.join(`::`);if(i.some(t=>t.startsWith(`${e}::`)))break;o.push(e)}}let s=[...new Set([...a,...o])].sort(),c=[];for(let i of s){let a=await e.deck.getDeckStats({decks:[i]}),o=Object.values(a);if(o.length>1){console.warn(`Multiple decks found for deck name: ${i}`);continue}let s=o.at(0);if(s===void 0){console.warn(`Deck not found for deck name: ${i}`);continue}let l=Math.max(s.total_in_deck,s.new_count+s.learn_count+s.review_count);if(r){let e=n.filter(e=>e.deckName===i).length,r=t.filter(e=>e.deckName===i).length;l===e&&r===0&&!c.includes(i)&&c.push(i)}else l===0&&!c.includes(i)&&c.push(i)}return r||await e.deck.deleteDecks({cardsToo:!0,decks:c}),c}async function Cv(e,t,n,r){let i;try{let{css:n}=await e.model.modelStyling({modelName:t});i=n}catch(i){if(i instanceof Error){if(i.message===`model was not found: ${t}`){let i=dv.find(e=>e.modelName===t);if(i===void 0)throw Error(`Model not found: ${t}`);return r?!1:(await e.model.createModel(i),Cv(e,i.modelName,n,r))}throw i}else throw TypeError(`Unknown error`)}return i!==void 0&&i===n?!1:(r||await e.model.updateModelStyling({model:{css:n,name:t}}),!0)}async function wv(e,t=fv[0]){let{css:n}=await e.model.modelStyling({modelName:t});return n}async function Tv(e,t,n,r){let i=$_(`${t.fields.Front}\n${t.fields.Back}\n${t.fields.Extra}`),a=[];for(let{filename:t,originalSrc:o}of i)if((await e.media.getMediaFilesNames({pattern:t})).length===0){if(!n)try{let n=await e.media.storeMediaFile(S_(o)?{deleteExisting:!0,filename:t,url:o}:{data:uv(await r.readFileBuffer(o)),deleteExisting:!0,filename:t});t!==n&&console.warn(`Anki media filename mismatch: Expected: "${t}" -> Received: "${n}"`)}catch(e){console.warn(`Anki could not store media file: "${t}"\n${String(e)}`)}a.push({filename:t,originalSrc:o})}return a}async function Ev(e,t,n,r){if(r)return[];let i=hg(n),a=[];for(let e of t){let t=$_(`${e.fields.Front}\n${e.fields.Back}\n${e.fields.Extra}`);for(let{filename:e}of t)a.push(e)}let o=await e.media.getMediaFilesNames({pattern:`${i}-*`}),s=[];for(let t of o)a.includes(t)||(await e.media.deleteMediaFile({filename:t}),s.push(t));return s}async function Dv(e){try{let{permission:t}=await e.miscellaneous.requestPermission();if(t===`denied`)throw Error(`Permission denied, please add this source to the "webCorsOriginList" in the Anki-Connect add-on configuration options.`);return`granted`}catch(e){if(e instanceof Error&&(e.message===`fetch failed`||e.message===`net::ERR_CONNECTION_REFUSED`))return`ankiUnreachable`;throw e}}async function Ov(e){try{await e.miscellaneous.sync()}catch{console.warn(`Could not sync to AnkiWeb.`)}}const kv={...Vh};async function Av(e){let t=performance.now(),{ankiConnectOptions:n,ankiWeb:r,dryRun:i,namespace:a}=T(kv,e??{}),o=fg(a,!0),s=new Te(n);if(await Dv(s)===`ankiUnreachable`)throw Error(`Anki is unreachable. Is Anki running?`);let c=await bv(s,o);await mv(s,c,i);let l=await Sv(s,[],c,i),u=await Ev(s,[],o,i);return c.length>0||l.length,!i&&r&&await Ov(s),{ankiWeb:r,deletedDecks:l,deletedMedia:u,deletedNotes:c,dryRun:i,duration:performance.now()-t,namespace:o}}function jv(e,t=!1){let n=e.deletedDecks.length,r=e.deletedNotes.length,i=e.deletedMedia.length;if(n===0&&r===0&&i===0)return`Nothing to delete`;let a=[`${e.dryRun?`Will`:`Successfully`} deleted ${r} ${ue(`note`,r)}, ${n} ${ue(`deck`,n)}, and ${i} media ${ue(`asset`,i)} from Anki${e.dryRun?``:` in ${ve(e.duration)}`}.`];if(t){if(r>0){a.push(``,e.dryRun?`Notes to delete:`:`Deleted notes:`);for(let t of e.deletedNotes){let e=Sh(Q_(t.fields.Front),50);a.push(` Note ID ${t.noteId} ${e}`)}}if(n>0){a.push(``,e.dryRun?`Decks to delete:`:`Deleted decks:`);for(let t of e.deletedDecks)a.push(` ${t}`)}if(i>0){a.push(``,e.dryRun?`Media assets to delete:`:`Deleted media assets:`);for(let t of e.deletedMedia)a.push(` ${t}`)}}return a.join(`
|
|
89
89
|
`)}const Mv={...Vh};async function Nv(e){let t=performance.now(),{ankiConnectOptions:n,namespace:r}=T(Mv,e??{}),i=fg(r,!0),a=new Te(n);if(await Dv(a)===`ankiUnreachable`)throw Error(`Anki is unreachable. Is Anki running?`);let o=await bv(a,i);return{duration:performance.now()-t,namespace:i,notes:o}}function Pv(e){if(e.notes.length===0)return`No notes found.`;let t=[];for(let n of e.notes){let e=Sh(Q_(n.fields.Front),50);t.push(`Note ID ${n.noteId} ${e}`)}return t.join(`
|
|
90
90
|
`)}function Fv(){return/[<>:"/\\|?*\u0000-\u001F]/g}function Iv(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}const Lv=/^\.+(\\|\/)|^\.+$/,Rv=/\.+$/;function zv(e,t={}){let n=/[\u0000-\u001F\u0080-\u009F]/g,r=/([<>:"/\\|?*\u0000-\u001F]){2,}/g;if(typeof e!=`string`)throw TypeError(`Expected a string`);let i=t.replacement===void 0?`!`:t.replacement;if(Fv().test(i)&&n.test(i))throw Error(`Replacement string cannot contain reserved filename characters`);i.length>0&&(e=e.replace(r,`$1`)),e=e.normalize(`NFD`),e=e.replace(Lv,i),e=e.replace(Fv(),i),e=e.replace(n,i),e=e.replace(Rv,``),i.length>0&&(e[0]!==`.`&&e[0]===`.`&&(e=i+e),e[e.length-1]===`.`&&(e+=i)),e=Iv().test(e)?e+i:e;let a=typeof t.maxLength==`number`?t.maxLength:100;if(e.length>a){let t=e.lastIndexOf(`.`);if(t===-1)e=e.slice(0,a);else{let n=e.slice(0,t),r=e.slice(t);e=n.slice(0,Math.max(1,a-r.length))+r}}return e}let Bv=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[n[e]&63];return t};function Vv(e,t,n){if(t===`off`)throw Error(`manageFilenames must not be off`);switch(e.modelName){case`Yanki - Basic`:case`Yanki - Basic (and reversed card with extra)`:case`Yanki - Basic (type in the answer)`:{let r=wh(Hv(e.fields.Front).replace(Ah,``).replace(Mh,``)),i=wh(Hv(e.fields.Back).replace(Ah,``).replace(Mh,``));switch(t){case`prompt`:return Hv(r??i??``,n);case`response`:return Hv(i??r??``,n)}}case`Yanki - Cloze`:{let r=Z_(e.fields.Front),i=wh(r.split(`{{`).at(0)??``),a=wh(/\{\{\w\d*\s?:{0,2}([^:}]+)/.exec(r)?.at(1)),o=wh(r.split(`}}`).at(1)?.split(`{{`).at(0)??``);switch(t){case`prompt`:return Hv(i??o??a??``,n);case`response`:return Hv(a??i??o??``,n)}}}}function Hv(e,t){let n=zv(Q_(e).trim(),{maxLength:2**53-1,replacement:` `}).replaceAll(/\s+/g,` `).trim();return n.length===0&&(n=Mh),n=n.normalize(`NFC`),t===void 0?n:Sh(n,Math.min(t,108))}function Uv(e,t){let n=Kv(e,1),r=2;for(;t.includes(n.toLowerCase());)n=Kv(e,r),r++;return n}function Wv(e,t){let n=Kv(e,2);return t.includes(n.toLowerCase())?e:Gv(e)}function Gv(e){let t=e.endsWith(`.`)||e.endsWith(`)`)?void 0:q.extname(e),n=q.basename(e,t).replace(/\s\(\d+\)$/,``);return q.join(q.dirname(e),`${n}${t??``}`)}function Kv(e,t){let n=q.extname(e),r=`${Gv(q.basename(e,n))} (${t})`;return q.join(q.dirname(e),`${r}${n}`)}function qv(e){return`${e}-${Bv(8)}`}function Jv(e){let t,n=0,r=/\{([^\|\}]+\|[^\|\}]+(?:\|[^\{\|\}]+)*)\}/g,i=[];for(;(t=r.exec(e))!==null;)i.push(e.substring(n,t.index)),i.push(t[1].split(`|`)),n=t.index+t[0].length;return i.push(e.substring(n,e.length)),i.filter(e=>e!==``)}function Yv(e,t){return[K(`text`,{value:e}),K(`rp`,{data:{hName:`rp`}},[K(`text`,{value:`(`})]),K(`rt`,{data:{hName:`rt`}},[K(`text`,{value:t})]),K(`rp`,{data:{hName:`rp`}},[K(`text`,{value:`)`})])]}function Xv(e){let t=Array.from(e[0]);if(t.length+1===e.length){let n=[];for(let r=0;r<t.length;r++)n.push(...Yv(t[r],e[r+1]));return K(`ruby`,{data:{hName:`ruby`}},n)}else{let t=e[0];return K(`ruby`,{data:{hName:`ruby`}},Yv(t,e.slice(1).join(``)))}}function Zv(){function e(e){M(e,`text`,(e,t,n)=>{let r=Jv(e.value).map(e=>typeof e==`string`?{type:`text`,value:e}:Xv(e));return n.children.splice(t,1,...r),t+r.length})}return e}const Qv=(function(e,t,n,r,i){let a=To(r),o=[];if(!e||!e.type||!e.children)throw Error(`Expected parent node`);if(typeof t==`number`){if(t<0||t===1/0)throw Error(`Expected positive finite number as index for start`)}else if(t=e.children.indexOf(t),t<0)throw Error(`Expected child node or index for start`);if(typeof n==`number`){if(n<0||n===1/0)throw Error(`Expected positive finite number as index for end`)}else if(n=e.children.indexOf(n),n<0)throw Error(`Expected child node or index for end`);if(i?.behaviour===`include`)for(;t<=n;)a(e.children[t],t,e)&&o.push(e.children[t]),t++;else for(;++t<n;)a(e.children[t],t,e)&&o.push(e.children[t]);return o}),$v=(function(e,t,n){let r=To(n),i=[],a=-1;if(!e||!e.type||!e.children)throw Error(`Expected parent node`);if(typeof t==`number`){if(t<0||t===1/0)throw Error(`Expected positive finite number as index`)}else if(t=e.children.indexOf(t),t<0)throw Error(`Expected child node or index`);for(t>e.children.length&&(t=e.children.length);++a<t;)r(e.children[a],a,e)&&i.push(e.children[a]);return i}),ey=(function(e,t,n){let r=To(n),i=[];if(!e||!e.type||!e.children)throw Error(`Expected parent node`);if(typeof t==`number`){if(t<0||t===1/0)throw Error(`Expected positive finite number as index`)}else if(t=e.children.indexOf(t),t<0)throw Error(`Expected child node or index`);for(;++t<e.children.length;)r(e.children[t],t,e)&&i.push(e.children[t]);return i}),ty={a:`amber`,b:`blue`,c:`cyan`,d:`brown`,e:`espresso`,f:`fuchsia`,g:`green`,h:`hotpink`,i:`indigo`,j:`jade`,k:`kiwi`,l:`lime`,m:`magenta`,n:`navyblue`,o:`orange`,p:`purple`,q:`pink`,r:`red`,s:`silver`,t:`teal`,u:`umber`,v:`violet`,w:`white`,x:`gray`,y:`yellow`,z:`black`},ny={dictionary:ty,markerTagName:`mark`,markerClassName:`flexible-marker`,actionForEmptyContent:`mark`},ry=/=([a-z]?)=(?![\s=])([\s\S]*?)(?<![\s=])==/,iy=/=([a-z]?)=(?![\s=])([\s\S]*?)(?<![\s=])==/g,ay=/=([a-z]?)=(?![\s]|=+\s)/,oy=/=([a-z]?)=(?![\s]|=+\s)/g,sy=/(?<!\s|\s=|\s==|\s===|\s====)==/,cy=/(?<!\s|\s=|\s==|\s===|\s====)==/g,ly=/=([a-z]?)=\s*==/,uy=/=([a-z]?)=\s*==/g;function dy(e){return e.filter(e=>!!e)}const fy=e=>{let t=Object.assign({},ny,e);e?.dictionary&&Object.keys(e.dictionary).length&&(t.dictionary=Object.assign({},ty,e.dictionary));let n=(e,n)=>{let r=e?t.dictionary[e]:void 0,i=typeof t.markerTagName==`string`?t.markerTagName:t.markerTagName(r),a=typeof t.markerClassName==`function`?t.markerClassName(r):dy([t.markerClassName,!e&&`${t.markerClassName}-default`,r&&`${t.markerClassName}-${r}`,!n.length&&`${t.markerClassName}-empty`]),o=t.markerProperties?.(r)??{};return Object.entries(o).forEach(([e,t])=>{(typeof t==`string`&&t===``||Array.isArray(t)&&t.length===0)&&(o[e]=void 0),e===`className`&&delete o?.className}),{type:`mark`,children:n,data:{hName:i,hProperties:{className:a,...o&&{...o}}}}},r=function(e,t,r){if(!r||t===void 0||!ry.test(e.value))return;let i=[],a=e.value,o=``,s=0,c=0,l=Array.from(a.matchAll(iy));for(let e=0;e<l.length;e++){let t=l[e],[r,u,d]=t,f=t.index,p=r.length,m=s+c;if(s=f,c=p,f>m){let e=K(`text`,a.substring(m,f));i.push(e)}let h=n(u,[{type:`text`,value:d.trim()}]);i.push(h),o=a.slice(f+p)}if(o){let e=K(`text`,o);i.push(e)}i.length&&r.children.splice(t,1,...i)},i=function(e,t,r){if(!r||t===void 0||!ay.test(e.value))return;let i=e,a=Wo(r,i,function(e){return e.type===`text`&&sy.test(e.value)});if(!a)return;let o=$v(r,i),s=Qv(r,i,a),c=ey(r,a),l=i.value,u=Array.from(l.matchAll(oy))[0],[d,f]=u,p=d.length,m=u.index;if(m>0){let e=K(`text`,l.substring(0,m));o.push(e)}if(l.length>m+p){let e=K(`text`,l.slice(m+p));s.unshift(e)}let h=a.value,g=Array.from(h.matchAll(cy))[0],[_]=g,v=_.length,y=g.index;if(y>0){let e=K(`text`,h.substring(0,y));s.push(e)}if(h.length>y+v){let e=K(`text`,h.slice(y+v));c.unshift(e)}let b=n(f,s);return r.children=[...o,b,...c],t},a=function(e,r,i){if(!i||r===void 0||!ly.test(e.value))return;if(t.actionForEmptyContent===`remove`)return e.value=e.value.replaceAll(uy,``),e.value.trim()===``?[Po,r]:!0;let a=[],o=e.value,s=``,c=0,l=0,u=Array.from(o.matchAll(uy));for(let e=0;e<u.length;e++){let t=u[e],[r,i]=t,d=t.index,f=r.length,p=c+l;if(c=d,l=f,d>p){let e=K(`text`,o.substring(p,d));a.push(e)}let m=n(i,[]);a.push(m),s=o.slice(d+f)}if(s){let e=K(`text`,s);a.push(e)}a.length&&i.children.splice(r,1,...a)};return e=>{if(M(e,`text`,r),M(e,`text`,i),t.actionForEmptyContent!==`keep`&&M(e,`text`,a),t.equalityOperator){let n=new RegExp(t.equalityOperator,`gi`);M(e,`text`,e=>{e.value=e.value.replaceAll(n,`==`)})}}};var py=u(s(((e,t)=>{(function(){var e=t===void 0?function(){return this||(0,eval)(`this`)}():t.exports=i;e.format=i,e.vsprintf=r,typeof console<`u`&&typeof console.log==`function`&&(e.printf=n);function n(){console.log(i.apply(null,arguments))}function r(e,t){return i.apply(null,[e].concat(t))}function i(e){for(var t=1,n=[].slice.call(arguments),r=0,i=e.length,a=``,o,s=!1,c,l,u=!1,d,f=function(){return n[t++]},p=function(){for(var t=``;/\d/.test(e[r]);)t+=e[r++],o=e[r];return t.length>0?parseInt(t):null};r<i;++r)if(o=e[r],s)switch(s=!1,o==`.`?(u=!1,o=e[++r]):o==`0`&&e[r+1]==`.`?(u=!0,r+=2,o=e[r]):u=!0,d=p(),o){case`b`:a+=parseInt(f(),10).toString(2);break;case`c`:c=f(),typeof c==`string`||c instanceof String?a+=c:a+=String.fromCharCode(parseInt(c,10));break;case`d`:a+=parseInt(f(),10);break;case`f`:l=String(parseFloat(f()).toFixed(d||6)),a+=u?l:l.replace(/^0/,``);break;case`j`:a+=JSON.stringify(f());break;case`o`:a+=`0`+parseInt(f(),10).toString(8);break;case`s`:a+=f();break;case`x`:a+=`0x`+parseInt(f(),10).toString(16);break;case`X`:a+=`0x`+parseInt(f(),10).toString(16).toUpperCase();break;default:a+=o;break}else o===`%`?s=!0:a+=o;return a}})()}))(),1);const my=Object.assign(hy(Error),{eval:hy(EvalError),range:hy(RangeError),reference:hy(ReferenceError),syntax:hy(SyntaxError),type:hy(TypeError),uri:hy(URIError)});function hy(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,py.default)(t,...n))}}const gy={}.hasOwnProperty,_y={yaml:`-`,toml:`+`};function vy(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=yy(r[n]);return t}function yy(e){let t=e;if(typeof t==`string`){if(!gy.call(_y,t))throw my("Missing matter definition for `%s`",t);t={type:t,marker:_y[t]}}else if(typeof t!=`object`)throw my("Expected matter to be an object, not `%j`",t);if(!gy.call(t,`type`))throw my("Missing `type` in matter `%j`",t);if(!gy.call(t,`fence`)&&!gy.call(t,`marker`))throw my("Missing `marker` or `fence` in matter `%j`",t);return t}function by(e){let t=vy(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Sy(e,`open`).charCodeAt(0),a=xy(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function xy(e){let t=e.anywhere,n=e.type,r=n+`Fence`,i=r+`Sequence`,a=n+`Value`,o={tokenize:u,partial:!0},s,c=0;return{tokenize:l,concrete:!0};function l(l,u,d){let f=this;return p;function p(a){let o=f.now();return o.column===1&&(o.line===1||t)&&(s=Sy(e,`open`),c=0,a===s.charCodeAt(c))?(l.enter(n),l.enter(r),l.enter(i),m(a)):d(a)}function m(e){return c===s.length?(l.exit(i),G(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return G(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return U(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Sy(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||U(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||U(e)?(l.exit(a),y(e)):(l.consume(e),v)}function y(e){return e===null?d(e):(l.enter(`lineEnding`),l.consume(e),l.exit(`lineEnding`),l.attempt(o,b,_))}function b(e){return l.exit(n),u(e)}}function u(e,t,n){let a=0;return o;function o(t){return t===s.charCodeAt(a)?(e.enter(r),e.enter(i),c(t)):n(t)}function c(t){return a===s.length?(e.exit(i),G(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return G(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||U(i)?(e.exit(r),t(i)):n(i)}}}function Sy(e,t){return e.marker?Cy(e.marker,t).repeat(3):Cy(e.fence,t)}function Cy(e,t){return typeof e==`string`?e:e[t]}function wy(e){let t=vy(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Ty(e),r[e.type]=Ey,r[e.type+`Value`]=Dy}return{enter:n,exit:r}}function Ty(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Ey(e){let t=this.resume(),n=this.stack[this.stack.length-1];`value`in n,this.exit(e),n.value=t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``)}function Dy(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Oy(e){let t=[],n={},r=vy(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=ky(e);let a=Ay(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Wh(a.charAt(1))})}return{unsafe:t,handlers:n}}function ky(e){let t=Ay(e,`open`),n=Ay(e,`close`);return r;function r(e){return t+(e.value?`
|
|
91
91
|
`+e.value:``)+`
|
package/package.json
CHANGED
package/dist/.DS_Store
DELETED
|
Binary file
|