likec4 1.59.2 → 1.59.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/__app__/src/chunks/AIChat.mjs +118 -123
  2. package/__app__/src/chunks/LikeC4Styles.mjs +828 -686
  3. package/__app__/src/chunks/ProjectsOverview.mjs +82 -82
  4. package/__app__/src/chunks/es.mjs +1 -1
  5. package/__app__/src/chunks/hooks.mjs +164 -135
  6. package/__app__/src/chunks/libs/@floating-ui.mjs +649 -335
  7. package/__app__/src/chunks/libs/@mantine.mjs +2934 -2040
  8. package/__app__/src/chunks/libs/@tanstack-ai.mjs +28 -28
  9. package/__app__/src/chunks/libs/@tanstack.mjs +46 -51
  10. package/__app__/src/chunks/libs/@xstate/react.mjs +59 -40
  11. package/__app__/src/chunks/libs/@xyflow/react.mjs +535 -448
  12. package/__app__/src/chunks/libs/bezier-js.mjs +10 -9
  13. package/__app__/src/chunks/libs/d3.mjs +20 -45
  14. package/__app__/src/chunks/libs/fast-equals.mjs +62 -50
  15. package/__app__/src/chunks/libs/framer.mjs +300 -279
  16. package/__app__/src/chunks/libs/zod.mjs +17 -14
  17. package/__app__/src/chunks/rolldown-runtime.mjs +2 -2
  18. package/__app__/src/chunks/styled-system.mjs +2580 -132
  19. package/__app__/src/main.mjs +24925 -23485
  20. package/__app__/src/style.css +1 -1
  21. package/config/schema.json +49 -0
  22. package/dist/app/render-view-client.css +1 -0
  23. package/dist/app/render-view-client.js +739 -0
  24. package/dist/chunks/enableServer.mjs +1 -1
  25. package/dist/chunks/filenames.mjs +7 -6
  26. package/dist/chunks/index.d.mts +18 -1
  27. package/dist/chunks/index2.d.mts +79 -26
  28. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
  29. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +5 -5
  30. package/dist/chunks/libs/@chevrotain/types.d.mts +108 -0
  31. package/dist/chunks/libs/@logtape/logtape.mjs +4 -4
  32. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  33. package/dist/chunks/libs/birpc.mjs +1 -1
  34. package/dist/chunks/libs/chevrotain-allstar.mjs +1 -1
  35. package/dist/chunks/libs/chevrotain.mjs +16 -16
  36. package/dist/chunks/libs/json5.mjs +3 -3
  37. package/dist/chunks/libs/langium.d.mts +1777 -16
  38. package/dist/chunks/libs/langium.mjs +11 -11
  39. package/dist/chunks/libs/merge-error-cause.mjs +2 -2
  40. package/dist/chunks/libs/p-queue.mjs +1 -1
  41. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  42. package/dist/chunks/libs/pako.mjs +2 -2
  43. package/dist/chunks/libs/picomatch.mjs +1 -1
  44. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  45. package/dist/chunks/libs/remeda.mjs +1 -1
  46. package/dist/chunks/libs/ufo.mjs +1 -1
  47. package/dist/chunks/libs/unstorage.mjs +1 -1
  48. package/dist/chunks/libs/zod.d.mts +1717 -17
  49. package/dist/chunks/libs/zod.mjs +4 -4
  50. package/dist/chunks/node.mjs +68 -57
  51. package/dist/chunks/rolldown-runtime.mjs +1 -1
  52. package/dist/chunks/sequence-view.mjs +1 -1
  53. package/dist/chunks/vite-plugin.mjs +168 -54
  54. package/dist/cli/index.d.mts +1 -1
  55. package/dist/cli/index.mjs +291 -165
  56. package/dist/config/index.d.mts +7 -1
  57. package/dist/config/index.mjs +1 -1
  58. package/dist/index.d.mts +3 -3
  59. package/dist/index.mjs +1 -1
  60. package/dist/model/index.d.mts +4 -4
  61. package/dist/vite-plugin/index.d.mts +2 -2
  62. package/dist/vite-plugin/internal/index.d.mts +72 -35
  63. package/dist/vite-plugin/internal/index.mjs +125 -44
  64. package/package.json +47 -47
  65. package/react/index.d.mts +22767 -1432
  66. package/react/index.mjs +38152 -32309
  67. package/vite-plugin-modules.d.ts +21 -1
  68. package/dist/chunks/dist.mjs +0 -10
  69. package/dist/chunks/logger.mjs +0 -1
