@likec4/mcp 1.59.1 → 1.59.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -100
- package/dist/app/render-view-client.css +1 -0
- package/dist/app/render-view-client.js +745 -0
- package/dist/chunks/src.mjs +55 -341
- package/dist/cli.mjs +1 -5
- package/package.json +33 -24
- package/dist/chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -1
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
- package/dist/chunks/libs/@hono/mcp.mjs +0 -70
- package/dist/chunks/libs/@hono/node-server.mjs +0 -3
- package/dist/chunks/libs/@logtape/logtape.mjs +0 -5
- package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -5
- package/dist/chunks/libs/@radix-ui/colors.mjs +0 -1
- package/dist/chunks/libs/@ts-graphviz/ast.mjs +0 -3
- package/dist/chunks/libs/@ts-graphviz/core.mjs +0 -1
- package/dist/chunks/libs/@ungap/structured-clone.mjs +0 -1
- package/dist/chunks/libs/character-entities.mjs +0 -2
- package/dist/chunks/libs/chevrotain-allstar.mjs +0 -2
- package/dist/chunks/libs/chevrotain.mjs +0 -58
- package/dist/chunks/libs/chokidar.mjs +0 -3
- package/dist/chunks/libs/chroma-js.mjs +0 -15
- package/dist/chunks/libs/eventemitter3.mjs +0 -1
- package/dist/chunks/libs/graphology-dag.mjs +0 -1
- package/dist/chunks/libs/graphology.mjs +0 -1
- package/dist/chunks/libs/hast-util-sanitize.mjs +0 -1
- package/dist/chunks/libs/hast-util-to-html.mjs +0 -9
- package/dist/chunks/libs/hono.mjs +0 -1
- package/dist/chunks/libs/immer.mjs +0 -1
- package/dist/chunks/libs/khroma.mjs +0 -1
- package/dist/chunks/libs/langium.mjs +0 -19
- package/dist/chunks/libs/markdown-table.mjs +0 -2
- package/dist/chunks/libs/mdast-util-find-and-replace.mjs +0 -1
- package/dist/chunks/libs/mdast-util-from-markdown.mjs +0 -3
- package/dist/chunks/libs/mdast-util-gfm.mjs +0 -15
- package/dist/chunks/libs/mdast-util-to-hast.mjs +0 -11
- package/dist/chunks/libs/merge-error-cause.mjs +0 -2
- package/dist/chunks/libs/micromark-extension-gfm.mjs +0 -1
- package/dist/chunks/libs/mnemonist.mjs +0 -1
- package/dist/chunks/libs/nano-spawn.mjs +0 -3
- package/dist/chunks/libs/p-queue.mjs +0 -1
- package/dist/chunks/libs/pathe.mjs +0 -1
- package/dist/chunks/libs/picomatch.mjs +0 -1
- package/dist/chunks/libs/pretty-ms.mjs +0 -1
- package/dist/chunks/libs/remark-github-blockquote-alert.mjs +0 -3
- package/dist/chunks/libs/remark-rehype.mjs +0 -1
- package/dist/chunks/libs/remeda.mjs +0 -1
- package/dist/chunks/libs/ufo.mjs +0 -1
- package/dist/chunks/libs/unified.mjs +0 -1
- package/dist/chunks/libs/unstorage.mjs +0 -1
- package/dist/chunks/rolldown-runtime.mjs +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"../rolldown-runtime.mjs";import{c as e,i as t,r as n,s as r}from"./chevrotain.mjs";import{c as i,d as a,f as o,h as s,l as c,o as l,p as u,u as d}from"./@chevrotain/cst-dts-gen.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(e,t,n){return n instanceof s?tokenRef(e,t,n.terminalType,n):n instanceof i?ruleRef(e,t,n):n instanceof l?alternation(e,t,n):n instanceof c?option(e,t,n):n instanceof d?repetition(e,t,n):n instanceof u?repetitionSep(e,t,n):n instanceof a?repetitionMandatory(e,t,n):n instanceof o?repetitionMandatorySep(e,t,n):block(e,t,n)}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 l)return`Alternation`;if(e instanceof c)return`Option`;if(e instanceof d)return`Repetition`;if(e instanceof u)return`RepetitionWithSeparator`;if(e instanceof a)return`RepetitionMandatory`;if(e instanceof o)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 n{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:n,rule:r,hasPredicates:i,dynamicTokensEnabled:a}=e,o=this.dfas,s=this.logging,c=buildATNKey(r,`Alternation`,n),l=this.atn.decisionMap[c].decision,u=map(t({maxLookahead:1,occurrence:n,prodType:`Alternation`,rule:r}),e=>map(e,e=>e[0]));if(isLL1Sequence(u,!1)&&!a){let e=reduce(u,(e,t,n)=>(forEach(t,t=>{t&&(e[t.tokenTypeIdx]=n,forEach(t.categoryMatches,t=>{e[t]=n}))}),e),{});return i?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(i)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,o,l,t,s);return typeof r==`number`?r:void 0};else return function(){let e=adaptivePredict.call(this,o,l,nn,s);return typeof e==`number`?e:void 0}}buildLookaheadForOptional(e){let{prodOccurrence:n,rule:r,prodType:i,dynamicTokensEnabled:a}=e,o=this.dfas,s=this.logging,c=buildATNKey(r,i,n),l=this.atn.decisionMap[c].decision,u=map(t({maxLookahead:1,occurrence:n,prodType:i,rule:r}),e=>map(e,e=>e[0]));if(isLL1Sequence(u)&&u[0][0]&&!a){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,o,l,nn,s);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=>r(e)).join(`, `),n=e.production.idx===0?``:e.production.idx,i=`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 i+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
2
|
-
For Further details.`,i}function getProductionDslName(e){if(e instanceof i)return`SUBRULE`;if(e instanceof c)return`OPTION`;if(e instanceof l)return`OR`;if(e instanceof a)return`AT_LEAST_ONE`;if(e instanceof o)return`AT_LEAST_ONE_SEP`;if(e instanceof u)return`MANY_SEP`;if(e instanceof d)return`MANY`;if(e instanceof s)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(t,n){if(t instanceof AtomTransition&&e(n,t.tokenType))return t.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};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import{r as e}from"../rolldown-runtime.mjs";import{n as t,t as n}from"./@chevrotain/regexp-to-ast.mjs";import{a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v}from"./@chevrotain/cst-dts-gen.mjs";import{assign as y,clone as b,compact as x,defaults as S,difference as C,drop as w,dropRight as T,every as E,filter as D,find as O,first as k,flatMap as A,flatten as j,forEach as M,groupBy as ee,has as N,identity as P,includes as F,indexOf as te,isArray as I,isEmpty as L,isFunction as R,isObject as ne,isRegExp as z,isString as B,isUndefined as V,keys as re,last as H,map as U,noop as W,pickBy as ie,reduce as G,reject as ae,some as oe,uniq as se,values as K}from"lodash-es";function PRINT_ERROR(e){console&&console.error&&console.error(`Error: ${e}`)}function PRINT_WARNING(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function timer(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function toFastProperties(e){function FakeConstructor(){}FakeConstructor.prototype=e;let t=new FakeConstructor;function fakeAccess(){return typeof t.bar}return fakeAccess(),fakeAccess(),e}var RestWalker=class{walk(e,t=[]){M(e.definition,(n,r)=>{let s=w(e.definition,r+1);if(n instanceof i)this.walkProdRef(n,s,t);else if(n instanceof c)this.walkTerminal(n,s,t);else if(n instanceof g)this.walkFlat(n,s,t);else if(n instanceof u)this.walkOption(n,s,t);else if(n instanceof a)this.walkAtLeastOne(n,s,t);else if(n instanceof o)this.walkAtLeastOneSep(n,s,t);else if(n instanceof m)this.walkManySep(n,s,t);else if(n instanceof v)this.walkMany(n,s,t);else if(n instanceof p)this.walkOr(n,s,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);M(e.definition,e=>{let t=new g({definition:[e]});this.walk(t,r)})}};function restForRepetitionWithSeparator(e,t,n){return[new u({definition:[new c({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function first$1(e){if(e instanceof i)return first$1(e.referencedRule);if(e instanceof c)return firstForTerminal(e);if(l(e))return firstForSequence(e);if(f(e))return firstForBranching(e);throw Error(`non exhaustive match`)}e(first$1,`first`);function firstForSequence(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=h(a),t=t.concat(first$1(a)),r+=1,i=n.length>r;return se(t)}function firstForBranching(e){return se(j(U(e.definition,e=>first$1(e))))}function firstForTerminal(e){return[e.terminalType]}const ce=`_~IN~_`;var ResyncFollowsWalker=class extends RestWalker{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=buildBetweenProdsFollowPrefix(e.referencedRule,e.idx)+this.topProd.name,i=first$1(new g({definition:t.concat(n)}));this.follows[r]=i}};function computeAllProdsFollows(e){let t={};return M(e,e=>{let n=new ResyncFollowsWalker(e).startWalking();y(t,n)}),t}function buildBetweenProdsFollowPrefix(e,t){return e.name+t+ce}let le={};const ue=new t;function getRegExpAst(e){let t=e.toString();if(le.hasOwnProperty(t))return le[t];{let e=ue.pattern(t);return le[t]=e,e}}function clearRegExpParserCache(){le={}}const de=`Complement Sets are not supported for first char optimization`,fe=`Unable to use "first char" lexer optimizations:
|
|
2
|
-
`;function getOptimizedStartCodesIndices(e,t=!1){try{let t=getRegExpAst(e);return firstCharOptimizedIndices(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===de)t&&PRINT_WARNING(`${fe}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
|
|
3
|
-
This will disable the lexer's first char optimizations.
|
|
4
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
|
|
5
|
-
This will disable the lexer's first char optimizations.
|
|
6
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),PRINT_ERROR(`${fe}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function firstCharOptimizedIndices(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)firstCharOptimizedIndices(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:addOptimizedIdxToResult(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(de);M(a.value,e=>{if(typeof e==`number`)addOptimizedIdxToResult(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)addOptimizedIdxToResult(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)addOptimizedIdxToResult(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=charCodeToOptimizedIndex(e),a=charCodeToOptimizedIndex(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:firstCharOptimizedIndices(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&isWholeOptional(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return K(t)}function addOptimizedIdxToResult(e,t,n){let r=charCodeToOptimizedIndex(e);t[r]=r,n===!0&&handleIgnoreCase(e,t)}function handleIgnoreCase(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=charCodeToOptimizedIndex(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=charCodeToOptimizedIndex(e.charCodeAt(0));t[n]=n}}}function findCode(e,t){return O(e.value,e=>{if(typeof e==`number`)return F(t,e);{let n=e;return O(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function isWholeOptional(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?I(e.value)?E(e.value,isWholeOptional):isWholeOptional(e.value):!1}var CharCodeFinder=class extends n{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){F(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?findCode(e,this.targetCharCodes)===void 0&&(this.found=!0):findCode(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function canMatchCharCode(e,t){if(t instanceof RegExp){let n=getRegExpAst(t),r=new CharCodeFinder(e);return r.visit(n),r.found}else return O(t,t=>F(e,t.charCodeAt(0)))!==void 0}const q=`PATTERN`,pe=`defaultMode`;let me=typeof RegExp(`(?:)`).sticky==`boolean`;function analyzeTokenTypes(e,t){t=S(t,{useSticky:me,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
|
|
7
|
-
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{initCharCodeToOptimizedIndexMap()});let r;n(`Reject Lexer.NA`,()=>{r=ae(e,e=>e[q]===Lexer.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=U(r,e=>{let n=e[q];if(z(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!F([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?addStickyFlag(n):addStartOfInput(n)}else if(R(n))return i=!0,{exec:n};else if(typeof n==`object`)return i=!0,n;else if(typeof n==`string`){if(n.length===1)return n;{let e=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),r=new RegExp(e);return t.useSticky?addStickyFlag(r):addStartOfInput(r)}}else throw Error(`non exhaustive match`)})});let o,s,c,l,u;n(`misc mapping`,()=>{o=U(r,e=>e.tokenTypeIdx),s=U(r,e=>{let t=e.GROUP;if(t!==Lexer.SKIPPED){if(B(t))return t;if(V(t))return!1;throw Error(`non exhaustive match`)}}),c=U(r,e=>{let t=e.LONGER_ALT;if(t)return I(t)?U(t,e=>te(r,e)):[te(r,t)]}),l=U(r,e=>e.PUSH_MODE),u=U(r,e=>N(e,`POP_MODE`))});let d;n(`Line Terminator Handling`,()=>{let e=getCharCodes(t.lineTerminatorCharacters);d=U(r,e=>!1),t.positionTracking!==`onlyOffset`&&(d=U(r,t=>N(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:checkLineBreaksIssues(t,e)===!1&&canMatchCharCode(e,t.PATTERN)))});let f,p,m,h;n(`Misc Mapping #2`,()=>{f=U(r,isCustomPattern),p=U(a,isShortPattern),m=G(r,(e,t)=>{let n=t.GROUP;return B(n)&&n!==Lexer.SKIPPED&&(e[n]=[]),e},{}),h=U(a,(e,t)=>({pattern:a[t],longerAlt:c[t],canLineTerminator:d[t],isCustom:f[t],short:p[t],group:s[t],push:l[t],pop:u[t],tokenTypeIdx:o[t],tokenType:r[t]}))});let g=!0,_=[];return t.safeMode||n(`First Char Optimization`,()=>{_=G(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)addToMapOfArrays(e,charCodeToOptimizedIndex(n.PATTERN.charCodeAt(0)),h[r]);else if(I(n.START_CHARS_HINT)){let t;M(n.START_CHARS_HINT,n=>{let i=charCodeToOptimizedIndex(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,addToMapOfArrays(e,i,h[r]))})}else if(z(n.PATTERN))if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&PRINT_ERROR(`${fe}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
8
|
-
This will disable the lexer's first char optimizations.
|
|
9
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=getOptimizedStartCodesIndices(n.PATTERN,t.ensureOptimizations);L(i)&&(g=!1),M(i,t=>{addToMapOfArrays(e,t,h[r])})}else t.ensureOptimizations&&PRINT_ERROR(`${fe}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
|
|
10
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e},[])}),{emptyGroups:m,patternIdxToConfig:h,charCodeToPatternIdxToConfig:_,hasCustom:i,canBeOptimized:g}}function validatePatterns(e,t){let n=[],r=findMissingPatterns(e);n=n.concat(r.errors);let i=findInvalidPatterns(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(validateRegExpPattern(a)),n=n.concat(findInvalidGroupType(a)),n=n.concat(findModesThatDoNotExist(a,t)),n=n.concat(findUnreachablePatterns(a)),n}function validateRegExpPattern(e){let t=[],n=D(e,e=>z(e[q]));return t=t.concat(findEndOfInputAnchor(n)),t=t.concat(findStartOfInputAnchor(n)),t=t.concat(findUnsupportedFlags(n)),t=t.concat(findDuplicatePatterns(n)),t=t.concat(findEmptyMatchRegExps(n)),t}function findMissingPatterns(e){let t=D(e,e=>!N(e,q));return{errors:U(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:J.MISSING_PATTERN,tokenTypes:[e]})),valid:C(e,t)}}function findInvalidPatterns(e){let t=D(e,e=>{let t=e[q];return!z(t)&&!R(t)&&!N(t,`exec`)&&!B(t)});return{errors:U(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:J.INVALID_PATTERN,tokenTypes:[e]})),valid:C(e,t)}}const he=/[^\\][$]/;function findEndOfInputAnchor(e){class EndAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return U(D(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new EndAnchorFinder;return n.visit(e),n.found}catch{return he.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
11
|
-
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
12
|
-
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findEmptyMatchRegExps(e){return U(D(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:J.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}const ge=/[^\\[][\^]|^\^/;function findStartOfInputAnchor(e){class StartAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return U(D(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new StartAnchorFinder;return n.visit(e),n.found}catch{return ge.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
13
|
-
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
14
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findUnsupportedFlags(e){return U(D(e,e=>{let t=e[q];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:J.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function findDuplicatePatterns(e){let t=[],n=U(e,n=>G(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!F(t,r)&&r.PATTERN!==Lexer.NA?(t.push(r),e.push(r),e):e,[]));return n=x(n),U(D(n,e=>e.length>1),e=>{let t=U(e,e=>e.name);return{message:`The same RegExp pattern ->${k(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:J.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function findInvalidGroupType(e){return U(D(e,e=>{if(!N(e,`GROUP`))return!1;let t=e.GROUP;return t!==Lexer.SKIPPED&&t!==Lexer.NA&&!B(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:J.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function findModesThatDoNotExist(e,t){return U(D(e,e=>e.PUSH_MODE!==void 0&&!F(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:J.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function findUnreachablePatterns(e){let t=[],n=G(e,(e,t,n)=>{let r=t.PATTERN;return r===Lexer.NA||(B(r)?e.push({str:r,idx:n,tokenType:t}):z(r)&&noMetaChar(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return M(e,(e,r)=>{M(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&testTokenType(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:J.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function testTokenType(e,t){if(z(t)){let n=t.exec(e);return n!==null&&n.index===0}else if(R(t))return t(e,0,[],{});else if(N(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}function noMetaChar(e){return O([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function addStartOfInput(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}function addStickyFlag(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function performRuntimeChecks(e,t,n){let r=[];return N(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition
|
|
15
|
-
`,type:J.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),N(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
|
|
16
|
-
`,type:J.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),N(e,`modes`)&&N(e,`defaultMode`)&&!N(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${pe}: <${e.defaultMode}>which does not exist\n`,type:J.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),N(e,`modes`)&&M(e.modes,(e,t)=>{M(e,(n,i)=>{V(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:J.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):N(n,`LONGER_ALT`)&&M(I(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!V(i)&&!F(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:J.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function performWarningRuntimeChecks(e,t,n){let r=[],i=!1,a=ae(x(j(K(e.modes))),e=>e[q]===Lexer.NA),o=getCharCodes(n);return t&&M(a,e=>{let t=checkLineBreaksIssues(e,o);if(t!==!1){let n={message:buildLineBreakIssueMessage(e,t),type:t.issue,tokenType:e};r.push(n)}else N(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):canMatchCharCode(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
|
|
17
|
-
This Lexer has been defined to track line and column information,
|
|
18
|
-
But none of the Token Types can be identified as matching a line terminator.
|
|
19
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
20
|
-
for details.`,type:J.NO_LINE_BREAKS_FLAGS}),r}function cloneEmptyGroups(e){let t={};return M(re(e),n=>{let r=e[n];if(I(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function isCustomPattern(e){let t=e.PATTERN;if(z(t))return!1;if(R(t)||N(t,`exec`))return!0;if(B(t))return!1;throw Error(`non exhaustive match`)}function isShortPattern(e){return B(e)&&e.length===1?e.charCodeAt(0):!1}const _e={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return e.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function checkLineBreaksIssues(e,t){if(N(e,`LINE_BREAKS`))return!1;if(z(e.PATTERN)){try{canMatchCharCode(t,e.PATTERN)}catch(e){return{issue:J.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(B(e.PATTERN))return!1;else if(isCustomPattern(e))return{issue:J.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}function buildLineBreakIssueMessage(e,t){if(t.issue===J.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
21
|
-
\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===J.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
22
|
-
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function getCharCodes(e){return U(e,e=>B(e)?e.charCodeAt(0):e)}function addToMapOfArrays(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}let ve=[];function charCodeToOptimizedIndex(e){return e<256?e:ve[e]}function initCharCodeToOptimizedIndexMap(){if(L(ve)){ve=Array(65536);for(let e=0;e<65536;e++)ve[e]=e>255?255+~~(e/255):e}}function tokenStructuredMatcher(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx||t.isParent===!0&&t.categoryMatchesMap[n]===!0}function tokenStructuredMatcherNoCategories(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let ye=1;const be={};function augmentTokenTypes(e){let t=expandCategories(e);assignTokenDefaultProps(t),assignCategoriesMapProp(t),assignCategoriesTokensProp(t),M(t,e=>{e.isParent=e.categoryMatches.length>0})}function expandCategories(e){let t=b(e),n=e,r=!0;for(;r;){n=x(j(U(n,e=>e.CATEGORIES)));let e=C(n,t);t=t.concat(e),L(e)?r=!1:n=e}return t}function assignTokenDefaultProps(e){M(e,e=>{hasShortKeyProperty(e)||(be[ye]=e,e.tokenTypeIdx=ye++),hasCategoriesProperty(e)&&!I(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),hasCategoriesProperty(e)||(e.CATEGORIES=[]),hasExtendingTokensTypesProperty(e)||(e.categoryMatches=[]),hasExtendingTokensTypesMapProperty(e)||(e.categoryMatchesMap={})})}function assignCategoriesTokensProp(e){M(e,e=>{e.categoryMatches=[],M(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(be[n].tokenTypeIdx)})})}function assignCategoriesMapProp(e){M(e,e=>{singleAssignCategoriesToksMap([],e)})}function singleAssignCategoriesToksMap(e,t){M(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),M(t.CATEGORIES,n=>{let r=e.concat(t);F(r,n)||singleAssignCategoriesToksMap(r,n)})}function hasShortKeyProperty(e){return N(e,`tokenTypeIdx`)}function hasCategoriesProperty(e){return N(e,`CATEGORIES`)}function hasExtendingTokensTypesProperty(e){return N(e,`categoryMatches`)}function hasExtendingTokensTypesMapProperty(e){return N(e,`categoryMatchesMap`)}function isTokenType(e){return N(e,`tokenTypeIdx`)}const xe={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}};var J;(function(e){e[e.MISSING_PATTERN=0]=`MISSING_PATTERN`,e[e.INVALID_PATTERN=1]=`INVALID_PATTERN`,e[e.EOI_ANCHOR_FOUND=2]=`EOI_ANCHOR_FOUND`,e[e.UNSUPPORTED_FLAGS_FOUND=3]=`UNSUPPORTED_FLAGS_FOUND`,e[e.DUPLICATE_PATTERNS_FOUND=4]=`DUPLICATE_PATTERNS_FOUND`,e[e.INVALID_GROUP_TYPE_FOUND=5]=`INVALID_GROUP_TYPE_FOUND`,e[e.PUSH_MODE_DOES_NOT_EXIST=6]=`PUSH_MODE_DOES_NOT_EXIST`,e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]=`MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE`,e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]=`MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY`,e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]=`MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST`,e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]=`LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED`,e[e.SOI_ANCHOR_FOUND=11]=`SOI_ANCHOR_FOUND`,e[e.EMPTY_MATCH_PATTERN=12]=`EMPTY_MATCH_PATTERN`,e[e.NO_LINE_BREAKS_FLAGS=13]=`NO_LINE_BREAKS_FLAGS`,e[e.UNREACHABLE_PATTERN=14]=`UNREACHABLE_PATTERN`,e[e.IDENTIFY_TERMINATOR=15]=`IDENTIFY_TERMINATOR`,e[e.CUSTOM_LINE_BREAK=16]=`CUSTOM_LINE_BREAK`,e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]=`MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE`})(J||={});const Se={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
23
|
-
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:xe,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Se);var Lexer=class{constructor(e,t=Se){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=timer(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
24
|
-
a boolean 2nd argument is no longer supported`);this.config=y({},Se,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT(`Lexer Constructor`,()=>{let n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===Se.lineTerminatorsPattern)this.config.lineTerminatorsPattern=_e;else if(this.config.lineTerminatorCharacters===Se.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
25
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),I(e)?n={modes:{defaultMode:b(e)},defaultMode:pe}:(r=!1,n=b(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(performRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(performWarningRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},M(n.modes,(e,t)=>{n.modes[t]=ae(e,e=>V(e))});let i=re(n.modes);if(M(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(validatePatterns(e,i))}),L(this.lexerDefinitionErrors)){augmentTokenTypes(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=analyzeTokenTypes(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=y({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!L(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=U(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
26
|
-
`);throw Error(`Errors detected in definition of Lexer:
|
|
27
|
-
`+e)}M(this.lexerDefinitionWarning,e=>{PRINT_WARNING(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(me?(this.chopInput=P,this.match=this.matchWithTest):(this.updateLastIndex=W,this.match=this.matchWithExec),r&&(this.handleModes=W),this.trackStartLines===!1&&(this.computeNewColumn=P),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=W),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=G(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!L(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
28
|
-
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{clearRegExpParserCache()}),this.TRACE_INIT(`toFastProperties`,()=>{toFastProperties(this)})})}tokenize(e,t=this.defaultMode){if(!L(this.lexerDefinitionErrors)){let e=U(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
29
|
-
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
30
|
-
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,v=_.length,y=0,b=0,x=this.hasCustom?0:Math.floor(e.length/10),S=Array(x),C=[],w=this.trackStartLines?1:void 0,T=this.trackStartLines?1:void 0,E=cloneEmptyGroups(this.emptyGroups),D=this.trackStartLines,O=this.config.lineTerminatorsPattern,k=0,A=[],j=[],M=[],ee=[];Object.freeze(ee);let N;function getPossiblePatternsSlow(){return A}function getPossiblePatternsOptimized(e){let t=charCodeToOptimizedIndex(e),n=j[t];return n===void 0?ee:n}let pop_mode=e=>{if(M.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);C.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{M.pop();let e=H(M);A=this.patternIdxToConfig[e],j=this.charCodeToPatternIdxToConfig[e],k=A.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;N=j&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}};function push_mode(e){M.push(e),j=this.charCodeToPatternIdxToConfig[e],A=this.patternIdxToConfig[e],k=A.length,k=A.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;N=j&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}push_mode.call(this,t);let P,F=this.config.recoveryEnabled;for(;y<v;){s=null;let t=_.charCodeAt(y),x=N(t),j=x.length;for(n=0;n<j;n++){P=x[n];let r=P.pattern;c=null;let u=P.short;if(u===!1?P.isCustom===!0?(g=r.exec(_,y,S,E),g===null?s=null:(s=g[0],g.payload!==void 0&&(c=g.payload))):(this.updateLastIndex(r,y),s=this.match(r,e,y)):t===u&&(s=r),s!==null){if(o=P.longerAlt,o!==void 0){let t=o.length;for(i=0;i<t;i++){let t=A[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(_,y,S,E),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(this.updateLastIndex(n,y),a=this.match(n,e,y)),a&&a.length>s.length){s=a,c=l,P=t;break}}}break}}if(s!==null){if(u=s.length,d=P.group,d!==void 0&&(f=P.tokenTypeIdx,p=this.createTokenInstance(s,y,f,P.tokenType,w,T,u),this.handlePayload(p,c),d===!1?b=this.addToken(S,b,p):E[d].push(p)),e=this.chopInput(e,u),y+=u,T=this.computeNewColumn(T,u),D===!0&&P.canLineTerminator===!0){let e=0,t,n;O.lastIndex=0;do t=O.test(s),t===!0&&(n=O.lastIndex-1,e++);while(t===!0);e!==0&&(w+=e,T=u-n,this.updateTokenEndLineColumnLocation(p,d,n,e,w,T,u))}this.handleModes(P,pop_mode,push_mode,p)}else{let t=y,n=w,i=T,a=F===!1;for(;a===!1&&y<v;)for(e=this.chopInput(e,1),y++,r=0;r<k;r++){let t=A[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(_,y,S,E)!==null:(this.updateLastIndex(n,y),a=n.exec(e)!==null):_.charCodeAt(y)===i&&(a=!0),a===!0)break}if(m=y-t,T=this.computeNewColumn(T,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,t,m,n,i),C.push({offset:t,line:n,column:i,length:m,message:h}),F===!1)break}}return this.hasCustom||(S.length=b),{tokens:S,groups:E,errors:C}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,(r!==1||s!==!0)&&(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchWithExec(e,t){let n=e.exec(t);return n===null?null:n[0]}};Lexer.SKIPPED=`This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.`,Lexer.NA=/NOT_APPLICABLE/;function tokenLabel(e){return hasTokenLabel(e)?e.LABEL:e.name}function hasTokenLabel(e){return B(e.LABEL)&&e.LABEL!==``}const Ce=`categories`,we=`label`,Te=`group`,Ee=`push_mode`,De=`pop_mode`,Oe=`longer_alt`,ke=`line_breaks`,Ae=`start_chars_hint`;function createToken(e){return createTokenInternal(e)}function createTokenInternal(e){let t=e.pattern,n={};if(n.name=e.name,V(t)||(n.PATTERN=t),N(e,`parent`))throw`The parent property is no longer supported.
|
|
31
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return N(e,Ce)&&(n.CATEGORIES=e[Ce]),augmentTokenTypes([n]),N(e,we)&&(n.LABEL=e[we]),N(e,Te)&&(n.GROUP=e[Te]),N(e,De)&&(n.POP_MODE=e[De]),N(e,Ee)&&(n.PUSH_MODE=e[Ee]),N(e,Oe)&&(n.LONGER_ALT=e[Oe]),N(e,ke)&&(n.LINE_BREAKS=e[ke]),N(e,Ae)&&(n.START_CHARS_HINT=e[Ae]),n}const Y=createToken({name:`EOF`,pattern:Lexer.NA});augmentTokenTypes([Y]);function createTokenInstance(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function tokenMatcher(e,t){return tokenStructuredMatcher(e,t)}const je={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${hasTokenLabel(e)?`--> ${tokenLabel(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
|
|
32
|
-
but found: '`+k(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${U(U(G(e,(e,t)=>e.concat(t),[]),e=>`[${U(e,e=>tokenLabel(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
|
|
33
|
-
`)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
|
|
34
|
-
but found: '`+k(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${U(e,e=>`[${U(e,e=>tokenLabel(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(je);const Me={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
|
|
35
|
-
inside top level rule: ->`+e.name+`<-`}},X={buildDuplicateFoundError(e,t){function getExtraProductionArgument(e){return e instanceof c?e.terminalType.name:e instanceof i?e.nonTerminalName:``}let n=e.name,r=k(t),a=r.idx,o=_(r),s=getExtraProductionArgument(r),l=`->${o}${a>0?a:``}<- ${s?`with argument: ->${s}<-`:``}
|
|
36
|
-
appears more than once (${t.length} times) in the top level rule: ->${n}<-.
|
|
37
|
-
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
38
|
-
`;return l=l.replace(/[ \t]+/g,` `),l=l.replace(/\s\s+/g,`
|
|
39
|
-
`),l},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=U(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=U(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${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
|
|
40
|
-
For Further details.`,r},buildEmptyRepetitionError(e){let t=_(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${U(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof d?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function resolveGrammar$1(e,t){let n=new GastRefResolverVisitor(e,t);return n.resolveRefs(),n.errors}e(resolveGrammar$1,`resolveGrammar`);var GastRefResolverVisitor=class extends r{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){M(K(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},AbstractNextPossibleTokensWalker=class extends RestWalker{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName=``,this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error(`The path does not start with the walker's top Rule!`);return this.ruleStack=b(this.path.ruleStack).reverse(),this.occurrenceStack=b(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){L(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},NextAfterTokenWalker=class extends AbstractNextPossibleTokensWalker{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new g({definition:t.concat(n)});this.possibleTokTypes=first$1(e),this.found=!0}}},AbstractNextTerminalAfterProductionWalker=class extends RestWalker{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},NextTerminalAfterManyWalker=class extends AbstractNextTerminalAfterProductionWalker{walkMany(e,t,n){if(e.idx===this.occurrence){let e=k(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof c&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},NextTerminalAfterManySepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=k(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof c&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},NextTerminalAfterAtLeastOneWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=k(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof c&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},NextTerminalAfterAtLeastOneSepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=k(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof c&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function possiblePathsFrom(e,t,n=[]){n=b(n);let r=[],s=0;function remainingPathWith(t){return t.concat(w(e,s+1))}function getAlternativesForProd(e){let i=possiblePathsFrom(remainingPathWith(e),t,n);return r.concat(i)}for(;n.length<t&&s<e.length;){let t=e[s];if(t instanceof g||t instanceof i)return getAlternativesForProd(t.definition);if(t instanceof u)r=getAlternativesForProd(t.definition);else if(t instanceof a)return getAlternativesForProd(t.definition.concat([new v({definition:t.definition})]));else if(t instanceof o)return getAlternativesForProd([new g({definition:t.definition}),new v({definition:[new c({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof m)r=getAlternativesForProd(t.definition.concat([new v({definition:[new c({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof v)r=getAlternativesForProd(t.definition.concat([new v({definition:t.definition})]));else if(t instanceof p)return M(t.definition,e=>{L(e.definition)===!1&&(r=getAlternativesForProd(e.definition))}),r;else if(t instanceof c)n.push(t.terminalType);else throw Error(`non exhaustive match`);s++}return r.push({partialPath:n,suffixDef:w(e,s)}),r}function nextPossibleTokensAfter(e,t,n,r){let s=`EXIT_NONE_TERMINAL`,l=[s],f=`EXIT_ALTERNATIVE`,h=!1,_=t.length,y=_-r-1,x=[],S=[];for(S.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!L(S);){let e=S.pop();if(e===f){h&&H(S).idx<=y&&S.pop();continue}let r=e.def,C=e.idx,E=e.ruleStack,D=e.occurrenceStack;if(L(r))continue;let O=r[0];if(O===s){let e={idx:C,def:w(r),ruleStack:T(E),occurrenceStack:T(D)};S.push(e)}else if(O instanceof c)if(C<_-1){let e=C+1,i=t[e];if(n(i,O.terminalType)){let t={idx:e,def:w(r),ruleStack:E,occurrenceStack:D};S.push(t)}}else if(C===_-1)x.push({nextTokenType:O.terminalType,nextTokenOccurrence:O.idx,ruleStack:E,occurrenceStack:D}),h=!0;else throw Error(`non exhaustive match`);else if(O instanceof i){let e=b(E);e.push(O.nonTerminalName);let t=b(D);t.push(O.idx);let n={idx:C,def:O.definition.concat(l,w(r)),ruleStack:e,occurrenceStack:t};S.push(n)}else if(O instanceof u){let e={idx:C,def:w(r),ruleStack:E,occurrenceStack:D};S.push(e),S.push(f);let t={idx:C,def:O.definition.concat(w(r)),ruleStack:E,occurrenceStack:D};S.push(t)}else if(O instanceof a){let e=new v({definition:O.definition,idx:O.idx}),t={idx:C,def:O.definition.concat([e],w(r)),ruleStack:E,occurrenceStack:D};S.push(t)}else if(O instanceof o){let e=new v({definition:[new c({terminalType:O.separator})].concat(O.definition),idx:O.idx}),t={idx:C,def:O.definition.concat([e],w(r)),ruleStack:E,occurrenceStack:D};S.push(t)}else if(O instanceof m){let e={idx:C,def:w(r),ruleStack:E,occurrenceStack:D};S.push(e),S.push(f);let t=new v({definition:[new c({terminalType:O.separator})].concat(O.definition),idx:O.idx}),n={idx:C,def:O.definition.concat([t],w(r)),ruleStack:E,occurrenceStack:D};S.push(n)}else if(O instanceof v){let e={idx:C,def:w(r),ruleStack:E,occurrenceStack:D};S.push(e),S.push(f);let t=new v({definition:O.definition,idx:O.idx}),n={idx:C,def:O.definition.concat([t],w(r)),ruleStack:E,occurrenceStack:D};S.push(n)}else if(O instanceof p)for(let e=O.definition.length-1;e>=0;e--){let t={idx:C,def:O.definition[e].definition.concat(w(r)),ruleStack:E,occurrenceStack:D};S.push(t),S.push(f)}else if(O instanceof g)S.push({idx:C,def:O.definition.concat(w(r)),ruleStack:E,occurrenceStack:D});else if(O instanceof d)S.push(expandTopLevelRule(O,C,E,D));else throw Error(`non exhaustive match`)}return x}function expandTopLevelRule(e,t,n,r){let i=b(n);i.push(e.name);let a=b(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(Z||={});function getProdType(e){if(e instanceof u||e===`Option`)return Z.OPTION;if(e instanceof v||e===`Repetition`)return Z.REPETITION;if(e instanceof a||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof o||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof m||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof p||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function getLookaheadPaths(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=getProdType(r);return a===Z.ALTERNATION?getLookaheadPathsForOr(t,n,i):getLookaheadPathsForOptionalProd(t,n,a,i)}function buildLookaheadFuncForOr(e,t,n,r,i,a){let o=getLookaheadPathsForOr(e,t,n);return a(o,r,areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,i)}function buildLookaheadFuncForOptionalProd(e,t,n,r,i,a){let o=getLookaheadPathsForOptionalProd(e,t,i,n),s=areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher;return a(o[0],s,r)}function buildAlternativesLookAheadFunc(e,t,n,r){let i=e.length,a=E(e,e=>E(e,e=>e.length===1));if(t)return function(t){let r=U(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(o===void 0||o.call(this)!==!1)nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=G(U(e,e=>j(e)),(e,t,n)=>(M(t,t=>{N(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),M(t.categoryMatches,t=>{N(e,t)||(e[t]=n)})}),e),{});return function(){let e=this.LA(1);return t[e.tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function buildSingleAlternativeLookaheadFunction(e,t,n){let r=E(e,e=>e.length===1),i=e.length;if(r&&!n){let t=j(e);if(t.length===1&&L(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=G(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,M(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){let t=this.LA(1);return e[t.tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var RestDefinitionFinderWalker=class extends RestWalker{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},InsideDefinitionFinderVisitor=class extends r{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function initializeArrayOfArrays(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function pathToHashKeys(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function isUniquePrefixHash(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function lookAheadSequenceFromAlternatives(e,t){let n=U(e,e=>possiblePathsFrom([e],1)),r=initializeArrayOfArrays(n.length),i=U(n,e=>{let t={};return M(e,e=>{M(pathToHashKeys(e.partialPath),e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=initializeArrayOfArrays(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=pathToHashKeys(c);if(isUniquePrefixHash(i,u,o)||L(l)||c.length===t){let e=r[o];if(containsPath(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=possiblePathsFrom(l,e+1,c);a[o]=a[o].concat(t),M(t,e=>{M(pathToHashKeys(e.partialPath),e=>{i[o][e]=!0})})}}}}return r}function getLookaheadPathsForOr(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,Z.ALTERNATION,r);return t.accept(i),lookAheadSequenceFromAlternatives(i.result,n)}function getLookaheadPathsForOptionalProd(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,n);t.accept(i);let a=i.result,o=new RestDefinitionFinderWalker(t,e,n).startWalking();return lookAheadSequenceFromAlternatives([new g({definition:a}),new g({definition:o})],r)}function containsPath(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(n!==i&&i.categoryMatchesMap[n.tokenTypeIdx]===void 0)continue compareOtherPath}return!0}}return!1}function isStrictPrefixOfPath(e,t){return e.length<t.length&&E(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function areTokenCategoriesNotUsed(e){return E(e,e=>E(e,e=>E(e,e=>L(e.categoryMatches))))}function validateLookahead(e){return U(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function validateGrammar$1(e,t,n,r){let i=A(e,e=>validateDuplicateProductions(e,n)),a=checkTerminalAndNoneTerminalsNameSpace(e,t,n),o=A(e,e=>validateTooManyAlts(e,n)),s=A(e,t=>validateRuleDoesNotAlreadyExist(t,e,r,n));return i.concat(a,o,s)}e(validateGrammar$1,`validateGrammar`);function validateDuplicateProductions(e,t){let n=new OccurrenceValidationCollector;e.accept(n);let r=n.allProductions;return U(K(ie(ee(r,identifyProductionForDuplicates),e=>e.length>1)),n=>{let r=k(n),i=t.buildDuplicateFoundError(e,n),a=_(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=getExtraProductionArgument(r);return s&&(o.parameter=s),o})}function identifyProductionForDuplicates(e){return`${_(e)}_#_${e.idx}_#_${getExtraProductionArgument(e)}`}function getExtraProductionArgument(e){return e instanceof c?e.terminalType.name:e instanceof i?e.nonTerminalName:``}var OccurrenceValidationCollector=class extends r{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function validateRuleDoesNotAlreadyExist(e,t,n,r){let i=[];if(G(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function validateRuleIsOverridden(e,t,n){let r=[],i;return F(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function validateNoLeftRecursion(e,t,n,r=[]){let i=[],a=getFirstNoneTerminal(t.definition);if(L(a))return[];{let t=e.name;F(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=A(C(a,r.concat([e])),t=>{let i=b(r);return i.push(t),validateNoLeftRecursion(e,t,n,i)});return i.concat(o)}}function getFirstNoneTerminal(e){let t=[];if(L(e))return t;let n=k(e);if(n instanceof i)t.push(n.referencedRule);else if(n instanceof g||n instanceof u||n instanceof a||n instanceof o||n instanceof m||n instanceof v)t=t.concat(getFirstNoneTerminal(n.definition));else if(n instanceof p)t=j(U(n.definition,e=>getFirstNoneTerminal(e.definition)));else if(!(n instanceof c))throw Error(`non exhaustive match`);let r=h(n),s=e.length>1;if(r&&s){let n=w(e);return t.concat(getFirstNoneTerminal(n))}else return t}var OrCollector=class extends r{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function validateEmptyOrAlternative(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return A(r,n=>A(T(n.definition),(r,i)=>L(nextPossibleTokensAfter([r],[],tokenStructuredMatcher,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function validateAmbiguousAlternationAlternatives(e,t,n){let r=new OrCollector;e.accept(r);let i=r.alternations;return i=ae(i,e=>e.ignoreAmbiguities===!0),A(i,r=>{let i=r.idx,a=getLookaheadPathsForOr(i,e,r.maxLookahead||t,r),o=checkAlternativesAmbiguities(a,r,e,n),s=checkPrefixAlternativesAmbiguities(a,r,e,n);return o.concat(s)})}var RepetitionCollector=class extends r{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function validateTooManyAlts(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return A(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function validateSomeNonEmptyLookaheadPath(e,t,n){let r=[];return M(e,e=>{let i=new RepetitionCollector;e.accept(i);let a=i.allProductions;M(a,i=>{let a=getProdType(i),o=i.maxLookahead||t,s=i.idx,c=getLookaheadPathsForOptionalProd(s,e,a,o)[0];if(L(j(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function checkAlternativesAmbiguities(e,t,n,r){let i=[];return U(G(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||M(r,r=>{let o=[a];M(e,(e,n)=>{a!==n&&containsPath(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!containsPath(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=U(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function checkPrefixAlternativesAmbiguities(e,t,n,r){let i=G(e,(e,t,n)=>{let r=U(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return x(A(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,o=e.path;return U(D(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&isStrictPrefixOfPath(e.path,o)),e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function checkTerminalAndNoneTerminalsNameSpace(e,t,n){let r=[],i=U(t,e=>e.name);return M(e,e=>{let t=e.name;if(F(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function resolveGrammar(e){let t=S(e,{errMsgProvider:Me}),n={};return M(e.rules,e=>{n[e.name]=e}),resolveGrammar$1(n,t.errMsgProvider)}function validateGrammar(e){return e=S(e,{errMsgProvider:X}),validateGrammar$1(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const Ne=`MismatchedTokenException`,Pe=`NoViableAltException`,Fe=`EarlyExitException`,Ie=`NotAllInputParsedException`,Le=[Ne,Pe,Fe,Ie];Object.freeze(Le);function isRecognitionException(e){return F(Le,e.name)}var RecognitionException=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},MismatchedTokenException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ne}},NoViableAltException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Pe}},NotAllInputParsedException=class extends RecognitionException{constructor(e,t){super(e,t),this.name=Ie}},EarlyExitException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Fe}};const Re={};var InRuleRecoveryException=class extends Error{constructor(e){super(e),this.name=`InRuleRecoveryException`}},Recoverable=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=N(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=attemptInRepetitionRecovery)}getTokenToInsert(e){let t=createTokenInstance(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),generateErrorMessage=()=>{let e=this.LA(0),t=new MismatchedTokenException(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=T(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){generateErrorMessage();return}else if(n.call(this)){generateErrorMessage(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new InRuleRecoveryException(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||L(t))return!1;let n=this.LA(1);return O(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return F(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=O(e,e=>tokenMatcher(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Re;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return U(e,(n,r)=>r===0?Re:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return j(U(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Re)return[Y];let t=e.ruleName+e.idxInCallingRule+ce+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Y)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return T(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:b(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return U(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function attemptInRepetitionRecovery(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Y,u=1),l!==void 0&&u!==void 0&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const ze=1024,Be=1280,Ve=1536;function getKeyForAutomaticLookahead(e,t,n){return n|t|e}var LLkLookaheadStrategy=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(L(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return A(e,e=>validateNoLeftRecursion(e,e,X))}validateEmptyOrAlternatives(e){return A(e,e=>validateEmptyOrAlternative(e,X))}validateAmbiguousAlternationAlternatives(e,t){return A(e,e=>validateAmbiguousAlternationAlternatives(e,t,X))}validateSomeNonEmptyLookaheadPath(e,t){return validateSomeNonEmptyLookaheadPath(e,t,X)}buildLookaheadForAlternation(e){return buildLookaheadFuncForOr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,buildAlternativesLookAheadFunc)}buildLookaheadForOptional(e){return buildLookaheadFuncForOptionalProd(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,getProdType(e.prodType),buildSingleAlternativeLookaheadFunction)}},LooksAhead=class{initLooksAhead(e){this.dynamicTokensEnabled=N(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=N(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=N(e,`lookaheadStrategy`)?e.lookaheadStrategy:new LLkLookaheadStrategy({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){M(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=collectMethods(e);M(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${_(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),M(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,_(t))}),M(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,_(t))}),M(i,t=>{this.computeLookaheadFunc(e,t.idx,ze,`RepetitionMandatory`,t.maxLookahead,_(t))}),M(a,t=>{this.computeLookaheadFunc(e,t.idx,Ve,`RepetitionMandatoryWithSeparator`,t.maxLookahead,_(t))}),M(o,t=>{this.computeLookaheadFunc(e,t.idx,Be,`RepetitionWithSeparator`,t.maxLookahead,_(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return getKeyForAutomaticLookahead(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},DslMethodsCollectorVisitor=class extends r{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};const He=new DslMethodsCollectorVisitor;function collectMethods(e){He.reset(),e.accept(He);let t=He.dslMethods;return He.reset(),t}function setNodeLocationOnlyOffset(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function setNodeLocationFull(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function addTerminalToCst(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function addNoneTerminalToCst(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function defineNameProp(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function defaultVisit(e,t){let n=re(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function createBaseSemanticVisitorConstructor(e,t){let derivedConstructor=function(){};return defineNameProp(derivedConstructor,e+`BaseSemantics`),derivedConstructor.prototype={visit:function(e,t){if(I(e)&&(e=e[0]),!V(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=validateVisitor(this,t);if(!L(e)){let t=U(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
41
|
-
|
|
42
|
-
`).replace(/\n/g,`
|
|
43
|
-
`)}`)}}},derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor._RULE_NAMES=t,derivedConstructor}function createBaseVisitorConstructorWithDefaults(e,t,n){let derivedConstructor=function(){};defineNameProp(derivedConstructor,e+`BaseSemanticsWithDefaults`);let r=Object.create(n.prototype);return M(t,e=>{r[e]=defaultVisit}),derivedConstructor.prototype=r,derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor}var Ue;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Ue||={});function validateVisitor(e,t){return validateMissingCstMethods(e,t)}function validateMissingCstMethods(e,t){return x(U(D(t,t=>R(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Ue.MISSING_METHOD,methodName:t})))}var TreeBuilder=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=N(e,`nodeLocationTracking`)?e.nodeLocationTracking:Q.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=W,this.cstFinallyStateUpdate=W,this.cstPostTerminal=W,this.cstPostNonTerminal=W,this.cstPostRule=W;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationFull,this.setNodeLocationFromNode=setNodeLocationFull,this.cstPostRule=W,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationOnlyOffset,this.setNodeLocationFromNode=setNodeLocationOnlyOffset,this.cstPostRule=W,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=W,this.setInitialNodeLocation=W;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addTerminalToCst(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addNoneTerminalToCst(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(V(this.baseCstVisitorConstructor)){let e=createBaseSemanticVisitorConstructor(this.className,re(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(V(this.baseCstVisitorWithDefaultsConstructor)){let e=createBaseVisitorConstructorWithDefaults(this.className,re(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},LexerAdapter=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Je}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Je:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},RecognizerApi=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=Ye){if(F(this.definedRulesNames,e)){let t={message:X.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Ye){let r=validateRuleIsOverridden(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return s(K(this.gastProductionsCache))}},RecognizerEngine=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=tokenStructuredMatcherNoCategories,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},N(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
44
|
-
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
45
|
-
For Further details.`);if(I(e)){if(L(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
46
|
-
Note that the first argument for the parser constructor
|
|
47
|
-
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
48
|
-
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
49
|
-
For Further details.`)}if(I(e))this.tokensMap=G(e,(e,t)=>(e[t.name]=t,e),{});else if(N(e,`modes`)&&E(j(K(e.modes)),isTokenType)){let t=se(j(K(e.modes)));this.tokensMap=G(t,(e,t)=>(e[t.name]=t,e),{})}else if(ne(e))this.tokensMap=b(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=Y;let n=E(N(e,`modes`)?j(K(e.modes)):K(e),e=>L(e.categoryMatches));this.tokenMatcher=n?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,augmentTokenTypes(K(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=N(n,`resyncEnabled`)?n.resyncEnabled:Ye.resyncEnabled,i=N(n,`recoveryValueFunc`)?n.recoveryValueFunc:Ye.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function invokeRuleWithTry(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function invokeRuleWithTryCst(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(isRecognitionException(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r))if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}else return n(e);else{if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}}else if(r)return this.moveToTerminatedState(),n(e);else throw t}else throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof e!=`function`){r=e.DEF;let t=e.GATE;if(t!==void 0){let e=lookAheadFunc;lookAheadFunc=()=>t.call(this)&&e.call(this)}}else r=e;if(lookAheadFunc.call(this)===!0)return r.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(ze,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookAheadFunc;lookAheadFunc=()=>e.call(this)&&t.call(this)}}else r=t;if(lookAheadFunc.call(this)===!0){let e=this.doSingleRepetition(r);for(;lookAheadFunc.call(this)===!0&&e===!0;)e=this.doSingleRepetition(r)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],lookAheadFunc,ze,e,NextTerminalAfterAtLeastOneWalker)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Ve,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterAtLeastOneSepWalker],separatorLookAheadFunc,Ve,e,NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let lookaheadFunction=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookaheadFunction;lookaheadFunction=()=>e.call(this)&&t.call(this)}}else r=t;let i=!0;for(;lookaheadFunction.call(this)===!0&&i===!0;)i=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],lookaheadFunction,768,e,NextTerminalAfterManyWalker,i)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Be,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterManySepWalker],separatorLookAheadFunc,Be,e,NextTerminalAfterManySepWalker)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Ve,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=I(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new NotAllInputParsedException(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw isRecognitionException(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new MismatchedTokenException(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}else throw n}saveRecogState(){let e=this.errors,t=b(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Y)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},ErrorHandler=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=N(e,`errorMessageProvider`)?e.errorMessageProvider:Q.errorMessageProvider}SAVE_ERROR(e){if(isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:b(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return b(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=getLookaheadPathsForOptionalProd(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new EarlyExitException(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=getLookaheadPathsForOr(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new NoViableAltException(s,this.LA(1),o))}},ContentAssist=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(V(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return nextPossibleTokensAfter([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=k(e.ruleStack),n=this.getGAstProductions()[t];return new NextAfterTokenWalker(n,e).startWalking()}};const We={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(We);const Ge=createToken({name:`RECORDING_PHASE_TOKEN`,pattern:Lexer.NA});augmentTokenTypes([Ge]);const Ke=createTokenInstance(Ge,`This IToken indicates the Parser is in Recording Phase
|
|
50
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Ke);const qe={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
51
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var GastRecorder=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT(`Enable Recording`,()=>{for(let e=0;e<10;e++){let t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT(`Deleting Recording methods`,()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:``;delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Je}topLevelRuleRecord(e,t){try{let n=new d({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
|
|
52
|
-
This error was thrown during the "grammar recording phase" For more info see:
|
|
53
|
-
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return recordProd.call(this,u,e,t)}atLeastOneInternalRecord(e,t){recordProd.call(this,a,t,e)}atLeastOneSepFirstInternalRecord(e,t){recordProd.call(this,o,t,e,!0)}manyInternalRecord(e,t){recordProd.call(this,v,t,e)}manySepFirstInternalRecord(e,t){recordProd.call(this,m,t,e,!0)}orInternalRecord(e,t){return recordOrProd.call(this,e,t)}subruleInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!e||N(e,`ruleName`)===!1){let n=Error(`<SUBRULE${getIdxSuffix(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=H(this.recordingProdStack),a=e.ruleName,o=new i({idx:t,nonTerminalName:a,label:n?.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?qe:We}consumeInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!hasShortKeyProperty(e)){let n=Error(`<CONSUME${getIdxSuffix(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=H(this.recordingProdStack),i=new c({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Ke}};function recordProd(e,t,n,r=!1){assertMethodIdxIsValid(n);let i=H(this.recordingProdStack),a=R(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),N(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),We}function recordOrProd(e,t){assertMethodIdxIsValid(t);let n=H(this.recordingProdStack),r=I(e)===!1,i=r===!1?e:e.DEF,a=new p({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return N(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=oe(i,e=>R(e.GATE)),n.definition.push(a),M(i,e=>{let t=new g({definition:[]});a.definition.push(t),N(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:N(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),We}function getIdxSuffix(e){return e===0?``:`${e}`}function assertMethodIdxIsValid(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var PerformanceTracer=class{initPerformanceTracer(e){if(N(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Q.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=timer(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function applyMixins(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}const Je=createTokenInstance(Y,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Je);const Q=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:je,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Ye=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});var $;(function(e){e[e.INVALID_RULE_NAME=0]=`INVALID_RULE_NAME`,e[e.DUPLICATE_RULE_NAME=1]=`DUPLICATE_RULE_NAME`,e[e.INVALID_RULE_OVERRIDE=2]=`INVALID_RULE_OVERRIDE`,e[e.DUPLICATE_PRODUCTIONS=3]=`DUPLICATE_PRODUCTIONS`,e[e.UNRESOLVED_SUBRULE_REF=4]=`UNRESOLVED_SUBRULE_REF`,e[e.LEFT_RECURSION=5]=`LEFT_RECURSION`,e[e.NONE_LAST_EMPTY_ALT=6]=`NONE_LAST_EMPTY_ALT`,e[e.AMBIGUOUS_ALTS=7]=`AMBIGUOUS_ALTS`,e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]=`CONFLICT_TOKENS_RULES_NAMESPACE`,e[e.INVALID_TOKEN_NAME=9]=`INVALID_TOKEN_NAME`,e[e.NO_NON_EMPTY_LOOKAHEAD=10]=`NO_NON_EMPTY_LOOKAHEAD`,e[e.AMBIGUOUS_PREFIX_ALTS=11]=`AMBIGUOUS_PREFIX_ALTS`,e[e.TOO_MANY_ALTS=12]=`TOO_MANY_ALTS`,e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]=`CUSTOM_LOOKAHEAD_VALIDATION`})($||={});function EMPTY_ALT(e=void 0){return function(){return e}}var Xe=class Parser{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT(`toFastProps`,()=>{toFastProperties(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),M(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{n=resolveGrammar({rules:K(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(L(n)&&this.skipValidations===!1){let e=validateGrammar({rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),errMsgProvider:X,grammarName:t}),n=validateLookahead({lookaheadStrategy:this.lookaheadStrategy,rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(e,n)}}),L(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=computeAllProdsFollows(K(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:K(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(K(this.gastProductionsCache))})),!Parser.DEFER_DEFINITION_ERRORS_HANDLING&&!L(this.definitionErrors))throw e=U(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${e.join(`
|
|
54
|
-
-------------------------------
|
|
55
|
-
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),N(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
56
|
-
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
57
|
-
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
58
|
-
For further details.`);this.skipValidations=N(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};Xe.DEFER_DEFINITION_ERRORS_HANDLING=!1,applyMixins(Xe,[Recoverable,LooksAhead,TreeBuilder,LexerAdapter,RecognizerEngine,RecognizerApi,ErrorHandler,ContentAssist,GastRecorder,PerformanceTracer]);var EmbeddedActionsParser=class extends Xe{constructor(e,t=Q){let n=b(t);n.outputCst=!1,super(e,n)}};export{je as a,tokenMatcher as c,getLookaheadPaths as i,Lexer as l,EmbeddedActionsParser as n,Y as o,LLkLookaheadStrategy as r,tokenLabel as s,EMPTY_ALT as t,xe as u};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"../rolldown-runtime.mjs";import*as t from"node:path";import{join as n,relative as r,resolve as i,sep as a}from"node:path";import{EventEmitter as o}from"node:events";import{lstat as s,open as c,readdir as l,realpath as u,stat as d}from"node:fs/promises";import{type as f}from"node:os";import{stat as p,unwatchFile as m,watch as h,watchFile as g}from"node:fs";import{Readable as _}from"node:stream";const v={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},y={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:v.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(y);const b=`READDIRP_RECURSIVE_ERROR`,x=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,b]),S=[v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE],C=new Set([v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE]),w=new Set([v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE]),isNormalFlowError=e=>x.has(e.code),T=process.platform===`win32`,emptyFn=e=>!0,normalizeFilter=e=>{if(e===void 0)return emptyFn;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return emptyFn};var ReaddirpStream=class extends _{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...y,...e},{root:n,type:r}=t;this._fileFilter=normalizeFilter(t.fileFilter),this._directoryFilter=normalizeFilter(t.directoryFilter);let a=t.lstat?s:d;T?this._stat=e=>a(e,{bigint:!0}):this._stat=a,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:y.depth,this._wantsDir=r?C.has(r):!1,this._wantsFile=r?w.has(r):!1,this._wantsEverything=r===v.EVERYTHING_TYPE,this._root=i(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await l(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let a,o=this._isDirent?e.name:e;try{let s=i(n(t,o));a={path:r(this._root,s),fullPath:s,basename:o},a[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(e){this._onError(e);return}return a}_onError(e){isNormalFlowError(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await u(t),n=await s(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===a){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=b,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function readdirp(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=v.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!S.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${S.join(`, `)}`);return t.root=e,new ReaddirpStream(t)}const EMPTY_FN=()=>{},E=process.platform,D=E===`win32`,O=E===`darwin`,k=E===`linux`,A=E===`freebsd`,j=f()===`OS400`,M={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},N=M,P={lstat:s,stat:d},F=`listeners`,I=`errHandlers`,L=`rawEmitters`,R=[F,I,L],z=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),isBinaryPath=e=>z.has(t.extname(e).slice(1).toLowerCase()),foreach=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},addAndConvert=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},clearItem=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},delFromSet=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},isEmptySet=e=>e instanceof Set?e.size===0:!e,B=new Map;function createFsWatchInstance(e,n,r,i,a){let handleEvent=(n,i)=>{r(e),a(n,i,{watchedPath:e}),i&&e!==i&&fsWatchBroadcast(t.resolve(e,i),F,t.join(e,i))};try{return h(e,{persistent:n.persistent},handleEvent)}catch(e){i(e);return}}const fsWatchBroadcast=(e,t,n,r,i)=>{let a=B.get(e);a&&foreach(a[t],e=>{e(n,r,i)})},setFsWatchListener=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,s=B.get(t),l;if(!n.persistent)return l=createFsWatchInstance(e,n,i,a,o),l?l.close.bind(l):void 0;if(s)addAndConvert(s,F,i),addAndConvert(s,I,a),addAndConvert(s,L,o);else{if(l=createFsWatchInstance(e,n,fsWatchBroadcast.bind(null,t,F),a,fsWatchBroadcast.bind(null,t,L)),!l)return;l.on(N.ERROR,async n=>{let r=fsWatchBroadcast.bind(null,t,I);if(s&&(s.watcherUnusable=!0),D&&n.code===`EPERM`)try{await(await c(e,`r`)).close(),r(n)}catch{}else r(n)}),s={listeners:i,errHandlers:a,rawEmitters:o,watcher:l},B.set(t,s)}return()=>{delFromSet(s,F,i),delFromSet(s,I,a),delFromSet(s,L,o),isEmptySet(s.listeners)&&(s.watcher.close(),B.delete(t),R.forEach(clearItem(s)),s.watcher=void 0,Object.freeze(s))}},V=new Map,setFsWatchFileListener=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=V.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(m(t),o=void 0),o?(addAndConvert(o,F,i),addAndConvert(o,L,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:g(t,n,(n,r)=>{foreach(o.rawEmitters,e=>{e(N.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&foreach(o.listeners,t=>t(e,n))})},V.set(t,o)),()=>{delFromSet(o,F,i),delFromSet(o,L,a),isEmptySet(o.listeners)&&(V.delete(t),m(t),o.options=o.watcher=void 0,Object.freeze(o))}};var NodeFsHandler=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,n){let r=this.fsw.options,i=t.dirname(e),a=t.basename(e);this.fsw._getWatchedDir(i).add(a);let o=t.resolve(e),s={persistent:r.persistent};n||=EMPTY_FN;let c;return r.usePolling?(s.interval=r.interval!==r.binaryInterval&&isBinaryPath(a)?r.binaryInterval:r.interval,c=setFsWatchFileListener(e,o,s,{listener:n,rawEmitter:this.fsw._emitRaw})):c=setFsWatchListener(e,o,s,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),c}_handleFile(e,n,r){if(this.fsw.closed)return;let i=t.dirname(e),a=t.basename(e),o=this.fsw._getWatchedDir(i),s=n;if(o.has(a))return;let listener=async(t,n)=>{if(this.fsw._throttle(`watch`,e,5)){if(!n||n.mtimeMs===0)try{let n=await d(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==s.mtimeMs)&&this.fsw._emit(N.CHANGE,e,n),(O||k||A)&&s.ino!==n.ino){this.fsw._closeFile(t),s=n;let r=this._watchWithNodeFs(e,listener);r&&this.fsw._addPathCloser(t,r)}else s=n}catch{this.fsw._remove(i,a)}else if(o.has(a)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==s.mtimeMs)&&this.fsw._emit(N.CHANGE,e,n),s=n}}},c=this._watchWithNodeFs(e,listener);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(N.ADD,e,0))return;this.fsw._emit(N.ADD,e,n)}return c}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await u(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(N.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(N.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,n,r,i,a,o,s){e=t.join(e,``);let c=i?`${e}:${i}`:e;if(s=this.fsw._throttle(`readdir`,c,1e3),!s)return;let l=this.fsw._getWatchedDir(r.path),u=new Set,d=this.fsw._readdirp(e,{fileFilter:e=>r.filterPath(e),directoryFilter:e=>r.filterDir(e)});if(d)return d.on(`data`,async s=>{if(this.fsw.closed){d=void 0;return}let c=s.path,f=t.join(e,c);if(u.add(c),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,e,f,c))){if(this.fsw.closed){d=void 0;return}(c===i||!i&&!l.has(c))&&(this.fsw._incrReadyCount(),f=t.join(a,t.relative(a,f)),this._addToNodeFs(f,n,r,o+1))}}).on(N.ERROR,this._boundHandleError),new Promise((t,n)=>{if(!d)return n();d.once(`end`,()=>{if(this.fsw.closed){d=void 0;return}let n=s?s.clear():!1;t(void 0),l.getChildren().filter(t=>t!==e&&!u.has(t)).forEach(t=>{this.fsw._remove(e,t)}),d=void 0,n&&this._handleRead(e,!1,r,i,a,o,s)})})}async _handleDir(e,n,r,i,a,o,s){let c=this.fsw._getWatchedDir(t.dirname(e)),l=c.has(t.basename(e));!(r&&this.fsw.options.ignoreInitial)&&!a&&!l&&this.fsw._emit(N.ADD_DIR,e,n),c.add(t.basename(e)),this.fsw._getWatchedDir(e);let u,d,f=this.fsw.options.depth;if((f==null||i<=f)&&!this.fsw._symlinkPaths.has(s)){if(!a&&(await this._handleRead(e,r,o,a,e,i,u),this.fsw.closed))return;d=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,o,a,e,i,u)})}return d}async _addToNodeFs(e,n,r,i,a){let o=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return o(),!1;let s=this.fsw._getWatchHelpers(e);r&&(s.filterPath=e=>r.filterPath(e),s.filterDir=e=>r.filterDir(e));try{let r=await P[s.statMethod](s.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(s.watchPath,r))return o(),!1;let c=this.fsw.options.followSymlinks,l;if(r.isDirectory()){let o=t.resolve(e),d=c?await u(e):e;if(this.fsw.closed||(l=await this._handleDir(s.watchPath,r,n,i,a,s,d),this.fsw.closed))return;o!==d&&d!==void 0&&this.fsw._symlinkPaths.set(o,d)}else if(r.isSymbolicLink()){let a=c?await u(e):e;if(this.fsw.closed)return;let o=t.dirname(s.watchPath);if(this.fsw._getWatchedDir(o).add(s.watchPath),this.fsw._emit(N.ADD,s.watchPath,r),l=await this._handleDir(o,r,n,i,e,s,a),this.fsw.closed)return;a!==void 0&&this.fsw._symlinkPaths.set(t.resolve(e),a)}else l=this._handleFile(s.watchPath,r,n);return o(),l&&this.fsw._addPathCloser(e,l),!1}catch(t){if(this.fsw._handleError(t))return o(),e}}};
|
|
2
|
-
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
3
|
-
const H=/\\/g,U=/\/\//g,W=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,G=/^\.[/\\]/;function arrify(e){return Array.isArray(e)?e:[e]}const isMatcherObject=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function createPattern(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?n=>{if(e.path===n)return!0;if(e.recursive){let r=t.relative(e.path,n);return r?!r.startsWith(`..`)&&!t.isAbsolute(r):!1}return!1}:()=>!1}function normalizePath(e){if(typeof e!=`string`)throw Error(`string expected`);e=t.normalize(e),e=e.replace(/\\/g,`/`);let n=!1;return e.startsWith(`//`)&&(n=!0),e=e.replace(U,`/`),n&&(e=`/`+e),e}function matchPatterns(e,t,n){let r=normalizePath(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function anymatch(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=arrify(e).map(e=>createPattern(e));return t==null?(e,t)=>matchPatterns(n,e,t):matchPatterns(n,t)}const unifyPaths=e=>{let t=arrify(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(normalizePathToUnix)},toUnix=e=>{let t=e.replace(H,`/`),n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(U,`/`),n&&(t=`/`+t),t},normalizePathToUnix=e=>toUnix(t.normalize(toUnix(e))),normalizeIgnored=(e=``)=>n=>typeof n==`string`?normalizePathToUnix(t.isAbsolute(n)?n:t.join(e,n)):n,getAbsolutePath=(e,n)=>t.isAbsolute(e)?e:t.join(n,e),K=Object.freeze(new Set);var DirEntry=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(e){let{items:n}=this;if(!n||(n.delete(e),n.size>0))return;let r=this.path;try{await l(r)}catch{this._removeWatcher&&this._removeWatcher(t.dirname(r),t.basename(r))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=EMPTY_FN,this.items=K,Object.freeze(this)}},WatchHelper=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(e,n,r){this.fsw=r;let i=e;this.path=e=e.replace(G,``),this.watchPath=i,this.fullWatchPath=t.resolve(i),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=n,this.statMethod=n?`stat`:`lstat`}entryPath(e){return t.join(this.watchPath,t.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},FSWatcher=class extends o{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?arrify(e.ignored):arrify([]),awaitWriteFinish:t===!0?n:typeof t==`object`&&{...n,...t}};j&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=EMPTY_FN,this._readyEmitted=!0,process.nextTick(()=>this.emit(M.READY)))},this._emitRaw=(...e)=>this.emit(M.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new NodeFsHandler(this),Object.freeze(r)}_addIgnoredPath(e){if(isMatcherObject(e)){for(let t of this._ignoredPaths)if(isMatcherObject(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)isMatcherObject(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,n,r){let{cwd:i}=this.options;this.closed=!1,this._closePromise=void 0;let a=unifyPaths(e);return i&&(a=a.map(e=>getAbsolutePath(e,i))),a.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=a.length,Promise.all(a.map(async e=>{let t=await this._nodeFsHandler._addToNodeFs(e,!r,void 0,0,n);return t&&this._emitReady(),t})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(t.dirname(e),t.basename(n||e))})}),this}unwatch(e){if(this.closed)return this;let n=unifyPaths(e),{cwd:r}=this.options;return n.forEach(e=>{!t.isAbsolute(e)&&!this._closers.has(e)&&(r&&(e=t.join(r,e)),e=t.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((n,r)=>{let i=(this.options.cwd?t.relative(this.options.cwd,r):r)||`.`;e[i]=n.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==M.ERROR&&this.emit(M.ALL,e,...t)}async _emit(e,n,r){if(this.closed)return;let i=this.options;D&&(n=t.normalize(n)),i.cwd&&(n=t.relative(i.cwd,n));let a=[n];r!=null&&a.push(r);let o=i.awaitWriteFinish,s;if(o&&(s=this._pendingWrites.get(n)))return s.lastChange=new Date,this;if(i.atomic){if(e===M.UNLINK)return this._pendingUnlinks.set(n,[e,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(M.ALL,...e),this._pendingUnlinks.delete(t)})},typeof i.atomic==`number`?i.atomic:100),this;e===M.ADD&&this._pendingUnlinks.has(n)&&(e=M.CHANGE,this._pendingUnlinks.delete(n))}if(o&&(e===M.ADD||e===M.CHANGE)&&this._readyEmitted){let awfEmit=(t,n)=>{t?(e=M.ERROR,a[0]=t,this.emitWithAll(e,a)):n&&(a.length>1?a[1]=n:a.push(n),this.emitWithAll(e,a))};return this._awaitWriteFinish(n,o.stabilityThreshold,e,awfEmit),this}if(e===M.CHANGE&&!this._throttle(M.CHANGE,n,50))return this;if(i.alwaysStat&&r===void 0&&(e===M.ADD||e===M.ADD_DIR||e===M.CHANGE)){let e=i.cwd?t.join(i.cwd,n):n,r;try{r=await d(e)}catch{}if(!r||this.closed)return;a.push(r)}return this.emitWithAll(e,a),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(M.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,clear=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(clear,n);let o={timeoutObject:a,clear,count:0};return r.set(t,o),o}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,n,r,i){let a=this.options.awaitWriteFinish;if(typeof a!=`object`)return;let o=a.pollInterval,s,c=e;this.options.cwd&&!t.isAbsolute(e)&&(c=t.join(this.options.cwd,e));let l=new Date,u=this._pendingWrites;function awaitWriteFinishFn(t){p(c,(r,a)=>{if(r||!u.has(e)){r&&r.code!==`ENOENT`&&i(r);return}let c=Number(new Date);t&&a.size!==t.size&&(u.get(e).lastChange=c),c-u.get(e).lastChange>=n?(u.delete(e),i(void 0,a)):s=setTimeout(awaitWriteFinishFn,o,a)})}u.has(e)||(u.set(e,{lastChange:l,cancelWait:()=>(u.delete(e),clearTimeout(s),r)}),s=setTimeout(awaitWriteFinishFn,o))}_isIgnored(e,t){if(this.options.atomic&&W.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(normalizeIgnored(e)),n=[...[...this._ignoredPaths].map(normalizeIgnored(e)),...t];this._userIgnored=anymatch(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new WatchHelper(e,this.options.followSymlinks,this)}_getWatchedDir(e){let n=t.resolve(e);return this._watched.has(n)||this._watched.set(n,new DirEntry(n,this._boundRemove)),this._watched.get(n)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,n,r){let i=t.join(e,n),a=t.resolve(i);if(r??=this._watched.has(i)||this._watched.has(a),!this._throttle(`remove`,i,100))return;!r&&this._watched.size===1&&this.add(e,n,!0),this._getWatchedDir(i).getChildren().forEach(e=>this._remove(i,e));let o=this._getWatchedDir(e),s=o.has(n);o.remove(n),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let c=i;if(this.options.cwd&&(c=t.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(c)&&this._pendingWrites.get(c).cancelWait()===M.ADD)return;this._watched.delete(i),this._watched.delete(a);let l=r?M.UNLINK_DIR:M.UNLINK;s&&!this._isIgnored(i)&&this._emit(l,i),this._closePath(i)}_closePath(e){this._closeFile(e);let n=t.dirname(e);this._getWatchedDir(n).remove(t.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=readdirp(e,{type:M.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function watch$1(e,t={}){let n=new FSWatcher(t);return n.add(e),n}e(watch$1,`watch`);var q={watch:watch$1,FSWatcher};export{q as t};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{r as e}from"../rolldown-runtime.mjs";const{min:t,max:n}=Math;var r=e((e,r=0,i=1)=>t(n(r,e),i),`default`),i=e(e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):t===3&&(e[t]=r(e[t],0,1));return e},`default`);const a={};for(let e of[`Boolean`,`Number`,`String`,`Function`,`Array`,`Date`,`RegExp`,`Undefined`,`Null`])a[`[object ${e}]`]=e.toLowerCase();function type_default(e){return a[Object.prototype.toString.call(e)]||`object`}e(type_default,`default`);var o=e((e,t=null)=>e.length>=3?Array.prototype.slice.call(e):type_default(e[0])==`object`&&t?t.split(``).filter(t=>e[0][t]!==void 0).map(t=>e[0][t]):e[0].slice(0),`default`),s=e(e=>{if(e.length<2)return null;let t=e.length-1;return type_default(e[t])==`string`?e[t].toLowerCase():null},`default`);const{PI:c,min:l,max:u}=Math,rnd2=e=>Math.round(e*100)/100,rnd3=e=>Math.round(e*100)/100,d=c*2,p=c/3,m=c/180,h=180/c;function reverse3(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var g={format:{},autodetect:[]},Color=class{constructor(...e){let t=this;if(type_default(e[0])===`object`&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=s(e),r=!1;if(!n){r=!0,g.sorted||=(g.autodetect=g.autodetect.sort((e,t)=>t.p-e.p),!0);for(let t of g.autodetect)if(n=t.test(...e),n)break}if(g.format[n])t._rgb=i(g.format[n].apply(null,r?e:e.slice(0,-1)));else throw Error(`unknown format: `+e);t._rgb.length===3&&t._rgb.push(1)}toString(){return type_default(this.hex)==`function`?this.hex():`[${this._rgb.join(`,`)}]`}};const chroma=(...e)=>new Color(...e);chroma.version=`3.2.0`;const _={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,laserlemon:`#ffff54`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrod:`#fafad2`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,maroon2:`#7f0000`,maroon3:`#b03060`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,purple2:`#7f007f`,purple3:`#a020f0`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`},v=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,y=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,hex2rgb=e=>{if(e.match(v)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16);return[t>>16,t>>8&255,t&255,1]}if(e.match(y)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((t&255)/255*100)/100]}throw Error(`unknown hex color: ${e}`)},{round:b}=Math,rgb2hex=(...e)=>{let[t,n,r,i]=o(e,`rgba`),a=s(e)||`auto`;i===void 0&&(i=1),a===`auto`&&(a=i<1?`rgba`:`rgb`),t=b(t),n=b(n),r=b(r);let c=`000000`+(t<<16|n<<8|r).toString(16);c=c.substr(c.length-6);let l=`0`+b(i*255).toString(16);switch(l=l.substr(l.length-2),a.toLowerCase()){case`rgba`:return`#${c}${l}`;case`argb`:return`#${l}${c}`;default:return`#${c}`}};Color.prototype.name=function(){let e=rgb2hex(this._rgb,`rgb`);for(let t of Object.keys(_))if(_[t]===e)return t.toLowerCase();return e},g.format.named=e=>{if(e=e.toLowerCase(),_[e])return hex2rgb(_[e]);throw Error(`unknown color name: `+e)},g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&_[e.toLowerCase()])return`named`}}),Color.prototype.alpha=function(e,t=!1){return e!==void 0&&type_default(e)===`number`?t?(this._rgb[3]=e,this):new Color([this._rgb[0],this._rgb[1],this._rgb[2],e],`rgb`):this._rgb[3]},Color.prototype.clipped=function(){return this._rgb._clipped||!1};const x={Kn:18,labWhitePoint:`d65`,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},S=new Map([[`a`,[1.0985,.35585]],[`b`,[1.0985,.35585]],[`c`,[.98074,1.18232]],[`d50`,[.96422,.82521]],[`d55`,[.95682,.92149]],[`d65`,[.95047,1.08883]],[`e`,[1,1,1]],[`f2`,[.99186,.67393]],[`f7`,[.95041,1.08747]],[`f11`,[1.00962,.6435]],[`icc`,[.96422,.82521]]]);function setLabWhitePoint(e){let t=S.get(String(e).toLowerCase());if(!t)throw Error(`unknown Lab illuminant `+e);x.labWhitePoint=e,x.Xn=t[0],x.Zn=t[1]}function getLabWhitePoint(){return x.labWhitePoint}const lab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r]=e,[i,a,s]=lab2xyz(t,n,r),[c,l,u]=xyz2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},lab2xyz=(e,t,n)=>{let{kE:r,kK:i,kKE:a,Xn:o,Yn:s,Zn:c}=x,l=(e+16)/116,u=.002*t+l,d=l-.005*n,p=u*u*u,m=d*d*d,h=p>r?p:(116*u-16)/i,g=e>a?((e+16)/116)**3:e/i,_=m>r?m:(116*d-16)/i;return[h*o,g*s,_*c]},compand=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*t},xyz2rgb=(e,t,n)=>{let{MtxAdaptMa:r,MtxAdaptMaI:i,MtxXYZ2RGB:a,RefWhiteRGB:o,Xn:s,Yn:c,Zn:l}=x,u=s*r.m00+c*r.m10+l*r.m20,d=s*r.m01+c*r.m11+l*r.m21,p=s*r.m02+c*r.m12+l*r.m22,m=o.X*r.m00+o.Y*r.m10+o.Z*r.m20,h=o.X*r.m01+o.Y*r.m11+o.Z*r.m21,g=o.X*r.m02+o.Y*r.m12+o.Z*r.m22,_=(e*r.m00+t*r.m10+n*r.m20)*(m/u),v=(e*r.m01+t*r.m11+n*r.m21)*(h/d),y=(e*r.m02+t*r.m12+n*r.m22)*(g/p),b=_*i.m00+v*i.m10+y*i.m20,S=_*i.m01+v*i.m11+y*i.m21,C=_*i.m02+v*i.m12+y*i.m22,w=compand(b*a.m00+S*a.m10+C*a.m20),T=compand(b*a.m01+S*a.m11+C*a.m21),E=compand(b*a.m02+S*a.m12+C*a.m22);return[w*255,T*255,E*255]},rgb2lab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2xyz(t,n,r),[l,u,d]=xyz2lab(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function xyz2lab(e,t,n){let{Xn:r,Yn:i,Zn:a,kE:o,kK:s}=x,c=e/r,l=t/i,u=n/a,d=c>o?c**(1/3):(s*c+16)/116,p=l>o?l**(1/3):(s*l+16)/116,m=u>o?u**(1/3):(s*u+16)/116;return[116*p-16,500*(d-p),200*(p-m)]}function gammaAdjustSRGB(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:((e+.055)/1.055)**2.4)*t}const rgb2xyz=(e,t,n)=>{e=gammaAdjustSRGB(e/255),t=gammaAdjustSRGB(t/255),n=gammaAdjustSRGB(n/255);let{MtxRGB2XYZ:r,MtxAdaptMa:i,MtxAdaptMaI:a,Xn:o,Yn:s,Zn:c,As:l,Bs:u,Cs:d}=x,p=e*r.m00+t*r.m10+n*r.m20,m=e*r.m01+t*r.m11+n*r.m21,h=e*r.m02+t*r.m12+n*r.m22,g=o*i.m00+s*i.m10+c*i.m20,_=o*i.m01+s*i.m11+c*i.m21,v=o*i.m02+s*i.m12+c*i.m22,y=p*i.m00+m*i.m10+h*i.m20,b=p*i.m01+m*i.m11+h*i.m21,S=p*i.m02+m*i.m12+h*i.m22;return y*=g/l,b*=_/u,S*=v/d,p=y*a.m00+b*a.m10+S*a.m20,m=y*a.m01+b*a.m11+S*a.m21,h=y*a.m02+b*a.m12+S*a.m22,[p,m,h]};Color.prototype.lab=function(){return rgb2lab(this._rgb)},Object.assign(chroma,{lab:e((...e)=>new Color(...e,`lab`),`lab`),getLabWhitePoint,setLabWhitePoint}),g.format.lab=lab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`lab`),type_default(e)===`array`&&e.length===3)return`lab`}}),Color.prototype.darken=function(e=1){let t=this,n=t.lab();return n[0]-=x.Kn*e,new Color(n,`lab`).alpha(t.alpha(),!0)},Color.prototype.brighten=function(e=1){return this.darken(-e)},Color.prototype.darker=Color.prototype.darken,Color.prototype.brighter=Color.prototype.brighten,Color.prototype.get=function(e){let[t,n]=e.split(`.`),r=this[t]();if(n){let e=t.indexOf(n)-(t.substr(0,2)===`ok`?2:0);if(e>-1)return r[e];throw Error(`unknown channel ${n} in mode ${t}`)}else return r};const{pow:C}=Math;Color.prototype.luminance=function(e,t=`rgb`){if(e!==void 0&&type_default(e)===`number`){if(e===0)return new Color([0,0,0,this._rgb[3]],`rgb`);if(e===1)return new Color([255,255,255,this._rgb[3]],`rgb`);let n=this.luminance(),r=20,test=(n,i)=>{let a=n.interpolate(i,.5,t),o=a.luminance();return Math.abs(e-o)<1e-7||!r--?a:o>e?test(n,a):test(a,i)};return new Color([...(n>e?test(new Color([0,0,0]),this):test(this,new Color([255,255,255]))).rgb(),this._rgb[3]])}return rgb2luminance(...this._rgb.slice(0,3))};const rgb2luminance=(e,t,n)=>(e=luminance_x(e),t=luminance_x(t),n=luminance_x(n),.2126*e+.7152*t+.0722*n),luminance_x=e=>(e/=255,e<=.03928?e/12.92:C((e+.055)/1.055,2.4));var w={},T=e((e,t,n=.5,...r)=>{let i=r[0]||`lrgb`;if(!w[i]&&!r.length&&(i=Object.keys(w)[0]),!w[i])throw Error(`interpolation mode ${i} is not defined`);return type_default(e)!==`object`&&(e=new Color(e)),type_default(t)!==`object`&&(t=new Color(t)),w[i](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))},`default`);Color.prototype.mix=Color.prototype.interpolate=function(e,t=.5,...n){return T(this,e,t,...n)},Color.prototype.premultiply=function(e=!1){let t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new Color([t[0]*n,t[1]*n,t[2]*n,n],`rgb`)};const{sin:E,cos:ee}=Math,lch2lab=(...e)=>{let[t,n,r]=o(e,`lch`);return isNaN(r)&&(r=0),r*=m,[t,ee(r)*n,E(r)*n]},lch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r]=e,[i,a,s]=lch2lab(t,n,r),[c,l,u]=lab2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},hcl2rgb=(...e)=>lch2rgb(...reverse3(o(e,`hcl`))),{sqrt:D,atan2:te,round:O}=Math,lab2lch=(...e)=>{let[t,n,r]=o(e,`lab`),i=D(n*n+r*r),a=(te(r,n)*h+360)%360;return O(i*1e4)===0&&(a=NaN),[t,i,a]},rgb2lch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2lab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};Color.prototype.lch=function(){return rgb2lch(this._rgb)},Color.prototype.hcl=function(){return reverse3(rgb2lch(this._rgb))};const k=e((...e)=>new Color(...e,`lch`),`lch`),hcl=(...e)=>new Color(...e,`hcl`);Object.assign(chroma,{lch:k,hcl}),g.format.lch=lch2rgb,g.format.hcl=hcl2rgb,[`lch`,`hcl`].forEach(e=>g.autodetect.push({p:2,test:(...t)=>{if(t=o(t,e),type_default(t)===`array`&&t.length===3)return e}})),Color.prototype.saturate=function(e=1){let t=this,n=t.lch();return n[1]+=x.Kn*e,n[1]<0&&(n[1]=0),new Color(n,`lch`).alpha(t.alpha(),!0)},Color.prototype.desaturate=function(e=1){return this.saturate(-e)},Color.prototype.set=function(e,t,n=!1){let[r,i]=e.split(`.`),a=this[r]();if(i){let e=r.indexOf(i)-(r.substr(0,2)===`ok`?2:0);if(e>-1){if(type_default(t)==`string`)switch(t.charAt(0)){case`+`:a[e]+=+t;break;case`-`:a[e]+=+t;break;case`*`:a[e]*=+t.substr(1);break;case`/`:a[e]/=+t.substr(1);break;default:a[e]=+t}else if(type_default(t)===`number`)a[e]=t;else throw Error(`unsupported value for Color.set`);let i=new Color(a,r);return n?(this._rgb=i._rgb,this):i}throw Error(`unknown channel ${i} in mode ${r}`)}else return a},Color.prototype.tint=function(e=.5,...t){return T(this,`white`,e,...t)},Color.prototype.shade=function(e=.5,...t){return T(this,`black`,e,...t)},w.rgb=e((e,t,n)=>{let r=e._rgb,i=t._rgb;return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`rgb`)},`rgb`);const{sqrt:A,pow:j}=Math,lrgb=(e,t,n)=>{let[r,i,a]=e._rgb,[o,s,c]=t._rgb;return new Color(A(j(r,2)*(1-n)+j(o,2)*n),A(j(i,2)*(1-n)+j(s,2)*n),A(j(a,2)*(1-n)+j(c,2)*n),`rgb`)};w.lrgb=lrgb;const lab=(e,t,n)=>{let r=e.lab(),i=t.lab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`lab`)};w.lab=lab;var M=e((e,t,n,r)=>{let i,a;r===`hsl`?(i=e.hsl(),a=t.hsl()):r===`hsv`?(i=e.hsv(),a=t.hsv()):r===`hcg`?(i=e.hcg(),a=t.hcg()):r===`hsi`?(i=e.hsi(),a=t.hsi()):r===`lch`||r===`hcl`?(r=`hcl`,i=e.hcl(),a=t.hcl()):r===`oklch`&&(i=e.oklch().reverse(),a=t.oklch().reverse());let o,s,c,l,u,d;(r.substr(0,1)===`h`||r===`oklch`)&&([o,c,u]=i,[s,l,d]=a);let p,m,h,g;return!isNaN(o)&&!isNaN(s)?(g=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,m=o+n*g):isNaN(o)?isNaN(s)?m=NaN:(m=s,(u==1||u==0)&&r!=`hsv`&&(p=l)):(m=o,(d==1||d==0)&&r!=`hsv`&&(p=c)),p===void 0&&(p=c+n*(l-c)),h=u+n*(d-u),r===`oklch`?new Color([h,p,m],r):new Color([m,p,h],r)},`default`);const lch=(e,t,n)=>M(e,t,n,`lch`);w.lch=lch,w.hcl=lch;const num2rgb=e=>{if(type_default(e)==`number`&&e>=0&&e<=16777215)return[e>>16,e>>8&255,e&255,1];throw Error(`unknown num color: `+e)},rgb2num=(...e)=>{let[t,n,r]=o(e,`rgb`);return(t<<16)+(n<<8)+r};Color.prototype.num=function(){return rgb2num(this._rgb)},Object.assign(chroma,{num:e((...e)=>new Color(...e,`num`),`num`)}),g.format.num=num2rgb,g.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&type_default(e[0])===`number`&&e[0]>=0&&e[0]<=16777215)return`num`}});const num=(e,t,n)=>{let r=e.num();return new Color(r+n*(t.num()-r),`num`)};w.num=num;const{floor:ne}=Math,hcg2rgb=(...e)=>{e=o(e,`hcg`);let[t,n,r]=e,i,a,s;r*=255;let c=n*255;if(n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=ne(t),o=t-e,l=r*(1-n),u=l+c*(1-o),d=l+c*o,p=l+c;switch(e){case 0:[i,a,s]=[p,d,l];break;case 1:[i,a,s]=[u,p,l];break;case 2:[i,a,s]=[l,p,d];break;case 3:[i,a,s]=[l,u,p];break;case 4:[i,a,s]=[d,l,p];break;case 5:[i,a,s]=[p,l,u];break}}return[i,a,s,e.length>3?e[3]:1]},rgb2hcg=(...e)=>{let[t,n,r]=o(e,`rgb`),i=l(t,n,r),a=u(t,n,r),s=a-i,c=s*100/255,d=i/(255-s)*100,p;return s===0?p=NaN:(t===a&&(p=(n-r)/s),n===a&&(p=2+(r-t)/s),r===a&&(p=4+(t-n)/s),p*=60,p<0&&(p+=360)),[p,c,d]};Color.prototype.hcg=function(){return rgb2hcg(this._rgb)},chroma.hcg=e((...e)=>new Color(...e,`hcg`),`hcg`),g.format.hcg=hcg2rgb,g.autodetect.push({p:1,test:(...e)=>{if(e=o(e,`hcg`),type_default(e)===`array`&&e.length===3)return`hcg`}});const hcg=(e,t,n)=>M(e,t,n,`hcg`);w.hcg=hcg;const{cos:N}=Math,hsi2rgb=(...e)=>{e=o(e,`hsi`);let[t,n,i]=e,a,s,c;return isNaN(t)&&(t=0),isNaN(n)&&(n=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(c=(1-n)/3,a=(1+n*N(d*t)/N(p-d*t))/3,s=1-(c+a)):t<2/3?(t-=1/3,a=(1-n)/3,s=(1+n*N(d*t)/N(p-d*t))/3,c=1-(a+s)):(t-=2/3,s=(1-n)/3,c=(1+n*N(d*t)/N(p-d*t))/3,a=1-(s+c)),a=r(i*a*3),s=r(i*s*3),c=r(i*c*3),[a*255,s*255,c*255,e.length>3?e[3]:1]},{min:re,sqrt:ie,acos:ae}=Math,rgb2hsi=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i,a=re(t,n,r),s=(t+n+r)/3,c=s>0?1-a/s:0;return c===0?i=NaN:(i=(t-n+(t-r))/2,i/=ie((t-n)*(t-n)+(t-r)*(n-r)),i=ae(i),r>n&&(i=d-i),i/=d),[i*360,c,s]};Color.prototype.hsi=function(){return rgb2hsi(this._rgb)},chroma.hsi=e((...e)=>new Color(...e,`hsi`),`hsi`),g.format.hsi=hsi2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsi`),type_default(e)===`array`&&e.length===3)return`hsi`}});const hsi=(e,t,n)=>M(e,t,n,`hsi`);w.hsi=hsi;const hsl2rgb=(...e)=>{e=o(e,`hsl`);let[t,n,r]=e,i,a,s;if(n===0)i=a=s=r*255;else{let e=[0,0,0],o=[0,0,0],c=r<.5?r*(1+n):r+n-r*n,l=2*r-c,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&--e[t],6*e[t]<1?o[t]=l+(c-l)*6*e[t]:2*e[t]<1?o[t]=c:3*e[t]<2?o[t]=l+(c-l)*(2/3-e[t])*6:o[t]=l;[i,a,s]=[o[0]*255,o[1]*255,o[2]*255]}return e.length>3?[i,a,s,e[3]]:[i,a,s,1]},oe=e((...e)=>{e=o(e,`rgba`);let[t,n,r]=e;t/=255,n/=255,r/=255;let i=l(t,n,r),a=u(t,n,r),s=(a+i)/2,c,d;return a===i?(c=0,d=NaN):c=s<.5?(a-i)/(a+i):(a-i)/(2-a-i),t==a?d=(n-r)/(a-i):n==a?d=2+(r-t)/(a-i):r==a&&(d=4+(t-n)/(a-i)),d*=60,d<0&&(d+=360),e.length>3&&e[3]!==void 0?[d,c,s,e[3]]:[d,c,s]},`rgb2hsl`);Color.prototype.hsl=function(){return oe(this._rgb)},chroma.hsl=e((...e)=>new Color(...e,`hsl`),`hsl`),g.format.hsl=hsl2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsl`),type_default(e)===`array`&&e.length===3)return`hsl`}});const hsl=(e,t,n)=>M(e,t,n,`hsl`);w.hsl=hsl;const{floor:se}=Math,hsv2rgb=(...e)=>{e=o(e,`hsv`);let[t,n,r]=e,i,a,s;if(r*=255,n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=se(t),o=t-e,c=r*(1-n),l=r*(1-n*o),u=r*(1-n*(1-o));switch(e){case 0:[i,a,s]=[r,u,c];break;case 1:[i,a,s]=[l,r,c];break;case 2:[i,a,s]=[c,r,u];break;case 3:[i,a,s]=[c,l,r];break;case 4:[i,a,s]=[u,c,r];break;case 5:[i,a,s]=[r,c,l];break}}return[i,a,s,e.length>3?e[3]:1]},{min:ce,max:le}=Math,rgb2hsl=(...e)=>{e=o(e,`rgb`);let[t,n,r]=e,i=ce(t,n,r),a=le(t,n,r),s=a-i,c,l,u;return u=a/255,a===0?(c=NaN,l=0):(l=s/a,t===a&&(c=(n-r)/s),n===a&&(c=2+(r-t)/s),r===a&&(c=4+(t-n)/s),c*=60,c<0&&(c+=360)),[c,l,u]};Color.prototype.hsv=function(){return rgb2hsl(this._rgb)},chroma.hsv=e((...e)=>new Color(...e,`hsv`),`hsv`),g.format.hsv=hsv2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsv`),type_default(e)===`array`&&e.length===3)return`hsv`}});const hsv=(e,t,n)=>M(e,t,n,`hsv`);w.hsv=hsv;function multiplyMatrices(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>Array.isArray(e)?e.reduce((e,n,r)=>e+n*(t[r]||0),0):t.reduce((t,n)=>t+n*e,0)));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}const oklab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r,...i]=e,[a,s,c]=OKLab_to_XYZ([t,n,r]),[l,u,d]=xyz2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function OKLab_to_XYZ(e){return multiplyMatrices([[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],multiplyMatrices([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],e).map(e=>e**3))}const rgb2oklab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`);return[...XYZ_to_OKLab(rgb2xyz(t,n,r)),...i.length>0&&i[0]<1?[i[0]]:[]]};function XYZ_to_OKLab(e){return multiplyMatrices([[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],multiplyMatrices([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e).map(e=>Math.cbrt(e)))}Color.prototype.oklab=function(){return rgb2oklab(this._rgb)},Object.assign(chroma,{oklab:e((...e)=>new Color(...e,`oklab`),`oklab`)}),g.format.oklab=oklab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklab`),type_default(e)===`array`&&e.length===3)return`oklab`}});const oklab=(e,t,n)=>{let r=e.oklab(),i=t.oklab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`oklab`)};w.oklab=oklab,w.oklch=e((e,t,n)=>M(e,t,n,`oklch`),`oklch`);const{pow:P,sqrt:F,PI:L,cos:ue,sin:de,atan2:fe}=Math;var pe=e((e,t=`lrgb`,n=null)=>{let r=e.length;n||=Array.from(Array(r)).map(()=>1);let i=r/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=i}),e=e.map(e=>new Color(e)),t===`lrgb`)return _average_lrgb(e,n);let a=e.shift(),o=a.get(t),s=[],c=0,l=0;for(let e=0;e<o.length;e++)if(o[e]=(o[e]||0)*n[0],s.push(isNaN(o[e])?0:n[0]),t.charAt(e)===`h`&&!isNaN(o[e])){let t=o[e]/180*L;c+=ue(t)*n[0],l+=de(t)*n[0]}let u=a.alpha()*n[0];e.forEach((e,r)=>{let i=e.get(t);u+=e.alpha()*n[r+1];for(let e=0;e<o.length;e++)if(!isNaN(i[e]))if(s[e]+=n[r+1],t.charAt(e)===`h`){let t=i[e]/180*L;c+=ue(t)*n[r+1],l+=de(t)*n[r+1]}else o[e]+=i[e]*n[r+1]});for(let e=0;e<o.length;e++)if(t.charAt(e)===`h`){let t=fe(l/s[e],c/s[e])/L*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;o[e]=t}else o[e]=o[e]/s[e];return u/=r,new Color(o,t).alpha(u>.99999?1:u,!0)},`default`);const _average_lrgb=(e,t)=>{let n=e.length,r=[0,0,0,0];for(let i=0;i<e.length;i++){let a=e[i],o=t[i]/n,s=a._rgb;r[0]+=P(s[0],2)*o,r[1]+=P(s[1],2)*o,r[2]+=P(s[2],2)*o,r[3]+=s[3]*o}return r[0]=F(r[0]),r[1]=F(r[1]),r[2]=F(r[2]),r[3]>.9999999&&(r[3]=1),new Color(i(r))},{pow:me}=Math;function scale_default(e){let t=`rgb`,n=chroma(`#ccc`),i=0,a=[0,1],o=[0,1],s=[],c=[0,0],l=!1,u=[],d=!1,p=0,m=1,h=!1,g={},_=!0,v=1,setColors=function(e){if(e||=[`#fff`,`#000`],e&&type_default(e)===`string`&&chroma.brewer&&chroma.brewer[e.toLowerCase()]&&(e=chroma.brewer[e.toLowerCase()]),type_default(e)===`array`){e.length===1&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=chroma(e[t]);s.length=0;for(let t=0;t<e.length;t++)s.push(t/(e.length-1))}return resetCache(),u=e},getClass=function(e){if(l!=null){let t=l.length-1,n=0;for(;n<t&&e>=l[n];)n++;return n-1}return 0},tMapLightness=e=>e,tMapDomain=e=>e,getColor=function(e,i){let a,o;if(i??=!1,isNaN(e)||e===null)return n;o=i?e:l&&l.length>2?getClass(e)/(l.length-2):m===p?1:(e-p)/(m-p),o=tMapDomain(o),i||(o=tMapLightness(o)),v!==1&&(o=me(o,v)),o=c[0]+o*(1-c[0]-c[1]),o=r(o,0,1);let d=Math.floor(o*1e4);if(_&&g[d])a=g[d];else{if(type_default(u)===`array`)for(let e=0;e<s.length;e++){let n=s[e];if(o<=n){a=u[e];break}if(o>=n&&e===s.length-1){a=u[e];break}if(o>n&&o<s[e+1]){o=(o-n)/(s[e+1]-n),a=chroma.interpolate(u[e],u[e+1],o,t);break}}else type_default(u)===`function`&&(a=u(o));_&&(g[d]=a)}return a};var resetCache=()=>g={};setColors(e);let f=function(e){let t=chroma(getColor(e));return d&&t[d]?t[d]():t};return f.classes=function(e){if(e!=null){if(type_default(e)===`array`)l=e,a=[e[0],e[e.length-1]];else{let t=chroma.analyze(a);l=e===0?[t.min,t.max]:chroma.limits(t,`e`,e)}return f}return l},f.domain=function(e){if(!arguments.length)return o;o=e.slice(0),p=e[0],m=e[e.length-1],s=[];let t=u.length;if(e.length===t&&p!==m)for(let t of Array.from(e))s.push((t-p)/(m-p));else{for(let e=0;e<t;e++)s.push(e/(t-1));if(e.length>2){let t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-p)/(m-p));n.every((e,n)=>t[n]===e)||(tMapDomain=e=>{if(e<=0||e>=1)return e;let r=0;for(;e>=n[r+1];)r++;let i=(e-n[r])/(n[r+1]-n[r]);return t[r]+i*(t[r+1]-t[r])})}}return a=[p,m],f},f.mode=function(e){return arguments.length?(t=e,resetCache(),f):t},f.range=function(e,t){return setColors(e,t),f},f.out=function(e){return d=e,f},f.spread=function(e){return arguments.length?(i=e,f):i},f.correctLightness=function(e){return e??=!0,h=e,resetCache(),tMapLightness=h?function(e){let t=getColor(0,!0).lab()[0],n=getColor(1,!0).lab()[0],r=t>n,i=getColor(e,!0).lab()[0],a=t+(n-t)*e,o=i-a,s=0,c=1,l=20;for(;Math.abs(o)>.01&&l-->0;)(function(){return r&&(o*=-1),o<0?(s=e,e+=(c-e)*.5):(c=e,e+=(s-e)*.5),i=getColor(e,!0).lab()[0],o=i-a})();return e}:e=>e,f},f.padding=function(e){return e==null?c:(type_default(e)===`number`&&(e=[e,e]),c=e,f)},f.colors=function(t,n){arguments.length<2&&(n=`hex`);let r=[];if(arguments.length===0)r=u.slice(0);else if(t===1)r=[f(.5)];else if(t>1){let e=a[0],n=a[1]-e;r=__range__(0,t,!1).map(r=>f(e+r/(t-1)*n))}else{e=[];let t=[];if(l&&l.length>2)for(let e=1,n=l.length,r=1<=n;r?e<n:e>n;r?e++:e--)t.push((l[e-1]+l[e])*.5);else t=a;r=t.map(e=>f(e))}return chroma[n]&&(r=r.map(e=>e[n]())),r},f.cache=function(e){return e==null?_:(_=e,f)},f.gamma=function(e){return e==null?v:(v=e,f)},f.nodata=function(e){return e==null?n:(n=chroma(e),f)},f}e(scale_default,`default`);function __range__(e,t,n){let r=[],i=e<t,a=n?i?t+1:t-1:t;for(let t=e;i?t<a:t>a;i?t++:t--)r.push(t);return r}const binom_row=function(e){let t=[1,1];for(let n=1;n<e;n++){let e=[1];for(let n=1;n<=t.length;n++)e[n]=(t[n]||0)+t[n-1];t=e}return t},bezier=function(e){let I,t,n,r;if(e=e.map(e=>new Color(e)),e.length===2)[t,n]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(r=>t[r]+e*(n[r]-t[r])),`lab`)};else if(e.length===3)[t,n,r]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(i=>(1-e)*(1-e)*t[i]+2*(1-e)*e*n[i]+e*e*r[i]),`lab`)};else if(e.length===4){let i;[t,n,r,i]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(a=>(1-e)*(1-e)*(1-e)*t[a]+3*(1-e)*(1-e)*e*n[a]+3*(1-e)*e*e*r[a]+e*e*e*i[a]),`lab`)}}else if(e.length>=5){let t,n,r;t=e.map(e=>e.lab()),r=e.length-1,n=binom_row(r),I=function(e){let i=1-e;return new Color([0,1,2].map(a=>t.reduce((t,o,s)=>t+n[s]*i**(r-s)*e**s*o[a],0)),`lab`)}}else throw RangeError(`No point in running bezier with only one color.`);return I};var he=e(e=>{let t=bezier(e);return t.scale=()=>scale_default(t),t},`default`);const{round:R}=Math;Color.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(R)},Color.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?e===!1?t:R(t):t)};const rgb=(...e)=>new Color(...e,`rgb`);Object.assign(chroma,{rgb}),g.format.rgb=(...e)=>{let t=o(e,`rgba`);return t[3]===void 0&&(t[3]=1),t},g.autodetect.push({p:3,test:(...e)=>{if(e=o(e,`rgba`),type_default(e)===`array`&&(e.length===3||e.length===4&&type_default(e[3])==`number`&&e[3]>=0&&e[3]<=1))return`rgb`}});const blend=(e,t,n)=>{if(!blend[n])throw Error(`unknown blend mode `+n);return blend[n](e,t)},blend_f=e=>(t,n)=>{let r=chroma(n).rgb(),i=chroma(t).rgb();return chroma.rgb(e(r,i))},each=e=>(t,n)=>{let r=[];return r[0]=e(t[0],n[0]),r[1]=e(t[1],n[1]),r[2]=e(t[2],n[2]),r},normal=e=>e,multiply=(e,t)=>e*t/255,darken=(e,t)=>e>t?t:e,lighten=(e,t)=>e>t?e:t,screen=(e,t)=>255*(1-(1-e/255)*(1-t/255)),overlay=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),burn=(e,t)=>255*(1-(1-t/255)/(e/255)),dodge=(e,t)=>e===255?255:(e=t/255*255/(1-e/255),e>255?255:e);blend.normal=blend_f(each(normal)),blend.multiply=blend_f(each(multiply)),blend.screen=blend_f(each(screen)),blend.overlay=blend_f(each(overlay)),blend.darken=blend_f(each(darken)),blend.lighten=blend_f(each(lighten)),blend.dodge=blend_f(each(dodge)),blend.burn=blend_f(each(burn));const{pow:ge,sin:_e,cos:ve}=Math;function cubehelix_default(e=300,t=-1.5,n=1,r=1,a=[0,1]){let o=0,s;type_default(a)===`array`?s=a[1]-a[0]:(s=0,a=[a,a]);let f=function(c){let l=d*((e+120)/360+t*c),u=ge(a[0]+s*c,r),p=(o===0?n:n[0]+c*o)*u*(1-u)/2,m=ve(l),h=_e(l),g=u+p*(-.14861*m+1.78277*h),_=u+p*(-.29227*m-.90649*h),v=u+1.97294*m*p;return chroma(i([g*255,_*255,v*255,1]))};return f.start=function(t){return t==null?e:(e=t,f)},f.rotations=function(e){return e==null?t:(t=e,f)},f.gamma=function(e){return e==null?r:(r=e,f)},f.hue=function(e){return e==null?n:(n=e,type_default(n)===`array`?(o=n[1]-n[0],o===0&&(n=n[1])):o=0,f)},f.lightness=function(e){return e==null?a:(type_default(e)===`array`?(a=e,s=e[1]-e[0]):(a=[e,e],s=0),f)},f.scale=()=>chroma.scale(f),f.hue(n),f}e(cubehelix_default,`default`);const{floor:ye,random:be}=Math;var xe=e((e=be)=>{let t=`#`;for(let n=0;n<6;n++)t+=`0123456789abcdef`.charAt(ye(e()*16));return new Color(t,`hex`)},`default`);const{log:z,pow:Se,floor:Ce,abs:we}=Math;function analyze(e,t=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return type_default(e)===`object`&&(e=Object.values(e)),e.forEach(e=>{t&&type_default(e)===`object`&&(e=e[t]),e!=null&&!isNaN(e)&&(n.values.push(e),n.sum+=e,e<n.min&&(n.min=e),e>n.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>limits(n,e,t),n}function limits(e,t=`equal`,n=7){type_default(e)==`array`&&(e=analyze(e));let{min:r,max:i}=e,a=e.values.sort((e,t)=>e-t);if(n===1)return[r,i];let o=[];if(t.substr(0,1)===`c`&&(o.push(r),o.push(i)),t.substr(0,1)===`e`){o.push(r);for(let e=1;e<n;e++)o.push(r+e/n*(i-r));o.push(i)}else if(t.substr(0,1)===`l`){if(r<=0)throw Error(`Logarithmic scales are only possible for values > 0`);let e=Math.LOG10E*z(r),t=Math.LOG10E*z(i);o.push(r);for(let r=1;r<n;r++)o.push(Se(10,e+r/n*(t-e)));o.push(i)}else if(t.substr(0,1)===`q`){o.push(r);for(let e=1;e<n;e++){let t=(a.length-1)*e/n,r=Ce(t);if(r===t)o.push(a[r]);else{let e=t-r;o.push(a[r]*(1-e)+a[r+1]*e)}}o.push(i)}else if(t.substr(0,1)===`k`){let e,t=a.length,s=Array(t),c=Array(n),l=!0,u=0,d=null;d=[],d.push(r);for(let e=1;e<n;e++)d.push(r+e/n*(i-r));for(d.push(i);l;){for(let e=0;e<n;e++)c[e]=0;for(let e=0;e<t;e++){let t=a[e],r=Number.MAX_VALUE,i;for(let a=0;a<n;a++){let n=we(d[a]-t);n<r&&(r=n,i=a),c[i]++,s[e]=i}}let r=Array(n);for(let e=0;e<n;e++)r[e]=null;for(let n=0;n<t;n++)e=s[n],r[e]===null?r[e]=a[n]:r[e]+=a[n];for(let e=0;e<n;e++)r[e]*=1/c[e];l=!1;for(let e=0;e<n;e++)if(r[e]!==d[e]){l=!0;break}d=r,u++,u>200&&(l=!1)}let p={};for(let e=0;e<n;e++)p[e]=[];for(let n=0;n<t;n++)e=s[n],p[e].push(a[n]);let m=[];for(let e=0;e<n;e++)m.push(p[e][0]),m.push(p[e][p[e].length-1]);m=m.sort((e,t)=>e-t),o.push(m[0]);for(let e=1;e<m.length;e+=2){let t=m[e];!isNaN(t)&&o.indexOf(t)===-1&&o.push(t)}}return o}var Te=e((e,t)=>{e=new Color(e),t=new Color(t);let n=e.luminance(),r=t.luminance();return n>r?(n+.05)/(r+.05):(r+.05)/(n+.05)},`default`);
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
*
|
|
5
|
-
* The APCA contrast prediction algorithm is based of the formulas published
|
|
6
|
-
* in the APCA-1.0.98G specification by Myndex. The specification is available at:
|
|
7
|
-
* https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
|
|
8
|
-
*
|
|
9
|
-
* Note that the APCA implementation is still beta, so please update to
|
|
10
|
-
* future versions of chroma.js when they become available.
|
|
11
|
-
*
|
|
12
|
-
* You can read more about the APCA Readability Criterion at
|
|
13
|
-
* https://readtech.org/ARC/
|
|
14
|
-
*/
|
|
15
|
-
const Ee=.027,De=1.14,B=.022,Oe=1.414;var ke=e((e,t)=>{e=new Color(e),t=new Color(t),e.alpha()<1&&(e=T(t,e,e.alpha(),`rgb`));let n=lum(...e.rgb()),r=lum(...t.rgb()),i=n>=B?n:n+(B-n)**Oe,a=r>=B?r:r+(B-r)**Oe,o=a**.56-i**.57,s=a**.65-i**.62,c=Math.abs(a-i)<5e-4?0:i<a?o*De:s*De;return(Math.abs(c)<.1?0:c>0?c-Ee:c+Ee)*100},`default`);function lum(e,t,n){return .2126729*(e/255)**2.4+.7151522*(t/255)**2.4+.072175*(n/255)**2.4}const{sqrt:V,pow:H,min:Ae,max:je,atan2:Me,abs:Ne,cos:U,sin:Pe,exp:Fe,PI:Ie}=Math;function delta_e_default(e,t,n=1,r=1,i=1){var rad2deg=function(e){return 360*e/(2*Ie)},deg2rad=function(e){return 2*Ie*e/360};e=new Color(e),t=new Color(t);let[a,o,s]=Array.from(e.lab()),[c,l,u]=Array.from(t.lab()),d=(a+c)/2,p=(V(H(o,2)+H(s,2))+V(H(l,2)+H(u,2)))/2,m=.5*(1-V(H(p,7)/(H(p,7)+H(25,7)))),h=o*(1+m),g=l*(1+m),_=V(H(h,2)+H(s,2)),v=V(H(g,2)+H(u,2)),y=(_+v)/2,b=rad2deg(Me(s,h)),x=rad2deg(Me(u,g)),S=b>=0?b:b+360,C=x>=0?x:x+360,w=Ne(S-C)>180?(S+C+360)/2:(S+C)/2,T=1-.17*U(deg2rad(w-30))+.24*U(deg2rad(2*w))+.32*U(deg2rad(3*w+6))-.2*U(deg2rad(4*w-63)),E=C-S;E=Ne(E)<=180?E:C<=S?E+360:E-360,E=2*V(_*v)*Pe(deg2rad(E)/2);let ee=c-a,D=v-_,te=1+.015*H(d-50,2)/V(20+H(d-50,2)),O=1+.045*y,k=1+.015*y*T,A=30*Fe(-H((w-275)/25,2)),j=-(2*V(H(y,7)/(H(y,7)+H(25,7))))*Pe(2*deg2rad(A)),M=V(H(ee/(n*te),2)+H(D/(r*O),2)+H(E/(i*k),2)+j*(D/(r*O))*(E/(i*k)));return je(0,Ae(100,M))}e(delta_e_default,`default`);function distance_default(e,t,n=`lab`){e=new Color(e),t=new Color(t);let r=e.get(n),i=t.get(n),a=0;for(let e in r){let t=(r[e]||0)-(i[e]||0);a+=t*t}return Math.sqrt(a)}e(distance_default,`default`);var Le=e((...e)=>{try{return new Color(...e),!0}catch{return!1}},`default`),Re={cool(){return scale_default([chroma.hsl(180,1,.9),chroma.hsl(250,.7,.4)])},hot(){return scale_default([`#000`,`#f00`,`#ff0`,`#fff`],[0,.25,.75,1]).mode(`rgb`)}};const W={OrRd:[`#fff7ec`,`#fee8c8`,`#fdd49e`,`#fdbb84`,`#fc8d59`,`#ef6548`,`#d7301f`,`#b30000`,`#7f0000`],PuBu:[`#fff7fb`,`#ece7f2`,`#d0d1e6`,`#a6bddb`,`#74a9cf`,`#3690c0`,`#0570b0`,`#045a8d`,`#023858`],BuPu:[`#f7fcfd`,`#e0ecf4`,`#bfd3e6`,`#9ebcda`,`#8c96c6`,`#8c6bb1`,`#88419d`,`#810f7c`,`#4d004b`],Oranges:[`#fff5eb`,`#fee6ce`,`#fdd0a2`,`#fdae6b`,`#fd8d3c`,`#f16913`,`#d94801`,`#a63603`,`#7f2704`],BuGn:[`#f7fcfd`,`#e5f5f9`,`#ccece6`,`#99d8c9`,`#66c2a4`,`#41ae76`,`#238b45`,`#006d2c`,`#00441b`],YlOrBr:[`#ffffe5`,`#fff7bc`,`#fee391`,`#fec44f`,`#fe9929`,`#ec7014`,`#cc4c02`,`#993404`,`#662506`],YlGn:[`#ffffe5`,`#f7fcb9`,`#d9f0a3`,`#addd8e`,`#78c679`,`#41ab5d`,`#238443`,`#006837`,`#004529`],Reds:[`#fff5f0`,`#fee0d2`,`#fcbba1`,`#fc9272`,`#fb6a4a`,`#ef3b2c`,`#cb181d`,`#a50f15`,`#67000d`],RdPu:[`#fff7f3`,`#fde0dd`,`#fcc5c0`,`#fa9fb5`,`#f768a1`,`#dd3497`,`#ae017e`,`#7a0177`,`#49006a`],Greens:[`#f7fcf5`,`#e5f5e0`,`#c7e9c0`,`#a1d99b`,`#74c476`,`#41ab5d`,`#238b45`,`#006d2c`,`#00441b`],YlGnBu:[`#ffffd9`,`#edf8b1`,`#c7e9b4`,`#7fcdbb`,`#41b6c4`,`#1d91c0`,`#225ea8`,`#253494`,`#081d58`],Purples:[`#fcfbfd`,`#efedf5`,`#dadaeb`,`#bcbddc`,`#9e9ac8`,`#807dba`,`#6a51a3`,`#54278f`,`#3f007d`],GnBu:[`#f7fcf0`,`#e0f3db`,`#ccebc5`,`#a8ddb5`,`#7bccc4`,`#4eb3d3`,`#2b8cbe`,`#0868ac`,`#084081`],Greys:[`#ffffff`,`#f0f0f0`,`#d9d9d9`,`#bdbdbd`,`#969696`,`#737373`,`#525252`,`#252525`,`#000000`],YlOrRd:[`#ffffcc`,`#ffeda0`,`#fed976`,`#feb24c`,`#fd8d3c`,`#fc4e2a`,`#e31a1c`,`#bd0026`,`#800026`],PuRd:[`#f7f4f9`,`#e7e1ef`,`#d4b9da`,`#c994c7`,`#df65b0`,`#e7298a`,`#ce1256`,`#980043`,`#67001f`],Blues:[`#f7fbff`,`#deebf7`,`#c6dbef`,`#9ecae1`,`#6baed6`,`#4292c6`,`#2171b5`,`#08519c`,`#08306b`],PuBuGn:[`#fff7fb`,`#ece2f0`,`#d0d1e6`,`#a6bddb`,`#67a9cf`,`#3690c0`,`#02818a`,`#016c59`,`#014636`],Viridis:[`#440154`,`#482777`,`#3f4a8a`,`#31678e`,`#26838f`,`#1f9d8a`,`#6cce5a`,`#b6de2b`,`#fee825`],Spectral:[`#9e0142`,`#d53e4f`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#e6f598`,`#abdda4`,`#66c2a5`,`#3288bd`,`#5e4fa2`],RdYlGn:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#d9ef8b`,`#a6d96a`,`#66bd63`,`#1a9850`,`#006837`],RdBu:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#f7f7f7`,`#d1e5f0`,`#92c5de`,`#4393c3`,`#2166ac`,`#053061`],PiYG:[`#8e0152`,`#c51b7d`,`#de77ae`,`#f1b6da`,`#fde0ef`,`#f7f7f7`,`#e6f5d0`,`#b8e186`,`#7fbc41`,`#4d9221`,`#276419`],PRGn:[`#40004b`,`#762a83`,`#9970ab`,`#c2a5cf`,`#e7d4e8`,`#f7f7f7`,`#d9f0d3`,`#a6dba0`,`#5aae61`,`#1b7837`,`#00441b`],RdYlBu:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee090`,`#ffffbf`,`#e0f3f8`,`#abd9e9`,`#74add1`,`#4575b4`,`#313695`],BrBG:[`#543005`,`#8c510a`,`#bf812d`,`#dfc27d`,`#f6e8c3`,`#f5f5f5`,`#c7eae5`,`#80cdc1`,`#35978f`,`#01665e`,`#003c30`],RdGy:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#ffffff`,`#e0e0e0`,`#bababa`,`#878787`,`#4d4d4d`,`#1a1a1a`],PuOr:[`#7f3b08`,`#b35806`,`#e08214`,`#fdb863`,`#fee0b6`,`#f7f7f7`,`#d8daeb`,`#b2abd2`,`#8073ac`,`#542788`,`#2d004b`],Set2:[`#66c2a5`,`#fc8d62`,`#8da0cb`,`#e78ac3`,`#a6d854`,`#ffd92f`,`#e5c494`,`#b3b3b3`],Accent:[`#7fc97f`,`#beaed4`,`#fdc086`,`#ffff99`,`#386cb0`,`#f0027f`,`#bf5b17`,`#666666`],Set1:[`#e41a1c`,`#377eb8`,`#4daf4a`,`#984ea3`,`#ff7f00`,`#ffff33`,`#a65628`,`#f781bf`,`#999999`],Set3:[`#8dd3c7`,`#ffffb3`,`#bebada`,`#fb8072`,`#80b1d3`,`#fdb462`,`#b3de69`,`#fccde5`,`#d9d9d9`,`#bc80bd`,`#ccebc5`,`#ffed6f`],Dark2:[`#1b9e77`,`#d95f02`,`#7570b3`,`#e7298a`,`#66a61e`,`#e6ab02`,`#a6761d`,`#666666`],Paired:[`#a6cee3`,`#1f78b4`,`#b2df8a`,`#33a02c`,`#fb9a99`,`#e31a1c`,`#fdbf6f`,`#ff7f00`,`#cab2d6`,`#6a3d9a`,`#ffff99`,`#b15928`],Pastel2:[`#b3e2cd`,`#fdcdac`,`#cbd5e8`,`#f4cae4`,`#e6f5c9`,`#fff2ae`,`#f1e2cc`,`#cccccc`],Pastel1:[`#fbb4ae`,`#b3cde3`,`#ccebc5`,`#decbe4`,`#fed9a6`,`#ffffcc`,`#e5d8bd`,`#fddaec`,`#f2f2f2`]},ze=Object.keys(W),Be=new Map(ze.map(e=>[e.toLowerCase(),e])),Ve=typeof Proxy==`function`?new Proxy(W,{get(e,t){let n=t.toLowerCase();if(Be.has(n))return e[Be.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(ze)}}):W,cmyk2rgb=(...e)=>{e=o(e,`cmyk`);let[t,n,r,i]=e,a=e.length>4?e[4]:1;return i===1?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-i),n>=1?0:255*(1-n)*(1-i),r>=1?0:255*(1-r)*(1-i),a]},{max:He}=Math,rgb2cmyk=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i=1-He(t,He(n,r)),a=i<1?1/(1-i):0;return[(1-t-i)*a,(1-n-i)*a,(1-r-i)*a,i]};Color.prototype.cmyk=function(){return rgb2cmyk(this._rgb)};const cmyk=(...e)=>new Color(...e,`cmyk`);Object.assign(chroma,{cmyk}),g.format.cmyk=cmyk2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`cmyk`),type_default(e)===`array`&&e.length===4)return`cmyk`}});const hsl2css=(...e)=>{let t=o(e,`hsla`),n=s(e)||`lsa`;return t[0]=rnd2(t[0]||0)+`deg`,t[1]=rnd2(t[1]*100)+`%`,t[2]=rnd2(t[2]*100)+`%`,n===`hsla`||t.length>3&&t[3]<1?(t[3]=`/ `+(t.length>3?t[3]:1),n=`hsla`):t.length=3,`${n.substr(0,3)}(${t.join(` `)})`},lab2css=(...e)=>{let t=o(e,`lab`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=rnd2(t[2]),n===`laba`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(` `)})`},lch2css=(...e)=>{let t=o(e,`lch`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,n===`lcha`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(` `)})`},oklab2css=(...e)=>{let t=o(e,`lab`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=rnd3(t[2]),t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(` `)})`},rgb2oklch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2oklab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},oklch2css=(...e)=>{let t=o(e,`lch`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(` `)})`},{round:G}=Math,rgb2css=(...e)=>{let t=o(e,`rgba`),n=s(e)||`rgb`;if(n.substr(0,3)===`hsl`)return hsl2css(oe(t),n);if(n.substr(0,3)===`lab`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lab2css(rgb2lab(t),n);return setLabWhitePoint(e),r}if(n.substr(0,3)===`lch`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lch2css(rgb2lch(t),n);return setLabWhitePoint(e),r}return n.substr(0,5)===`oklab`?oklab2css(rgb2oklab(t)):n.substr(0,5)===`oklch`?oklch2css(rgb2oklch(t)):(t[0]=G(t[0]),t[1]=G(t[1]),t[2]=G(t[2]),(n===`rgba`||t.length>3&&t[3]<1)&&(t[3]=`/ `+(t.length>3?t[3]:1),n=`rgba`),`${n.substr(0,3)}(${t.slice(0,n===`rgb`?3:4).join(` `)})`)},oklch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r,...i]=e,[a,s,c]=lch2lab(t,n,r),[l,u,d]=oklab2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},K=`((?:-?\\d+)|(?:-?\\d+(?:\\.\\d+)?)%|none)`,q=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%?)|none)`,J=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%)|none)`,Y=`\\s*,\\s*`,X=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:deg)?)|none)`,Ue=RegExp(`^rgba?\\(\\s*`+[K,K,K].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),We=RegExp(`^rgb\\(\\s*`+[K,K,K].join(Y)+`\\s*\\)$`),Ge=RegExp(`^rgba\\(\\s*`+[K,K,K,q].join(Y)+`\\s*\\)$`),Ke=RegExp(`^hsla?\\(\\s*`+[X,J,J].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),qe=RegExp(`^hsl?\\(\\s*`+[X,J,J].join(Y)+`\\s*\\)$`),Je=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Z=RegExp(`^lab\\(\\s*`+[q,q,q].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Ye=RegExp(`^lch\\(\\s*`+[q,q,X].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Xe=RegExp(`^oklab\\(\\s*`+[q,q,q].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Ze=RegExp(`^oklch\\(\\s*`+[q,q,X].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),{round:Q}=Math,roundRGB=e=>e.map((e,t)=>t<=2?r(Q(e),0,255):e),percentToAbsolute=(e,t=0,n=100,r=!1)=>(typeof e==`string`&&e.endsWith(`%`)&&(e=parseFloat(e.substring(0,e.length-1))/100,e=r?t+(e+1)*.5*(n-t):t+e*(n-t)),+e),noneToValue=(e,t)=>e===`none`?t:e,css2rgb=e=>{if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t;if(g.format.named)try{return g.format.named(e)}catch{}if((t=e.match(Ue))||(t=e.match(We))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+percentToAbsolute(noneToValue(e[t],0),0,255);e=roundRGB(e);let n=t[4]===void 0?1:+percentToAbsolute(t[4],0,1);return e[3]=n,e}if(t=e.match(Ge)){let e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+percentToAbsolute(e[t],0,255);return e}if((t=e.match(Ke))||(t=e.match(qe))){let e=t.slice(1,4);e[0]=+noneToValue(e[0].replace(`deg`,``),0),e[1]=percentToAbsolute(noneToValue(e[1],0),0,100)*.01,e[2]=percentToAbsolute(noneToValue(e[2],0),0,100)*.01;let n=roundRGB(hsl2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Je)){let e=t.slice(1,4);e[1]*=.01,e[2]*=.01;let n=hsl2rgb(e);for(let e=0;e<3;e++)n[e]=Q(n[e]);return n[3]=+t[4],n}if(t=e.match(Z)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),-125,125,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-125,125,!0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lab2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Ye)){let e=t.slice(1,4);e[0]=percentToAbsolute(e[0],0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),0,150,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lch2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Xe)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),-.4,.4,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-.4,.4,!0);let n=roundRGB(oklab2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Ze)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),0,.4,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=roundRGB(oklch2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}};css2rgb.test=e=>Ue.test(e)||Ke.test(e)||Z.test(e)||Ye.test(e)||Xe.test(e)||Ze.test(e)||We.test(e)||Ge.test(e)||qe.test(e)||Je.test(e)||e===`transparent`,Color.prototype.css=function(e){return rgb2css(this._rgb,e)};const css=(...e)=>new Color(...e,`css`);chroma.css=css,g.format.css=css2rgb,g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&css2rgb.test(e))return`css`}}),g.format.gl=(...e)=>{let t=o(e,`rgba`);return t[0]*=255,t[1]*=255,t[2]*=255,t};const gl=(...e)=>new Color(...e,`gl`);chroma.gl=gl,Color.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},Color.prototype.hex=function(e){return rgb2hex(this._rgb,e)};const hex=(...e)=>new Color(...e,`hex`);chroma.hex=hex,g.format.hex=hex2rgb,g.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return`hex`}});const{log:$}=Math,temperature2rgb=e=>{let t=e/100,n,r,i;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*$(r),i=t<20?0:-254.76935184120902+.8274096064007395*(i=t-10)+115.67994401066147*$(i)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*$(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*$(r),i=255),[n,r,i,1]},{round:Qe}=Math,rgb2temperature=(...e)=>{let t=o(e,`rgb`),n=t[0],r=t[2],i=1e3,a=4e4,s;for(;a-i>.4;){s=(a+i)*.5;let e=temperature2rgb(s);e[2]/e[0]>=r/n?a=s:i=s}return Qe(s)};Color.prototype.temp=Color.prototype.kelvin=Color.prototype.temperature=function(){return rgb2temperature(this._rgb)};const temp=(...e)=>new Color(...e,`temp`);Object.assign(chroma,{temp,kelvin:temp,temperature:temp}),g.format.temp=g.format.kelvin=g.format.temperature=temperature2rgb,Color.prototype.oklch=function(){return rgb2oklch(this._rgb)};const oklch=(...e)=>new Color(...e,`oklch`);Object.assign(chroma,{oklch}),g.format.oklch=oklch2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklch`),type_default(e)===`array`&&e.length===3)return`oklch`}}),Object.assign(chroma,{analyze,average:pe,bezier:he,blend,brewer:Ve,Color,colors:_,contrast:Te,contrastAPCA:ke,cubehelix:cubehelix_default,deltaE:delta_e_default,distance:distance_default,input:g,interpolate:T,limits,mix:T,random:xe,scale:scale_default,scales:Re,valid:Le});var $e=chroma;export{$e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,t}from"../rolldown-runtime.mjs";var n=e(t(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function Events(){}Object.create&&(Events.prototype=Object.create(null),new Events().__proto__||(r=!1));function EE(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function addListener(e,t,n,i,a){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var o=new EE(n,i||e,a),s=r?r+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function clearEvent(e,t){--e._eventsCount===0?e._events=new Events:delete e._events[t]}function EventEmitter(){this._events=new Events,this._eventsCount=0}EventEmitter.prototype.eventNames=function eventNames(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},EventEmitter.prototype.listeners=function listeners(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},EventEmitter.prototype.listenerCount=function listenerCount(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},EventEmitter.prototype.emit=function emit(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},EventEmitter.prototype.on=function on(e,t,n){return addListener(this,e,t,n,!1)},EventEmitter.prototype.once=function once(e,t,n){return addListener(this,e,t,n,!0)},EventEmitter.prototype.removeListener=function removeListener(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return clearEvent(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&clearEvent(this,a);else{for(var s=0,c=[],l=o.length;s<l;s++)(o[s].fn!==t||i&&!o[s].once||n&&o[s].context!==n)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:clearEvent(this,a)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(e){var t;return e?(t=r?r+e:e,this._events[t]&&clearEvent(this,t)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=r,EventEmitter.EventEmitter=EventEmitter,t!==void 0&&(t.exports=EventEmitter)}))(),1);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"../rolldown-runtime.mjs";var t=e((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),n=e(((e,n)=>{var r=t(),i=r.ARRAY_BUFFER_SUPPORT,a=r.SYMBOL_SUPPORT;n.exports=function forEach(e,t){var n,r,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||i&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(a&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(r in e)e.hasOwnProperty(r)&&t(e[r],r)}})),r=e(((e,t)=>{function Iterator(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(Iterator.prototype[Symbol.iterator]=function(){return this}),Iterator.of=function(){var e=arguments,t=e.length,n=0;return new Iterator(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},Iterator.empty=function(){return new Iterator(function(){return{done:!0}})},Iterator.fromSequence=function(e){var t=0,n=e.length;return new Iterator(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},Iterator.is=function(e){return e instanceof Iterator||typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=Iterator})),i=e(((e,t)=>{t.exports=function isGraph(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),a=e((e=>{var t=2**16-1,n=2**32-1,r=2**7-1,i=2**15-1,a=2**31-1;e.getPointerArray=function(e){var r=e-1;if(r<=255)return Uint8Array;if(r<=t)return Uint16Array;if(r<=n)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=r?Int8Array:t<=i?Int16Array:t<=a?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var o={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,s,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],s=e.getNumberType(c),a=o[s.name],a>i&&(i=a,r=s);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),o=e((e=>{var t=n(),r=a();function isArrayLike(e){return Array.isArray(e)||r.isTypedArray(e)}function guessLength(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function toArray(e){var n=guessLength(e),r=typeof n==`number`?Array(n):[],i=0;return t(e,function(e){r[i++]=e}),r}function toArrayWithIndices(e){var n=guessLength(e),i=typeof n==`number`?r.getPointerArray(n):Array,a=typeof n==`number`?Array(n):[],o=typeof n==`number`?new i(n):[],s=0;return t(e,function(e){a[s]=e,o[s]=s++}),[a,o]}e.isArrayLike=isArrayLike,e.guessLength=guessLength,e.toArray=toArray,e.toArrayWithIndices=toArrayWithIndices})),s=e(((e,t)=>{var n=o(),i=r();function FixedDeque(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-deque: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}FixedDeque.prototype.clear=function(){this.start=0,this.size=0},FixedDeque.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.push: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,++this.size},FixedDeque.prototype.unshift=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.unshift: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.start=t,++this.size},FixedDeque.prototype.pop=function(){if(this.size!==0){this.size--;var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},FixedDeque.prototype.shift=function(){if(this.size!==0){var e=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[e]}},FixedDeque.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},FixedDeque.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},FixedDeque.prototype.get=function(e){if(!(this.size===0||e>=this.capacity))return e=this.start+e,e>=this.capacity&&(e-=this.capacity),this.items[e]},FixedDeque.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.items[i],a,this),i++,a++,i===n&&(i=0)},FixedDeque.prototype.toArray=function(){var e=this.start+this.size;if(e<this.capacity)return this.items.slice(this.start,e);for(var t=new this.ArrayClass(this.size),n=this.capacity,r=this.size,i=this.start,a=0;a<r;)t[a]=this.items[i],i++,a++,i===n&&(i=0);return t},FixedDeque.prototype.values=function(){var e=this.items,t=this.capacity,n=this.size,r=this.start,a=0;return new i(function(){if(a>=n)return{done:!0};var i=e[r];return r++,a++,r===t&&(r=0),{value:i,done:!1}})},FixedDeque.prototype.entries=function(){var e=this.items,t=this.capacity,n=this.size,r=this.start,a=0;return new i(function(){if(a>=n)return{done:!0};var i=e[r];return r++,r===t&&(r=0),{value:[a++,i],done:!1}})},typeof Symbol<`u`&&(FixedDeque.prototype[Symbol.iterator]=FixedDeque.prototype.values),FixedDeque.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:FixedDeque,enumerable:!1}),e},typeof Symbol<`u`&&(FixedDeque.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=FixedDeque.prototype.inspect),FixedDeque.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.`);var i=new FixedDeque(t,r);if(n.isArrayLike(e)){var a,o;for(a=0,o=e.length;a<o;a++)i.items[a]=e[a];return i.size=o,i}return n.forEach(e,function(e){i.push(e)}),i},t.exports=FixedDeque})),c=e((e=>{let t=i(),n=s();function simpleInDegree(e,t){let n=0;return e.forEachInNeighbor(t,()=>{n++}),n}function forEachNodeInTopologicalOrder(e,r){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);if(e.type===`undirected`||e.undirectedSize!==0)throw Error(`graphology-dag/topological-sort: cannot work if graph is not directed.`);if(e.order===0)return;let i=new n(Array,e.order),a={},o=0;e.forEachNode((t,n)=>{let r=e.multi?simpleInDegree(e,t):e.inDegree(t);r===0?i.push([t,n,0]):(a[t]=r,o+=r)});let s=0;function neighborCallback(e,t){let n=--a[e];o--,n===0&&i.push([e,t,s+1]),a[e]=n}for(;i.size!==0;){let[t,n,a]=i.shift();s=a,r(t,n,a),e.forEachOutNeighbor(t,neighborCallback)}if(o!==0)throw Error(`graphology-dag/topological-sort: given graph is not acyclic.`)}function topologicalSort(e){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);let n=Array(e.order),r=0;return forEachNodeInTopologicalOrder(e,e=>{n[r++]=e}),n}e.topologicalSort=topologicalSort})),l=e(((e,t)=>{let n=i();t.exports=function willCreateCycle(e,t,r){if(!n(e))throw Error(`graphology-dag/will-create-cycle: the given graph is not a valid graphology instance.`);if(t=``+t,r=``+r,t===r)return!0;if(!e.hasNode(t)||!e.hasNode(r)||e.hasDirectedEdge(t,r))return!1;if(e.hasDirectedEdge(r,t))return!0;let i=e.outNeighbors(r);function push(e){i.push(e)}for(;i.length!==0;){let n=i.pop();if(n===t)return!0;e.forEachOutNeighbor(n,push)}return!1}}));export{n as i,c as n,r,l as t};
|