@gram-data/gram-identity
Advanced tools
Comparing version 0.2.11 to 0.2.12
import { Plugin } from 'unified'; | ||
interface IdentityPluginSettings { | ||
kind?: 'numeric' | 'shortid'; | ||
generator: 'counter' | 'nanoid'; | ||
alphabet?: string; | ||
prefix?: string; | ||
} | ||
declare const gramIdentityPlugin: Plugin<IdentityPluginSettings[]>; | ||
export default gramIdentityPlugin; |
@@ -6,2 +6,4 @@ 'use strict'; | ||
var gramAst = require('@gram-data/gram-ast'); | ||
var nanoid = require('nanoid'); | ||
var simpleBaseConverter = require('simple-base-converter'); | ||
@@ -26,10 +28,12 @@ function _extends() { | ||
var shortid = /*#__PURE__*/require('shortid'); | ||
var alphabets = { | ||
base2: '01', | ||
dieBase6: '⚀⚁⚂⚃⚄⚅', | ||
base8: '01234567', | ||
base10: '0123456789', | ||
astrologyBase12: '♈︎♉︎♊︎♋︎♌︎♍︎♎︎♏︎♐︎♑︎♒︎♓︎', | ||
base11: '0123456789a', | ||
chessBase12: '♚♛♜♝♞♟♔♕♖♗♘♙', | ||
base16: '0123456789abcdef', | ||
dominoBase28: '🁣🁤🁫🁥🁬🁳🁦🁭🁴🁻🁧🁮🁵🁼🂃🁨🁯🁶🁽🂊🂋🁩🁰🁷🁾🂅🂌🂓', | ||
base32: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', | ||
@@ -40,40 +44,74 @@ zBase32: 'ybndrfg8ejkmcpqxot1uwisza345h769', | ||
base36: '0123456789abcdefghijklmnopqrstuvwxyz', | ||
mahjongBase43: '🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀇🀈🀉🀊🀋🀌🀍🀎🀏🀀🀁🀂🀃🀄︎🀅🀆🀐🀢🀣🀤🀥🀦🀧🀨🀩🀪', | ||
cards56: '🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎🃑🃒🃓🃔🃕🃖🃗🃘🃙🃝🃞', | ||
base58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
flickrBase58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
base62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@' | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@', | ||
cookieBase90: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~" | ||
}; | ||
shortid.characters(alphabets.base64); | ||
/** | ||
* Identifier function which produces a pseudo-random, short identifier. | ||
* Creates an IDGenerator based on incrementing numbers. | ||
* | ||
*/ | ||
var counterIDGenerator = function counterIDGenerator(prefix) { | ||
var nextid = 0; | ||
return { | ||
generate: function generate() { | ||
return "" + (prefix || '') + nextid++; | ||
} | ||
}; | ||
}; | ||
var shortID = shortid.generate; | ||
/** | ||
* Factory for creating an IDGenerator based on | ||
* [nanoid](https://github.com/ai/nanoid) | ||
* | ||
*/ | ||
var nanoidGenerator = function nanoidGenerator(alphabet, size, prefix) { | ||
if (alphabet === void 0) { | ||
alphabet = alphabets.base64; | ||
} | ||
if (size === void 0) { | ||
size = 21; | ||
} | ||
var generator = nanoid.customAlphabet(alphabet, size); | ||
return { | ||
generate: function generate() { | ||
return prefix ? prefix + generator() : generator(); | ||
} | ||
}; | ||
}; | ||
var visit = /*#__PURE__*/require('unist-util-visit'); | ||
var defaultSettings = { | ||
kind: 'numeric' | ||
generator: 'counter', | ||
alphabet: alphabets.base58, | ||
prefix: undefined | ||
}; | ||
var gramIdentityPlugin = function gramIdentityPlugin(s) { | ||
if (s === void 0) { | ||
s = defaultSettings; | ||
} | ||
var gramIdentityPlugin = function gramIdentityPlugin(settings) { | ||
var s = _extends({}, defaultSettings, settings); | ||
var mergedSettings = _extends({}, defaultSettings, s); | ||
var identification = function identification(tree) { | ||
var generator; | ||
var identification = function identification(tree) { | ||
var counter = 0; | ||
switch (s.generator) { | ||
case 'nanoid': | ||
generator = nanoidGenerator(s.alphabet, 21, s.prefix); | ||
break; | ||
case 'counter': | ||
default: | ||
generator = counterIDGenerator(s.prefix); | ||
} | ||
visit(tree, function (element) { | ||
if (gramAst.isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
case 'numeric': | ||
element.id = element.id || "" + counter++; | ||
break; | ||
case 'shortid': | ||
element.id = element.id || shortID(); | ||
break; | ||
} | ||
element.id = element.id || generator.generate(); | ||
} | ||
@@ -86,5 +124,45 @@ }); | ||
var _short = /*#__PURE__*/require('short-uuid'); | ||
/** | ||
* Factory for creating an IDGenerator based on | ||
* [short-uuid](https://github.com/oculus42/short-uuid) | ||
* | ||
*/ | ||
var shortUUIDGenerator = function shortUUIDGenerator(alphabet, opt) { | ||
return _short(alphabet, opt); | ||
}; | ||
/** | ||
* Creates an IDGenerator based an alphabet progression | ||
* (like counting numbers with an alternative encoding). | ||
* | ||
* @see [power-radix](https://github.com/cflynn07/power-radix) | ||
* @see [bigint-buffer](https://github.com/no2chem/bigint-buffer) | ||
* | ||
*/ | ||
var simpleBaseIDGenerator = function simpleBaseIDGenerator(alphabet, prefix) { | ||
if (alphabet === void 0) { | ||
alphabet = alphabets.crock32; | ||
} | ||
var one = BigInt(1); | ||
var nextid = BigInt(0); | ||
return { | ||
generate: function generate() { | ||
var id = simpleBaseConverter.convertBase(nextid.toString(), 10, alphabet); | ||
nextid = nextid + one; | ||
return prefix ? prefix + id : id; | ||
} | ||
}; | ||
}; | ||
exports.alphabets = alphabets; | ||
exports.counterIDGenerator = counterIDGenerator; | ||
exports.gramIdentityPlugin = gramIdentityPlugin; | ||
exports.shortID = shortID; | ||
exports.nanoidGenerator = nanoidGenerator; | ||
exports.shortUUIDGenerator = shortUUIDGenerator; | ||
exports.simpleBaseIDGenerator = simpleBaseIDGenerator; | ||
//# sourceMappingURL=gram-identity.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast");function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e}).apply(this,arguments)}var a=require("shortid"),t={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};a.characters(t.base64);var s=a.generate,i=require("unist-util-visit"),n={kind:"numeric"};exports.alphabets=t,exports.gramIdentityPlugin=function(a){void 0===a&&(a=n);var t=r({},n,a);return function(r){var a=0;i(r,(function(r){if(e.isGramPath(r))switch(t.kind){case"numeric":r.id=r.id||""+a++;break;case"shortid":r.id=r.id||s()}}))}},exports.shortID=s; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast"),r=require("nanoid"),a=require("simple-base-converter");function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e}).apply(this,arguments)}var n={base2:"01",dieBase6:"⚀⚁⚂⚃⚄⚅",base8:"01234567",base10:"0123456789",astrologyBase12:"♈︎♉︎♊︎♋︎♌︎♍︎♎︎♏︎♐︎♑︎♒︎♓︎",base11:"0123456789a",chessBase12:"♚♛♜♝♞♟♔♕♖♗♘♙",base16:"0123456789abcdef",dominoBase28:"🁣🁤🁫🁥🁬🁳🁦🁭🁴🁻🁧🁮🁵🁼🂃🁨🁯🁶🁽🂊🂋🁩🁰🁷🁾🂅🂌🂓",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",mahjongBase43:"🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀇🀈🀉🀊🀋🀌🀍🀎🀏🀀🀁🀂🀃🀄︎🀅🀆🀐🀢🀣🀤🀥🀦🀧🀨🀩🀪",cards56:"🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎🃑🃒🃓🃔🃕🃖🃗🃘🃙🃝🃞",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",flickrBase58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@",cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~"},o=function(e){var r=0;return{generate:function(){return""+(e||"")+r++}}},s=function(e,a,t){void 0===e&&(e=n.base64),void 0===a&&(a=21);var o=r.customAlphabet(e,a);return{generate:function(){return t?t+o():o()}}},i=require("unist-util-visit"),u={generator:"counter",alphabet:n.base58,prefix:void 0},c=require("short-uuid");exports.alphabets=n,exports.counterIDGenerator=o,exports.gramIdentityPlugin=function(r){var a=t({},u,r);return function(r){var t;switch(a.generator){case"nanoid":t=s(a.alphabet,21,a.prefix);break;case"counter":default:t=o(a.prefix)}i(r,(function(r){e.isGramPath(r)&&(r.id=r.id||t.generate())}))}},exports.nanoidGenerator=s,exports.shortUUIDGenerator=function(e,r){return c(e,r)},exports.simpleBaseIDGenerator=function(e,r){void 0===e&&(e=n.crock32);var t=BigInt(1),o=BigInt(0);return{generate:function(){var n=a.convertBase(o.toString(),10,e);return o+=t,r?r+n:n}}}; | ||
//# sourceMappingURL=gram-identity.cjs.production.min.js.map |
export declare const alphabets: { | ||
base2: string; | ||
dieBase6: string; | ||
base8: string; | ||
base10: string; | ||
astrologyBase12: string; | ||
base11: string; | ||
chessBase12: string; | ||
base16: string; | ||
dominoBase28: string; | ||
base32: string; | ||
@@ -12,10 +16,12 @@ zBase32: string; | ||
base36: string; | ||
mahjongBase43: string; | ||
cards56: string; | ||
base58: string; | ||
flickrBase58: string; | ||
base62: string; | ||
base64: string; | ||
cookieBase90: string; | ||
}; | ||
/** | ||
* Identifier function which produces a pseudo-random, short identifier. | ||
* | ||
*/ | ||
export declare const shortID: any; | ||
export declare type IDGenerator = { | ||
generate: () => string; | ||
}; |
import { isGramPath } from '@gram-data/gram-ast'; | ||
import { customAlphabet } from 'nanoid'; | ||
import { convertBase } from 'simple-base-converter'; | ||
@@ -21,10 +23,12 @@ function _extends() { | ||
var shortid = /*#__PURE__*/require('shortid'); | ||
var alphabets = { | ||
base2: '01', | ||
dieBase6: '⚀⚁⚂⚃⚄⚅', | ||
base8: '01234567', | ||
base10: '0123456789', | ||
astrologyBase12: '♈︎♉︎♊︎♋︎♌︎♍︎♎︎♏︎♐︎♑︎♒︎♓︎', | ||
base11: '0123456789a', | ||
chessBase12: '♚♛♜♝♞♟♔♕♖♗♘♙', | ||
base16: '0123456789abcdef', | ||
dominoBase28: '🁣🁤🁫🁥🁬🁳🁦🁭🁴🁻🁧🁮🁵🁼🂃🁨🁯🁶🁽🂊🂋🁩🁰🁷🁾🂅🂌🂓', | ||
base32: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', | ||
@@ -35,40 +39,74 @@ zBase32: 'ybndrfg8ejkmcpqxot1uwisza345h769', | ||
base36: '0123456789abcdefghijklmnopqrstuvwxyz', | ||
mahjongBase43: '🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀇🀈🀉🀊🀋🀌🀍🀎🀏🀀🀁🀂🀃🀄︎🀅🀆🀐🀢🀣🀤🀥🀦🀧🀨🀩🀪', | ||
cards56: '🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎🃑🃒🃓🃔🃕🃖🃗🃘🃙🃝🃞', | ||
base58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
flickrBase58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
base62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@' | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@', | ||
cookieBase90: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~" | ||
}; | ||
shortid.characters(alphabets.base64); | ||
/** | ||
* Identifier function which produces a pseudo-random, short identifier. | ||
* Creates an IDGenerator based on incrementing numbers. | ||
* | ||
*/ | ||
var counterIDGenerator = function counterIDGenerator(prefix) { | ||
var nextid = 0; | ||
return { | ||
generate: function generate() { | ||
return "" + (prefix || '') + nextid++; | ||
} | ||
}; | ||
}; | ||
var shortID = shortid.generate; | ||
/** | ||
* Factory for creating an IDGenerator based on | ||
* [nanoid](https://github.com/ai/nanoid) | ||
* | ||
*/ | ||
var nanoidGenerator = function nanoidGenerator(alphabet, size, prefix) { | ||
if (alphabet === void 0) { | ||
alphabet = alphabets.base64; | ||
} | ||
if (size === void 0) { | ||
size = 21; | ||
} | ||
var generator = customAlphabet(alphabet, size); | ||
return { | ||
generate: function generate() { | ||
return prefix ? prefix + generator() : generator(); | ||
} | ||
}; | ||
}; | ||
var visit = /*#__PURE__*/require('unist-util-visit'); | ||
var defaultSettings = { | ||
kind: 'numeric' | ||
generator: 'counter', | ||
alphabet: alphabets.base58, | ||
prefix: undefined | ||
}; | ||
var gramIdentityPlugin = function gramIdentityPlugin(s) { | ||
if (s === void 0) { | ||
s = defaultSettings; | ||
} | ||
var gramIdentityPlugin = function gramIdentityPlugin(settings) { | ||
var s = _extends({}, defaultSettings, settings); | ||
var mergedSettings = _extends({}, defaultSettings, s); | ||
var identification = function identification(tree) { | ||
var generator; | ||
var identification = function identification(tree) { | ||
var counter = 0; | ||
switch (s.generator) { | ||
case 'nanoid': | ||
generator = nanoidGenerator(s.alphabet, 21, s.prefix); | ||
break; | ||
case 'counter': | ||
default: | ||
generator = counterIDGenerator(s.prefix); | ||
} | ||
visit(tree, function (element) { | ||
if (isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
case 'numeric': | ||
element.id = element.id || "" + counter++; | ||
break; | ||
case 'shortid': | ||
element.id = element.id || shortID(); | ||
break; | ||
} | ||
element.id = element.id || generator.generate(); | ||
} | ||
@@ -81,3 +119,40 @@ }); | ||
export { alphabets, gramIdentityPlugin, shortID }; | ||
var _short = /*#__PURE__*/require('short-uuid'); | ||
/** | ||
* Factory for creating an IDGenerator based on | ||
* [short-uuid](https://github.com/oculus42/short-uuid) | ||
* | ||
*/ | ||
var shortUUIDGenerator = function shortUUIDGenerator(alphabet, opt) { | ||
return _short(alphabet, opt); | ||
}; | ||
/** | ||
* Creates an IDGenerator based an alphabet progression | ||
* (like counting numbers with an alternative encoding). | ||
* | ||
* @see [power-radix](https://github.com/cflynn07/power-radix) | ||
* @see [bigint-buffer](https://github.com/no2chem/bigint-buffer) | ||
* | ||
*/ | ||
var simpleBaseIDGenerator = function simpleBaseIDGenerator(alphabet, prefix) { | ||
if (alphabet === void 0) { | ||
alphabet = alphabets.crock32; | ||
} | ||
var one = BigInt(1); | ||
var nextid = BigInt(0); | ||
return { | ||
generate: function generate() { | ||
var id = convertBase(nextid.toString(), 10, alphabet); | ||
nextid = nextid + one; | ||
return prefix ? prefix + id : id; | ||
} | ||
}; | ||
}; | ||
export { alphabets, counterIDGenerator, gramIdentityPlugin, nanoidGenerator, shortUUIDGenerator, simpleBaseIDGenerator }; | ||
//# sourceMappingURL=gram-identity.esm.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.identity={}))}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}var r=require("shortid"),a={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};r.characters(a.base64);var i=r.generate,n=require("unist-util-visit"),s={kind:"numeric"};e.alphabets=a,e.gramIdentityPlugin=function(e){void 0===e&&(e=s);var r=t({},s,e);return function(e){var t=0;n(e,(function(e){if((a=e).type&&"path"===a.type)switch(r.kind){case"numeric":e.id=e.id||""+t++;break;case"shortid":e.id=e.id||i()}var a}))}},e.shortID=i,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((e=e||self).gram=e.gram||{},e.gram.identity={}))}(this,(function(e){"use strict";function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var t={base2:"01",dieBase6:"⚀⚁⚂⚃⚄⚅",base8:"01234567",base10:"0123456789",astrologyBase12:"♈︎♉︎♊︎♋︎♌︎♍︎♎︎♏︎♐︎♑︎♒︎♓︎",base11:"0123456789a",chessBase12:"♚♛♜♝♞♟♔♕♖♗♘♙",base16:"0123456789abcdef",dominoBase28:"🁣🁤🁫🁥🁬🁳🁦🁭🁴🁻🁧🁮🁵🁼🂃🁨🁯🁶🁽🂊🂋🁩🁰🁷🁾🂅🂌🂓",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",mahjongBase43:"🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀇🀈🀉🀊🀋🀌🀍🀎🀏🀀🀁🀂🀃🀄︎🀅🀆🀐🀢🀣🀤🀥🀦🀧🀨🀩🀪",cards56:"🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎🃑🃒🃓🃔🃕🃖🃗🃘🃙🃝🃞",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",flickrBase58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@",cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~"},r=function(e){var n=0;return{generate:function(){return""+(e||"")+n++}}};let i=e=>crypto.getRandomValues(new Uint8Array(e));var s,o,u=function(e,n,r){void 0===e&&(e=t.base64),void 0===n&&(n=21);var s=((e,n)=>((e,n,t)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*r*n/e.length);return()=>{let s="";for(;;){let o=t(i),u=i;for(;u--;)if(s+=e[o[u]&r]||"",s.length===+n)return s}}})(e,n,i))(e,n);return{generate:function(){return r?r+s():s()}}},c=require("unist-util-visit"),a={generator:"counter",alphabet:t.base58,prefix:void 0},f=require("short-uuid"),l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=9e15,h="0123456789abcdef",g="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",p="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",m={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-d,maxE:d,crypto:!1},w=!0,v="[DecimalError] Invalid argument: ",b=Math.floor,N=Math.pow,y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,E=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,x=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,T=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_=1e7,M=g.length-1,O=p.length-1,q={name:"[object Decimal]"};function D(e){var n,t,r,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,n=1;n<i;n++)(t=7-(r=e[n]+"").length)&&(s+=L(t)),s+=r;(t=7-(r=(o=e[n])+"").length)&&(s+=L(t))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function S(e,n,t){if(e!==~~e||e<n||e>t)throw Error(v+e)}function F(e,n,t,r){var i,s,o,u;for(s=e[0];s>=10;s/=10)--n;return--n<0?(n+=7,i=0):(i=Math.ceil((n+1)/7),n%=7),s=N(10,7-n),u=e[i]%s|0,null==r?n<3?(0==n?u=u/100|0:1==n&&(u=u/10|0),o=t<4&&99999==u||t>3&&49999==u||5e4==u||0==u):o=(t<4&&u+1==s||t>3&&u+1==s/2)&&(e[i+1]/s/100|0)==N(10,n-2)-1||(u==s/2||0==u)&&0==(e[i+1]/s/100|0):n<4?(0==n?u=u/1e3|0:1==n?u=u/100|0:2==n&&(u=u/10|0),o=(r||t<4)&&9999==u||!r&&t>3&&4999==u):o=((r||t<4)&&u+1==s||!r&&t>3&&u+1==s/2)&&(e[i+1]/s/1e3|0)==N(10,n-3)-1,o}function B(e,n,t){for(var r,i,s=[0],o=0,u=e.length;o<u;){for(i=s.length;i--;)s[i]*=n;for(s[0]+=h.indexOf(e.charAt(o++)),r=0;r<s.length;r++)s[r]>t-1&&(void 0===s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/t|0,s[r]%=t)}return s.reverse()}q.absoluteValue=q.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),A(e)},q.ceil=function(){return A(new this.constructor(this),this.e+1,2)},q.comparedTo=q.cmp=function(e){var n,t,r,i,s=this,o=s.d,u=(e=new s.constructor(e)).d,c=s.s,a=e.s;if(!o||!u)return c&&a?c!==a?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-a:0;if(c!==a)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(n=0,t=(r=o.length)<(i=u.length)?r:i;n<t;++n)if(o[n]!==u[n])return o[n]>u[n]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},q.cosine=q.cos=function(){var e,n,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.rounding,r.precision=(e=r.precision)+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,n){var t,r,i=n.d.length;i<32?r=(1/Q(4,t=Math.ceil(i/3))).toString():(t=16,r="2.3283064365386962890625e-10"),e.precision+=t,n=K(e,1,n.times(r),new e(1));for(var s=t;s--;){var o=n.times(n);n=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,n}(r,X(r,t)),r.precision=e,r.rounding=n,A(2==o||3==o?t.neg():t,e,n,!0)):new r(1):new r(NaN)},q.cubeRoot=q.cbrt=function(){var e,n,t,r,i,s,o,u,c,a,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(w=!1,(s=f.s*N(f.s*f,1/3))&&Math.abs(s)!=1/0?r=new l(s.toString()):(t=D(f.d),(s=((e=f.e)-t.length+1)%3)&&(t+=1==s||-2==s?"0":"00"),s=N(t,1/3),e=b((e+1)/3)-(e%3==(e<0?-1:2)),(r=new l(t=s==1/0?"5e"+e:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=f.s),o=(e=l.precision)+3;;)if(a=(c=(u=r).times(u).times(u)).plus(f),r=P(a.plus(f).times(u),a.plus(c),o+2,1),D(u.d).slice(0,o)===(t=D(r.d)).slice(0,o)){if("9999"!=(t=t.slice(o-3,o+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(A(r,e+1,1),n=!r.times(r).times(r).eq(f));break}if(!i&&(A(u,e+1,0),u.times(u).times(u).eq(f))){r=u;break}o+=4,i=1}return w=!0,A(r,e,l.rounding,n)},q.decimalPlaces=q.dp=function(){var e,n=this.d,t=NaN;if(n){if(t=7*((e=n.length-1)-b(this.e/7)),e=n[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},q.dividedBy=q.div=function(e){return P(this,new this.constructor(e))},q.dividedToIntegerBy=q.divToInt=function(e){var n=this.constructor;return A(P(this,new n(e),0,1,1),n.precision,n.rounding)},q.equals=q.eq=function(e){return 0===this.cmp(e)},q.floor=function(){return A(new this.constructor(this),this.e+1,3)},q.greaterThan=q.gt=function(e){return this.cmp(e)>0},q.greaterThanOrEqualTo=q.gte=function(e){var n=this.cmp(e);return 1==n||0===n},q.hyperbolicCosine=q.cosh=function(){var e,n,t,r,i,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;r=o.rounding,o.precision=(t=o.precision)+Math.max(s.e,s.sd())+4,o.rounding=1,(i=s.d.length)<32?n=(1/Q(4,e=Math.ceil(i/3))).toString():(e=16,n="2.3283064365386962890625e-10"),s=K(o,1,s.times(n),new o(1),!0);for(var c,a=e,f=new o(8);a--;)c=s.times(s),s=u.minus(c.times(f.minus(c.times(f))));return A(s,o.precision=t,o.rounding=r,!0)},q.hyperbolicSine=q.sinh=function(){var e,n,t,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.rounding,s.precision=(n=s.precision)+Math.max(i.e,i.sd())+4,s.rounding=1,(r=i.d.length)<3)i=K(s,2,i,i,!0);else{e=1.4*Math.sqrt(r),i=K(s,2,i=i.times(1/Q(5,e=e>16?16:0|e)),i,!0);for(var o,u=new s(5),c=new s(16),a=new s(20);e--;)o=i.times(i),i=i.times(u.plus(o.times(c.times(o).plus(a))))}return s.precision=n,s.rounding=t,A(i,n,t,!0)},q.hyperbolicTangent=q.tanh=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.rounding,r.precision=(e=r.precision)+7,r.rounding=1,P(t.sinh(),t.cosh(),r.precision=e,r.rounding=n)):new r(t.s)},q.inverseCosine=q.acos=function(){var e,n=this,t=n.constructor,r=n.abs().cmp(1),i=t.precision,s=t.rounding;return-1!==r?0===r?n.isNeg()?I(t,i,s):new t(0):new t(NaN):n.isZero()?I(t,i+4,s).times(.5):(t.precision=i+6,t.rounding=1,n=n.asin(),e=I(t,i+4,s).times(.5),t.precision=i,t.rounding=s,e.minus(n))},q.inverseHyperbolicCosine=q.acosh=function(){var e,n,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.rounding,r.precision=(e=r.precision)+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,w=!1,t=t.times(t).minus(1).sqrt().plus(t),w=!0,r.precision=e,r.rounding=n,t.ln()):new r(t)},q.inverseHyperbolicSine=q.asinh=function(){var e,n,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.rounding,r.precision=(e=r.precision)+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,w=!1,t=t.times(t).plus(1).sqrt().plus(t),w=!0,r.precision=e,r.rounding=n,t.ln())},q.inverseHyperbolicTangent=q.atanh=function(){var e,n,t,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,n=s.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?A(new s(i),e,n,!0):(s.precision=t=r-i.e,i=P(i.plus(1),new s(1).minus(i),t+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=n,i.times(.5))):new s(NaN)},q.inverseSine=q.asin=function(){var e,n,t,r,i=this,s=i.constructor;return i.isZero()?new s(i):(n=i.abs().cmp(1),t=s.precision,r=s.rounding,-1!==n?0===n?((e=I(s,t+4,r).times(.5)).s=i.s,e):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,i.times(2)))},q.inverseTangent=q.atan=function(){var e,n,t,r,i,s,o,u,c,a=this,f=a.constructor,l=f.precision,d=f.rounding;if(a.isFinite()){if(a.isZero())return new f(a);if(a.abs().eq(1)&&l+4<=O)return(o=I(f,l+4,d).times(.25)).s=a.s,o}else{if(!a.s)return new f(NaN);if(l+4<=O)return(o=I(f,l+4,d).times(.5)).s=a.s,o}for(f.precision=u=l+10,f.rounding=1,e=t=Math.min(28,u/7+2|0);e;--e)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(w=!1,n=Math.ceil(u/7),r=1,c=a.times(a),o=new f(a),i=a;-1!==e;)if(i=i.times(c),s=o.minus(i.div(r+=2)),i=i.times(c),void 0!==(o=s.plus(i.div(r+=2))).d[n])for(e=n;o.d[e]===s.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),w=!0,A(o,f.precision=l,f.rounding=d,!0)},q.isFinite=function(){return!!this.d},q.isInteger=q.isInt=function(){return!!this.d&&b(this.e/7)>this.d.length-2},q.isNaN=function(){return!this.s},q.isNegative=q.isNeg=function(){return this.s<0},q.isPositive=q.isPos=function(){return this.s>0},q.isZero=function(){return!!this.d&&0===this.d[0]},q.lessThan=q.lt=function(e){return this.cmp(e)<0},q.lessThanOrEqualTo=q.lte=function(e){return this.cmp(e)<1},q.logarithm=q.log=function(e){var n,t,r,i,s,o,u,c,a=this.constructor,f=a.precision,l=a.rounding;if(null==e)e=new a(10),n=!0;else{if(t=(e=new a(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new a(NaN);n=e.eq(10)}if(t=this.d,this.s<0||!t||!t[0]||this.eq(1))return new a(t&&!t[0]?-1/0:1!=this.s?NaN:t?0:1/0);if(n)if(t.length>1)s=!0;else{for(i=t[0];i%10==0;)i/=10;s=1!==i}if(w=!1,o=G(this,u=f+5),r=n?k(a,u+10):G(e,u),F((c=P(o,r,u,1)).d,i=f,l))do{if(o=G(this,u+=10),r=n?k(a,u+10):G(e,u),c=P(o,r,u,1),!s){+D(c.d).slice(i+1,i+15)+1==1e14&&(c=A(c,f+1,0));break}}while(F(c.d,i+=10,l));return w=!0,A(c,f,l)},q.minus=q.sub=function(e){var n,t,r,i,s,o,u,c,a,f,l,d,h=this,g=h.constructor;if(e=new g(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new g(e.d||h.s!==e.s?h:NaN):e=new g(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(d=e.d,u=g.precision,c=g.rounding,!(a=h.d)[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!a[0])return new g(3===c?-0:0);e=new g(h)}return w?A(e,u,c):e}if(t=b(e.e/7),f=b(h.e/7),a=a.slice(),s=f-t){for((l=s<0)?(n=a,s=-s,o=d.length):(n=d,t=f,o=a.length),s>(r=Math.max(Math.ceil(u/7),o)+2)&&(s=r,n.length=1),n.reverse(),r=s;r--;)n.push(0);n.reverse()}else{for((l=(r=a.length)<(o=d.length))&&(o=r),r=0;r<o;r++)if(a[r]!=d[r]){l=a[r]<d[r];break}s=0}for(l&&(n=a,a=d,d=n,e.s=-e.s),r=d.length-(o=a.length);r>0;--r)a[o++]=0;for(r=d.length;r>s;){if(a[--r]<d[r]){for(i=r;i&&0===a[--i];)a[i]=_-1;--a[i],a[r]+=_}a[r]-=d[r]}for(;0===a[--o];)a.pop();for(;0===a[0];a.shift())--t;return a[0]?(e.d=a,e.e=Z(a,t),w?A(e,u,c):e):new g(3===c?-0:0)},q.modulo=q.mod=function(e){var n,t=this,r=t.constructor;return e=new r(e),!t.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||t.d&&!t.d[0]?A(new r(t),r.precision,r.rounding):(w=!1,9==r.modulo?(n=P(t,e.abs(),0,3,1)).s*=e.s:n=P(t,e,0,r.modulo,1),n=n.times(e),w=!0,t.minus(n))},q.naturalExponential=q.exp=function(){return V(this)},q.naturalLogarithm=q.ln=function(){return G(this)},q.negated=q.neg=function(){var e=new this.constructor(this);return e.s=-e.s,A(e)},q.plus=q.add=function(e){var n,t,r,i,s,o,u,c,a,f,l=this,d=l.constructor;if(e=new d(e),!l.d||!e.d)return l.s&&e.s?l.d||(e=new d(e.d||l.s===e.s?l:NaN)):e=new d(NaN),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(f=e.d,u=d.precision,c=d.rounding,!(a=l.d)[0]||!f[0])return f[0]||(e=new d(l)),w?A(e,u,c):e;if(s=b(l.e/7),r=b(e.e/7),a=a.slice(),i=s-r){for(i<0?(t=a,i=-i,o=f.length):(t=f,r=s,o=a.length),i>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for((o=a.length)-(i=f.length)<0&&(i=o,t=f,f=a,a=t),n=0;i;)n=(a[--i]=a[i]+f[i]+n)/_|0,a[i]%=_;for(n&&(a.unshift(n),++r),o=a.length;0==a[--o];)a.pop();return e.d=a,e.e=Z(a,r),w?A(e,u,c):e},q.precision=q.sd=function(e){var n,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(v+e);return t.d?(n=U(t.d),e&&t.e+1>n&&(n=t.e+1)):n=NaN,n},q.round=function(){var e=this,n=e.constructor;return A(new n(e),e.e+1,n.rounding)},q.sine=q.sin=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.rounding,r.precision=(e=r.precision)+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,n){var t,r=n.d.length;if(r<3)return K(e,2,n,n);t=1.4*Math.sqrt(r),n=K(e,2,n=n.times(1/Q(5,t=t>16?16:0|t)),n);for(var i,s=new e(5),o=new e(16),u=new e(20);t--;)i=n.times(n),n=n.times(s.plus(i.times(o.times(i).minus(u))));return n}(r,X(r,t)),r.precision=e,r.rounding=n,A(o>2?t.neg():t,e,n,!0)):new r(NaN)},q.squareRoot=q.sqrt=function(){var e,n,t,r,i,s,o=this,u=o.d,c=o.e,a=o.s,f=o.constructor;if(1!==a||!u||!u[0])return new f(!a||a<0&&(!u||u[0])?NaN:u?o:1/0);for(w=!1,0==(a=Math.sqrt(+o))||a==1/0?(((n=D(u)).length+c)%2==0&&(n+="0"),a=Math.sqrt(n),c=b((c+1)/2)-(c<0||c%2),r=new f(n=a==1/0?"5e"+c:(n=a.toExponential()).slice(0,n.indexOf("e")+1)+c)):r=new f(a.toString()),t=(c=f.precision)+3;;)if(r=(s=r).plus(P(o,s,t+2,1)).times(.5),D(s.d).slice(0,t)===(n=D(r.d)).slice(0,t)){if("9999"!=(n=n.slice(t-3,t+1))&&(i||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(A(r,c+1,1),e=!r.times(r).eq(o));break}if(!i&&(A(s,c+1,0),s.times(s).eq(o))){r=s;break}t+=4,i=1}return w=!0,A(r,c,f.rounding,e)},q.tangent=q.tan=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.rounding,r.precision=(e=r.precision)+10,r.rounding=1,(t=t.sin()).s=1,t=P(t,new r(1).minus(t.times(t)).sqrt(),e+10,0),r.precision=e,r.rounding=n,A(2==o||4==o?t.neg():t,e,n,!0)):new r(NaN)},q.times=q.mul=function(e){var n,t,r,i,s,o,u,c,a,f=this,l=f.constructor,d=f.d,h=(e=new l(e)).d;if(e.s*=f.s,!(d&&d[0]&&h&&h[0]))return new l(!e.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*e.s:e.s/0);for(t=b(f.e/7)+b(e.e/7),(c=d.length)<(a=h.length)&&(s=d,d=h,h=s,o=c,c=a,a=o),s=[],r=o=c+a;r--;)s.push(0);for(r=a;--r>=0;){for(n=0,i=c+r;i>r;)u=s[i]+h[r]*d[i-r-1]+n,s[i--]=u%_|0,n=u/_|0;s[i]=(s[i]+n)%_|0}for(;!s[--o];)s.pop();return n?++t:s.shift(),e.d=s,e.e=Z(s,t),w?A(e,l.precision,l.rounding):e},q.toBinary=function(e,n){return Y(this,2,e,n)},q.toDecimalPlaces=q.toDP=function(e,n){var t=this,r=t.constructor;return t=new r(t),void 0===e?t:(S(e,0,1e9),void 0===n?n=r.rounding:S(n,0,8),A(t,e+t.e+1,n))},q.toExponential=function(e,n){var t,r=this,i=r.constructor;return void 0===e?t=R(r,!0):(S(e,0,1e9),void 0===n?n=i.rounding:S(n,0,8),t=R(r=A(new i(r),e+1,n),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+t:t},q.toFixed=function(e,n){var t,r,i=this,s=i.constructor;return void 0===e?t=R(i):(S(e,0,1e9),void 0===n?n=s.rounding:S(n,0,8),t=R(r=A(new s(i),e+i.e+1,n),!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},q.toFraction=function(e){var n,t,r,i,s,o,u,c,a,f,l,d,h=this,g=h.d,p=h.constructor;if(!g)return new p(h);if(a=t=new p(1),r=c=new p(0),s=(n=new p(r)).e=U(g)-h.e-1,n.d[0]=N(10,(o=s%7)<0?7+o:o),null==e)e=s>0?n:a;else{if(!(u=new p(e)).isInt()||u.lt(a))throw Error(v+u);e=u.gt(n)?s>0?n:a:u}for(w=!1,u=new p(D(g)),f=p.precision,p.precision=s=7*g.length*2;l=P(u,n,0,1,1),1!=(i=t.plus(l.times(r))).cmp(e);)t=r,r=i,a=c.plus(l.times(i=a)),c=i,n=u.minus(l.times(i=n)),u=i;return i=P(e.minus(t),r,0,1,1),c=c.plus(i.times(a)),t=t.plus(i.times(r)),c.s=a.s=h.s,d=P(a,r,s,1).minus(h).abs().cmp(P(c,t,s,1).minus(h).abs())<1?[a,r]:[c,t],p.precision=f,w=!0,d},q.toHexadecimal=q.toHex=function(e,n){return Y(this,16,e,n)},q.toNearest=function(e,n){var t=this,r=t.constructor;if(t=new r(t),null==e){if(!t.d)return t;e=new r(1),n=r.rounding}else{if(e=new r(e),void 0===n?n=r.rounding:S(n,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(w=!1,t=P(t,e,0,n,1).times(e),w=!0,A(t)):(e.s=t.s,t=e),t},q.toNumber=function(){return+this},q.toOctal=function(e,n){return Y(this,8,e,n)},q.toPower=q.pow=function(e){var n,t,r,i,s,o,u=this,c=u.constructor,a=+(e=new c(e));if(!(u.d&&e.d&&u.d[0]&&e.d[0]))return new c(N(+u,a));if((u=new c(u)).eq(1))return u;if(r=c.precision,s=c.rounding,e.eq(1))return A(u,r,s);if((n=b(e.e/7))>=e.d.length-1&&(t=a<0?-a:a)<=9007199254740991)return i=j(c,u,t,r),e.s<0?new c(1).div(i):A(i,r,s);if((o=u.s)<0){if(n<e.d.length-1)return new c(NaN);if(0==(1&e.d[n])&&(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(n=0!=(t=N(+u,a))&&isFinite(t)?new c(t+"").e:b(a*(Math.log("0."+D(u.d))/Math.LN10+u.e+1)))>c.maxE+1||n<c.minE-1?new c(n>0?o/0:0):(w=!1,c.rounding=u.s=1,t=Math.min(12,(n+"").length),(i=V(e.times(G(u,r+t)),r)).d&&F((i=A(i,r+5,1)).d,r,s)&&+D((i=A(V(e.times(G(u,(n=r+10)+t)),n),n+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=A(i,r+1,0)),i.s=o,w=!0,c.rounding=s,A(i,r,s))},q.toPrecision=function(e,n){var t,r=this,i=r.constructor;return void 0===e?t=R(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(S(e,1,1e9),void 0===n?n=i.rounding:S(n,0,8),t=R(r=A(new i(r),e,n),e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+t:t},q.toSignificantDigits=q.toSD=function(e,n){var t=this.constructor;return void 0===e?(e=t.precision,n=t.rounding):(S(e,1,1e9),void 0===n?n=t.rounding:S(n,0,8)),A(new t(this),e,n)},q.toString=function(){var e=this,n=e.constructor,t=R(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},q.truncated=q.trunc=function(){return A(new this.constructor(this),this.e+1,1)},q.valueOf=q.toJSON=function(){var e=this,n=e.constructor,t=R(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+t:t};var P=function(){function e(e,n,t){var r,i=0,s=e.length;for(e=e.slice();s--;)e[s]=(r=e[s]*n+i)%t|0,i=r/t|0;return i&&e.unshift(i),e}function n(e,n,t,r){var i,s;if(t!=r)s=t>r?1:-1;else for(i=s=0;i<t;i++)if(e[i]!=n[i]){s=e[i]>n[i]?1:-1;break}return s}function t(e,n,t,r){for(var i=0;t--;)e[t]-=i,e[t]=(i=e[t]<n[t]?1:0)*r+e[t]-n[t];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,u,c,a){var f,l,d,h,g,p,m,w,v,N,y,E,x,T,M,O,q,D,S,F,B=r.constructor,P=r.s==i.s?1:-1,R=r.d,Z=i.d;if(!(R&&R[0]&&Z&&Z[0]))return new B(r.s&&i.s&&(R?!Z||R[0]!=Z[0]:Z)?R&&0==R[0]||!Z?0*P:P/0:NaN);for(a?(g=1,l=r.e-i.e):(a=_,l=b(r.e/(g=7))-b(i.e/g)),S=Z.length,q=R.length,N=(v=new B(P)).d=[],d=0;Z[d]==(R[d]||0);d++);if(Z[d]>(R[d]||0)&&l--,null==o?(T=o=B.precision,u=B.rounding):T=c?o+(r.e-i.e)+1:o,T<0)N.push(1),p=!0;else{if(T=T/g+2|0,d=0,1==S){for(h=0,Z=Z[0],T++;(d<q||h)&&T--;d++)N[d]=(M=h*a+(R[d]||0))/Z|0,h=M%Z|0;p=h||d<q}else{for((h=a/(Z[0]+1)|0)>1&&(Z=e(Z,h,a),R=e(R,h,a),S=Z.length,q=R.length),O=S,E=(y=R.slice(0,S)).length;E<S;)y[E++]=0;(F=Z.slice()).unshift(0),D=Z[0],Z[1]>=a/2&&++D;do{h=0,(f=n(Z,y,S,E))<0?(x=y[0],S!=E&&(x=x*a+(y[1]||0)),(h=x/D|0)>1?(h>=a&&(h=a-1),1==(f=n(m=e(Z,h,a),y,w=m.length,E=y.length))&&(h--,t(m,S<w?F:Z,w,a))):(0==h&&(f=h=1),m=Z.slice()),(w=m.length)<E&&m.unshift(0),t(y,m,E,a),-1==f&&(f=n(Z,y,S,E=y.length))<1&&(h++,t(y,S<E?F:Z,E,a)),E=y.length):0===f&&(h++,y=[0]),N[d++]=h,f&&y[0]?y[E++]=R[O]||0:(y=[R[O]],E=1)}while((O++<q||void 0!==y[0])&&T--);p=void 0!==y[0]}N[0]||N.shift()}if(1==g)v.e=l,s=p;else{for(d=1,h=N[0];h>=10;h/=10)d++;v.e=d+l*g-1,A(v,c?o+v.e+1:o,u,p)}return v}}();function A(e,n,t,r){var i,s,o,u,c,a,f,l,d,h=e.constructor;e:if(null!=n){if(!(l=e.d))return e;for(i=1,u=l[0];u>=10;u/=10)i++;if((s=n-i)<0)s+=7,c=(f=l[d=0])/N(10,i-(o=n)-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(u=l.length)){if(!r)break e;for(;u++<=d;)l.push(0);f=c=0,i=1,o=(s%=7)-7+1}else{for(f=u=l[d],i=1;u>=10;u/=10)i++;c=(o=(s%=7)-7+i)<0?0:f/N(10,i-o-1)%10|0}if(r=r||n<0||void 0!==l[d+1]||(o<0?f:f%N(10,i-o-1)),a=t<4?(c||r)&&(0==t||t==(e.s<0?3:2)):c>5||5==c&&(4==t||r||6==t&&(s>0?o>0?f/N(10,i-o):0:l[d-1])%10&1||t==(e.s<0?8:7)),n<1||!l[0])return l.length=0,a?(l[0]=N(10,(7-(n-=e.e+1)%7)%7),e.e=-n||0):l[0]=e.e=0,e;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=N(10,7-s),l[d]=o>0?(f/N(10,i-o)%N(10,o)|0)*u:0),a)for(;;){if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(e.e++,l[0]==_&&(l[0]=1));break}if(l[d]+=u,l[d]!=_)break;l[d--]=0,u=1}for(s=l.length;0===l[--s];)l.pop()}return w&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e<h.minE&&(e.e=0,e.d=[0])),e}function R(e,n,t){if(!e.isFinite())return z(e);var r,i=e.e,s=D(e.d),o=s.length;return n?(t&&(r=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+L(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+L(-i-1)+s,t&&(r=t-o)>0&&(s+=L(r))):i>=o?(s+=L(i+1-o),t&&(r=t-i-1)>0&&(s=s+"."+L(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-o)>0&&(i+1===o&&(s+="."),s+=L(r))),s}function Z(e,n){var t=e[0];for(n*=7;t>=10;t/=10)n++;return n}function k(e,n,t){if(n>M)throw w=!0,t&&(e.precision=t),Error("[DecimalError] Precision limit exceeded");return A(new e(g),n,1,!0)}function I(e,n,t){if(n>O)throw Error("[DecimalError] Precision limit exceeded");return A(new e(p),n,t,!0)}function U(e){var n=e.length-1,t=7*n+1;if(n=e[n]){for(;n%10==0;n/=10)t--;for(n=e[0];n>=10;n/=10)t++}return t}function L(e){for(var n="";e--;)n+="0";return n}function j(e,n,t,r){var i,s=new e(1),o=Math.ceil(r/7+4);for(w=!1;;){if(t%2&&$((s=s.times(n)).d,o)&&(i=!0),0===(t=b(t/2))){t=s.d.length-1,i&&0===s.d[t]&&++s.d[t];break}$((n=n.times(n)).d,o)}return w=!0,s}function H(e){return 1&e.d[e.d.length-1]}function C(e,n,t){for(var r,i=new e(n[0]),s=0;++s<n.length;){if(!(r=new e(n[s])).s){i=r;break}i[t](r)&&(i=r)}return i}function V(e,n){var t,r,i,s,o,u,c,a=0,f=0,l=0,d=e.constructor,h=d.rounding,g=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==n?(w=!1,c=g):c=n,u=new d(.03125);e.e>-2;)e=e.times(u),l+=5;for(c+=r=Math.log(N(2,l))/Math.LN10*2+5|0,t=s=o=new d(1),d.precision=c;;){if(s=A(s.times(e),c,1),t=t.times(++f),D((u=o.plus(P(s,t,c,1))).d).slice(0,c)===D(o.d).slice(0,c)){for(i=l;i--;)o=A(o.times(o),c,1);if(null!=n)return d.precision=g,o;if(!(a<3&&F(o.d,c-r,h,a)))return A(o,d.precision=g,h,w=!0);d.precision=c+=10,t=s=u=new d(1),f=0,a++}o=u}}function G(e,n){var t,r,i,s,o,u,c,a,f,l,d,h=1,g=e,p=g.d,m=g.constructor,v=m.rounding,b=m.precision;if(g.s<0||!p||!p[0]||!g.e&&1==p[0]&&1==p.length)return new m(p&&!p[0]?-1/0:1!=g.s?NaN:p?0:g);if(null==n?(w=!1,f=b):f=n,m.precision=f+=10,r=(t=D(p)).charAt(0),!(Math.abs(s=g.e)<15e14))return a=k(m,f+2,b).times(s+""),g=G(new m(r+"."+t.slice(1)),f-10).plus(a),m.precision=b,null==n?A(g,b,v,w=!0):g;for(;r<7&&1!=r||1==r&&t.charAt(1)>3;)r=(t=D((g=g.times(e)).d)).charAt(0),h++;for(s=g.e,r>1?(g=new m("0."+t),s++):g=new m(r+"."+t.slice(1)),l=g,c=o=g=P(g.minus(1),g.plus(1),f,1),d=A(g.times(g),f,1),i=3;;){if(o=A(o.times(d),f,1),D((a=c.plus(P(o,new m(i),f,1))).d).slice(0,f)===D(c.d).slice(0,f)){if(c=c.times(2),0!==s&&(c=c.plus(k(m,f+2,b).times(s+""))),c=P(c,new m(h),f,1),null!=n)return m.precision=b,c;if(!F(c.d,f-10,v,u))return A(c,m.precision=b,v,w=!0);m.precision=f+=10,a=o=g=P(l.minus(1),l.plus(1),f,1),d=A(g.times(g),f,1),i=u=1}c=a,i+=2}}function z(e){return String(e.s*e.s/0)}function J(e,n){var t,r,i;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(r=n.search(/e/i))>0?(t<0&&(t=r),t+=+n.slice(r+1),n=n.substring(0,r)):t<0&&(t=n.length),r=0;48===n.charCodeAt(r);r++);for(i=n.length;48===n.charCodeAt(i-1);--i);if(n=n.slice(r,i)){if(i-=r,e.e=t=t-r-1,e.d=[],r=(t+1)%7,t<0&&(r+=7),r<i){for(r&&e.d.push(+n.slice(0,r)),i-=7;r<i;)e.d.push(+n.slice(r,r+=7));r=7-(n=n.slice(r)).length}else r-=i;for(;r--;)n+="0";e.d.push(+n),w&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function W(e,n){var t,r,i,s,o,u,c,a,f;if("Infinity"===n||"NaN"===n)return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(E.test(n))t=16,n=n.toLowerCase();else if(y.test(n))t=2;else{if(!x.test(n))throw Error(v+n);t=8}for((s=n.search(/p/i))>0?(c=+n.slice(s+1),n=n.substring(2,s)):n=n.slice(2),s=n.indexOf("."),r=e.constructor,(o=s>=0)&&(s=(u=(n=n.replace(".","")).length)-s,i=j(r,new r(t),s,2*s)),s=f=(a=B(n,t,_)).length-1;0===a[s];--s)a.pop();return s<0?new r(0*e.s):(e.e=Z(a,f),e.d=a,w=!1,o&&(e=P(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?N(2,c):Ie.pow(2,c))),w=!0,e)}function K(e,n,t,r,i){var s,o,u,c,a=e.precision,f=Math.ceil(a/7);for(w=!1,c=t.times(t),u=new e(r);;){if(o=P(u.times(c),new e(n++*n++),a,1),u=i?r.plus(o):r.minus(o),r=P(o.times(c),new e(n++*n++),a,1),void 0!==(o=u.plus(r)).d[f]){for(s=f;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=r,r=o,o=s}return w=!0,o.d.length=f+1,o}function Q(e,n){for(var t=e;--n;)t*=e;return t}function X(e,n){var t,r=n.s<0,i=I(e,e.precision,1),s=i.times(.5);if((n=n.abs()).lte(s))return o=r?4:1,n;if((t=n.divToInt(i)).isZero())o=r?3:2;else{if((n=n.minus(t.times(i))).lte(s))return o=H(t)?r?2:3:r?4:1,n;o=H(t)?r?1:4:r?3:2}return n.minus(i).abs()}function Y(e,n,t,r){var i,o,u,c,a,f,l,d,g,p=e.constructor,m=void 0!==t;if(m?(S(t,1,1e9),void 0===r?r=p.rounding:S(r,0,8)):(t=p.precision,r=p.rounding),e.isFinite()){for(m?(i=2,16==n?t=4*t-3:8==n&&(t=3*t-2)):i=n,(u=(l=R(e)).indexOf("."))>=0&&(l=l.replace(".",""),(g=new p(1)).e=l.length-u,g.d=B(R(g),10,i),g.e=g.d.length),o=a=(d=B(l,10,i)).length;0==d[--a];)d.pop();if(d[0]){if(u<0?o--:((e=new p(e)).d=d,e.e=o,d=(e=P(e,g,t,r,0,i)).d,o=e.e,f=s),u=d[t],c=i/2,f=f||void 0!==d[t+1],f=r<4?(void 0!==u||f)&&(0===r||r===(e.s<0?3:2)):u>c||u===c&&(4===r||f||6===r&&1&d[t-1]||r===(e.s<0?8:7)),d.length=t,f)for(;++d[--t]>i-1;)d[t]=0,t||(++o,d.unshift(1));for(a=d.length;!d[a-1];--a);for(u=0,l="";u<a;u++)l+=h.charAt(d[u]);if(m){if(a>1)if(16==n||8==n){for(u=16==n?4:3,--a;a%u;a++)l+="0";for(a=(d=B(l,i,n)).length;!d[a-1];--a);for(u=1,l="1.";u<a;u++)l+=h.charAt(d[u])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>a)for(o-=a;o--;)l+="0";else o<a&&(l=l.slice(0,o)+"."+l.slice(o))}else l=m?"0p+0":"0";l=(16==n?"0x":2==n?"0b":8==n?"0o":"")+l}else l=z(e);return e.s<0?"-"+l:l}function $(e,n){if(e.length>n)return e.length=n,!0}function ee(e){return new this(e).abs()}function ne(e){return new this(e).acos()}function te(e){return new this(e).acosh()}function re(e,n){return new this(e).plus(n)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function ce(e,n){e=new this(e),n=new this(n);var t,r=this.precision,i=this.rounding,s=r+4;return e.s&&n.s?e.d||n.d?!n.d||e.isZero()?(t=n.s<0?I(this,r,i):new this(0)).s=e.s:!e.d||n.isZero()?(t=I(this,s,1).times(.5)).s=e.s:n.s<0?(this.precision=s,this.rounding=1,t=this.atan(P(e,n,s,1)),n=I(this,s,1),this.precision=r,this.rounding=i,t=e.s<0?t.minus(n):t.plus(n)):t=this.atan(P(e,n,s,1)):(t=I(this,s,1).times(n.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function ae(e){return new this(e).cbrt()}function fe(e){return A(e=new this(e),e.e+1,2)}function le(e){if(!e||"object"!=typeof e)throw Error("[DecimalError] Object expected");var n,t,r,i=!0===e.defaults,s=["precision",1,1e9,"rounding",0,8,"toExpNeg",-d,0,"toExpPos",0,d,"maxE",0,d,"minE",-d,0,"modulo",0,9];for(n=0;n<s.length;n+=3)if(t=s[n],i&&(this[t]=m[t]),void 0!==(r=e[t])){if(!(b(r)===r&&r>=s[n+1]&&r<=s[n+2]))throw Error(v+t+": "+r);this[t]=r}if(t="crypto",i&&(this[t]=m[t]),void 0!==(r=e[t])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(v+t+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error("[DecimalError] crypto unavailable");this[t]=!0}else this[t]=!1}return this}function de(e){return new this(e).cos()}function he(e){return new this(e).cosh()}function ge(e,n){return new this(e).div(n)}function pe(e){return new this(e).exp()}function me(e){return A(e=new this(e),e.e+1,3)}function we(){var e,n,t=new this(0);for(w=!1,e=0;e<arguments.length;)if((n=new this(arguments[e++])).d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return w=!0,new this(1/0);t=n}return w=!0,t.sqrt()}function ve(e){return e instanceof Ie||e&&"[object Decimal]"===e.name||!1}function be(e){return new this(e).ln()}function Ne(e,n){return new this(e).log(n)}function ye(e){return new this(e).log(2)}function Ee(e){return new this(e).log(10)}function xe(){return C(this,arguments,"lt")}function Te(){return C(this,arguments,"gt")}function _e(e,n){return new this(e).mod(n)}function Me(e,n){return new this(e).mul(n)}function Oe(e,n){return new this(e).pow(n)}function qe(e){var n,t,r,i,s=0,o=new this(1),u=[];if(void 0===e?e=this.precision:S(e,1,1e9),r=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(r));s<r;)(i=n[s])>=429e7?n[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=i%1e7;else{if(!crypto.randomBytes)throw Error("[DecimalError] crypto unavailable");for(n=crypto.randomBytes(r*=4);s<r;)(i=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+((127&n[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(n,s):(u.push(i%1e7),s+=4);s=r/4}else for(;s<r;)u[s++]=1e7*Math.random()|0;for(e%=7,(r=u[--s])&&e&&(i=N(10,7-e),u[s]=(r/i|0)*i);0===u[s];s--)u.pop();if(s<0)t=0,u=[0];else{for(t=-1;0===u[0];t-=7)u.shift();for(r=1,i=u[0];i>=10;i/=10)r++;r<7&&(t-=7-r)}return o.e=t,o.d=u,o}function De(e){return A(e=new this(e),e.e+1,this.rounding)}function Se(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Fe(e){return new this(e).sin()}function Be(e){return new this(e).sinh()}function Pe(e){return new this(e).sqrt()}function Ae(e,n){return new this(e).sub(n)}function Re(e){return new this(e).tan()}function Ze(e){return new this(e).tanh()}function ke(e){return A(e=new this(e),e.e+1,1)}q[Symbol.for("nodejs.util.inspect.custom")]=q.toString,q[Symbol.toStringTag]="Decimal";var Ie=function e(n){var t,r,i;function s(e){var n,t,r,i=this;if(!(i instanceof s))return new s(e);if(i.constructor=s,e instanceof s)return i.s=e.s,void(w?!e.d||e.e>s.maxE?(i.e=NaN,i.d=null):e.e<s.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(r=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(n=0,t=e;t>=10;t/=10)n++;return void(w?n>s.maxE?(i.e=NaN,i.d=null):n<s.minE?(i.e=0,i.d=[0]):(i.e=n,i.d=[e]):(i.e=n,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):J(i,e.toString())}if("string"!==r)throw Error(v+e);return 45===(t=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===t&&(e=e.slice(1)),i.s=1),T.test(e)?J(i,e):W(i,e)}if(s.prototype=q,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=le,s.clone=e,s.isDecimal=ve,s.abs=ee,s.acos=ne,s.acosh=te,s.add=re,s.asin=ie,s.asinh=se,s.atan=oe,s.atanh=ue,s.atan2=ce,s.cbrt=ae,s.ceil=fe,s.cos=de,s.cosh=he,s.div=ge,s.exp=pe,s.floor=me,s.hypot=we,s.ln=be,s.log=Ne,s.log10=Ee,s.log2=ye,s.max=xe,s.min=Te,s.mod=_e,s.mul=Me,s.pow=Oe,s.random=qe,s.round=De,s.sign=Se,s.sin=Fe,s.sinh=Be,s.sqrt=Pe,s.sub=Ae,s.tan=Re,s.tanh=Ze,s.trunc=ke,void 0===n&&(n={}),n&&!0!==n.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)n.hasOwnProperty(r=i[t++])||(n[r]=this[r]);return s.config(n),s}(m);g=new Ie(g),p=new Ie(p);var Ue,Le,je=(Ue={__proto__:null,Decimal:Ie,default:Ie})&&Ue.default||Ue,He=function(e,n){return function(e,n){var t=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n._62To10=n._36To10=n._32To10=n._16To10=n._8To10=n._2To10=n._10To62=n._10To36=n._10To32=n._10To16=n._10To8=n._10To2=n.convertBase=void 0;const r=t(je);r.default.set({precision:1e9}),r.default.set({toExpPos:9e15});const i=(e,n,t)=>{const i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";if("number"!=typeof e&&"string"!=typeof e||"number"==typeof e&&!isFinite(e))throw new Error("First augument must be a number or string.");if("number"==typeof e&&(e=e.toString()),"number"!=typeof n&&"string"!=typeof n)throw new Error("Second augument must be a number or string.");if("number"==typeof n){if(!Number.isInteger(n))throw new Error("Second augument must be integer.");if(!(2<=n&&n<=62))throw new Error("Second augument must be between 2 and 62.");n=i.substr(0,n)}if(n.length<=1)throw new Error("Second augument' length must be larger than 1. Base 1 or smaller cannnot be defined.");if(n.length!==new Set(n).size)throw new Error("Second augument must not contain the same characters.");if(!new RegExp("^["+n+"]+$").test(e))throw new Error("First augument must consist of second augument.");if("number"!=typeof t&&"string"!=typeof t)throw new Error("Third augument must be a number or string.");if("number"==typeof t){if(!Number.isInteger(t))throw new Error("Third augument must be integer.");if(!(2<=t&&t<=62))throw new Error("Third augument must be between 2 and 62.");t=i.substr(0,t)}if(t.length<=1)throw new Error("Third augument' length must be larger than 1. Base 1 or smaller cannnot be defined.");if(t.length!==new Set(t).size)throw new Error("Third augument must not contain the same characters.");return((e,n)=>{const t=[];let i=new r.default(e);const s=new r.default(n.length);for(;!i.isZero();){const e=i.mod(s).toNumber();i=i.dividedToIntegerBy(s),t.unshift(n.substr(e,1))}return 0===t.length&&t.unshift("0"),t.join("")})(((e,n)=>{const t={};for(let e=0;e<n.length;e++)t[n.substr(e,1)]=new r.default(e);const i=new r.default(n.length);let s=new r.default(0);for(let n=0;n<e.length;n++){const o=t[e.substr(-1*(n+1),1)],u=r.default.pow(i,n),c=o.times(u);s=s.plus(c)}return s.toString()})(e,n),t)};n.convertBase=i,n._10To2=e=>i(e,10,2),n._10To8=e=>i(e,10,8),n._10To16=e=>i(e,10,16),n._10To32=e=>i(e,10,32),n._10To36=e=>i(e,10,36),n._10To62=e=>i(e,10,62),n._2To10=e=>i(e,2,10),n._8To10=e=>i(e,8,10),n._16To10=e=>i(e,16,10),n._32To10=e=>i(e,32,10),n._36To10=e=>i(e,36,10),n._62To10=e=>i(e,62,10)}(n={exports:{}},n.exports),n.exports}();(Le=He)&&Le.__esModule&&Object.prototype.hasOwnProperty.call(Le,"default");var Ce=He.convertBase;e.alphabets=t,e.counterIDGenerator=r,e.gramIdentityPlugin=function(e){var t=n({},a,e);return function(e){var n;switch(t.generator){case"nanoid":n=u(t.alphabet,21,t.prefix);break;case"counter":default:n=r(t.prefix)}c(e,(function(e){var t;(t=e).type&&"path"===t.type&&(e.id=e.id||n.generate())}))}},e.nanoidGenerator=u,e.shortUUIDGenerator=function(e,n){return f(e,n)},e.simpleBaseIDGenerator=function(e,n){void 0===e&&(e=t.crock32);var r=BigInt(1),i=BigInt(0);return{generate:function(){var t=Ce(i.toString(),10,e);return i+=r,n?n+t:t}}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-identity.umd.production.min.js.map |
import gramIdentityPlugin from './gram-identity-plugin'; | ||
export * from './gram-identity'; | ||
export * from './shortuuid-generator'; | ||
export * from './counter-generator'; | ||
export * from './nanoid-generator'; | ||
export * from './simple-base-generator'; | ||
export { gramIdentityPlugin }; |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"license": "MIT", | ||
@@ -30,4 +30,4 @@ "repository": { | ||
"test:watch": "tsdx test --watch", | ||
"lint": "tsdx lint", | ||
"lint:fix": "tsdx lint --fix", | ||
"lint": "tsdx lint src", | ||
"lint:fix": "tsdx lint src --fix", | ||
"build:demo": "shx cp dist/gram-identity.umd.development.* ./public", | ||
@@ -41,3 +41,3 @@ "demo": "serve ./public/", | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
"pre-commit": "tsdx lint src" | ||
} | ||
@@ -54,3 +54,3 @@ }, | ||
"devDependencies": { | ||
"@gram-data/gram-parse": "^0.2.11", | ||
"@gram-data/gram-parse": "^0.2.12", | ||
"@types/jest": "^26.0.15", | ||
@@ -72,4 +72,10 @@ "@types/shortid": "^0.0.29", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.2.11", | ||
"@gram-data/gram-ast": "^0.2.12", | ||
"base-x": "^3.0.8", | ||
"bigint-buffer": "^1.1.5", | ||
"nanoid": "^3.1.18", | ||
"power-radix": "^2.5.6", | ||
"short-uuid": "^4.1.0", | ||
"shortid": "^2.2.16", | ||
"simple-base-converter": "^1.0.5", | ||
"unified": "^9.2.0", | ||
@@ -82,3 +88,3 @@ "unist-util-visit": "^2.0.3", | ||
}, | ||
"gitHead": "23013fdd8af755746f936dd4c01b165b90c477d7" | ||
"gitHead": "7f663c601c2fcd63f180bcd817d107e9cd5f29ee" | ||
} |
@@ -7,30 +7,41 @@ import { Plugin, Transformer } from 'unified'; | ||
import { isGramPath } from '@gram-data/gram-ast'; | ||
import { shortID } from './gram-identity'; | ||
import { alphabets, IDGenerator } from './gram-identity'; | ||
import { counterIDGenerator } from './counter-generator'; | ||
import { nanoidGenerator } from './nanoid-generator'; | ||
const visit = require('unist-util-visit'); | ||
interface IdentityPluginSettings { | ||
kind?: 'numeric' | 'shortid'; | ||
generator: 'counter' | 'nanoid', | ||
alphabet?: string, | ||
prefix?: string, | ||
} | ||
const defaultSettings: IdentityPluginSettings = { | ||
kind: 'numeric', | ||
}; | ||
const defaultSettings = { | ||
generator: 'counter', | ||
alphabet: alphabets.base58, | ||
prefix: undefined | ||
} | ||
const gramIdentityPlugin: Plugin<IdentityPluginSettings[]> = ( | ||
s: IdentityPluginSettings = defaultSettings | ||
settings: IdentityPluginSettings | ||
) => { | ||
const mergedSettings = { ...defaultSettings, ...s }; | ||
const s = {...defaultSettings, ...settings}; | ||
const identification: Transformer = (tree: UnistNode) => { | ||
let counter = 0; | ||
let generator:IDGenerator; | ||
switch (s.generator) { | ||
case 'nanoid': | ||
generator = nanoidGenerator(s.alphabet, 21, s.prefix) | ||
break; | ||
case 'counter': | ||
default: | ||
generator = counterIDGenerator(s.prefix); | ||
} | ||
visit(tree, (element: UnistNode) => { | ||
if (isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
case 'numeric': | ||
element.id = element.id || `${counter++}`; | ||
break; | ||
case 'shortid': | ||
element.id = element.id || shortID(); | ||
break; | ||
} | ||
element.id = element.id || generator.generate(); | ||
} | ||
@@ -37,0 +48,0 @@ }); |
@@ -1,25 +0,29 @@ | ||
const shortid = require('shortid'); | ||
export const alphabets = { | ||
base2: '01', | ||
base8: '01234567', | ||
base10: '0123456789', | ||
base11: '0123456789a', | ||
base16: '0123456789abcdef', | ||
base32: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', | ||
zBase32: 'ybndrfg8ejkmcpqxot1uwisza345h769', | ||
crock32: '0123456789ABCDEFGHJKMNPQRSTVWXYZ', | ||
base32Hex: '0123456789ABCDEFGHIJKLMNOPQRSTUV', | ||
base36: '0123456789abcdefghijklmnopqrstuvwxyz', | ||
base58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
base62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@', | ||
}; | ||
base2: '01', | ||
dieBase6: '⚀⚁⚂⚃⚄⚅', | ||
base8: '01234567', | ||
base10: '0123456789', | ||
astrologyBase12: '♈︎♉︎♊︎♋︎♌︎♍︎♎︎♏︎♐︎♑︎♒︎♓︎', | ||
base11: '0123456789a', | ||
chessBase12: '♚♛♜♝♞♟♔♕♖♗♘♙', | ||
base16: '0123456789abcdef', | ||
dominoBase28: '🁣🁤🁫🁥🁬🁳🁦🁭🁴🁻🁧🁮🁵🁼🂃🁨🁯🁶🁽🂊🂋🁩🁰🁷🁾🂅🂌🂓', | ||
base32: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', | ||
zBase32: 'ybndrfg8ejkmcpqxot1uwisza345h769', | ||
crock32: '0123456789ABCDEFGHJKMNPQRSTVWXYZ', | ||
base32Hex: '0123456789ABCDEFGHIJKLMNOPQRSTUV', | ||
base36: '0123456789abcdefghijklmnopqrstuvwxyz', | ||
mahjongBase43: '🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀇🀈🀉🀊🀋🀌🀍🀎🀏🀀🀁🀂🀃🀄︎🀅🀆🀐🀢🀣🀤🀥🀦🀧🀨🀩🀪', | ||
cards56: '🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🂮🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽🂾🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🃎🃑🃒🃓🃔🃕🃖🃗🃘🃙🃝🃞', | ||
base58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
flickrBase58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', | ||
base62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
base64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@', | ||
cookieBase90: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~", | ||
}; | ||
export type IDGenerator = { | ||
generate: () => string | ||
} | ||
shortid.characters(alphabets.base64); | ||
/** | ||
* Identifier function which produces a pseudo-random, short identifier. | ||
* | ||
*/ | ||
export const shortID = shortid.generate; |
import gramIdentityPlugin from './gram-identity-plugin'; | ||
export * from './gram-identity'; | ||
export * from './shortuuid-generator'; | ||
export * from './counter-generator'; | ||
export * from './nanoid-generator'; | ||
export * from './simple-base-generator'; | ||
export { gramIdentityPlugin }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
728121
30
4989
11
5
1
+ Addedbase-x@^3.0.8
+ Addedbigint-buffer@^1.1.5
+ Addednanoid@^3.1.18
+ Addedpower-radix@^2.5.6
+ Addedshort-uuid@^4.1.0
+ Addedsimple-base-converter@^1.0.5
+ Addedany-base@1.1.0(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbigi@1.4.2(transitive)
+ Addedbigint-buffer@1.1.5(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddecimal.js@10.5.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpower-radix@2.5.6(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedshort-uuid@4.2.2(transitive)
+ Addedsimple-base-converter@1.0.19(transitive)
+ Addeduuid@8.3.2(transitive)
Updated@gram-data/gram-ast@^0.2.12