@@ -0,0 +1,108 @@
1
+ import { i as __name } from "../../rolldown-runtime.mjs";
2
+ //#region ../../node_modules/.pnpm/@chevrotain+types@11.0.3/node_modules/@chevrotain/types/api.d.ts
3
+ type TokenPattern = RegExp | string | CustomPatternMatcherFunc | ICustomPattern;
4
+ /**
5
+ * API #1 [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
6
+ */
7
+ declare type CustomPatternMatcherFunc = (
8
+ /**
9
+ * The full input string.
10
+ */
11
+ text: string,
12
+ /**
13
+ * The offset at which to attempt a match
14
+ */
15
+ offset: number,
16
+ /**
17
+ * Previously scanned Tokens
18
+ */
19
+ tokens: IToken[],
20
+ /**
21
+ * Token Groups
22
+ */
23
+ groups: {
24
+ [groupName: string]: IToken[];
25
+ }) => CustomPatternMatcherReturn | RegExpExecArray | null; // RegExpExecArray included for legacy reasons
26
+ type CustomPatternMatcherReturn = [string] & {
27
+ payload?: any;
28
+ };
29
+ interface TokenType {
30
+ name: string;
31
+ GROUP?: string;
32
+ PATTERN?: TokenPattern;
33
+ LABEL?: string;
34
+ LONGER_ALT?: TokenType | TokenType[];
35
+ POP_MODE?: boolean;
36
+ PUSH_MODE?: string;
37
+ LINE_BREAKS?: boolean;
38
+ CATEGORIES?: TokenType[];
39
+ tokenTypeIdx?: number;
40
+ categoryMatches?: number[];
41
+ categoryMatchesMap?: {
42
+ [tokType: number]: boolean;
43
+ };
44
+ isParent?: boolean;
45
+ START_CHARS_HINT?: (string | number)[];
46
+ }
47
+ /**
48
+ * API #2 for [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
49
+ */
50
+ interface ICustomPattern {
51
+ exec: CustomPatternMatcherFunc;
52
+ }
53
+ /**
54
+ * Things to note:
55
+ * - The offset range is inclusive to exclusive.
56
+ *
57
+ * - A lineTerminator as the last character does not effect the Token's line numbering.
58
+ * In other words a new line only starts **after** a line terminator.
59
+ *
60
+ * - A Token's image is it's **literal** text.
61
+ * e.g unicode escaping is untouched.
62
+ */
63
+ interface IToken {
64
+ /** The textual representation of the Token as it appeared in the text. */
65
+ image: string;
66
+ /** Offset of the first character of the Token. 0-indexed. */
67
+ startOffset: number;
68
+ /** Line of the first character of the Token. 1-indexed. */
69
+ startLine?: number;
70
+ /**
71
+ * Column of the first character of the Token. 1-indexed.
72
+ *
73
+ * For token foo in the following line, startColumn will be 3 and endColumn will be 5.
74
+ * ```
75
+ * a foo
76
+ * 123456
77
+ * ```
78
+ */
79
+ startColumn?: number;
80
+ /**
81
+ * Offset of the last character of the Token. 0-indexed.
82
+ * Note that this points at the last character, not the end of the token, so the original image would be
83
+ * `input.substring(token.startOffset, token.endOffset + 1)`.
84
+ */
85
+ endOffset?: number;
86
+ /** Line of the last character of the Token. 1-indexed. Will be the same as startLine for single-line tokens.*/
87
+ endLine?: number;
88
+ /** Column of the last character of the Token. 1-indexed. See also startColumn. */
89
+ endColumn?: number;
90
+ /** this marks if a Token does not really exist and has been inserted "artificially" during parsing in rule error recovery. */
91
+ isInsertedInRecovery?: boolean;
92
+ /** An number index representing the type of the Token use <getTokenConstructor> to get the Token Type from a token "instance" */
93
+ tokenTypeIdx: number;
94
+ /**
95
+ * The actual Token Type of this Token "instance"
96
+ * This is the same Object returned by the "createToken" API.
97
+ * This property is very useful for debugging the Lexing and Parsing phases.
98
+ */
99
+ tokenType: TokenType;
100
+ /**
101
+ * Custom Payload value, this is an optional feature of Custom Token Patterns
102
+ * For additional details see the docs:
103
+ * https://chevrotain.io/docs/guide/custom_token_patterns.html#custom-payloads
104
+ */
105
+ payload?: any;
106
+ }
107
+ //#endregion
108
+ export { IToken as t };
@@ -1,5 +1,5 @@
1
- import{i as e,r as t}from"../../rolldown-runtime.mjs";import n from"node:util";function toFilter(e){return typeof e==`function`?e:getLevelFilter(e)}function getLevelFilter(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const r=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function compareLogLevel(e,t){let n=r.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let i=r.indexOf(t);if(i<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-i}const i=Symbol.for(`logtape.lazy`),a=Symbol.for(`LogTape.throttlingSummaryRecord`);function isLazy(e){return typeof e==`object`&&!!e&&i in e&&e[i]===!0}function resolveProperties(e){let t={};for(let n in e){let r=e[n];t[n]=isLazy(r)?r.getter():r}let n=e,r=t;if(Object.prototype.propertyIsEnumerable.call(e,a)){let e=n[a];r[a]=isLazy(e)?e.getter():e}return t}function isPromiseObject(e){return e instanceof Promise||Object.prototype.toString.call(e)===`[object Promise]`&&typeof e.then==`function`}function logStringMessage(e,t,n,r){if(typeof r!=`function`){let i=r??{};e.log(t,n,i);return}if(!e.isEnabledFor(t))return Promise.resolve();let i=r();if(isPromiseObject(i))return Promise.resolve(i).then(r=>{e.log(t,n,r)});e.log(t,n,i)}function snapshotLogRecordProperties(e){let t=resolveProperties(e.properties),n=Object.getOwnPropertyDescriptors(e);return n.properties={value:t,enumerable:!0,configurable:!0},Object.defineProperties({},n)}function getLogger(e=[]){return s.getLogger(e)}const o=Symbol.for(`logtape.rootLogger`);function isMetaLoggerCategory(e){return e.length===2&&e[0]===`logtape`&&e[1]===`meta`}var s=class LoggerImpl{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(e=[]){let t=o in globalThis?globalThis[o]??null:null;return t??(t=new LoggerImpl(null,[]),globalThis[o]=t),typeof e==`string`?t.getChild(e):e.length===0?t:t.getChild(e)}static getNearestExistingLogger(e){let t=LoggerImpl.getLogger();for(let n of e){let e=t.children[n],r=e instanceof LoggerImpl?e:e?.deref();if(r==null)break;t=r}return t}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(e){let t=typeof e==`string`?e:e[0],n=this.children[t],r=n instanceof LoggerImpl?n:n?.deref();return r??(r=new LoggerImpl(this,[...this.category,t]),this.children[t]=`WeakRef`in globalThis?new WeakRef(r):r),typeof e==`string`||e.length===1?r:r.getChild(e.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let e of Object.values(this.children))(e instanceof LoggerImpl?e:e.deref())?.resetDescendants();this.reset()}with(e){return new c(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||compareLogLevel(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}isEnabledFor(e){let t=isMetaLoggerCategory(this.category)?[]:getCategoryPrefix();return(t.length>0?LoggerImpl.getNearestExistingLogger([...t,...this.category]):this).isEnabledForResolved(e)}isEnabledForResolved(e){if(this.lowestLevel===null||compareLogLevel(e,this.lowestLevel)<0)return!1;for(let t of this.getSinks(e))return!0;return!1}emit(e,t){let n=`category`in e?e.category:this.category,r=isMetaLoggerCategory(n)?[]:getCategoryPrefix(),i=r.length>0?[...r,...n]:n,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);(r.length>0?LoggerImpl.getNearestExistingLogger(i):this).emitResolved(o,t)}emitResolved(e,t){if(this.lowestLevel===null||compareLogLevel(e.level,this.lowestLevel)<0||!this.filter(e))return;let n=[...this.getSinks(e.level)];if(n.length<1)return;let r,i=!1;for(let a of n)if(!t?.has(a))try{if(r==null&&!i)try{r=snapshotLogRecordProperties(e)}catch{i=!0,r=e}a(r??e)}catch(n){let r=new Set(t);r.add(a),l.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:a,error:n,record:e},r)}}log(e,t,n,r){let i=getImplicitContext(),a,o,s=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i,...n()}),a}}:{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i,...n}),a}};this.emit(s,r)}logLazily(e,t,n={}){let r=getImplicitContext(),i,a;function realizeMessage(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,renderMessage(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return realizeMessage()[0]},get rawMessage(){return realizeMessage()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=getImplicitContext();this.emit({category:this.category,level:e,message:renderMessage(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0]);typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0]);typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},c=class LoggerCtx{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(e){return new LoggerCtx(this.logger,{...this.properties,...e})}log(e,t,n,r){let i=this.properties;this.logger.log(e,t,typeof n==`function`?()=>resolveProperties({...i,...n()}):()=>resolveProperties({...i,...n}),r)}logLazily(e,t){this.logger.logLazily(e,t,resolveProperties(this.properties))}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,resolveProperties(this.properties))}emit(e){let t={...e,properties:resolveProperties({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0]);typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0]);typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const l=s.getLogger([`logtape`,`meta`]);function isNestedAccess(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function getOwnProperty(e,t){if(t!==`__proto__`&&t!==`prototype`&&t!==`constructor`&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function parseNextSegment(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
2
- `;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function accessProperty(e,t){if(typeof t==`string`)return getOwnProperty(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function resolvePropertyPath(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=parseNextSegment(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=accessProperty(n,i),n===void 0)return}return n}function parseMessageTemplate(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&isNestedAccess(u)&&(l=resolvePropertyPath(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function renderMessage(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const u=Symbol.for(`logtape.categoryPrefix`);function getCategoryPrefix(){let e=s.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[u];return Array.isArray(t)?t:[]}function getImplicitContext(){let e=s.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var d=t({inspect:()=>inspect$1});function inspect$1(e,t){return n.inspect(e,t)}e(inspect$1,`inspect`);const f={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},p=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):d!=null&&`inspect`in d&&typeof inspect$1==`function`?(e,t)=>inspect$1(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e),inspect=(e,t)=>String(p(e,t)),m=new TextEncoder;function renderMessageParts(e,t){let n=e.length;if(n===1)return e[0];if(n<=6){let r=``;for(let i=0;i<n;i++)r+=i%2==0?e[i]:t(e[i]);return r}let r=Array(n);for(let i=0;i<n;i++)r[i]=i%2==0?e[i]:t(e[i]);return r.join(``)}function padZero(e){return e<10?`0${e}`:`${e}`}function padThree(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const h=/^([+-])(0\d|1\d|2[0-3]):([0-5]\d)$/;function formatOffset(e,t){let n=e<0?`-`:`+`,r=Math.abs(e),i=padZero(Math.floor(r/60)),a=padZero(r%60);return!t&&a===`00`?`${n}${i}`:`${n}${i}:${a}`}function readPartsFromFormatter(e,t){let n=e.formatToParts(new Date(t)),r=``,i=``,a=``,o=``,s=``,c=``;for(let e of n)e.type===`year`?r=e.value:e.type===`month`?i=e.value:e.type===`day`?a=e.value:e.type===`hour`?o=e.value:e.type===`minute`?s=e.value:e.type===`second`&&(c=e.value);return{year:r,month:i,day:a,hour:o,minute:s,second:c}}function getDateParts(e,t){let n=new Date(e),r=padThree(n.getUTCMilliseconds());if(t.kind===`utc`)return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:0};if(t.kind===`local`)return{year:`${n.getFullYear()}`,month:padZero(n.getMonth()+1),day:padZero(n.getDate()),hour:padZero(n.getHours()),minute:padZero(n.getMinutes()),second:padZero(n.getSeconds()),ms:r,offsetMinutes:-n.getTimezoneOffset()};if(t.kind===`offset`){let n=new Date(e+t.minutes*6e4);return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:t.minutes}}let i=readPartsFromFormatter(t.formatter,e),a=Date.UTC(Number(i.year),Number(i.month)-1,Number(i.day),Number(i.hour),Number(i.minute),Number(i.second),n.getUTCMilliseconds()),o=Math.round((a-e)/6e4);return{...i,ms:r,offsetMinutes:o}}function resolveTimeZone(e){if(e===void 0)return{kind:`utc`};if(e===null)return{kind:`local`};let t=h.exec(e);if(t!=null){let e=t[1]===`-`?-1:1,n=Number(t[2]),r=Number(t[3]);return{kind:`offset`,minutes:e*(n*60+r)}}if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. This environment does not support IANA time zones.`);try{return{kind:`iana`,formatter:new Intl.DateTimeFormat(`en-CA`,{timeZone:e,hour12:!1,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}}catch{throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. Expected an IANA time zone name (e.g., "Asia/Seoul") or a fixed UTC offset string (e.g., "+09:00").`)}}function createTimestampFormatter(e,t){return e===`none`?()=>null:e===`rfc3339`&&t.kind===`utc`?e=>new Date(e).toISOString():n=>{let r=getDateParts(n,t),i=`${r.year}-${r.month}-${r.day}`,a=`${r.hour}:${r.minute}:${r.second}.${r.ms}`,o=formatOffset(r.offsetMinutes,!0),s=formatOffset(r.offsetMinutes,!1);return e===`date-time-timezone`?`${i} ${a} ${o}`:e===`date-time-tz`?`${i} ${a} ${s}`:e===`date-time`?`${i} ${a}`:e===`time-timezone`?`${a} ${o}`:e===`time-tz`?`${a} ${s}`:e===`time`?a:e===`date`?i:`${i}T${a}${o}`}}const g={ABBR:f,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function getLineEndingValue(e){return e===`crlf`?`\r
1
+ import{i as e,r as t}from"../../rolldown-runtime.mjs";import n from"node:util";function toFilter(e){return typeof e==`function`?e:getLevelFilter(e)}function getLevelFilter(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const r=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function compareLogLevel(e,t){let n=r.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let i=r.indexOf(t);if(i<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-i}const i=Symbol.for(`logtape.scopedConfig`),a={filters:[],lowestLevel:`trace`,parentSinks:`inherit`,sinks:[]},o=[];function getCurrentScopedConfig(e){let t=e?.getStore()?.[i];return isCompiledScopedConfig(t)?getActiveScopedConfig(t):void 0}function scopedConfigHasSink(e,t,n){return getScopedSinkDispatchPlan(e,t,n).kind!==`none`}function emitWithScopedConfig(e,t,n,r){let i=getScopedSinkDispatchPlan(e,t.category,t.level);if(i.kind!==`none`&&filterScopedRecord(e,t.category,t)){if(i.kind===`one`){n?.has(i.sink)||r(i.sink,n);return}for(let e of i.sinks)n?.has(e)||r(e,n)}}function isCompiledScopedConfig(e){return typeof e==`object`&&!!e&&`nodes`in e}function getActiveScopedConfig(e){let t=e;for(;t?.disposed;)t=t.parent;return t}function categoryKey(e){return JSON.stringify(e)}function getScopedSinkDispatchPlan(e,t,n){let r=`${categoryKey(t)}:${n}`,i=e.dispatchCache.get(r);return i??(i=getScopedSinkDispatchPlanForPrefix(e,t,t.length,n),e.dispatchCache.set(r,i)),i}function getScopedSinkDispatchPlanForPrefix(e,t,n,r){let i=t.slice(0,n),o=e.nodes.get(categoryKey(i))??a;if(o.lowestLevel===null||compareLogLevel(r,o.lowestLevel)<0)return{kind:`none`};let s=n>0&&o.parentSinks===`inherit`?getScopedSinkDispatchPlanForPrefix(e,t,n-1,r):{kind:`none`},c,l,appendSink=e=>{l==null?c==null?c=e:l=[c,e]:l.push(e)};if(s.kind===`one`)appendSink(s.sink);else if(s.kind===`many`)for(let e of s.sinks)appendSink(e);for(let e of o.sinks)appendSink(e);return l==null?c==null?{kind:`none`}:{kind:`one`,sink:c}:{kind:`many`,sinks:l}}function filterScopedRecord(e,t,n){let r=categoryKey(t),i=e.filterCache.get(r);return i??(i=getScopedFilters(e,t),e.filterCache.set(r,i)),i.every(e=>e(n))}function getScopedFilters(e,t){for(let n=t.length;n>=0;n--){let r=e.nodes.get(categoryKey(t.slice(0,n)));if(!(r==null||r.filters.length<1))return r.filters}return o}const s=Symbol.for(`logtape.lazy`),c=Symbol.for(`LogTape.throttlingSummaryRecord`),l=Symbol.for(`LogTape.sinkSnapshotPolicy.immediate`),u=new WeakSet,d=new WeakSet;function isLazy(e){return typeof e==`object`&&!!e&&s in e&&e[s]===!0}function resolveProperties(e){let t={};for(let n in e){let r=e[n];t[n]=isLazy(r)?r.getter():r}let n=e,r=t;if(Object.prototype.propertyIsEnumerable.call(e,c)){let e=n[c];r[c]=isLazy(e)?e.getter():e}return t}function isPromiseObject(e){return e instanceof Promise||Object.prototype.toString.call(e)===`[object Promise]`&&typeof e.then==`function`}function logStringMessage(e,t,n,r){if(typeof r!=`function`){let i=r??{};e.log(t,n,i);return}if(!e.isEnabledFor(t))return Promise.resolve();let i=r();if(isPromiseObject(i))return Promise.resolve(i).then(r=>{e.log(t,n,r)});e.log(t,n,i)}function snapshotLogRecordProperties(e){if(d.has(e))return e;let t=resolveProperties(e.properties);if(u.has(e))return{category:e.category,level:e.level,get message(){return e.message},rawMessage:e.rawMessage,timestamp:e.timestamp,properties:t};let n=Object.getOwnPropertyDescriptors(e);return n.properties={value:t,enumerable:!0,configurable:!0},Object.defineProperties({},n)}function hasEnumerableProperties(e){return typeof e!=`object`||!e?!1:Object.keys(e).length>0||Object.prototype.propertyIsEnumerable.call(e,c)}function shouldSnapshotForSink(e){return e[l]!==!0}function getLogger(e=[]){return p.getLogger(e)}const f=Symbol.for(`logtape.rootLogger`);function isMetaLoggerCategory(e){return e.length>=2&&e[0]===`logtape`&&e[1]===`meta`}var p=class LoggerImpl{parent;children;category;sinks;filters;contextLocalStorage;#e=`inherit`;#t=`trace`;#n={};static getLogger(e=[]){let t=f in globalThis?globalThis[f]??null:null;return t??(t=new LoggerImpl(null,[]),globalThis[f]=t),typeof e==`string`?t.getChild(e):e.length===0?t:t.getChild(e)}static getNearestExistingLogger(e){let t=LoggerImpl.getLogger();for(let n of e){let e=t.children[n],r=e instanceof LoggerImpl?e:e?.deref();if(r==null)break;t=r}return t}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}get parentSinks(){return this.#e}set parentSinks(e){this.#e!==e&&(this.#e=e)}get lowestLevel(){return this.#t}set lowestLevel(e){this.#t!==e&&(this.#t=e)}getChild(e){let t=typeof e==`string`?e:e[0],n=this.children[t],r=n instanceof LoggerImpl?n:n?.deref();return r??(r=new LoggerImpl(this,[...this.category,t]),this.children[t]=`WeakRef`in globalThis?new WeakRef(r):r),typeof e==`string`||e.length===1?r:r.getChild(e.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let e of Object.values(this.children))(e instanceof LoggerImpl?e:e.deref())?.resetDescendants();this.reset()}with(e){return new m(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){let t=this.getSinkDispatchPlan(e);switch(t.kind){case`none`:return;case`one`:yield t.sink;return;case`many`:yield*t.sinks;return}}getSinkDispatchPlan(e){let t=this.#n[e];if(t!=null&&this.isSinkDispatchPlanFresh(e,t))return t;let n=this.parent!=null&&this.parentSinks===`inherit`?this.parent.getSinkDispatchPlan(e):void 0,r=this.createSinkDispatchPlan(e,n);return this.#n[e]=r,r}isSinkDispatchPlanFresh(e,t){if(t.lowestLevel!==this.lowestLevel||t.parentSinks!==this.parentSinks||t.localSinks.length!==this.sinks.length)return!1;for(let e=0;e<t.localSinks.length;e++)if(t.localSinks[e]!==this.sinks[e])return!1;let n=this.parent!=null&&this.parentSinks===`inherit`?this.parent.getSinkDispatchPlan(e):void 0;return t.parentPlan===n}createSinkDispatchPlan(e,t){let n={localSinks:[...this.sinks],parentSinks:this.parentSinks,lowestLevel:this.lowestLevel,parentPlan:t};if(n.lowestLevel===null||compareLogLevel(e,n.lowestLevel)<0)return{...n,kind:`none`};let r,i,appendSink=e=>{i==null?r==null?r=e:i=[r,e]:i.push(e)};t!=null&&(t.kind===`one`?r=t.sink:t.kind===`many`&&(i=[...t.sinks]));for(let e of n.localSinks)appendSink(e);return i==null?r==null?{...n,kind:`none`}:{...n,kind:`one`,sink:r}:{...n,kind:`many`,sinks:i}}isEnabledFor(e){let t=isMetaLoggerCategory(this.category)?[]:getCategoryPrefix(),n=t.length>0?LoggerImpl.getNearestExistingLogger([...t,...this.category]):this,r=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);return r==null?n.isEnabledForResolved(e):scopedConfigHasSink(r,t.length>0?[...t,...this.category]:this.category,e)}isEnabledForResolved(e){return this.getSinkDispatchPlan(e).kind!==`none`}emit(e,t){let n=`category`in e?e.category:this.category,r=isMetaLoggerCategory(n)?[]:getCategoryPrefix(),i=r.length>0?[...r,...n]:n;if(r.length<1&&Object.prototype.hasOwnProperty.call(e,`category`)){this.emitResolved(e,t);return}let a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);(r.length>0?LoggerImpl.getNearestExistingLogger(i):this).emitResolved(o,t)}emitResolved(e,t){let n=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);if(n!=null){let r,i=!1;emitWithScopedConfig(n,e,t,(t,n)=>{try{if(shouldSnapshotForSink(t))try{r??=snapshotLogRecordProperties(e)}catch{i=!0,r=e}t(r??e)}catch(r){let i=new Set(n);i.add(t),h.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:t,error:r,record:e},i)}i&&(r=e)});return}if(this.lowestLevel===null||compareLogLevel(e.level,this.lowestLevel)<0||!this.filter(e))return;let r=this.getSinkDispatchPlan(e.level);if(r.kind===`none`)return;let i,a=!1;if(r.kind===`one`){let n=r.sink;if(t?.has(n))return;try{if(shouldSnapshotForSink(n))try{i=snapshotLogRecordProperties(e)}catch{a=!0,i=e}n(i??e)}catch(r){let i=new Set(t);i.add(n),h.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:n,error:r,record:e},i)}return}for(let n of r.sinks)if(!t?.has(n))try{if(i==null&&!a&&shouldSnapshotForSink(n))try{i=snapshotLogRecordProperties(e)}catch{a=!0,i=e}n(i??e)}catch(r){let i=new Set(t);i.add(n),h.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:n,error:r,record:e},i)}}log(e,t,n,r){let i=getImplicitContextIfAny();if(typeof n!=`function`&&i==null&&!t.includes(`{`)&&!hasEnumerableProperties(n)){let n={category:this.category,level:e,message:[t],rawMessage:t,timestamp:Date.now(),properties:{}};d.add(n),this.emit(n,r);return}let a,o,s=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i??{},...n()}),a}}:{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i??{},...n}),a}};u.add(s),this.emit(s,r)}logLazily(e,t,n={}){let r=getImplicitContextIfAny(),i,a;function realizeMessage(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,renderMessage(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return realizeMessage()[0]},get rawMessage(){return realizeMessage()[1]},timestamp:Date.now(),properties:{...r??{},...n}})}logTemplate(e,t,n,r={}){let i=getImplicitContextIfAny();this.emit({category:this.category,level:e,message:renderMessage(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i??{},...r}})}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0]);typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0]);typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},m=class LoggerCtx{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(e){return new LoggerCtx(this.logger,{...this.properties,...e})}log(e,t,n,r){let i=this.properties;this.logger.log(e,t,typeof n==`function`?()=>resolveProperties({...i,...n()}):()=>resolveProperties({...i,...n}),r)}logLazily(e,t){this.logger.logLazily(e,t,resolveProperties(this.properties))}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,resolveProperties(this.properties))}emit(e){let t={...e,properties:resolveProperties({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0]);typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0]);typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const h=p.getLogger([`logtape`,`meta`]);function isNestedAccess(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function getOwnProperty(e,t){if(t!==`__proto__`&&t!==`prototype`&&t!==`constructor`&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function parseNextSegment(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
2
+ `;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function accessProperty(e,t){if(typeof t==`string`)return getOwnProperty(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function resolvePropertyPath(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=parseNextSegment(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=accessProperty(n,i),n===void 0)return}return n}function parseMessageTemplate(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&isNestedAccess(u)&&(l=resolvePropertyPath(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function renderMessage(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const g=Symbol.for(`logtape.categoryPrefix`);function getCategoryPrefix(){let e=p.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[g];return Array.isArray(t)?t:[]}function getImplicitContextIfAny(){let e=p.getLogger().contextLocalStorage?.getStore();if(e==null)return;let t=Object.keys(e);if(t.length<1)return;let n={};for(let r of t)n[r]=e[r];return n}var _=t({inspect:()=>inspect$1});function inspect$1(e,t){return n.inspect(e,t)}e(inspect$1,`inspect`);const v={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},y=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):_!=null&&`inspect`in _&&typeof inspect$1==`function`?(e,t)=>inspect$1(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e),inspect=(e,t)=>String(y(e,t)),b=new TextEncoder;function renderMessageParts(e,t){let n=e.length;if(n===1)return e[0];if(n<=6){let r=``;for(let i=0;i<n;i++)r+=i%2==0?e[i]:t(e[i]);return r}let r=Array(n);for(let i=0;i<n;i++)r[i]=i%2==0?e[i]:t(e[i]);return r.join(``)}function padZero(e){return e<10?`0${e}`:`${e}`}function padThree(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const x=/^([+-])(0\d|1\d|2[0-3]):([0-5]\d)$/;function formatOffset(e,t){let n=e<0?`-`:`+`,r=Math.abs(e),i=padZero(Math.floor(r/60)),a=padZero(r%60);return!t&&a===`00`?`${n}${i}`:`${n}${i}:${a}`}function readPartsFromFormatter(e,t){let n=e.formatToParts(new Date(t)),r=``,i=``,a=``,o=``,s=``,c=``;for(let e of n)e.type===`year`?r=e.value:e.type===`month`?i=e.value:e.type===`day`?a=e.value:e.type===`hour`?o=e.value:e.type===`minute`?s=e.value:e.type===`second`&&(c=e.value);return{year:r,month:i,day:a,hour:o,minute:s,second:c}}function getDateParts(e,t){let n=new Date(e),r=padThree(n.getUTCMilliseconds());if(t.kind===`utc`)return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:0};if(t.kind===`local`)return{year:`${n.getFullYear()}`,month:padZero(n.getMonth()+1),day:padZero(n.getDate()),hour:padZero(n.getHours()),minute:padZero(n.getMinutes()),second:padZero(n.getSeconds()),ms:r,offsetMinutes:-n.getTimezoneOffset()};if(t.kind===`offset`){let n=new Date(e+t.minutes*6e4);return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:t.minutes}}let i=readPartsFromFormatter(t.formatter,e),a=Date.UTC(Number(i.year),Number(i.month)-1,Number(i.day),Number(i.hour),Number(i.minute),Number(i.second),n.getUTCMilliseconds()),o=Math.round((a-e)/6e4);return{...i,ms:r,offsetMinutes:o}}function resolveTimeZone(e){if(e===void 0)return{kind:`utc`};if(e===null)return{kind:`local`};let t=x.exec(e);if(t!=null){let e=t[1]===`-`?-1:1,n=Number(t[2]),r=Number(t[3]);return{kind:`offset`,minutes:e*(n*60+r)}}if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. This environment does not support IANA time zones.`);try{return{kind:`iana`,formatter:new Intl.DateTimeFormat(`en-CA`,{timeZone:e,hour12:!1,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}}catch{throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. Expected an IANA time zone name (e.g., "Asia/Seoul") or a fixed UTC offset string (e.g., "+09:00").`)}}function createTimestampFormatter(e,t){return e===`none`?()=>null:e===`rfc3339`&&t.kind===`utc`?e=>new Date(e).toISOString():n=>{let r=getDateParts(n,t),i=`${r.year}-${r.month}-${r.day}`,a=`${r.hour}:${r.minute}:${r.second}.${r.ms}`,o=formatOffset(r.offsetMinutes,!0),s=formatOffset(r.offsetMinutes,!1);return e===`date-time-timezone`?`${i} ${a} ${o}`:e===`date-time-tz`?`${i} ${a} ${s}`:e===`date-time`?`${i} ${a}`:e===`time-timezone`?`${a} ${o}`:e===`time-tz`?`${a} ${s}`:e===`time`?a:e===`date`?i:`${i}T${a}${o}`}}const S={ABBR:v,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function getLineEndingValue(e){return e===`crlf`?`\r
3
3
  `:`
4
- `}function jsonReplacer(e,t){if(!(t instanceof Error))return t;let n={name:t.name,message:t.message};typeof t.stack==`string`&&(n.stack=t.stack);let r=t.cause;r!==void 0&&(n.cause=r),typeof AggregateError<`u`&&t instanceof AggregateError&&(n.errors=t.errors);for(let e of Object.keys(t))e in n||(n[e]=t[e]);return n}function getTextFormatter(e={}){let t=(()=>{let t=e.timestamp,n=resolveTimeZone(e.timeZone);return t==null?createTimestampFormatter(`date-time-timezone`,n):t===`disabled`?createTimestampFormatter(`none`,n):typeof t==`string`&&(t===`date-time-timezone`||t===`date-time-tz`||t===`date-time`||t===`time-timezone`||t===`time-tz`||t===`time`||t===`date`||t===`rfc3339`||t===`none`)?createTimestampFormatter(t,n):t})(),n=e.category??`·`,r=e.value?t=>e.value(t,inspect):inspect,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>g.ABBR[e]:t===`abbr`?e=>g.abbr[e]:t===`FULL`?e=>g.FULL[e]:t===`full`?e=>g.full[e]:t===`L`?e=>g.L[e]:t===`l`?e=>g.l[e]:t})(),a=getLineEndingValue(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=renderMessageParts(e.message,r),c={timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:s,record:e};return`${o(c)}${a}`}}getTextFormatter();const _=`\x1B[0m`,v={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},y={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},b={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function getAnsiColorFormatter(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:y[n]}${r==null?``:v[r]}`,a=n==null&&r==null?``:_,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??b,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:y[c]}${l==null?``:v[l]}`,d=c==null&&l==null?``:_;return getTextFormatter({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:y[o]}${f==null?``:v[f]}${n}${o==null&&f==null?``:_}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}getAnsiColorFormatter();function getJsonLinesFormatter(e={}){let t=getLineEndingValue(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties},jsonReplacer)+t;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties},jsonReplacer)+t;let n=e.message[0];for(let t=1;t<e.message.length;t++)n+=t&1?JSON.stringify(e.message[t]):e.message[t];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:n,logger:e.category.join(`.`),properties:e.properties},jsonReplacer)+t};let n=e.message===`template`,r=e.properties??`nest:properties`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let getProperties;if(r===`flatten`)getProperties=e=>e;else if(r.startsWith(`prepend:`)){let e=r.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);getProperties=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(r.startsWith(`nest:`)){let e=r.substring(5);getProperties=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let i;return i=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)n>0&&(t+=`{}`),t+=e.rawMessage[n];return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:i(e),logger:joinCategory(e.category),...getProperties(e.properties)},jsonReplacer)+t}getJsonLinesFormatter();function renderStructuredMessage(e,t){return t?typeof e.rawMessage==`string`?e.rawMessage:e.rawMessage.join(`{}`):renderMessageParts(e.message,stringifyLogfmtValue)}function filterLogfmtKey(e){if(e===``)return null;let t=!1;for(let n of e)if(shouldEscapeLogfmtKeyChar(n,n.codePointAt(0))){t=!0;break}if(!t)return e;let n=``;for(let t of e)shouldEscapeLogfmtKeyChar(t,t.codePointAt(0))?n+=encodeLogfmtKeyChar(t):n+=t;return n}function shouldEscapeLogfmtKeyChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`%`}function encodeLogfmtKeyChar(e){let t=``;for(let n of m.encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function stringifyLogfmtValue(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||e===void 0||typeof e==`symbol`||typeof e==`function`)return String(e);try{let t=JSON.stringify(e,jsonReplacer);if(typeof t==`string`)return unwrapJsonStringLiteral(t)}catch{}return inspect(e,{colors:!1})}function unwrapJsonStringLiteral(e){return e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e}function quoteLogfmtValue(e,t){let n=e===``||t&&shouldQuoteStringLiteral(e);for(let t of e)if(shouldQuoteLogfmtValueChar(t,t.codePointAt(0))){n=!0;break}if(!n)return e;let r=``;for(let t of e){let e=t.codePointAt(0);r+=escapeLogfmtValueChar(t,e)}return`"${r}"`}function shouldQuoteStringLiteral(e){return e===`null`||e===`undefined`||e===`true`||e===`false`}function shouldQuoteLogfmtValueChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`\\`}function escapeLogfmtValueChar(e,t){switch(e){case` `:return`\\t`;case`
5
- `:return`\\n`;case`\r`:return`\\r`;case`"`:return`\\"`;case`\\`:return`\\\\`;default:return t<=31||t===127?`\\u${t.toString(16).padStart(4,`0`)}`:e}}function formatLogfmtValue(e){return quoteLogfmtValue(stringifyLogfmtValue(e),typeof e==`string`)}function pushLogfmtPair(e,t,n){let r=filterLogfmtKey(t);r!=null&&e.push(`${r}=${formatLogfmtValue(n)}`)}function getLogfmtFormatter(e={}){let t=getLineEndingValue(e.lineEnding),n=createTimestampFormatter(`rfc3339`,resolveTimeZone(e.timeZone)),r=e.message===`template`,i=e.properties??`flatten`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let a=``;if(i===`flatten`)a=``;else if(i.startsWith(`prepend:`)){if(a=i.substring(8),a===``)throw TypeError(`Invalid properties option: `+JSON.stringify(i)+`. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`)}else throw TypeError(`Invalid properties option: ${JSON.stringify(i)}. It must be "flatten" or "prepend:<prefix>".`);return e=>{let i=[];pushLogfmtPair(i,`time`,n(e.timestamp)),pushLogfmtPair(i,`level`,e.level),pushLogfmtPair(i,`logger`,joinCategory(e.category)),pushLogfmtPair(i,`msg`,renderStructuredMessage(e,r));for(let t in e.properties)Object.prototype.hasOwnProperty.call(e.properties,t)&&pushLogfmtPair(i,`${a}${t}`,e.properties[t]);return`${i.join(` `)}${t}`}}getLogfmtFormatter();const x={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function defaultConsoleFormatter(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${f[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,x[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function getConsoleSink(e={}){let t=e.formatter??defaultConsoleFormatter,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,baseSink=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return baseSink;let i=e.nonBlocking===!0?{}:e.nonBlocking,a=i.bufferSize??100,o=i.flushInterval??100,s=[],c=null,l=!1,u=!1,d=a*2;function flush(){if(s.length===0)return;let e=s.splice(0);for(let t of e)try{baseSink(t)}catch{}}function scheduleFlush(){u||(u=!0,setTimeout(()=>{u=!1,flush()},0))}function startFlushTimer(){c!==null||l||(c=setInterval(()=>{flush()},o))}let nonBlockingSink=e=>{l||(s.length>=d&&s.shift(),s.push(e),s.length>=a?scheduleFlush():c===null&&startFlushTimer())};return nonBlockingSink[Symbol.dispose]=()=>{l=!0,c!==null&&(clearInterval(c),c=null),flush()},nonBlockingSink}let S=null;const C=new Set,w=new Set,T=new Set,E=new Set,D=new Set;function isLoggerConfigMeta(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function registerDisposeHook(e){let t=e?dispose:disposeSync;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t);return}}let n=globalThis.addEventListener;typeof n==`function`&&(`Deno`in globalThis?n.call(globalThis,`unload`,t):n.call(globalThis,`pagehide`,t))}function configureSync(e){if(S!=null&&!e.reset)throw new ConfigError(`Already configured; if you want to reset, turn on the reset flag.`);if(E.size>0||D.size>0)throw new ConfigError(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);resetSync();try{configureInternal(e,!1)}catch(e){throw e instanceof ConfigError&&resetSync(),e}}function configureInternal(e,t){S=e;let n=!1,r=new Set;for(let t of e.loggers){isLoggerConfigMeta(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new ConfigError(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=s.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new ConfigError(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new ConfigError(`Filter not found: ${n}.`);a.filters.push(toFilter(t))}C.add(a)}s.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)D.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&T.add(n)}for(let n of Object.values(e.filters??{}))if(n!=null&&typeof n!=`string`){if(Symbol.asyncDispose in n){if(t)E.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`);D.delete(n)}Symbol.dispose in n&&(w.add(n),T.delete(n))}registerDisposeHook(t);let i=s.getLogger([`logtape`,`meta`]);n||i.sinks.push(getConsoleSink()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function resetSync(){disposeSync(),resetInternal()}function resetInternal(){let e=s.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,C.clear(),S=null}async function dispose(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{await disposeAsyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}try{await disposeAsyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSync(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSyncFilters(){disposeSyncDisposables(w)}function disposeSyncSinks(){disposeSyncDisposables(T)}function disposeSyncDisposables(e){let t=[];try{for(let n of e)try{n[Symbol.dispose]()}catch(e){t.push(e)}finally{e.delete(n)}}finally{e.clear()}throwDisposeErrors(t)}async function disposeAsyncFilters(){await disposeAsyncDisposables(E)}async function disposeAsyncSinks(){await disposeAsyncDisposables(D)}async function disposeAsyncDisposables(e){let t=[];try{for(let n of e)try{t.push(Promise.resolve(n[Symbol.asyncDispose]()))}catch(e){t.push(Promise.reject(e))}finally{e.delete(n)}}finally{e.clear()}await settleDisposePromises(t)}async function settleDisposePromises(e){throwDisposeErrors((await Promise.allSettled(e)).filter(e=>e.status===`rejected`).map(e=>e.reason))}function throwDisposeErrors(e){if(!(e.length<1))throw e.length===1?e[0]:AggregateError(e,`Multiple errors occurred while disposing LogTape resources.`)}var ConfigError=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{getLogger as a,getTextFormatter as i,getConsoleSink as n,getAnsiColorFormatter as r,configureSync as t};
4
+ `}function jsonReplacer(e,t){if(!(t instanceof Error))return t;let n={name:t.name,message:t.message};typeof t.stack==`string`&&(n.stack=t.stack);let r=t.cause;r!==void 0&&(n.cause=r),typeof AggregateError<`u`&&t instanceof AggregateError&&(n.errors=t.errors);for(let e of Object.keys(t))e in n||(n[e]=t[e]);return n}function renderDefaultJsonLinesMessage(e){let t=e.length;if(t===1)return e[0];if(t===3)return e[0]+JSON.stringify(e[1])+e[2];let n=e[0];for(let r=1;r<t;r++)n+=r&1?JSON.stringify(e[r]):e[r];return n}function stringifyJsonLinesField(e,t){if(t!=null&&(typeof t==`object`||typeof t==`function`||typeof t==`bigint`)){let n=t.toJSON;typeof n==`function`&&(t=n.call(t,e))}return JSON.stringify(jsonReplacer(e,t),jsonReplacer)}function formatDefaultJsonLinesRecord(e,t){let n=e.level===`warning`?`WARN`:e.level.toUpperCase(),r=stringifyJsonLinesField(`message`,renderDefaultJsonLinesMessage(e.message)),i=stringifyJsonLinesField(`properties`,e.properties),a=`{"@timestamp":${JSON.stringify(new Date(e.timestamp).toISOString())},"level":${JSON.stringify(n)}`;return r!==void 0&&(a+=`,"message":${r}`),a+=`,"logger":${JSON.stringify(e.category.join(`.`))}`,i!==void 0&&(a+=`,"properties":${i}`),`${a}}${t}`}function getTextFormatter(e={}){let t=(()=>{let t=e.timestamp,n=resolveTimeZone(e.timeZone);return t==null?createTimestampFormatter(`date-time-timezone`,n):t===`disabled`?createTimestampFormatter(`none`,n):typeof t==`string`&&(t===`date-time-timezone`||t===`date-time-tz`||t===`date-time`||t===`time-timezone`||t===`time-tz`||t===`time`||t===`date`||t===`rfc3339`||t===`none`)?createTimestampFormatter(t,n):t})(),n=e.category??`·`,r=e.value?t=>e.value(t,inspect):inspect,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>S.ABBR[e]:t===`abbr`?e=>S.abbr[e]:t===`FULL`?e=>S.FULL[e]:t===`full`?e=>S.full[e]:t===`L`?e=>S.L[e]:t===`l`?e=>S.l[e]:t})(),a=getLineEndingValue(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=renderMessageParts(e.message,r),c={timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:s,record:e};return`${o(c)}${a}`}}getTextFormatter();const C=`\x1B[0m`,w={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},T={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},E={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function getAnsiColorFormatter(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:T[n]}${r==null?``:w[r]}`,a=n==null&&r==null?``:C,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??E,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:T[c]}${l==null?``:w[l]}`,d=c==null&&l==null?``:C;return getTextFormatter({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:T[o]}${f==null?``:w[f]}${n}${o==null&&f==null?``:C}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}getAnsiColorFormatter();function getJsonLinesFormatter(e={}){let t=getLineEndingValue(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>formatDefaultJsonLinesRecord(e,t);let n=e.message===`template`,r=e.properties??`nest:properties`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let getProperties;if(r===`flatten`)getProperties=e=>e;else if(r.startsWith(`prepend:`)){let e=r.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);getProperties=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(r.startsWith(`nest:`)){let e=r.substring(5);getProperties=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let i;return i=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)n>0&&(t+=`{}`),t+=e.rawMessage[n];return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:i(e),logger:joinCategory(e.category),...getProperties(e.properties)},jsonReplacer)+t}getJsonLinesFormatter();function renderStructuredMessage(e,t){return t?typeof e.rawMessage==`string`?e.rawMessage:e.rawMessage.join(`{}`):renderMessageParts(e.message,stringifyLogfmtValue)}function filterLogfmtKey(e){if(e===``)return null;let t=!1;for(let n of e)if(shouldEscapeLogfmtKeyChar(n,n.codePointAt(0))){t=!0;break}if(!t)return e;let n=``;for(let t of e)shouldEscapeLogfmtKeyChar(t,t.codePointAt(0))?n+=encodeLogfmtKeyChar(t):n+=t;return n}function shouldEscapeLogfmtKeyChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`%`}function encodeLogfmtKeyChar(e){let t=``;for(let n of b.encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function stringifyLogfmtValue(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||e===void 0||typeof e==`symbol`||typeof e==`function`)return String(e);try{let t=JSON.stringify(e,jsonReplacer);if(typeof t==`string`)return unwrapJsonStringLiteral(t)}catch{}return inspect(e,{colors:!1})}function unwrapJsonStringLiteral(e){return e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e}function quoteLogfmtValue(e,t){let n=e===``||t&&shouldQuoteStringLiteral(e);for(let t of e)if(shouldQuoteLogfmtValueChar(t,t.codePointAt(0))){n=!0;break}if(!n)return e;let r=``;for(let t of e){let e=t.codePointAt(0);r+=escapeLogfmtValueChar(t,e)}return`"${r}"`}function shouldQuoteStringLiteral(e){return e===`null`||e===`undefined`||e===`true`||e===`false`}function shouldQuoteLogfmtValueChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`\\`}function escapeLogfmtValueChar(e,t){switch(e){case` `:return`\\t`;case`
5
+ `:return`\\n`;case`\r`:return`\\r`;case`"`:return`\\"`;case`\\`:return`\\\\`;default:return t<=31||t===127?`\\u${t.toString(16).padStart(4,`0`)}`:e}}function formatLogfmtValue(e){return quoteLogfmtValue(stringifyLogfmtValue(e),typeof e==`string`)}function pushLogfmtPair(e,t,n){let r=filterLogfmtKey(t);r!=null&&e.push(`${r}=${formatLogfmtValue(n)}`)}function getLogfmtFormatter(e={}){let t=getLineEndingValue(e.lineEnding),n=createTimestampFormatter(`rfc3339`,resolveTimeZone(e.timeZone)),r=e.message===`template`,i=e.properties??`flatten`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let a=``;if(i===`flatten`)a=``;else if(i.startsWith(`prepend:`)){if(a=i.substring(8),a===``)throw TypeError(`Invalid properties option: `+JSON.stringify(i)+`. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`)}else throw TypeError(`Invalid properties option: ${JSON.stringify(i)}. It must be "flatten" or "prepend:<prefix>".`);return e=>{let i=[];pushLogfmtPair(i,`time`,n(e.timestamp)),pushLogfmtPair(i,`level`,e.level),pushLogfmtPair(i,`logger`,joinCategory(e.category)),pushLogfmtPair(i,`msg`,renderStructuredMessage(e,r));for(let t in e.properties)Object.prototype.hasOwnProperty.call(e.properties,t)&&pushLogfmtPair(i,`${a}${t}`,e.properties[t]);return`${i.join(` `)}${t}`}}getLogfmtFormatter();const D={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function defaultConsoleFormatter(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${v[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,D[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function getConsoleSink(e={}){let t=e.formatter??defaultConsoleFormatter,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,baseSink=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return baseSink;let i=e.nonBlocking===!0?{}:e.nonBlocking,a=i.bufferSize??100,o=i.flushInterval??100,s=[],c=null,l=null,u=!1,d=!1,f=a*2;function flush(){if(s.length===0)return;let e=s.splice(0);for(let t of e)try{baseSink(t)}catch{}}function scheduleFlush(){d||(d=!0,l=setTimeout(()=>{l=null,d=!1,flush()},0))}function startFlushTimer(){c!==null||u||(c=setInterval(()=>{flush()},o))}let nonBlockingSink=e=>{u||(s.length>=f&&s.shift(),s.push(e),s.length>=a?scheduleFlush():c===null&&startFlushTimer())};return nonBlockingSink[Symbol.dispose]=()=>{u=!0,c!==null&&(clearInterval(c),c=null),l!==null&&(clearTimeout(l),l=null,d=!1),flush()},nonBlockingSink}let O=null,k=!1;const A=new Set,j=new Set,M=new Set,N=new Set,P=new Set;let unregisterDisposeHook;function isLoggerConfigMeta(e){let t=Array.isArray(e.category)?e.category:[e.category];return t.length===0||t.length===1&&t[0]===`logtape`||t.length===2&&t[0]===`logtape`&&t[1]===`meta`}function registerDisposeHook(e){unregisterDisposeHook?.(),unregisterDisposeHook=void 0;let t=e?disposeInternal:disposeSyncInternal;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t),unregisterDisposeHook=()=>{let n=e?.off??e?.removeListener;typeof n==`function`&&n.call(e,`exit`,t)};return}}let n=globalThis.addEventListener;if(typeof n!=`function`)return;let r=globalThis.removeEventListener;`Deno`in globalThis?(n.call(globalThis,`unload`,t),typeof r==`function`&&(unregisterDisposeHook=()=>{r.call(globalThis,`unload`,t)})):(n.call(globalThis,`pagehide`,t),typeof r==`function`&&(unregisterDisposeHook=()=>{r.call(globalThis,`pagehide`,t)}))}function configureSync(e){runGlobalConfigMutationSync(`configureSync()`,()=>{if(O!=null&&!e.reset)throw new ConfigError(`Already configured; if you want to reset, turn on the reset flag.`);if(N.size>0||P.size>0)throw new ConfigError(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);disposeSyncInternal(),resetInternal();try{configureInternal(e,!1)}catch(e){throw e instanceof ConfigError&&(disposeSyncInternal(),resetInternal()),e}})}function configureInternal(e,t){O=e;let n=!1,r=new Set;for(let t of e.loggers){isLoggerConfigMeta(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new ConfigError(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=p.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new ConfigError(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new ConfigError(`Filter not found: ${n}.`);a.filters.push(toFilter(t))}A.add(a)}p.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n){if(t)P.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`)}Symbol.dispose in n&&M.add(n)}for(let n of Object.values(e.filters??{}))if(n!=null&&typeof n!=`string`){if(Symbol.asyncDispose in n){if(t)N.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`);P.delete(n)}Symbol.dispose in n&&(j.add(n),M.delete(n))}registerDisposeHook(t);let i=p.getLogger([`logtape`,`meta`]);n||i.sinks.push(getConsoleSink()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function resetInternal(){unregisterDisposeHook?.(),unregisterDisposeHook=void 0;let e=p.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,A.clear(),O=null}async function disposeInternal(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{await disposeAsyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}try{await disposeAsyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSyncInternal(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function runGlobalConfigMutationSync(e,t){assertCanMutateGlobalConfig(e),k=!0;try{return t()}finally{k=!1}}function assertCanMutateGlobalConfig(e){if(k)throw new ConfigError(`${e} cannot be called while LogTape is being reconfigured.`)}function disposeSyncFilters(){disposeSyncDisposables(j)}function disposeSyncSinks(){disposeSyncDisposables(M)}function disposeSyncDisposables(e){let t=[];try{for(let n of e)try{n[Symbol.dispose]()}catch(e){t.push(e)}finally{e.delete(n)}}finally{e.clear()}throwDisposeErrors(t)}async function disposeAsyncFilters(){await disposeAsyncDisposables(N)}async function disposeAsyncSinks(){await disposeAsyncDisposables(P)}async function disposeAsyncDisposables(e){let t=[];try{for(let n of e)try{t.push(Promise.resolve(n[Symbol.asyncDispose]()))}catch(e){t.push(Promise.reject(e))}finally{e.delete(n)}}finally{e.clear()}await settleDisposePromises(t)}async function settleDisposePromises(e){throwDisposeErrors((await Promise.allSettled(e)).filter(e=>e.status===`rejected`).map(e=>e.reason))}function throwDisposeErrors(e){if(!(e.length<1))throw e.length===1?e[0]:AggregateError(e,`Multiple errors occurred while disposing LogTape resources.`)}var ConfigError=class extends Error{constructor(e){super(e),this.name=`ConfigError`}};export{getTextFormatter as a,getAnsiColorFormatter as i,getConsoleSink as n,getLogger as o,defaultConsoleFormatter as r,configureSync as t};
@@ -1 +1 @@
1
- import"../../rolldown-runtime.mjs";function createMap(){return new e}var e=class IndexedMap{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,n){let r=this.index[e.id()];if(r===void 0){let r=new t(e,n());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[r]}insert(e,n){let r=new t(e,n),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let e=new IndexedMap;for(let t=0;t<this.array.length;t++){let n=this.array[t].copy();e.array[t]=n,e.index[n.first.id()]=t}return e}},t=class Pair{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new Pair(this.first,this.second)}},Variable=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new r(this,e)}minus(e){return new r(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new r([e,this])}divide(e){return new r([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=n++};let n=0;var r=class Expression{constructor(){let e=parseArgs(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(e){return new Expression(this,e)}minus(e){return new Expression(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new Expression([e,this])}divide(e){return new Expression([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function parseArgs(e){let t=0,factory=()=>0,n=createMap();for(let i=0,a=e.length;i<a;++i){let a=e[i];if(typeof a==`number`)t+=a;else if(a instanceof Variable)n.setDefault(a,factory).second+=1;else if(a instanceof r){t+=a.constant();let e=a.terms();for(let t=0,r=e.size();t<r;t++){let r=e.itemAt(t);n.setDefault(r.first,factory).second+=r.second}}else if(a instanceof Array){if(a.length!==2)throw Error(`array must have length 2`);let e=a[0],i=a[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(i instanceof Variable)n.setDefault(i,factory).second+=e;else if(i instanceof r){t+=i.constant()*e;let r=i.terms();for(let t=0,i=r.size();t<i;t++){let i=r.itemAt(t);n.setDefault(i.first,factory).second+=i.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+a)}return{terms:n,constant:t}}var i=class Strength{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=Strength.create(1e3,1e3,1e3);static strong=Strength.create(1,0,0);static medium=Strength.create(0,1,0);static weak=Strength.create(0,0,1);static clip(e){return Math.max(0,Math.min(Strength.required,e))}},a;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(a||={});var Constraint=class{constructor(e,t,n,a=i.required){this._operator=t,this._strength=i.clip(a),n===void 0&&e instanceof r?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=o++};let o=0;var Solver=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=i.required){let a=new Constraint(e,t,n,r);return this.addConstraint(a),a}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===s.Invalid&&n.allDummies())if(nearZero(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`);if(i.type()===s.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===s.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=i.clip(t),t===i.required)throw Error(`bad required strength`);let n=new Constraint(new r(e),a.Eq,void 0,t);this.addConstraint(n);let o={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,o)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,c=r.find(o);if(c!==void 0){c.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let l=i.tag.other;if(c=r.find(l),c!==void 0){c.second.add(a)<0&&this._infeasibleRows.push(l),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==s.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){let factory=()=>this._makeSymbol(s.External);return this._varMap.setDefault(e,factory).second}_createRow(e){let t=e.expression(),n=new l(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!nearZero(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let o=this._objective,u=e.strength(),d={marker:c,other:c};switch(e.op()){case a.Le:case a.Ge:{let t=e.op()===a.Le?1:-1,r=this._makeSymbol(s.Slack);if(d.marker=r,n.insertSymbol(r,t),u<i.required){let e=this._makeSymbol(s.Error);d.other=e,n.insertSymbol(e,-t),o.insertSymbol(e,u)}break}case a.Eq:if(u<i.required){let e=this._makeSymbol(s.Error),t=this._makeSymbol(s.Error);d.marker=e,d.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),o.insertSymbol(e,u),o.insertSymbol(t,u)}else{let e=this._makeSymbol(s.Dummy);d.marker=e,n.insertSymbol(e)}break}return n.constant()<0&&n.reverseSign(),{row:n,tag:d}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===s.External)return t.first}let r=t.marker.type();return(r===s.Slack||r===s.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===s.Slack||r===s.Error)&&e.coefficientFor(t.other)<0?t.other:c)}_addWithArtificialVariable(e){let t=this._makeSymbol(s.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=nearZero(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===s.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==s.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===s.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===s.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===s.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==s.Dummy)return r}return c}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=c,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==s.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=c,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==s.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=c,a=i,o=i,l=i,u=this._rowMap;for(let t=0,i=u.size();t<i;++t){let i=u.itemAt(t),c=i.second,d=c.coefficientFor(e);if(d===0)continue;let f=i.first;if(f.type()===s.External)l=f;else if(d<0){let e=-c.constant()/d;e<n&&(n=e,a=f)}else{let e=c.constant()/d;e<r&&(r=e,o=f)}}return a===i?o===i?l:o:a}_removeConstraintEffects(e,t){t.marker.type()===s.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===s.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===s.Slack||r===s.Error)return n.first}return c}_makeSymbol(e){return new Symbol(e,this._idTick++)}_cnMap=createCnMap();_rowMap=createRowMap();_varMap=createVarMap();_editMap=createEditMap();_infeasibleRows=[];_objective=new l;_artificial=null;_idTick=0};function nearZero(e){let t=1e-8;return e<0?-e<t:e<t}function createCnMap(){return createMap()}function createRowMap(){return createMap()}function createVarMap(){return createMap()}function createEditMap(){return createMap()}var s;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(s||={});var Symbol=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let c=new Symbol(s.Invalid,-1);var l=class Row{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==s.Dummy)return!1;return!0}copy(){let e=new Row(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);nearZero(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=createMap();_constant};export{Variable as a,i,Constraint as n,a as r,Solver as t};
1
+ import"../../rolldown-runtime.mjs";function createMap(){return new e}var e=class IndexedMap{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,n){let r=this.index[e.id()];if(r===void 0){let r=new t(e,n());return this.index[e.id()]=this.array.length,this.array.push(r),r}return this.array[r]}insert(e,n){let r=new t(e,n),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let e=new IndexedMap;for(let t=0;t<this.array.length;t++){let n=this.array[t].copy();e.array[t]=n,e.index[n.first.id()]=t}return e}},t=class Pair{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new Pair(this.first,this.second)}},Variable=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new r(this,e)}minus(e){return new r(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new r([e,this])}divide(e){return new r([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=n++};let n=0;var r=class Expression{constructor(){let e=parseArgs(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(e){return new Expression(this,e)}minus(e){return new Expression(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new Expression([e,this])}divide(e){return new Expression([1/e,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function parseArgs(e){let t=0,factory=()=>0,n=createMap();for(let i=0,a=e.length;i<a;++i){let a=e[i];if(typeof a==`number`)t+=a;else if(a instanceof Variable)n.setDefault(a,factory).second+=1;else if(a instanceof r){t+=a.constant();let e=a.terms();for(let t=0,r=e.size();t<r;t++){let r=e.itemAt(t);n.setDefault(r.first,factory).second+=r.second}}else if(a instanceof Array){if(a.length!==2)throw Error(`array must have length 2`);let e=a[0],i=a[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(i instanceof Variable)n.setDefault(i,factory).second+=e;else if(i instanceof r){t+=i.constant()*e;let r=i.terms();for(let t=0,i=r.size();t<i;t++){let i=r.itemAt(t);n.setDefault(i.first,factory).second+=i.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+a)}return{terms:n,constant:t}}var i=class Strength{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=Strength.create(1e3,1e3,1e3);static strong=Strength.create(1,0,0);static medium=Strength.create(0,1,0);static weak=Strength.create(0,0,1);static clip(e){return Math.max(0,Math.min(Strength.required,e))}},a;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(a||={});var Constraint=class{constructor(e,t,n,a=i.required){this._operator=t,this._strength=i.clip(a),this._expression=n===void 0&&e instanceof r?e:e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=o++};let o=0;var Solver=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=i.required){let a=new Constraint(e,t,n,r);return this.addConstraint(a),a}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===s.Invalid&&n.allDummies()){if(nearZero(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`)}if(i.type()===s.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===s.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=i.clip(t),t===i.required)throw Error(`bad required strength`);let n=new Constraint(new r(e),a.Eq,void 0,t);this.addConstraint(n);let o={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,o)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,c=r.find(o);if(c!==void 0){c.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let l=i.tag.other;if(c=r.find(l),c!==void 0){c.second.add(a)<0&&this._infeasibleRows.push(l),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==s.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){let factory=()=>this._makeSymbol(s.External);return this._varMap.setDefault(e,factory).second}_createRow(e){let t=e.expression(),n=new l(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!nearZero(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let o=this._objective,u=e.strength(),d={marker:c,other:c};switch(e.op()){case a.Le:case a.Ge:{let t=e.op()===a.Le?1:-1,r=this._makeSymbol(s.Slack);if(d.marker=r,n.insertSymbol(r,t),u<i.required){let e=this._makeSymbol(s.Error);d.other=e,n.insertSymbol(e,-t),o.insertSymbol(e,u)}break}case a.Eq:if(u<i.required){let e=this._makeSymbol(s.Error),t=this._makeSymbol(s.Error);d.marker=e,d.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),o.insertSymbol(e,u),o.insertSymbol(t,u)}else{let e=this._makeSymbol(s.Dummy);d.marker=e,n.insertSymbol(e)}}return n.constant()<0&&n.reverseSign(),{row:n,tag:d}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===s.External)return t.first}let r=t.marker.type();return(r===s.Slack||r===s.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===s.Slack||r===s.Error)&&e.coefficientFor(t.other)<0?t.other:c)}_addWithArtificialVariable(e){let t=this._makeSymbol(s.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=nearZero(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===s.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==s.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===s.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===s.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===s.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==s.Dummy)return r}return c}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=c,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==s.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=c,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==s.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=c,a=i,o=i,l=i,u=this._rowMap;for(let t=0,i=u.size();t<i;++t){let i=u.itemAt(t),c=i.second,d=c.coefficientFor(e);if(d===0)continue;let f=i.first;if(f.type()===s.External)l=f;else if(d<0){let e=-c.constant()/d;e<n&&(n=e,a=f)}else{let e=c.constant()/d;e<r&&(r=e,o=f)}}return a===i?o===i?l:o:a}_removeConstraintEffects(e,t){t.marker.type()===s.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===s.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===s.Slack||r===s.Error)return n.first}return c}_makeSymbol(e){return new Symbol(e,this._idTick++)}_cnMap=createCnMap();_rowMap=createRowMap();_varMap=createVarMap();_editMap=createEditMap();_infeasibleRows=[];_objective=new l;_artificial=null;_idTick=0};function nearZero(e){let t=1e-8;return e<0?-e<t:e<t}function createCnMap(){return createMap()}function createRowMap(){return createMap()}function createVarMap(){return createMap()}function createEditMap(){return createMap()}var s;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(s||={});var Symbol=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let c=new Symbol(s.Invalid,-1);var l=class Row{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==s.Dummy)return!1;return!0}copy(){let e=new Row(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);nearZero(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=createMap();_constant};export{Variable as a,i,Constraint as n,a as r,Solver as t};
@@ -1 +1 @@
1
- import"../rolldown-runtime.mjs";function createPromiseWithResolvers(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const e=Math.random.bind(Math);function nanoid(t=21){let n=``,r=t;for(;r--;)n+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[e()*64|0];return n}const defaultSerialize=e=>e,t=defaultSerialize,{clearTimeout:n,setTimeout:r}=globalThis;function createBirpc(e,i){let{post:a,on:o,off=()=>{},eventNames:s=[],serialize:c=defaultSerialize,deserialize:l=t,resolver:u,bind:d=`rpc`,timeout:f=6e4,proxify:p=!0}=i,m=!1,h=new Map,g,_;async function _call(e,t,o,s){if(m)throw Error(`[birpc] rpc is closed, cannot call "${e}"`);let l={m:e,a:t,t:`q`};s&&(l.o=!0);let send=async e=>a(c(e));if(o){await send(l);return}if(g)try{await g}finally{g=void 0}let{promise:u,resolve:d,reject:p}=createPromiseWithResolvers(),v=nanoid();l.i=v;let y;async function handler(n=l){return f>=0&&(y=r(()=>{try{if(i.onTimeoutError?.call(_,e,t)!==!0)throw Error(`[birpc] timeout on calling "${e}"`)}catch(e){p(e)}h.delete(v)},f),typeof y==`object`&&(y=y.unref?.())),h.set(v,{resolve:d,reject:p,timeoutId:y,method:e}),await send(n),u}try{i.onRequest?await i.onRequest.call(_,l,handler,d):await handler()}catch(e){if(i.onGeneralError?.call(_,e)!==!0)throw e;return}finally{n(y),h.delete(v)}return u}let v={$call:(e,...t)=>_call(e,t,!1),$callOptional:(e,...t)=>_call(e,t,!1,!0),$callEvent:(e,...t)=>_call(e,t,!0),$callRaw:e=>_call(e.method,e.args,e.event,e.optional),$rejectPendingCalls,get $closed(){return m},get $meta(){return i.meta},$close,$functions:e};_=p?new Proxy({},{get(t,n){if(Object.prototype.hasOwnProperty.call(v,n))return v[n];if(n===`then`&&!s.includes(`then`)&&!(`then`in e))return;let sendEvent=(...e)=>_call(n,e,!0);if(s.includes(n))return sendEvent.asEvent=sendEvent,sendEvent;let sendCall=(...e)=>_call(n,e,!1);return sendCall.asEvent=sendEvent,sendCall}}):v;function $close(e){m=!0,h.forEach(({reject:t,method:n})=>{let r=Error(`[birpc] rpc is closed, cannot call "${n}"`);if(e)return e.cause??=r,t(e);t(r)}),h.clear(),off(onMessage)}function $rejectPendingCalls(e){let t=Array.from(h.values()).map(({method:t,reject:n})=>e?e({method:t,reject:n}):n(Error(`[birpc]: rejected pending call "${t}".`)));return h.clear(),t}async function onMessage(t,...r){let o;try{o=l(t)}catch(e){if(i.onGeneralError?.call(_,e)!==!0)throw e;return}if(o.t===`q`){let{m:t,a:n,o:s}=o,l,f,fn=await(u?u.call(_,t,e[t]):e[t]);if(s&&(fn||=()=>void 0),!fn)f=Error(`[birpc] function "${t}" not found`);else try{l=await fn.apply(d===`rpc`?_:e,n)}catch(e){f=e}if(o.i){if(f&&i.onFunctionError&&i.onFunctionError.call(_,f,t,n)===!0)return;if(!f)try{await a(c({t:`s`,i:o.i,r:l}),...r);return}catch(e){if(f=e,i.onGeneralError?.call(_,e,t,n)!==!0)throw e}try{await a(c({t:`s`,i:o.i,e:f}),...r)}catch(e){if(i.onGeneralError?.call(_,e,t,n)!==!0)throw e}}}else{let{i:e,r:t,e:r}=o,i=h.get(e);i&&(n(i.timeoutId),r?i.reject(r):i.resolve(t)),h.delete(e)}}return g=o(onMessage),_}export{createBirpc as t};
1
+ import"../rolldown-runtime.mjs";function createPromiseWithResolvers(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const e=Math.random.bind(Math);function nanoid(t=21){let n=``,r=t;for(;r--;)n+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[e()*64|0];return n}const defaultSerialize=e=>e,t=defaultSerialize,{clearTimeout:n,setTimeout:r}=globalThis;function createBirpc(e,i){let{post:a,on:o,off=()=>{},eventNames:s=[],serialize:c=defaultSerialize,deserialize:l=t,resolver:u,bind:d=`rpc`,timeout:f=6e4,proxify:p=!0}=i,m=!1,h=new Map,g,_;async function _call(e,t,o,s){if(m)throw Error(`[birpc] rpc is closed, cannot call "${e}"`);let l={m:e,a:t,t:`q`};s&&(l.o=!0);let send=async e=>a(c(e));if(o){await send(l);return}if(g)try{await g}finally{g=void 0}let{promise:u,resolve:d,reject:p}=createPromiseWithResolvers(),v=nanoid();l.i=v;let y;async function handler(n=l){return f>=0&&(y=r(()=>{try{if(i.onTimeoutError?.call(_,e,t)!==!0)throw Error(`[birpc] timeout on calling "${e}"`)}catch(e){p(e)}h.delete(v)},f),typeof y==`object`&&(y=y.unref?.())),h.set(v,{resolve:d,reject:p,timeoutId:y,method:e}),await send(n),u}try{i.onRequest?await i.onRequest.call(_,l,handler,d):await handler()}catch(e){if(i.onGeneralError?.call(_,e)!==!0)throw e;return}finally{n(y),h.delete(v)}return u}let v={$call:(e,...t)=>_call(e,t,!1),$callOptional:(e,...t)=>_call(e,t,!1,!0),$callEvent:(e,...t)=>_call(e,t,!0),$callRaw:e=>_call(e.method,e.args,e.event,e.optional),$rejectPendingCalls,get $closed(){return m},get $meta(){return i.meta},$close,$functions:e};_=p?new Proxy({},{get(t,n){if(Object.hasOwn(v,n))return v[n];if(n===`then`&&!s.includes(`then`)&&!(`then`in e))return;let sendEvent=(...e)=>_call(n,e,!0);if(s.includes(n))return sendEvent.asEvent=sendEvent,sendEvent;let sendCall=(...e)=>_call(n,e,!1);return sendCall.asEvent=sendEvent,sendCall}}):v;function $close(e){m=!0,h.forEach(({reject:t,method:n})=>{let r=Error(`[birpc] rpc is closed, cannot call "${n}"`);if(e)return e.cause??=r,t(e);t(r)}),h.clear(),off(onMessage)}function $rejectPendingCalls(e){let t=Array.from(h.values()).map(({method:t,reject:n})=>e?e({method:t,reject:n}):n(Error(`[birpc]: rejected pending call "${t}".`)));return h.clear(),t}async function onMessage(t,...r){let o;try{o=l(t)}catch(e){if(i.onGeneralError?.call(_,e)!==!0)throw e;return}if(o.t===`q`){let{m:t,a:n,o:s}=o,l,f,fn=await(u?u.call(_,t,e[t]):e[t]);if(s&&(fn||=()=>void 0),!fn)f=Error(`[birpc] function "${t}" not found`);else try{l=await fn.apply(d===`rpc`?_:e,n)}catch(e){f=e}if(o.i){if(f&&i.onFunctionError&&i.onFunctionError.call(_,f,t,n)===!0)return;if(!f)try{await a(c({t:`s`,i:o.i,r:l}),...r);return}catch(e){if(f=e,i.onGeneralError?.call(_,e,t,n)!==!0)throw e}try{await a(c({t:`s`,i:o.i,e:f}),...r)}catch(e){if(i.onGeneralError?.call(_,e,t,n)!==!0)throw e}}}else{let{i:e,r:t,e:r}=o,i=h.get(e);i&&(n(i.timeoutId),r?i.reject(r):i.resolve(t)),h.delete(e)}}return g=o(onMessage),_}export{createBirpc as t};
@@ -1,2 +1,2 @@
1
- import"../rolldown-runtime.mjs";import{c as e,d as t,f as n,h as r,l as i,o as a,p as o,u as s}from"./@chevrotain/gast.mjs";import{c,i as l,r as u,s as d}from"./chevrotain.mjs";function arrayMap(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function listCacheClear(){this.__data__=[],this.size=0}function eq(e,t){return e===t||e!==e&&t!==t}function assocIndexOf(e,t){for(var n=e.length;n--;)if(eq(e[n][0],t))return n;return-1}var f=Array.prototype.splice;function listCacheDelete(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?!1:(n==t.length-1?t.pop():f.call(t,n,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?void 0:t[n][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function ListCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}var p=typeof global==`object`&&global&&global.Object===Object&&global,m=typeof self==`object`&&self&&self.Object===Object&&self,h=p||m||Function(`return this`)(),g=h.Symbol,_=Object.prototype,v=_.hasOwnProperty,y=_.toString,b=g?g.toStringTag:void 0;function getRawTag(e){var t=v.call(e,b),n=e[b];try{e[b]=void 0;var r=!0}catch{}var i=y.call(e);return r&&(t?e[b]=n:delete e[b]),i}var ee=Object.prototype.toString;function objectToString(e){return ee.call(e)}var te=`[object Null]`,ne=`[object Undefined]`,re=g?g.toStringTag:void 0;function baseGetTag(e){return e==null?e===void 0?ne:te:re&&re in Object(e)?getRawTag(e):objectToString(e)}function isObject(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var ie=`[object AsyncFunction]`,ae=`[object Function]`,oe=`[object GeneratorFunction]`,se=`[object Proxy]`;function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==ae||t==oe||t==ie||t==se}var x=h[`__core-js_shared__`],S=function(){var e=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function isMasked(e){return!!S&&S in e}var ce=Function.prototype.toString;function toSource(e){if(e!=null){try{return ce.call(e)}catch{}try{return e+``}catch{}}return``}var le=/[\\^$.*+?()[\]{}|]/g,ue=/^\[object .+?Constructor\]$/,de=Function.prototype,fe=Object.prototype,pe=de.toString,me=fe.hasOwnProperty,he=RegExp(`^`+pe.call(me).replace(le,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function baseIsNative(e){return!isObject(e)||isMasked(e)?!1:(isFunction(e)?he:ue).test(toSource(e))}function getValue(e,t){return e?.[t]}function getNative(e,t){var n=getValue(e,t);return baseIsNative(n)?n:void 0}var C=getNative(h,`Map`),w=getNative(Object,`create`);function hashClear(){this.__data__=w?w(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var ge=`__lodash_hash_undefined__`,_e=Object.prototype.hasOwnProperty;function hashGet(e){var t=this.__data__;if(w){var n=t[e];return n===ge?void 0:n}return _e.call(t,e)?t[e]:void 0}var ve=Object.prototype.hasOwnProperty;function hashHas(e){var t=this.__data__;return w?t[e]!==void 0:ve.call(t,e)}var ye=`__lodash_hash_undefined__`;function hashSet(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=w&&t===void 0?ye:t,this}function Hash(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(C||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function getMapData(e,t){var n=e.__data__;return isKeyable(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=+!!t,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function MapCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var be=200;function stackSet(e,t){var n=this.__data__;if(n instanceof ListCache){var r=n.__data__;if(!C||r.length<be-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new MapCache(r)}return n.set(e,t),this.size=n.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var xe=`__lodash_hash_undefined__`;function setCacheAdd(e){return this.__data__.set(e,xe),this}function setCacheHas(e){return this.__data__.has(e)}function SetCache(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new MapCache;++t<n;)this.add(e[t])}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;function arraySome(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function cacheHas(e,t){return e.has(t)}var Se=1,Ce=2;function equalArrays(e,t,n,r,i,a){var o=n&Se,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&Ce?new SetCache:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!arraySome(t,function(e,t){if(!cacheHas(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var T=h.Uint8Array;function mapToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function setToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var we=1,Te=2,Ee=`[object Boolean]`,De=`[object Date]`,Oe=`[object Error]`,ke=`[object Map]`,Ae=`[object Number]`,je=`[object RegExp]`,Me=`[object Set]`,Ne=`[object String]`,Pe=`[object Symbol]`,Fe=`[object ArrayBuffer]`,Ie=`[object DataView]`,E=g?g.prototype:void 0,D=E?E.valueOf:void 0;function equalByTag(e,t,n,r,i,a,o){switch(n){case Ie:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Fe:return!(e.byteLength!=t.byteLength||!a(new T(e),new T(t)));case Ee:case De:case Ae:return eq(+e,+t);case Oe:return e.name==t.name&&e.message==t.message;case je:case Ne:return e==t+``;case ke:var s=mapToArray;case Me:var c=r&we;if(s||=setToArray,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=Te,o.set(e,t);var u=equalArrays(s(e),s(t),r,i,a,o);return o.delete(e),u;case Pe:if(D)return D.call(e)==D.call(t)}return!1}function arrayPush(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var O=Array.isArray;function baseGetAllKeys(e,t,n){var r=t(e);return O(e)?r:arrayPush(r,n(e))}function arrayFilter(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function stubArray(){return[]}var Le=Object.prototype.propertyIsEnumerable,Re=Object.getOwnPropertySymbols,ze=Re?function(e){return e==null?[]:(e=Object(e),arrayFilter(Re(e),function(t){return Le.call(e,t)}))}:stubArray;function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function isObjectLike(e){return typeof e==`object`&&!!e}var Be=`[object Arguments]`;function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==Be}var Ve=Object.prototype,He=Ve.hasOwnProperty,Ue=Ve.propertyIsEnumerable,k=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&He.call(e,`callee`)&&!Ue.call(e,`callee`)};function stubFalse(){return!1}var We=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=We&&typeof module==`object`&&module&&!module.nodeType&&module,j=A&&A.exports===We?h.Buffer:void 0,M=(j?j.isBuffer:void 0)||stubFalse,Ge=9007199254740991,Ke=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var n=typeof e;return t??=Ge,!!t&&(n==`number`||n!=`symbol`&&Ke.test(e))&&e>-1&&e%1==0&&e<t}var qe=9007199254740991;function isLength(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=qe}var Je=`[object Arguments]`,Ye=`[object Array]`,Xe=`[object Boolean]`,Ze=`[object Date]`,Qe=`[object Error]`,$e=`[object Function]`,et=`[object Map]`,tt=`[object Number]`,nt=`[object Object]`,rt=`[object RegExp]`,it=`[object Set]`,at=`[object String]`,ot=`[object WeakMap]`,st=`[object ArrayBuffer]`,ct=`[object DataView]`,lt=`[object Float32Array]`,ut=`[object Float64Array]`,dt=`[object Int8Array]`,ft=`[object Int16Array]`,pt=`[object Int32Array]`,mt=`[object Uint8Array]`,ht=`[object Uint8ClampedArray]`,gt=`[object Uint16Array]`,_t=`[object Uint32Array]`,N={};N[lt]=N[ut]=N[dt]=N[ft]=N[pt]=N[mt]=N[ht]=N[gt]=N[_t]=!0,N[Je]=N[Ye]=N[st]=N[Xe]=N[ct]=N[Ze]=N[Qe]=N[$e]=N[et]=N[tt]=N[nt]=N[rt]=N[it]=N[at]=N[ot]=!1;function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!N[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}var P=typeof exports==`object`&&exports&&!exports.nodeType&&exports,F=P&&typeof module==`object`&&module&&!module.nodeType&&module,I=F&&F.exports===P&&p.process,L=function(){try{return F&&F.require&&F.require(`util`).types||I&&I.binding&&I.binding(`util`)}catch{}}(),R=L&&L.isTypedArray,z=R?baseUnary(R):baseIsTypedArray,vt=Object.prototype.hasOwnProperty;function arrayLikeKeys(e,t){var n=O(e),r=!n&&k(e),i=!n&&!r&&M(e),a=!n&&!r&&!i&&z(e),o=n||r||i||a,s=o?baseTimes(e.length,String):[],c=s.length;for(var l in e)(t||vt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||isIndex(l,c)))&&s.push(l);return s}var yt=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||yt)}function overArg(e,t){return function(n){return e(t(n))}}var bt=overArg(Object.keys,Object),xt=Object.prototype.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return bt(e);var t=[];for(var n in Object(e))xt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function getAllKeys(e){return baseGetAllKeys(e,keys,ze)}var St=1,Ct=Object.prototype.hasOwnProperty;function equalObjects(e,t,n,r,i,a){var o=n&St,s=getAllKeys(e),c=s.length;if(c!=getAllKeys(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Ct.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var B=getNative(h,`DataView`),V=getNative(h,`Promise`),H=getNative(h,`Set`),U=getNative(h,`WeakMap`),W=`[object Map]`,wt=`[object Object]`,G=`[object Promise]`,K=`[object Set]`,q=`[object WeakMap]`,J=`[object DataView]`,Tt=toSource(B),Et=toSource(C),Dt=toSource(V),Ot=toSource(H),kt=toSource(U),getTag=baseGetTag;(B&&getTag(new B(new ArrayBuffer(1)))!=J||C&&getTag(new C)!=W||V&&getTag(V.resolve())!=G||H&&getTag(new H)!=K||U&&getTag(new U)!=q)&&(getTag=function(e){var t=baseGetTag(e),n=t==wt?e.constructor:void 0,r=n?toSource(n):``;if(r)switch(r){case Tt:return J;case Et:return W;case Dt:return G;case Ot:return K;case kt:return q}return t});var Y=getTag,At=1,X=`[object Arguments]`,jt=`[object Array]`,Z=`[object Object]`,Mt=Object.prototype.hasOwnProperty;function baseIsEqualDeep(e,t,n,r,i,a){var o=O(e),s=O(t),c=o?jt:Y(e),l=s?jt:Y(t);c=c==X?Z:c,l=l==X?Z:l;var u=c==Z,d=l==Z,f=c==l;if(f&&M(e)){if(!M(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Stack,o||z(e)?equalArrays(e,t,n,r,i,a):equalByTag(e,t,c,n,r,i,a);if(!(n&At)){var p=u&&Mt.call(e,`__wrapped__`),m=d&&Mt.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new Stack,i(h,g,n,r,a)}}return f?(a||=new Stack,equalObjects(e,t,n,r,i,a)):!1}function baseIsEqual(e,t,n,r,i){return e===t?!0:e==null||t==null||!isObjectLike(e)&&!isObjectLike(t)?e!==e&&t!==t:baseIsEqualDeep(e,t,n,r,baseIsEqual,i)}var Nt=1,Pt=2;function baseIsMatch(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Stack;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?baseIsEqual(u,l,Nt|Pt,r,d):f))return!1}}return!0}function isStrictComparable(e){return e===e&&!isObject(e)}function getMatchData(e){for(var t=keys(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,isStrictComparable(i)]}return t}function matchesStrictComparable(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function baseMatches(e){var t=getMatchData(e);return t.length==1&&t[0][2]?matchesStrictComparable(t[0][0],t[0][1]):function(n){return n===e||baseIsMatch(n,e,t)}}var Ft=`[object Symbol]`;function isSymbol(e){return typeof e==`symbol`||isObjectLike(e)&&baseGetTag(e)==Ft}var It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lt=/^\w*$/;function isKey(e,t){if(O(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||isSymbol(e)?!0:Lt.test(e)||!It.test(e)||t!=null&&e in Object(t)}var Rt=`Expected a function`;function memoize(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(Rt);var memoized=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=memoized.cache;if(i.has(r))return i.get(r);var a=e.apply(this,n);return memoized.cache=i.set(r,a)||i,a};return memoized.cache=new(memoize.Cache||MapCache),memoized}memoize.Cache=MapCache;var zt=500;function memoizeCapped(e){var t=memoize(e,function(e){return n.size===zt&&n.clear(),e}),n=t.cache;return t}var Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vt=/\\(\\)?/g,Ht=memoizeCapped(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Bt,function(e,n,r,i){t.push(r?i.replace(Vt,`$1`):n||e)}),t}),Ut=1/0,Wt=g?g.prototype:void 0,Gt=Wt?Wt.toString:void 0;function baseToString(e){if(typeof e==`string`)return e;if(O(e))return arrayMap(e,baseToString)+``;if(isSymbol(e))return Gt?Gt.call(e):``;var t=e+``;return t==`0`&&1/e==-Ut?`-0`:t}function toString(e){return e==null?``:baseToString(e)}function castPath(e,t){return O(e)?e:isKey(e,t)?[e]:Ht(toString(e))}var Kt=1/0;function toKey(e){if(typeof e==`string`||isSymbol(e))return e;var t=e+``;return t==`0`&&1/e==-Kt?`-0`:t}function baseGet(e,t){t=castPath(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[toKey(t[n++])];return n&&n==r?e:void 0}function get(e,t,n){var r=e==null?void 0:baseGet(e,t);return r===void 0?n:r}function baseHasIn(e,t){return e!=null&&t in Object(e)}function hasPath(e,t,n){t=castPath(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=toKey(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&isLength(i)&&isIndex(o,i)&&(O(e)||k(e)))}function hasIn(e,t){return e!=null&&hasPath(e,t,baseHasIn)}var qt=1,Jt=2;function baseMatchesProperty(e,t){return isKey(e)&&isStrictComparable(t)?matchesStrictComparable(toKey(e),t):function(n){var r=get(n,e);return r===void 0&&r===t?hasIn(n,e):baseIsEqual(t,r,qt|Jt)}}function identity(e){return e}function baseProperty(e){return function(t){return t?.[e]}}function basePropertyDeep(e){return function(t){return baseGet(t,e)}}function property(e){return isKey(e)?baseProperty(toKey(e)):basePropertyDeep(e)}function baseIteratee(e){return typeof e==`function`?e:e==null?identity:typeof e==`object`?O(e)?baseMatchesProperty(e[0],e[1]):baseMatches(e):property(e)}function createBaseFor(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Yt=createBaseFor();function baseForOwn(e,t){return e&&Yt(e,t,keys)}function createBaseEach(e,t){return function(n,r){if(n==null)return n;if(!isArrayLike(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var Q=createBaseEach(baseForOwn);function baseMap(e,t){var n=-1,r=isArrayLike(e)?Array(e.length):[];return Q(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function map(e,t){return(O(e)?arrayMap:baseMap)(e,baseIteratee(t,3))}function baseFilter(e,t){var n=[];return Q(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function filter(e,t){return(O(e)?arrayFilter:baseFilter)(e,baseIteratee(t,3))}function buildATNKey(e,t,n){return`${e.name}_${t}_${n}`}var AbstractTransition=class{constructor(e){this.target=e}isEpsilon(){return!1}},AtomTransition=class extends AbstractTransition{constructor(e,t){super(e),this.tokenType=t}},EpsilonTransition=class extends AbstractTransition{constructor(e){super(e)}isEpsilon(){return!0}},RuleTransition=class extends AbstractTransition{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}};function createATN(e){let t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};createRuleStartAndStopATNStates(t,e);let n=e.length;for(let r=0;r<n;r++){let n=e[r],i=block(t,n,n);i!==void 0&&buildRuleHandle(t,n,i)}return t}function createRuleStartAndStopATNStates(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=newState(e,n,void 0,{type:2}),a=newState(e,n,void 0,{type:7});i.stop=a,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,a)}}function atom(c,l,u){return u instanceof r?tokenRef(c,l,u.terminalType,u):u instanceof e?ruleRef(c,l,u):u instanceof a?alternation(c,l,u):u instanceof i?option(c,l,u):u instanceof s?repetition(c,l,u):u instanceof o?repetitionSep(c,l,u):u instanceof t?repetitionMandatory(c,l,u):u instanceof n?repetitionMandatorySep(c,l,u):block(c,l,u)}function repetition(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionSep(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function repetitionMandatory(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionMandatorySep(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function alternation(e,t,n){let r=newState(e,t,n,{type:1});return defineDecisionState(e,r),makeAlts(e,t,r,n,...map(n.definition,n=>atom(e,t,n)))}function option(e,t,n){let r=newState(e,t,n,{type:1});return defineDecisionState(e,r),optional(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function block(e,t,n){let r=filter(map(n.definition,n=>atom(e,t,n)),e=>e!==void 0);return r.length===1?r[0]:r.length===0?void 0:makeBlock(e,r)}function plus(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:11});defineDecisionState(e,s);let c=newState(e,t,n,{type:12});return a.loopback=s,c.loopback=s,e.decisionMap[buildATNKey(t,i?`RepetitionMandatoryWithSeparator`:`RepetitionMandatory`,n.idx)]=s,epsilon(o,s),i===void 0?(epsilon(s,a),epsilon(s,c)):(epsilon(s,c),epsilon(s,i.left),epsilon(i.right,a)),{left:a,right:c}}function star(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:10});defineDecisionState(e,s);let c=newState(e,t,n,{type:12}),l=newState(e,t,n,{type:9});return s.loopback=l,c.loopback=l,epsilon(s,a),epsilon(s,c),epsilon(o,l),i===void 0?epsilon(l,s):(epsilon(l,c),epsilon(l,i.left),epsilon(i.right,a)),e.decisionMap[buildATNKey(t,i?`RepetitionWithSeparator`:`Repetition`,n.idx)]=s,{left:s,right:c}}function optional(e,t,n,r){let i=r.left,a=r.right;return epsilon(i,a),e.decisionMap[buildATNKey(t,`Option`,n.idx)]=i,r}function defineDecisionState(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function makeAlts(e,t,n,r,...i){let a=newState(e,t,r,{type:8,start:n});n.end=a;for(let e of i)e===void 0?epsilon(n,a):(epsilon(n,e.left),epsilon(e.right,a));let o={left:n,right:a};return e.decisionMap[buildATNKey(t,getProdType(r),r.idx)]=n,o}function getProdType(e){if(e instanceof a)return`Alternation`;if(e instanceof i)return`Option`;if(e instanceof s)return`Repetition`;if(e instanceof o)return`RepetitionWithSeparator`;if(e instanceof t)return`RepetitionMandatory`;if(e instanceof n)return`RepetitionMandatoryWithSeparator`;throw Error(`Invalid production type encountered`)}function makeBlock(e,t){let n=t.length;for(let r=0;r<n-1;r++){let n=t[r],i;n.left.transitions.length===1&&(i=n.left.transitions[0]);let a=i instanceof RuleTransition,o=i,s=t[r+1].left;n.left.type===1&&n.right.type===1&&i!==void 0&&(a&&o.followState===n.right||i.target===n.right)?(a?o.followState=s:i.target=s,removeState(e,n.right)):epsilon(n.right,s)}let r=t[0],i=t[n-1];return{left:r.left,right:i.right}}function tokenRef(e,t,n,r){let i=newState(e,t,r,{type:1}),a=newState(e,t,r,{type:1});return addTransition(i,new AtomTransition(a,n)),{left:i,right:a}}function ruleRef(e,t,n){let r=n.referencedRule,i=e.ruleToStartState.get(r),a=newState(e,t,n,{type:1}),o=newState(e,t,n,{type:1});return addTransition(a,new RuleTransition(i,r,o)),{left:a,right:o}}function buildRuleHandle(e,t,n){let r=e.ruleToStartState.get(t);epsilon(r,n.left);let i=e.ruleToStopState.get(t);return epsilon(n.right,i),{left:r,right:i}}function epsilon(e,t){addTransition(e,new EpsilonTransition(t))}function newState(e,t,n,r){let i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function addTransition(e,t){e.transitions.length===0&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function removeState(e,t){e.states.splice(e.states.indexOf(t),1)}const $={};var ATNConfigSet=class{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){let t=getATNConfigKey(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return map(this.configs,e=>e.alt)}get key(){let e=``;for(let t in this.map)e+=t+`:`;return e}};function getATNConfigKey(e,t=!0){return`${t?`a${e.alt}`:``}s${e.state.stateNumber}:${e.stack.map(e=>e.stateNumber.toString()).join(`_`)}`}function baseExtremum(e,t,n){for(var r=-1,i=e.length;++r<i;){var a=e[r],o=t(a);if(o!=null&&(s===void 0?o===o&&!isSymbol(o):n(o,s)))var s=o,c=a}return c}function baseLt(e,t){return e<t}function min(e){return e&&e.length?baseExtremum(e,identity,baseLt):void 0}var Xt=g?g.isConcatSpreadable:void 0;function isFlattenable(e){return O(e)||k(e)||!!(Xt&&e&&e[Xt])}function baseFlatten(e,t,n,r,i){var a=-1,o=e.length;for(n||=isFlattenable,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?baseFlatten(s,t-1,n,r,i):arrayPush(i,s):r||(i[i.length]=s)}return i}function flatMap(e,t){return baseFlatten(map(e,t),1)}function baseFindIndex(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function baseIsNaN(e){return e!==e}function strictIndexOf(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function baseIndexOf(e,t,n){return t===t?strictIndexOf(e,t,n):baseFindIndex(e,baseIsNaN,n)}function arrayIncludes(e,t){return!!(e!=null&&e.length)&&baseIndexOf(e,t,0)>-1}function arrayIncludesWith(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function noop(){}var Zt=H&&1/setToArray(new H([,-0]))[1]==1/0?function(e){return new H(e)}:noop,Qt=200;function baseUniq(e,t,n){var r=-1,i=arrayIncludes,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=arrayIncludesWith;else if(a>=Qt){var l=t?null:Zt(e);if(l)return setToArray(l);o=!1,i=cacheHas,c=new SetCache}else c=t?[]:s;outer:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue outer;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}function uniqBy(e,t){return e&&e.length?baseUniq(e,baseIteratee(t,2)):[]}function flatten(e){return e!=null&&e.length?baseFlatten(e,1):[]}function arrayEach(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function castFunction(e){return typeof e==`function`?e:identity}function forEach(e,t){return(O(e)?arrayEach:Q)(e,castFunction(t))}var $t=`[object Map]`,en=`[object Set]`,tn=Object.prototype.hasOwnProperty;function isEmpty(e){if(e==null)return!0;if(isArrayLike(e)&&(O(e)||typeof e==`string`||typeof e.splice==`function`||M(e)||z(e)||k(e)))return!e.length;var t=Y(e);if(t==$t||t==en)return!e.size;if(isPrototype(e))return!baseKeys(e).length;for(var n in e)if(tn.call(e,n))return!1;return!0}function arrayReduce(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function baseReduce(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function reduce(e,t,n){var r=O(e)?arrayReduce:baseReduce,i=arguments.length<3;return r(e,baseIteratee(t,4),n,i,Q)}function createDFACache(e,t){let n={};return r=>{let i=r.toString(),a=n[i];return a===void 0?(a={atnStartState:e,decision:t,states:{}},n[i]=a,a):a}}var PredicateSet=class{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,t){this.predicates[e]=t}toString(){let e=``,t=this.predicates.length;for(let n=0;n<t;n++)e+=this.predicates[n]===!0?`1`:`0`;return e}};const nn=new PredicateSet;var LLStarLookaheadStrategy=class extends u{constructor(e){super(),this.logging=e?.logging??(e=>console.log(e))}initialize(e){this.atn=createATN(e.rules),this.dfas=initATNSimulator(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){let{prodOccurrence:t,rule:n,hasPredicates:r,dynamicTokensEnabled:i}=e,a=this.dfas,o=this.logging,s=buildATNKey(n,`Alternation`,t),c=this.atn.decisionMap[s].decision,u=map(l({maxLookahead:1,occurrence:t,prodType:`Alternation`,rule:n}),e=>map(e,e=>e[0]));if(isLL1Sequence(u,!1)&&!i){let e=reduce(u,(e,t,n)=>(forEach(t,t=>{t&&(e[t.tokenTypeIdx]=n,forEach(t.categoryMatches,t=>{e[t]=n}))}),e),{});return r?function(t){let n=this.LA(1),r=e[n.tokenTypeIdx];if(t!==void 0&&r!==void 0){let e=t[r]?.GATE;if(e!==void 0&&e.call(this)===!1)return}return r}:function(){let t=this.LA(1);return e[t.tokenTypeIdx]}}else if(r)return function(e){let t=new PredicateSet,n=e===void 0?0:e.length;for(let r=0;r<n;r++){let n=e?.[r].GATE;t.set(r,n===void 0||n.call(this))}let r=adaptivePredict.call(this,a,c,t,o);return typeof r==`number`?r:void 0};else return function(){let e=adaptivePredict.call(this,a,c,nn,o);return typeof e==`number`?e:void 0}}buildLookaheadForOptional(e){let{prodOccurrence:t,rule:n,prodType:r,dynamicTokensEnabled:i}=e,a=this.dfas,o=this.logging,s=buildATNKey(n,r,t),c=this.atn.decisionMap[s].decision,u=map(l({maxLookahead:1,occurrence:t,prodType:r,rule:n}),e=>map(e,e=>e[0]));if(isLL1Sequence(u)&&u[0][0]&&!i){let e=u[0],t=flatten(e);if(t.length===1&&isEmpty(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=reduce(t,(e,t)=>(t!==void 0&&(e[t.tokenTypeIdx]=!0,forEach(t.categoryMatches,t=>{e[t]=!0})),e),{});return function(){let t=this.LA(1);return e[t.tokenTypeIdx]===!0}}}return function(){let e=adaptivePredict.call(this,a,c,nn,o);return typeof e!=`object`&&e===0}}};function isLL1Sequence(e,t=!0){let n=new Set;for(let r of e){let e=new Set;for(let i of r){if(i===void 0){if(t)break;return!1}let r=[i.tokenTypeIdx].concat(i.categoryMatches);for(let t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function initATNSimulator(e){let t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=createDFACache(e.decisionStates[r],r);return n}function adaptivePredict(e,t,n,r){let i=e[t](n),a=i.start;return a===void 0&&(a=addDFAState(i,newDFAState(computeStartState(i.atnStartState))),i.start=a),performLookahead.apply(this,[i,a,n,r])}function performLookahead(e,t,n,r){let i=t,a=1,o=[],s=this.LA(a++);for(;;){let t=getExistingTargetState(i,s);if(t===void 0&&(t=computeLookaheadTarget.apply(this,[e,i,s,a,n,r])),t===$)return buildAdaptivePredictError(o,i,s);if(t.isAcceptState===!0)return t.prediction;i=t,o.push(s),s=this.LA(a++)}}function computeLookaheadTarget(e,t,n,r,i,a){let o=computeReachSet(t.configs,n,i);if(o.size===0)return addDFAEdge(e,t,n,$),$;let s=newDFAState(o),c=getUniqueAlt(o,i);if(c!==void 0)s.isAcceptState=!0,s.prediction=c,s.configs.uniqueAlt=c;else if(hasConflictTerminatingPrediction(o)){let t=min(o.alts);s.isAcceptState=!0,s.prediction=t,s.configs.uniqueAlt=t,reportLookaheadAmbiguity.apply(this,[e,r,o.alts,a])}return s=addDFAEdge(e,t,n,s),s}function reportLookaheadAmbiguity(e,t,n,r){let i=[];for(let e=1;e<=t;e++)i.push(this.LA(e).tokenType);let a=e.atnStartState,o=a.rule,s=a.production;r(buildAmbiguityError({topLevelRule:o,ambiguityIndices:n,production:s,prefixPath:i}))}function buildAmbiguityError(e){let t=map(e.prefixPath,e=>d(e)).join(`, `),n=e.production.idx===0?``:e.production.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(`, `)}> in <${getProductionDslName(e.production)}${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
1
+ import"../rolldown-runtime.mjs";import{c as e,d as t,f as n,h as r,l as i,o as a,p as o,u as s}from"./@chevrotain/gast.mjs";import{c,i as l,r as u,s as d}from"./chevrotain.mjs";function arrayMap(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function listCacheClear(){this.__data__=[],this.size=0}function eq(e,t){return e===t||e!==e&&t!==t}function assocIndexOf(e,t){for(var n=e.length;n--;)if(eq(e[n][0],t))return n;return-1}var f=Array.prototype.splice;function listCacheDelete(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?!1:(n==t.length-1?t.pop():f.call(t,n,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?void 0:t[n][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function ListCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}var p=typeof global==`object`&&global&&global.Object===Object&&global,m=typeof self==`object`&&self&&self.Object===Object&&self,h=p||m||Function(`return this`)(),g=h.Symbol,_=Object.prototype,v=_.hasOwnProperty,y=_.toString,b=g?g.toStringTag:void 0;function getRawTag(e){var t=v.call(e,b),n=e[b];try{e[b]=void 0;var r=!0}catch{}var i=y.call(e);return r&&(t?e[b]=n:delete e[b]),i}var ee=Object.prototype.toString;function objectToString(e){return ee.call(e)}var te=`[object Null]`,ne=`[object Undefined]`,re=g?g.toStringTag:void 0;function baseGetTag(e){return e==null?e===void 0?ne:te:re&&re in Object(e)?getRawTag(e):objectToString(e)}function isObject(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var ie=`[object AsyncFunction]`,ae=`[object Function]`,oe=`[object GeneratorFunction]`,se=`[object Proxy]`;function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==ae||t==oe||t==ie||t==se}var x=h[`__core-js_shared__`],S=function(){var e=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function isMasked(e){return!!S&&S in e}var ce=Function.prototype.toString;function toSource(e){if(e!=null){try{return ce.call(e)}catch{}try{return e+``}catch{}}return``}var le=/[\\^$.*+?()[\]{}|]/g,ue=/^\[object .+?Constructor\]$/,de=Function.prototype,fe=Object.prototype,pe=de.toString,me=fe.hasOwnProperty,he=RegExp(`^`+pe.call(me).replace(le,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function baseIsNative(e){return!isObject(e)||isMasked(e)?!1:(isFunction(e)?he:ue).test(toSource(e))}function getValue(e,t){return e?.[t]}function getNative(e,t){var n=getValue(e,t);return baseIsNative(n)?n:void 0}var C=getNative(h,`Map`),w=getNative(Object,`create`);function hashClear(){this.__data__=w?w(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var ge=`__lodash_hash_undefined__`,_e=Object.prototype.hasOwnProperty;function hashGet(e){var t=this.__data__;if(w){var n=t[e];return n===ge?void 0:n}return _e.call(t,e)?t[e]:void 0}var ve=Object.prototype.hasOwnProperty;function hashHas(e){var t=this.__data__;return w?t[e]!==void 0:ve.call(t,e)}var ye=`__lodash_hash_undefined__`;function hashSet(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=w&&t===void 0?ye:t,this}function Hash(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(C||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function getMapData(e,t){var n=e.__data__;return isKeyable(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=+!!t,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function MapCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var be=200;function stackSet(e,t){var n=this.__data__;if(n instanceof ListCache){var r=n.__data__;if(!C||r.length<be-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new MapCache(r)}return n.set(e,t),this.size=n.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var xe=`__lodash_hash_undefined__`;function setCacheAdd(e){return this.__data__.set(e,xe),this}function setCacheHas(e){return this.__data__.has(e)}function SetCache(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new MapCache;++t<n;)this.add(e[t])}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;function arraySome(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function cacheHas(e,t){return e.has(t)}var Se=1,Ce=2;function equalArrays(e,t,n,r,i,a){var o=n&Se,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&Ce?new SetCache:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!arraySome(t,function(e,t){if(!cacheHas(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var T=h.Uint8Array;function mapToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function setToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var we=1,Te=2,Ee=`[object Boolean]`,De=`[object Date]`,Oe=`[object Error]`,ke=`[object Map]`,Ae=`[object Number]`,je=`[object RegExp]`,Me=`[object Set]`,Ne=`[object String]`,Pe=`[object Symbol]`,Fe=`[object ArrayBuffer]`,Ie=`[object DataView]`,E=g?g.prototype:void 0,D=E?E.valueOf:void 0;function equalByTag(e,t,n,r,i,a,o){switch(n){case Ie:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Fe:return!(e.byteLength!=t.byteLength||!a(new T(e),new T(t)));case Ee:case De:case Ae:return eq(+e,+t);case Oe:return e.name==t.name&&e.message==t.message;case je:case Ne:return e==t+``;case ke:var s=mapToArray;case Me:var c=r&we;if(s||=setToArray,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=Te,o.set(e,t);var u=equalArrays(s(e),s(t),r,i,a,o);return o.delete(e),u;case Pe:if(D)return D.call(e)==D.call(t)}return!1}function arrayPush(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var O=Array.isArray;function baseGetAllKeys(e,t,n){var r=t(e);return O(e)?r:arrayPush(r,n(e))}function arrayFilter(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function stubArray(){return[]}var Le=Object.prototype.propertyIsEnumerable,Re=Object.getOwnPropertySymbols,ze=Re?function(e){return e==null?[]:(e=Object(e),arrayFilter(Re(e),function(t){return Le.call(e,t)}))}:stubArray;function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function isObjectLike(e){return typeof e==`object`&&!!e}var Be=`[object Arguments]`;function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==Be}var Ve=Object.prototype,He=Ve.hasOwnProperty,Ue=Ve.propertyIsEnumerable,k=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&He.call(e,`callee`)&&!Ue.call(e,`callee`)};function stubFalse(){return!1}var We=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=We&&typeof module==`object`&&module&&!module.nodeType&&module,j=A&&A.exports===We?h.Buffer:void 0,M=(j?j.isBuffer:void 0)||stubFalse,Ge=9007199254740991,Ke=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var n=typeof e;return t??=Ge,!!t&&(n==`number`||n!=`symbol`&&Ke.test(e))&&e>-1&&e%1==0&&e<t}var qe=9007199254740991;function isLength(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=qe}var Je=`[object Arguments]`,Ye=`[object Array]`,Xe=`[object Boolean]`,Ze=`[object Date]`,Qe=`[object Error]`,$e=`[object Function]`,et=`[object Map]`,tt=`[object Number]`,nt=`[object Object]`,rt=`[object RegExp]`,it=`[object Set]`,at=`[object String]`,ot=`[object WeakMap]`,st=`[object ArrayBuffer]`,ct=`[object DataView]`,lt=`[object Float32Array]`,ut=`[object Float64Array]`,dt=`[object Int8Array]`,ft=`[object Int16Array]`,pt=`[object Int32Array]`,mt=`[object Uint8Array]`,ht=`[object Uint8ClampedArray]`,gt=`[object Uint16Array]`,_t=`[object Uint32Array]`,N={};N[lt]=N[ut]=N[dt]=N[ft]=N[pt]=N[mt]=N[ht]=N[gt]=N[_t]=!0,N[Je]=N[Ye]=N[st]=N[Xe]=N[ct]=N[Ze]=N[Qe]=N[$e]=N[et]=N[tt]=N[nt]=N[rt]=N[it]=N[at]=N[ot]=!1;function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!N[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}var P=typeof exports==`object`&&exports&&!exports.nodeType&&exports,F=P&&typeof module==`object`&&module&&!module.nodeType&&module,I=F&&F.exports===P&&p.process,L=function(){try{return F&&F.require&&F.require(`util`).types||I&&I.binding&&I.binding(`util`)}catch{}}(),R=L&&L.isTypedArray,z=R?baseUnary(R):baseIsTypedArray,vt=Object.prototype.hasOwnProperty;function arrayLikeKeys(e,t){var n=O(e),r=!n&&k(e),i=!n&&!r&&M(e),a=!n&&!r&&!i&&z(e),o=n||r||i||a,s=o?baseTimes(e.length,String):[],c=s.length;for(var l in e)(t||vt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||isIndex(l,c)))&&s.push(l);return s}var yt=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||yt)}function overArg(e,t){return function(n){return e(t(n))}}var bt=overArg(Object.keys,Object),xt=Object.prototype.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return bt(e);var t=[];for(var n in Object(e))xt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function getAllKeys(e){return baseGetAllKeys(e,keys,ze)}var St=1,Ct=Object.prototype.hasOwnProperty;function equalObjects(e,t,n,r,i,a){var o=n&St,s=getAllKeys(e),c=s.length;if(c!=getAllKeys(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Ct.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var B=getNative(h,`DataView`),V=getNative(h,`Promise`),H=getNative(h,`Set`),U=getNative(h,`WeakMap`),W=`[object Map]`,wt=`[object Object]`,G=`[object Promise]`,K=`[object Set]`,q=`[object WeakMap]`,J=`[object DataView]`,Tt=toSource(B),Et=toSource(C),Dt=toSource(V),Ot=toSource(H),kt=toSource(U),getTag=baseGetTag;(B&&getTag(new B(new ArrayBuffer(1)))!=J||C&&getTag(new C)!=W||V&&getTag(V.resolve())!=G||H&&getTag(new H)!=K||U&&getTag(new U)!=q)&&(getTag=function(e){var t=baseGetTag(e),n=t==wt?e.constructor:void 0,r=n?toSource(n):``;if(r)switch(r){case Tt:return J;case Et:return W;case Dt:return G;case Ot:return K;case kt:return q}return t});var Y=getTag,At=1,X=`[object Arguments]`,jt=`[object Array]`,Z=`[object Object]`,Mt=Object.prototype.hasOwnProperty;function baseIsEqualDeep(e,t,n,r,i,a){var o=O(e),s=O(t),c=o?jt:Y(e),l=s?jt:Y(t);c=c==X?Z:c,l=l==X?Z:l;var u=c==Z,d=l==Z,f=c==l;if(f&&M(e)){if(!M(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Stack,o||z(e)?equalArrays(e,t,n,r,i,a):equalByTag(e,t,c,n,r,i,a);if(!(n&At)){var p=u&&Mt.call(e,`__wrapped__`),m=d&&Mt.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new Stack,i(h,g,n,r,a)}}return f?(a||=new Stack,equalObjects(e,t,n,r,i,a)):!1}function baseIsEqual(e,t,n,r,i){return e===t?!0:e==null||t==null||!isObjectLike(e)&&!isObjectLike(t)?e!==e&&t!==t:baseIsEqualDeep(e,t,n,r,baseIsEqual,i)}var Nt=1,Pt=2;function baseIsMatch(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Stack;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?baseIsEqual(u,l,Nt|Pt,r,d):f))return!1}}return!0}function isStrictComparable(e){return e===e&&!isObject(e)}function getMatchData(e){for(var t=keys(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,isStrictComparable(i)]}return t}function matchesStrictComparable(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function baseMatches(e){var t=getMatchData(e);return t.length==1&&t[0][2]?matchesStrictComparable(t[0][0],t[0][1]):function(n){return n===e||baseIsMatch(n,e,t)}}var Ft=`[object Symbol]`;function isSymbol(e){return typeof e==`symbol`||isObjectLike(e)&&baseGetTag(e)==Ft}var It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lt=/^\w*$/;function isKey(e,t){if(O(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||isSymbol(e)?!0:Lt.test(e)||!It.test(e)||t!=null&&e in Object(t)}var Rt=`Expected a function`;function memoize(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(Rt);var memoized=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=memoized.cache;if(i.has(r))return i.get(r);var a=e.apply(this,n);return memoized.cache=i.set(r,a)||i,a};return memoized.cache=new(memoize.Cache||MapCache),memoized}memoize.Cache=MapCache;var zt=500;function memoizeCapped(e){var t=memoize(e,function(e){return n.size===zt&&n.clear(),e}),n=t.cache;return t}var Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vt=/\\(\\)?/g,Ht=memoizeCapped(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Bt,function(e,n,r,i){t.push(r?i.replace(Vt,`$1`):n||e)}),t}),Ut=1/0,Wt=g?g.prototype:void 0,Gt=Wt?Wt.toString:void 0;function baseToString(e){if(typeof e==`string`)return e;if(O(e))return arrayMap(e,baseToString)+``;if(isSymbol(e))return Gt?Gt.call(e):``;var t=e+``;return t==`0`&&1/e==-Ut?`-0`:t}function toString(e){return e==null?``:baseToString(e)}function castPath(e,t){return O(e)?e:isKey(e,t)?[e]:Ht(toString(e))}var Kt=1/0;function toKey(e){if(typeof e==`string`||isSymbol(e))return e;var t=e+``;return t==`0`&&1/e==-Kt?`-0`:t}function baseGet(e,t){t=castPath(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[toKey(t[n++])];return n&&n==r?e:void 0}function get(e,t,n){var r=e==null?void 0:baseGet(e,t);return r===void 0?n:r}function baseHasIn(e,t){return e!=null&&t in Object(e)}function hasPath(e,t,n){t=castPath(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=toKey(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&isLength(i)&&isIndex(o,i)&&(O(e)||k(e)))}function hasIn(e,t){return e!=null&&hasPath(e,t,baseHasIn)}var qt=1,Jt=2;function baseMatchesProperty(e,t){return isKey(e)&&isStrictComparable(t)?matchesStrictComparable(toKey(e),t):function(n){var r=get(n,e);return r===void 0&&r===t?hasIn(n,e):baseIsEqual(t,r,qt|Jt)}}function identity(e){return e}function baseProperty(e){return function(t){return t?.[e]}}function basePropertyDeep(e){return function(t){return baseGet(t,e)}}function property(e){return isKey(e)?baseProperty(toKey(e)):basePropertyDeep(e)}function baseIteratee(e){return typeof e==`function`?e:e==null?identity:typeof e==`object`?O(e)?baseMatchesProperty(e[0],e[1]):baseMatches(e):property(e)}function createBaseFor(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Yt=createBaseFor();function baseForOwn(e,t){return e&&Yt(e,t,keys)}function createBaseEach(e,t){return function(n,r){if(n==null)return n;if(!isArrayLike(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var Q=createBaseEach(baseForOwn);function baseMap(e,t){var n=-1,r=isArrayLike(e)?Array(e.length):[];return Q(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function map(e,t){return(O(e)?arrayMap:baseMap)(e,baseIteratee(t,3))}function baseFilter(e,t){var n=[];return Q(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function filter(e,t){return(O(e)?arrayFilter:baseFilter)(e,baseIteratee(t,3))}function buildATNKey(e,t,n){return`${e.name}_${t}_${n}`}var AbstractTransition=class{constructor(e){this.target=e}isEpsilon(){return!1}},AtomTransition=class extends AbstractTransition{constructor(e,t){super(e),this.tokenType=t}},EpsilonTransition=class extends AbstractTransition{constructor(e){super(e)}isEpsilon(){return!0}},RuleTransition=class extends AbstractTransition{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}};function createATN(e){let t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};createRuleStartAndStopATNStates(t,e);let n=e.length;for(let r=0;r<n;r++){let n=e[r],i=block(t,n,n);i!==void 0&&buildRuleHandle(t,n,i)}return t}function createRuleStartAndStopATNStates(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=newState(e,n,void 0,{type:2}),a=newState(e,n,void 0,{type:7});i.stop=a,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,a)}}function atom(c,l,u){return u instanceof r?tokenRef(c,l,u.terminalType,u):u instanceof e?ruleRef(c,l,u):u instanceof a?alternation(c,l,u):u instanceof i?option(c,l,u):u instanceof s?repetition(c,l,u):u instanceof o?repetitionSep(c,l,u):u instanceof t?repetitionMandatory(c,l,u):u instanceof n?repetitionMandatorySep(c,l,u):block(c,l,u)}function repetition(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionSep(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function repetitionMandatory(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionMandatorySep(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function alternation(e,t,n){let r=newState(e,t,n,{type:1});return defineDecisionState(e,r),makeAlts(e,t,r,n,...map(n.definition,n=>atom(e,t,n)))}function option(e,t,n){let r=newState(e,t,n,{type:1});return defineDecisionState(e,r),optional(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function block(e,t,n){let r=filter(map(n.definition,n=>atom(e,t,n)),e=>e!==void 0);return r.length===1?r[0]:r.length===0?void 0:makeBlock(e,r)}function plus(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:11});defineDecisionState(e,s);let c=newState(e,t,n,{type:12});return a.loopback=s,c.loopback=s,e.decisionMap[buildATNKey(t,i?`RepetitionMandatoryWithSeparator`:`RepetitionMandatory`,n.idx)]=s,epsilon(o,s),i===void 0?(epsilon(s,a),epsilon(s,c)):(epsilon(s,c),epsilon(s,i.left),epsilon(i.right,a)),{left:a,right:c}}function star(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:10});defineDecisionState(e,s);let c=newState(e,t,n,{type:12}),l=newState(e,t,n,{type:9});return s.loopback=l,c.loopback=l,epsilon(s,a),epsilon(s,c),epsilon(o,l),i===void 0?epsilon(l,s):(epsilon(l,c),epsilon(l,i.left),epsilon(i.right,a)),e.decisionMap[buildATNKey(t,i?`RepetitionWithSeparator`:`Repetition`,n.idx)]=s,{left:s,right:c}}function optional(e,t,n,r){let i=r.left,a=r.right;return epsilon(i,a),e.decisionMap[buildATNKey(t,`Option`,n.idx)]=i,r}function defineDecisionState(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function makeAlts(e,t,n,r,...i){let a=newState(e,t,r,{type:8,start:n});n.end=a;for(let e of i)e===void 0?epsilon(n,a):(epsilon(n,e.left),epsilon(e.right,a));let o={left:n,right:a};return e.decisionMap[buildATNKey(t,getProdType(r),r.idx)]=n,o}function getProdType(e){if(e instanceof a)return`Alternation`;if(e instanceof i)return`Option`;if(e instanceof s)return`Repetition`;if(e instanceof o)return`RepetitionWithSeparator`;if(e instanceof t)return`RepetitionMandatory`;if(e instanceof n)return`RepetitionMandatoryWithSeparator`;throw Error(`Invalid production type encountered`)}function makeBlock(e,t){let n=t.length;for(let r=0;r<n-1;r++){let n=t[r],i;n.left.transitions.length===1&&(i=n.left.transitions[0]);let a=i instanceof RuleTransition,o=i,s=t[r+1].left;n.left.type===1&&n.right.type===1&&i!==void 0&&(a&&o.followState===n.right||i.target===n.right)?(a?o.followState=s:i.target=s,removeState(e,n.right)):epsilon(n.right,s)}let r=t[0],i=t[n-1];return{left:r.left,right:i.right}}function tokenRef(e,t,n,r){let i=newState(e,t,r,{type:1}),a=newState(e,t,r,{type:1});return addTransition(i,new AtomTransition(a,n)),{left:i,right:a}}function ruleRef(e,t,n){let r=n.referencedRule,i=e.ruleToStartState.get(r),a=newState(e,t,n,{type:1}),o=newState(e,t,n,{type:1});return addTransition(a,new RuleTransition(i,r,o)),{left:a,right:o}}function buildRuleHandle(e,t,n){let r=e.ruleToStartState.get(t);epsilon(r,n.left);let i=e.ruleToStopState.get(t);return epsilon(n.right,i),{left:r,right:i}}function epsilon(e,t){addTransition(e,new EpsilonTransition(t))}function newState(e,t,n,r){let i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function addTransition(e,t){e.transitions.length===0&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function removeState(e,t){e.states.splice(e.states.indexOf(t),1)}const $={};var ATNConfigSet=class{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){let t=getATNConfigKey(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return map(this.configs,e=>e.alt)}get key(){let e=``;for(let t in this.map)e+=t+`:`;return e}};function getATNConfigKey(e,t=!0){return`${t?`a${e.alt}`:``}s${e.state.stateNumber}:${e.stack.map(e=>e.stateNumber.toString()).join(`_`)}`}function baseExtremum(e,t,n){for(var r=-1,i=e.length;++r<i;){var a=e[r],o=t(a);if(o!=null&&(s===void 0?o===o&&!isSymbol(o):n(o,s)))var s=o,c=a}return c}function baseLt(e,t){return e<t}function min(e){return e&&e.length?baseExtremum(e,identity,baseLt):void 0}var Xt=g?g.isConcatSpreadable:void 0;function isFlattenable(e){return O(e)||k(e)||!!(Xt&&e&&e[Xt])}function baseFlatten(e,t,n,r,i){var a=-1,o=e.length;for(n||=isFlattenable,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?baseFlatten(s,t-1,n,r,i):arrayPush(i,s):r||(i[i.length]=s)}return i}function flatMap(e,t){return baseFlatten(map(e,t),1)}function baseFindIndex(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function baseIsNaN(e){return e!==e}function strictIndexOf(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function baseIndexOf(e,t,n){return t===t?strictIndexOf(e,t,n):baseFindIndex(e,baseIsNaN,n)}function arrayIncludes(e,t){return!!(e!=null&&e.length)&&baseIndexOf(e,t,0)>-1}function arrayIncludesWith(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function noop(){}var Zt=H&&1/setToArray(new H([,-0]))[1]==1/0?function(e){return new H(e)}:noop,Qt=200;function baseUniq(e,t,n){var r=-1,i=arrayIncludes,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=arrayIncludesWith;else if(a>=Qt){var l=t?null:Zt(e);if(l)return setToArray(l);o=!1,i=cacheHas,c=new SetCache}else c=t?[]:s;outer:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue outer;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}function uniqBy(e,t){return e&&e.length?baseUniq(e,baseIteratee(t,2)):[]}function flatten(e){return e!=null&&e.length?baseFlatten(e,1):[]}function arrayEach(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function castFunction(e){return typeof e==`function`?e:identity}function forEach(e,t){return(O(e)?arrayEach:Q)(e,castFunction(t))}var $t=`[object Map]`,en=`[object Set]`,tn=Object.prototype.hasOwnProperty;function isEmpty(e){if(e==null)return!0;if(isArrayLike(e)&&(O(e)||typeof e==`string`||typeof e.splice==`function`||M(e)||z(e)||k(e)))return!e.length;var t=Y(e);if(t==$t||t==en)return!e.size;if(isPrototype(e))return!baseKeys(e).length;for(var n in e)if(tn.call(e,n))return!1;return!0}function arrayReduce(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function baseReduce(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function reduce(e,t,n){var r=O(e)?arrayReduce:baseReduce,i=arguments.length<3;return r(e,baseIteratee(t,4),n,i,Q)}function createDFACache(e,t){let n={};return r=>{let i=r.toString(),a=n[i];return a===void 0?(a={atnStartState:e,decision:t,states:{}},n[i]=a,a):a}}var PredicateSet=class{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,t){this.predicates[e]=t}toString(){let e=``,t=this.predicates.length;for(let n=0;n<t;n++)e+=this.predicates[n]===!0?`1`:`0`;return e}};const nn=new PredicateSet;var LLStarLookaheadStrategy=class extends u{constructor(e){super(),this.logging=e?.logging??(e=>console.log(e))}initialize(e){this.atn=createATN(e.rules),this.dfas=initATNSimulator(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){let{prodOccurrence:t,rule:n,hasPredicates:r,dynamicTokensEnabled:i}=e,a=this.dfas,o=this.logging,s=buildATNKey(n,`Alternation`,t),c=this.atn.decisionMap[s].decision,u=map(l({maxLookahead:1,occurrence:t,prodType:`Alternation`,rule:n}),e=>map(e,e=>e[0]));if(isLL1Sequence(u,!1)&&!i){let e=reduce(u,(e,t,n)=>(forEach(t,t=>{t&&(e[t.tokenTypeIdx]=n,forEach(t.categoryMatches,t=>{e[t]=n}))}),e),{});return r?function(t){let n=this.LA(1),r=e[n.tokenTypeIdx];if(t!==void 0&&r!==void 0){let e=t[r]?.GATE;if(e!==void 0&&e.call(this)===!1)return}return r}:function(){let t=this.LA(1);return e[t.tokenTypeIdx]}}return r?function(e){let t=new PredicateSet,n=e===void 0?0:e.length;for(let r=0;r<n;r++){let n=e?.[r].GATE;t.set(r,n===void 0||n.call(this))}let r=adaptivePredict.call(this,a,c,t,o);return typeof r==`number`?r:void 0}:function(){let e=adaptivePredict.call(this,a,c,nn,o);return typeof e==`number`?e:void 0}}buildLookaheadForOptional(e){let{prodOccurrence:t,rule:n,prodType:r,dynamicTokensEnabled:i}=e,a=this.dfas,o=this.logging,s=buildATNKey(n,r,t),c=this.atn.decisionMap[s].decision,u=map(l({maxLookahead:1,occurrence:t,prodType:r,rule:n}),e=>map(e,e=>e[0]));if(isLL1Sequence(u)&&u[0][0]&&!i){let e=u[0],t=flatten(e);if(t.length===1&&isEmpty(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{let e=reduce(t,(e,t)=>(t!==void 0&&(e[t.tokenTypeIdx]=!0,forEach(t.categoryMatches,t=>{e[t]=!0})),e),{});return function(){let t=this.LA(1);return e[t.tokenTypeIdx]===!0}}}return function(){let e=adaptivePredict.call(this,a,c,nn,o);return typeof e!=`object`&&e===0}}};function isLL1Sequence(e,t=!0){let n=new Set;for(let r of e){let e=new Set;for(let i of r){if(i===void 0){if(t)break;return!1}let r=[i.tokenTypeIdx].concat(i.categoryMatches);for(let t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function initATNSimulator(e){let t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=createDFACache(e.decisionStates[r],r);return n}function adaptivePredict(e,t,n,r){let i=e[t](n),a=i.start;return a===void 0&&(a=addDFAState(i,newDFAState(computeStartState(i.atnStartState))),i.start=a),performLookahead.apply(this,[i,a,n,r])}function performLookahead(e,t,n,r){let i=t,a=1,o=[],s=this.LA(a++);for(;;){let t=getExistingTargetState(i,s);if(t===void 0&&(t=computeLookaheadTarget.apply(this,[e,i,s,a,n,r])),t===$)return buildAdaptivePredictError(o,i,s);if(t.isAcceptState===!0)return t.prediction;i=t,o.push(s),s=this.LA(a++)}}function computeLookaheadTarget(e,t,n,r,i,a){let o=computeReachSet(t.configs,n,i);if(o.size===0)return addDFAEdge(e,t,n,$),$;let s=newDFAState(o),c=getUniqueAlt(o,i);if(c!==void 0)s.isAcceptState=!0,s.prediction=c,s.configs.uniqueAlt=c;else if(hasConflictTerminatingPrediction(o)){let t=min(o.alts);s.isAcceptState=!0,s.prediction=t,s.configs.uniqueAlt=t,reportLookaheadAmbiguity.apply(this,[e,r,o.alts,a])}return s=addDFAEdge(e,t,n,s),s}function reportLookaheadAmbiguity(e,t,n,r){let i=[];for(let e=1;e<=t;e++)i.push(this.LA(e).tokenType);let a=e.atnStartState,o=a.rule,s=a.production;r(buildAmbiguityError({topLevelRule:o,ambiguityIndices:n,production:s,prefixPath:i}))}function buildAmbiguityError(e){let t=map(e.prefixPath,e=>d(e)).join(`, `),n=e.production.idx===0?``:e.production.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(`, `)}> in <${getProductionDslName(e.production)}${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
2
2
  For Further details.`,r}function getProductionDslName(c){if(c instanceof e)return`SUBRULE`;if(c instanceof i)return`OPTION`;if(c instanceof a)return`OR`;if(c instanceof t)return`AT_LEAST_ONE`;if(c instanceof n)return`AT_LEAST_ONE_SEP`;if(c instanceof o)return`MANY_SEP`;if(c instanceof s)return`MANY`;if(c instanceof r)return`CONSUME`;throw Error(`non exhaustive match`)}function buildAdaptivePredictError(e,t,n){return{actualToken:n,possibleTokenTypes:uniqBy(flatMap(t.configs.elements,e=>e.state.transitions).filter(e=>e instanceof AtomTransition).map(e=>e.tokenType),e=>e.tokenTypeIdx),tokenPath:e}}function getExistingTargetState(e,t){return e.edges[t.tokenTypeIdx]}function computeReachSet(e,t,n){let r=new ATNConfigSet,i=[];for(let a of e.elements){if(n.is(a.alt)===!1)continue;if(a.state.type===7){i.push(a);continue}let e=a.state.transitions.length;for(let n=0;n<e;n++){let e=a.state.transitions[n],i=getReachableTarget(e,t);i!==void 0&&r.add({state:i,alt:a.alt,stack:a.stack})}}let a;if(i.length===0&&r.size===1&&(a=r),a===void 0){a=new ATNConfigSet;for(let e of r.elements)closure(e,a)}if(i.length>0&&!hasConfigInRuleStopState(a))for(let e of i)a.add(e);return a}function getReachableTarget(e,t){if(e instanceof AtomTransition&&c(t,e.tokenType))return e.target}function getUniqueAlt(e,t){let n;for(let r of e.elements)if(t.is(r.alt)===!0){if(n===void 0)n=r.alt;else if(n!==r.alt)return}return n}function newDFAState(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}function addDFAEdge(e,t,n,r){return r=addDFAState(e,r),t.edges[n.tokenTypeIdx]=r,r}function addDFAState(e,t){if(t===$)return t;let n=t.configs.key,r=e.states[n];return r===void 0?(t.configs.finalize(),e.states[n]=t,t):r}function computeStartState(e){let t=new ATNConfigSet,n=e.transitions.length;for(let r=0;r<n;r++)closure({state:e.transitions[r].target,alt:r,stack:[]},t);return t}function closure(e,t){let n=e.state;if(n.type===7){if(e.stack.length>0){let n=[...e.stack];closure({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);let r=n.transitions.length;for(let i=0;i<r;i++){let r=n.transitions[i],a=getEpsilonTarget(e,r);a!==void 0&&closure(a,t)}}function getEpsilonTarget(e,t){if(t instanceof EpsilonTransition)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof RuleTransition){let n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}function hasConfigInRuleStopState(e){for(let t of e.elements)if(t.state.type===7)return!0;return!1}function allConfigsInRuleStopStates(e){for(let t of e.elements)if(t.state.type!==7)return!1;return!0}function hasConflictTerminatingPrediction(e){if(allConfigsInRuleStopStates(e))return!0;let t=getConflictingAltSets(e.elements);return hasConflictingAltSet(t)&&!hasStateAssociatedWithOneAlt(t)}function getConflictingAltSets(e){let t=new Map;for(let n of e){let e=getATNConfigKey(n,!1),r=t.get(e);r===void 0&&(r={},t.set(e,r)),r[n.alt]=!0}return t}function hasConflictingAltSet(e){for(let t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}function hasStateAssociatedWithOneAlt(e){for(let t of Array.from(e.values()))if(Object.keys(t).length===1)return!0;return!1}export{LLStarLookaheadStrategy as t};